https://bugs.kde.org/show_bug.cgi?id=528631

--- Comment #5 from Martin Cermak <[email protected]> ---
Created attachment 198536
  --> https://bugs.kde.org/attachment.cgi?id=198536&action=edit
patch allowing to build libvirtcpuid on fedora 44

I've built libvirtcpuid (currently newest commit 3b549c7 from 2021) with the
attached patch. With that I can use libvirtcpuid to mask off cpu features:

$ cp /usr/bin/cpuid .
$ patchelf --set-interpreter $WORKDIR/ld-virtcpuid.so $WORKDIR/cpuid
$ LD_PRELOAD=$WORKDIR/libvirtcpuid.so VIRT_CPUID_MASK=sse4_1,sse4_2 ./cpuid -1 
| fgrep -i sse4
      SSE4.1 extensions                       = false
      SSE4.2 extensions                       = false
$ LD_PRELOAD=$WORKDIR/libvirtcpuid.so VIRT_CPUID_MASK=sse4_1 ./cpuid -1  |
fgrep -i sse4
      SSE4.1 extensions                       = false
      SSE4.2 extensions                       = true
$ LD_PRELOAD=$WORKDIR/libvirtcpuid.so VIRT_CPUID_MASK= ./cpuid -1  | fgrep -i
sse4
      SSE4.1 extensions                       = true
      SSE4.2 extensions                       = true
$

To double check that cpuid faulting using arch_prctl() works as expected:

$ strace -o /tmp/xxx -earch_prctl -E LD_PRELOAD=$WORKDIR/libvirtcpuid.so -E
VIRT_CPUID_MASK= ./cpuid -1 >/dev/null 
$ head /tmp/xxx 
arch_prctl(ARCH_SET_FS, 0x7f6c3274c508) = 0
arch_prctl(ARCH_GET_CPUID)              = 1
arch_prctl(ARCH_SET_CPUID, 0)           = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} ---
arch_prctl(ARCH_SET_CPUID, 0x1)         = 0
arch_prctl(ARCH_SET_CPUID, 0)           = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} ---
arch_prctl(ARCH_SET_CPUID, 0x1)         = 0
arch_prctl(ARCH_SET_CPUID, 0)           = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} ---
$

Here is how running the above modified cpuid program ends up with release
valgrind 3.27:

$ /usr/bin/valgrind -q ./cpuid -1 | fgrep -i sse4
libvirtcpuid: Failed to enable CPUID faulting: Invalid argument
$ 
$ /usr/bin/valgrind --version
valgrind-3.27.1
$

And finally here is how my valgrind path behaves (YAY!):

$ /usr/bin/valgrind -q ./cpuid -1 | fgrep -i sse4
libvirtcpuid: Failed to enable CPUID faulting: Invalid argument
$ 
$ $VG --version
valgrind-3.29.0.GIT
$ $VG -q ./cpuid -1 | fgrep -i sse4
==403616== Conditional jump or move depends on uninitialised value(s)
==403616==    at 0x4067B83: map_library (dynlink.c:773)
==403616==    by 0x4067D64: stage4 (loader.c:374)
==403616==    by 0x406861F: __dls3 (loader.c:327)
==403616==    by 0x4068345: __dls2 (dynlink.c:1650)
==403616==    by 0x40662FA: extend_bfs_deps (dynlink.c:1035)
==403616==    by 0x40662FA: ??? (dynlink.c:2049)
==403616==    by 0x1: ???
==403616==    by 0x1FFF000062: ???
==403616==    by 0x1FFF00006A: ??? 
==403616==
      SSE4.1 extensions                       = false
      SSE4.2 extensions                       = true
$ 

That said:  It's not 100% perfect, but ... not too bad :)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to