From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, qemu-riscv@nongnu.org,
qemu-s390x@nongnu.org,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Peter Xu" <peterx@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Chinmay Rath" <rathc@linux.ibm.com>,
"Glenn Miles" <milesg@linux.ibm.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Chao Liu" <chao.liu.zevorn@gmail.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"David Hildenbrand" <david@kernel.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Artyom Tarasenko" <atar4qemu@gmail.com>
Subject: Re: [PATCH 14/17] hw/core: Implement new cpu_translate_for_debug()
Date: Sun, 19 Apr 2026 00:25:27 +0200 [thread overview]
Message-ID: <5f593c69-e7b2-4df9-9a8f-342ba767c018@linaro.org> (raw)
In-Reply-To: <20260417173105.1648172-15-peter.maydell@linaro.org>
On 17/4/26 19:31, Peter Maydell wrote:
> In cpu_memory_rw_debug() we need to do a virtual-to-physical address
> translation for debug access. Currently we assume that the
> translation is valid for an entire guest page, but this may not be
> true if the target implements some protection regions that have
> sub-page granularity. (Currently the only such target is the Arm
> CPUs when using an MPU, as in R-profile and M-profile.)
>
> For TCG's emulated accesses, we handle sub-page granularity by the
> CPU filling in the lg_page_size field of the CPUTLBEntryFull struct
> to tell us how large the region covered by the result is. But we
> didn't extend this to the debug-access code path, with the result
> that debug accesses might incorrectly fail because they are looking
> at the mapping for the address rounded down to a page boundary.
>
> Provide a cpu_translate_for_debug() function which reports to the
> caller not just the physical address and attributes of the
> translation but also the lg_page_size for which it is valid. The
> fallback implementation calls cpu_get_phys_addr_attrs_debug() and
> assumes target-page-sized validity.
>
> NB: the "return true on valid access, false on failure" follows
> the same convention as TCGCPUOps::tlb_fill_align() (though it
> is the opposite of what we use in some other places, e.g.
> in target/arm's get_phys_addr_* functions).
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/core/cpu-system.c | 32 ++++++++++++++++++++++++++++++++
> include/hw/core/cpu.h | 32 ++++++++++++++++++++++++++++++++
> include/hw/core/sysemu-cpu-ops.h | 27 +++++++++++++++++++++++++--
> 3 files changed, 89 insertions(+), 2 deletions(-)
> + /**
> + * @translate_for_debug: Callback for translating a virtual address into
> + * a physical address for debug purposes.
> + * The implementation should fill in @result with the physical address,
> + * transaction attributes, and log2 of the size of the aligned block of
> + * memory that the translation is valid for.
> + * This must be able to handle a non-page-aligned address, and will
> + * return the physical address corresponding to that address.
> + * The attributes must include the debug flag being set.
> + * Returns false on translation failure; on success returns true and
> + * fills in @result.
> + *
> + * This is the preferred method to implement for new CPUs.
> + */
> + bool (*translate_for_debug)(CPUState *cpu, vaddr addr,
> + TranslateForDebugResult *result);
Since this call shouldn't modify the internal CPU state, could
we use 'const CPUState *cpu'? Maybe not possible due to callees
still taking non-const. Regardless:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2026-04-18 22:25 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 17:30 [PATCH 00/17] Handle sub-page granularity in cpu_memory_rw_debug() Peter Maydell
2026-04-17 17:30 ` [PATCH 01/17] target/riscv: Make get_phys_page_debug handle non-page-aligned addrs Peter Maydell
2026-04-18 3:43 ` Chao Liu
2026-04-18 22:18 ` Philippe Mathieu-Daudé
2026-04-23 2:13 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 02/17] target/alpha: " Peter Maydell
2026-04-23 2:14 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 03/17] target/microblaze: Make get_phys_page_attrs_debug " Peter Maydell
2026-04-18 22:18 ` Philippe Mathieu-Daudé
2026-04-23 2:24 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 04/17] target/sparc: Make get_phys_page_debug " Peter Maydell
2026-04-23 2:26 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 05/17] target/x86: Make get_phys_page_attrs_debug " Peter Maydell
2026-04-23 2:27 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 06/17] target/s390x: Make get_phys_page_debug " Peter Maydell
2026-04-21 11:04 ` Ilya Leoshkevich
2026-04-23 2:29 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 07/17] target/ppc: " Peter Maydell
2026-04-23 2:30 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 08/17] target: Rename get_phys_page_debug to get_phys_addr_debug Peter Maydell
2026-04-18 22:14 ` Philippe Mathieu-Daudé
2026-04-23 2:32 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 09/17] target: Rename cpu_get_phys_page_{,attrs_}debug Peter Maydell
2026-04-18 22:15 ` Philippe Mathieu-Daudé
2026-04-23 2:34 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 10/17] hw/core: Update docs for get_phys_addr_{attrs_,}debug Peter Maydell
2026-04-18 22:16 ` Philippe Mathieu-Daudé
2026-04-23 2:42 ` Richard Henderson
2026-04-17 17:30 ` [PATCH 11/17] target/arm: Rename arm_cpu_get_phys_page() Peter Maydell
2026-04-18 22:16 ` Philippe Mathieu-Daudé
2026-04-17 17:31 ` [PATCH 12/17] monitor: hmp_gva2gpa: Don't page-align cpu_get_phys_addr_debug() arg and return Peter Maydell
2026-04-17 17:46 ` Dr. David Alan Gilbert
2026-04-18 22:16 ` Philippe Mathieu-Daudé
2026-04-17 17:31 ` [PATCH 13/17] plugins/api.c: Trust cpu_get_phys_addr_debug() return address Peter Maydell
2026-04-23 2:44 ` Richard Henderson
2026-04-17 17:31 ` [PATCH 14/17] hw/core: Implement new cpu_translate_for_debug() Peter Maydell
2026-04-18 22:25 ` Philippe Mathieu-Daudé [this message]
2026-04-23 3:05 ` Richard Henderson
2026-04-28 10:42 ` Peter Maydell
2026-04-17 17:31 ` [PATCH 15/17] hw/core: Implement cpu_get_phys_addr_attrs_debug() with cpu_translate_for_debug() Peter Maydell
2026-04-23 3:08 ` Richard Henderson
2026-04-28 10:43 ` Peter Maydell
2026-04-17 17:31 ` [PATCH 16/17] target/arm: Implement translate_for_debug Peter Maydell
2026-04-18 22:29 ` Philippe Mathieu-Daudé
2026-04-23 3:12 ` Richard Henderson
2026-04-28 10:26 ` Peter Maydell
2026-04-17 17:31 ` [PATCH 17/17] system/physmem: Use translate_for_debug() in cpu_memory_rw_debug() Peter Maydell
2026-04-18 22:33 ` Philippe Mathieu-Daudé
2026-04-23 3:17 ` Richard Henderson
2026-04-28 10:32 ` 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=5f593c69-e7b2-4df9-9a8f-342ba767c018@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=atar4qemu@gmail.com \
--cc=chao.liu.zevorn@gmail.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=dave@treblig.org \
--cc=david@kernel.org \
--cc=edgar.iglesias@gmail.com \
--cc=erdnaxe@crans.org \
--cc=iii@linux.ibm.com \
--cc=jiaxun.yang@flygoat.com \
--cc=liwei1518@gmail.com \
--cc=ma.mandourr@gmail.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=milesg@linux.ibm.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=rathc@linux.ibm.com \
--cc=richard.henderson@linaro.org \
--cc=wangyanan55@huawei.com \
--cc=zhao1.liu@intel.com \
--cc=zhiwei_liu@linux.alibaba.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 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.