2019-06-04 08:11:33 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2014-04-16 02:47:52 +00:00
|
|
|
/*
|
|
|
|
* EFI entry point.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013, 2014 Red Hat, Inc.
|
|
|
|
* Author: Mark Salter <msalter@redhat.com>
|
|
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <asm/assembler.h>
|
|
|
|
|
|
|
|
__INIT
|
|
|
|
|
2020-02-17 11:44:37 +00:00
|
|
|
ENTRY(efi_enter_kernel)
|
2014-04-16 02:47:52 +00:00
|
|
|
/*
|
2014-11-13 12:22:01 +00:00
|
|
|
* efi_entry() will have copied the kernel image if necessary and we
|
2020-02-17 11:44:37 +00:00
|
|
|
* end up here with device tree address in x1 and the kernel entry
|
|
|
|
* point stored in x0. Save those values in registers which are
|
|
|
|
* callee preserved.
|
2014-04-16 02:47:52 +00:00
|
|
|
*/
|
2020-02-17 11:44:37 +00:00
|
|
|
mov x19, x0 // relocated Image address
|
|
|
|
mov x20, x1 // DTB address
|
2014-04-16 02:47:52 +00:00
|
|
|
|
2014-11-13 12:22:01 +00:00
|
|
|
/*
|
|
|
|
* Flush the copied Image to the PoC, and ensure it is not shadowed by
|
|
|
|
* stale icache entries from before relocation.
|
|
|
|
*/
|
2020-02-17 11:44:37 +00:00
|
|
|
ldr w1, =kernel_size
|
2014-04-16 02:47:52 +00:00
|
|
|
bl __flush_dcache_area
|
|
|
|
ic ialluis
|
2020-02-17 11:44:37 +00:00
|
|
|
dsb sy
|
2014-04-16 02:47:52 +00:00
|
|
|
|
2014-11-13 12:22:01 +00:00
|
|
|
/*
|
2020-02-17 11:44:37 +00:00
|
|
|
* Jump across, into the copy of the image that we just cleaned
|
|
|
|
* to the PoC, so that we can safely disable the MMU and caches.
|
2014-11-13 12:22:01 +00:00
|
|
|
*/
|
2020-02-17 11:44:37 +00:00
|
|
|
ldr w0, .Ljmp
|
|
|
|
sub x0, x19, w0, sxtw
|
|
|
|
br x0
|
|
|
|
0:
|
2014-04-16 02:47:52 +00:00
|
|
|
/* Turn off Dcache and MMU */
|
|
|
|
mrs x0, CurrentEL
|
2014-06-06 13:16:21 +00:00
|
|
|
cmp x0, #CurrentEL_EL2
|
2014-04-16 02:47:52 +00:00
|
|
|
b.ne 1f
|
|
|
|
mrs x0, sctlr_el2
|
|
|
|
bic x0, x0, #1 << 0 // clear SCTLR.M
|
|
|
|
bic x0, x0, #1 << 2 // clear SCTLR.C
|
2017-12-11 22:42:32 +00:00
|
|
|
pre_disable_mmu_workaround
|
2014-04-16 02:47:52 +00:00
|
|
|
msr sctlr_el2, x0
|
|
|
|
isb
|
|
|
|
b 2f
|
|
|
|
1:
|
|
|
|
mrs x0, sctlr_el1
|
|
|
|
bic x0, x0, #1 << 0 // clear SCTLR.M
|
|
|
|
bic x0, x0, #1 << 2 // clear SCTLR.C
|
2017-12-11 22:42:32 +00:00
|
|
|
pre_disable_mmu_workaround
|
2014-04-16 02:47:52 +00:00
|
|
|
msr sctlr_el1, x0
|
|
|
|
isb
|
|
|
|
2:
|
|
|
|
/* Jump to kernel entry point */
|
|
|
|
mov x0, x20
|
|
|
|
mov x1, xzr
|
|
|
|
mov x2, xzr
|
|
|
|
mov x3, xzr
|
2020-02-17 11:44:37 +00:00
|
|
|
b stext
|
|
|
|
ENDPROC(efi_enter_kernel)
|
|
|
|
.Ljmp: .long _text - 0b
|