Re: [PATCH v2 15/17] KVM: VMX: Add a helper for NMI handling
From: Sean Christopherson
Date: Tue Feb 11 2025 - 20:10:38 EST
On Tue, Feb 11, 2025, Binbin Wu wrote:
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 012649688e46..228a7e51b6a5 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -7212,6 +7212,20 @@ static fastpath_t vmx_exit_handlers_fastpath(struct kvm_vcpu *vcpu,
> }
> }
>
> +noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu)
> +{
> + if ((u16)vmx_get_exit_reason(vcpu).basic != EXIT_REASON_EXCEPTION_NMI ||
> + !is_nmi(vmx_get_intr_info(vcpu)))
Align indentation.
> + return;
> +
> + kvm_before_interrupt(vcpu, KVM_HANDLING_NMI);
> + if (cpu_feature_enabled(X86_FEATURE_FRED))
> + fred_entry_from_kvm(EVENT_TYPE_NMI, NMI_VECTOR);
> + else
> + vmx_do_nmi_irqoff();
> + kvm_after_interrupt(vcpu);
> +}