qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: Rowan Hart <rowanbhart@gmail.com>, qemu-devel@nongnu.org
Cc: "Alexandre Iooss" <erdnaxe@crans.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Mahmoud Mandour" <ma.mandourr@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: Re: [PATCH v3 5/8] Add memory hardware address read/write API
Date: Thu, 22 May 2025 12:46:15 -0700	[thread overview]
Message-ID: <39d3cfdf-10b6-484c-824a-fe84377acb54@linaro.org> (raw)
In-Reply-To: <9e1ebea2-bfbf-4ba6-85fa-c068d627d9e1@gmail.com>

On 5/21/25 8:34 PM, Rowan Hart wrote:
> Well, first I just noticed that I left a debug print in this function!
> So I'll fix that.
> 
>> Reading this patch, and patch 3 (Add address space API), I am not sure
>> AddressSpace is something we want to leak in plugins interface.
>> It is a concept *very* internal to QEMU, and not reflecting directly
>> something concerning the emulated architecture (it is related, but not
>> officially described for it).
>>
>> The same way qemu_plugin_write_memory_vaddr is only valid in the
>> current page table setup, we could assume the same for current address
>> space, and return an error if memory is not mapped with current AS.
>> Eventually, we could read/write a given hwaddr in all existing address
>> spaces (starting with current mapped one), if it makes sense to do
>> this, which I'm not sure about.
>>
>> What are your thoughts on this?
> 
> I definitely see the arguments for not exposing it even as an opaque
> struct, internality not withstanding it also adds some complexity for
> plugin authors.
> 
> My thought with exposing it is kind of twofold. First, there are
> specific address spaces like the secure address space on ARM or I/O
> memory on x86 that plugins might like to access and I think it's easiest
> to facilitate that if we just let them choose which one they want to r/w
> to. Second, I wanted to lean towards being less restrictive now to avoid
> having to go back and remove restrictions later since even though it's
> very internal, it doesn't seem very likely to change.
> 
> That said, if you think it's more trouble than it's worth I'm totally
> fine with just defaulting to writing to the current AS (or to
> cpu-memory, whichever's more reasonable). Your call, just let me know
> which way you think is best for v4 :)

I understand your point, but to the opposite of registers, I think we 
should refrain from exposing all this.
For now, we can just use the current AS.

Later, we could consider to add a new architecture specific parameter 
for that need (being a union, with fields per base architecture). So 
people writing architecture specific plugins can have a solution.

AddressSpace as = {.arm = ADDRESS_SPACE_ARM_SECURE};
qemu_plugin_read_memory_hwaddr_as(addr, data, as);

>> qemu_plugin_translate_vaddr is fine for me.
> I did have a question about this -- one of the test plugins prints out
> vaddr, haddr from qemu_plugin_insn_haddr, and the translated haddr from
> qemu_plugin_translate_vaddr. When running with direct memory mappings in
> a system test, the vaddr = translated haddr, which is correct, but the
> haddr from qemu_plugin_insn_haddr was incorrect (it was 0x7f....f<actual
> address>). Is this expected behavior?
>

qemu_plugin_insn_haddr returns directly a pointer to instruction in 
(host) memory, which is different from hwaddr, thus the void* signature.
Name is pretty confusing though, qemu_plugin_insn_ptr could have been a 
better name.

> Thanks for the feedback!
> 
> 


  reply	other threads:[~2025-05-22 19:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21  9:43 [PATCH v3 0/8] Add additional plugin API functions to read and write memory and registers Rowan Hart
2025-05-21  9:43 ` [PATCH v3 1/8] Expose gdb_write_register function to consumers of gdbstub Rowan Hart
2025-05-21 22:52   ` Pierrick Bouvier
2025-05-22  8:53   ` Manos Pitsidianakis
2025-05-22 11:59   ` Julian Ganz
2025-05-21  9:43 ` [PATCH v3 2/8] Add register write API Rowan Hart
2025-05-21 22:52   ` Pierrick Bouvier
2025-05-22 11:59   ` Julian Ganz
2025-05-22 15:02     ` Rowan Hart
2025-05-22 15:16       ` Julian Ganz
2025-05-22 15:39   ` Alex Bennée
2025-05-22 20:11     ` Rowan Hart
2025-05-21  9:43 ` [PATCH v3 3/8] Add address space API Rowan Hart
2025-05-21  9:43 ` [PATCH v3 4/8] Add memory virtual address write API Rowan Hart
2025-05-21 22:53   ` Pierrick Bouvier
2025-05-21  9:43 ` [PATCH v3 5/8] Add memory hardware address read/write API Rowan Hart
2025-05-21 23:18   ` Pierrick Bouvier
2025-05-22  3:34     ` Rowan Hart
2025-05-22 19:46       ` Pierrick Bouvier [this message]
2025-05-22 11:59   ` Julian Ganz
2025-05-22 19:16     ` Pierrick Bouvier
2025-05-22 21:01       ` Rowan Hart
2025-05-22 22:37         ` Pierrick Bouvier
2025-05-21  9:43 ` [PATCH v3 6/8] Add patcher plugin and test Rowan Hart
2025-05-21  9:43 ` [PATCH v3 7/8] Add hypercalls " Rowan Hart
2025-05-21  9:43 ` [PATCH v3 8/8] Update plugin version and add notes Rowan Hart

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=39d3cfdf-10b6-484c-824a-fe84377acb54@linaro.org \
    --to=pierrick.bouvier@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=eduardo@habkost.net \
    --cc=erdnaxe@crans.org \
    --cc=ma.mandourr@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rowanbhart@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).