All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Eugenio Perez Martin <eperezma@redhat.com>
Cc: qemu-level <qemu-devel@nongnu.org>,
	Gautam Dawar <gdawar@xilinx.com>,
	 "Michael S. Tsirkin" <mst@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	 "Gonglei (Arei)" <arei.gonglei@huawei.com>,
	Harpreet Singh Anand <hanand@xilinx.com>,
	 Cornelia Huck <cohuck@redhat.com>,
	Zhu Lingshan <lingshan.zhu@intel.com>,
	 Laurent Vivier <lvivier@redhat.com>,
	Eli Cohen <eli@mellanox.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	Liuxiangdong <liuxiangdong5@huawei.com>,
	 Eric Blake <eblake@redhat.com>, Cindy Lu <lulu@redhat.com>,
	Parav Pandit <parav@mellanox.com>
Subject: Re: [RFC PATCH v8 00/21] Net Control VQ support with asid in vDPA SVQ
Date: Tue, 14 Jun 2022 16:01:51 +0800	[thread overview]
Message-ID: <CACGkMEutyK2AXZ6uMg2nioXnJoaONkC7u1gGCuzJmuem_OsLLg@mail.gmail.com> (raw)
In-Reply-To: <CAJaqyWfy4f579a-pH2rPMB7KBrZ+iiNwuUEn2Y2TDoxPjD3VUQ@mail.gmail.com>

On Tue, Jun 14, 2022 at 12:32 AM Eugenio Perez Martin
<eperezma@redhat.com> wrote:
>
> On Wed, Jun 8, 2022 at 9:28 PM Eugenio Perez Martin <eperezma@redhat.com> wrote:
> >
> > On Wed, Jun 8, 2022 at 7:51 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > >
> > > 在 2022/5/20 03:12, Eugenio Pérez 写道:
> > > > Control virtqueue is used by networking device for accepting various
> > > > commands from the driver. It's a must to support multiqueue and other
> > > > configurations.
> > > >
> > > > Shadow VirtQueue (SVQ) already makes possible migration of virtqueue
> > > > states, effectively intercepting them so qemu can track what regions of memory
> > > > are dirty because device action and needs migration. However, this does not
> > > > solve networking device state seen by the driver because CVQ messages, like
> > > > changes on MAC addresses from the driver.
> > > >
> > > > To solve that, this series uses SVQ infraestructure proposed to intercept
> > > > networking control messages used by the device. This way, qemu is able to
> > > > update VirtIONet device model and to migrate it.
> > > >
> > > > However, to intercept all queues would slow device data forwarding. To solve
> > > > that, only the CVQ must be intercepted all the time. This is achieved using
> > > > the ASID infraestructure, that allows different translations for different
> > > > virtqueues. The most updated kernel part of ASID is proposed at [1].
> > > >
> > > > You can run qemu in two modes after applying this series: only intercepting
> > > > cvq with x-cvq-svq=on or intercept all the virtqueues adding cmdline x-svq=on:
> > > >
> > > > -netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,id=vhost-vdpa0,x-cvq-svq=on,x-svq=on
> > > >
> > > > First three patches enable the update of the virtio-net device model for each
> > > > CVQ message acknoledged by the device.
> > > >
> > > > Patches from 5 to 9 enables individual SVQ to copy the buffers to QEMU's VA.
> > > > This allows simplyfing the memory mapping, instead of map all the guest's
> > > > memory like in the data virtqueues.
> > > >
> > > > Patch 10 allows to inject control messages to the device. This allows to set
> > > > state to the device both at QEMU startup and at live migration destination. In
> > > > the future, this may also be used to emulate _F_ANNOUNCE.
> > > >
> > > > Patch 11 updates kernel headers, but it assign random numbers to needed ioctls
> > > > because they are still not accepted in the kernel.
> > > >
> > > > Patches 12-16 enables the set of the features of the net device model to the
> > > > vdpa device at device start.
> > > >
> > > > Last ones enables the sepparated ASID and SVQ.
> > > >
> > > > Comments are welcomed.
> > >
> > >
> > > As discussed, I think we need to split this huge series into smaller ones:
> > >
> > > 1) shadow CVQ only, this makes rx-filter-event work
> > > 2) ASID support for CVQ
> > >
> > > And for 1) we need consider whether or not it could be simplified.
> > >
> > > Or do it in reverse order, since if we do 1) first, we may have security
> > > issues.
> > >
> >
> > I'm ok with both, but I also think 2) before 1) might make more sense.
> > There is no way to only shadow CVQ otherwise ATM.
> >
>
> On second thought, that order is kind of harder.
>
> If we only map CVQ buffers, we need to either:
> a. Copy them to controlled buffers
> b. Track properly when to unmap them

Just to make sure we're at the same page:

I meant we can start with e.g having a dedicated ASID for CVQ but
still using CVQ passthrough.

