Skip to content

Commit c23708f

Browse files
committed
tools headers: Update tools's copy of x86/asm headers
tldr; Just FYI, I'm carrying this on the perf tools tree. Full explanation: There used to be no copies, with tools/ code using kernel headers directly. From time to time tools/perf/ broke due to legitimate kernel hacking. At some point Linus complained about such direct usage. Then we adopted the current model. The way these headers are used in perf are not restricted to just including them to compile something. There are sometimes used in scripts that convert defines into string tables, etc, so some change may break one of these scripts, or new MSRs may use some different #define pattern, etc. E.g.: $ ls -1 tools/perf/trace/beauty/*.sh | head -5 tools/perf/trace/beauty/arch_errno_names.sh tools/perf/trace/beauty/drm_ioctl.sh tools/perf/trace/beauty/fadvise.sh tools/perf/trace/beauty/fsconfig.sh tools/perf/trace/beauty/fsmount.sh $ $ tools/perf/trace/beauty/fadvise.sh static const char *fadvise_advices[] = { [0] = "NORMAL", [1] = "RANDOM", [2] = "SEQUENTIAL", [3] = "WILLNEED", [4] = "DONTNEED", [5] = "NOREUSE", }; $ The tools/perf/check-headers.sh script, part of the tools/ build process, points out changes in the original files. So its important not to touch the copies in tools/ when doing changes in the original kernel headers, that will be done later, when check-headers.sh inform about the change to the perf tools hackers. Cc: Thomas Gleixner <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Dave Hansen <[email protected]> Cc: [email protected] Cc: "H. Peter Anvin" <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fd2ddee commit c23708f

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed

tools/arch/x86/include/asm/cpufeatures.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
#define X86_FEATURE_CAT_L3 ( 7*32+ 4) /* Cache Allocation Technology L3 */
199199
#define X86_FEATURE_CAT_L2 ( 7*32+ 5) /* Cache Allocation Technology L2 */
200200
#define X86_FEATURE_CDP_L3 ( 7*32+ 6) /* Code and Data Prioritization L3 */
201-
#define X86_FEATURE_INVPCID_SINGLE ( 7*32+ 7) /* Effectively INVPCID && CR4.PCIDE=1 */
202201
#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */
203202
#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
204203
#define X86_FEATURE_XCOMPACTED ( 7*32+10) /* "" Use compacted XSTATE (XSAVES or XSAVEC) */
@@ -308,6 +307,11 @@
308307
#define X86_FEATURE_MSR_TSX_CTRL (11*32+20) /* "" MSR IA32_TSX_CTRL (Intel) implemented */
309308
#define X86_FEATURE_SMBA (11*32+21) /* "" Slow Memory Bandwidth Allocation */
310309
#define X86_FEATURE_BMEC (11*32+22) /* "" Bandwidth Monitoring Event Configuration */
310+
#define X86_FEATURE_USER_SHSTK (11*32+23) /* Shadow stack support for user mode applications */
311+
312+
#define X86_FEATURE_SRSO (11*32+24) /* "" AMD BTB untrain RETs */
313+
#define X86_FEATURE_SRSO_ALIAS (11*32+25) /* "" AMD BTB untrain RETs through aliasing */
314+
#define X86_FEATURE_IBPB_ON_VMEXIT (11*32+26) /* "" Issue an IBPB only on VMEXIT */
311315

312316
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
313317
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */
@@ -380,6 +384,7 @@
380384
#define X86_FEATURE_OSPKE (16*32+ 4) /* OS Protection Keys Enable */
381385
#define X86_FEATURE_WAITPKG (16*32+ 5) /* UMONITOR/UMWAIT/TPAUSE Instructions */
382386
#define X86_FEATURE_AVX512_VBMI2 (16*32+ 6) /* Additional AVX512 Vector Bit Manipulation Instructions */
387+
#define X86_FEATURE_SHSTK (16*32+ 7) /* "" Shadow stack */
383388
#define X86_FEATURE_GFNI (16*32+ 8) /* Galois Field New Instructions */
384389
#define X86_FEATURE_VAES (16*32+ 9) /* Vector AES */
385390
#define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication Double Quadword */
@@ -438,11 +443,16 @@
438443

