From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
qemu-arm@nongnu.org (open list:ARM TCG CPUs)
Subject: Re: [RFC PATCH] target/arm: hold bql when SEV sets the event_register
Date: Mon, 12 Oct 2026 15:52:23 +0100 [thread overview]
Message-ID: <87fqybx97c.fsf@draig.linaro.org> (raw)
In-Reply-To: <20261012134840.1051969-1-alex.bennee@linaro.org> ("Alex Bennée"'s message of "Mon, 12 Oct 2026 14:48:40 +0100")
Alex Bennée <alex.bennee@linaro.org> writes:
> There is a race in qemu_process_cpu_events and sleeping on halt_cond
> where we can miss the setting of the event_register which would cause
> arm_cpu_has_work to report we shouldn't sleep. As by definition the
> bql has to be held when we go to sleep against halt_cond guard the
> kicking of the cpus by the SEV helper with the BQL to ensure things
> are properly serialised.
>
> The other places that set event_register are fine as they are either
> in the same vCPU context or are already serialised by the BQL.
>
> Also use qemu_cond_wait_bql like the other halt_cond users.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4660
This also fixes 4670
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> system/cpus.c | 2 +-
> target/arm/tcg/op_helper.c | 3 +++
> 2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/system/cpus.c b/system/cpus.c
> index e11a5aab6a6..985732217fb 100644
> --- a/system/cpus.c
> +++ b/system/cpus.c
> @@ -412,7 +412,7 @@ void qemu_process_cpu_events(CPUState *cpu)
> slept = true;
> qemu_plugin_vcpu_idle_cb(cpu);
> }
> - qemu_cond_wait(cpu->halt_cond, &bql);
> + qemu_cond_wait_bql(cpu->halt_cond);
> }
> if (slept) {
> qemu_plugin_vcpu_resume_cb(cpu);
> diff --git a/target/arm/tcg/op_helper.c b/target/arm/tcg/op_helper.c
> index af56eff9f18..7c1fdab79d7 100644
> --- a/target/arm/tcg/op_helper.c
> +++ b/target/arm/tcg/op_helper.c
> @@ -471,6 +471,9 @@ void HELPER(wfit)(CPUARMState *env, uint32_t rd)
> void HELPER(sev)(CPUARMState *env)
> {
> CPUState *cs = env_cpu(env);
> +
> + BQL_LOCK_GUARD();
> +
> CPU_FOREACH(cs) {
> ARMCPU *target_cpu = ARM_CPU(cs);
> target_cpu->env.event_register = true;
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2026-10-12 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 13:48 [RFC PATCH] target/arm: hold bql when SEV sets the event_register Alex Bennée
2026-10-12 14:52 ` Alex Bennée [this message]
2026-10-12 16:27 ` Paolo Bonzini
2026-10-12 18:47 ` Alex Bennée
2026-10-13 5:13 ` Paolo Bonzini
2026-10-13 11:41 ` Peter Maydell
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=87fqybx97c.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.