Re: [RESEND RFC v2 1/4] KVM: add initial support for KVM_SET_IOREGION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 05 Feb 2021 10:39:33 -0800
Elena Afanasova <eafanasova@xxxxxxxxx> wrote:

> On Thu, 2021-02-04 at 14:03 +0100, Cornelia Huck wrote:
> > On Fri, 29 Jan 2021 21:48:26 +0300
> > Elena Afanasova <eafanasova@xxxxxxxxx> wrote:

> > > @@ -1308,6 +1330,7 @@ struct kvm_vfio_spapr_tce {
> > >  					struct
> > > kvm_userspace_memory_region)
> > >  #define KVM_SET_TSS_ADDR          _IO(KVMIO,   0x47)
> > >  #define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO,  0x48, __u64)
> > > +#define KVM_SET_IOREGION          _IOW(KVMIO,  0x49, struct
> > > kvm_ioregion)  
> > 
> > This new ioctl needs some documentation under
> > Documentation/virt/kvm/api.rst. (That would also make review easier.)
> >   
> Agreed. The latest version of the ioregionfd API can be found in 
> https://marc.info/?l=kvm&m=160633710708172&w=2. There are still some
> open questions like write coalescing support.  So I think API may still
> be changed during code reviews.

Understood.

> 
> > >  
> > >  /* enable ucontrol for s390 */
> > >  struct kvm_s390_ucas_mapping {  
> > 
> > (...)
> >   
> > > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> > > index c2323c27a28b..aadb73903f8b 100644
> > > --- a/virt/kvm/eventfd.c
> > > +++ b/virt/kvm/eventfd.c
> > > @@ -27,6 +27,7 @@
> > >  #include <trace/events/kvm.h>
> > >  
> > >  #include <kvm/iodev.h>
> > > +#include "ioregion.h"
> > >  
> > >  #ifdef CONFIG_HAVE_KVM_IRQFD
> > >  
> > > @@ -755,6 +756,23 @@ static const struct kvm_io_device_ops
> > > ioeventfd_ops = {
> > >  	.destructor = ioeventfd_destructor,
> > >  };
> > >  
> > > +#ifdef CONFIG_KVM_IOREGION
> > > +/* assumes kvm->slots_lock held */
> > > +bool kvm_eventfd_collides(struct kvm *kvm, int bus_idx,
> > > +			  u64 start, u64 size)
> > > +{
> > > +	struct _ioeventfd *_p;
> > > +
> > > +	list_for_each_entry(_p, &kvm->ioeventfds, list)
> > > +		if (_p->bus_idx == bus_idx &&
> > > +		    overlap(start, size, _p->addr,
> > > +			    !_p->length ? 8 : _p->length))  
> > 
> > Not a problem right now, as this is x86 only, but I'm not sure we can
> > define "overlap" in a meaningful way for every bus_idx. (For example,
> > the s390-only ccw notifications use addr to identify a device; as
> > long
> > as addr is unique, there will be no clash. I'm not sure yet if
> > ioregions are usable for ccw devices, and if yes, in which form, but
> > we
> > should probably keep it in mind.)
> >   
> Thank you for pointing it out. Yes, CCW bus seems to be a special case.

In any case, it needs some special care if we want to include it later,
maybe by introducing a bus-specific collision check. As long as we're
just dealing with pio/mmio, I think the function can stay this way.




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux