Bug 27398 - x86: Improve testing false positive for tst-cpu-features-cpuinfo with bad hardware.
Summary: x86: Improve testing false positive for tst-cpu-features-cpuinfo with bad har...
Status: RESOLVED MOVED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: 2.35
Assignee: H.J. Lu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-02-12 04:44 UTC by Siddhesh Poyarekar
Modified: 2022-05-02 10:42 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments
A patch (666 bytes, patch)
2022-01-14 22:57 UTC, H.J. Lu
Details | Diff
The v2 patch (597 bytes, patch)
2022-01-17 15:17 UTC, H.J. Lu
Details | Diff
The v3 patch (1.19 KB, patch)
2022-01-18 14:22 UTC, H.J. Lu
Details | Diff
The v4 patch (667 bytes, patch)
2022-01-18 16:32 UTC, H.J. Lu
Details | Diff
A patch for HLE (283 bytes, patch)
2022-01-25 18:41 UTC, H.J. Lu
Details | Diff
A patch for HLE (282 bytes, patch)
2022-01-25 18:42 UTC, H.J. Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Siddhesh Poyarekar 2021-02-12 04:44:31 UTC
The following tests fail sporadically on my machine:

Checking HAS_CPU_FEATURE (HLE):
  HAS_CPU_FEATURE (HLE): 1
  cpuinfo (hle): 0
 *** failure ***
--
Checking HAS_CPU_FEATURE (RTM):
  HAS_CPU_FEATURE (RTM): 1
  cpuinfo (rtm): 0
 *** failure ***

Whenever it succeeds, HAS_CPU_FEATURE is 0 in both cases but every once in a while it returns 1.

To reproduce:

while ./testrun.sh elf/tst-cpu-features-cpuinfo; do /bin/true; done

This exits on the first failed run.

My /proc/cpuinfo:

processor	: 7
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
stepping	: 12
microcode	: 0xde
cpu MHz		: 877.111
cache size	: 8192 KB
physical id	: 0
siblings	: 8
core id		: 3
cpu cores	: 4
apicid		: 7
initial apicid	: 7
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
vmx flags	: vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec
bugs		: spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit srbds
bogomips	: 4199.88
clflush size	: 64
cache_alignment	: 64
address sizes	: 39 bits physical, 48 bits virtual
power management:
Comment 1 Siddhesh Poyarekar 2021-02-12 04:52:35 UTC
The failures become deterministic and numerous (18 failures in all) when the test is run under valgrind.  That may have something to do with valgrind's emulation but noting it here anyway since it seems relevant.  Importantly, valgrind does not report any errors.

valgrind --trace-children=yes ./testrun.sh elf/tst-cpu-features-cpuinfo --direct

<valgrind output snipped since it does not report any errors>

Checking HAS_CPU_FEATURE (ACPI):
  HAS_CPU_FEATURE (ACPI): 1
  cpuinfo (acpi): 1
Checking HAS_CPU_FEATURE (ADX):
  HAS_CPU_FEATURE (ADX): 0
  cpuinfo (adx): 1
 *** failure ***
Checking HAS_CPU_FEATURE (APIC):
  HAS_CPU_FEATURE (APIC): 1
  cpuinfo (apic): 1
Checking HAS_CPU_FEATURE (AES):
  HAS_CPU_FEATURE (AES): 1
  cpuinfo (aes): 1
Checking HAS_CPU_FEATURE (AMX_BF16):
  HAS_CPU_FEATURE (AMX_BF16): 0
  cpuinfo (amx_bf16): 0
Checking HAS_CPU_FEATURE (AMX_INT8):
  HAS_CPU_FEATURE (AMX_INT8): 0
  cpuinfo (amx_int8): 0
Checking HAS_CPU_FEATURE (AMX_TILE):
  HAS_CPU_FEATURE (AMX_TILE): 0
  cpuinfo (amx_tile): 0
Checking HAS_CPU_FEATURE (ARCH_CAPABILITIES):
  HAS_CPU_FEATURE (ARCH_CAPABILITIES): 0
  cpuinfo (arch_capabilities): 1
 *** failure ***
Checking HAS_CPU_FEATURE (AVX):
  HAS_CPU_FEATURE (AVX): 1
  cpuinfo (avx): 1
Checking HAS_CPU_FEATURE (AVX2):
  HAS_CPU_FEATURE (AVX2): 1
  cpuinfo (avx2): 1
Checking HAS_CPU_FEATURE (AVX512_4FMAPS):
  HAS_CPU_FEATURE (AVX512_4FMAPS): 0
  cpuinfo (avx512_4fmaps): 0
Checking HAS_CPU_FEATURE (AVX512_4VNNIW):
  HAS_CPU_FEATURE (AVX512_4VNNIW): 0
  cpuinfo (avx512_4vnniw): 0
Checking HAS_CPU_FEATURE (AVX512_BF16):
  HAS_CPU_FEATURE (AVX512_BF16): 0
  cpuinfo (avx512_bf16): 0
Checking HAS_CPU_FEATURE (AVX512_BITALG):
  HAS_CPU_FEATURE (AVX512_BITALG): 0
  cpuinfo (avx512_bitalg): 0
Checking HAS_CPU_FEATURE (AVX512_IFMA):
  HAS_CPU_FEATURE (AVX512_IFMA): 0
  cpuinfo (avx512ifma): 0
Checking HAS_CPU_FEATURE (AVX512_VBMI):
  HAS_CPU_FEATURE (AVX512_VBMI): 0
  cpuinfo (avx512vbmi): 0
