Skip to content

Commit 6bcbd6a

Browse files
avikivityLinus Torvalds
authored andcommitted
[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>
1 parent cd4a4e5 commit 6bcbd6a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/kvm/paging_tmpl.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*/
5353
struct guest_walker {
5454
int level;
55+
gfn_t table_gfn;
5556
pt_element_t *table;
5657
pt_element_t inherited_ar;
5758
};
@@ -63,8 +64,8 @@ static void FNAME(init_walker)(struct guest_walker *walker,
6364
struct kvm_memory_slot *slot;
6465

6566
walker->level = vcpu->mmu.root_level;
66-
slot = gfn_to_memslot(vcpu->kvm,
67-
(vcpu->cr3 & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT);
67+
walker->table_gfn = (vcpu->cr3 & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
68+
slot = gfn_to_memslot(vcpu->kvm, walker->table_gfn);
6869
hpa = safe_gpa_to_hpa(vcpu, vcpu->cr3 & PT64_BASE_ADDR_MASK);
6970
walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0);
7071

@@ -133,6 +134,8 @@ static pt_element_t *FNAME(fetch_guest)(struct kvm_vcpu *vcpu,
133134
return &walker->table[index];
134135
if (walker->level != 3 || is_long_mode(vcpu))
135136
walker->inherited_ar &= walker->table[index];
137+
walker->table_gfn = (walker->table[index] & PT_BASE_ADDR_MASK)
138+
>> PAGE_SHIFT;
136139
paddr = safe_gpa_to_hpa(vcpu, walker->table[index] & PT_BASE_ADDR_MASK);
137140
kunmap_atomic(walker->table, KM_USER0);
138141
walker->table = kmap_atomic(pfn_to_page(paddr >> PAGE_SHIFT),

0 commit comments

Comments
 (0)