From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] hw/arm/armv7m: Disable reentrancy guard for v7m_sysreg_ns_ops MRs
Date: Fri, 21 Nov 2025 08:12:42 +0100 [thread overview]
Message-ID: <34ec72d0-dafa-418c-9372-d5d033a93c0d@linaro.org> (raw)
In-Reply-To: <20251114155304.2662414-1-peter.maydell@linaro.org>
On 14/11/25 16:53, Peter Maydell wrote:
> For M-profile cores which support TrustZone, there are some memory
> areas which are "NS aliases" -- a Secure access to these addresses
> really performs an NS access to a different part of the device. We
> implement these using MemoryRegionOps read and write functions which
> pass the access on with adjusted attributes using
> memory_region_dispatch_read() and memory_region_dispatch_write().
>
> Since the MR we are dispatching to is owned by the same device that
> owns the NS-alias MR (the TYPE_ARMV7M container object), this trips
> the reentrancy-guard that is applied by access_with_adjusted_size().
>
> Mark the NS alias MemoryRegions as disable_reentrancy_guard; this is
> safe because v7m_sysreg_ns_read() and v7m_sysreg_ns_write() do not
> touch any of the device's state. (Any further reentrancy attempts by
> the underlying MR will still be caught.)
>
> Without this fix, an attempt to read from an address like 0xe002e010,
> which is a register in the NS systick alias, will fail and provoke
>
> qemu-system-arm: warning: Blocked re-entrant IO on MemoryRegion: v7m_systick at addr: 0x0
>
> We didn't notice this earlier because almost all code accesses
> the registers and systick via the non-alias addresses; the NS
> aliases are only need for the rarer case of Secure code that needs
> to manage the NS timer or system state on behalf of NS code.
>
> Note that although the v7m_systick_ops read and write functions
> also call memory_region_dispatch_{read,write}, this MR does not
> need to have the reentrancy-guard disabled because the underlying
> MR that it forwards to is owned by a different device (the
> TYPE_SYSTICK timer device).
>
> Reported via a stackoverflow question:
> https://stackoverflow.com/questions/79808107/what-this-error-is-even-about-qemu-system-arm-warning-blocked-re-entrant-io
>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/arm/armv7m.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
prev parent reply other threads:[~2025-11-21 7:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 15:53 [PATCH] hw/arm/armv7m: Disable reentrancy guard for v7m_sysreg_ns_ops MRs Peter Maydell
2025-11-21 7:12 ` Philippe Mathieu-Daudé [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=34ec72d0-dafa-418c-9372-d5d033a93c0d@linaro.org \
--to=philmd@linaro.org \
--cc=peter.maydell@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 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).