[kvm-unit-tests RFC PATCH 02/10] x86: vm: Remove install_pte() redundant argument

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

 



Function's install_pte() pt_page argument is never used
and could be eliminated.

Cc: Radim Krčmář <rkrcmar@xxxxxxxxxx>
Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxx>
---
 lib/x86/vm.c      | 13 ++++---------
 lib/x86/vm.h      |  3 +--
 x86/asyncpf.c     |  4 ++--
 x86/eventinj.c    |  6 +++---
 x86/hypercall.c   |  2 +-
 x86/rmap_chain.c  |  2 +-
 x86/taskswitch2.c |  2 +-
 7 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index 362497cfa341..b9fa5cd3c389 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -40,8 +40,7 @@ static unsigned long end_of_memory;
 unsigned long *install_pte(unsigned long *cr3,
 			   int pte_level,
 			   void *virt,
-			   unsigned long pte,
-			   unsigned long *pt_page)
+			   unsigned long pte)
 {
     int level;
     unsigned long *pt = cr3;
@@ -50,11 +49,7 @@ unsigned long *install_pte(unsigned long *cr3,
     for (level = PAGE_LEVEL; level > pte_level; --level) {
 	offset = PGDIR_OFFSET((unsigned long)virt, level);
 	if (!(pt[offset] & PT_PRESENT_MASK)) {
-	    unsigned long *new_pt = pt_page;
-            if (!new_pt)
-                new_pt = alloc_page();
-            else
-                pt_page = 0;
+	    unsigned long *new_pt = alloc_page();
 	    memset(new_pt, 0, PAGE_SIZE);
 	    pt[offset] = virt_to_phys(new_pt) | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK;
 	}
@@ -89,14 +84,14 @@ unsigned long *install_large_page(unsigned long *cr3,
 				  void *virt)
 {
     return install_pte(cr3, 2, virt,
-		       phys | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK | PT_PAGE_SIZE_MASK, 0);
+		       phys | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK | PT_PAGE_SIZE_MASK);
 }
 
 unsigned long *install_page(unsigned long *cr3,
 			    unsigned long phys,
 			    void *virt)
 {
-    return install_pte(cr3, 1, virt, phys | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK, 0);
+    return install_pte(cr3, 1, virt, phys | PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK);
 }
 
 
diff --git a/lib/x86/vm.h b/lib/x86/vm.h
index 6a4384f5a48d..2418311b25f5 100644
--- a/lib/x86/vm.h
+++ b/lib/x86/vm.h
@@ -18,8 +18,7 @@ unsigned long *get_pte(unsigned long *cr3, void *virt);
 unsigned long *install_pte(unsigned long *cr3,
                            int pte_level,
                            void *virt,
-                           unsigned long pte,
-                           unsigned long *pt_page);
+                           unsigned long pte);
 
 void *alloc_page();
 void free_page(void *page);
diff --git a/x86/asyncpf.c b/x86/asyncpf.c
index e29e07c556f3..3b1bcb007ded 100644
--- a/x86/asyncpf.c
+++ b/x86/asyncpf.c
@@ -56,7 +56,7 @@ static void pf_isr(struct ex_regs *r)
 			break;
 		case KVM_PV_REASON_PAGE_NOT_PRESENT:
 			phys = virt_to_phys_cr3(virt);
-			install_pte(phys_to_virt(read_cr3()), 1, virt, phys, 0);
+			install_pte(phys_to_virt(read_cr3()), 1, virt, phys);
 			write_cr3(read_cr3());
 			report("Got not present #PF token %x virt addr %p phys addr %p",
 					true, read_cr2(), virt, phys);
@@ -69,7 +69,7 @@ static void pf_isr(struct ex_regs *r)
 			report("Got present #PF token %x", true, read_cr2());
 			if ((uint32_t)read_cr2() == ~0)
 				break;
-			install_pte(phys_to_virt(read_cr3()), 1, virt, phys | PT_PRESENT_MASK | PT_WRITABLE_MASK, 0);
+			install_pte(phys_to_virt(read_cr3()), 1, virt, phys | PT_PRESENT_MASK | PT_WRITABLE_MASK);
 			write_cr3(read_cr3());
 			phys = 0;
 			break;
diff --git a/x86/eventinj.c b/x86/eventinj.c
index 9ee557b85494..0ca7d300f6a7 100644
--- a/x86/eventinj.c
+++ b/x86/eventinj.c
@@ -52,7 +52,7 @@ void do_pf_tss(void)
 {
 	printf("PF running\n");
 	install_pte(phys_to_virt(read_cr3()), 1, stack_va,
-		    stack_phys | PT_PRESENT_MASK | PT_WRITABLE_MASK, 0);
+		    stack_phys | PT_PRESENT_MASK | PT_WRITABLE_MASK);
 	invlpg(stack_va);
 }
 
