[PATCH] VMX: Return to userspace on invalid state emulation failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Return to userspace instead of repeatedly trying to emulate
instructions that have already failed

Signed-off-by: Mohammed Gamal <m.gamal005@xxxxxxxxx>
---
 arch/x86/kvm/vmx.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 1ee811c..423e44f 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3341,6 +3341,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
 
 		if (err != EMULATE_DONE) {
 			kvm_report_emulation_failure(vcpu, "emulation failure");
+			kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
+			kvm_run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
 			break;
 		}
 
@@ -3612,7 +3614,9 @@ static void vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 		vmx->entry_time = ktime_get();
 
 	/* Handle invalid guest state instead of entering VMX */
-	if (vmx->emulation_required && emulate_invalid_guest_state) {
+	if (vmx->emulation_required && emulate_invalid_guest_state
+		&& !(kvm_run->exit_reason == KVM_EXIT_INTERNAL_ERROR && 
+		  kvm_run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION)) {
 		handle_invalid_guest_state(vcpu, kvm_run);
 		return;
 	}
-- 
1.6.0.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux