From: Jan Kiszka <[email protected]> While this split-up makes sense on x86 with the two different CPU vendors, it's artificial on ARM. So move the hypervisor (exception) entry over into entry.S and define a corresponding header that holds all interfaces.
Signed-off-by: Jan Kiszka <[email protected]> --- hypervisor/arch/arm/Kbuild | 2 +- hypervisor/arch/arm/entry.S | 60 ++++++++++++++++++++++++++ hypervisor/arch/arm/exception.S | 72 ------------------------------- hypervisor/arch/arm/include/asm/control.h | 1 - hypervisor/arch/arm/include/asm/entry.h | 20 +++++++++ hypervisor/arch/arm/mmu_hyp.c | 5 +-- 6 files changed, 82 insertions(+), 78 deletions(-) delete mode 100644 hypervisor/arch/arm/exception.S create mode 100644 hypervisor/arch/arm/include/asm/entry.h diff --git a/hypervisor/arch/arm/Kbuild b/hypervisor/arch/arm/Kbuild index 04e835c6..158759c1 100644 --- a/hypervisor/arch/arm/Kbuild +++ b/hypervisor/arch/arm/Kbuild @@ -17,7 +17,7 @@ KBUILD_AFLAGS := $(subst -include asm/unified.h,,$(KBUILD_AFLAGS)) always := built-in.o obj-y := $(COMMON_OBJECTS) -obj-y += entry.o exception.o setup.o control.o traps.o mmio.o lib.o +obj-y += entry.o setup.o control.o traps.o mmio.o lib.o obj-y += mmu_hyp.o caches.o mach-stubs.o # in here we switch of the MMU and stuff, cant profile such code diff --git a/hypervisor/arch/arm/entry.S b/hypervisor/arch/arm/entry.S index 53469e80..7ea6895b 100644 --- a/hypervisor/arch/arm/entry.S +++ b/hypervisor/arch/arm/entry.S @@ -14,6 +14,8 @@ #include <asm/percpu.h> #include <asm/processor.h> + .arch_extension virt + /* Entry point for Linux loader module on JAILHOUSE_ENABLE */ .text .globl arch_entry @@ -63,6 +65,7 @@ arch_entry: pop {r1 - r12} subs pc, lr, #0 + .globl bootstrap_vectors .align 5 bootstrap_vectors: @@ -83,3 +86,60 @@ setup_el2: mov sp, r1 bx lr + + + .globl hyp_vectors + .align 5 +hyp_vectors: + b . + b hyp_undef + b hyp_hvc + b hyp_pabt + b hyp_dabt + b hyp_trap + b hyp_irq + b hyp_fiq + +.macro handle_vmexit exit_reason + /* Fill the struct registers. Should comply with NUM_USR_REGS */ + push {r0-r12, lr} + mov r0, #\exit_reason + b vmexit_common +.endm + +hyp_undef: + handle_vmexit EXIT_REASON_UNDEF +hyp_hvc: + handle_vmexit EXIT_REASON_HVC +hyp_pabt: + handle_vmexit EXIT_REASON_PABT +hyp_dabt: + handle_vmexit EXIT_REASON_DABT + +hyp_irq: + handle_vmexit EXIT_REASON_IRQ +hyp_fiq: + handle_vmexit EXIT_REASON_FIQ +hyp_trap: + handle_vmexit EXIT_REASON_TRAP + +vmexit_common: + push {r0} + + arm_read_sysreg(TPIDR_EL2, r0) + mov r1, sp + bl arch_handle_exit + + + /* + * Because the hypervisor may call vmreturn to reset the stack, + * arch_handle_exit has to return with the guest registers in r0 + */ + .globl vmreturn +vmreturn: + mov sp, r0 + add sp, #4 + + /* Restore usr regs */ + pop {r0-r12, lr} + eret diff --git a/hypervisor/arch/arm/exception.S b/hypervisor/arch/arm/exception.S deleted file mode 100644 index 8c0ce6a8..00000000 --- a/hypervisor/arch/arm/exception.S +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Jailhouse, a Linux-based partitioning hypervisor - * - * Copyright (c) ARM Limited, 2014 - * - * Authors: - * Jean-Philippe Brucker <[email protected]> - * - * This work is licensed under the terms of the GNU GPL, version 2. See - * the COPYING file in the top-level directory. - */ - -#include <asm/processor.h> -#include <asm/sysregs.h> - - .arch_extension virt - - .text - .globl hyp_vectors - .align 5 -hyp_vectors: - b . - b hyp_undef - b hyp_hvc - b hyp_pabt - b hyp_dabt - b hyp_trap - b hyp_irq - b hyp_fiq - -.macro handle_vmexit exit_reason - /* Fill the struct registers. Should comply with NUM_USR_REGS */ - push {r0-r12, lr} - mov r0, #\exit_reason - b vmexit_common -.endm - -hyp_undef: - handle_vmexit EXIT_REASON_UNDEF -hyp_hvc: - handle_vmexit EXIT_REASON_HVC -hyp_pabt: - handle_vmexit EXIT_REASON_PABT -hyp_dabt: - handle_vmexit EXIT_REASON_DABT - -hyp_irq: - handle_vmexit EXIT_REASON_IRQ -hyp_fiq: - handle_vmexit EXIT_REASON_FIQ -hyp_trap: - handle_vmexit EXIT_REASON_TRAP - -vmexit_common: - push {r0} - - arm_read_sysreg(TPIDR_EL2, r0) - mov r1, sp - bl arch_handle_exit - - /* - * Because the hypervisor may call vmreturn to reset the stack, - * arch_handle_exit has to return with the guest registers in r0 - */ - .globl vmreturn -vmreturn: - mov sp, r0 - add sp, #4 - - /* Restore usr regs */ - pop {r0-r12, lr} - eret diff --git a/hypervisor/arch/arm/include/asm/control.h b/hypervisor/arch/arm/include/asm/control.h index 481ca195..fd3bea03 100644 --- a/hypervisor/arch/arm/include/asm/control.h +++ b/hypervisor/arch/arm/include/asm/control.h @@ -36,7 +36,6 @@ void arch_shutdown_self(struct per_cpu *cpu_data); unsigned int arm_cpu_by_mpidr(struct cell *cell, unsigned long mpidr); -void __attribute__((noreturn)) vmreturn(struct registers *guest_regs); void __attribute__((noreturn)) arch_shutdown_mmu(struct per_cpu *cpu_data); void arm_cpu_reset(unsigned long pc); diff --git a/hypervisor/arch/arm/include/asm/entry.h b/hypervisor/arch/arm/include/asm/entry.h new file mode 100644 index 00000000..007a264d --- /dev/null +++ b/hypervisor/arch/arm/include/asm/entry.h @@ -0,0 +1,20 @@ +/* + * Jailhouse, a Linux-based partitioning hypervisor + * + * Copyright (c) ARM Limited, 2014 + * Copyright (c) Siemens AG, 2017 + * + * Authors: + * Jean-Philippe Brucker <[email protected]> + * Jan Kiszka <[email protected]> + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include <asm/processor.h> + +extern unsigned long bootstrap_vectors; +extern unsigned long hyp_vectors; + +void __attribute__((noreturn)) vmreturn(struct registers *guest_regs); diff --git a/hypervisor/arch/arm/mmu_hyp.c b/hypervisor/arch/arm/mmu_hyp.c index 765160b6..aa58fbbb 100644 --- a/hypervisor/arch/arm/mmu_hyp.c +++ b/hypervisor/arch/arm/mmu_hyp.c @@ -12,7 +12,7 @@ #include <jailhouse/paging.h> #include <jailhouse/printk.h> -#include <asm/control.h> +#include <asm/entry.h> #include <asm/setup.h> #include <asm/sysregs.h> @@ -257,9 +257,6 @@ static void check_mmu_map(unsigned long virt_addr, unsigned long phys_addr) */ int switch_exception_level(struct per_cpu *cpu_data) { - extern unsigned long bootstrap_vectors; - extern unsigned long hyp_vectors; - /* Save the virtual address of the phys2virt function for later */ phys2virt_t phys2virt = paging_phys2hvirt; virt2phys_t virt2phys = paging_hvirt2phys; -- 2.12.3 -- 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.
