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.
This commit is contained in:
parent
6486c09935
commit
bf8ca114e2
@ -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))
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user