diff options
author | Avi Kivity <avi@qumranet.com> | 2007-01-05 19:36:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2007-01-06 02:55:24 -0500 |
commit | 6bcbd6aba00fced696fc99f1a4fcd7ac7d42d6ef (patch) | |
tree | 7673a159366ed204a262ef703c6afccf2aeedbc3 | |
parent | cd4a4e5374110444dc38831af517e51ff5a053c3 (diff) |
[PATCH] KVM: MMU: Teach the page table walker to track guest page table gfns
Saving the table gfns removes the need to walk the guest and host page tables
in lockstep.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/kvm/paging_tmpl.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index 8c48528a6e89..3a35c8067dec 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -52,6 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | struct guest_walker { | 53 | struct guest_walker { |
54 | int level; | 54 | int level; |
55 | gfn_t table_gfn; | ||
55 | pt_element_t *table; | 56 | pt_element_t *table; |
56 | pt_element_t inherited_ar; | 57 | pt_element_t inherited_ar; |
57 | }; | 58 | }; |
@@ -63,8 +64,8 @@ static void FNAME(init_walker)(struct guest_walker *walker, | |||
63 | struct kvm_memory_slot *slot; | 64 | struct kvm_memory_slot *slot; |
64 | 65 | ||
65 | walker->level = vcpu->mmu.root_level; | 66 | walker->level = vcpu->mmu.root_level; |
66 | slot = gfn_to_memslot(vcpu->kvm, | 67 | walker->table_gfn = (vcpu->cr3 & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT; |
67 | (vcpu->cr3 & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT); | 68 | slot = gfn_to_memslot(vcpu->kvm, walker->table_gfn); |
68 | hpa = safe_gpa_to_hpa(vcpu, vcpu->cr3 & PT64_BASE_ADDR_MASK); | 69 | hpa = safe_gpa_to_hpa(vcpu, vcpu->cr3 & PT64_BASE_ADDR_MASK); |
69 | walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0); | 70 | walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0); |
70 | 71 | ||
@@ -133,6 +134,8 @@ static pt_element_t *FNAME(fetch_guest)(struct kvm_vcpu *vcpu, | |||
133 | return &walker->table[index]; | 134 | return &walker->table[index]; |
134 | if (walker->level != 3 || is_long_mode(vcpu)) | 135 | if (walker->level != 3 || is_long_mode(vcpu)) |
135 | walker->inherited_ar &= walker->table[index]; | 136 | walker->inherited_ar &= walker->table[index]; |
137 | walker->table_gfn = (walker->table[index] & PT_BASE_ADDR_MASK) | ||
138 | >> PAGE_SHIFT; | ||
136 | paddr = safe_gpa_to_hpa(vcpu, walker->table[index] & PT_BASE_ADDR_MASK); | 139 | paddr = safe_gpa_to_hpa(vcpu, walker->table[index] & PT_BASE_ADDR_MASK); |
137 | kunmap_atomic(walker->table, KM_USER0); | 140 | kunmap_atomic(walker->table, KM_USER0); |
138 | walker->table = kmap_atomic(pfn_to_page(paddr >> PAGE_SHIFT), | 141 | walker->table = kmap_atomic(pfn_to_page(paddr >> PAGE_SHIFT), |