Skip to content

Commit 5b909d4

Browse files
kimphillamdbp3tk0v
authored andcommitted
x86/cpu, kvm: Add the Null Selector Clears Base feature
The Null Selector Clears Base feature was being open-coded for KVM. Add it to its newly added native CPUID leaf 0x80000021 EAX proper. Also drop the bit description comments now it's more self-describing. [ bp: Convert test in check_null_seg_clears_base() too. ] Signed-off-by: Kim Phillips <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 84168ae commit 5b909d4

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

arch/x86/include/asm/cpufeatures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@
430430
/* AMD-defined Extended Feature 2 EAX, CPUID level 0x80000021 (EAX), word 20 */
431431
#define X86_FEATURE_NO_NESTED_DATA_BP (20*32+ 0) /* "" No Nested Data Breakpoints */
432432
#define X86_FEATURE_LFENCE_RDTSC (20*32+ 2) /* "" LFENCE always serializing / synchronizes RDTSC */
433+
#define X86_FEATURE_NULL_SEL_CLR_BASE (20*32+ 6) /* "" Null Selector Clears Base */
433434

434435
/*
435436
* BUG word(s)

arch/x86/kernel/cpu/common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,9 +1685,7 @@ void check_null_seg_clears_base(struct cpuinfo_x86 *c)
16851685
if (!IS_ENABLED(CONFIG_X86_64))
16861686
return;
16871687

1688-
/* Zen3 CPUs advertise Null Selector Clears Base in CPUID. */
1689-
if (c->extended_cpuid_level >= 0x80000021 &&
1690-
cpuid_eax(0x80000021) & BIT(6))
1688+
if (cpu_has(c, X86_FEATURE_NULL_SEL_CLR_BASE))
16911689
return;
16921690

16931691
/*

arch/x86/kvm/cpuid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void kvm_set_cpu_caps(void)
743743

744744
kvm_cpu_cap_mask(CPUID_8000_0021_EAX,
745745
F(NO_NESTED_DATA_BP) | F(LFENCE_RDTSC) | 0 /* SmmPgCfgLock */ |
746-
BIT(6) /* NULL_SEL_CLR_BASE */ | 0 /* PrefetchCtlMsr */
746+
F(NULL_SEL_CLR_BASE) | 0 /* PrefetchCtlMsr */
747747
);
748748

749749
/*
@@ -759,7 +759,7 @@ void kvm_set_cpu_caps(void)
759759
if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC))
760760
kvm_cpu_cap_set(X86_FEATURE_LFENCE_RDTSC);
761761
if (!static_cpu_has_bug(X86_BUG_NULL_SEG))
762-
kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(6) /* NULL_SEL_CLR_BASE */;
762+
kvm_cpu_cap_set(X86_FEATURE_NULL_SEL_CLR_BASE);
763763
kvm_cpu_caps[CPUID_8000_0021_EAX] |= BIT(9) /* NO_SMM_CTL_MSR */;
764764

765765
kvm_cpu_cap_mask(CPUID_C000_0001_EDX,

0 commit comments

Comments
 (0)