Checking HAS_CPU_FEATURE (AVX512_VBMI2):
  HAS_CPU_FEATURE (AVX512_VBMI2): 0
  cpuinfo (avx512_vbmi2): 0
Checking HAS_CPU_FEATURE (AVX512_VNNI):
  HAS_CPU_FEATURE (AVX512_VNNI): 0
  cpuinfo (avx512_vnni): 0
Checking HAS_CPU_FEATURE (AVX512_VP2INTERSECT):
  HAS_CPU_FEATURE (AVX512_VP2INTERSECT): 0
  cpuinfo (avx512_vp2intersect): 0
Checking HAS_CPU_FEATURE (AVX512_VPOPCNTDQ):
  HAS_CPU_FEATURE (AVX512_VPOPCNTDQ): 0
  cpuinfo (avx512_vpopcntdq): 0
Checking HAS_CPU_FEATURE (AVX512BW):
  HAS_CPU_FEATURE (AVX512BW): 0
  cpuinfo (avx512bw): 0
Checking HAS_CPU_FEATURE (AVX512CD):
  HAS_CPU_FEATURE (AVX512CD): 0
  cpuinfo (avx512cd): 0
Checking HAS_CPU_FEATURE (AVX512ER):
  HAS_CPU_FEATURE (AVX512ER): 0
  cpuinfo (avx512er): 0
Checking HAS_CPU_FEATURE (AVX512DQ):
  HAS_CPU_FEATURE (AVX512DQ): 0
  cpuinfo (avx512dq): 0
Checking HAS_CPU_FEATURE (AVX512F):
  HAS_CPU_FEATURE (AVX512F): 0
  cpuinfo (avx512f): 0
Checking HAS_CPU_FEATURE (AVX512PF):
  HAS_CPU_FEATURE (AVX512PF): 0
  cpuinfo (avx512pf): 0
Checking HAS_CPU_FEATURE (AVX512VL):
  HAS_CPU_FEATURE (AVX512VL): 0
  cpuinfo (avx512vl): 0
Checking HAS_CPU_FEATURE (BMI1):
  HAS_CPU_FEATURE (BMI1): 1
  cpuinfo (bmi1): 1
Checking HAS_CPU_FEATURE (BMI2):
  HAS_CPU_FEATURE (BMI2): 1
  cpuinfo (bmi2): 1
Checking HAS_CPU_FEATURE (CLDEMOTE):
  HAS_CPU_FEATURE (CLDEMOTE): 0
  cpuinfo (cldemote): 0
Checking HAS_CPU_FEATURE (CLFLUSHOPT):
  HAS_CPU_FEATURE (CLFLUSHOPT): 0
  cpuinfo (clflushopt): 1
 *** failure ***
Checking HAS_CPU_FEATURE (CLFSH):
  HAS_CPU_FEATURE (CLFSH): 1
  cpuinfo (clflush): 1
Checking HAS_CPU_FEATURE (CLWB):
  HAS_CPU_FEATURE (CLWB): 0
  cpuinfo (clwb): 0
Checking HAS_CPU_FEATURE (CMOV):
  HAS_CPU_FEATURE (CMOV): 1
  cpuinfo (cmov): 1
Checking HAS_CPU_FEATURE (CMPXCHG16B):
  HAS_CPU_FEATURE (CMPXCHG16B): 1
  cpuinfo (cx16): 1
Checking HAS_CPU_FEATURE (CNXT_ID):
  HAS_CPU_FEATURE (CNXT_ID): 0
  cpuinfo (cnxt_id): 0
Checking HAS_CPU_FEATURE (CORE_CAPABILITIES):
  HAS_CPU_FEATURE (CORE_CAPABILITIES): 0
  cpuinfo (core_capabilities): 0
Checking HAS_CPU_FEATURE (CX8):
  HAS_CPU_FEATURE (CX8): 1
  cpuinfo (cx8): 1
Checking HAS_CPU_FEATURE (DCA):
  HAS_CPU_FEATURE (DCA): 0
  cpuinfo (dca): 0
Checking HAS_CPU_FEATURE (DE):
  HAS_CPU_FEATURE (DE): 1
  cpuinfo (de): 1
Checking HAS_CPU_FEATURE (DEPR_FPU_CS_DS):
  HAS_CPU_FEATURE (DEPR_FPU_CS_DS): 1
  cpuinfo (zero_fcs_fds): 0
 *** missing in /proc/cpuinfo ***
Checking HAS_CPU_FEATURE (DS):
  HAS_CPU_FEATURE (DS): 1
  cpuinfo (dts): 1
Checking HAS_CPU_FEATURE (DS_CPL):
  HAS_CPU_FEATURE (DS_CPL): 1
  cpuinfo (ds_cpl): 1
Checking HAS_CPU_FEATURE (DTES64):
  HAS_CPU_FEATURE (DTES64): 1
  cpuinfo (dtes64): 1
Checking HAS_CPU_FEATURE (EIST):
  HAS_CPU_FEATURE (EIST): 1
  cpuinfo (est): 1
Checking HAS_CPU_FEATURE (ENQCMD):
  HAS_CPU_FEATURE (ENQCMD): 0
  cpuinfo (enqcmd): 0
Checking HAS_CPU_FEATURE (ERMS):
  HAS_CPU_FEATURE (ERMS): 1
  cpuinfo (erms): 1
Checking HAS_CPU_FEATURE (F16C):
  HAS_CPU_FEATURE (F16C): 1
  cpuinfo (f16c): 1
