On Tue, Oct 10, 2023, isaku.yamahata@xxxxxxxxx wrote: > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > The KVM/x86 handles machine-check in the guest specially. It sets up the > guest so that vcpu exits from running guests, checks the exit reason and, > manually raises the machine check by calling do_machine_check(). > > To test the KVM machine check execution path, KVM wants to inject the > machine check in the context of vcpu instead of the context of the process > of MCE injection. Wire up the MCE injection framework for KVM to trigger > MCE in the vcpu context. Add a kvm vcpu debugfs entry for an operator to > tell KVM to inject MCE. But this isn't "injecting" a #MC, it's just having KVM call do_machine_check() before enabling IRQs after a VM-Exit. I don't see how that is interesting enough to warrant a dedicated knob and code in KVM's run loop. > @@ -10814,6 +10823,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) > fpu_sync_guest_vmexit_xfd_state(); > > static_call(kvm_x86_handle_exit_irqoff)(vcpu); > + if (unlikely(req_mce_inject)) { > + mce_call_atomic_injector_chain(smp_processor_id()); > + kvm_machine_check(); > + mce_inject_unlock(); > + } > > if (vcpu->arch.guest_fpu.xfd_err) > wrmsrl(MSR_IA32_XFD_ERR, 0); > -- > 2.25.1 >