From: "Alex Bennée" <alex.bennee@linaro.org>
To: Vikram Garhwal <vikram.garhwal@amd.com>
Cc: qemu-devel@nongnu.org, sstabellini@kernel.org, jgross@suse.com,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"David Hildenbrand" <david@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: Re: [QEMU][PATCH v3 3/7] softmmu: let qemu_map_ram_ptr() use qemu_ram_ptr_length()
Date: Fri, 01 Mar 2024 17:04:54 +0000 [thread overview]
Message-ID: <87ttlp51e1.fsf@draig.linaro.org> (raw)
In-Reply-To: <20240227223501.28475-4-vikram.garhwal@amd.com> (Vikram Garhwal's message of "Tue, 27 Feb 2024 14:34:57 -0800")
Vikram Garhwal <vikram.garhwal@amd.com> writes:
> From: Juergen Gross <jgross@suse.com>
>
> qemu_map_ram_ptr() and qemu_ram_ptr_length() share quite some code, so
> modify qemu_ram_ptr_length() a little bit and use it for
> qemu_map_ram_ptr(), too.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> Signed-off-by: Vikram Garhwal <vikram.garhwal@amd.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> ---
> system/physmem.c | 56 ++++++++++++++++++++----------------------------
> 1 file changed, 23 insertions(+), 33 deletions(-)
>
<snip>
> -
> -/* Return a host pointer to guest's ram. Similar to qemu_map_ram_ptr
> - * but takes a size argument.
> +/*
> + * Return a host pointer to guest's ram.
> *
> * Called within RCU critical section.
> */
If you end up re-spinning it would be nice to kdoc this function and at
least call out size as a return by ref and optional.
> static void *qemu_ram_ptr_length(RAMBlock *block, ram_addr_t addr,
> hwaddr *size, bool lock)
> {
> - if (*size == 0) {
> + hwaddr len = 0;
> +
> + if (size && *size == 0) {
> return NULL;
> }
>
> @@ -2207,7 +2181,10 @@ static void *qemu_ram_ptr_length(RAMBlock *block, ram_addr_t addr,
> block = qemu_get_ram_block(addr);
> addr -= block->offset;
> }
> - *size = MIN(*size, block->max_length - addr);
> + if (size) {
> + *size = MIN(*size, block->max_length - addr);
> + len = *size;
> + }
>
> if (xen_enabled() && block->host == NULL) {
> /* We need to check if the requested address is in the RAM
> @@ -2215,7 +2192,7 @@ static void *qemu_ram_ptr_length(RAMBlock *block, ram_addr_t addr,
> * In that case just map the requested area.
> */
> if (block->offset == 0) {
> - return xen_map_cache(addr, *size, lock, lock);
> + return xen_map_cache(addr, len, lock, lock);
I did wonder if len == 0 will confuse things but it seems xen_map_cache
will default to XC_PAGE_SIZE in that case.
Anyway:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
next prev parent reply other threads:[~2024-03-01 17:05 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-27 22:34 [QEMU][PATCH v3 0/7] Xen: support grant mappings Vikram Garhwal
2024-02-27 22:34 ` [QEMU][PATCH v3 1/7] softmmu: physmem: Split ram_block_add() Vikram Garhwal
2024-03-01 11:33 ` Alex Bennée
2024-04-10 11:10 ` Edgar E. Iglesias
2024-02-27 22:34 ` [QEMU][PATCH v3 2/7] xen: add pseudo RAM region for grant mappings Vikram Garhwal
2024-03-01 14:05 ` Alex Bennée
2024-04-10 11:12 ` Edgar E. Iglesias
2024-02-27 22:34 ` [QEMU][PATCH v3 3/7] softmmu: let qemu_map_ram_ptr() use qemu_ram_ptr_length() Vikram Garhwal
2024-03-01 17:04 ` Alex Bennée [this message]
2024-03-06 20:58 ` Vikram Garhwal
2024-04-10 11:15 ` Edgar E. Iglesias
2024-02-27 22:34 ` [QEMU][PATCH v3 4/7] xen: let xen_ram_addr_from_mapcache() return -1 in case of not found entry Vikram Garhwal
2024-03-01 17:08 ` Alex Bennée
2024-04-10 11:14 ` Edgar E. Iglesias
2024-02-27 22:34 ` [QEMU][PATCH v3 5/7] memory: add MemoryRegion map and unmap callbacks Vikram Garhwal
2024-02-29 23:10 ` Stefano Stabellini
2024-04-10 11:16 ` Edgar E. Iglesias
2024-04-10 16:44 ` Edgar E. Iglesias
2024-04-10 18:56 ` Peter Xu
2024-04-16 11:32 ` Edgar E. Iglesias
2024-04-16 13:28 ` Jürgen Groß
2024-04-16 15:55 ` Peter Xu
2024-04-17 10:34 ` Edgar E. Iglesias
2024-02-27 22:35 ` [QEMU][PATCH v3 6/7] xen: add map and unmap callbacks for grant region Vikram Garhwal
2024-02-29 23:10 ` Stefano Stabellini
2024-04-10 11:11 ` Edgar E. Iglesias
2024-02-27 22:35 ` [QEMU][PATCH v3 7/7] hw: arm: Add grant mapping Vikram Garhwal
2024-03-01 17:10 ` Alex Bennée
2024-03-06 20:56 ` Vikram Garhwal
2024-04-10 11:09 ` Edgar E. Iglesias
2024-02-28 13:27 ` [QEMU][PATCH v3 0/7] Xen: support grant mappings Manos Pitsidianakis
2024-02-28 18:59 ` Vikram Garhwal
2024-04-10 12:43 ` Edgar E. Iglesias
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=87ttlp51e1.fsf@draig.linaro.org \
--to=alex.bennee@linaro.org \
--cc=david@redhat.com \
--cc=jgross@suse.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=vikram.garhwal@amd.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).