Skip to contentSkip to conversation

armv8: Flush dcache before switching to EL2

PATCH New York Sun 3 participants 3 messages Mar 31, 2014 – Apr 7, 2014 Arm (32-bit)

lore
Share & tools
lore

York Sun

author
#0 lore raw

PATCH 1/1 armv8: Flush dcache before switching to EL2

For ARMv8, U-boot has been running at EL3 with cache and MMU enabled. Without proper setup for EL2, cache and MMU are both disabled (out of reset). Before switching, we need to flush the dcache to make sure the data is in the main memory.

---
 arch/arm/lib/bootm.c |    1 +
 1 file changed, 1 insertion(+)
arch/arm/lib/bootm.c +1 -0
index a8295bf..9782ddb 100644
@@ -199,6 +199,7 @@ static void do_nonsec_virt_switch(void)
 
 #ifdef CONFIG_ARM64
 	smp_kick_all_cpus();
+	flush_dcache_all();	/* flush cache before swtiching to EL2 */
 	armv8_switch_to_el2();
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
 	armv8_switch_to_el1();
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 armv8: Flush dcache before switching to EL2

Quoted 34 lines

-----Original Messages-----
From: "York Sun" <[email protected]>
Sent Time: 2014-04-01 05:40:32 (Tuesday)
To: albert.u.boot at aribaud.net
Cc: u-boot at lists.denx.de, "York Sun" <[email protected]>
Subject: [U-Boot] [PATCH] armv8: Flush dcache before switching to EL2

For ARMv8, U-boot has been running at EL3 with cache and MMU enabled. Without proper setup for EL2, cache and MMU are both disabled (out of reset). Before switching, we need to flush the dcache to make sure the data is in the main memory.

---
 arch/arm/lib/bootm.c |    1 +
 1 file changed, 1 insertion(+)
arch/arm/lib/bootm.c +1 -0
index a8295bf..9782ddb 100644
@@ -199,6 +199,7 @@ static void do_nonsec_virt_switch(void)
 
 #ifdef CONFIG_ARM64
 	smp_kick_all_cpus();
+	flush_dcache_all();	/* flush cache before swtiching to EL2 */
 	armv8_switch_to_el2();
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
 	armv8_switch_to_el1();
Signature · 1 line
1.7.9.5

fine!

#2 lore raw

PATCH 1/1 armv8: Flush dcache before switching to EL2

In reply to York Sun

Hi York,

Quoted 15 lines · York Sun

For ARMv8, U-boot has been running at EL3 with cache and MMU enabled. Without proper setup for EL2, cache and MMU are both disabled (out of reset). Before switching, we need to flush the dcache to make sure the data is in the main memory.

---
 arch/arm/lib/bootm.c |    1 +
 1 file changed, 1 insertion(+)
arch/arm/lib/bootm.c +0 -0
index a8295bf..9782ddb 100644

arch/arm/lib/bootm.c static void do_nonsec_virt_switch(void) · line 205

Quoted 7 lines
arch/arm/lib/bootm.c +1 -0
@@ -199,6 +199,7 @@ static void do_nonsec_virt_switch(void)
 
 #ifdef CONFIG_ARM64
 	smp_kick_all_cpus();
+	flush_dcache_all();	/* flush cache before swtiching to EL2 */
 	armv8_switch_to_el2();
 #ifdef CONFIG_ARMV8_SWITCH_TO_EL1
 	armv8_switch_to_el1();

Applied as a bugfix to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.