PERFORCE change 42509 for review

Peter Wemm peter at FreeBSD.org
Sat Nov 15 19:31:01 PST 2003


http://perforce.freebsd.org/chv.cgi?CH=42509

Change 42509 by peter at peter_overcee on 2003/11/15 19:30:12

	create AP bootstrap page tables

Affected files ...

.. //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#30 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/amd64/mp_machdep.c#30 (text+ko) ====

@@ -454,7 +454,8 @@
 	u_char mpbiosreason;
 	u_int32_t mpbioswarmvec;
 	struct pcpu *pc;
-	int x, apic_id, cpu;
+	int x, apic_id, cpu, i;
+	u_int64_t *pt4, *pt3, *pt2;
 
 	mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
 
@@ -462,6 +463,28 @@
 	pmap_kenter(boot_address + KERNBASE, boot_address);
 	bcopy(mptramp_start, (void *)((uintptr_t)boot_address + KERNBASE), bootMP_size);
 
+	/* Locate the page tables, they'll be below the trampoline */
+	pt4 = (u_int64_t *)(uintptr_t)mptramp_pagetables;
+	pt3 = pt4 + 512;
+	pt2 = pt3 + 512;
+	printf("pt4 = %p; pt3 = %p; pt2 = %p\n", pt4, pt3, pt2);
+
+	/* Create the initial 1GB replicated page tables */
+	for (i = 0; i < 512; i++) {
+		/* Each slot of the level 4 pages points to the same level 3 page */
+		pt4[i] = (u_int64_t)(uintptr_t)pt3;
+		pt4[i] = PG_V | PG_RW | PG_U;
+
+		/* Each slot of the level 3 pages points to the same level 2 page */
+		pt3[i] = (u_int64_t)(uintptr_t)pt2;
+		pt3[i] = PG_V | PG_RW | PG_U;
+
+		/* The level 2 page slots are mapped with 2MB pages for 1GB. */
+		pt2[i] = i * (2 * 1024 * 1024);
+		pt2[i] = PG_V | PG_RW | PG_PS | PG_U;
+	}
+	printf("pagetables created\n");
+
 	/* save the current value of the warm-start vector */
 	mpbioswarmvec = *((u_int32_t *) WARMBOOT_OFF);
 	outb(CMOS_REG, BIOS_RESET);


More information about the p4-projects mailing list