Commit 789afc5c authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: nVMX: Move reflection check into nested_vmx_reflect_vmexit()

Move the call to nested_vmx_exit_reflected() from vmx_handle_exit() into
nested_vmx_reflect_vmexit() and change the semantics of the return value
for nested_vmx_reflect_vmexit() to indicate whether or not the exit was
reflected into L1.  nested_vmx_exit_reflected() and
nested_vmx_reflect_vmexit() are intrinsically tied together, calling one
without simultaneously calling the other makes little sense.

No functional change intended.
Reviewed-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Message-Id: <20200415175519.14230-2-sean.j.christopherson@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 812756a8
...@@ -81,12 +81,16 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu) ...@@ -81,12 +81,16 @@ static inline bool nested_ept_ad_enabled(struct kvm_vcpu *vcpu)
} }
/* /*
* Reflect a VM Exit into L1. * Conditionally reflect a VM-Exit into L1. Returns %true if the VM-Exit was
* reflected into L1.
*/ */
static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, static inline bool nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
u32 exit_reason) u32 exit_reason)
{ {
u32 exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO); u32 exit_intr_info;
if (!nested_vmx_exit_reflected(vcpu, exit_reason))
return false;
/* /*
* At this point, the exit interruption info in exit_intr_info * At this point, the exit interruption info in exit_intr_info
...@@ -94,6 +98,8 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, ...@@ -94,6 +98,8 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
* we need to query the in-kernel LAPIC. * we need to query the in-kernel LAPIC.
*/ */
WARN_ON(exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT); WARN_ON(exit_reason == EXIT_REASON_EXTERNAL_INTERRUPT);
exit_intr_info = vmcs_read32(VM_EXIT_INTR_INFO);
if ((exit_intr_info & if ((exit_intr_info &
(INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) == (INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) ==
(INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) { (INTR_INFO_VALID_MASK | INTR_INFO_DELIVER_CODE_MASK)) {
...@@ -105,7 +111,7 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu, ...@@ -105,7 +111,7 @@ static inline int nested_vmx_reflect_vmexit(struct kvm_vcpu *vcpu,
nested_vmx_vmexit(vcpu, exit_reason, exit_intr_info, nested_vmx_vmexit(vcpu, exit_reason, exit_intr_info,
vmcs_readl(EXIT_QUALIFICATION)); vmcs_readl(EXIT_QUALIFICATION));
return 1; return true;
} }
/* /*
......
...@@ -5905,8 +5905,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu, ...@@ -5905,8 +5905,8 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu,
*/ */
nested_mark_vmcs12_pages_dirty(vcpu); nested_mark_vmcs12_pages_dirty(vcpu);
if (nested_vmx_exit_reflected(vcpu, exit_reason)) if (nested_vmx_reflect_vmexit(vcpu, exit_reason))
return nested_vmx_reflect_vmexit(vcpu, exit_reason); return 1;
} }
if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) { if (exit_reason & VMX_EXIT_REASONS_FAILED_VMENTRY) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment