diff options
author | peter <peter@FreeBSD.org> | 2003-07-09 23:04:23 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2003-07-09 23:04:23 +0000 |
commit | 9fc6da3f4c50a6a9d1ccfd5ea211980d3f244799 (patch) | |
tree | e3205656711935b2bcc1da978133f4e7e78905b5 | |
parent | b1f1716f2aea85089a01e4a4b2e10c0393be888a (diff) | |
download | FreeBSD-src-9fc6da3f4c50a6a9d1ccfd5ea211980d3f244799.zip FreeBSD-src-9fc6da3f4c50a6a9d1ccfd5ea211980d3f244799.tar.gz |
Fix the VADDR() macros to use either KVADDR() or UVADDR(), depending
on the implied sign extension. The single unified VADDR() macro was
not able to avoid sign extending the VM_MAXUSER_ADDRESS/USRSTACK values.
Be explicit about UVADDR() (positive address space) and KVADDR()
(kernel negative address space) to make mistakes show up more
spectacularly.
Increase user VM space from 1/2TB (512GB) to 128TB.
-rw-r--r-- | sys/amd64/include/pmap.h | 22 | ||||
-rw-r--r-- | sys/amd64/include/vmparam.h | 16 |
2 files changed, 21 insertions, 17 deletions
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 27e1330..cb978a9 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -86,14 +86,18 @@ * Pte related macros. This is complicated by having to deal with * the sign extension of the 48th bit. */ -#define VADDR_SIGN(l4) \ - ((l4) >= NPML4EPG/2 ? ((unsigned long)-1 << 47) : 0ul) -#define VADDR(l4, l3, l2, l1) ( \ - ((unsigned long)(l4) << PML4SHIFT) | VADDR_SIGN(l4) | \ +#define KVADDR(l4, l3, l2, l1) ( \ + ((unsigned long)-1 << 47) | \ + ((unsigned long)(l4) << PML4SHIFT) | \ ((unsigned long)(l3) << PDPSHIFT) | \ ((unsigned long)(l2) << PDRSHIFT) | \ ((unsigned long)(l1) << PAGE_SHIFT)) +#define UVADDR(l4, l3, l2, l1) ( \ + ((unsigned long)(l4) << PML4SHIFT) | \ + ((unsigned long)(l3) << PDPSHIFT) | \ + ((unsigned long)(l2) << PDRSHIFT) | \ + ((unsigned long)(l1) << PAGE_SHIFT)) #ifndef NKPT #define NKPT 120 /* initial number of kernel page tables */ @@ -103,7 +107,7 @@ #define NKPDPE 1 /* number of kernel PDP slots */ #define NKPDE (NKPDPE*NPDEPG) /* number of kernel PD slots */ -#define NUPML4E 1 /* number of userland PML4 pages */ +#define NUPML4E (NPML4EPG/2) /* number of userland PML4 pages */ #define NUPDPE (NUPML4E*NPDPEPG)/* number of userland PDP pages */ #define NUPDE (NUPDPE*NPDEPG) /* number of userland PD entries */ @@ -149,10 +153,10 @@ typedef u_int64_t pml4_entry_t; * in the page tables and the evil overlapping. */ #ifdef _KERNEL -#define addr_PTmap (VADDR(PML4PML4I, 0, 0, 0)) -#define addr_PDmap (VADDR(PML4PML4I, PML4PML4I, 0, 0)) -#define addr_PDPmap (VADDR(PML4PML4I, PML4PML4I, PML4PML4I, 0)) -#define addr_PML4map (VADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I)) +#define addr_PTmap (KVADDR(PML4PML4I, 0, 0, 0)) +#define addr_PDmap (KVADDR(PML4PML4I, PML4PML4I, 0, 0)) +#define addr_PDPmap (KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, 0)) +#define addr_PML4map (KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I)) #define addr_PML4pml4e (addr_PML4map + (PML4PML4I * sizeof(pml4_entry_t))) #define PTmap ((pt_entry_t *)(addr_PTmap)) #define PDmap ((pd_entry_t *)(addr_PDmap)) diff --git a/sys/amd64/include/vmparam.h b/sys/amd64/include/vmparam.h index 6dc7560..9336bab 100644 --- a/sys/amd64/include/vmparam.h +++ b/sys/amd64/include/vmparam.h @@ -92,18 +92,18 @@ * messy at times, but hey, we'll do anything to save a page :-) */ -#define VM_MAX_KERNEL_ADDRESS VADDR(KPML4I, NPDPEPG-1, NKPDE-1, NPTEPG-1) -#define VM_MIN_KERNEL_ADDRESS VADDR(KPML4I, KPDPI, 0, 0) +#define VM_MAX_KERNEL_ADDRESS KVADDR(KPML4I, NPDPEPG-1, NKPDE-1, NPTEPG-1) +#define VM_MIN_KERNEL_ADDRESS KVADDR(KPML4I, KPDPI, 0, 0) -#define DMAP_MIN_ADDRESS VADDR(DMPML4I, 0, 0, 0) -#define DMAP_MAX_ADDRESS VADDR(DMPML4I+1, 0, 0, 0) +#define DMAP_MIN_ADDRESS KVADDR(DMPML4I, 0, 0, 0) +#define DMAP_MAX_ADDRESS KVADDR(DMPML4I+1, 0, 0, 0) -#define KERNBASE VADDR(KPML4I, KPDPI, 0, 0) +#define KERNBASE KVADDR(KPML4I, KPDPI, 0, 0) -#define UPT_MAX_ADDRESS VADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I) -#define UPT_MIN_ADDRESS VADDR(PML4PML4I, 0, 0, 0) +#define UPT_MAX_ADDRESS KVADDR(PML4PML4I, PML4PML4I, PML4PML4I, PML4PML4I) +#define UPT_MIN_ADDRESS KVADDR(PML4PML4I, 0, 0, 0) -#define VM_MAXUSER_ADDRESS VADDR(NUPML4E, 0, 0, 0) +#define VM_MAXUSER_ADDRESS UVADDR(NUPML4E, 0, 0, 0) #define USRSTACK VM_MAXUSER_ADDRESS |