Skip to contentSkip to conversation

ARMv7: start.S: stay in HYP mode if u-boot is entered in it

PATCH New Andre Przywara 2 participants 2 messages Apr 2, 2013 – Apr 15, 2013 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARMv7: start.S: stay in HYP mode if u-boot is entered in it

The KVM and Xen hypervisors for the Cortex-A15 virtualization implementation need to be entered in HYP mode. Should the primary board firmware already enter HYP mode (Calxeda firmware does that), we should not deliberately drop back to SVC mode.
Since U-boot does not use the MMU, running in HYP mode is just fine.

---
 arch/arm/cpu/armv7/start.S | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/start.S +7 -3
index 36a4c3c..95c8a95 100644
@@ -126,11 +126,15 @@ IRQ_STACK_START_IN:
 reset:
 	bl	save_boot_params
 	/*
-	 * set the cpu to SVC32 mode
+	 * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
+	 * except if in HYP mode already
 	 */
 	mrs	r0, cpsr
-	bic	r0, r0, #0x1f
-	orr	r0, r0, #0xd3
+	and	r1, r0, #0x1f		@ mask mode bits
+	teq	r1, #0x1a		@ test for HYP mode
+	bicne	r0, r0, #0x1f		@ clear all mode bits
+	orrne	r0, r0, #0x13		@ set SVC mode
+	orr	r0, r0, #0xc0		@ disable FIQ and IRQ
 	msr	cpsr,r0
 
 /*
Signature · 1 line
1.7.12.1
#1 lore raw

PATCH 1/1 ARMv7: start.S: stay in HYP mode if u-boot is entered in it

Hi Andre,

Quoted 24 lines · Andre Przywara

The KVM and Xen hypervisors for the Cortex-A15 virtualization implementation need to be entered in HYP mode. Should the primary board firmware already enter HYP mode (Calxeda firmware does that), we should not deliberately drop back to SVC mode.
Since U-boot does not use the MMU, running in HYP mode is just fine.

---
 arch/arm/cpu/armv7/start.S | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm/cpu/armv7/start.S +2 -1
index 36a4c3c..95c8a95 100644
@@ -126,11 +126,15 @@ IRQ_STACK_START_IN:
 reset:
 	bl	save_boot_params
 	/*
-	 * set the cpu to SVC32 mode
+	 * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
+	 * except if in HYP mode already
 	 */
 	mrs	r0, cpsr

arch/arm/cpu/armv7/start.S IRQ_STACK_START_IN: · line 140

Quoted 10 lines
arch/arm/cpu/armv7/start.S +5 -2
-	bic	r0, r0, #0x1f
-	orr	r0, r0, #0xd3
+	and	r1, r0, #0x1f		@ mask mode bits
+	teq	r1, #0x1a		@ test for HYP mode
+	bicne	r0, r0, #0x1f		@ clear all mode bits
+	orrne	r0, r0, #0x13		@ set SVC mode
+	orr	r0, r0, #0xc0		@ disable FIQ and IRQ
 	msr	cpsr,r0
 
 /*

Applied to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.