Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Nov 2002 18:18:37 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 21328 for review
Message-ID:  <200211210218.gAL2Ib2Q023856@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=21328

Change 21328 by peter@peter_daintree on 2002/11/20 18:17:56

	fill in some more blanks

Affected files ...

.. //depot/projects/hammer/sys/x86_64/include/pmap.h#3 edit

Differences ...

==== //depot/projects/hammer/sys/x86_64/include/pmap.h#3 (text+ko) ====

@@ -83,35 +83,32 @@
 #define PGEX_U		0x04	/* access from User mode (UPL) */
 
 /*
- * Size of Kernel address space.  This is the number of page table pages
- * (4MB each) to use for the kernel.  256 pages == 1 Gigabyte.
- * This **MUST** be a multiple of 4 (eg: 252, 256, 260, etc).
+ * Size of Kernel address space.  This is the number of level 4 (top)
+ * entries.  We use half of them for the kernel due to the 48 bit
+ * virtual address sign extension.
  */
-#ifndef KVA_PAGES
 #define KVA_PAGES	256
-#endif
 
 /*
  * Pte related macros
  */
-#define VADDR(pdi, pti) ((vm_offset_t)(((pdi)<<PDRSHIFT)|((pti)<<PAGE_SHIFT)))
+#define VADDR(l4, l3, l2, l1) ((vm_offset_t) ( \
+	((l4)<<PML4SHIFT) | \ ((l3)<<PDPSHIFT) | \
+	((l2)<<PDRSHIFT) | ((l1)<<PAGE_SHIFT)) )
+
 
 #ifndef NKPT
 #define	NKPT		30	/* actual number of kernel page tables */
 #endif
-#ifndef NKPDE
 #define NKPDE	(KVA_PAGES - 1)	/* addressable number of page tables/pde's */
-#endif
 
 /*
  * The *PTDI values control the layout of virtual memory
- *
- * XXX This works for now, but I am not real happy with it, I'll fix it
- * right after I fix locore.s and the magic 28K hole
  */
-#define	APTDPTDI	(NPDEPG-1)	/* alt ptd entry that points to APTD */
+#define	APTDPTDI	(NPML4EPG-1)	/* alt ptd entry that points to APTD */
 #define	KPTDI		(APTDPTDI-NKPDE)/* start of kernel virtual pde's */
-#define	PTDPTDI		(KPTDI-1)	/* ptd entry that points to ptd! */
+/* Hole */
+#define	PTDPTDI		((NPML4EPG/2)-1)/* ptd entry that points to ptd! */
 #define	UMAXPTDI	(PTDPTDI-1)	/* ptd entry for user space end */
 #define	UMAXPTEOFF	(NPTEPG)	/* pte entry for user space end */
 
@@ -125,22 +122,34 @@
 
 #include <sys/queue.h>
 
-typedef u_int32_t pd_entry_t;
-typedef u_int32_t pt_entry_t;
+typedef u_int64_t pd_entry_t;
+typedef u_int64_t pt_entry_t;
+typedef u_int64_t pdp_entry_t;
+typedef u_int64_t pml4_entry_t;
 
+#define PML4ESIZE	sizeof(pml4_entry_t) /* for assembly files */
+#define PDPESIZE	sizeof(pdp_entry_t) /* for assembly files */
 #define PDESIZE		sizeof(pd_entry_t) /* for assembly files */
 #define PTESIZE		sizeof(pt_entry_t) /* for assembly files */
 
 /*
  * Address of current and alternate address space page table maps
  * and directories.
+ * XXX it might be saner to just direct map all of physical memory
+ * into the kernel using 2MB pages.  We have enough space to do
+ * it (2^47 bits of KVM, while current max physical addressability
+ * is 2^40 physical bits).  Then we can get rid of the evil hole
+ * in the page tables and the evil overlapping.
  */
 #ifdef _KERNEL
-extern pt_entry_t PTmap[], APTmap[];
-extern pd_entry_t PTD[], APTD[];
-extern pd_entry_t PTDpde, APTDpde;
+extern pt_entry_t	PTmap[], APTmap[];
+extern pd_entry_t	PDmap[], APDmap[];
+extern pdp_entry_t	PDPmap[], APDPmap[];
+extern pml4_entry_t	PML4[], APML4;
+extern pd_entry_t	PML4pml4e, APML4pml4e;
+
 
-extern pd_entry_t *IdlePTD;	/* physical address of "Idle" state directory */
+extern pd_entry_t *IdlePML4;	/* physical address of "Idle" state directory */
 #endif
 
 #ifdef _KERNEL
@@ -150,8 +159,8 @@
  * Note: these work recursively, thus vtopte of a pte will give
  * the corresponding pde that in turn maps it.
  */
-#define	vtopte(va)	(PTmap + i386_btop(va))
-#define	avtopte(va)	(APTmap + i386_btop(va))
+#define	vtopte(va)	(PTmap + x86_64_btop(va))
+#define	avtopte(va)	(APTmap + x86_64_btop(va))
 
 /*
  *	Routine:	pmap_kextract
@@ -163,9 +172,11 @@
 pmap_kextract(vm_offset_t va)
 {
 	vm_offset_t pa;
-	if ((pa = (vm_offset_t) PTD[va >> PDRSHIFT]) & PG_PS) {
+
+/* XXX the acronyms are giving me headaches at the moment */
+/* XXX	if ((pa = (vm_offset_t) PTD[va >> PDRSHIFT]) & PG_PS) {
 		pa = (pa & ~(NBPDR - 1)) | (va & (NBPDR - 1));
-	} else {
+	} else */ {
 		pa = *(vm_offset_t *)vtopte(va);
 		pa = (pa & PG_FRAME) | (va & PAGE_MASK);
 	}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211210218.gAL2Ib2Q023856>