public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 3/5] vhost-user: introduce vhost-user API
Date: Thu, 11 Jul 2024 14:07:00 +0200	[thread overview]
Message-ID: <4b401408-9816-4c91-82e4-2d7550cda5d5@redhat.com> (raw)
In-Reply-To: <Znjhrdvyh1nOHFVJ@zatzit>

On 24/06/2024 05:02, David Gibson wrote:
> On Fri, Jun 21, 2024 at 04:56:38PM +0200, Laurent Vivier wrote:
>> Add vhost_user.c and vhost_user.h that define the functions needed
>> to implement vhost-user backend.
>>
>> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> 
> I'm a little confused by this patch.  The commit message seems to
> suggest that like the previous patch it's basically just a code import
> from qemu.  However...
> 
> [snip]
>> diff --git a/passt.c b/passt.c
>> index a5e2c5a8e151..9d21c545b9cf 100644
>> --- a/passt.c
>> +++ b/passt.c
>> @@ -73,6 +73,8 @@ char *epoll_type_str[] = {
>>   	[EPOLL_TYPE_TAP_PASTA]		= "/dev/net/tun device",
>>   	[EPOLL_TYPE_TAP_PASST]		= "connected qemu socket",
>>   	[EPOLL_TYPE_TAP_LISTEN]		= "listening qemu socket",
>> +	[EPOLL_TYPE_VHOST_CMD]		= "vhost-user command socket",
>> +	[EPOLL_TYPE_VHOST_KICK]		= "vhost-user kick socket",
> 
> ... we also have real changes to passt specific code.  It's not very
> obvious to me what the boundaries of that are.

I have moved all of this to the last patch.

...
>> +/* Translate qemu virtual address to our virtual address.  */
> 
> Now that this code is not in qemu, it's not very clear what either of
> these "virtual addresses" is.

It's actually QEMU virtual address (QEMU or any other vhost-user client). it's also called 
userspace address in vhost data structure but I don't like this term as we don't know if 
it's our userspace or the user space of the vhost-user client. Our userspace address is 
called mmap address.
We have also the guest physical address that is the address from inside the guest.

The vring addresses are provided from the QEMU userspace address (information from the 
vhost-user level):
https://qemu-project.gitlab.io/qemu/interop/vhost-user.html#a-vring-address-description

The descriptor ring addresses are provided from the guest space so they are physical 
addresses (information from the virtio level):
https://docs.oasis-open.org/virtio/virtio/v1.1/cs01/virtio-v1.1-cs01.html#x1-7500013

>> +static void *qva_to_va(VuDev *dev, uint64_t qemu_addr)
>> +{
>> +	unsigned int i;
>> +
>> +	/* Find matching memory region.  */
>> +	for (i = 0; i < dev->nregions; i++) {
>> +		const VuDevRegion *r = &dev->regions[i];
>> +
>> +		if ((qemu_addr >= r->qva) && (qemu_addr < (r->qva + r->size))) {
>> +			/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
>> +			return (void *)(qemu_addr - r->qva + r->mmap_addr +
>> +					r->mmap_offset);
>> +		}
>> +	}
>> +
>> +	return NULL;
>> +}

This function translate the QEMU userspace address to our process userspace address 
(mmapped memory).

I'm updating all the function comment headers to describe this kind of information.

Thanks,
Laurent


  reply	other threads:[~2024-07-11 12:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-21 14:56 [PATCH 0/5] Add vhost-user support to passt. (part 3) Laurent Vivier
2024-06-21 14:56 ` [PATCH 1/5] packet: replace struct desc by struct iovec Laurent Vivier
2024-06-24  2:48   ` David Gibson
2024-07-04 15:52     ` Laurent Vivier
2024-07-05  1:28       ` David Gibson
2024-06-21 14:56 ` [PATCH 2/5] vhost-user: introduce virtio API Laurent Vivier
2024-06-24  2:56   ` David Gibson
2024-07-05 15:06     ` Laurent Vivier
2024-07-05 23:53       ` David Gibson
2024-06-21 14:56 ` [PATCH 3/5] vhost-user: introduce vhost-user API Laurent Vivier
2024-06-24  3:02   ` David Gibson
2024-07-11 12:07     ` Laurent Vivier [this message]
2024-06-21 14:56 ` [PATCH 4/5] iov: add iov_count() Laurent Vivier
2024-06-24  3:03   ` David Gibson
2024-06-24  6:59     ` Laurent Vivier
2024-06-21 14:56 ` [PATCH 5/5] vhost-user: add vhost-user Laurent Vivier
2024-06-24  5:05   ` David Gibson
2024-07-12 14:49     ` Laurent Vivier
2024-07-15  0:37       ` David Gibson

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=4b401408-9816-4c91-82e4-2d7550cda5d5@redhat.com \
    --to=lvivier@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).