From 41ba11229a80eb19d97c8052aff1861478ee2486 Mon Sep 17 00:00:00 2001 From: David Milosevic Date: Thu, 27 Apr 2023 02:12:31 +0200 Subject: arch/arm64: Add EL1/EL2/EL3 support for arm64 Currently, arch/arm64 requires coreboot to run on EL3 due to EL3 register access. This might be an issue when, for example, one boots into TF-A first and drops into EL2 for coreboot afterwards. This patch aims at making arch/arm64 more versatile by removing the current EL3 constraint and allowing arm64 coreboot to run on EL1, EL2 and EL3. The strategy here, is to add a Kconfig option (ARM64_CURRENT_EL) which lets us specify coreboot's EL upon entry. Based on that, we access the appropriate ELx registers. So, for example, when running coreboot on EL1, we would not access vbar_el3 or vbar_el2 but instead vbar_el1. This way, we don't generate faults when accessing higher-EL registers. Currently only tested on the qemu-aarch64 target. Exceptions were tested by enabling FATAL_ASSERTS. Signed-off-by: David Milosevic Change-Id: Iae1c57f0846c8d0585384f7e54102a837e701e7e Reviewed-on: https://review.coreboot.org/c/coreboot/+/74798 Reviewed-by: Werner Zeh Reviewed-by: ron minnich Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner --- src/arch/arm64/armv8/exception.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/arch/arm64/armv8/exception.c') diff --git a/src/arch/arm64/armv8/exception.c b/src/arch/arm64/armv8/exception.c index 8583fd5172..6035d749c7 100644 --- a/src/arch/arm64/armv8/exception.c +++ b/src/arch/arm64/armv8/exception.c @@ -51,9 +51,10 @@ static void print_regs(struct exc_state *exc_state) struct regs *regs = &exc_state->regs; printk(BIOS_DEBUG, "ELR = 0x%016llx ESR = 0x%08llx\n", - elx->elr, raw_read_esr_el3()); + elx->elr, raw_read_esr()); printk(BIOS_DEBUG, "FAR = 0x%016llx SPSR = 0x%08llx\n", - raw_read_far_el3(), raw_read_spsr_el3()); + raw_read_far(), raw_read_spsr()); + for (i = 0; i < 30; i += 2) { printk(BIOS_DEBUG, "X%02d = 0x%016llx X%02d = 0x%016llx\n", @@ -173,7 +174,8 @@ static int test_exception_handler(struct exc_state *state, uint64_t vector_id) { /* Update instruction pointer to next instruction. */ state->elx.elr += sizeof(uint32_t); - raw_write_elr_el3(state->elx.elr); + raw_write_elr(state->elx.elr); + return EXC_RET_HANDLED; } -- cgit v1.2.3