arm64: Switch to EL2 for libpayload jump

CQ-DEPEND=CL:216826,CL:218300
BUG=chrome-os-partner:31634
BRANCH=None
TEST=Compiles successfully and we are able to start execution of libpayload in
EL2 and reach kernel login prompt

Change-Id: I336d73085f08ca03e533555a10b88f20d74b4347
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/217826
Tested-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Commit-Queue: Furquan Shaikh <furquan@chromium.org>
This commit is contained in:
Furquan Shaikh 2014-09-11 16:06:01 -07:00 committed by chrome-internal-fetch
commit 169948a2af

View file

@ -18,16 +18,36 @@
*/
#include <arch/cache.h>
#include <arch/lib_helpers.h>
#include <arch/stages.h>
#include <arch/transition.h>
#include <cbmem.h>
#include <console/console.h>
#include <string.h>
void jmp_to_elf_entry(void *entry, unsigned long buffer, unsigned long size)
{
void (*doit)(void *) = entry;
void *cb_tables = cbmem_find(CBMEM_ID_CBTABLE);
uint8_t current_el = get_current_el();
printk(BIOS_SPEW, "entry = %p\n", entry);
/* If current EL is not EL3, jump to payload at same EL. */
if (current_el != EL3) {
cache_sync_instructions();
/* Point of no-return */
doit(cb_tables);
}
/* If current EL is EL3, we transition to payload in EL2. */
struct exc_state exc_state;
memset(&exc_state, 0, sizeof(exc_state));
exc_state.elx.spsr = get_eret_el(EL2, SPSR_USE_L);
cache_sync_instructions();
doit(cb_tables);
transition_with_entry(entry, cb_tables, &exc_state);
}