From 280c69559f68ae8329b935f0374acee0ff994902 Mon Sep 17 00:00:00 2001 From: Sergiu Moga Date: Fri, 7 Apr 2023 19:45:58 +0300 Subject: [PATCH] plat/kvm/arm: Make the earliest bootstack be part of the image In order to make it easier for the paging API to not invalidate the stack, make it part of the image (.bss), so that it is automatically ignored. Signed-off-by: Sergiu Moga Reviewed-by: Michalis Pappas Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #848 --- plat/kvm/arm/entry64.S | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/plat/kvm/arm/entry64.S b/plat/kvm/arm/entry64.S index 52df96647..abf2c01dc 100644 --- a/plat/kvm/arm/entry64.S +++ b/plat/kvm/arm/entry64.S @@ -36,6 +36,13 @@ #include #include +/* Prefer using in-image stack, to avoid conflicts when unmapping is done by + * paging_init (it invalidates our stack) + */ +.section .bss +.space 4096 +lcpu_bootstack: + /* * The registers used by _libkvmplat_start: * x0 - FDT pointer @@ -45,8 +52,6 @@ ENTRY(_libkvmplat_entry) ur_ldr x25, _dtb - ur_ldr x26, _end - #ifdef CONFIG_FPSIMD /* Enable fp/simd support */ ldr x0, =(3 << 20) @@ -63,10 +68,8 @@ ENTRY(_libkvmplat_entry) * just need to invalidate what we are going to use: * DTB, TEXT, DATA, BSS, and bootstack. */ - ur_ldr x0, _start_ram_addr - - add x27, x26, #__STACK_SIZE - sub x1, x27, x25 + ur_ldr x0, _start_ram_addr + ur_ldr x1, _end bl clean_and_invalidate_dcache_range /* Disable the MMU and D-Cache. */ @@ -78,7 +81,8 @@ ENTRY(_libkvmplat_entry) isb /* Set the boot stack */ - mov sp, x27 + ur_ldr x26, lcpu_bootstack + mov sp, x26 /* Set the context id */ msr contextidr_el1, xzr -- 2.39.5