I have sent out two patches to address this bug and an #GP reported by syzkaller. https://lore.kernel.org/kvm/20220701165045.4074471-1-juew@xxxxxxxxxx/ Thanks again for the review and reporting of this issue! Best regards, -Jue On Thu, Jun 30, 2022 at 7:07 PM Xiaoyao Li <xiaoyao.li@xxxxxxxxx> wrote: > > 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: >