• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * EFI entry point.
4 *
5 * Copyright (C) 2013, 2014 Red Hat, Inc.
6 * Author: Mark Salter <msalter@redhat.com>
7 */
8#include <linux/linkage.h>
9#include <linux/init.h>
10
11#include <asm/assembler.h>
12
13	__INIT
14
15SYM_CODE_START(efi_enter_kernel)
16	/*
17	 * efi_pe_entry() will have copied the kernel image if necessary and we
18	 * end up here with device tree address in x1 and the kernel entry
19	 * point stored in x0. Save those values in registers which are
20	 * callee preserved.
21	 */
22	ldr	w2, =primary_entry_offset
23	add	x19, x0, x2		// relocated Image entrypoint
24	mov	x20, x1			// DTB address
25
26	/*
27	 * Clean the copied Image to the PoC, and ensure it is not shadowed by
28	 * stale icache entries from before relocation.
29	 */
30	ldr	w1, =kernel_size
31	bl	__clean_dcache_area_poc
32	ic	ialluis
33
34	/*
35	 * Clean the remainder of this routine to the PoC
36	 * so that we can safely disable the MMU and caches.
37	 */
38	adr	x0, 0f
39	ldr	w1, 3f
40	bl	__clean_dcache_area_poc
410:
42	/* Turn off Dcache and MMU */
43	mrs	x0, CurrentEL
44	cmp	x0, #CurrentEL_EL2
45	b.ne	1f
46	mrs	x0, sctlr_el2
47	bic	x0, x0, #1 << 0	// clear SCTLR.M
48	bic	x0, x0, #1 << 2	// clear SCTLR.C
49	pre_disable_mmu_workaround
50	msr	sctlr_el2, x0
51	isb
52	b	2f
531:
54	mrs	x0, sctlr_el1
55	bic	x0, x0, #1 << 0	// clear SCTLR.M
56	bic	x0, x0, #1 << 2	// clear SCTLR.C
57	pre_disable_mmu_workaround
58	msr	sctlr_el1, x0
59	isb
602:
61	/* Jump to kernel entry point */
62	mov	x0, x20
63	mov	x1, xzr
64	mov	x2, xzr
65	mov	x3, xzr
66	br	x19
67SYM_CODE_END(efi_enter_kernel)
683:	.long	. - 0b
69