From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Thomas Huth <thuth@redhat.com>,
Anton Johansson <anjo@rev.ng>,
Richard Henderson <richard.henderson@linaro.org>,
Laurent Vivier <lvivier@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Fabiano Rosas <farosas@suse.de>
Subject: Re: [PATCH-for-10.0] system/qtest: Access memory using cpu_physical_memory_rw() API
Date: Tue, 10 Dec 2024 11:31:22 +0100 [thread overview]
Message-ID: <e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org> (raw)
In-Reply-To: <0406480e-29aa-4207-970c-818db3de0291@linaro.org>
On 10/12/24 11:20, Philippe Mathieu-Daudé wrote:
> On 10/12/24 11:03, Peter Maydell wrote:
>> On Wed, 27 Nov 2024 at 19:20, Philippe Mathieu-Daudé
>> <philmd@linaro.org> wrote:
>>>
>>> There is no vCPU within the QTest accelerator (well, they
>>> are stubs doing nothing, see dummy_cpu_thread_fn).
>>> Directly use the cpu_physical_memory_rw() API -- which
>>> amusingly prefixed 'cpu_' does not use vCPU -- to access
>>> memory. This reduces accesses to the global 'first_cpu'.
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> system/qtest.c | 42 ++++++++++++++----------------------------
>>> 1 file changed, 14 insertions(+), 28 deletions(-)
>>>
>>> diff --git a/system/qtest.c b/system/qtest.c
>>> index 12703a20455..a2de9a7d5a4 100644
>>> --- a/system/qtest.c
>>> +++ b/system/qtest.c
>>> @@ -18,6 +18,7 @@
>>> #include "chardev/char-fe.h"
>>> #include "exec/ioport.h"
>>> #include "exec/memory.h"
>>> +#include "exec/cpu-common.h"
>>> #include "exec/tswap.h"
>>> #include "hw/qdev-core.h"
>>> #include "hw/irq.h"
>>> @@ -514,23 +515,19 @@ static void qtest_process_command(CharBackend
>>> *chr, gchar **words)
>>>
>>> if (words[0][5] == 'b') {
>>> uint8_t data = value;
>>> - address_space_write(first_cpu->as, addr,
>>> MEMTXATTRS_UNSPECIFIED,
>>> - &data, 1);
>>> + cpu_physical_memory_write(addr, &data, 1);
>>
>> I'm not a huge fan of this, because cpu_physical_memory_write()
>> is one of those old APIs that it would be nice to see less
>> use of, not more. Ideally anything issuing memory transactions
>> should know what it's issuing them to, i.e. should be using
>> address_space_* functions and passing an AddressSpace.
>
> I totally agree with you. I'm chasing one problem at a time
> starting by first_cpu, and you are already seeing ahead :)
>
> Do you mind posting a documentation patch clarifying the
> cpu_physical_memory_*() methods we want to deprecate?
I was looking for docstring in "exec/cpu-common.h" but now see
commit b7ecba0f6f6 ("docs/devel/loads-stores.rst: Document our
various load and store APIs"):
``cpu_physical_memory_*``
~~~~~~~~~~~~~~~~~~~~~~~~~
For new code they are better avoided:
``cpu_physical_memory_read``
``cpu_physical_memory_write``
``cpu_physical_memory_rw``
>> If you don't want to use first_cpu, then you could use
>> address_space_write(address_space_memory, ...), which is
>> what cpu_physical_memory_write() is doing under the hood.
>> The qtest protocol assumes a single address space anyway.
>
> Correct, good idea.
>
> Next problem I have here is to understand what 'endianness'
> means for QTest framework. Use case: heterogeneous ZynqMP
> with ARM and MicroBlaze cores.
>
> Thanks,
>
> Phil.
next prev parent reply other threads:[~2024-12-10 10:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 19:19 [PATCH-for-10.0] system/qtest: Access memory using cpu_physical_memory_rw() API Philippe Mathieu-Daudé
2024-11-27 22:35 ` Richard Henderson
2024-11-28 5:56 ` Philippe Mathieu-Daudé
2024-12-09 17:08 ` Fabiano Rosas
2024-12-09 20:34 ` Fabiano Rosas
2024-12-09 20:42 ` Philippe Mathieu-Daudé
2024-12-10 10:03 ` Peter Maydell
2024-12-10 10:20 ` Philippe Mathieu-Daudé
2024-12-10 10:31 ` Philippe Mathieu-Daudé [this message]
2024-12-10 10:31 ` 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=e979b3ba-e701-4ac6-962a-19e4598ba947@linaro.org \
--to=philmd@linaro.org \
--cc=anjo@rev.ng \
--cc=farosas@suse.de \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.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).