summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorJoerg Roedel2010-09-10 17:30:55 +0200
committerAvi Kivity2010-10-24 10:52:40 +0200
commitd4f8cf664e4c1fd579df6b6e6378335c9f79d790 (patch)
treee5f5ce71daa78ebf2bae27d355f1e9a11d59ef77 /arch/x86/kvm/x86.c
parentKVM: MMU: Introduce init_kvm_nested_mmu() (diff)
downloadkernel-qcow2-linux-d4f8cf664e4c1fd579df6b6e6378335c9f79d790.tar.gz
kernel-qcow2-linux-d4f8cf664e4c1fd579df6b6e6378335c9f79d790.tar.xz
kernel-qcow2-linux-d4f8cf664e4c1fd579df6b6e6378335c9f79d790.zip
KVM: MMU: Propagate the right fault back to the guest after gva_to_gpa
This patch implements logic to make sure that either a page-fault/page-fault-vmexit or a nested-page-fault-vmexit is propagated back to the guest. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e4c76bf86081..0281d920e9ed 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -338,6 +338,22 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu)
kvm_queue_exception_e(vcpu, PF_VECTOR, error_code);
}
+void kvm_propagate_fault(struct kvm_vcpu *vcpu)
+{
+ u32 nested, error;
+
+ error = vcpu->arch.fault.error_code;
+ nested = error & PFERR_NESTED_MASK;
+ error = error & ~PFERR_NESTED_MASK;
+
+ vcpu->arch.fault.error_code = error;
+
+ if (mmu_is_nested(vcpu) && !nested)
+ vcpu->arch.nested_mmu.inject_page_fault(vcpu);
+ else
+ vcpu->arch.mmu.inject_page_fault(vcpu);
+}
+
void kvm_inject_nmi(struct kvm_vcpu *vcpu)
{
vcpu->arch.nmi_pending = 1;
@@ -4140,7 +4156,7 @@ static void inject_emulated_exception(struct kvm_vcpu *vcpu)
{
struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
if (ctxt->exception == PF_VECTOR)
- kvm_inject_page_fault(vcpu);
+ kvm_propagate_fault(vcpu);
else if (ctxt->error_code_valid)
kvm_queue_exception_e(vcpu, ctxt->exception, ctxt->error_code);
else