Skip to content

Commit bef91c2

Browse files
committed
Merge tag 'x86_cpu_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 cpu feature updates from Borislav Petkov: - Add synthetic X86_FEATURE flags for the different AMD Zen generations and use them everywhere instead of ad-hoc family/model checks. Drop an ancient AMD errata checking facility as a result - Fix a fragile initcall ordering in intel_epb - Do not issue the MFENCE+LFENCE barrier for the TSC deadline and X2APIC MSRs on AMD as it is not needed there * tag 'x86_cpu_for_v6.8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/CPU/AMD: Add X86_FEATURE_ZEN1 x86/CPU/AMD: Drop now unused CPU erratum checking function x86/CPU/AMD: Get rid of amd_erratum_1485[] x86/CPU/AMD: Get rid of amd_erratum_400[] x86/CPU/AMD: Get rid of amd_erratum_383[] x86/CPU/AMD: Get rid of amd_erratum_1054[] x86/CPU/AMD: Move the DIV0 bug detection to the Zen1 init function x86/CPU/AMD: Move Zenbleed check to the Zen2 init function x86/CPU/AMD: Rename init_amd_zn() to init_amd_zen_common() x86/CPU/AMD: Call the spectral chicken in the Zen2 init function x86/CPU/AMD: Move erratum 1076 fix into the Zen1 init function x86/CPU/AMD: Move the Zen3 BTC_NO detection to the Zen3 init function x86/CPU/AMD: Carve out the erratum 1386 fix x86/CPU/AMD: Add ZenX generations flags x86/cpu/intel_epb: Don't rely on link order x86/barrier: Do not serialize MSR accesses on AMD
2 parents e900042 + 232afb5 commit bef91c2

8 files changed

Lines changed: 170 additions & 156 deletions

File tree

arch/x86/include/asm/barrier.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,4 @@ do { \
8181

8282
#include <asm-generic/barrier.h>
8383

84-
/*
85-
* Make previous memory operations globally visible before
86-
* a WRMSR.
87-
*
88-
* MFENCE makes writes visible, but only affects load/store
89-
* instructions. WRMSR is unfortunately not a load/store
90-
* instruction and is unaffected by MFENCE. The LFENCE ensures
91-
* that the WRMSR is not reordered.
92-
*
93-
* Most WRMSRs are full serializing instructions themselves and
94-
* do not require this barrier. This is only required for the
95-
* IA32_TSC_DEADLINE and X2APIC MSRs.
96-
*/
97-
static inline void weak_wrmsr_fence(void)
98-
{
99-
asm volatile("mfence; lfence" : : : "memory");
100-
}
101-
10284
#endif /* _ASM_X86_BARRIER_H */

arch/x86/include/asm/cpufeatures.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@
218218
#define X86_FEATURE_IBRS ( 7*32+25) /* Indirect Branch Restricted Speculation */
219219
#define X86_FEATURE_IBPB ( 7*32+26) /* Indirect Branch Prediction Barrier */
220220
#define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
221-
#define X86_FEATURE_ZEN (7*32+28) /* "" CPU based on Zen microarchitecture */
221+
#define X86_FEATURE_ZEN ( 7*32+28) /* "" Generic flag for all Zen and newer */
222222
#define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
223223
#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
224224
#define X86_FEATURE_MSR_IA32_FEAT_CTL ( 7*32+31) /* "" MSR IA32_FEAT_CTL configured */
@@ -308,10 +308,14 @@
308308
#define X86_FEATURE_SMBA (11*32+21) /* "" Slow Memory Bandwidth Allocation */
309309
#define X86_FEATURE_BMEC (11*32+22) /* "" Bandwidth Monitoring Event Configuration */
310310
#define X86_FEATURE_USER_SHSTK (11*32+23) /* Shadow stack support for user mode applications */
311-
312311
#define X86_FEATURE_SRSO (11*32+24) /* "" AMD BTB untrain RETs */
313312
#define X86_FEATURE_SRSO_ALIAS (11*32+25) /* "" AMD BTB untrain RETs through aliasing */
314313
#define X86_FEATURE_IBPB_ON_VMEXIT (11*32+26) /* "" Issue an IBPB only on VMEXIT */
314+
#define X86_FEATURE_APIC_MSRS_FENCE (11*32+27) /* "" IA32_TSC_DEADLINE and X2APIC MSRs need fencing */
315+
#define X86_FEATURE_ZEN2 (11*32+28) /* "" CPU based on Zen2 microarchitecture */
316+
#define X86_FEATURE_ZEN3 (11*32+29) /* "" CPU based on Zen3 microarchitecture */
317+
#define X86_FEATURE_ZEN4 (11*32+30) /* "" CPU based on Zen4 microarchitecture */
318+
#define X86_FEATURE_ZEN1 (11*32+31) /* "" CPU based on Zen1 microarchitecture */
315319

316320
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
317321
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */

arch/x86/include/asm/processor.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,4 +749,22 @@ enum mds_mitigations {
749749

750750
extern bool gds_ucode_mitigated(void);
751751

752+
/*
753+
* Make previous memory operations globally visible before
754+
* a WRMSR.
755+
*
756+
* MFENCE makes writes visible, but only affects load/store
757+
* instructions. WRMSR is unfortunately not a load/store
758+
* instruction and is unaffected by MFENCE. The LFENCE ensures
759+
* that the WRMSR is not reordered.
760+
*
761+
* Most WRMSRs are full serializing instructions themselves and
762+
* do not require this barrier. This is only required for the
763+
* IA32_TSC_DEADLINE and X2APIC MSRs.
764+
*/
765+
static inline void weak_wrmsr_fence(void)
766+
{
767+
alternative("mfence; lfence", "", ALT_NOT(X86_FEATURE_APIC_MSRS_FENCE));
768+
}
769+
752770
#endif /* _ASM_X86_PROCESSOR_H */

0 commit comments

Comments
 (0)