Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Apr 2003 16:40:21 -0800 (PST)
From:      Peter Wemm <peter@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 28089 for review
Message-ID:  <200304050040.h350eLum079669@repoman.freebsd.org>

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

Change 28089 by peter@peter_daintree on 2003/04/04 16:39:32

	IFC @28080 on i386_hammer

Affected files ...

.. //depot/projects/hammer/sys/x86_64/include/pmap.h#6 integrate
.. //depot/projects/hammer/sys/x86_64/x86_64/locore.s#19 integrate

Differences ...

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

@@ -42,7 +42,7 @@
  *
  *	from: hp300: @(#)pmap.h	7.2 (Berkeley) 12/16/90
  *	from: @(#)pmap.h	7.4 (Berkeley) 5/12/91
- * $FreeBSD: src/sys/i386/include/pmap.h,v 1.88 2003/02/27 20:13:20 alc Exp $
+ * $FreeBSD: src/sys/i386/include/pmap.h,v 1.96 2003/04/04 10:09:44 jake Exp $
  */
 
 #ifndef _MACHINE_PMAP_H_
@@ -70,7 +70,7 @@
 /* Our various interpretations of the above */
 #define PG_W		PG_AVAIL1	/* "Wired" pseudoflag */
 #define	PG_MANAGED	PG_AVAIL2
-#define	PG_FRAME	(~PAGE_MASK)
+#define	PG_FRAME	(~((vm_paddr_t)PAGE_MASK))
 #define	PG_PROT		(PG_RW|PG_U)	/* all protection bits . */
 #define PG_N		(PG_NC_PWT|PG_NC_PCD)	/* Non-cacheable */
 
@@ -131,10 +131,12 @@
 typedef u_int64_t pdp_entry_t;
 typedef u_int64_t pml4_entry_t;
 
-#define	PML4ESHIFT	(2)
-#define	PDPESHIFT	(2)
-#define	PTESHIFT	(2)
-#define	PDESHIFT	(2)
+#define	PML4ESHIFT	(3)
+#define	PDPESHIFT	(3)
+#define	PTESHIFT	(3)
+#define	PDESHIFT	(3)
+
+#endif
 
 /*
  * Address of current and alternate address space page table maps
@@ -146,11 +148,11 @@
  * in the page tables and the evil overlapping.
  */
 #ifdef _KERNEL
-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 pt_entry_t	PTmap[]:
+extern pd_entry_t	PDmap[]:
+extern pdp_entry_t	PDPmap[]:
+extern pml4_entry_t	PML4[]:
+extern pd_entry_t	PML4pml4e[]:
 
 extern pd_entry_t *IdlePML4;	/* physical address of "Idle" state directory */
 #endif
@@ -163,7 +165,6 @@
  * the corresponding pde that in turn maps it.
  */
 #define	vtopte(va)	(PTmap + x86_64_btop(va))
-#define	avtopte(va)	(APTmap + x86_64_btop(va))
 
 /*
  *	Routine:	pmap_kextract
@@ -171,24 +172,48 @@
  *		Extract the physical page address associated
  *		kernel virtual address.
  */
-static __inline vm_offset_t
+static __inline vm_paddr_t
 pmap_kextract(vm_offset_t va)
 {
-	vm_offset_t pa;
+	vm_paddr_t pa;
 
 /* 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 */ {
-		pa = *(vm_offset_t *)vtopte(va);
+		pa = *vtopte(va);
 		pa = (pa & PG_FRAME) | (va & PAGE_MASK);
 	}
 	return pa;
 }
 
 #define	vtophys(va)	pmap_kextract(((vm_offset_t) (va)))
+
+#ifdef PAE
+
+static __inline pt_entry_t
+pte_load_clear(pt_entry_t *pte)
+{
+	pt_entry_t r;
+
+	r = *pte;
+	__asm __volatile(
+	    "1:\n"
+	    "\tcmpxchg8b %1\n"
+	    "\tjnz 1b"
+	    : "+A" (r)
+	    : "m" (*pte), "b" (0), "c" (0));
+	return (r);
+}
+
+#else
+
+#define	pte_load_clear(pte)	atomic_readandclear_int(pte)
+
 #endif
 
+#endif
+
 /*
  * Pmap stuff
  */
@@ -203,9 +228,13 @@
 	pd_entry_t		*pm_pdir;	/* KVA of page directory */
 	vm_object_t		pm_pteobj;	/* Container for pte's */
 	TAILQ_HEAD(,pv_entry)	pm_pvlist;	/* list of mappings in pmap */
-	int			pm_active;	/* active on cpus */
+	u_int			pm_active;	/* active on cpus */
 	struct pmap_statistics	pm_stats;	/* pmap statistics */
 	LIST_ENTRY(pmap) 	pm_list;	/* List of all pmaps */
+#ifdef PAE
+	pdpt_entry_t		*pm_pdpt;	/* KVA of page director pointer
+						   table */
+#endif
 };
 
 #define	pmap_page_is_mapped(m)	(!TAILQ_EMPTY(&(m)->md.pv_list))
@@ -242,19 +271,21 @@
 
 extern caddr_t	CADDR1;
 extern pt_entry_t *CMAP1;
-extern vm_offset_t avail_end;
-extern vm_offset_t avail_start;
+extern vm_paddr_t avail_end;
+extern vm_paddr_t avail_start;
 extern vm_offset_t clean_eva;
 extern vm_offset_t clean_sva;
-extern vm_offset_t phys_avail[];
+extern vm_paddr_t phys_avail[];
 extern char *ptvmmap;		/* poor name! */
 extern vm_offset_t virtual_avail;
 extern vm_offset_t virtual_end;
 
-void	pmap_bootstrap(vm_offset_t, vm_offset_t);
-void	*pmap_mapdev(vm_offset_t, vm_size_t);
+void	pmap_bootstrap(vm_paddr_t, vm_paddr_t);
+void	pmap_kenter(vm_offset_t va, vm_paddr_t pa);
+void	pmap_kremove(vm_offset_t);
+void	*pmap_mapdev(vm_paddr_t, vm_size_t);
 void	pmap_unmapdev(vm_offset_t, vm_size_t);
-pt_entry_t *pmap_pte(pmap_t, vm_offset_t) __pure2;
+pt_entry_t *pmap_pte_quick(pmap_t, vm_offset_t) __pure2;
 void	pmap_set_opt(void);
 void	pmap_invalidate_page(pmap_t, vm_offset_t);
 void	pmap_invalidate_range(pmap_t, vm_offset_t, vm_offset_t);

==== //depot/projects/hammer/sys/x86_64/x86_64/locore.s#19 (text+ko) ====

@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)locore.s	7.3 (Berkeley) 5/13/91
- * $FreeBSD: src/sys/i386/i386/locore.s,v 1.169 2003/02/23 22:12:07 jake Exp $
+ * $FreeBSD: src/sys/i386/i386/locore.s,v 1.171 2003/04/03 23:44:34 jake Exp $
  *
  *		originally from: locore.s, by William F. Jolitz
  *
