svn commit: r247247 - in projects/uefi/sys/amd64: amd64 include

Benno Rice benno at FreeBSD.org
Mon Feb 25 00:04:03 UTC 2013


Author: benno
Date: Mon Feb 25 00:04:02 2013
New Revision: 247247
URL: http://svnweb.freebsd.org/changeset/base/247247

Log:
  Rearrange early pmap bootstrap so we have real page tables before cninit.

Modified:
  projects/uefi/sys/amd64/amd64/machdep.c
  projects/uefi/sys/amd64/amd64/pmap.c
  projects/uefi/sys/amd64/include/pmap.h

Modified: projects/uefi/sys/amd64/amd64/machdep.c
==============================================================================
--- projects/uefi/sys/amd64/amd64/machdep.c	Sun Feb 24 23:57:52 2013	(r247246)
+++ projects/uefi/sys/amd64/amd64/machdep.c	Mon Feb 25 00:04:02 2013	(r247247)
@@ -1525,16 +1525,13 @@ add_efi_map_entries(struct efi_header *e
  *
  * XXX first should be vm_paddr_t.
  */
-static void
-getmemsize(caddr_t kmdp, u_int64_t first)
+static int
+parsememmap(caddr_t kmdp, u_int64_t first, vm_paddr_t *physmap)
 {
-	int i, physmap_idx, pa_indx, da_indx;
-	vm_paddr_t pa, physmap[PHYSMAP_SIZE];
-	u_long physmem_start, physmem_tunable, memtest;
-	pt_entry_t *pte;
+	int i, physmap_idx;
+	u_long physmem_tunable;
 	struct bios_smap *smapbase;
 	struct efi_header *efihdr;
-	quad_t dcons_addr, dcons_size;
 
 	bzero(physmap, sizeof(physmap));
 	basemem = 0;
@@ -1548,12 +1545,8 @@ getmemsize(caddr_t kmdp, u_int64_t first
 		panic("No BIOS smap or EFI map info from loader!");
 
 	if (efihdr != NULL) {
-		if (boothowto & RB_VERBOSE)
-			printf("Using EFI memory map.\n");
 		add_efi_map_entries(efihdr, physmap, &physmap_idx);
 	} else {
-		if (boothowto & RB_VERBOSE)
-			printf("Using BIOS SMAP memory map.\n");
 		add_smap_entries(smapbase, physmap, &physmap_idx);
 	}
 
@@ -1591,26 +1584,38 @@ getmemsize(caddr_t kmdp, u_int64_t first
 		Maxmem = atop(physmem_tunable);
 
 	/*
-	 * By default enable the memory test on real hardware, and disable
-	 * it if we appear to be running in a VM.  This avoids touching all
-	 * pages unnecessarily, which doesn't matter on real hardware but is
-	 * bad for shared VM hosts.  Use a general name so that
-	 * one could eventually do more with the code than just disable it.
-	 */
-	memtest = (vm_guest > VM_GUEST_NO) ? 0 : 1;
-	TUNABLE_ULONG_FETCH("hw.memtest.tests", &memtest);
-
-	/*
 	 * Don't allow MAXMEM or hw.physmem to extend the amount of memory
 	 * in the system.
 	 */
 	if (Maxmem > atop(physmap[physmap_idx + 1]))
 		Maxmem = atop(physmap[physmap_idx + 1]);
 
+	return (physmap_idx);
+}
+
+static void
+getmemsize(vm_paddr_t first, vm_paddr_t *physmap, int physmap_idx)
+{
+	u_long physmem_start, memtest;
+	int i, pa_indx, da_indx;
+	vm_paddr_t pa;
+	pt_entry_t *pte;
+	quad_t dcons_addr, dcons_size;
+
 	if (atop(physmap[physmap_idx + 1]) != Maxmem &&
 	    (boothowto & RB_VERBOSE))
 		printf("Physical memory use set to %ldK\n", Maxmem * 4);
 
+	/*
+	 * By default enable the memory test on real hardware, and disable
+	 * it if we appear to be running in a VM.  This avoids touching all
+	 * pages unnecessarily, which doesn't matter on real hardware but is
+	 * bad for shared VM hosts.  Use a general name so that
+	 * one could eventually do more with the code than just disable it.
+	 */
+	memtest = (vm_guest > VM_GUEST_NO) ? 0 : 1;
+	TUNABLE_ULONG_FETCH("hw.memtest.tests", &memtest);
+
 	/* call pmap initialization to make new kernel address space */
 	pmap_bootstrap(&first);
 
@@ -1797,6 +1802,8 @@ hammer_time(u_int64_t modulep, u_int64_t
 	u_int64_t msr;
 	char *env;
 	size_t kstack0_sz;
+	vm_paddr_t physmap[PHYSMAP_SIZE];
+	int physmap_idx;
 
 	thread0.td_kstack = physfree + KERNBASE;
 	thread0.td_kstack_pages = KSTACK_PAGES;
@@ -1906,6 +1913,9 @@ hammer_time(u_int64_t modulep, u_int64_t
 	 */
 	i8254_init();
 
+	physmap_idx = parsememmap(kmdp, physfree, physmap);
+	create_pagetables(&physfree);
+
 	/*
 	 * Initialize the console before we print anything out.
 	 */
@@ -1970,7 +1980,7 @@ hammer_time(u_int64_t modulep, u_int64_t
 	wrmsr(MSR_STAR, msr);
 	wrmsr(MSR_SF_MASK, PSL_NT|PSL_T|PSL_I|PSL_C|PSL_D);
 
-	getmemsize(kmdp, physfree);
+	getmemsize(physfree, physmap, physmap_idx);
 	init_param2(physmem);
 
 	/* now running on new page tables, configured,and u/iom is accessible */

Modified: projects/uefi/sys/amd64/amd64/pmap.c
==============================================================================
--- projects/uefi/sys/amd64/amd64/pmap.c	Sun Feb 24 23:57:52 2013	(r247246)
+++ projects/uefi/sys/amd64/amd64/pmap.c	Mon Feb 25 00:04:02 2013	(r247247)
@@ -529,7 +529,7 @@ nkpt_init(vm_paddr_t addr)
 	nkpt = pt_pages;
 }
 
-static void
+void
 create_pagetables(vm_paddr_t *firstaddr)
 {
 	int i, j, ndm1g, nkpdpe;
@@ -647,11 +647,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
 	vm_offset_t va;
 	pt_entry_t *pte, *unused;
 
-	/*
-	 * Create an initial set of page tables to run the kernel in.
-	 */
-	create_pagetables(firstaddr);
-
 	virtual_avail = (vm_offset_t) KERNBASE + *firstaddr;
 	virtual_avail = pmap_kmem_choose(virtual_avail);
 

Modified: projects/uefi/sys/amd64/include/pmap.h
==============================================================================
--- projects/uefi/sys/amd64/include/pmap.h	Sun Feb 24 23:57:52 2013	(r247246)
+++ projects/uefi/sys/amd64/include/pmap.h	Mon Feb 25 00:04:02 2013	(r247247)
@@ -307,6 +307,7 @@ extern vm_offset_t virtual_end;
 #define	pmap_page_is_write_mapped(m)	(((m)->aflags & PGA_WRITEABLE) != 0)
 #define	pmap_unmapbios(va, sz)	pmap_unmapdev((va), (sz))
 
+void	create_pagetables(vm_paddr_t *);
 void	pmap_bootstrap(vm_paddr_t *);
 int	pmap_change_attr(vm_offset_t, vm_size_t, int);
 void	pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate);


More information about the svn-src-projects mailing list