Skip to content

Commit

Permalink
KVM: Clear exception queue before emulating an instruction
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Avi Kivity committed Oct 15, 2008
1 parent 668f612 commit 26eef70
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "i8254.h"
#include "tss.h"
#include "kvm_cache_regs.h"
#include "x86.h"

#include <linux/clocksource.h>
#include <linux/kvm.h>
Expand Down Expand Up @@ -2121,6 +2122,7 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
int r;
struct decode_cache *c;

kvm_clear_exception_queue(vcpu);
vcpu->arch.mmio_fault_cr2 = cr2;
/*
* TODO: fix x86_emulate.c to use guest_read/write_register
Expand Down
11 changes: 11 additions & 0 deletions arch/x86/kvm/x86.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 26eef70

Please sign in to comment.