public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] armv8: mmu: don't switch to emergency tlb when adding a dynamic mapping
@ 2025-01-08 14:22 Caleb Connolly
  2025-01-08 15:05 ` Marc Zyngier
  0 siblings, 1 reply; 9+ messages in thread
From: Caleb Connolly @ 2025-01-08 14:22 UTC (permalink / raw)
  To: Andre Przywara, Caleb Connolly, Marc Zyngier, Neil Armstrong,
	Patrick Rudolph, Peter Hoyes, Pierre-Clément Tosi,
	Simon Glass, Sumit Garg, Tom Rini
  Cc: u-boot-qcom, Ilias Apalodimas, u-boot

This seems to cause crashes on a bunch of Qualcomm platforms. It's safer
to just update the live table and flush it.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 arch/arm/cpu/armv8/cache_v8.c | 11 ++---------
 arch/arm/include/asm/system.h |  3 +--
 drivers/soc/qcom/cmd-db.c     |  2 +-
 3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index e6be6359c5d9..43051d156122 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -338,9 +338,9 @@ static void map_range(u64 virt, u64 phys, u64 size, int level,
 		size -= next_size;
 	}
 }
 
-void mmu_map_region(phys_addr_t addr, u64 size, bool emergency)
+void mmu_map_region(phys_addr_t addr, u64 size)
 {
 	u64 va_bits;
 	int level = 0;
 	u64 attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | PTE_BLOCK_INNER_SHARE;
@@ -350,19 +350,12 @@ void mmu_map_region(phys_addr_t addr, u64 size, bool emergency)
 	get_tcr(NULL, &va_bits);
 	if (va_bits < 39)
 		level = 1;
 
-	if (emergency)
-		map_range(addr, addr, size, level,
-			  (u64 *)gd->arch.tlb_emerg, attrs);
-
-	/* Switch pagetables while we update the primary one */
-	__asm_switch_ttbr(gd->arch.tlb_emerg);
-
 	map_range(addr, addr, size, level,
 		  (u64 *)gd->arch.tlb_addr, attrs);
 
-	__asm_switch_ttbr(gd->arch.tlb_addr);
+	flush_dcache_range(gd->arch.tlb_addr, gd->arch.tlb_size);
 }
 
 static void add_map(struct mm_region *map)
 {
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 52f6c9b934d7..475ca97c5c82 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -283,11 +283,10 @@ void flush_l3_cache(void);
  * Will be mapped MT_NORMAL & PTE_BLOCK_INNER_SHARE.
  *
  * @start: Start address of the region
  * @size: Size of the region
- * @emerg: Also map the region in the emergency table
  */
-void mmu_map_region(phys_addr_t start, u64 size, bool emerg);
+void mmu_map_region(phys_addr_t start, u64 size);
 void mmu_change_region_attr(phys_addr_t start, size_t size, u64 attrs);
 
 /*
  * smc_call() - issue a secure monitor call
diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
index 67be18e89f4d..4c8bd9abda23 100644
--- a/drivers/soc/qcom/cmd-db.c
+++ b/drivers/soc/qcom/cmd-db.c
@@ -202,9 +202,9 @@ static int cmd_db_bind(struct udevice *dev)
 		return -ENOENT;
 	}
 
 	/* On SM8550/SM8650 and newer SoCs cmd-db might not be mapped */
-	mmu_map_region((phys_addr_t)base, (phys_size_t)size, false);
+	mmu_map_region((phys_addr_t)base, (phys_size_t)size);
 
 	cmd_db_header = base;
 	if (!cmd_db_magic_matches(cmd_db_header)) {
 		log_err("%s: Invalid Command DB Magic\n", __func__);
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-14  8:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 14:22 [PATCH] armv8: mmu: don't switch to emergency tlb when adding a dynamic mapping Caleb Connolly
2025-01-08 15:05 ` Marc Zyngier
2025-01-08 15:19   ` Caleb Connolly
2025-01-08 15:42     ` Marc Zyngier
2025-01-08 16:07       ` Caleb Connolly
2025-01-10 14:20       ` Neil Armstrong
2025-01-08 15:52     ` Pierre-Clément Tosi
2025-01-14  8:38       ` Ahmad Fatoum
2025-01-14  8:55         ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox