KVM: x86: Advertise SUCCOR and OVERFLOW_RECOV cpuid bits
PATCH 1/1 KVM: x86: Advertise SUCCOR and OVERFLOW_RECOV cpuid bits
Handling deferred, uncorrected MCEs on AMD guests is now possible with additional support in qemu. Ensure that the SUCCOR and OVERFLOW_RECOV bits are advertised to the guest in KVM.
--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)
arch/x86/kvm/cpuid.c +1 -1
@@ -1241,7 +1241,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)/* mask against host */ entry->edx &= boot_cpu_data.x86_power; - entry->eax = entry->ebx = entry->ecx =0 ; + entry->eax = entry->ecx =0 ;break ;case 0x80000008 : {/*
arch/x86/kvm/svm/svm.c +7 -0
@@ -5199,6 +5199,13 @@ static __init void svm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SVME_ADDR_CHK ); } +/* CPUID 0x80000007 */ +if (boot_cpu_has (X86_FEATURE_SUCCOR )) +kvm_cpu_cap_set (X86_FEATURE_SUCCOR ); + +if (boot_cpu_has (X86_FEATURE_OVERFLOW_RECOV )) +kvm_cpu_cap_set (X86_FEATURE_OVERFLOW_RECOV ); +/* CPUID 0x80000008 */ if (boot_cpu_has (X86_FEATURE_LS_CFG_SSBD ) ||boot_cpu_has (X86_FEATURE_AMD_SSBD ))
Signature · 1 line
2.34.1
Sean Christopherson
maintainerQuoted 16 lines · John Allen
Handling deferred, uncorrected MCEs on AMD guests is now possible with additional support in qemu. Ensure that the SUCCOR and
OVERFLOW_RECOVbits are advertised to the guest in KVM.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by John Allen <[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/x86/kvm/cpuid.c +0
-0
arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1244
Quoted 5 lines
arch/x86/kvm/cpuid.c +1
-1@@ -1241,7 +1241,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)/* mask against host */ entry->edx &= boot_cpu_data.x86_power; - entry->eax = entry->ebx = entry->ecx =0 ; + entry->eax = entry->ecx =0 ;
Needs an override to prevent reporting all of EBX to userspace.
cpuid_entry_override(entry, CPUID_8000_0007_EBX);
Quoted 8 lines
arch/x86/kvm/cpuid.c +0
-0break ;case 0x80000008 : {/* arch/x86/kvm/svm/svm.c +0
-0
arch/x86/kvm/svm/svm.c static __init void svm_set_cpu_caps(void) · line 5207
Quoted 9 lines
arch/x86/kvm/svm/svm.c +6
-0@@ -5199,6 +5199,13 @@ static __init void svm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SVME_ADDR_CHK ); } +/* CPUID 0x80000007 */ +if (boot_cpu_has (X86_FEATURE_SUCCOR )) +kvm_cpu_cap_set (X86_FEATURE_SUCCOR ); + +if (boot_cpu_has (X86_FEATURE_OVERFLOW_RECOV )) +kvm_cpu_cap_set (X86_FEATURE_OVERFLOW_RECOV );
This _could_ use kvm_cpu_cap_check_and_set(), but given that this an AMD specific leaf and unlikely to ever be used by Intel, I'm inclined to handle this in cpuid.c, with an opporunustic "conversion" to one feature per line[*]:
arch/x86/kvm/cpuid.c +5 -0
@@ -743,6 +743,11 @@ void kvm_set_cpu_caps(void)if (!tdp_enabled &&IS_ENABLED (CONFIG_X86_64 ))kvm_cpu_cap_set (X86_FEATURE_GBPAGES ); +kvm_cpu_cap_mask (CPUID_8000_0007_EBX , +F (OVERFLOW_RECOV ) | +F (SUCCOR ) + ); +kvm_cpu_cap_init_kvm_defined (CPUID_8000_0007_EDX ,SF (CONSTANT_TSC ) );
Quoted 18 lines · Sean Christopherson
Quoted 17 lines · John Allen
Handling deferred, uncorrected MCEs on AMD guests is now possible with additional support in qemu. Ensure that the SUCCOR and
OVERFLOW_RECOVbits are advertised to the guest in KVM.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by John Allen <[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/x86/kvm/cpuid.c +0
-0@@ -1241,7 +1241,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
Quoted 8 lines
arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1244
Quoted 4 lines
arch/x86/kvm/cpuid.c +1
-1/* mask against host */ entry->edx &= boot_cpu_data.x86_power; - entry->eax = entry->ebx = entry->ecx =0 ; + entry->eax = entry->ecx =0 ;Needs an override to prevent reporting all of EBX to userspace.
cpuid_entry_override(entry, CPUID_8000_0007_EBX);
Right, I see what you mean. We just want to expose these specific bits and not all of EBX. I think with the patch as it is along with the change you suggest below, this should resolve this as the above case already has the cpuid_entry_override just above where it cuts off. Or is there another place we need it?
Thanks,
John
Quoted 42 lines
Quoted 9 lines
arch/x86/kvm/cpuid.c +0
-0break ;case 0x80000008 : {/* arch/x86/kvm/svm/svm.c +0
-0arch/x86/kvm/svm/svm.c static __init void svm_set_cpu_caps(void) · line 5207
Quoted 9 lines
arch/x86/kvm/svm/svm.c +6
-0@@ -5199,6 +5199,13 @@ static __init void svm_set_cpu_caps(void)kvm_cpu_cap_set (X86_FEATURE_SVME_ADDR_CHK ); } +/* CPUID 0x80000007 */ +if (boot_cpu_has (X86_FEATURE_SUCCOR )) +kvm_cpu_cap_set (X86_FEATURE_SUCCOR ); + +if (boot_cpu_has (X86_FEATURE_OVERFLOW_RECOV )) +kvm_cpu_cap_set (X86_FEATURE_OVERFLOW_RECOV );This _could_ use
kvm_cpu_cap_check_and_set(), but given that this an AMD specific leaf and unlikely to ever be used by Intel, I'm inclined to handle this incpuid.c, with an opporunustic "conversion" to one feature per line[*]:arch/x86/kvm/cpuid.c +5
-0@@ -743,6 +743,11 @@ void kvm_set_cpu_caps(void)if (!tdp_enabled &&IS_ENABLED (CONFIG_X86_64 ))kvm_cpu_cap_set (X86_FEATURE_GBPAGES ); +kvm_cpu_cap_mask (CPUID_8000_0007_EBX , +F (OVERFLOW_RECOV ) | +F (SUCCOR ) + ); +kvm_cpu_cap_init_kvm_defined (CPUID_8000_0007_EDX ,SF (CONSTANT_TSC ) );
Sean Christopherson
maintainerQuoted 26 lines · John Allen
Quoted 25 lines · Sean Christopherson
Quoted 16 lines · John Allen
Handling deferred, uncorrected MCEs on AMD guests is now possible with additional support in qemu. Ensure that the SUCCOR and
OVERFLOW_RECOVbits are advertised to the guest in KVM.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by John Allen <[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/x86/kvm/cpuid.c +0
-0arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1244
Quoted 5 lines
arch/x86/kvm/cpuid.c +1
-1@@ -1241,7 +1241,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)/* mask against host */ entry->edx &= boot_cpu_data.x86_power; - entry->eax = entry->ebx = entry->ecx =0 ; + entry->eax = entry->ecx =0 ;Needs an override to prevent reporting all of EBX to userspace.
Quoted 6 lines
Quoted 1 line
cpuid_entry_override(entry, CPUID_8000_0007_EBX);Right, I see what you mean. We just want to expose these specific bits and not all of EBX. I think with the patch as it is along with the change you suggest below, this should resolve this as the above case already has the
cpuid_entry_overridejust above where it cuts off.
Heh, nope, it doesn't. The existing override is for EDX, this needs one for EBX.
Quoted 27 lines · Sean Christopherson
Quoted 26 lines · John Allen
Quoted 25 lines · Sean Christopherson
Quoted 16 lines · John Allen
Handling deferred, uncorrected MCEs on AMD guests is now possible with additional support in qemu. Ensure that the SUCCOR and
OVERFLOW_RECOVbits are advertised to the guest in KVM.Suggested-by Paolo Bonzini <[email protected]>Signed-off-by John Allen <[email protected]>--- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-)arch/x86/kvm/cpuid.c +0
-0arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 1244
Quoted 5 lines
arch/x86/kvm/cpuid.c +1
-1@@ -1241,7 +1241,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)/* mask against host */ entry->edx &= boot_cpu_data.x86_power; - entry->eax = entry->ebx = entry->ecx =0 ; + entry->eax = entry->ecx =0 ;Needs an override to prevent reporting all of EBX to userspace.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
cpuid_entry_override(entry, CPUID_8000_0007_EBX);Right, I see what you mean. We just want to expose these specific bits and not all of EBX. I think with the patch as it is along with the change you suggest below, this should resolve this as the above case already has the
cpuid_entry_overridejust above where it cuts off.Heh, nope, it doesn't. The existing override is for EDX, this needs one for EBX.
Ah, yes you're right. Sorry for the noise!