summaryrefslogtreecommitdiff
path: root/drivers/kvm/x86.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-11-25 14:04:58 +0200
committerAvi Kivity <avi@qumranet.com>2008-01-30 17:53:18 +0200
commitc3c91fee5195ba5176a6da5ddc2a2822243eb79f (patch)
tree1fcccd77e5705d5f885bbb24ecb08bd93cf71c63 /drivers/kvm/x86.c
parent298101da2f507c13eaf179ee4507a7c0fe3e7b06 (diff)
downloadlwn-c3c91fee5195ba5176a6da5ddc2a2822243eb79f.tar.gz
lwn-c3c91fee5195ba5176a6da5ddc2a2822243eb79f.zip
KVM: Replace page fault injection by the generalized exception queue
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/x86.c')
-rw-r--r--drivers/kvm/x86.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 11440d12a2d3..dc007a32a883 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -142,6 +142,21 @@ void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr)
}
EXPORT_SYMBOL_GPL(kvm_queue_exception);
+void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr,
+ u32 error_code)
+{
+ ++vcpu->stat.pf_guest;
+ if (vcpu->exception.pending && vcpu->exception.nr == PF_VECTOR) {
+ printk(KERN_DEBUG "kvm: inject_page_fault:"
+ " double fault 0x%lx\n", addr);
+ vcpu->exception.nr = DF_VECTOR;
+ vcpu->exception.error_code = 0;
+ return;
+ }
+ vcpu->cr2 = addr;
+ kvm_queue_exception_e(vcpu, PF_VECTOR, error_code);
+}
+
void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code)
{
WARN_ON(vcpu->exception.pending);
@@ -1601,7 +1616,7 @@ static int emulator_write_emulated_onepage(unsigned long addr,
gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr);
if (gpa == UNMAPPED_GVA) {
- kvm_x86_ops->inject_page_fault(vcpu, addr, 2);
+ kvm_inject_page_fault(vcpu, addr, 2);
return X86EMUL_PROPAGATE_FAULT;
}