From: Richard Henderson <richard.henderson@linaro.org>
To: Xiong Nandi <xndchn@gmail.com>, qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [PATCH] system/physmem: Fix cpu_memory_rw_debug for armv7m MPU
Date: Fri, 22 Nov 2024 14:32:12 -0600 [thread overview]
Message-ID: <4d3f8a83-7c03-4b48-9a84-d99b88b0d47c@linaro.org> (raw)
In-Reply-To: <20241120151515.56884-2-xndchn@gmail.com>
On 11/20/24 09:15, Xiong Nandi wrote:
> The actual page size (region size for MPU) of armv7m may
> smaller than TARGET_PAGE_SIZE (2^5 vs 2^10). So we should
> use the actual virtual address to get the phys page address.
>
> Signed-off-by: Xiong Nandi <xndchn@gmail.com>
> ---
> system/physmem.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/system/physmem.c b/system/physmem.c
> index dc1db3a384..a76b305130 100644
> --- a/system/physmem.c
> +++ b/system/physmem.c
> @@ -3564,11 +3564,12 @@ int cpu_memory_rw_debug(CPUState *cpu, vaddr addr,
> MemTxResult res;
>
> page = addr & TARGET_PAGE_MASK;
> - phys_addr = cpu_get_phys_page_attrs_debug(cpu, page, &attrs);
> + phys_addr = cpu_get_phys_page_attrs_debug(cpu, addr, &attrs);
> asidx = cpu_asidx_from_attrs(cpu, attrs);
> /* if no physical page mapped, return an error */
> if (phys_addr == -1)
> return -1;
> + phys_addr &= TARGET_PAGE_MASK;
> l = (page + TARGET_PAGE_SIZE) - addr;
> if (l > len)
> l = len;
So... I guess this might accidentally work, but L is definitely incorrect under the
circumstances. So we could easily be exchanging one set of bugs for another.
We really need to be returning the range of addresses under which the address translation
is valid. One solution could be passing in 'l = len, &l' to be modified so that (addr, l)
translates to (phys_addr, l) after the call; iterate for sum l < len as we're currently doing.
r~
next prev parent reply other threads:[~2024-11-22 20:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 15:15 [PATCH] system/physmem: Fix cpu_memory_rw_debug for armv7m MPU Xiong Nandi
2024-11-20 15:15 ` Xiong Nandi
2024-11-22 20:32 ` Richard Henderson [this message]
2024-11-24 4:30 ` xndcn
2024-11-24 21:23 ` Richard Henderson
2024-11-25 2:50 ` xndcn
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=4d3f8a83-7c03-4b48-9a84-d99b88b0d47c@linaro.org \
--to=richard.henderson@linaro.org \
--cc=david@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=xndchn@gmail.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).