diff --git a/arch/x86_64/kernel/include/arch-memory.h b/arch/x86_64/kernel/include/arch-memory.h index e38d5e28..ab6b918b 100644 --- a/arch/x86_64/kernel/include/arch-memory.h +++ b/arch/x86_64/kernel/include/arch-memory.h @@ -42,10 +42,24 @@ #define USER_END 0x0000800000000000UL #define TASK_UNMAPPED_BASE 0x00002AAAAAA00000UL + +/* + * Canonical negative addresses (i.e., the smallest kernel virtual address) + * on x86 64 bit mode (in its most restricted 48 bit format) starts from + * 0xffff800000000000, but Linux starts mapping physical memory at 0xffff880000000000. + * The 0x80000000000 long gap (8TBs, i.e., 16 PGD level entries in the page tables) + * is used for Xen hyervisor (see arch/x86/include/asm/page.h) and that is + * what we utilize for McKernel. + * This gives us the benefit of being able to use Linux kernel virtual + * addresses identically as in Linux. + * + * NOTE: update these also in eclair.c when modified! + */ #define MAP_ST_START 0xffff800000000000UL -#define MAP_VMAP_START 0xfffff00000000000UL -#define MAP_FIXED_START 0xffffffff70000000UL -#define MAP_KERNEL_START 0xffffffff80000000UL +#define MAP_VMAP_START 0xffff850000000000UL +#define MAP_FIXED_START 0xffff860000000000UL +#define MAP_KERNEL_START 0xffff870000000000UL +#define LINUX_PAGE_OFFSET 0xffff880000000000UL #define STACK_TOP(region) ((region)->user_end) #define MAP_VMAP_SIZE 0x0000000100000000UL diff --git a/arch/x86_64/kernel/memory.c b/arch/x86_64/kernel/memory.c index 4dde930c..e98696dd 100644 --- a/arch/x86_64/kernel/memory.c +++ b/arch/x86_64/kernel/memory.c @@ -2539,6 +2539,30 @@ static void init_normal_area(struct page_table *pt) virt += LARGE_PAGE_SIZE; } } + +static void init_linux_kernel_mapping(struct page_table *pt) +{ + unsigned long map_start, map_end, phys; + void *virt; + + /* Map 2 TB for now */ + map_start = 0; + map_end = 0x20000000000; + + virt = (void *)LINUX_PAGE_OFFSET; + + kprintf("Linux kernel virtual: 0x%lx - 0x%lx -> 0x%lx - 0x%lx\n", + LINUX_PAGE_OFFSET, LINUX_PAGE_OFFSET + map_end, 0, map_end); + + for (phys = map_start; phys < map_end; phs += LARGE_PAGE_SIZE) { + if (set_pt_large_page(pt, virt, phys, PTATTR_WRITABLE) != 0) { + kprintf("%s: error setting mapping for 0x%lx\n", + __func__, virt); + } + virt += LARGE_PAGE_SIZE; + } +} + void init_text_area(struct page_table *pt) { unsigned long __end, phys, virt; @@ -2627,6 +2651,7 @@ void init_page_table(void) /* Normal memory area */ init_normal_area(init_pt); + init_linux_kernel_mapping(init_pt); init_fixed_area(init_pt); init_low_area(init_pt); init_text_area(init_pt); diff --git a/ihk b/ihk index 779390b2..e783a654 160000 --- a/ihk +++ b/ihk @@ -1 +1 @@ -Subproject commit 779390b27b81c6c98ae54811333e066ae3823391 +Subproject commit e783a654b424b2b1cc81be87a0cb3fc75634d0a6 diff --git a/kernel/config/smp-x86.lds b/kernel/config/smp-x86.lds index 0e322d13..ba11abfc 100644 --- a/kernel/config/smp-x86.lds +++ b/kernel/config/smp-x86.lds @@ -5,7 +5,7 @@ PHDRS } SECTIONS { - . = 0xffffffff80001000; + . = 0xffff870000001000; _head = .; .text : {