[kvm-unit-tests PATCH 09/12] lib/vmalloc: Let arch code pass a value to its setup_mmu() helper

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

 



Add an inner __setup_vm() that takes an opaque param and passes said
param along to setup_mmu().  x86 will use the param to configure its page
tables for kernel vs. user so that tests that want to enable SMEP (fault
if kernel executes user page) can do so without resorting to hacks and
without breaking tests that need user pages, i.e. that run user code.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 lib/arm/mmu.c   | 2 +-
 lib/s390x/mmu.c | 3 ++-
 lib/vmalloc.c   | 9 +++++++--
 lib/vmalloc.h   | 4 +++-
 lib/x86/vm.c    | 2 +-
 s390x/uv-host.c | 2 +-
 6 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/lib/arm/mmu.c b/lib/arm/mmu.c
index 7628f79..e1a72fe 100644
--- a/lib/arm/mmu.c
+++ b/lib/arm/mmu.c
@@ -153,7 +153,7 @@ void mmu_set_range_sect(pgd_t *pgtable, uintptr_t virt_offset,
 	}
 }
 
-void *setup_mmu(phys_addr_t phys_end)
+void *setup_mmu(phys_addr_t phys_end, void *unused)
 {
 	struct mem_region *r;
 
diff --git a/lib/s390x/mmu.c b/lib/s390x/mmu.c
index c973443..6f9e650 100644
--- a/lib/s390x/mmu.c
+++ b/lib/s390x/mmu.c
@@ -343,7 +343,8 @@ static void setup_identity(pgd_t *pgtable, phys_addr_t start_addr,
 	}
 }
 
-void *setup_mmu(phys_addr_t phys_end){
+void *setup_mmu(phys_addr_t phys_end, void *unused)
+{
 	pgd_t *page_root;
 
 	/* allocate a region-1 table */
diff --git a/lib/vmalloc.c b/lib/vmalloc.c
index aa7cc41..5726825 100644
--- a/lib/vmalloc.c
+++ b/lib/vmalloc.c
@@ -206,7 +206,7 @@ void init_alloc_vpage(void *top)
 	spin_unlock(&lock);
 }
 
-void setup_vm()
+void __setup_vm(void *opaque)
 {
 	phys_addr_t base, top;
 
@@ -228,7 +228,7 @@ void setup_vm()
 
 	find_highmem();
 	phys_alloc_get_unused(&base, &top);
-	page_root = setup_mmu(top);
+	page_root = setup_mmu(top, opaque);
 	if (base != top) {
 		base = PAGE_ALIGN(base) >> PAGE_SHIFT;
 		top = top >> PAGE_SHIFT;
@@ -240,3 +240,8 @@ void setup_vm()
 	alloc_ops = &vmalloc_ops;
 	spin_unlock(&lock);
 }
+
+void setup_vm(void)
+{
+	__setup_vm(NULL);
+}
diff --git a/lib/vmalloc.h b/lib/vmalloc.h
index 346f94f..0269fdd 100644
--- a/lib/vmalloc.h
+++ b/lib/vmalloc.h
@@ -14,9 +14,11 @@ extern void *alloc_vpage(void);
 extern void init_alloc_vpage(void *top);
 /* Set up the virtual allocator; also sets up the page allocator if needed */
 extern void setup_vm(void);
+/* As above, plus passes an opaque value to setup_mmu(). */
+extern void __setup_vm(void *opaque);
 
 /* Set up paging */
-extern void *setup_mmu(phys_addr_t top);
+extern void *setup_mmu(phys_addr_t top, void *opaque);
 /* Walk the page table and resolve the virtual address to a physical address */
 extern phys_addr_t virt_to_pte_phys(pgd_t *pgtable, void *virt);
 /* Map the virtual address to the physical address for the given page tables */
diff --git a/lib/x86/vm.c b/lib/x86/vm.c
index e223bb4..221d427 100644
--- a/lib/x86/vm.c
+++ b/lib/x86/vm.c
@@ -147,7 +147,7 @@ static void set_additional_vcpu_vmregs(struct vm_vcpu_info *info)
 	write_cr0(info->cr0);
 }
 
-void *setup_mmu(phys_addr_t end_of_memory)
+void *setup_mmu(phys_addr_t end_of_memory, void *unused)
 {
     pgd_t *cr3 = alloc_page();
     struct vm_vcpu_info info;
diff --git a/s390x/uv-host.c b/s390x/uv-host.c
index 49c66f1..426a67f 100644
--- a/s390x/uv-host.c
+++ b/s390x/uv-host.c
@@ -446,7 +446,7 @@ static void setup_vmem(void)
 {
 	uint64_t asce, mask;
 
-	setup_mmu(get_max_ram_size());
+	setup_mmu(get_max_ram_size(), NULL);
 	asce = stctg(1);
 	lctlg(13, asce);
 	mask = extract_psw_mask() | 0x0000C00000000000UL;
-- 
2.32.0.288.g62a8d224e6-goog




[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