All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zenghui Yu <zenghui.yu@linux.dev>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, agraf@csgraf.de,
	mads@ynddal.dk, peter.maydell@linaro.org
Subject: Re: [PATCH v2 1/2] hvf: arm: Add permission check in GIC sysreg handlers
Date: Tue, 15 Jul 2025 23:40:49 +0800	[thread overview]
Message-ID: <ea30d545-d261-4cac-9f8f-c7397cd0560d@linux.dev> (raw)
In-Reply-To: <7a34c735-3306-4028-bec9-f34b4271a543@linaro.org>

Hi Philippe,

On 2025/7/15 04:04, Philippe Mathieu-Daudé wrote:
> On 14/7/25 18:01, Zenghui Yu wrote:
> > Quoting Peter Maydell:
> >
> > " hvf_sysreg_read_cp() and hvf_sysreg_write_cp() do not check the .access
> >   field of the ARMCPRegInfo to ensure that they forbid writes to registers
> >   that are marked with a .access field that says they're read-only (and
> >   ditto reads to write-only registers). "
> >
> > Before we add more registers in GIC sysreg handlers, let's get it correct
> > by adding the .access checks to hvf_sysreg_read_cp() and
> > hvf_sysreg_write_cp(). With that, a sysreg access with invalid permission
> > will result in an UNDEFINED exception.
> >
> > Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> > Signed-off-by: Zenghui Yu <zenghui.yu@linux.dev>
> > ---
> >
> > I hard-code the @current_el parameter of cp_access_ok() to 1 because
> >
> > * we only support EL0 and EL1 in HVF, and
> 
> This might change with this work:
> https://lore.kernel.org/qemu-devel/20250620172751.94231-1-philmd@linaro.org/
> and plan to leverage M3/M4 for EL2 support:
> https://developer.apple.com/documentation/hypervisor/hv_vm_config_set_el2_enabled(_:_:)

Thanks for the heads-up! I hadn't noticed that and need to have a
further look at both.

An alternative would be using arm_current_el() as the @current_el [1],
plus a cpu_synchronize_state() before cp_access_ok() to synchronize
env->pstate from HVF. I'm not sure if it works for the new split-accel.

P.S., there is another arm_current_el() (in hvf.c, pmswinc_write()/
pmu_counter_enabled()) for which we haven't called
cpu_synchronize_state() to synchronize env->pstate. Is it wrong?

Probably we can do an overall cpu_synchronize_state() on every "handle
VMEXIT", to fix at least the above issue, which however definitely hurts
the performance.. What do you think?

[1] https://lore.kernel.org/r/d9c8d200-4453-48d7-b14a-8e15a7cf6602@linux.dev

Thanks,
Zenghui


  reply	other threads:[~2025-07-15 16:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-14 16:01 [PATCH v2 0/2] hvf: arm: two small GIC sysreg emulation fixes Zenghui Yu
2025-07-14 16:01 ` [PATCH v2 1/2] hvf: arm: Add permission check in GIC sysreg handlers Zenghui Yu
2025-07-14 20:04   ` Philippe Mathieu-Daudé
2025-07-15 15:40     ` Zenghui Yu [this message]
2025-07-21 10:19     ` Peter Maydell
2025-07-21 10:28       ` Mohamed Mediouni
2025-07-14 16:01 ` [PATCH v2 2/2] hvf: arm: Emulate ICC_RPR_EL1 accesses properly Zenghui Yu
2025-07-14 19:59   ` Philippe Mathieu-Daudé
2025-07-21 10:20 ` [PATCH v2 0/2] hvf: arm: two small GIC sysreg emulation fixes 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=ea30d545-d261-4cac-9f8f-c7397cd0560d@linux.dev \
    --to=zenghui.yu@linux.dev \
    --cc=agraf@csgraf.de \
    --cc=mads@ynddal.dk \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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.