On 6/11/2022 1:11 AM, Jue Wang wrote:
...
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4790f0d7d40b..a08693808729 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -4772,6 +4772,8 @@ static int kvm_vcpu_ioctl_x86_setup_mce(struct kvm_vcpu *vcpu,
/* Init IA32_MCi_CTL to all 1s */
for (bank = 0; bank < bank_num; bank++)
vcpu->arch.mce_banks[bank*4] = ~(u64)0;
+ vcpu->arch.apic->nr_lvt_entries =
+ KVM_APIC_MAX_NR_LVT_ENTRIES - !(mcg_cap & MCG_CMCI_P);
vcpu->arch.apic->nr_lvt_entries needs to be initialized as
KVM_APIC_MAX_NR_LVT_ENTREIS - 1 when creating lapic.
What if userspace doesn't call KVM_X86_SETUP_MCE at all?
static_call(kvm_x86_setup_mce)(vcpu);
out: