Skip to content

Commit 974c8e4

Browse files
Marc Zyngierctmarinas
authored andcommitted
arm64: fix el2_setup check of CurrentEL
The CurrentEL system register reports the Current Exception Level of the CPU. It doesn't say anything about the stack handling, and yet we compare it to PSR_MODE_EL2t and PSR_MODE_EL2h. It works by chance because PSR_MODE_EL2t happens to match the right bits, but that's otherwise a very bad idea. Just check for the EL value instead. Signed-off-by: Marc Zyngier <[email protected]> [[email protected]: fixed arch/arm64/kernel/efi-entry.S] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 923b8f5 commit 974c8e4

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

arch/arm64/include/asm/ptrace.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121

2222
#include <uapi/asm/ptrace.h>
2323

24+
/* Current Exception Level values, as contained in CurrentEL */
25+
#define CurrentEL_EL1 (1 << 2)
26+
#define CurrentEL_EL2 (2 << 2)
27+
2428
/* AArch32-specific ptrace requests */
2529
#define COMPAT_PTRACE_GETREGS 12
2630
#define COMPAT_PTRACE_SETREGS 13

arch/arm64/kernel/efi-entry.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ ENTRY(efi_stub_entry)
7878

7979
/* Turn off Dcache and MMU */
8080
mrs x0, CurrentEL
81-
cmp x0, #PSR_MODE_EL2t
82-
ccmp x0, #PSR_MODE_EL2h, #0x4, ne
81+
cmp x0, #CurrentEL_EL2
8382
b.ne 1f
8483
mrs x0, sctlr_el2
8584
bic x0, x0, #1 << 0 // clear SCTLR.M

arch/arm64/kernel/head.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ ENDPROC(stext)
270270
*/
271271
ENTRY(el2_setup)
272272
mrs x0, CurrentEL
273-
cmp x0, #PSR_MODE_EL2t
274-
ccmp x0, #PSR_MODE_EL2h, #0x4, ne
273+
cmp x0, #CurrentEL_EL2
275274
b.ne 1f
276275
mrs x0, sctlr_el2
277276
CPU_BE( orr x0, x0, #(1 << 25) ) // Set the EE bit for EL2

0 commit comments

Comments
 (0)