Checking HAS_CPU_FEATURE (FMA):
  HAS_CPU_FEATURE (FMA): 1
  cpuinfo (fma): 1
Checking HAS_CPU_FEATURE (FMA4):
  HAS_CPU_FEATURE (FMA4): 0
  cpuinfo (fma4): 0
Checking HAS_CPU_FEATURE (FPU):
  HAS_CPU_FEATURE (FPU): 1
  cpuinfo (fpu): 1
Checking HAS_CPU_FEATURE (FSGSBASE):
  HAS_CPU_FEATURE (FSGSBASE): 0
  cpuinfo (fsgsbase): 1
 *** failure ***
Checking HAS_CPU_FEATURE (FSRM):
  HAS_CPU_FEATURE (FSRM): 0
  cpuinfo (fsrm): 0
Checking HAS_CPU_FEATURE (FXSR):
  HAS_CPU_FEATURE (FXSR): 1
  cpuinfo (fxsr): 1
Checking HAS_CPU_FEATURE (GFNI):
  HAS_CPU_FEATURE (GFNI): 0
  cpuinfo (gfni): 0
Checking HAS_CPU_FEATURE (HLE):
  HAS_CPU_FEATURE (HLE): 0
  cpuinfo (hle): 0
Checking HAS_CPU_FEATURE (HTT):
  HAS_CPU_FEATURE (HTT): 1
  cpuinfo (ht): 1
Checking HAS_CPU_FEATURE (HYBRID):
  HAS_CPU_FEATURE (HYBRID): 0
  cpuinfo (hybrid): 0
Checking HAS_CPU_FEATURE (IBRS_IBPB):
  HAS_CPU_FEATURE (IBRS_IBPB): 0
  cpuinfo (ibrs): 1
 *** failure ***
Checking HAS_CPU_FEATURE (IBT):
  HAS_CPU_FEATURE (IBT): 0
  cpuinfo (ibt): 0
Checking HAS_CPU_FEATURE (INVARIANT_TSC):
  HAS_CPU_FEATURE (INVARIANT_TSC): 1
  cpuinfo (invariant_tsc): 0
 *** missing in /proc/cpuinfo ***
Checking HAS_CPU_FEATURE (INVPCID):
  HAS_CPU_FEATURE (INVPCID): 1
  cpuinfo (invpcid): 1
Checking HAS_CPU_FEATURE (L1D_FLUSH):
  HAS_CPU_FEATURE (L1D_FLUSH): 0
  cpuinfo (flush_l1d): 1
 *** failure ***
Checking HAS_CPU_FEATURE (LAHF64_SAHF64):
  HAS_CPU_FEATURE (LAHF64_SAHF64): 1
  cpuinfo (lahf_lm): 1
Checking HAS_CPU_FEATURE (LM):
  HAS_CPU_FEATURE (LM): 1
  cpuinfo (lm): 1
Checking HAS_CPU_FEATURE (LWP):
  HAS_CPU_FEATURE (LWP): 0
  cpuinfo (lwp): 0
Checking HAS_CPU_FEATURE (LZCNT):
  HAS_CPU_FEATURE (LZCNT): 1
  cpuinfo (abm): 1
Checking HAS_CPU_FEATURE (MCA):
  HAS_CPU_FEATURE (MCA): 1
  cpuinfo (mca): 1
Checking HAS_CPU_FEATURE (MCE):
  HAS_CPU_FEATURE (MCE): 1
  cpuinfo (mce): 1
Checking HAS_CPU_FEATURE (MD_CLEAR):
  HAS_CPU_FEATURE (MD_CLEAR): 0
  cpuinfo (md_clear): 1
 *** failure ***
Checking HAS_CPU_FEATURE (MMX):
  HAS_CPU_FEATURE (MMX): 1
  cpuinfo (mmx): 1
Checking HAS_CPU_FEATURE (MONITOR):
  HAS_CPU_FEATURE (MONITOR): 1
  cpuinfo (monitor): 1
Checking HAS_CPU_FEATURE (MOVBE):
  HAS_CPU_FEATURE (MOVBE): 1
  cpuinfo (movbe): 1
Checking HAS_CPU_FEATURE (MOVDIRI):
  HAS_CPU_FEATURE (MOVDIRI): 0
  cpuinfo (movdiri): 0
Checking HAS_CPU_FEATURE (MOVDIR64B):
  HAS_CPU_FEATURE (MOVDIR64B): 0
  cpuinfo (movdir64b): 0
Checking HAS_CPU_FEATURE (MPX):
  HAS_CPU_FEATURE (MPX): 0
  cpuinfo (mpx): 1
 *** failure ***
Checking HAS_CPU_FEATURE (MSR):
  HAS_CPU_FEATURE (MSR): 1
  cpuinfo (msr): 1
Checking HAS_CPU_FEATURE (MTRR):
  HAS_CPU_FEATURE (MTRR): 1
  cpuinfo (mtrr): 1
Checking HAS_CPU_FEATURE (NX):
  HAS_CPU_FEATURE (NX): 1
  cpuinfo (nx): 1
Checking HAS_CPU_FEATURE (OSPKE):
  HAS_CPU_FEATURE (OSPKE): 0
  cpuinfo (ospke): 0
Checking HAS_CPU_FEATURE (PAE):
  HAS_CPU_FEATURE (PAE): 1
  cpuinfo (pae): 1
