qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH qemu v16 16/19] vfio: Add host side DMA window c


From: David Gibson
Subject: Re: [Qemu-devel] [PATCH qemu v16 16/19] vfio: Add host side DMA window capabilities
Date: Fri, 27 May 2016 10:36:32 +1000
User-agent: Mutt/1.6.1 (2016-04-27)

On Fri, May 13, 2016 at 04:25:59PM -0600, Alex Williamson wrote:
> On Wed,  4 May 2016 16:52:28 +1000
> Alexey Kardashevskiy <address@hidden> wrote:
> 
> > There are going to be multiple IOMMUs per a container. This moves
> > the single host IOMMU parameter set to a list of VFIOHostDMAWindow.
> > 
> > This should cause no behavioral change and will be used later by
> > the SPAPR TCE IOMMU v2 which will also add a vfio_host_win_del() helper.
> > 
> > Signed-off-by: Alexey Kardashevskiy <address@hidden>
> > Reviewed-by: David Gibson <address@hidden>
> > ---
> > Changes:
> > v16:
> > * adjusted commit log with changes from v15
> > 
> > v15:
> > * s/vfio_host_iommu_add/vfio_host_win_add/
> > * s/VFIOHostIOMMU/VFIOHostDMAWindow/
> > ---
> >  hw/vfio/common.c              | 65 
> > +++++++++++++++++++++++++++++++++----------
> >  include/hw/vfio/vfio-common.h |  9 ++++--
> >  2 files changed, 57 insertions(+), 17 deletions(-)
> > 
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index 496eb82..3f2fb23 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -29,6 +29,7 @@
> >  #include "exec/memory.h"
> >  #include "hw/hw.h"
> >  #include "qemu/error-report.h"
> > +#include "qemu/range.h"
> >  #include "sysemu/kvm.h"
> >  #include "trace.h"
> >  
> > @@ -239,6 +240,45 @@ static int vfio_dma_map(VFIOContainer *container, 
> > hwaddr iova,
> >      return -errno;
> >  }
> >  
> > +static VFIOHostDMAWindow *vfio_host_win_lookup(VFIOContainer *container,
> > +                                               hwaddr min_iova, hwaddr 
> > max_iova)
> > +{
> > +    VFIOHostDMAWindow *hostwin;
> > +
> > +    QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
> > +        if (hostwin->min_iova <= min_iova && max_iova <= 
> > hostwin->max_iova) {
> > +            return hostwin;
> > +        }
> > +    }
> > +
> > +    return NULL;
> > +}
> > +
> > +static int vfio_host_win_add(VFIOContainer *container,
> > +                             hwaddr min_iova, hwaddr max_iova,
> > +                             uint64_t iova_pgsizes)
> > +{
> > +    VFIOHostDMAWindow *hostwin;
> > +
> > +    QLIST_FOREACH(hostwin, &container->hostwin_list, hostwin_next) {
> > +        if (ranges_overlap(min_iova, max_iova - min_iova + 1,
> > +                           hostwin->min_iova,
> > +                           hostwin->max_iova - hostwin->min_iova + 1)) {
> 
> Why does vfio_host_win_lookup() not also use ranges_overlap()?  In
> fact, why don't we call vfio_host_win_lookup here to find the conflict?
> 
> > +            error_report("%s: Overlapped IOMMU are not enabled", __func__);
> > +            return -1;
> 
> Nobody here tests the return value, shouldn't this be fatal?

Hm, yes.  I think hw_error() would be the right choice here.  This
would represent either a qemu programming error, or seriously
unexpected behaviour from the host kernel.
-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]