@@ -54,12 +54,6 @@
 /*
  * PTmap is recursive pagemap at top of virtual address space.
  * Within PTmap, the page directory can be found (third indirection).
- *
- * NOTE: PTDpde, PTmap, and PTD are being defined as address symbols.
- * In C you access them directly, and not with a '*'. Storage is not being 
- * allocated. They will magically address the correct locations in KVM
- * which C will treat as normal variables of the type they are defined in 
- * machine/pmap.h, i.e.  PTDpde = XX ; to set a PDE entry, NOT *PTDpde = XX;
  */
 	.globl	PTmap,PTD,PTDpde
 	.set	PTmap,(PTDPTDI << PDRSHIFT)
@@ -67,16 +61,6 @@
 	.set	PTDpde,PTD + (PTDPTDI * PDESIZE)
 
 /*
- * APTmap, APTD is the alternate recursive pagemap.
- * It's used when modifying another process's page tables.
- * See the note above. It is true here as well.
- */
-	.globl	APTmap,APTD,APTDpde
-	.set	APTmap,APTDPTDI << PDRSHIFT
-	.set	APTD,APTmap + (APTDPTDI * PAGE_SIZE)
-	.set	APTDpde,PTD + (APTDPTDI * PDESIZE)
-
-/*
  * Compiled KERNBASE location
  */
 	.globl	kernbase
@@ -223,7 +207,11 @@
 
 	xorl	%ebp,%ebp		/* mark end of frames */
 
+#ifdef PAE
+	movl	IdlePDPT,%esi
+#else
 	movl	IdlePTD,%esi
+#endif
 	movl	%esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax)
 
 	pushl	physfree		/* value of first for init386(first) */
@@ -308,6 +296,11 @@
 	movl	%esi,R(KPTphys)
 
 /* Allocate Page Table Directory */
+#ifdef PAE
+	/* XXX only need 32 bytes (easier for now) */
+	ALLOCPAGES(1)
+	movl	%esi,R(IdlePDPT)
+#endif
 	ALLOCPAGES(NPGPTD)
 	movl	%esi,R(IdlePTD)
 
@@ -341,6 +334,12 @@
 	fillkptphys(%edx)
 
 /* Map page directory. */
+#ifdef PAE
+	movl	R(IdlePDPT), %eax
+	movl	$1, %ecx
+	fillkptphys($PG_RW)
+#endif
+
 	movl	R(IdlePTD), %eax
 	movl	$NPGPTD, %ecx
 	fillkptphys($PG_RW)
@@ -378,6 +377,13 @@
 	movl	$NPGPTD,%ecx
 	fillkpt(R(IdlePTD), $PG_RW)
 
+#ifdef PAE
+	movl	R(IdlePTD), %eax
+	xorl	%ebx, %ebx
+	movl	$NPGPTD, %ecx
+	fillkpt(R(IdlePDPT), $0x0)
+#endif
+
 	ret
 
 /**********************************************************************



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