[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 06/10] vfio: Allow hotplug of con
From: |
David Gibson |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings |
Date: |
Thu, 24 Sep 2015 09:50:54 +1000 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Wed, Sep 23, 2015 at 01:02:32PM +0200, Thomas Huth wrote:
> On 18/09/15 01:31, David Gibson wrote:
> > On Thu, Sep 17, 2015 at 10:54:24AM -0600, Alex Williamson wrote:
> >> On Thu, 2015-09-17 at 23:09 +1000, David Gibson wrote:
> >>> At present the memory listener used by vfio to keep host IOMMU mappings
> >>> in sync with the guest memory image assumes that if a guest IOMMU
> >>> appears, then it has no existing mappings.
> >>>
> >>> This may not be true if a VFIO device is hotplugged onto a guest bus
> >>> which didn't previously include a VFIO device, and which has existing
> >>> guest IOMMU mappings.
> >>>
> >>> Therefore, use the memory_region_register_iommu_notifier_replay()
> >>> function in order to fix this case, replaying existing guest IOMMU
> >>> mappings, bringing the host IOMMU into sync with the guest IOMMU.
> >>>
> >>> Signed-off-by: David Gibson <address@hidden>
> >>> ---
> >>> hw/vfio/common.c | 34 +++++++++++++++++++---------------
> >>> 1 file changed, 19 insertions(+), 15 deletions(-)
> >>>
> >>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> >>> index daaac48..543c38e 100644
> >>> --- a/hw/vfio/common.c
> >>> +++ b/hw/vfio/common.c
> >>> @@ -312,6 +312,22 @@ out:
> >>> rcu_read_unlock();
> >>> }
> >>>
> >>> +static hwaddr vfio_container_granularity(VFIOContainer *container)
> >>> +{
> >>> + uint64_t pgsize;
> >>> +
> >>> + assert(container->iommu_data.iova_pgsizes);
> >>
> >> return (hwaddr)1 << (ffsl(container->iommu_data.iova_pgsizes) - 1;
> >
> > Ah, yes, that should work. I didn't do it that way mostly because I
> > tend to confuse myself when I try to remember exactly how ffs
> > semantics work.
>
> Maybe use ffsll instead of ffsl, in case the code ever runs on a 32-bit
> host instead of a 64-bit host ?
Already done :)
--
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
pgpPUJ_WNwsHd.pgp
Description: PGP signature
[Qemu-ppc] [RFC PATCH 10/10] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 04/10] vfio: Record host IOMMU's available IO page sizes, David Gibson, 2015/09/17
[Qemu-ppc] [RFC PATCH 08/10] spapr_iommu: Rename vfio_accel parameter, David Gibson, 2015/09/17
Re: [Qemu-ppc] [RFC PATCH 00/10] pseries: Allow VFIO devices on spapr-pci-host-bridge, Alex Williamson, 2015/09/17
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 00/10] pseries: Allow VFIO devices on spapr-pci-host-bridge, Thomas Huth, 2015/09/23