From: Vikram Garhwal <vikram.garhwal@amd.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: qemu-devel@nongnu.org, "Juergen Gross" <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 v1 3/7] softmmu: let qemu_map_ram_ptr() use qemu_ram_ptr_length()
Date: Tue, 10 Oct 2023 14:26:02 -0700 [thread overview]
Message-ID: <ZSXBaiyLZWechQ7L@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2310091703070.3431292@ubuntu-linux-20-04-desktop>
On Mon, Oct 09, 2023 at 05:10:43PM -0700, Stefano Stabellini wrote:
> On Thu, 5 Oct 2023, Vikram Garhwal wrote:
> > 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>
>
> This patch also doesn't apply due to code movement.
Will rebase it.
>
> Other than that, the patch looks good to me
>
>
> > ---
> > softmmu/physmem.c | 58 +++++++++++++++++++----------------------------
> > 1 file changed, 23 insertions(+), 35 deletions(-)
> >
> > diff --git a/softmmu/physmem.c b/softmmu/physmem.c
> > index e182a2fa07..6e5e379dd0 100644
> > --- a/softmmu/physmem.c
> > +++ b/softmmu/physmem.c
> > @@ -2163,38 +2163,8 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
> > }
> > #endif /* !_WIN32 */
> >
> > -/* Return a host pointer to ram allocated with qemu_ram_alloc.
> > - * This should not be used for general purpose DMA. Use address_space_map
> > - * or address_space_rw instead. For local memory (e.g. video ram) that the
> > - * device owns, use memory_region_get_ram_ptr.
> > - *
> > - * Called within RCU critical section.
> > - */
> > -void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
> > -{
> > - RAMBlock *block = ram_block;
> > -
> > - if (block == NULL) {
> > - block = qemu_get_ram_block(addr);
> > - addr -= block->offset;
> > - }
> > -
> > - if (xen_enabled() && block->host == NULL) {
> > - /* We need to check if the requested address is in the RAM
> > - * because we don't want to map the entire memory in QEMU.
> > - * In that case just map until the end of the page.
> > - */
> > - if (block->offset == 0) {
> > - return xen_map_cache(addr, 0, 0, false);
> > - }
> > -
> > - block->host = xen_map_cache(block->offset, block->max_length, 1, false);
> > - }
> > - return ramblock_ptr(block, addr);
> > -}
> > -
> > -/* 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.
> > */
> > @@ -2202,7 +2172,9 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
> > hwaddr *size, bool lock)
> > {
> > RAMBlock *block = ram_block;
> > - if (*size == 0) {
> > + hwaddr len = 0;
> > +
> > + if (size && *size == 0) {
> > return NULL;
> > }
> >
> > @@ -2210,7 +2182,10 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_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
> > @@ -2218,7 +2193,7 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_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);
> > }
> >
> > block->host = xen_map_cache(block->offset, block->max_length, 1, lock);
> > @@ -2227,6 +2202,19 @@ static void *qemu_ram_ptr_length(RAMBlock *ram_block, ram_addr_t addr,
> > return ramblock_ptr(block, addr);
> > }
> >
> > +/*
> > + * Return a host pointer to ram allocated with qemu_ram_alloc.
> > + * This should not be used for general purpose DMA. Use address_space_map
> > + * or address_space_rw instead. For local memory (e.g. video ram) that the
> > + * device owns, use memory_region_get_ram_ptr.
> > + *
> > + * Called within RCU critical section.
> > + */
> > +void *qemu_map_ram_ptr(RAMBlock *ram_block, ram_addr_t addr)
> > +{
> > + return qemu_ram_ptr_length(ram_block, addr, NULL, false);
> > +}
> > +
> > /* Return the offset of a hostpointer within a ramblock */
> > ram_addr_t qemu_ram_block_host_offset(RAMBlock *rb, void *host)
> > {
> > --
> > 2.17.1
> >
next prev parent reply other threads:[~2023-10-10 21:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 18:16 [QEMU][PATCH v1 0/7] Xen: support grant mappings Vikram Garhwal
2023-10-05 18:16 ` [QEMU][PATCH v1 1/7] xen: when unplugging emulated devices skip virtio devices Vikram Garhwal
2023-10-09 23:51 ` Stefano Stabellini
2023-10-10 20:24 ` Vikram Garhwal
2023-10-19 9:17 ` David Woodhouse
2023-10-05 18:16 ` [QEMU][PATCH v1 2/7] xen: add pseudo RAM region for grant mappings Vikram Garhwal
2023-10-10 0:02 ` Stefano Stabellini
2023-10-10 0:29 ` Stefano Stabellini
2023-10-10 21:25 ` Vikram Garhwal
2023-10-10 22:30 ` Stefano Stabellini
2023-10-05 18:16 ` [QEMU][PATCH v1 3/7] softmmu: let qemu_map_ram_ptr() use qemu_ram_ptr_length() Vikram Garhwal
2023-10-10 0:10 ` Stefano Stabellini
2023-10-10 21:26 ` Vikram Garhwal [this message]
2023-10-05 18:16 ` [QEMU][PATCH v1 4/7] xen: let xen_ram_addr_from_mapcache() return -1 in case of not found entry Vikram Garhwal
2023-10-10 0:13 ` Stefano Stabellini
2023-10-05 18:16 ` [QEMU][PATCH v1 5/7] memory: add MemoryRegion map and unmap callbacks Vikram Garhwal
2023-10-10 0:17 ` Stefano Stabellini
2023-10-11 7:01 ` Juergen Gross
2023-10-26 1:41 ` Stefano Stabellini
2023-10-05 18:16 ` [QEMU][PATCH v1 6/7] xen: add map and unmap callbacks for grant region Vikram Garhwal
2023-10-10 0:27 ` Stefano Stabellini
2023-10-05 18:16 ` [QEMU][PATCH v1 7/7] hw: arm: Add grant mapping Vikram Garhwal
2023-10-10 0:28 ` Stefano Stabellini
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=ZSXBaiyLZWechQ7L@amd.com \
--to=vikram.garhwal@amd.com \
--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 \
/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.