@@ -363,7 +363,7 @@ int main()
 	printf("Try to divide by 0\n");
 	/* install read only pte */
 	install_pte(phys_to_virt(read_cr3()), 1, stack_va,
-		    stack_phys | PT_PRESENT_MASK, 0);
+		    stack_phys | PT_PRESENT_MASK);
 	invlpg(stack_va);
 	flush_phys_addr(stack_phys);
 	switch_stack(stack_va + 4095);
@@ -382,7 +382,7 @@ int main()
 	set_idt_sel(33, NP_SEL);
 	/* install read only pte */
 	install_pte(phys_to_virt(read_cr3()), 1, stack_va,
-		    stack_phys | PT_PRESENT_MASK, 0);
+		    stack_phys | PT_PRESENT_MASK);
 	invlpg(stack_va);
 	flush_idt_page();
 	flush_phys_addr(stack_phys);
diff --git a/x86/hypercall.c b/x86/hypercall.c
index 9380f785761a..2b57bf5c89ac 100644
--- a/x86/hypercall.c
+++ b/x86/hypercall.c
@@ -65,7 +65,7 @@ int main(int ac, char **av)
 	u8 *topmost = (void *) ((1ul << 47) - PAGE_SIZE);
 
 	install_pte(phys_to_virt(read_cr3()), 1, topmost,
-		    virt_to_phys(data1) | PT_PRESENT_MASK | PT_WRITABLE_MASK, 0);
+		    virt_to_phys(data1) | PT_PRESENT_MASK | PT_WRITABLE_MASK);
 	memset(topmost, 0xcc, PAGE_SIZE);
 	topmost[4093] = 0x0f;
 	topmost[4094] = 0x01;
diff --git a/x86/rmap_chain.c b/x86/rmap_chain.c
index 7bf6275cab22..878eeb16ce91 100644
--- a/x86/rmap_chain.c
+++ b/x86/rmap_chain.c
@@ -36,7 +36,7 @@ int main (void)
 
     virt_addr += PAGE_SIZE;
     install_pte(phys_to_virt(read_cr3()), 1, virt_addr,
-                0 | PT_PRESENT_MASK | PT_WRITABLE_MASK, target_page);
+                0 | PT_PRESENT_MASK | PT_WRITABLE_MASK);
 
     *(unsigned long *)virt_addr = 0;
     printf("PASS\n");
diff --git a/x86/taskswitch2.c b/x86/taskswitch2.c
index bb7345b2f525..9bd44ab4ca33 100644
--- a/x86/taskswitch2.c
+++ b/x86/taskswitch2.c
@@ -67,7 +67,7 @@ void do_pf_tss(ulong *error_code)
 	if (*error_code == 0x2) /* write access, not present */
 		test_count++;
 	install_pte(phys_to_virt(read_cr3()), 1, fault_addr,
-		    fault_phys | PT_PRESENT_MASK | PT_WRITABLE_MASK, 0);
+		    fault_phys | PT_PRESENT_MASK | PT_WRITABLE_MASK);
 }
 
 extern void pf_tss(void);
-- 
1.8.3.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