diff options
author | Luca Dariz <luca@orpolo.org> | 2023-02-12 18:28:18 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2023-02-12 19:20:31 +0100 |
commit | 6a46db9fe035c26ab549bc0b681469fc650141d6 (patch) | |
tree | 18168863abbfbb4e1850c995269a20b86e748d31 | |
parent | eef53f7a1309e52012babc62da81a2ac750a7e9f (diff) | |
download | gnumach-6a46db9fe035c26ab549bc0b681469fc650141d6.tar.gz gnumach-6a46db9fe035c26ab549bc0b681469fc650141d6.tar.bz2 gnumach-6a46db9fe035c26ab549bc0b681469fc650141d6.zip |
move kernel virtual address space to upper addresses
* i386/i386/vm_param.h: adjust constants to the new kernel map
- the boothdr.S code already sets up a temporary map to higher
addresses, so we can use INIT_VM_MIN_KERNEL_ADDRESS as in xen
- increase the kernel map size to accomodate for bigger structures
and more memory
- adjust kernel max address and directmap limit
* i386/i386at/biosmem.c: enable directmap check also on x86_64
* i386/include/mach/i386/vm_param.h: increase user virtual memory
limit as it's not conflicting with the kernel's anymore
* i386/intel/pmap.h: adjust lin2pdenum_cont() and INTEL_PTE_PFN to the
new kernel map
* x86_64/Makefrag.am: change KERNEL_MAP_BASE to be above 4G, and
according to mcmodel=kernel. This will allow to use the full memory
address space.
Message-Id: <20230212172818.1511405-10-luca@orpolo.org>
-rw-r--r-- | i386/i386/vm_param.h | 20 | ||||
-rw-r--r-- | i386/i386at/biosmem.c | 2 | ||||
-rw-r--r-- | i386/include/mach/i386/vm_param.h | 2 | ||||
-rw-r--r-- | i386/intel/pmap.h | 12 | ||||
-rw-r--r-- | x86_64/Makefrag.am | 12 |
5 files changed, 33 insertions, 15 deletions
diff --git a/i386/i386/vm_param.h b/i386/i386/vm_param.h index c2e623a6..8264ea11 100644 --- a/i386/i386/vm_param.h +++ b/i386/i386/vm_param.h @@ -45,7 +45,7 @@ #define VM_MIN_KERNEL_ADDRESS 0xC0000000UL #endif -#ifdef MACH_XEN +#if defined(MACH_XEN) || defined (__x86_64__) /* PV kernels can be loaded directly to the target virtual address */ #define INIT_VM_MIN_KERNEL_ADDRESS VM_MIN_KERNEL_ADDRESS #else /* MACH_XEN */ @@ -72,12 +72,22 @@ * Reserve mapping room for the kernel map, which includes * the device I/O map and the IPC map. */ +#ifdef __x86_64__ +/* + * Vm structures are quite bigger on 64 bit. + * This should be well enough for 8G of physical memory; on the other hand, + * maybe not all of them need to be in directly-mapped memory, see the parts + * allocated with pmap_steal_memory(). + */ +#define VM_KERNEL_MAP_SIZE (512 * 1024 * 1024) +#else #define VM_KERNEL_MAP_SIZE (152 * 1024 * 1024) +#endif /* This is the kernel address range in linear addresses. */ #ifdef __x86_64__ #define LINEAR_MIN_KERNEL_ADDRESS VM_MIN_KERNEL_ADDRESS -#define LINEAR_MAX_KERNEL_ADDRESS (0x00000000ffffffffUL) +#define LINEAR_MAX_KERNEL_ADDRESS (0xffffffffffffffffUL) #else /* On x86, the kernel virtual address space is actually located at high linear addresses. */ @@ -141,8 +151,10 @@ #else /* MACH_XEN */ #ifdef __LP64__ #define VM_PAGE_MAX_SEGS 4 -#define VM_PAGE_DMA32_LIMIT DECL_CONST(0x100000000, UL) -#define VM_PAGE_DIRECTMAP_LIMIT DECL_CONST(0x400000000000, UL) +#define VM_PAGE_DMA32_LIMIT DECL_CONST(0x10000000, UL) +#define VM_PAGE_DIRECTMAP_LIMIT (VM_MAX_KERNEL_ADDRESS \ + - VM_MIN_KERNEL_ADDRESS \ + - VM_KERNEL_MAP_SIZE + 1) #define VM_PAGE_HIGHMEM_LIMIT DECL_CONST(0x10000000000000, UL) #else /* __LP64__ */ #define VM_PAGE_DIRECTMAP_LIMIT (VM_MAX_KERNEL_ADDRESS \ diff --git a/i386/i386at/biosmem.c b/i386/i386at/biosmem.c index 78e7bb21..880989fe 100644 --- a/i386/i386at/biosmem.c +++ b/i386/i386at/biosmem.c @@ -637,10 +637,8 @@ biosmem_setup_allocator(const struct multiboot_raw_info *mbi) */ end = vm_page_trunc((mbi->mem_upper + 1024) << 10); -#ifndef __LP64__ if (end > VM_PAGE_DIRECTMAP_LIMIT) end = VM_PAGE_DIRECTMAP_LIMIT; -#endif /* __LP64__ */ max_heap_start = 0; max_heap_end = 0; diff --git a/i386/include/mach/i386/vm_param.h b/i386/include/mach/i386/vm_param.h index a684ed97..e98f032c 100644 --- a/i386/include/mach/i386/vm_param.h +++ b/i386/include/mach/i386/vm_param.h @@ -74,7 +74,7 @@ */ #define VM_MIN_ADDRESS (0) #ifdef __x86_64__ -#define VM_MAX_ADDRESS (0x40000000UL) +#define VM_MAX_ADDRESS (0xC0000000UL) #else #define VM_MAX_ADDRESS (0xc0000000UL) #endif diff --git a/i386/intel/pmap.h b/i386/intel/pmap.h index 34c7cc89..78d27bc8 100644 --- a/i386/intel/pmap.h +++ b/i386/intel/pmap.h @@ -77,10 +77,10 @@ typedef phys_addr_t pt_entry_t; #define PDPNUM_KERNEL (((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) >> PDPSHIFT) + 1) #define PDPNUM_USER (((VM_MAX_USER_ADDRESS - VM_MIN_USER_ADDRESS) >> PDPSHIFT) + 1) #define PDPMASK 0x1ff /* mask for page directory pointer index */ -#else +#else /* __x86_64__ */ #define PDPNUM 4 /* number of page directory pointers */ #define PDPMASK 3 /* mask for page directory pointer index */ -#endif +#endif /* __x86_64__ */ #define PDPSHIFT 30 /* page directory pointer */ #define PDESHIFT 21 /* page descriptor shift */ #define PDEMASK 0x1ff /* mask for page descriptor index */ @@ -109,7 +109,11 @@ typedef phys_addr_t pt_entry_t; #if PAE /* Special version assuming contiguous page directories. Making it include the page directory pointer table index too. */ +#ifdef __x86_64__ +#define lin2pdenum_cont(a) (((a) >> PDESHIFT) & 0x3ff) +#else #define lin2pdenum_cont(a) (((a) >> PDESHIFT) & 0x7ff) +#endif #else #define lin2pdenum_cont(a) lin2pdenum(a) #endif @@ -155,7 +159,11 @@ typedef phys_addr_t pt_entry_t; #endif /* MACH_PV_PAGETABLES */ #define INTEL_PTE_WIRED 0x00000200 #ifdef PAE +#ifdef __x86_64__ +#define INTEL_PTE_PFN 0xfffffffffffff000ULL +#else /* __x86_64__ */ #define INTEL_PTE_PFN 0x00007ffffffff000ULL +#endif/* __x86_64__ */ #else #define INTEL_PTE_PFN 0xfffff000 #endif diff --git a/x86_64/Makefrag.am b/x86_64/Makefrag.am index 03b1eca7..d3735890 100644 --- a/x86_64/Makefrag.am +++ b/x86_64/Makefrag.am @@ -186,12 +186,12 @@ include_mach_x86_64_HEADERS = \ # if PLATFORM_at -# This should probably be 0xffffffff80000000 for mcmodel=kernel, but let's try -# to stay in the first 8G first, otherwise we have to fix the pmap module to -# actually use the l4 page level -#KERNEL_MAP_BASE=0x100000000 -# but for nor try with < 4G, otherwise we have linker errors -KERNEL_MAP_BASE=0x40000000 +# For now simply keep all the kernel virtual space in the last 2G. +# We could use a more elaborate schema if needed (e.g. reserving a +# larger area for directmap or the kernel heap)), I think only the +# test/bss/data sections need to be placed here kere because of +# -mcmodel=kernel +KERNEL_MAP_BASE=0xffffffff80000000 gnumach_LINKFLAGS += \ --defsym _START_MAP=$(_START_MAP) \ --defsym _START=$(_START_MAP) \ |