aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2010-09-10 11:30:58 -0400
committerAvi Kivity <avi@redhat.com>2010-10-24 04:52:42 -0400
commitd41d1895eb856b5d1c82f3be106b7a3e75e4216b (patch)
tree9c03b7f6b304fcebea1e242de53f39a9d26de395 /arch/x86
parentff03a073e715d49b5cfeeec862649b1df2481ae0 (diff)
KVM: MMU: Introduce kvm_pdptr_read_mmu
This function is implemented to load the pdptr pointers of the currently running guest (l1 or l2 guest). Therefore it takes care about the current paging mode and can read pdptrs out of l2 guest physical memory. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/kvm_cache_regs.h7
-rw-r--r--arch/x86/kvm/mmu.c2
-rw-r--r--arch/x86/kvm/paging_tmpl.h2
3 files changed, 9 insertions, 2 deletions
diff --git a/arch/x86/kvm/kvm_cache_regs.h b/arch/x86/kvm/kvm_cache_regs.h
index a37abe2ec39a..975bb45329a1 100644
--- a/arch/x86/kvm/kvm_cache_regs.h
+++ b/arch/x86/kvm/kvm_cache_regs.h
@@ -45,6 +45,13 @@ static inline u64 kvm_pdptr_read(struct kvm_vcpu *vcpu, int index)
45 return vcpu->arch.walk_mmu->pdptrs[index]; 45 return vcpu->arch.walk_mmu->pdptrs[index];
46} 46}
47 47
48static inline u64 kvm_pdptr_read_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, int index)
49{
50 load_pdptrs(vcpu, mmu, mmu->get_cr3(vcpu));
51
52 return mmu->pdptrs[index];
53}
54
48static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask) 55static inline ulong kvm_read_cr0_bits(struct kvm_vcpu *vcpu, ulong mask)
49{ 56{
50 ulong tmask = mask & KVM_POSSIBLE_CR0_GUEST_BITS; 57 ulong tmask = mask & KVM_POSSIBLE_CR0_GUEST_BITS;
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a26f13bd34e0..a25173a0d8b9 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2398,7 +2398,7 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu)
2398 2398
2399 ASSERT(!VALID_PAGE(root)); 2399 ASSERT(!VALID_PAGE(root));
2400 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) { 2400 if (vcpu->arch.mmu.root_level == PT32E_ROOT_LEVEL) {
2401 pdptr = kvm_pdptr_read(vcpu, i); 2401 pdptr = kvm_pdptr_read_mmu(vcpu, &vcpu->arch.mmu, i);
2402 if (!is_present_gpte(pdptr)) { 2402 if (!is_present_gpte(pdptr)) {
2403 vcpu->arch.mmu.pae_root[i] = 0; 2403 vcpu->arch.mmu.pae_root[i] = 0;
2404 continue; 2404 continue;
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index f4e09d341e28..a28f09bb76c6 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -137,7 +137,7 @@ walk:
137 137
138#if PTTYPE == 64 138#if PTTYPE == 64
139 if (walker->level == PT32E_ROOT_LEVEL) { 139 if (walker->level == PT32E_ROOT_LEVEL) {
140 pte = kvm_pdptr_read(vcpu, (addr >> 30) & 3); 140 pte = kvm_pdptr_read_mmu(vcpu, mmu, (addr >> 30) & 3);
141 trace_kvm_mmu_paging_element(pte, walker->level); 141 trace_kvm_mmu_paging_element(pte, walker->level);
142 if (!is_present_gpte(pte)) { 142 if (!is_present_gpte(pte)) {
143 present = false; 143 present = false;