From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: Alex Williamson <alex.williamson@redhat.com>,
"Tian, Kevin" <kevin.tian@intel.com>
Cc: "Zhao, Yan Y" <yan.y.zhao@intel.com>,
"Kim, Dongwon" <dongwon.kim@intel.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>
Subject: RE: [RFC 3/3] vfio: Share the KVM instance with Vdmabuf
Date: Thu, 21 Jan 2021 03:15:01 +0000 [thread overview]
Message-ID: <04429d865db84e91ad72d9238ad9486b@intel.com> (raw)
In-Reply-To: <20210119203658.75d4e303@x1.home.shazbot.org>
Hi Alex,
> -----Original Message-----
> From: Alex Williamson <alex.williamson@redhat.com>
> Sent: Tuesday, January 19, 2021 7:37 PM
> To: Tian, Kevin <kevin.tian@intel.com>
> Cc: Kasireddy, Vivek <vivek.kasireddy@intel.com>; Kim, Dongwon
> <dongwon.kim@intel.com>; virtualization@lists.linux-foundation.org; Zhao, Yan Y
> <yan.y.zhao@intel.com>
> Subject: Re: [RFC 3/3] vfio: Share the KVM instance with Vdmabuf
>
> On Wed, 20 Jan 2021 03:05:49 +0000
> "Tian, Kevin" <kevin.tian@intel.com> wrote:
>
> > > From: Alex Williamson
> > > Sent: Wednesday, January 20, 2021 8:51 AM
> > >
> > > On Wed, 20 Jan 2021 00:14:49 +0000
> > > "Kasireddy, Vivek" <vivek.kasireddy@intel.com> wrote:
> > >
> > > > Hi Alex,
> > > >
> > > > > -----Original Message-----
> > > > > From: Alex Williamson <alex.williamson@redhat.com>
> > > > > Sent: Tuesday, January 19, 2021 7:40 AM
> > > > > To: Kasireddy, Vivek <vivek.kasireddy@intel.com>
> > > > > Cc: virtualization@lists.linux-foundation.org; Kim, Dongwon
> > > <dongwon.kim@intel.com>
> > > > > Subject: Re: [RFC 3/3] vfio: Share the KVM instance with Vdmabuf
> > > > >
> > > > > On Tue, 19 Jan 2021 00:28:12 -0800
> > > > > Vivek Kasireddy <vivek.kasireddy@intel.com> wrote:
> > > > >
> > > > > > Getting a copy of the KVM instance is necessary for mapping Guest
> > > > > > pages in the Host.
> > > > > >
> > > > > > TODO: Instead of invoking the symbol directly, there needs to be a
> > > > > > better way of getting a copy of the KVM instance probably by using
> > > > > > other notifiers. However, currently, KVM shares its instance only
> > > > > > with VFIO and therefore we are compelled to bind the passthrough'd
> > > > > > device to vfio-pci.
> > > > >
> > > > > Yeah, this is a bad solution, sorry, vfio is not going to gratuitously
> > > > > call out to vhost to share a kvm pointer. I'd prefer to get rid of
> > > > > vfio having any knowledge or visibility of the kvm pointer. Thanks,
> > > >
> > > > [Kasireddy, Vivek] I agree that this is definitely not ideal as I recognize it
> > > > in the TODO. However, it looks like VFIO also gets a copy of the KVM
> > > > pointer in a similar manner:
> > > >
> > > > virt/kvm/vfio.c
> > > >
> > > > static void kvm_vfio_group_set_kvm(struct vfio_group *group, struct kvm
> > > *kvm)
> > > > {
> > > > void (*fn)(struct vfio_group *, struct kvm *);
> > > >
> > > > fn = symbol_get(vfio_group_set_kvm);
> > > > if (!fn)
> > > > return;
> > > >
> > > > fn(group, kvm);
> > > >
> > > > symbol_put(vfio_group_set_kvm);
> > > > }
> > >
> > > You're equating the mechanism with the architecture. We use symbols
> > > here to avoid module dependencies between kvm and vfio, but this is
> > > just propagating data that userspace is specifically registering
> > > between kvm and vfio. vhost doesn't get to piggyback on that channel.
> > >
> > > > With this patch, I am not suggesting that this is a precedent that should be
> > > followed
> > > > but it appears there doesn't seem to be an alternative way of getting a copy
> > > of the KVM
> > > > pointer that is clean and elegant -- unless I have not looked hard enough. I
> > > guess we
> > > > could create a notifier chain with callbacks for VFIO and Vhost that KVM
> > > would call
> > > > but this would mean modifying KVM.
> > > >
> > > > Also, if I understand correctly, if VFIO does not want to share the KVM
> > > pointer with
> > > > VFIO groups, then I think it would break stuff like mdev which counts on it.
> > >
> > > Only kvmgt requires the kvm pointer and the use case there is pretty
> > > questionable, I wonder if it actually still exists now that we have the
> > > DMA r/w interface through vfio. Thanks,
> > >
> >
> > IIRC, kvmgt still needs the kvm pointer to use kvm page tracking interface
> > for write-protecting guest pgtable.
>
> Thanks, Kevin. Either way, a vhost device has no stake in the game wrt
> the kvm pointer lifecycle here and no business adding a callout. I'm
> reluctant to add any further use cases even for mdevs as ideally mdevs
> should have no dependency on kvm. Thanks,
[Kasireddy, Vivek] All I am trying to do is leverage existing mechanism(s)
instead of creating new ones. So, if Vhost cannot get the kvm pointer from
VFIO in any manner, my only option, as it appears is to add a new
notifier_block to KVM that gets triggered in kvm_create_vm() and
kvm_destroy_vm(). However, I am not sure if that would be acceptable to
the KVM maintainers. Does anyone know if there is another cleaner option
available rather than having to modify KVM?
Thanks,
Vivek
>
> Alex
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2021-01-21 3:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-19 8:28 [RFC 0/3] Introduce Vdmabuf driver Vivek Kasireddy
2021-01-19 8:28 ` [RFC 1/3] virtio: " Vivek Kasireddy
2021-01-19 8:28 ` [RFC 2/3] vhost: Add Vdmabuf backend Vivek Kasireddy
2021-01-19 8:28 ` [RFC 3/3] vfio: Share the KVM instance with Vdmabuf Vivek Kasireddy
2021-01-19 15:39 ` Alex Williamson
2021-01-20 0:14 ` Kasireddy, Vivek
2021-01-20 0:50 ` Alex Williamson
2021-01-20 3:05 ` Tian, Kevin
2021-01-20 3:36 ` Alex Williamson
2021-01-21 3:15 ` Kasireddy, Vivek [this message]
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=04429d865db84e91ad72d9238ad9486b@intel.com \
--to=vivek.kasireddy@intel.com \
--cc=alex.williamson@redhat.com \
--cc=dongwon.kim@intel.com \
--cc=kevin.tian@intel.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=yan.y.zhao@intel.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).