Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 1 | From 545f6950ae4dc55b4974986aa9629adb16eaf4e1 Mon Sep 17 00:00:00 2001 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 2 | From: Jaxson Han <jaxson.han@arm.com> |
| 3 | Date: Tue, 25 May 2021 07:25:00 +0100 |
| 4 | Subject: [PATCH] aarch64: Rename labels and prepare for lower EL booting |
| 5 | |
| 6 | Prepare for booting from lower EL. Rename *_el3 relavant labels with |
| 7 | *_el_max and *_no_el3 with *_keep_el. Since the original _no_el3 means |
| 8 | "We neither do init sequence at this highest EL nor drop to lower EL |
| 9 | when entering to kernel", we rename it with _keep_el to make it more |
| 10 | clear for lower EL initialisation. |
| 11 | |
| 12 | Upstream-Status: Pending |
| 13 | Signed-off-by: Jaxson Han <jaxson.han@arm.com> |
| 14 | --- |
| 15 | arch/aarch64/boot.S | 28 ++++++++++++++++++++-------- |
| 16 | arch/aarch64/psci.S | 9 +++++---- |
| 17 | arch/aarch64/spin.S | 4 ++-- |
| 18 | 3 files changed, 27 insertions(+), 14 deletions(-) |
| 19 | |
| 20 | diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 21 | index d682ba5..fab694e 100644 |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 22 | --- a/arch/aarch64/boot.S |
| 23 | +++ b/arch/aarch64/boot.S |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 24 | @@ -34,18 +34,30 @@ ASM_FUNC(_start) |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 25 | |
| 26 | /* |
| 27 | * EL3 initialisation |
| 28 | + * Boot sequence |
| 29 | + * If CurrentEL == EL3, then goto EL3 initialisation and drop to |
| 30 | + * lower EL before entering the kernel. |
| 31 | + * Else, no initialisation and keep the current EL before |
| 32 | + * entering the kernel. |
| 33 | */ |
| 34 | mrs x0, CurrentEL |
| 35 | cmp x0, #CURRENTEL_EL3 |
| 36 | - b.eq 1f |
| 37 | + b.eq el3_init |
| 38 | |
| 39 | + /* |
| 40 | + * We stay in the current EL for entering the kernel |
| 41 | + */ |
| 42 | mov w0, #1 |
| 43 | - ldr x1, =flag_no_el3 |
| 44 | + ldr x1, =flag_keep_el |
| 45 | str w0, [x1] |
| 46 | |
| 47 | - b start_no_el3 |
| 48 | + b start_keep_el |
| 49 | |
| 50 | -1: mov x0, #0x30 // RES1 |
| 51 | + /* |
| 52 | + * EL3 initialisation |
| 53 | + */ |
| 54 | +el3_init: |
| 55 | + mov x0, #0x30 // RES1 |
| 56 | orr x0, x0, #(1 << 0) // Non-secure EL1 |
| 57 | orr x0, x0, #(1 << 8) // HVC enable |
| 58 | |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 59 | @@ -145,7 +157,7 @@ ASM_FUNC(_start) |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 60 | |
| 61 | bl gic_secure_init |
| 62 | |
| 63 | - b start_el3 |
| 64 | + b start_el_max |
| 65 | |
| 66 | err_invalid_id: |
| 67 | b . |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 68 | @@ -172,7 +184,7 @@ ASM_FUNC(jump_kernel) |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 69 | bl find_logical_id |
| 70 | bl setup_stack // Reset stack pointer |
| 71 | |
| 72 | - ldr w0, flag_no_el3 |
| 73 | + ldr w0, flag_keep_el |
| 74 | cmp w0, #0 // Prepare Z flag |
| 75 | |
| 76 | mov x0, x20 |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 77 | @@ -181,7 +193,7 @@ ASM_FUNC(jump_kernel) |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 78 | mov x3, x23 |
| 79 | |
| 80 | b.eq 1f |
| 81 | - br x19 // No EL3 |
| 82 | + br x19 // Keep current EL |
| 83 | |
| 84 | 1: mov x4, #SPSR_KERNEL |
| 85 | |
Andrew Geissler | 9347dd4 | 2023-03-03 12:38:41 -0600 | [diff] [blame^] | 86 | @@ -199,5 +211,5 @@ ASM_FUNC(jump_kernel) |
Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 87 | |
| 88 | .data |
| 89 | .align 3 |
| 90 | -flag_no_el3: |
| 91 | +flag_keep_el: |
| 92 | .long 0 |
| 93 | diff --git a/arch/aarch64/psci.S b/arch/aarch64/psci.S |
| 94 | index 8bd224b..7b8919a 100644 |
| 95 | --- a/arch/aarch64/psci.S |
| 96 | +++ b/arch/aarch64/psci.S |
| 97 | @@ -79,7 +79,7 @@ smc_exit: |
| 98 | ldp x18, x19, [sp], #16 |
| 99 | eret |
| 100 | |
| 101 | -ASM_FUNC(start_el3) |
| 102 | +ASM_FUNC(start_el_max) |
| 103 | ldr x0, =vector |
| 104 | bl setup_vector |
| 105 | |
| 106 | @@ -89,10 +89,11 @@ ASM_FUNC(start_el3) |
| 107 | b psci_first_spin |
| 108 | |
| 109 | /* |
| 110 | - * This PSCI implementation requires EL3. Without EL3 we'll only boot the |
| 111 | - * primary cpu, all others will be trapped in an infinite loop. |
| 112 | + * This PSCI implementation requires the highest EL(EL3 or Armv8-R EL2). |
| 113 | + * Without the highest EL, we'll only boot the primary cpu, all othersr |
| 114 | + * will be trapped in an infinite loop. |
| 115 | */ |
| 116 | -ASM_FUNC(start_no_el3) |
| 117 | +ASM_FUNC(start_keep_el) |
| 118 | cpuid x0, x1 |
| 119 | bl find_logical_id |
| 120 | cbz x0, psci_first_spin |
| 121 | diff --git a/arch/aarch64/spin.S b/arch/aarch64/spin.S |
| 122 | index 1ea1c0b..bfb1d47 100644 |
| 123 | --- a/arch/aarch64/spin.S |
| 124 | +++ b/arch/aarch64/spin.S |
| 125 | @@ -12,8 +12,8 @@ |
| 126 | |
| 127 | .text |
| 128 | |
| 129 | -ASM_FUNC(start_el3) |
| 130 | -ASM_FUNC(start_no_el3) |
| 131 | +ASM_FUNC(start_el_max) |
| 132 | +ASM_FUNC(start_keep_el) |
| 133 | cpuid x0, x1 |
| 134 | bl find_logical_id |
| 135 | |