aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-09-10 11:31:02 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:52:45 -0400
commit5bd2edc341d11af175e759a546e4335ba3e0584f (patch)
treec376bdae4ee4a84f4be89ac16a030812ea63f06d /arch/x86/kvm/svm.c
parent2d48a985c7bbcd72b4e92e301ea96bf1252ffc61 (diff)
KVM: SVM: Implement MMU helper functions for Nested Nested Paging
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>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index ca711cb27a19..9a9a4405b571 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -104,6 +104,8 @@ struct nested_state {
104 u32 intercept_exceptions; 104 u32 intercept_exceptions;
105 u64 intercept; 105 u64 intercept;
106 106
107 /* Nested Paging related state */
108 u64 nested_cr3;
107}; 109};
108 110
109#define MSRPM_OFFSETS 16 111#define MSRPM_OFFSETS 16
@@ -1600,6 +1602,34 @@ static int vmmcall_interception(struct vcpu_svm *svm)
1600 return 1; 1602 return 1;
1601} 1603}
1602 1604
1605static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu)
1606{
1607 struct vcpu_svm *svm = to_svm(vcpu);
1608
1609 return svm->nested.nested_cr3;
1610}
1611
1612static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu,
1613 unsigned long root)
1614{
1615 struct vcpu_svm *svm = to_svm(vcpu);
1616
1617 svm->vmcb->control.nested_cr3 = root;
1618 force_new_asid(vcpu);
1619}
1620
1621static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu)
1622{
1623 struct vcpu_svm *svm = to_svm(vcpu);
1624
1625 svm->vmcb->control.exit_code = SVM_EXIT_NPF;
1626 svm->vmcb->control.exit_code_hi = 0;
1627 svm->vmcb->control.exit_info_1 = vcpu->arch.fault.error_code;
1628 svm->vmcb->control.exit_info_2 = vcpu->arch.fault.address;
1629
1630 nested_svm_vmexit(svm);
1631}
1632
1603static int nested_svm_check_permissions(struct vcpu_svm *svm) 1633static int nested_svm_check_permissions(struct vcpu_svm *svm)
1604{ 1634{
1605 if (!(svm->vcpu.arch.efer & EFER_SVME) 1635 if (!(svm->vcpu.arch.efer & EFER_SVME)