Browse Source

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 <marc.zyngier@arm.com>
[catalin.marinas@arm.com: fixed arch/arm64/kernel/efi-entry.S]
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Marc Zyngier 11 years ago
parent
commit
974c8e450b
3 changed files with 6 additions and 4 deletions
  1. 4 0
      arch/arm64/include/asm/ptrace.h
  2. 1 2
      arch/arm64/kernel/efi-entry.S
  3. 1 2
      arch/arm64/kernel/head.S

+ 4 - 0
arch/arm64/include/asm/ptrace.h

@@ -21,6 +21,10 @@
 
 
 #include <uapi/asm/ptrace.h>
 #include <uapi/asm/ptrace.h>
 
 
+/* Current Exception Level values, as contained in CurrentEL */
+#define CurrentEL_EL1		(1 << 2)
+#define CurrentEL_EL2		(2 << 2)
+
 /* AArch32-specific ptrace requests */
 /* AArch32-specific ptrace requests */
 #define COMPAT_PTRACE_GETREGS		12
 #define COMPAT_PTRACE_GETREGS		12
 #define COMPAT_PTRACE_SETREGS		13
 #define COMPAT_PTRACE_SETREGS		13

+ 1 - 2
arch/arm64/kernel/efi-entry.S

@@ -78,8 +78,7 @@ ENTRY(efi_stub_entry)
 
 
 	/* Turn off Dcache and MMU */
 	/* Turn off Dcache and MMU */
 	mrs	x0, CurrentEL
 	mrs	x0, CurrentEL
-	cmp	x0, #PSR_MODE_EL2t
-	ccmp	x0, #PSR_MODE_EL2h, #0x4, ne
+	cmp	x0, #CurrentEL_EL2
 	b.ne	1f
 	b.ne	1f
 	mrs	x0, sctlr_el2
 	mrs	x0, sctlr_el2
 	bic	x0, x0, #1 << 0	// clear SCTLR.M
 	bic	x0, x0, #1 << 0	// clear SCTLR.M

+ 1 - 2
arch/arm64/kernel/head.S

@@ -270,8 +270,7 @@ ENDPROC(stext)
  */
  */
 ENTRY(el2_setup)
 ENTRY(el2_setup)
 	mrs	x0, CurrentEL
 	mrs	x0, CurrentEL
-	cmp	x0, #PSR_MODE_EL2t
-	ccmp	x0, #PSR_MODE_EL2h, #0x4, ne
+	cmp	x0, #CurrentEL_EL2
 	b.ne	1f
 	b.ne	1f
 	mrs	x0, sctlr_el2
 	mrs	x0, sctlr_el2
 CPU_BE(	orr	x0, x0, #(1 << 25)	)	// Set the EE bit for EL2
 CPU_BE(	orr	x0, x0, #(1 << 25)	)	// Set the EE bit for EL2