x86/cpufeatures: KVM: Add mem encrypt word
Sean Christopherson
maintainerv3 cover x86/cpufeatures: KVM: Add mem encrypt word
Gather the AMD memory encryption features into a dedicated word for CPUID 0x8000001F[EAX] and use the new word in KVM to adjust its reporting of SEV support based on host kernel enabling.
Paolo, can you ack patch 2? Boris is planning on taking this through the tip tree. Thanks!
Split out from a larger KVM SEV cleanup series[*], thus the somewhat questionable v3 tag.
Based on v5.11-rc4.
[*] https://lkml.kernel.org/r/[email protected]
Sean Christopherson (2):
x86/cpufeatures: Assign dedicated feature word for
CPUID_0x8000001F[EAX]
KVM: x86: Override reported SME/SEV feature flags with host mask
arch/x86/include/asm/cpufeature.h | 7 +++++-- arch/x86/include/asm/cpufeatures.h | 17 +++++++++++------ arch/x86/include/asm/disabled-features.h | 3 ++- arch/x86/include/asm/required-features.h | 3 ++- arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/cpu/scattered.c | 5 ----- arch/x86/kvm/cpuid.c | 2 ++ arch/x86/kvm/cpuid.h | 1 + tools/arch/x86/include/asm/disabled-features.h | 3 ++- tools/arch/x86/include/asm/required-features.h | 3 ++- 10 files changed, 30 insertions(+), 17 deletions(-)
Signature · 1 line
2.30.0.280.ga3ce27912f-goog
Sean Christopherson
maintainerPATCH v3 1/2 x86/cpufeatures: Assign dedicated feature word for CPUID_0x8000001F[EAX]
Collect the scattered SME/SEV related feature flags into a dedicated word. There are now five recognized features in CPUID.0x8000001F.EAX, with at least one more on the horizon (SEV-SNP). Using a dedicated word allows KVM to use its automagic CPUID adjustment logic when reporting the set of supported features to userspace.
No functional change intended.
--- arch/x86/include/asm/cpufeature.h | 7 +++++-- arch/x86/include/asm/cpufeatures.h | 17 +++++++++++------ arch/x86/include/asm/disabled-features.h | 3 ++- arch/x86/include/asm/required-features.h | 3 ++- arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/cpu/scattered.c | 5 ----- tools/arch/x86/include/asm/disabled-features.h | 3 ++- tools/arch/x86/include/asm/required-features.h | 3 ++- 8 files changed, 27 insertions(+), 17 deletions(-)
arch/x86/include/asm/cpufeature.h +5 -2
@@ -30,6 +30,7 @@ enum cpuid_leafsCPUID_7_ECX ,CPUID_8000_0007_EBX ,CPUID_7_EDX , + CPUID_8000_001F_EAX, };#ifdef CONFIG_X86_FEATURE_NAMES
@@ -88,8 +89,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 19)) + BUILD_BUG_ON_ZERO(NCAPINTS != 20))#define DISABLED_MASK_BIT_SET (feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -111,8 +113,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 19)) + BUILD_BUG_ON_ZERO(NCAPINTS != 20))#define cpu_has (c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
arch/x86/include/asm/cpufeatures.h +11 -6
@@ -13,7 +13,7 @@/* * Defines x86 CPU feature bits */ -#define NCAPINTS 19/* N 32-bit words worth of info */ +#define NCAPINTS 20/* N 32-bit words worth of info */ #define NBUGINTS 1/* N 32-bit bug flags */ /*
@@ -96,7 +96,7 @@#define X86_FEATURE_SYSCALL32 ( 3*32+14)/* "" syscall in IA32 userspace */ #define X86_FEATURE_SYSENTER32 ( 3*32+15)/* "" sysenter in IA32 userspace */ #define X86_FEATURE_REP_GOOD ( 3*32+16)/* REP microcode works well */ -#define X86_FEATURE_SME_COHERENT ( 3*32+17)/* "" AMD hardware-enforced cache coherency */ +/* FREE! ( 3*32+17) */ #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18)/* "" LFENCE synchronizes RDTSC */ #define X86_FEATURE_ACC_POWER ( 3*32+19)/* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20)/* The NOPL (0F 1F) instructions */
@@ -201,7 +201,7 @@#define X86_FEATURE_INVPCID_SINGLE ( 7*32+ 7)/* Effectively INVPCID && CR4.PCIDE=1 */ #define X86_FEATURE_HW_PSTATE ( 7*32+ 8)/* AMD HW-PState */ #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ -#define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ +/* FREE! ( 7*32+10) */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ #define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* "" AMD Retpoline mitigation for Spectre variant 2 */
@@ -211,7 +211,7 @@#define X86_FEATURE_SSBD ( 7*32+17)/* Speculative Store Bypass Disable */ #define X86_FEATURE_MBA ( 7*32+18)/* Memory Bandwidth Allocation */ #define X86_FEATURE_RSB_CTXSW ( 7*32+19)/* "" Fill RSB on context switches */ -#define X86_FEATURE_SEV ( 7*32+20)/* AMD Secure Encrypted Virtualization */ +/* FREE! ( 7*32+20) */ #define X86_FEATURE_USE_IBPB ( 7*32+21)/* "" Indirect Branch Prediction Barrier enabled */ #define X86_FEATURE_USE_IBRS_FW ( 7*32+22)/* "" Use IBRS during runtime firmware calls */ #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE ( 7*32+23)/* "" Disable Speculative Store Bypass. */
@@ -236,8 +236,6 @@#define X86_FEATURE_EPT_AD ( 8*32+17)/* Intel Extended Page Table access-dirty bit */ #define X86_FEATURE_VMCALL ( 8*32+18)/* "" Hypervisor supports the VMCALL instruction */ #define X86_FEATURE_VMW_VMMCALL ( 8*32+19)/* "" VMware prefers VMMCALL hypercall instruction */ -#define X86_FEATURE_SEV_ES ( 8*32+20)/* AMD Secure Encrypted Virtualization - Encrypted State */ -#define X86_FEATURE_VM_PAGE_FLUSH ( 8*32+21)/* "" VM Page Flush MSR is supported */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ #define X86_FEATURE_FSGSBASE ( 9*32+ 0)/* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
@@ -385,6 +383,13 @@#define X86_FEATURE_CORE_CAPABILITIES (18*32+30)/* "" IA32_CORE_CAPABILITIES MSR */ #define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31)/* "" Speculative Store Bypass Disable */ +/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */ +#define X86_FEATURE_SME (19*32+ 0)/* AMD Secure Memory Encryption */ +#define X86_FEATURE_SEV (19*32+ 1)/* AMD Secure Encrypted Virtualization */ +#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2)/* "" VM Page Flush MSR is supported */ +#define X86_FEATURE_SEV_ES (19*32+ 3)/* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_SME_COHERENT (19*32+10)/* "" AMD hardware-enforced cache coherency */ +/* * BUG word(s) */
arch/x86/include/asm/disabled-features.h +2 -1
@@ -91,6 +91,7 @@ DISABLE_ENQCMD)#define DISABLED_MASK17 0#define DISABLED_MASK18 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define DISABLED_MASK19 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_DISABLED_FEATURES_H */
arch/x86/include/asm/required-features.h +2 -1
@@ -101,6 +101,7 @@#define REQUIRED_MASK16 0#define REQUIRED_MASK17 0#define REQUIRED_MASK18 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define REQUIRED_MASK19 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
arch/x86/kernel/cpu/common.c +3 -0
@@ -960,6 +960,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x8000000a ) c->x86_capability[CPUID_8000_000A_EDX ] =cpuid_edx (0x8000000a ); +if (c->extended_cpuid_level >=0x8000001f ) + c->x86_capability[CPUID_8000_001F_EAX ] =cpuid_eax (0x8000001f ); +init_scattered_cpuid_features (c);init_speculation_control (c);
arch/x86/kernel/cpu/scattered.c +0 -5
@@ -40,11 +40,6 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, - { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 }, - { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 }, - { X86_FEATURE_SEV_ES, CPUID_EAX, 3, 0x8000001f, 0 }, - { X86_FEATURE_SME_COHERENT, CPUID_EAX, 10, 0x8000001f, 0 }, - { X86_FEATURE_VM_PAGE_FLUSH, CPUID_EAX, 2, 0x8000001f, 0 }, { 0, 0, 0, 0, 0 } };
tools/arch/x86/include/asm/disabled-features.h +2 -1
@@ -91,6 +91,7 @@ DISABLE_ENQCMD)#define DISABLED_MASK17 0#define DISABLED_MASK18 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define DISABLED_MASK19 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_DISABLED_FEATURES_H */
tools/arch/x86/include/asm/required-features.h +2 -1
@@ -101,6 +101,7 @@#define REQUIRED_MASK16 0#define REQUIRED_MASK17 0#define REQUIRED_MASK18 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define REQUIRED_MASK19 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
Signature · 1 line
2.30.0.280.ga3ce27912f-goog
[tip: x86/cpu] x86/cpufeatures: Assign dedicated feature word for CPUID_0x8000001F[EAX]
The following commit has been merged into the x86/cpu branch of tip:
The following commit has been merged into the x86/cpu branch of tip:
Commit-ID: fb35d30fe5b06cc24444f0405da8fbe0be5330d1 Gitweb: https://git.kernel.org/tip/fb35d30fe5b06cc24444f0405da8fbe0be5330d1 Author: Sean Christopherson <[email protected]> AuthorDate: Fri, 22 Jan 2021 12:40:46 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Thu, 28 Jan 2021 17:41:24 +01:00
x86/cpufeatures: Assign dedicated feature word for CPUID_0x8000001F[EAX]
Collect the scattered SME/SEV related feature flags into a dedicated word. There are now five recognized features in CPUID.0x8000001F.EAX, with at least one more on the horizon (SEV-SNP). Using a dedicated word allows KVM to use its automagic CPUID adjustment logic when reporting the set of supported features to userspace.
No functional change intended.
--- arch/x86/include/asm/cpufeature.h | 7 +++++-- arch/x86/include/asm/cpufeatures.h | 17 +++++++++++------ arch/x86/include/asm/disabled-features.h | 3 ++- arch/x86/include/asm/required-features.h | 3 ++- arch/x86/kernel/cpu/common.c | 3 +++- arch/x86/kernel/cpu/scattered.c | 5 +----- tools/arch/x86/include/asm/disabled-features.h | 3 ++- tools/arch/x86/include/asm/required-features.h | 3 ++- 8 files changed, 27 insertions(+), 17 deletions(-)
arch/x86/include/asm/cpufeature.h +5 -2
@@ -30,6 +30,7 @@ enum cpuid_leafsCPUID_7_ECX ,CPUID_8000_0007_EBX ,CPUID_7_EDX , + CPUID_8000_001F_EAX, };#ifdef CONFIG_X86_FEATURE_NAMES
@@ -88,8 +89,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 19, feature_bit) || \ REQUIRED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 19)) + BUILD_BUG_ON_ZERO(NCAPINTS != 20))#define DISABLED_MASK_BIT_SET (feature_bit) \ ( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -111,8 +113,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32]; CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \ CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \ + CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 19, feature_bit) || \ DISABLED_MASK_CHECK || \ - BUILD_BUG_ON_ZERO(NCAPINTS != 19)) + BUILD_BUG_ON_ZERO(NCAPINTS != 20))#define cpu_has (c, bit) \ (__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \
arch/x86/include/asm/cpufeatures.h +11 -6
@@ -13,7 +13,7 @@/* * Defines x86 CPU feature bits */ -#define NCAPINTS 19/* N 32-bit words worth of info */ +#define NCAPINTS 20/* N 32-bit words worth of info */ #define NBUGINTS 1/* N 32-bit bug flags */ /*
@@ -96,7 +96,7 @@#define X86_FEATURE_SYSCALL32 ( 3*32+14)/* "" syscall in IA32 userspace */ #define X86_FEATURE_SYSENTER32 ( 3*32+15)/* "" sysenter in IA32 userspace */ #define X86_FEATURE_REP_GOOD ( 3*32+16)/* REP microcode works well */ -#define X86_FEATURE_SME_COHERENT ( 3*32+17)/* "" AMD hardware-enforced cache coherency */ +/* FREE! ( 3*32+17) */ #define X86_FEATURE_LFENCE_RDTSC ( 3*32+18)/* "" LFENCE synchronizes RDTSC */ #define X86_FEATURE_ACC_POWER ( 3*32+19)/* AMD Accumulated Power Mechanism */ #define X86_FEATURE_NOPL ( 3*32+20)/* The NOPL (0F 1F) instructions */
@@ -201,7 +201,7 @@#define X86_FEATURE_INVPCID_SINGLE ( 7*32+ 7)/* Effectively INVPCID && CR4.PCIDE=1 */ #define X86_FEATURE_HW_PSTATE ( 7*32+ 8)/* AMD HW-PState */ #define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9)/* AMD ProcFeedbackInterface */ -#define X86_FEATURE_SME ( 7*32+10)/* AMD Secure Memory Encryption */ +/* FREE! ( 7*32+10) */ #define X86_FEATURE_PTI ( 7*32+11)/* Kernel Page Table Isolation enabled */ #define X86_FEATURE_RETPOLINE ( 7*32+12)/* "" Generic Retpoline mitigation for Spectre variant 2 */ #define X86_FEATURE_RETPOLINE_AMD ( 7*32+13)/* "" AMD Retpoline mitigation for Spectre variant 2 */
@@ -211,7 +211,7 @@#define X86_FEATURE_SSBD ( 7*32+17)/* Speculative Store Bypass Disable */ #define X86_FEATURE_MBA ( 7*32+18)/* Memory Bandwidth Allocation */ #define X86_FEATURE_RSB_CTXSW ( 7*32+19)/* "" Fill RSB on context switches */ -#define X86_FEATURE_SEV ( 7*32+20)/* AMD Secure Encrypted Virtualization */ +/* FREE! ( 7*32+20) */ #define X86_FEATURE_USE_IBPB ( 7*32+21)/* "" Indirect Branch Prediction Barrier enabled */ #define X86_FEATURE_USE_IBRS_FW ( 7*32+22)/* "" Use IBRS during runtime firmware calls */ #define X86_FEATURE_SPEC_STORE_BYPASS_DISABLE ( 7*32+23)/* "" Disable Speculative Store Bypass. */
@@ -236,8 +236,6 @@#define X86_FEATURE_EPT_AD ( 8*32+17)/* Intel Extended Page Table access-dirty bit */ #define X86_FEATURE_VMCALL ( 8*32+18)/* "" Hypervisor supports the VMCALL instruction */ #define X86_FEATURE_VMW_VMMCALL ( 8*32+19)/* "" VMware prefers VMMCALL hypercall instruction */ -#define X86_FEATURE_SEV_ES ( 8*32+20)/* AMD Secure Encrypted Virtualization - Encrypted State */ -#define X86_FEATURE_VM_PAGE_FLUSH ( 8*32+21)/* "" VM Page Flush MSR is supported */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ #define X86_FEATURE_FSGSBASE ( 9*32+ 0)/* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
@@ -385,6 +383,13 @@#define X86_FEATURE_CORE_CAPABILITIES (18*32+30)/* "" IA32_CORE_CAPABILITIES MSR */ #define X86_FEATURE_SPEC_CTRL_SSBD (18*32+31)/* "" Speculative Store Bypass Disable */ +/* AMD-defined memory encryption features, CPUID level 0x8000001f (EAX), word 19 */ +#define X86_FEATURE_SME (19*32+ 0)/* AMD Secure Memory Encryption */ +#define X86_FEATURE_SEV (19*32+ 1)/* AMD Secure Encrypted Virtualization */ +#define X86_FEATURE_VM_PAGE_FLUSH (19*32+ 2)/* "" VM Page Flush MSR is supported */ +#define X86_FEATURE_SEV_ES (19*32+ 3)/* AMD Secure Encrypted Virtualization - Encrypted State */ +#define X86_FEATURE_SME_COHERENT (19*32+10)/* "" AMD hardware-enforced cache coherency */ +/* * BUG word(s) */
arch/x86/include/asm/disabled-features.h +2 -1
@@ -91,6 +91,7 @@ DISABLE_ENQCMD)#define DISABLED_MASK17 0#define DISABLED_MASK18 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define DISABLED_MASK19 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_DISABLED_FEATURES_H */
arch/x86/include/asm/required-features.h +2 -1
@@ -101,6 +101,7 @@#define REQUIRED_MASK16 0#define REQUIRED_MASK17 0#define REQUIRED_MASK18 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define REQUIRED_MASK19 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
arch/x86/kernel/cpu/common.c +3 -0
@@ -960,6 +960,9 @@ void get_cpu_cap(struct cpuinfo_x86 *c)if (c->extended_cpuid_level >=0x8000000a ) c->x86_capability[CPUID_8000_000A_EDX ] =cpuid_edx (0x8000000a ); +if (c->extended_cpuid_level >=0x8000001f ) + c->x86_capability[CPUID_8000_001F_EAX ] =cpuid_eax (0x8000001f ); +init_scattered_cpuid_features (c);init_speculation_control (c);
arch/x86/kernel/cpu/scattered.c +0 -5
@@ -40,11 +40,6 @@ static const struct cpuid_bit cpuid_bits[] = { { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, - { X86_FEATURE_SME, CPUID_EAX, 0, 0x8000001f, 0 }, - { X86_FEATURE_SEV, CPUID_EAX, 1, 0x8000001f, 0 }, - { X86_FEATURE_SEV_ES, CPUID_EAX, 3, 0x8000001f, 0 }, - { X86_FEATURE_SME_COHERENT, CPUID_EAX, 10, 0x8000001f, 0 }, - { X86_FEATURE_VM_PAGE_FLUSH, CPUID_EAX, 2, 0x8000001f, 0 }, { 0, 0, 0, 0, 0 } };
tools/arch/x86/include/asm/disabled-features.h +2 -1
@@ -91,6 +91,7 @@ DISABLE_ENQCMD)#define DISABLED_MASK17 0#define DISABLED_MASK18 0 -#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define DISABLED_MASK19 0 +#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_DISABLED_FEATURES_H */
tools/arch/x86/include/asm/required-features.h +2 -1
@@ -101,6 +101,7 @@#define REQUIRED_MASK16 0#define REQUIRED_MASK17 0#define REQUIRED_MASK18 0 -#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19) +#define REQUIRED_MASK19 0 +#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20)#endif /* _ASM_X86_REQUIRED_FEATURES_H */
Sean Christopherson
maintainerPATCH v3 2/2 KVM: x86: Override reported SME/SEV feature flags with host mask
In reply to Sean ChristophersonAdd a reverse-CPUID entry for the memory encryption word, 0x8000001F.EAX, and use it to override the supported CPUID flags reported to userspace. Masking the reported CPUID flags avoids over-reporting KVM support, e.g. without the mask a SEV-SNP capable CPU may incorrectly advertise SNP support to userspace.
--- arch/x86/kvm/cpuid.c | 2 ++ arch/x86/kvm/cpuid.h | 1 + 2 files changed, 3 insertions(+)
arch/x86/kvm/cpuid.c +2 -0
@@ -855,6 +855,8 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)case 0x8000001F :if (!boot_cpu_has (X86_FEATURE_SEV )) entry->eax = entry->ebx = entry->ecx = entry->edx =0 ; +else +cpuid_entry_override (entry,CPUID_8000_001F_EAX );break ;/*Add support for Centaur's CPUID instruction*/ case 0xC0000000 :
arch/x86/kvm/cpuid.h +1 -0
@@ -63,6 +63,7 @@ static const struct cpuid_reg reverse_cpuid[] = { [CPUID_8000_0007_EBX] = {0x80000007, 0, CPUID_EBX}, [CPUID_7_EDX] = { 7, 0, CPUID_EDX}, [CPUID_7_1_EAX] = { 7, 1, CPUID_EAX}, + [CPUID_8000_001F_EAX] = {0x8000001f, 1, CPUID_EAX}, };/*
Signature · 1 line
2.30.0.280.ga3ce27912f-goog