Then do other stuff on top.

>
> Alternative a. have the same problems exposed in this RFC: It's hard
> (and unneeded in the final version) to know the size to copy.
> Alternative b. also requires things not needed in the final version,
> like to count the number of times each page is mapped and unmapped.
>
> So I'll go to the first alternative, that is also the proposed order
> of the RFC. What security issues do you expect beyond the comments in
> this series?

If we shadow CVQ without ASID. The guest may guess the IOVA of CVQ and
try to peek/modify it?

Thanks

>
> Thanks!
>
> > Can we do as with previous base SVQ patches? they were merged although
> > there is still no way to enable SVQ.
> >
> > Thanks!
> >
> > > Thoughts?
> > >
> > > Thanks
> > >
> > >
> > > >
> > > > TODO:
> > > > * Fallback on regular CVQ if QEMU cannot isolate in its own ASID by any
> > > >    reason, blocking migration. This is tricky, since it can cause that the VM
> > > >    cannot be migrated anymore, so some way of block it must be used.
> > > > * Review failure paths, some are with TODO notes, other don't.
> > > >
> > > > Changes from rfc v7:
> > > > * Don't map all guest space in ASID 1 but copy all the buffers. No need for
> > > >    more memory listeners.
> > > > * Move net backend start callback to SVQ.
> > > > * Wait for device CVQ commands used by the device at SVQ start, avoiding races.
> > > > * Changed ioctls, but they're provisional anyway.
> > > > * Reorder commits so refactor and code adding ones are closer to usage.
> > > > * Usual cleaning: better tracing, doc, patches messages, ...
> > > >
> > > > Changes from rfc v6:
> > > > * Fix bad iotlb updates order when batching was enabled
> > > > * Add reference counting to iova_tree so cleaning is simpler.
> > > >
> > > > Changes from rfc v5:
> > > > * Fixes bad calculus of cvq end group when MQ is not acked by the guest.
> > > >
> > > > Changes from rfc v4:
> > > > * Add missing tracing
> > > > * Add multiqueue support
> > > > * Use already sent version for replacing g_memdup
> > > > * Care with memory management
> > > >
> > > > Changes from rfc v3:
> > > > * Fix bad returning of descriptors to SVQ list.
> > > >
> > > > Changes from rfc v2:
> > > > * Fix use-after-free.
> > > >
> > > > Changes from rfc v1:
> > > > * Rebase to latest master.
> > > > * Configure ASID instead of assuming cvq asid != data vqs asid.
> > > > * Update device model so (MAC) state can be migrated too.
> > > >
> > > > [1] https://lkml.kernel.org/kvm/20220224212314.1326-1-gdawar@xilinx.com/
> > > >
> > > > Eugenio Pérez (21):
> > > >    virtio-net: Expose ctrl virtqueue logic
> > > >    vhost: Add custom used buffer callback
> > > >    vdpa: control virtqueue support on shadow virtqueue
> > > >    virtio: Make virtqueue_alloc_element non-static
> > > >    vhost: Add vhost_iova_tree_find
> > > >    vdpa: Add map/unmap operation callback to SVQ
> > > >    vhost: move descriptor translation to vhost_svq_vring_write_descs
> > > >    vhost: Add SVQElement
> > > >    vhost: Add svq copy desc mode
> > > >    vhost: Add vhost_svq_inject
> > > >    vhost: Update kernel headers
> > > >    vdpa: delay set_vring_ready after DRIVER_OK
> > > >    vhost: Add ShadowVirtQueueStart operation
> > > >    vhost: Make possible to check for device exclusive vq group
> > > >    vhost: add vhost_svq_poll
> > > >    vdpa: Add vhost_vdpa_start_control_svq
> > > >    vdpa: Add asid attribute to vdpa device
> > > >    vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs
> > > >    vhost: Add reference counting to vhost_iova_tree
> > > >    vdpa: Add x-svq to NetdevVhostVDPAOptions
> > > >    vdpa: Add x-cvq-svq
> > > >
> > > >   qapi/net.json                                |  13 +-
> > > >   hw/virtio/vhost-iova-tree.h                  |   7 +-
> > > >   hw/virtio/vhost-shadow-virtqueue.h           |  61 ++-
> > > >   include/hw/virtio/vhost-vdpa.h               |   3 +
> > > >   include/hw/virtio/vhost.h                    |   3 +
> > > >   include/hw/virtio/virtio-net.h               |   4 +
> > > >   include/hw/virtio/virtio.h                   |   1 +
> > > >   include/standard-headers/linux/vhost_types.h |  11 +-
> > > >   linux-headers/linux/vhost.h                  |  25 +-
> > > >   hw/net/vhost_net.c                           |   5 +-
> > > >   hw/net/virtio-net.c                          |  84 +++--
> > > >   hw/virtio/vhost-iova-tree.c                  |  35 +-
> > > >   hw/virtio/vhost-shadow-virtqueue.c           | 378 ++++++++++++++++---
> > > >   hw/virtio/vhost-vdpa.c                       | 206 +++++++++-
> > > >   hw/virtio/virtio.c                           |   2 +-
> > > >   net/vhost-vdpa.c                             | 294 ++++++++++++++-
> > > >   hw/virtio/trace-events                       |  10 +-
> > > >   17 files changed, 1012 insertions(+), 130 deletions(-)
> > > >
> > >
>



  reply	other threads:[~2022-06-14  8:16 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 19:12 [RFC PATCH v8 00/21] Net Control VQ support with asid in vDPA SVQ Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 01/21] virtio-net: Expose ctrl virtqueue logic Eugenio Pérez
