Bug 506596

Summary: arch_prctl ARCH_SET_CPUID/ARCH_GET_CPUID don't work
Product: [Developer tools] valgrind Reporter: Mark Wielaard <mark>
Component: generalAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 506971    

Description Mark Wielaard 2025-07-04 17:26:06 UTC
The ltp arch_prctl01 test fails:

Command: ./auxprogs/auxchecks/ltp-full-20250530/testcases/kernel/syscalls/arch_prctl/arch_prctl01
tst_test.c:1953: TINFO: LTP version: VALGRIND_3_25_0-71-gf89b54e8a601
tst_test.c:1956: TINFO: Tested kernel: 6.14.11-300.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 10 16:24:16 UTC 2025 x86_64
tst_kconfig.c:88: TINFO: Parsing kernel config '/lib/modules/6.14.11-300.fc42.x86_64/build/.config'
tst_test.c:1774: TINFO: Overall timeout per run is 0h 00m 30s
arch_prctl01.c:54: TFAIL: arch_prctl_set(ARCH_SET_CPUID, index) failed: EINVAL (22)
arch_prctl01.c:66: TFAIL: get wrong cpuid status
arch_prctl01.c:54: TFAIL: arch_prctl_set(ARCH_SET_CPUID, index) failed: EINVAL (22)
arch_prctl01.c:66: TFAIL: get wrong cpuid status

PRE(sys_arch_prctl) in coregrind/m_syswrap/syswrap-amd64-linux.c doesn't recognize ARCH_SET_CPUID and explicitly sets EINVAL.

ARCH_SET_CPUID enables or disables the cpuid instruction for the calling thread. If disabled trying to execute a cpuid instruction causes a SEGSEGV.

We would have to emulate that in VEX/priv/guest_amd64_toIR.c (and VEX/priv/guest_x86_toIR.c)