diff --git a/executer/user/arch/arm64/arch-eclair.c b/executer/user/arch/arm64/arch-eclair.c index 93be202e..47c8cbda 100644 --- a/executer/user/arch/arm64/arch-eclair.c +++ b/executer/user/arch/arm64/arch-eclair.c @@ -98,8 +98,8 @@ uintptr_t virt_to_phys(uintptr_t va) return (va - MAP_ST + PHYS_OFFSET); } - if (va >= MAP_KERNEL) { - return (va - MAP_KERNEL + kernel_base); + if (va >= MAP_KERNEL_START) { + return (va - MAP_KERNEL_START + kernel_base); } return NOPHYS; @@ -107,7 +107,13 @@ uintptr_t virt_to_phys(uintptr_t va) int arch_setup_constants(void) { - /* Nothing here */ + MAP_KERNEL_START = lookup_symbol("_head"); + if (MAP_KERNEL_START == NOSYMBOL) { + fprintf(stderr, "error: obtaining MAP_KERNEL_START\n"); + return 1; + } + printf("arm64 MAP_KERNEL_START 0x%lx\n", MAP_KERNEL_START); + return 0; } diff --git a/executer/user/arch/arm64/include/arch-eclair.h b/executer/user/arch/arm64/include/arch-eclair.h index 9140788b..891aec54 100644 --- a/executer/user/arch/arm64/include/arch-eclair.h +++ b/executer/user/arch/arm64/include/arch-eclair.h @@ -9,15 +9,11 @@ # # if (CONFIG_ARM64_VA_BITS == 42) # /* VA_BITS=42, 64K_PAGE address */ -# define MAP_KERNEL 0xfffffc0007800000 # define MAP_ST 0xfffffe0000000000 -# define MAP_KERNEL_TEXT "0xfffffc0007800000" # # elif (CONFIG_ARM64_VA_BITS == 48) # /* VA_BITS=48, 64K_PAGE address */ -# define MAP_KERNEL 0xffff000007800000 # define MAP_ST 0xffff800000000000 -# define MAP_KERNEL_TEXT "0xffff000007800000" # # else # @@ -29,15 +25,11 @@ # # if (CONFIG_ARM64_VA_BITS == 39) # /* VA_BITS=39, 4K_PAGE address */ -# define MAP_KERNEL 0xffffff8007800000 # define MAP_ST 0xffffffc000000000 -# define MAP_KERNEL_TEXT "0xffffff8007800000" # # elif (CONFIG_ARM64_VA_BITS == 48) # /* VA_BITS=48, 4K_PAGE address */ -# define MAP_KERNEL 0xffff000007800000 # define MAP_ST 0xffff800000000000 -# define MAP_KERNEL_TEXT "0xffff000007800000" # # else # diff --git a/executer/user/arch/x86_64/arch-eclair.c b/executer/user/arch/x86_64/arch-eclair.c index f8620a7f..2a5ba4e0 100644 --- a/executer/user/arch/x86_64/arch-eclair.c +++ b/executer/user/arch/x86_64/arch-eclair.c @@ -124,6 +124,16 @@ uintptr_t virt_to_phys(uintptr_t va) int arch_setup_constants(void) { + MAP_KERNEL_START = lookup_symbol("_head"); + if (MAP_KERNEL_START == NOSYMBOL) { + fprintf(stderr, "error: obtaining MAP_KERNEL_START\n"); + return 1; + } + + /* One page extra head, see smp-x86.lds */ + MAP_KERNEL_START -= 0x1000; + printf("x86 MAP_KERNEL_START 0x%lx\n", MAP_KERNEL_START); + if (read_symbol_64("linux_page_offset_base", &linux_page_offset) != 0) { fprintf(stderr, "error: obtaining Linux page offset\n"); diff --git a/executer/user/arch/x86_64/include/arch-eclair.h b/executer/user/arch/x86_64/include/arch-eclair.h index cc466d15..1a0f056b 100644 --- a/executer/user/arch/x86_64/include/arch-eclair.h +++ b/executer/user/arch/x86_64/include/arch-eclair.h @@ -4,7 +4,6 @@ #define MAP_ST_START 0xffff800000000000UL #define MAP_FIXED_START 0xffff860000000000UL -#define MAP_KERNEL_START 0xFFFFFFFFFE800000UL extern unsigned long linux_page_offset; #define ARCH_CLV_SPAN "x86_cpu_local_variables_span" diff --git a/executer/user/eclair.c b/executer/user/eclair.c index 69ece3c2..f7c752c8 100644 --- a/executer/user/eclair.c +++ b/executer/user/eclair.c @@ -60,6 +60,9 @@ struct thread_info { uintptr_t arch_clv; }; /* struct thread_info */ +/* Virtual address where McKernel is mapped to */ +unsigned long MAP_KERNEL_START; + static struct options opt; static volatile int f_done = 0; static bfd *symbfd = NULL; @@ -83,7 +86,6 @@ uintptr_t lookup_symbol(char *name) return (symtab[i]->section->vma + symtab[i]->value); } } -#define NOSYMBOL ((uintptr_t)-1) return NOSYMBOL; } /* lookup_symbol() */ @@ -794,10 +796,11 @@ static void command(const char *cmd, char *res, size_t res_size) { rbp += sprintf(rbp, "T0;tnotrun:0"); } else if (!strncmp(p, "qXfer:memory-map:read::", 23)) { - char *str = - "" - "" - ""; + char str[1024]; + sprintf(str, "" + "" + "", MAP_KERNEL_START); + rbp += sprintf(rbp, "l"); if (0) rbp += print_hex(rbp, res_size, str); diff --git a/executer/user/eclair.h b/executer/user/eclair.h index 9542253c..8f9f24b7 100644 --- a/executer/user/eclair.h +++ b/executer/user/eclair.h @@ -8,6 +8,8 @@ #include #include +extern unsigned long MAP_KERNEL_START; + /* common */ int read_mem(uintptr_t va, void *buf, size_t size); #define NOSYMBOL ((uintptr_t)-1)