2022-06-07  6:13   ` Jason Wang
2022-06-08 16:30     ` Eugenio Perez Martin
2022-05-19 19:12 ` [RFC PATCH v8 02/21] vhost: Add custom used buffer callback Eugenio Pérez
2022-06-07  6:12   ` Jason Wang
2022-06-08 19:38     ` Eugenio Perez Martin
2022-05-19 19:12 ` [RFC PATCH v8 03/21] vdpa: control virtqueue support on shadow virtqueue Eugenio Pérez
2022-06-07  6:05   ` Jason Wang
2022-06-08 16:38     ` Eugenio Perez Martin
2022-05-19 19:12 ` [RFC PATCH v8 04/21] virtio: Make virtqueue_alloc_element non-static Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 05/21] vhost: Add vhost_iova_tree_find Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 06/21] vdpa: Add map/unmap operation callback to SVQ Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 07/21] vhost: move descriptor translation to vhost_svq_vring_write_descs Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 08/21] vhost: Add SVQElement Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 09/21] vhost: Add svq copy desc mode Eugenio Pérez
2022-06-08  4:14   ` Jason Wang
2022-06-08 19:02     ` Eugenio Perez Martin
2022-06-09  7:00       ` Jason Wang
2022-05-19 19:12 ` [RFC PATCH v8 10/21] vhost: Add vhost_svq_inject Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 11/21] vhost: Update kernel headers Eugenio Pérez
2022-06-08  4:18   ` Jason Wang
2022-06-08 19:04     ` Eugenio Perez Martin
2022-05-19 19:12 ` [RFC PATCH v8 12/21] vdpa: delay set_vring_ready after DRIVER_OK Eugenio Pérez
2022-06-08  4:20   ` Jason Wang
2022-06-08 19:06     ` Eugenio Perez Martin
2022-05-19 19:12 ` [RFC PATCH v8 13/21] vhost: Add ShadowVirtQueueStart operation Eugenio Pérez
2022-05-19 19:12 ` [RFC PATCH v8 14/21] vhost: Make possible to check for device exclusive vq group Eugenio Pérez
2022-06-08  4:25   ` Jason Wang
2022-06-08 19:21     ` Eugenio Perez Martin
2022-06-09  7:13       ` Jason Wang
2022-06-09  7:51         ` Eugenio Perez Martin
2022-05-19 19:13 ` [RFC PATCH v8 15/21] vhost: add vhost_svq_poll Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 16/21] vdpa: Add vhost_vdpa_start_control_svq Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 17/21] vdpa: Add asid attribute to vdpa device Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 18/21] vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 19/21] vhost: Add reference counting to vhost_iova_tree Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 20/21] vdpa: Add x-svq to NetdevVhostVDPAOptions Eugenio Pérez
2022-05-19 19:13 ` [RFC PATCH v8 21/21] vdpa: Add x-cvq-svq Eugenio Pérez
2022-06-08  5:51 ` [RFC PATCH v8 00/21] Net Control VQ support with asid in vDPA SVQ Jason Wang
2022-06-08 19:28   ` Eugenio Perez Martin
2022-06-13 16:31     ` Eugenio Perez Martin
2022-06-14  8:01       ` Jason Wang [this message]
2022-06-14  8:13         ` Eugenio Perez Martin
2022-06-14  8:20           ` Jason Wang
2022-06-14  9:31             ` Eugenio Perez Martin
2022-06-15  3:04               ` Jason Wang
2022-06-15 10:02                 ` Eugenio Perez Martin
2022-06-17  1:29                   ` Jason Wang
2022-06-17  8:17                     ` Eugenio Perez Martin
2022-06-20  5:07                       ` Jason Wang

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=CACGkMEutyK2AXZ6uMg2nioXnJoaONkC7u1gGCuzJmuem_OsLLg@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=eblake@redhat.com \
    --cc=eli@mellanox.com \
    --cc=eperezma@redhat.com \
    --cc=gdawar@xilinx.com \
    --cc=hanand@xilinx.com \
    --cc=lingshan.zhu@intel.com \
    --cc=liuxiangdong5@huawei.com \
    --cc=lulu@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.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.