* [PATCH] ARM64: setupc: drop erroneous cache flush of virt addr 0
@ 2025-09-12 6:51 Ahmad Fatoum
2025-09-12 7:51 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-09-12 6:51 UTC (permalink / raw)
To: barebox; +Cc: Chali Anis, Ahmad Fatoum
From: Chali Anis <chalianis1@gmail.com>
relocate_to_adr copies around executable code and thus needs to
ensure coherence between I$ and D$. When the function was first added,
it didn't maintain cache correctly, because while it did call
arm_early_mmu_cache_flush(), back then that function did not invalidate
I$ after the D$ clean.
This likely went unnoticed, because a comment in relocate_to_adr
suggested that ic ivau is invalidating the I$, but in reality that
instruction did an unconditional invalidation of the single
cache line corresponding to virtual address 0 if it exists.
Back in 2019, sync_caches_for_execution() was introduced, which
correctly invalidates I$ after D$ cleaning, but the invalidation of
address 0 still remained.
On a 64-bit Tegra SoC with barebox running as EFI payload, it was
observed that this instruction was triggering a translation fault[1] at
address 0. The reason behind that is not completely understood, but it's
fixed by removing these two lines that are erroneous anyway, so let's do
that.
[1]: https://esr.arm64.dev/#0x96000147
Fixes: 868df08038a9 ("ARM: aarch64: Add relocation support")
Signed-off-by: Chali Anis <chalianis1@gmail.com>
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
arch/arm/cpu/setupc_64.S | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/arm/cpu/setupc_64.S b/arch/arm/cpu/setupc_64.S
index 2138c2a600fa..fd95187a0422 100644
--- a/arch/arm/cpu/setupc_64.S
+++ b/arch/arm/cpu/setupc_64.S
@@ -63,9 +63,6 @@ ENTRY(relocate_to_adr)
bl sync_caches_for_execution
- mov x0,#0
- ic ivau, x0 /* flush icache */
-
adr_l x0, 1f
sub x0, x0, x20
add x0, x0, x21
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ARM64: setupc: drop erroneous cache flush of virt addr 0
2025-09-12 6:51 [PATCH] ARM64: setupc: drop erroneous cache flush of virt addr 0 Ahmad Fatoum
@ 2025-09-12 7:51 ` Sascha Hauer
0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2025-09-12 7:51 UTC (permalink / raw)
To: barebox, Ahmad Fatoum; +Cc: Chali Anis
On Fri, 12 Sep 2025 08:51:04 +0200, Ahmad Fatoum wrote:
> relocate_to_adr copies around executable code and thus needs to
> ensure coherence between I$ and D$. When the function was first added,
> it didn't maintain cache correctly, because while it did call
> arm_early_mmu_cache_flush(), back then that function did not invalidate
> I$ after the D$ clean.
>
> This likely went unnoticed, because a comment in relocate_to_adr
> suggested that ic ivau is invalidating the I$, but in reality that
> instruction did an unconditional invalidation of the single
> cache line corresponding to virtual address 0 if it exists.
>
> [...]
Applied, thanks!
[1/1] ARM64: setupc: drop erroneous cache flush of virt addr 0
https://git.pengutronix.de/cgit/barebox/commit/?id=cca8ff2e8810 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-12 7:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-12 6:51 [PATCH] ARM64: setupc: drop erroneous cache flush of virt addr 0 Ahmad Fatoum
2025-09-12 7:51 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox