x64: Define TLB bitmap region

Defines the TLB bitmap to be located, virtually, just below the kernel
window. To get an initialized bitmap in each new address space we
change copyGlobalMappings to copy from USER_TOP (which includes the
initialized TLB bitmap in the global address space) instead of just
the kernel window base
This commit is contained in:
Adrian Danis 2016-11-09 16:07:51 +11:00
parent bd72c0c066
commit fc56575ea6
2 changed files with 17 additions and 2 deletions

View file

@ -48,7 +48,12 @@
/* Define the top of our static 'kernel window', which is the top 1GiB of memory */
#define PADDR_HIGH_TOP (PPTR_KDEV - KERNEL_BASE)
#define PPTR_USER_TOP KERNEL_BASE
/* Below the main kernel window we have any slots for the TLB bitmap */
#define TLBBITMAP_PML4_RESERVED (TLBBITMAP_ROOT_ENTRIES * BIT(PML4_INDEX_OFFSET))
#define TLBBITMAP_PPTR (PPTR_BASE - TLBBITMAP_PML4_RESERVED)
/* The start of the this TLB bitmap becomes the highest valid user address */
#define PPTR_USER_TOP TLBBITMAP_PPTR
#define KERNEL_BASE_OFFSET (KERNEL_BASE - PADDR_BASE)
#define kernelBase KERNEL_BASE

View file

@ -19,6 +19,7 @@
#include <arch/kernel/boot.h>
#include <arch/api/invocation.h>
#include <mode/kernel/tlb.h>
#include <arch/kernel/tlb_bitmap.h>
struct lookupPML4Slot_ret {
exception_t status;
@ -253,6 +254,11 @@ map_kernel_window(
return false;
}
#if CONFIG_MAX_NUM_NODES > 1
/* initialize the TLB bitmap */
tlb_bitmap_init(x64KSGlobalPML4);
#endif /* CONFIG_MAX_NUM_NODES */
/* In boot code, so fine to just trash everything here */
invalidateLocalTranslationAll();
printf("Mapping kernel window is done\n");
@ -724,7 +730,11 @@ void copyGlobalMappings(vspace_root_t *new_vspace)
unsigned long i;
pml4e_t *vspace = (pml4e_t *)new_vspace;
for (i = GET_PML4_INDEX(PPTR_BASE); i < BIT(PML4_INDEX_BITS); i++) {
/* Copy from the user top so that we copy the default entries of the
* tlb bitmap (if it exists). If it doesn't exist then this loop
* will be equivalent to copying from PPTR_BASE
*/
for (i = GET_PML4_INDEX(PPTR_USER_TOP); i < BIT(PML4_INDEX_BITS); i++) {
vspace[i] = x64KSGlobalPML4[i];
}
}