Bug 235251

Summary: No way to override "nosegneg" hwcap bit
Product: [Fedora] Fedora Reporter: Will Woods <wwoods>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-05-21 15:33:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 230874    

Description Will Woods 2007-04-04 18:10:16 UTC
The Xen kernel uses an "extra" hwcap bit (the "nosegneg" bit) and 
/etc/ld.so.conf.d/kernelcap-*.conf to make ld.so use the libraries in
/lib/i686/nosegneg. 

Some circumstances (e.g. building a mkinitrd for a non-xen kernel while running
under xen, or vice-versa - see bug #230874) demand the ability to set or unset
these bits, but LD_HWCAP_MASK does not affect them. 

There should be an environment variable that ld.so honors, like LD_HWCAP_MASK,
that allows us to pass a mask/vector. (We'd probably also need the ability to
read that vector from an on-disk kernel image, but that's outside the scope of
glibc.)

Comment 1 Jakub Jelinek 2007-05-04 16:29:59 UTC
Adding support for this in LD_HWCAP_MASK is possible, but you'd still have hard
time to compute which bit you actually want to mask (as the bit for nosegneg
is derived from vDSO content).
I'd suggest just hardcoding this, like:
--- mkinitrd.jj 2007-04-16 17:55:39.000000000 -0400
+++ mkinitrd    2007-05-04 12:27:56.000000000 -0400
@@ -206,6 +206,20 @@ requires ${NAMES[$n]} n order to properl
 EOF
             exit 1
         fi
+       case "$FILE" in
+         /lib*)
+           LIBDIR=`echo "$FILE" | sed 's,\(/lib[^/]*\)/.*$,\1,'`
+           BASE=`basename "$FILE"`
+           # Prefer nosegneg libs over direct segment accesses on i686.
+           if [ -f "$LIBDIR/i686/nosegneg/$BASE" ]; then
+             FILE="$LIBDIR/i686/nosegneg/$BASE"
+           # Otherwise, prefer base libraries rather than their optimized
+           # variants.
+           elif [ -f "$LIBDIR/$BASE" ]; then
+             FILE="$LIBDIR/$BASE"
+           fi
+           ;;
+       esac
         dynamic="yes"
         let n++
     done
@@ -426,7 +440,12 @@ inst() {
             get_dso_deps "$file"
             local DEPS="$DSO_DEPS"
             for x in $DEPS ; do
-                inst "$x" "$root"
+               l=`echo "$x" | sed -n 's,\(/lib[^/]*\)/.*$,\1,p'`
+               if [ -n "$l" ]; then
+                 inst "$x" "$root" "$l"/`basename "$x"`
+               else
+                 inst "$x" "$root"
+               fi
             done
             RET=$?
         fi

Perhaps even extend the latter chunk, install all shared libraries into /lib{,64}
.  This would create initrd that is usable with any kernels.  If you want to
taylor it for xen vs. non-xen kernels, you can add/remove that i686/nosegneg
preference depending on it.

Comment 2 Peter Jones 2007-05-21 15:33:29 UTC
Fixed in mkinitrd-6.0.9-3 .