When we first created the arm64 port, we weren't quite sure whether coreboot would always run in EL3 on all platforms. The AArch64 A.R.M. technically considers this exception level optional, but in practice all SoCs seem to support it. We have since accumulated a lot of code that already hardcodes an implicit or explicit assumption of executing in EL3 somewhere, so coreboot wouldn't work on a system that tries to enter it in EL1/2 right now anyway. However, some of our low level support libraries (in particular those for accessing architectural registers) still have provisions for running at different exception levels built-in, and often use switch statements over the current exception level to decide which register to access. This includes an unnecessarily large amount of code for what should be single-instruction operations and precludes further optimization via inlining. This patch removes any remaining code that dynamically depends on the current exception level and makes the assumption that coreboot executes at EL3 official. If this ever needs to change for a future platform, it would probably be cleaner to set the expected exception level in a Kconfig rather than always probing it at runtime. Change-Id: I1a9fb9b4227bd15a013080d1c7eabd48515fdb67 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/27880 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
/*
|
|
* This file is part of the coreboot project.
|
|
*
|
|
* Copyright 2013 Google Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; version 2 of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <arch/cache.h>
|
|
#include <arch/lib_helpers.h>
|
|
#include <arch/stages.h>
|
|
#include <arch/transition.h>
|
|
#include <arm_tf.h>
|
|
#include <cbmem.h>
|
|
#include <compiler.h>
|
|
#include <console/console.h>
|
|
#include <program_loading.h>
|
|
#include <rules.h>
|
|
#include <string.h>
|
|
|
|
static void run_payload(struct prog *prog)
|
|
{
|
|
void (*doit)(void *);
|
|
void *arg;
|
|
|
|
doit = prog_entry(prog);
|
|
arg = prog_entry_arg(prog);
|
|
u64 payload_spsr = get_eret_el(EL2, SPSR_USE_L);
|
|
|
|
if (IS_ENABLED(CONFIG_ARM64_USE_ARM_TRUSTED_FIRMWARE))
|
|
arm_tf_run_bl31((u64)doit, (u64)arg, payload_spsr);
|
|
else
|
|
transition_to_el2(doit, arg, payload_spsr);
|
|
}
|
|
|
|
void arch_prog_run(struct prog *prog)
|
|
{
|
|
void (*doit)(void *);
|
|
void *arg;
|
|
|
|
if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) {
|
|
run_payload(prog);
|
|
return;
|
|
}
|
|
|
|
doit = prog_entry(prog);
|
|
arg = prog_entry_arg(prog);
|
|
|
|
doit(prog_entry_arg(prog));
|
|
}
|
|
|
|
int arch_supports_bounce_buffer(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
/* Generic stage entry point. Can be overridden by board/SoC if needed. */
|
|
__weak void stage_entry(void)
|
|
{
|
|
main();
|
|
}
|