Skip to contentSkip to conversation

armv8: cache_v8: Fix pgtables setup when MMU is already enabled

PATCH In review Pali Rohár 4 participants 4 messages Sep 14, 2022 – Oct 7, 2022 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 armv8: cache_v8: Fix pgtables setup when MMU is already enabled

When MMU is already enabled then dcache_enable() does not call mmu_setup() and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour() function then U-Boot crashes with error message:

Emergency page table not setup.

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable() function near condition for mmu_setup().

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

---
 arch/arm/cpu/armv8/cache_v8.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/cache_v8.c +4 -0
index e4736e564366..2a226fd0633d 100644
@@ -503,6 +503,10 @@ void dcache_enable(void)
 		mmu_setup();
 	}
 
+	/* Set up page tables only once (it is done also by mmu_setup()) */
+	if (!gd->arch.tlb_fillptr)
+		setup_all_pgtables();
+
 	set_sctlr(get_sctlr() | CR_C);
 }
 
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Wed, 14 Sep 2022 13:37:46 +0200 Pali Rohár <[email protected]> wrote:

When MMU is already enabled then dcache_enable() does not call mmu_setup() and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour() function then U-Boot crashes with error message:

Emergency page table not setup.

Quoted 7 lines

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable() function near condition for mmu_setup().

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

Reviewed-by on v1 1/1
#2 lore raw
In reply to Pali Rohár
Quoted 8 lines · Pali Rohár

When MMU is already enabled then dcache_enable() does not call mmu_setup() and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour() function then U-Boot crashes with error message:

Emergency page table not setup.

Quoted 7 lines

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable() function near condition for mmu_setup().

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

Thanks,
Stefan

Quoted 9 lines
---
  arch/arm/cpu/armv8/cache_v8.c | 4 ++++
  1 file changed, 4 insertions(+)
arch/arm/cpu/armv8/cache_v8.c +0 -0
index e4736e564366..2a226fd0633d 100644

arch/arm/cpu/armv8/cache_v8.c void dcache_enable(void) · line 512

Quoted 10 lines
arch/arm/cpu/armv8/cache_v8.c +4 -0
@@ -503,6 +503,10 @@ void dcache_enable(void)
  		mmu_setup();
  	}
 
+	/* Set up page tables only once (it is done also by mmu_setup()) */
+	if (!gd->arch.tlb_fillptr)
+		setup_all_pgtables();
+
  	set_sctlr(get_sctlr() | CR_C);
  }
 

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
#3 lore raw
In reply to Pali Rohár
Quoted 11 lines · Pali Rohár

When MMU is already enabled then dcache_enable() does not call mmu_setup() and so setup_all_pgtables() is also never called.

In this situation when some driver calls mmu_set_region_dcache_behaviour() function then U-Boot crashes with error message:

Emergency page table not setup.

Fix this issue by explicitly calling setup_all_pgtables() in dcache_enable() function near condition for mmu_setup().

Quoted 6 lines

This change fixes chainloading U-Boot from U-Boot on Turris Mox board which uses mvneta ethernet driver which calls mmu_set_region_dcache_behaviour().

Applied to u-boot/master, thanks!

Signature · 1 line
Tom