qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Mads Ynddal <mads@ynddal.dk>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	 Phil Dennis-Jordan <phil@philjordan.eu>,
	Cameron Esfahani <dirty@apple.com>,
	 Roman Bolshakov <rbolshakov@ddn.com>,
	Alexander Graf <agraf@csgraf.de>,
	Mads Ynddal <m.ynddal@samsung.com>,
	Daniel Gomez <da.gomez@samsung.com>
Subject: Re: [PATCH 2/2] hvf: only update sysreg from owning thread
Date: Fri, 2 May 2025 13:55:48 +0100	[thread overview]
Message-ID: <CAFEAcA8Hgmt_ph1Sv1Sbhvf+CnXRrw1jwE67_uJKFt2AqRFZng@mail.gmail.com> (raw)
In-Reply-To: <20250402135229.28143-3-mads@ynddal.dk>

On Wed, 2 Apr 2025 at 14:52, Mads Ynddal <mads@ynddal.dk> wrote:
>
> From: Mads Ynddal <m.ynddal@samsung.com>
>
> hv_vcpu_set_sys_reg should only be called from the owning thread of the
> vCPU, so to avoid crashes, the call to hvf_update_guest_debug is
> dispatched to the individual threads.
>
> Tested-by: Daniel Gomez <da.gomez@samsung.com>
> Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
> ---
>  accel/hvf/hvf-all.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/accel/hvf/hvf-all.c b/accel/hvf/hvf-all.c
> index d404e01ade..3fc65d6b23 100644
> --- a/accel/hvf/hvf-all.c
> +++ b/accel/hvf/hvf-all.c
> @@ -58,8 +58,13 @@ int hvf_sw_breakpoints_active(CPUState *cpu)
>      return !QTAILQ_EMPTY(&hvf_state->hvf_sw_breakpoints);
>  }
>
> -int hvf_update_guest_debug(CPUState *cpu)
> +static void do_hvf_update_guest_debug(CPUState *cpu, run_on_cpu_data arg)
>  {
>      hvf_arch_update_guest_debug(cpu);
> +}
> +
> +int hvf_update_guest_debug(CPUState *cpu)
> +{
> +    run_on_cpu(cpu, do_hvf_update_guest_debug, RUN_ON_CPU_NULL);
>      return 0;
>  }

run_on_cpu() implicitly drops the BQL, so it is a potential
really nasty footgun in this kind of situation where callers
to update_guest_debug aren't expecting the BQL to be dropped
on them. But we already use run_on_cpu() in the KVM equivalent
kvm_update_guest_debug(), so presumably it's also OK here...

-- PMM


  parent reply	other threads:[~2025-05-02 12:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02 13:52 [PATCH 0/2] Fix GDB support for macOS hvf Mads Ynddal
2025-04-02 13:52 ` [PATCH 1/2] hvf: avoid repeatedly setting trap debug for each cpu Mads Ynddal
2025-04-02 18:15   ` Daniel Gomez
2025-04-14  9:20   ` Alex Bennée
2025-04-02 13:52 ` [PATCH 2/2] hvf: only update sysreg from owning thread Mads Ynddal
2025-04-14  9:11   ` Alex Bennée
2025-05-02 12:55   ` Peter Maydell [this message]
2025-04-14  8:07 ` [PATCH 0/2] Fix GDB support for macOS hvf Mads Ynddal
2025-05-02 12:57 ` 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=CAFEAcA8Hgmt_ph1Sv1Sbhvf+CnXRrw1jwE67_uJKFt2AqRFZng@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=agraf@csgraf.de \
    --cc=da.gomez@samsung.com \
    --cc=dirty@apple.com \
    --cc=m.ynddal@samsung.com \
    --cc=mads@ynddal.dk \
    --cc=phil@philjordan.eu \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rbolshakov@ddn.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).