439444
/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */
440445
#define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */
446+
#define X86_FEATURE_WRMSR_XX_BASE_NS (20*32+ 1) /* "" WRMSR to {FS,GS,KERNEL_GS}_BASE is non-serializing */
441447
#define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */
442448
#define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* "" Null Selector Clears Base */
443449
#define X86_FEATURE_AUTOIBRS (20*32+ 8) /* "" Automatic IBRS */
444450
#define X86_FEATURE_NO_SMM_CTL_MSR (20*32+ 9) /* "" SMM_CTL MSR is not present */
445451

452+
#define X86_FEATURE_SBPB (20*32+27) /* "" Selective Branch Prediction Barrier */
453+
#define X86_FEATURE_IBPB_BRTYPE (20*32+28) /* "" MSR_PRED_CMD[IBPB] flushes all branch type predictions */
454+
#define X86_FEATURE_SRSO_NO (20*32+29) /* "" CPU is not affected by SRSO */
455+
446456
/*
447457
* BUG word(s)
448458
*/
@@ -484,5 +494,9 @@
484494
#define X86_BUG_RETBLEED X86_BUG(27) /* CPU is affected by RETBleed */
485495
#define X86_BUG_EIBRS_PBRSB X86_BUG(28) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
486496
#define X86_BUG_SMT_RSB X86_BUG(29) /* CPU is vulnerable to Cross-Thread Return Address Predictions */
497+
#define X86_BUG_GDS X86_BUG(30) /* CPU is affected by Gather Data Sampling */
487498

499+
/* BUG word 2 */
500+
#define X86_BUG_SRSO X86_BUG(1*32 + 0) /* AMD SRSO bug */
501+
#define X86_BUG_DIV0 X86_BUG(1*32 + 1) /* AMD DIV0 speculation bug */
488502
#endif /* _ASM_X86_CPUFEATURES_H */

tools/arch/x86/include/asm/disabled-features.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@
105105
# define DISABLE_TDX_GUEST (1 << (X86_FEATURE_TDX_GUEST & 31))
106106
#endif
107107

108+
#ifdef CONFIG_X86_USER_SHADOW_STACK
109+
#define DISABLE_USER_SHSTK 0
110+
#else
111+
#define DISABLE_USER_SHSTK (1 << (X86_FEATURE_USER_SHSTK & 31))
112+
#endif
113+
114+
#ifdef CONFIG_X86_KERNEL_IBT
115+
#define DISABLE_IBT 0
116+
#else
117+
#define DISABLE_IBT (1 << (X86_FEATURE_IBT & 31))
118+
#endif
119+
108120
/*
109121
* Make sure to add features to the correct mask
110122
*/
@@ -120,15 +132,15 @@
120132
#define DISABLED_MASK9 (DISABLE_SGX)
121133
#define DISABLED_MASK10 0
122134
#define DISABLED_MASK11 (DISABLE_RETPOLINE|DISABLE_RETHUNK|DISABLE_UNRET| \
123-
DISABLE_CALL_DEPTH_TRACKING)
135+
DISABLE_CALL_DEPTH_TRACKING|DISABLE_USER_SHSTK)
124136
#define DISABLED_MASK12 (DISABLE_LAM)
125137
#define DISABLED_MASK13 0
126138
#define DISABLED_MASK14 0
127139
#define DISABLED_MASK15 0
128140
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP| \
129141
DISABLE_ENQCMD)
130142
#define DISABLED_MASK17 0
131-
#define DISABLED_MASK18 0
143+
#define DISABLED_MASK18 (DISABLE_IBT)
132144
#define DISABLED_MASK19 0
133145
#define DISABLED_MASK20 0
134146
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21)

tools/arch/x86/include/asm/msr-index.h

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
#define MSR_INTEGRITY_CAPS_ARRAY_BIST BIT(MSR_INTEGRITY_CAPS_ARRAY_BIST_BIT)
223223
#define MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT 4
224224
#define MSR_INTEGRITY_CAPS_PERIODIC_BIST BIT(MSR_INTEGRITY_CAPS_PERIODIC_BIST_BIT)
225+
#define MSR_INTEGRITY_CAPS_SAF_GEN_MASK GENMASK_ULL(10, 9)
225226

