When we no longer identity-map the hypervisor, the bootstrap and shutdown code will require special care because it will run both with MMU on and off.
Push all functions we need for that phases (enable_mmu_el2, shutdown_el2 and vmreturn) into a dedicated, page-aligned trampoline section and identity-map that section during early init. The latter currently only breaks up an already existing ID-mapped hugepage but will become essential once the hypervisor is mapped elsewhere in its address space. Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm64/entry.S | 2 ++ hypervisor/arch/arm64/exception.S | 3 +++ hypervisor/arch/arm64/include/asm/sections.h | 4 ++++ hypervisor/arch/arm64/setup.c | 15 +++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/hypervisor/arch/arm64/entry.S b/hypervisor/arch/arm64/entry.S index 727d50d..021a6a0 100644 --- a/hypervisor/arch/arm64/entry.S +++ b/hypervisor/arch/arm64/entry.S @@ -123,6 +123,7 @@ el2_entry: b . + .pushsection .trampoline, "ax" .globl shutdown_el2 shutdown_el2: /* x0: struct percpu* */ @@ -195,6 +196,7 @@ enable_mmu_el2: dsb nsh ret + .popsection /* diff --git a/hypervisor/arch/arm64/exception.S b/hypervisor/arch/arm64/exception.S index 7164b3f..3e5d8eb 100644 --- a/hypervisor/arch/arm64/exception.S +++ b/hypervisor/arch/arm64/exception.S @@ -72,6 +72,8 @@ hyp_vectors: ventry . ventry . + + .pushsection .trampoline, "ax" .globl vmreturn vmreturn: /* x0: struct registers* */ @@ -93,3 +95,4 @@ vmreturn: ldp x27, x28, [sp], #16 ldp x29, x30, [sp], #16 eret + .popsection diff --git a/hypervisor/arch/arm64/include/asm/sections.h b/hypervisor/arch/arm64/include/asm/sections.h index 3f2e18e..721a8fb 100644 --- a/hypervisor/arch/arm64/include/asm/sections.h +++ b/hypervisor/arch/arm64/include/asm/sections.h @@ -26,4 +26,8 @@ . = . + PAGE_SIZE; \ bootstrap_pt_wildcard = .; \ . = . + PAGE_SIZE; \ + } \ + .trampoline : { \ + __trampoline_start = .; \ + *(.trampoline) \ } diff --git a/hypervisor/arch/arm64/setup.c b/hypervisor/arch/arm64/setup.c index d796ed0..0e49bb0 100644 --- a/hypervisor/arch/arm64/setup.c +++ b/hypervisor/arch/arm64/setup.c @@ -19,6 +19,8 @@ #include <asm/irqchip.h> #include <asm/setup.h> +extern u8 __trampoline_start[]; + static u32 __attribute__((aligned(PAGE_SIZE))) parking_code[PAGE_SIZE / 4] = { 0xd503207f, /* 1: wfi */ 0x17ffffff, /* b 1b */ @@ -28,8 +30,21 @@ struct paging_structures parking_mm; int arch_init_early(void) { + unsigned long trampoline_page = paging_hvirt2phys(&__trampoline_start); int err; + /* + * ID-map the trampoline code page. + * + * We will need it for shutting down once the final page table is + * installed. So better do this early while we can still handle errors. + */ + err = paging_create(&hv_paging_structs, trampoline_page, PAGE_SIZE, + trampoline_page, PAGE_DEFAULT_FLAGS, + PAGING_NON_COHERENT); + if (err) + return err; + parking_mm.root_paging = cell_paging; parking_mm.root_table = page_alloc_aligned(&mem_pool, ARM_CELL_ROOT_PT_SZ); -- 2.1.4 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
