[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: |
Thomas Huth |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [RFC PATCH 06/10] vfio: Allow hotplug of containers onto existing guest IOMMU mappings |
Date: |
Wed, 23 Sep 2015 13:02:32 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
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 ?
Thomas
signature.asc
Description: OpenPGP digital 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