Checking HAS_CPU_FEATURE (PAGE1GB):
  HAS_CPU_FEATURE (PAGE1GB): 1
  cpuinfo (pdpe1gb): 1
Checking HAS_CPU_FEATURE (PAT):
  HAS_CPU_FEATURE (PAT): 1
  cpuinfo (pat): 1
Checking HAS_CPU_FEATURE (PBE):
  HAS_CPU_FEATURE (PBE): 1
  cpuinfo (pbe): 1
Checking HAS_CPU_FEATURE (PCID):
  HAS_CPU_FEATURE (PCID): 1
  cpuinfo (pcid): 1
Checking HAS_CPU_FEATURE (PCLMULQDQ):
  HAS_CPU_FEATURE (PCLMULQDQ): 1
  cpuinfo (pclmulqdq): 1
Checking HAS_CPU_FEATURE (PCONFIG):
  HAS_CPU_FEATURE (PCONFIG): 0
  cpuinfo (pconfig): 0
Checking HAS_CPU_FEATURE (PDCM):
  HAS_CPU_FEATURE (PDCM): 1
  cpuinfo (pdcm): 1
Checking HAS_CPU_FEATURE (PGE):
  HAS_CPU_FEATURE (PGE): 1
  cpuinfo (pge): 1
Checking HAS_CPU_FEATURE (PKS):
  HAS_CPU_FEATURE (PKS): 0
  cpuinfo (pks): 0
Checking HAS_CPU_FEATURE (PKU):
  HAS_CPU_FEATURE (PKU): 0
  cpuinfo (pku): 0
Checking HAS_CPU_FEATURE (POPCNT):
  HAS_CPU_FEATURE (POPCNT): 1
  cpuinfo (popcnt): 1
Checking HAS_CPU_FEATURE (PREFETCHW):
  HAS_CPU_FEATURE (PREFETCHW): 0
  cpuinfo (3dnowprefetch): 1
 *** failure ***
Checking HAS_CPU_FEATURE (PREFETCHWT1):
  HAS_CPU_FEATURE (PREFETCHWT1): 0
  cpuinfo (prefetchwt1): 0
Checking HAS_CPU_FEATURE (PTWRITE):
  HAS_CPU_FEATURE (PTWRITE): 0
  cpuinfo (ptwrite): 0
Checking HAS_CPU_FEATURE (PSE):
  HAS_CPU_FEATURE (PSE): 1
  cpuinfo (pse): 1
Checking HAS_CPU_FEATURE (PSE_36):
  HAS_CPU_FEATURE (PSE_36): 1
  cpuinfo (pse36): 1
Checking HAS_CPU_FEATURE (PSN):
  HAS_CPU_FEATURE (PSN): 0
  cpuinfo (psn): 0
Checking HAS_CPU_FEATURE (RDPID):
  HAS_CPU_FEATURE (RDPID): 0
  cpuinfo (rdpid): 0
Checking HAS_CPU_FEATURE (RDRAND):
  HAS_CPU_FEATURE (RDRAND): 1
  cpuinfo (rdrand): 1
Checking HAS_CPU_FEATURE (RDSEED):
  HAS_CPU_FEATURE (RDSEED): 0
  cpuinfo (rdseed): 1
 *** failure ***
Checking HAS_CPU_FEATURE (RDT_A):
  HAS_CPU_FEATURE (RDT_A): 0
  cpuinfo (rdt_a): 0
Checking HAS_CPU_FEATURE (RDT_M):
  HAS_CPU_FEATURE (RDT_M): 0
  cpuinfo (cqm): 0
Checking HAS_CPU_FEATURE (RDTSCP):
  HAS_CPU_FEATURE (RDTSCP): 1
  cpuinfo (rdtscp): 1
Checking HAS_CPU_FEATURE (RTM):
  HAS_CPU_FEATURE (RTM): 0
  cpuinfo (rtm): 0
Checking HAS_CPU_FEATURE (SDBG):
  HAS_CPU_FEATURE (SDBG): 1
  cpuinfo (sdbg): 1
Checking HAS_CPU_FEATURE (SEP):
  HAS_CPU_FEATURE (SEP): 1
  cpuinfo (sep): 1
Checking HAS_CPU_FEATURE (SERIALIZE):
  HAS_CPU_FEATURE (SERIALIZE): 0
  cpuinfo (serialize): 0
Checking HAS_CPU_FEATURE (SGX):
  HAS_CPU_FEATURE (SGX): 0
  cpuinfo (sgx): 0
Checking HAS_CPU_FEATURE (SGX_LC):
  HAS_CPU_FEATURE (SGX_LC): 0
  cpuinfo (sgx_lc): 0
Checking HAS_CPU_FEATURE (SHA):
  HAS_CPU_FEATURE (SHA): 0
  cpuinfo (sha_ni): 0
Checking HAS_CPU_FEATURE (SHSTK):
  HAS_CPU_FEATURE (SHSTK): 0
  cpuinfo (shstk): 0
Checking HAS_CPU_FEATURE (SMAP):
  HAS_CPU_FEATURE (SMAP): 0
  cpuinfo (smap): 1
 *** failure ***
Checking HAS_CPU_FEATURE (SMEP):
  HAS_CPU_FEATURE (SMEP): 1
  cpuinfo (smep): 1
Checking HAS_CPU_FEATURE (SMX):
  HAS_CPU_FEATURE (SMX): 1
  cpuinfo (smx): 1
Checking HAS_CPU_FEATURE (SS):
  HAS_CPU_FEATURE (SS): 1
  cpuinfo (ss): 1
Checking HAS_CPU_FEATURE (SSBD):
  HAS_CPU_FEATURE (SSBD): 0
  cpuinfo (ssbd): 1
 *** failure ***
Checking HAS_CPU_FEATURE (SSE):
  HAS_CPU_FEATURE (SSE): 1
  cpuinfo (sse): 1
Checking HAS_CPU_FEATURE (SSE2):
  HAS_CPU_FEATURE (SSE2): 1
  cpuinfo (sse2): 1
Checking HAS_CPU_FEATURE (SSE3):
  HAS_CPU_FEATURE (SSE3): 1
  cpuinfo (pni): 1
Checking HAS_CPU_FEATURE (SSE4_1):
  HAS_CPU_FEATURE (SSE4_1): 1
  cpuinfo (sse4_1): 1
Checking HAS_CPU_FEATURE (SSE4_2):
  HAS_CPU_FEATURE (SSE4_2): 1
  cpuinfo (sse4_2): 1
Checking HAS_CPU_FEATURE (SSE4A):
  HAS_CPU_FEATURE (SSE4A): 0
  cpuinfo (sse4a): 0
Checking HAS_CPU_FEATURE (SSSE3):
  HAS_CPU_FEATURE (SSSE3): 1
  cpuinfo (ssse3): 1
Checking HAS_CPU_FEATURE (STIBP):
  HAS_CPU_FEATURE (STIBP): 0
  cpuinfo (stibp): 1
 *** failure ***
Checking HAS_CPU_FEATURE (SVM):
  HAS_CPU_FEATURE (SVM): 0
  cpuinfo (svm): 0
Checking HAS_CPU_FEATURE (SYSCALL_SYSRET):
  HAS_CPU_FEATURE (SYSCALL_SYSRET): 1
  cpuinfo (syscall): 1
Checking HAS_CPU_FEATURE (TBM):
  HAS_CPU_FEATURE (TBM): 0
  cpuinfo (tbm): 0
Checking HAS_CPU_FEATURE (TM):
  HAS_CPU_FEATURE (TM): 1
  cpuinfo (tm): 1
Checking HAS_CPU_FEATURE (TM2):
  HAS_CPU_FEATURE (TM2): 1
  cpuinfo (tm2): 1
Checking HAS_CPU_FEATURE (TRACE):
  HAS_CPU_FEATURE (TRACE): 0
  cpuinfo (intel_pt): 1
 *** failure ***
Checking HAS_CPU_FEATURE (TSC):
  HAS_CPU_FEATURE (TSC): 1
  cpuinfo (tsc): 1
Checking HAS_CPU_FEATURE (TSC_ADJUST):
  HAS_CPU_FEATURE (TSC_ADJUST): 1
  cpuinfo (tsc_adjust): 1
Checking HAS_CPU_FEATURE (TSC_DEADLINE):
  HAS_CPU_FEATURE (TSC_DEADLINE): 1
  cpuinfo (tsc_deadline_timer): 1
Checking HAS_CPU_FEATURE (TSXLDTRK):
  HAS_CPU_FEATURE (TSXLDTRK): 0
  cpuinfo (tsxldtrk): 0
Checking HAS_CPU_FEATURE (UMIP):
  HAS_CPU_FEATURE (UMIP): 0
  cpuinfo (umip): 0
Checking HAS_CPU_FEATURE (VAES):
  HAS_CPU_FEATURE (VAES): 0
  cpuinfo (vaes): 0
Checking HAS_CPU_FEATURE (VME):
  HAS_CPU_FEATURE (VME): 1
  cpuinfo (vme): 1
Checking HAS_CPU_FEATURE (VMX):
  HAS_CPU_FEATURE (VMX): 1
  cpuinfo (vmx): 1
Checking HAS_CPU_FEATURE (VPCLMULQDQ):
  HAS_CPU_FEATURE (VPCLMULQDQ): 0
  cpuinfo (vpclmulqdq): 0
Checking HAS_CPU_FEATURE (WAITPKG):
  HAS_CPU_FEATURE (WAITPKG): 0
  cpuinfo (waitpkg): 0
Checking HAS_CPU_FEATURE (WBNOINVD):
  HAS_CPU_FEATURE (WBNOINVD): 0
  cpuinfo (wbnoinvd): 0
Checking HAS_CPU_FEATURE (X2APIC):
  HAS_CPU_FEATURE (X2APIC): 1
  cpuinfo (x2apic): 1
Checking HAS_CPU_FEATURE (XFD):
  HAS_CPU_FEATURE (XFD): 0
  cpuinfo (xfd): 0
Checking HAS_CPU_FEATURE (XGETBV_ECX_1):
  HAS_CPU_FEATURE (XGETBV_ECX_1): 0
  cpuinfo (xgetbv1): 1
 *** failure ***
Checking HAS_CPU_FEATURE (XOP):
  HAS_CPU_FEATURE (XOP): 0
  cpuinfo (xop): 0
Checking HAS_CPU_FEATURE (XSAVE):
  HAS_CPU_FEATURE (XSAVE): 1
  cpuinfo (xsave): 1
Checking HAS_CPU_FEATURE (XSAVEC):
  HAS_CPU_FEATURE (XSAVEC): 0
  cpuinfo (xsavec): 1
 *** failure ***
Checking HAS_CPU_FEATURE (XSAVEOPT):
  HAS_CPU_FEATURE (XSAVEOPT): 0
  cpuinfo (xsaveopt): 1
 *** failure ***
Checking HAS_CPU_FEATURE (XSAVES):
  HAS_CPU_FEATURE (XSAVES): 0
  cpuinfo (xsaves): 1
 *** failure ***
Checking HAS_CPU_FEATURE (XTPRUPDCTRL):
  HAS_CPU_FEATURE (XTPRUPDCTRL): 1
  cpuinfo (xtpr): 1
18 differences between /proc/cpuinfo and glibc code.
Comment 2 Florian Weimer 2021-02-12 09:46:26 UTC
The valgrind failures are expected because fiddles with CPUID bits, while not altering the contents of /proc/cpuinfo.

Can you try pinning the test (without valgrind) to different CPUs using taskset? Thanks.
Comment 3 Siddhesh Poyarekar 2021-02-12 09:59:29 UTC
It only reports failures on cpu0, on every run, none of the other cores:

$ taskset --cpu-list 0 ./testrun.sh elf/tst-cpu-features-cpuinfo | grep -B 3 fail
Checking HAS_CPU_FEATURE (HLE):
  HAS_CPU_FEATURE (HLE): 1
  cpuinfo (hle): 0
 *** failure ***
--
Checking HAS_CPU_FEATURE (RTM):
  HAS_CPU_FEATURE (RTM): 1
  cpuinfo (rtm): 0
 *** failure ***
Comment 4 H.J. Lu 2021-02-12 13:45:40 UTC
(In reply to Siddhesh Poyarekar from comment #1)
> The failures become deterministic and numerous (18 failures in all) when the
> test is run under valgrind.  That may have something to do with valgrind's
> emulation but noting it here anyway since it seems relevant.  Importantly,
> valgrind does not report any errors.
> 
> valgrind --trace-children=yes ./testrun.sh elf/tst-cpu-features-cpuinfo
> --direct
> 
> <valgrind output snipped since it does not report any errors>
> 
> Checking HAS_CPU_FEATURE (ACPI):
>   HAS_CPU_FEATURE (ACPI): 1
>   cpuinfo (acpi): 1
> Checking HAS_CPU_FEATURE (ADX):
>   HAS_CPU_FEATURE (ADX): 0
>   cpuinfo (adx): 1
>  *** failure ***

This is because valgrind changes CPUID value:

https://stackoverflow.com/questions/48697579/valgrind-changes-cpuid-value
Comment 5 H.J. Lu 2021-02-12 13:51:48 UTC
(In reply to Siddhesh Poyarekar from comment #0)
> The following tests fail sporadically on my machine:
> 
> Checking HAS_CPU_FEATURE (HLE):
>   HAS_CPU_FEATURE (HLE): 1
>   cpuinfo (hle): 0
>  *** failure ***
> --
> Checking HAS_CPU_FEATURE (RTM):
>   HAS_CPU_FEATURE (RTM): 1
>   cpuinfo (rtm): 0
>  *** failure ***
> 
> Whenever it succeeds, HAS_CPU_FEATURE is 0 in both cases but every once in a
> while it returns 1.
> 

This sounds like CPUID instruction returns different value on your procsesors.
Comment 6 Siddhesh Poyarekar 2021-02-12 14:00:50 UTC
Yes, this is evidently not a glibc or a test issue.  Closing.
Comment 7 Carlos O'Donell 2022-01-14 22:20:27 UTC
(In reply to Siddhesh Poyarekar from comment #6)
> Yes, this is evidently not a glibc or a test issue.  Closing.

Just for reference I saw the same problem.

CPU0 cpuid and cpuinfo don't match.

I have the same model as Siddhesh but newer microcode.

processor	: 7
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
stepping	: 12
microcode	: 0xea
cpu MHz		: 1059.308
cache size	: 8192 KB
physical id	: 0
siblings	: 8
core id		: 3
cpu cores	: 4
apicid		: 7
initial apicid	: 7
fpu		: yes
fpu_exception	: yes
cpuid level	: 22
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
vmx flags	: vnmi preemption_timer invvpid ept_x_only ept_ad ept_1gb flexpriority tsc_offset vtpr mtf vapic ept vpid unrestricted_guest ple shadow_vmcs pml ept_mode_based_exec
bugs		: spectre_v1 spectre_v2 spec_store_bypass swapgs taa itlb_multihit srbds
bogomips	: 4199.88
clflush size	: 64
cache_alignment	: 64
address sizes	: 39 bits physical, 48 bits virtual
power management:

I'm reopening this because I think we should do something about the testing aspect of improving false positives in the face of hardware bugs. Even if we maintain a blacklist in support/* just for testing that would be OK with me.
Comment 8 H.J. Lu 2022-01-14 22:26:47 UTC
Let me take a look.
Comment 9 H.J. Lu 2022-01-14 22:57:07 UTC
Created attachment 13908 [details]
A patch

Please try this.
Comment 10 Carlos O'Donell 2022-01-17 14:09:56 UTC
(In reply to H.J. Lu from comment #9)
> Created attachment 13908 [details]
> A patch
> 
> Please try this.

This fixes the issue for x86_64, thank you very much HJ.

However, I'm still seeing i686 failures as reported here:
https://sourceware.org/pipermail/libc-alpha/2022-January/135345.html
Comment 11 H.J. Lu 2022-01-17 15:17:24 UTC
Created attachment 13910 [details]
The v2 patch

Please try this.
Comment 12 Carlos O'Donell 2022-01-18 03:49:52 UTC
(In reply to H.J. Lu from comment #11)
> Created attachment 13910 [details]
> The v2 patch
> 
> Please try this.

Thanks HJ.

My apologies, I made a mistake during testing, this still fails:

[carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh /home/carlos/build/glibc-review/elf/tst-cpu-features-cpuinfo-static; echo $?

Checking HAS_CPU_FEATURE (HLE):
  HAS_CPU_FEATURE (HLE): 1
  cpuinfo (hle): 0
 *** failure ***

Checking HAS_CPU_FEATURE (RTM):
  HAS_CPU_FEATURE (RTM): 1
  cpuinfo (rtm): 0
 *** failure ***

Likewise:

[carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh /home/carlos/build/glibc-review/string/tst-memchr-rtm; echo $?
error: ../sysdeps/x86/tst-string-rtm.h:63: TSX abort rate: 100.00% (3000 out of 3000)
error: 1 test failures
1
[carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh /home/carlos/build/glibc-review/string/tst-memchr-rtm; echo $?
77

[carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review-i686/testrun.sh /home/carlos/build/glibc-review-i686/string/tst-memchr-rtm; echo $?
77
[carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review-i686/testrun.sh /home/carlos/build/glibc-review-i686/string/tst-memchr-rtm; echo $?
error: ../sysdeps/x86/tst-string-rtm.h:63: TSX abort rate: 100.00% (3000 out of 3000)
error: 1 test failures
1
Comment 13 H.J. Lu 2022-01-18 14:22:26 UTC
Created attachment 13913 [details]
The v3 patch

Please try this.
Comment 14 H.J. Lu 2022-01-18 14:24:59 UTC
(In reply to Carlos O'Donell from comment #12)
> (In reply to H.J. Lu from comment #11)
> > Created attachment 13910 [details]
> > The v2 patch
> > 
> > Please try this.
> 
> Thanks HJ.
> 
> My apologies, I made a mistake during testing, this still fails:
> 
> [carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh
> /home/carlos/build/glibc-review/elf/tst-cpu-features-cpuinfo-static; echo $?
> 
> Checking HAS_CPU_FEATURE (HLE):
>   HAS_CPU_FEATURE (HLE): 1
>   cpuinfo (hle): 0
>  *** failure ***
> 
> Checking HAS_CPU_FEATURE (RTM):
>   HAS_CPU_FEATURE (RTM): 1
>   cpuinfo (rtm): 0
>  *** failure ***

These should be fixed by the v3 patch.


> Likewise:
> 
> [carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh
> /home/carlos/build/glibc-review/string/tst-memchr-rtm; echo $?
> error: ../sysdeps/x86/tst-string-rtm.h:63: TSX abort rate: 100.00% (3000 out
> of 3000)
> error: 1 test failures
> 1
> [carlos@fedora ~]$ taskset --cpu-list 0,1 ~/build/glibc-review/testrun.sh
> /home/carlos/build/glibc-review/string/tst-memchr-rtm; echo $?
> 77
> 
> [carlos@fedora ~]$ taskset --cpu-list 0,1
> ~/build/glibc-review-i686/testrun.sh
> /home/carlos/build/glibc-review-i686/string/tst-memchr-rtm; echo $?
> 77
> [carlos@fedora ~]$ taskset --cpu-list 0,1
> ~/build/glibc-review-i686/testrun.sh
> /home/carlos/build/glibc-review-i686/string/tst-memchr-rtm; echo $?
> error: ../sysdeps/x86/tst-string-rtm.h:63: TSX abort rate: 100.00% (3000 out
> of 3000)
> error: 1 test failures
> 1

This test is gated by

static int
do_test_1 (const char *name, unsigned int loop, int (*prepare) (void),
	   int (*function) (void))
{
  if (!CPU_FEATURE_ACTIVE (RTM))
    return EXIT_UNSUPPORTED;

Can you find put why your processor isn't on the black list?
Comment 15 Carlos O'Donell 2022-01-18 16:17:22 UTC
(In reply to H.J. Lu from comment #14)
> Can you find put why your processor isn't on the black list?

cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 142
model name	: Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
stepping	: 12
microcode	: 0xea

+           case 0x8e:
+             if (stepping <= 0xb)
+               goto disable_tsx;
+             break;

Model 142 == Model 142 (0x8e) [OK]
Stepping 12 > Stepping 11 (0xb) [No match]

The blacklist doesn't include my processor, but yet this i7 exhibits something wrong in CPU0 after resume. So either the errata is wrong or we have a kernel bug on valid hardware.
Comment 16 H.J. Lu 2022-01-18 16:32:16 UTC
Created attachment 13914 [details]
The v4 patch

Please try this.
Comment 17 Carlos O'Donell 2022-01-18 16:35:55 UTC
(In reply to H.J. Lu from comment #16)
> Created attachment 13914 [details]
> The v4 patch
> 
> Please try this.

That works. Extending it to cover 0xc stepping fixes both failures.

As one of the Intel maintainers for glibc I'm going to rely on your judgement here if extending the errata to cover 0xc is acceptable. Worst case this is pessimistic for this hardware and we get user feedback that they want the range adjusted.
Comment 18 Carlos O'Donell 2022-01-18 16:38:20 UTC
(In reply to Carlos O'Donell from comment #17)
> (In reply to H.J. Lu from comment #16)
> > Created attachment 13914 [details]
> > The v4 patch
> > 
> > Please try this.
> 
> That works. Extending it to cover 0xc stepping fixes both failures.
> 
> As one of the Intel maintainers for glibc I'm going to rely on your
> judgement here if extending the errata to cover 0xc is acceptable. Worst
> case this is pessimistic for this hardware and we get user feedback that
> they want the range adjusted.

Note that Siddhesh's hardware is also stepping 12, so this isn't something random, but a specific flaw with this stepping or a kernel issue. But we can sort out the latter with more time, and blacklisting this CPU seems correct for now.
Comment 19 Sourceware Commits 2022-01-18 22:21:33 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1e000d3d33211d5a954300e2a69b90f93f18a1a1

commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Comment 20 H.J. Lu 2022-01-18 22:22:01 UTC
Fixed for 2.35.
Comment 21 Carlos O'Donell 2022-01-25 18:19:56 UTC
On i686 I still see the following failure:

Checking CPU_FEATURE_ACTIVE (HLE):
  CPU_FEATURE_ACTIVE (HLE): 0
  __builtin_cpu_supports (hle): 1048576
 *** failure ***

Which looks like we need to suppress this test because there will always be a difference here when HLE has been unset by the excluded CPU list?
Comment 22 H.J. Lu 2022-01-25 18:41:27 UTC
Created attachment 13929 [details]
A patch for HLE

Try this.
Comment 23 H.J. Lu 2022-01-25 18:42:29 UTC
Created attachment 13930 [details]
A patch for HLE
Comment 24 Carlos O'Donell 2022-01-26 19:30:04 UTC
(In reply to H.J. Lu from comment #23)
> Created attachment 13930 [details]
> A patch for HLE

The HLE patch fixes the issue and corrects the failure. Thank you!
Comment 25 Sourceware Commits 2022-02-01 13:54:13 UTC
The release/2.34/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b952c25dc7adf0684c53ad72d1d667da0348c929

commit b952c25dc7adf0684c53ad72d1d667da0348c929
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 26 Sourceware Commits 2022-02-01 14:08:19 UTC
The release/2.33/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=54fdfa2b33590fa960bcaf6d016b61e9b783dfab

commit 54fdfa2b33590fa960bcaf6d016b61e9b783dfab
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 27 Sourceware Commits 2022-02-01 15:26:40 UTC
The release/2.32/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b1fcaf14fe91a35a21a184623c4f08352f566297

commit b1fcaf14fe91a35a21a184623c4f08352f566297
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 28 Sourceware Commits 2022-02-01 15:36:59 UTC
The release/2.31/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5db3239baf661b9ccdee58949e282ad34e1c8956

commit 5db3239baf661b9ccdee58949e282ad34e1c8956
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 29 Sourceware Commits 2022-02-01 15:59:35 UTC
The release/2.30/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=76e30dd44ef7aab743a538dcd4a81761a1f612d9

commit 76e30dd44ef7aab743a538dcd4a81761a1f612d9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 30 Sourceware Commits 2022-02-01 16:06:52 UTC
The release/2.29/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5d94c86a47ded691d954bf38c443bb83dc83cb46

commit 5d94c86a47ded691d954bf38c443bb83dc83cb46
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 31 Sourceware Commits 2022-02-01 17:16:21 UTC
The release/2.28/master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5219747d67f0f3860dc3ccf54bc9473b2aec0311

commit 5219747d67f0f3860dc3ccf54bc9473b2aec0311
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Jan 14 14:48:01 2022 -0800

    x86: Black list more Intel CPUs for TSX [BZ #27398]
    
    Disable TSX and enable RTM_ALWAYS_ABORT for Intel CPUs listed in:
    
    https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html
    
    This fixes BZ #27398.
    
    Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
    (cherry picked from commit 1e000d3d33211d5a954300e2a69b90f93f18a1a1)
Comment 32 Florian Weimer 2022-05-02 10:42:38 UTC
(In reply to Siddhesh Poyarekar from comment #3)
> It only reports failures on cpu0, on every run, none of the other cores:
> 
> $ taskset --cpu-list 0 ./testrun.sh elf/tst-cpu-features-cpuinfo | grep -B 3
> fail
> Checking HAS_CPU_FEATURE (HLE):
>   HAS_CPU_FEATURE (HLE): 1
>   cpuinfo (hle): 0
>  *** failure ***
> --
> Checking HAS_CPU_FEATURE (RTM):
>   HAS_CPU_FEATURE (RTM): 1
>   cpuinfo (rtm): 0
>  *** failure ***

This was fixed as a kernel bug:

commit e2a1256b17b16f9b9adf1b6fea56819e7b68e463
Author: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Date:   Mon Apr 4 17:35:45 2022 -0700

    x86/speculation: Restore speculation related MSRs during S3 resume
    
    After resuming from suspend-to-RAM, the MSRs that control CPU's
    speculative execution behavior are not being restored on the boot CPU.
    
    These MSRs are used to mitigate speculative execution vulnerabilities.
    Not restoring them correctly may leave the CPU vulnerable.  Secondary
    CPU's MSRs are correctly being restored at S3 resume by
    identify_secondary_cpu().
    
    During S3 resume, restore these MSRs for boot CPU when restoring its
    processor state.
    
    Fixes: 772439717dbf ("x86/bugs/intel: Set proper CPU features and setup RDS")
    Reported-by: Neelima Krishnan <neelima.krishnan@intel.com>
    Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
    Tested-by: Neelima Krishnan <neelima.krishnan@intel.com>
    Acked-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Leaving this bug here at security- because it's not a glibc bug (disabling RTM for glibc's own use does not mitigate the vulnerability).