Skip to contentSkip to conversation

arm64: Make sure SPsel is always set

PATCH New Will Deacon 2 participants 2 messages Sep 26, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: Make sure SPsel is always set

From: Marc Zyngier <[email protected]>

When the kernel is entered at EL2 on an ARMv8.0 system, we construct the EL1 pstate and make sure this uses the the EL1 stack pointer (we perform an exception return to EL1h).

But if the kernel is either entered at EL1 or stays at EL2 (because we're on a VHE-capable system), we fail to set SPsel, and use whatever stack selection the higher exception level has choosen for us.

Let's not take any chance, and make sure that SPsel is set to one before we decide the mode we're going to run in.

---
 arch/arm64/kernel/head.S | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/kernel/head.S +1 -0
index 7434ec0c7a27..0b243ecaf7ac 100644
@@ -384,6 +384,7 @@ ENTRY(kimage_vaddr)
  * booted in EL1 or EL2 respectively.
  */
 ENTRY(el2_setup)
+	msr	SPsel, #1			// We want to use SP_EL{1,2}
 	mrs	x0, CurrentEL
 	cmp	x0, #CurrentEL_EL2
 	b.eq	1f
Signature · 1 line
2.1.4
maintainer Applied
#1 lore raw

PATCH 1/1 arm64: Make sure SPsel is always set

Quoted 10 lines · Will Deacon

From: Marc Zyngier <[email protected]>

When the kernel is entered at EL2 on an ARMv8.0 system, we construct the EL1 pstate and make sure this uses the the EL1 stack pointer (we perform an exception return to EL1h).

But if the kernel is either entered at EL1 or stays at EL2 (because we're on a VHE-capable system), we fail to set SPsel, and use whatever stack selection the higher exception level has choosen for us.

Quoted 7 lines

Let's not take any chance, and make sure that SPsel is set to one before we decide the mode we're going to run in.

Queued for 4.14-rc3. Thanks.

Signature · 1 line
Catalin