瀏覽代碼

KVM: Clear exception queue before emulating an instruction

If we're emulating an instruction, either it will succeed, in which case
any previously queued exception will be spurious, or we will requeue the
same exception.

Signed-off-by: Avi Kivity <avi@qumranet.com>
Avi Kivity 17 年之前
父節點
當前提交
26eef70c3e
共有 2 個文件被更改,包括 13 次插入0 次删除
  1. 2 0
      arch/x86/kvm/x86.c
  2. 11 0
      arch/x86/kvm/x86.h

+ 2 - 0
arch/x86/kvm/x86.c

@@ -20,6 +20,7 @@
 #include "i8254.h"
 #include "i8254.h"
 #include "tss.h"
 #include "tss.h"
 #include "kvm_cache_regs.h"
 #include "kvm_cache_regs.h"
+#include "x86.h"
 
 
 #include <linux/clocksource.h>
 #include <linux/clocksource.h>
 #include <linux/kvm.h>
 #include <linux/kvm.h>
@@ -2121,6 +2122,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
 	int r;
 	int r;
 	struct decode_cache *c;
 	struct decode_cache *c;
 
 
+	kvm_clear_exception_queue(vcpu);
 	vcpu->arch.mmio_fault_cr2 = cr2;
 	vcpu->arch.mmio_fault_cr2 = cr2;
 	/*
 	/*
 	 * TODO: fix x86_emulate.c to use guest_read/write_register
 	 * TODO: fix x86_emulate.c to use guest_read/write_register

+ 11 - 0
arch/x86/kvm/x86.h

@@ -0,0 +1,11 @@
+#ifndef ARCH_X86_KVM_X86_H
+#define ARCH_X86_KVM_X86_H
+
+#include <linux/kvm_host.h>
+
+static inline void kvm_clear_exception_queue(struct kvm_vcpu *vcpu)
+{
+	vcpu->arch.exception.pending = false;
+}
+
+#endif