[PATCH 2/4] KVM: MMU: Move some variables into the walk loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Takuya Yoshikawa <yoshikawa.takuya@xxxxxxxxxxxxx>

This will help us split out the big body of the walk loop later.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@xxxxxxxxxxxxx>
---
 arch/x86/kvm/paging_tmpl.h |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
index 51e5990..3270789 100644
--- a/arch/x86/kvm/paging_tmpl.h
+++ b/arch/x86/kvm/paging_tmpl.h
@@ -122,11 +122,8 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
 {
 	pt_element_t pte;
 	pt_element_t __user *ptep_user;
-	gfn_t table_gfn;
-	unsigned index, pt_access, uninitialized_var(pte_access);
-	gpa_t pte_gpa;
+	unsigned pt_access, uninitialized_var(pte_access);
 	bool eperm;
-	int offset;
 	const int write_fault = access & PFERR_WRITE_MASK;
 	const int user_fault  = access & PFERR_USER_MASK;
 	const int fetch_fault = access & PFERR_FETCH_MASK;
@@ -158,12 +155,11 @@ walk:
 	for (;;) {
 		gfn_t real_gfn;
 		unsigned long host_addr;
+		unsigned index  = PT_INDEX(addr, walker->level);
+		int offset      = index * sizeof(pt_element_t);
+		gfn_t table_gfn = gpte_to_gfn(pte);
+		gpa_t pte_gpa   = gfn_to_gpa(table_gfn) + offset;
 
-		index = PT_INDEX(addr, walker->level);
-
-		table_gfn = gpte_to_gfn(pte);
-		offset    = index * sizeof(pt_element_t);
-		pte_gpa   = gfn_to_gpa(table_gfn) + offset;
 		walker->table_gfn[walker->level - 1] = table_gfn;
 		walker->pte_gpa[walker->level - 1] = pte_gpa;
 
@@ -273,6 +269,8 @@ walk:
 
 	if (write_fault && unlikely(!is_dirty_gpte(pte))) {
 		int ret;
+		unsigned index  = PT_INDEX(addr, walker->level);
+		gfn_t table_gfn = walker->table_gfn[walker->level - 1];
 
 		trace_kvm_mmu_set_dirty_bit(table_gfn, index, sizeof(pte));
 		ret = FNAME(cmpxchg_gpte)(vcpu, mmu, ptep_user, index,
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux