mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Chali Anis <chalianis1@gmail.com>, Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] ARM64: setupc: drop erroneous cache flush of virt addr 0
Date: Fri, 12 Sep 2025 08:51:04 +0200	[thread overview]
Message-ID: <20250912065105.2443411-1-a.fatoum@barebox.org> (raw)

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




             reply	other threads:[~2025-09-12  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12  6:51 Ahmad Fatoum [this message]
2025-09-12  7:51 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250912065105.2443411-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    --cc=chalianis1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox