KVM: SVM: Implement MMU helper functions for Nested Nested Paging
authorJoerg Roedel <joerg.roedel@amd.com>
Fri, 10 Sep 2010 15:31:02 +0000 (17:31 +0200)
committerAvi Kivity <avi@redhat.com>
Sun, 24 Oct 2010 08:52:45 +0000 (10:52 +0200)
This patch adds the helper functions which will be used in
the mmu context for handling nested nested page faults.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/svm.c

index ca711cb27a194ed4ccc7e13c70371699b3e4b0c0..9a9a4405b571cd78105c6fb3c50e84fed0943f73 100644 (file)
@@ -104,6 +104,8 @@ struct nested_state {
        u32 intercept_exceptions;
        u64 intercept;
 
+       /* Nested Paging related state */
+       u64 nested_cr3;
 };
 
 #define MSRPM_OFFSETS  16
@@ -1600,6 +1602,34 @@ static int vmmcall_interception(struct vcpu_svm *svm)
        return 1;
 }
 
+static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
+{
+       struct vcpu_svm *svm = to_svm(vcpu);
+
+       return svm->nested.nested_cr3;
+}
+
+static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu,
+                                  unsigned long root)
+{
+       struct vcpu_svm *svm = to_svm(vcpu);
+
+       svm->vmcb->control.nested_cr3 = root;
+       force_new_asid(vcpu);
+}
+
+static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu)
+{
+       struct vcpu_svm *svm = to_svm(vcpu);
+
+       svm->vmcb->control.exit_code = SVM_EXIT_NPF;
+       svm->vmcb->control.exit_code_hi = 0;
+       svm->vmcb->control.exit_info_1 = vcpu->arch.fault.error_code;
+       svm->vmcb->control.exit_info_2 = vcpu->arch.fault.address;
+
+       nested_svm_vmexit(svm);
+}
+
 static int nested_svm_check_permissions(struct vcpu_svm *svm)
 {
        if (!(svm->vcpu.arch.efer & EFER_SVME)