diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 27e1330358fa..cb978a95e629 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 6dc756017258..9336bab4d7cb 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