diff options
author | Avi Kivity <avi@qumranet.com> | 2007-11-25 07:04:58 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:18 -0500 |
commit | c3c91fee5195ba5176a6da5ddc2a2822243eb79f (patch) | |
tree | 1fcccd77e5705d5f885bbb24ecb08bd93cf71c63 /drivers/kvm/x86.c | |
parent | 298101da2f507c13eaf179ee4507a7c0fe3e7b06 (diff) |
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.c | 17 |
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) | |||
142 | } | 142 | } |
143 | EXPORT_SYMBOL_GPL(kvm_queue_exception); | 143 | EXPORT_SYMBOL_GPL(kvm_queue_exception); |
144 | 144 | ||
145 | void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr, | ||
146 | u32 error_code) | ||
147 | { | ||
148 | ++vcpu->stat.pf_guest; | ||
149 | if (vcpu->exception.pending && vcpu->exception.nr == PF_VECTOR) { | ||
150 | printk(KERN_DEBUG "kvm: inject_page_fault:" | ||
151 | " double fault 0x%lx\n", addr); | ||
152 | vcpu->exception.nr = DF_VECTOR; | ||
153 | vcpu->exception.error_code = 0; | ||
154 | return; | ||
155 | } | ||
156 | vcpu->cr2 = addr; | ||
157 | kvm_queue_exception_e(vcpu, PF_VECTOR, error_code); | ||
158 | } | ||
159 | |||
145 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code) | 160 | void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code) |
146 | { | 161 | { |
147 | WARN_ON(vcpu->exception.pending); | 162 | WARN_ON(vcpu->exception.pending); |
@@ -1601,7 +1616,7 @@ static int emulator_write_emulated_onepage(unsigned long addr, | |||
1601 | gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr); | 1616 | gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr); |
1602 | 1617 | ||
1603 | if (gpa == UNMAPPED_GVA) { | 1618 | if (gpa == UNMAPPED_GVA) { |
1604 | kvm_x86_ops->inject_page_fault(vcpu, addr, 2); | 1619 | kvm_inject_page_fault(vcpu, addr, 2); |
1605 | return X86EMUL_PROPAGATE_FAULT; | 1620 | return X86EMUL_PROPAGATE_FAULT; |
1606 | } | 1621 | } |
1607 | 1622 | ||