[LTP] [PATCH v3 0/2] Fix ptrace07 hardcoded xstate size issue

Pengfei Xu pengfei.xu@intel.com
Tue Oct 18 14:10:45 CEST 2022


Should not use a hardcoded xstate size(512 * 8 = 4096 bytes), and use maximum
XSAVE size specified by CPUID.(EAX=0DH, ECX=0H):EBX instead.
If the CPU's maximum XSAVE size exceeds the hard-coded xstate size 4096 bytes,
it will cause the ptrace07 case to break as below:
"
./ptrace07
tst_test.c:1528: TINFO: Timeout per run is 0h 00m 30s
ptrace07.c:142: TBROK: PTRACE_SETREGSET failed with unexpected error: EFAULT (14)
tst_test.c:1571: TINFO: Killed the leftover descendant processes

Summary:
passed   0
failed   0
broken   1
skipped  0
warnings 0
"

And there is no proper cpuid() function in LTP, so provides the cpuid()
function first in previous commit.

=========
v2 -> v3:
 - Thanks Richard Palethorpe's report, should not use old API cpuid function
   in LTP, and provide the __cpuid_count() function instead
 - Thanks Richard Palethorpe's suggestion, put __cpuid_count() in
   include/lapi/cpuid.h
 - Add the aligned_alloc() successfully check in ptrace07.c
 - Add the cpuid output check prints as Richard Palethorpe's suggestion


Pengfei Xu (2):
  cpuid.h: Provide the macro definition __cpuid_count()
  ptrace07: fix the broken case caused by hardcoded xstate size

 include/lapi/cpuid.h                        | 24 +++++++++++++++++
 testcases/kernel/syscalls/ptrace/ptrace07.c | 29 ++++++++++++++++++---
 2 files changed, 49 insertions(+), 4 deletions(-)
 create mode 100644 include/lapi/cpuid.h

-- 
2.31.1



More information about the ltp mailing list