[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [PATCH qemu v16 16/19] vfio: Add host side DMA window cap
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [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
signature.asc
Description: PGP signature
- [Qemu-ppc] [PATCH qemu v16 00/19] spapr: vfio: Enable Dynamic DMA windows (DDW), Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 10/19] spapr_iommu: Migrate full state, Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 16/19] vfio: Add host side DMA window capabilities, Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 05/19] vfio: Check that IOMMU MR translates to system address space, Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 12/19] spapr_pci: Reset DMA config on PHB reset, Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 09/19] spapr_iommu: Finish renaming vfio_accel to need_vfio, Alexey Kardashevskiy, 2016/05/04
- [Qemu-ppc] [PATCH qemu v16 17/19] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping being used by VFIO, Alexey Kardashevskiy, 2016/05/04
- Re: [Qemu-ppc] [PATCH qemu v16 17/19] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping being used by VFIO, Alex Williamson, 2016/05/13
- Re: [Qemu-ppc] [PATCH qemu v16 17/19] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping being used by VFIO, Alexey Kardashevskiy, 2016/05/16
- Re: [Qemu-ppc] [PATCH qemu v16 17/19] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping being used by VFIO, Alex Williamson, 2016/05/16
- [Qemu-ppc] [RFC PATCH qemu] spapr_iommu, vfio, memory: Notify IOMMU about starting/stopping listening, Alexey Kardashevskiy, 2016/05/20