From: Sean Christopherson <sean.j.christopher...@intel.com>

Pass intr_info to the NMI and INTR handlers instead of pulling it from
vcpu_vmx in preparation for sharing the bulk of the handlers with TDX.

Signed-off-by: Sean Christopherson <sean.j.christopher...@intel.com>
---
 arch/x86/kvm/vmx/vmx.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 997a391f0842..5d6c3a50230d 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6358,25 +6358,21 @@ static void handle_interrupt_nmi_irqoff(struct kvm_vcpu 
*vcpu, u32 intr_info)
        kvm_after_interrupt(vcpu);
 }
 
-static void handle_exception_nmi_irqoff(struct vcpu_vmx *vmx)
+static void handle_exception_nmi_irqoff(struct kvm_vcpu *vcpu, u32 intr_info)
 {
-       u32 intr_info = vmx_get_intr_info(&vmx->vcpu);
-
        /* if exit due to PF check for async PF */
        if (is_page_fault(intr_info))
-               vmx->vcpu.arch.apf.host_apf_flags = 
kvm_read_and_reset_apf_flags();
+               vcpu->arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags();
        /* Handle machine checks before interrupts are enabled */
        else if (is_machine_check(intr_info))
                kvm_machine_check();
        /* We need to handle NMIs before interrupts are enabled */
        else if (is_nmi(intr_info))
-               handle_interrupt_nmi_irqoff(&vmx->vcpu, intr_info);
+               handle_interrupt_nmi_irqoff(vcpu, intr_info);
 }
 
-static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
+static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu, u32 
intr_info)
 {
-       u32 intr_info = vmx_get_intr_info(vcpu);
-
        if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm,
            "KVM: unexpected VM-Exit interrupt info: 0x%x", intr_info))
                return;
@@ -6389,9 +6385,9 @@ static void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
        struct vcpu_vmx *vmx = to_vmx(vcpu);
 
        if (vmx->exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT)
-               handle_external_interrupt_irqoff(vcpu);
+               handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu));
        else if (vmx->exit_reason == EXIT_REASON_EXCEPTION_NMI)
-               handle_exception_nmi_irqoff(vmx);
+               handle_exception_nmi_irqoff(vcpu, vmx_get_intr_info(vcpu));
 }
 
 static bool vmx_has_emulated_msr(struct kvm *kvm, u32 index)
-- 
2.17.1

Reply via email to