From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
Joe Komlodi <komlodi@google.com>
Cc: qemu-devel@nongnu.org, slongfield@google.com, pbonzini@redhat.com
Subject: Re: [PATCH 1/1] util/cacheflush: Make first DSB unconditional on aarch64
Date: Wed, 12 Mar 2025 07:32:45 -0700 [thread overview]
Message-ID: <01af330a-d5c0-4d0e-bda2-0a3908dacd6e@linaro.org> (raw)
In-Reply-To: <CAFEAcA8VO4QNU5+9Xk=AiBObXFCRoPF3NUN9m2r1752oi1cShA@mail.gmail.com>
On 3/12/25 07:18, Peter Maydell wrote:
> On Mon, 10 Mar 2025 at 20:36, Joe Komlodi <komlodi@google.com> wrote:
>>
>> On ARM hosts with CTR_EL0.DIC and CTR_EL0.IDC set, this would only cause
>> an ISB to be executed during cache maintenance, which could lead to QEMU
>> executing TBs containing garbage instructions.
>>
>> This seems to be because the ISB finishes executing instructions and
>> flushes the pipeline, but the ISB doesn't guarantee that writes from the
>> executed instructions are committed. If a small enough TB is created, it's
>> possible that the writes setting up the TB aren't committed by the time the
>> TB is executed.
>
> Yes; we need the DSB to ensure that the stores have completed
> and are visible to subsequent icache fills; and then we need
> the ISB to ensure that any instructions that we execute after
> this are done with an instruction fetch that happens after the
> ISB (i.e. the CPU hasn't already speculatively fetched the insn
> before we forced the store to complete).
>
>> This function is intended to be a port of the gcc implementation
>> (https://github.com/gcc-mirror/gcc/blob/85b46d0795ac76bc192cb8f88b646a647acf98c1/libgcc/config/aarch64/sync-cache.c#L67)
>> which makes the first DSB unconditional, so we can fix the synchronization
>> issue by doing that as well.
>>
>> Signed-off-by: Joe Komlodi <komlodi@google.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Richard, are you doing a TCG pullreq for rc0? If not, I can
> put this into target-arm.next.
So far I have nothing queued for tcg. Please go ahead.
r~
prev parent reply other threads:[~2025-03-12 14:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 20:36 [PATCH 0/1] util/cacheflush: Make first DSB unconditional on aarch64 Joe Komlodi
2025-03-10 20:36 ` [PATCH 1/1] " Joe Komlodi
2025-03-12 14:18 ` Peter Maydell
2025-03-12 14:32 ` Richard Henderson [this message]
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=01af330a-d5c0-4d0e-bda2-0a3908dacd6e@linaro.org \
--to=richard.henderson@linaro.org \
--cc=komlodi@google.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=slongfield@google.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;
as well as URLs for NNTP newsgroup(s).