226227
#define MSR_LBR_NHM_FROM 0x00000680
227228
#define MSR_LBR_NHM_TO 0x000006c0
@@ -553,6 +554,7 @@
553554
#define MSR_AMD64_CPUID_FN_1 0xc0011004
554555
#define MSR_AMD64_LS_CFG 0xc0011020
555556
#define MSR_AMD64_DC_CFG 0xc0011022
557+
#define MSR_AMD64_TW_CFG 0xc0011023
556558

557559
#define MSR_AMD64_DE_CFG 0xc0011029
558560
#define MSR_AMD64_DE_CFG_LFENCE_SERIALIZE_BIT 1
@@ -637,12 +639,21 @@
637639
/* AMD Last Branch Record MSRs */
638640
#define MSR_AMD64_LBR_SELECT 0xc000010e
639641

642+
/* Zen4 */
643+
#define MSR_ZEN4_BP_CFG 0xc001102e
644+
#define MSR_ZEN4_BP_CFG_SHARED_BTB_FIX_BIT 5
645+
646+
/* Fam 19h MSRs */
647+
#define MSR_F19H_UMC_PERF_CTL 0xc0010800
648+
#define MSR_F19H_UMC_PERF_CTR 0xc0010801
649+
650+
/* Zen 2 */
651+
#define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3
652+
#define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1)
653+
640654
/* Fam 17h MSRs */
641655
#define MSR_F17H_IRPERF 0xc00000e9
642656

643-
#define MSR_ZEN2_SPECTRAL_CHICKEN 0xc00110e3
644-
#define MSR_ZEN2_SPECTRAL_CHICKEN_BIT BIT_ULL(1)
645-
646657
/* Fam 16h MSRs */
647658
#define MSR_F16H_L2I_PERF_CTL 0xc0010230
648659
#define MSR_F16H_L2I_PERF_CTR 0xc0010231
@@ -1112,12 +1123,16 @@
11121123
#define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14)
11131124
#define MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS (1ULL << 29)
11141125
#define MSR_IA32_VMX_MISC_PREEMPTION_TIMER_SCALE 0x1F
1115-
/* AMD-V MSRs */
11161126

1127+
/* AMD-V MSRs */
11171128
#define MSR_VM_CR 0xc0010114
11181129
#define MSR_VM_IGNNE 0xc0010115
11191130
#define MSR_VM_HSAVE_PA 0xc0010117
11201131

1132+
#define SVM_VM_CR_VALID_MASK 0x001fULL
1133+
#define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL
1134+
#define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL
1135+
11211136
/* Hardware Feedback Interface */
11221137
#define MSR_IA32_HW_FEEDBACK_PTR 0x17d0
11231138
#define MSR_IA32_HW_FEEDBACK_CONFIG 0x17d1

tools/arch/x86/include/uapi/asm/prctl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@
2323
#define ARCH_MAP_VDSO_32 0x2002
2424
#define ARCH_MAP_VDSO_64 0x2003
2525

26+
/* Don't use 0x3001-0x3004 because of old glibcs */
27+
2628
#define ARCH_GET_UNTAG_MASK 0x4001
2729
#define ARCH_ENABLE_TAGGED_ADDR 0x4002
2830
#define ARCH_GET_MAX_TAG_BITS 0x4003
2931
#define ARCH_FORCE_TAGGED_SVA 0x4004
3032

33+
#define ARCH_SHSTK_ENABLE 0x5001
34+
#define ARCH_SHSTK_DISABLE 0x5002
35+
#define ARCH_SHSTK_LOCK 0x5003
36+
#define ARCH_SHSTK_UNLOCK 0x5004
37+
#define ARCH_SHSTK_STATUS 0x5005
38+
39+
/* ARCH_SHSTK_ features bits */
40+
#define ARCH_SHSTK_SHSTK (1ULL << 0)
41+
#define ARCH_SHSTK_WRSS (1ULL << 1)
42+
3143
#endif /* _ASM_X86_PRCTL_H */

0 commit comments

Comments
 (0)