.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * EFI entry point. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2013, 2014 Red Hat, Inc. |
---|
5 | 6 | * Author: Mark Salter <msalter@redhat.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | 7 | */ |
---|
12 | 8 | #include <linux/linkage.h> |
---|
13 | 9 | #include <linux/init.h> |
---|
14 | 10 | |
---|
15 | 11 | #include <asm/assembler.h> |
---|
16 | 12 | |
---|
17 | | -#define EFI_LOAD_ERROR 0x8000000000000001 |
---|
18 | | - |
---|
19 | 13 | __INIT |
---|
20 | 14 | |
---|
| 15 | +SYM_CODE_START(efi_enter_kernel) |
---|
21 | 16 | /* |
---|
22 | | - * We arrive here from the EFI boot manager with: |
---|
23 | | - * |
---|
24 | | - * * CPU in little-endian mode |
---|
25 | | - * * MMU on with identity-mapped RAM |
---|
26 | | - * * Icache and Dcache on |
---|
27 | | - * |
---|
28 | | - * We will most likely be running from some place other than where |
---|
29 | | - * we want to be. The kernel image wants to be placed at TEXT_OFFSET |
---|
30 | | - * from start of RAM. |
---|
| 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. |
---|
31 | 21 | */ |
---|
32 | | -ENTRY(entry) |
---|
33 | | - /* |
---|
34 | | - * Create a stack frame to save FP/LR with extra space |
---|
35 | | - * for image_addr variable passed to efi_entry(). |
---|
36 | | - */ |
---|
37 | | - stp x29, x30, [sp, #-32]! |
---|
38 | | - mov x29, sp |
---|
| 22 | + ldr w2, =primary_entry_offset |
---|
| 23 | + add x19, x0, x2 // relocated Image entrypoint |
---|
| 24 | + mov x20, x1 // DTB address |
---|
39 | 25 | |
---|
40 | 26 | /* |
---|
41 | | - * Call efi_entry to do the real work. |
---|
42 | | - * x0 and x1 are already set up by firmware. Current runtime |
---|
43 | | - * address of image is calculated and passed via *image_addr. |
---|
44 | | - * |
---|
45 | | - * unsigned long efi_entry(void *handle, |
---|
46 | | - * efi_system_table_t *sys_table, |
---|
47 | | - * unsigned long *image_addr) ; |
---|
48 | | - */ |
---|
49 | | - adr_l x8, _text |
---|
50 | | - add x2, sp, 16 |
---|
51 | | - str x8, [x2] |
---|
52 | | - bl efi_entry |
---|
53 | | - cmn x0, #1 |
---|
54 | | - b.eq efi_load_fail |
---|
55 | | - |
---|
56 | | - /* |
---|
57 | | - * efi_entry() will have copied the kernel image if necessary and we |
---|
58 | | - * return here with device tree address in x0 and the kernel entry |
---|
59 | | - * point stored at *image_addr. Save those values in registers which |
---|
60 | | - * are callee preserved. |
---|
61 | | - */ |
---|
62 | | - mov x20, x0 // DTB address |
---|
63 | | - ldr x0, [sp, #16] // relocated _text address |
---|
64 | | - ldr w21, =stext_offset |
---|
65 | | - add x21, x0, x21 |
---|
66 | | - |
---|
67 | | - /* |
---|
68 | | - * Calculate size of the kernel Image (same for original and copy). |
---|
69 | | - */ |
---|
70 | | - adr_l x1, _text |
---|
71 | | - adr_l x2, _edata |
---|
72 | | - sub x1, x2, x1 |
---|
73 | | - |
---|
74 | | - /* |
---|
75 | | - * Flush the copied Image to the PoC, and ensure it is not shadowed by |
---|
| 27 | + * Clean the copied Image to the PoC, and ensure it is not shadowed by |
---|
76 | 28 | * stale icache entries from before relocation. |
---|
77 | 29 | */ |
---|
78 | | - bl __flush_dcache_area |
---|
| 30 | + ldr w1, =kernel_size |
---|
| 31 | + bl __clean_dcache_area_poc |
---|
79 | 32 | ic ialluis |
---|
80 | 33 | |
---|
81 | 34 | /* |
---|
82 | | - * Ensure that the rest of this function (in the original Image) is |
---|
83 | | - * visible when the caches are disabled. The I-cache can't have stale |
---|
84 | | - * entries for the VA range of the current image, so no maintenance is |
---|
85 | | - * necessary. |
---|
| 35 | + * Clean the remainder of this routine to the PoC |
---|
| 36 | + * so that we can safely disable the MMU and caches. |
---|
86 | 37 | */ |
---|
87 | | - adr x0, entry |
---|
88 | | - adr x1, entry_end |
---|
89 | | - sub x1, x1, x0 |
---|
90 | | - bl __flush_dcache_area |
---|
91 | | - |
---|
| 38 | + adr x0, 0f |
---|
| 39 | + ldr w1, 3f |
---|
| 40 | + bl __clean_dcache_area_poc |
---|
| 41 | +0: |
---|
92 | 42 | /* Turn off Dcache and MMU */ |
---|
93 | 43 | mrs x0, CurrentEL |
---|
94 | 44 | cmp x0, #CurrentEL_EL2 |
---|
.. | .. |
---|
113 | 63 | mov x1, xzr |
---|
114 | 64 | mov x2, xzr |
---|
115 | 65 | mov x3, xzr |
---|
116 | | - br x21 |
---|
117 | | - |
---|
118 | | -efi_load_fail: |
---|
119 | | - mov x0, #EFI_LOAD_ERROR |
---|
120 | | - ldp x29, x30, [sp], #32 |
---|
121 | | - ret |
---|
122 | | - |
---|
123 | | -entry_end: |
---|
124 | | -ENDPROC(entry) |
---|
| 66 | + br x19 |
---|
| 67 | +SYM_CODE_END(efi_enter_kernel) |
---|
| 68 | +3: .long . - 0b |
---|