KVM needs to check if guests can see BHI_CTRL. If a guest is using
BHB-clearing sequence and cannot see BHI_CTRL and the host enumerates BHI,
KVM is responsible for setting BHI_DIS_S for the guest.
This allows VM migration from parts doesn't enumerate BHI to those
that enumerate BHI.
Signed-off-by: Zhang Chen <[email protected]>
---
arch/x86/kvm/cpuid.c | 2 +-
arch/x86/kvm/reverse_cpuid.h | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 8d45bc0b4b7c..91af27cc57e5 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -669,7 +669,7 @@ void kvm_set_cpu_caps(void)
);
kvm_cpu_cap_init_scattered(CPUID_7_2_EDX,
- SF(RRSBA_CTRL)
+ SF(RRSBA_CTRL) | F(BHI_CTRL)
);
kvm_cpu_cap_mask(CPUID_8000_0001_ECX,
diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h
index 4c38ed61c505..cf4e209ce2f6 100644
--- a/arch/x86/kvm/reverse_cpuid.h
+++ b/arch/x86/kvm/reverse_cpuid.h
@@ -27,6 +27,8 @@ enum kvm_only_cpuid_leafs {
/* Intel-defined sub-features, CPUID level 0x00000007:2 (EDX)*/
#define KVM_X86_FEATURE_RRSBA_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 2)
+/* X86_FEATURE_BHI_CTRL only used by KVM */
+#define X86_FEATURE_BHI_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 4)
struct cpuid_reg {
u32 function;
--
2.25.1
On Sun, Dec 11, 2022 at 12:00:40AM +0800, Zhang Chen wrote:
> KVM needs to check if guests can see BHI_CTRL. If a guest is using
> BHB-clearing sequence and cannot see BHI_CTRL and the host enumerates BHI,
> KVM is responsible for setting BHI_DIS_S for the guest.
>
> This allows VM migration from parts doesn't enumerate BHI to those
> that enumerate BHI.
Similar comment as in patch 2.