Skip to content

Commit 2325a21

Browse files
sean-jcbonzini
authored andcommitted
KVM: VMX: Modify NMI and INTR handlers to take intr_info as function argument
TDX uses different ABI to get information about VM exit. 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. When the guest TD exits to VMM, RAX holds status and exit reason, RCX holds exit qualification etc rather than the VMCS fields because VMM doesn't have access to the VMCS. The eventual code will be VMX: - get exit reason, intr_info, exit_qualification, and etc from VMCS - call NMI/INTR handlers (common code) TDX: - get exit reason, intr_info, exit_qualification, and etc from guest registers - call NMI/INTR handlers (common code) Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Isaku Yamahata <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Message-Id: <0396a9ae70d293c9d0b060349dae385a8a4fbcec.1705965635.git.isaku.yamahata@intel.com> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5f18c64 commit 2325a21

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6956,24 +6956,22 @@ static void handle_nm_fault_irqoff(struct kvm_vcpu *vcpu)
69566956
rdmsrl(MSR_IA32_XFD_ERR, vcpu->arch.guest_fpu.xfd_err);
69576957
}
69586958

6959-
static void handle_exception_irqoff(struct vcpu_vmx *vmx)
6959+
static void handle_exception_irqoff(struct kvm_vcpu *vcpu, u32 intr_info)
69606960
{
6961-
u32 intr_info = vmx_get_intr_info(&vmx->vcpu);
6962-
69636961
/* if exit due to PF check for async PF */
69646962
if (is_page_fault(intr_info))
6965-
vmx->vcpu.arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags();
6963+
vcpu->arch.apf.host_apf_flags = kvm_read_and_reset_apf_flags();
69666964
/* if exit due to NM, handle before interrupts are enabled */
69676965
else if (is_nm_fault(intr_info))
6968-
handle_nm_fault_irqoff(&vmx->vcpu);
6966+
handle_nm_fault_irqoff(vcpu);
69696967
/* Handle machine checks before interrupts are enabled */
69706968
else if (is_machine_check(intr_info))
69716969
kvm_machine_check();
69726970
}
69736971

6974-
static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu)
6972+
static void handle_external_interrupt_irqoff(struct kvm_vcpu *vcpu,
6973+
u32 intr_info)
69756974
{
6976-
u32 intr_info = vmx_get_intr_info(vcpu);
69776975
unsigned int vector = intr_info & INTR_INFO_VECTOR_MASK;
69786976

69796977
if (KVM_BUG(!is_external_intr(intr_info), vcpu->kvm,
@@ -6998,9 +6996,9 @@ void vmx_handle_exit_irqoff(struct kvm_vcpu *vcpu)
69986996
return;
69996997

70006998
if (vmx->exit_reason.basic == EXIT_REASON_EXTERNAL_INTERRUPT)
7001-
handle_external_interrupt_irqoff(vcpu);
6999+
handle_external_interrupt_irqoff(vcpu, vmx_get_intr_info(vcpu));
70027000
else if (vmx->exit_reason.basic == EXIT_REASON_EXCEPTION_NMI)
7003-
handle_exception_irqoff(vmx);
7001+
handle_exception_irqoff(vcpu, vmx_get_intr_info(vcpu));
70047002
}
70057003

70067004
/*

0 commit comments

Comments
 (0)