[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 07/22] intel_iommu: add set/unset_iommu_context callback
From: |
Peter Xu |
Subject: |
Re: [PATCH v1 07/22] intel_iommu: add set/unset_iommu_context callback |
Date: |
Tue, 24 Mar 2020 11:24:16 -0400 |
On Tue, Mar 24, 2020 at 11:15:24AM +0000, Liu, Yi L wrote:
[...]
> > > struct VTDIOTLBEntry {
> > > @@ -271,6 +282,8 @@ struct IntelIOMMUState {
> > > /*
> > > * Protects IOMMU states in general. Currently it protects the
> > > * per-IOMMU IOTLB cache, and context entry cache in VTDAddressSpace.
> > > + * Protect the update/usage of HostIOMMUContext pointer cached in
> > > + * VTDBus->dev_icx array as array elements may be updated by hotplug
> >
> > I think the context update does not need to be updated, because they
> > should always be with the BQL, right?
>
> Hmmmm, maybe I used bad description. My purpose is to protect the stored
> HostIOMMUContext pointer in vIOMMU. With pci_device_set/unset_iommu_context,
> vIOMMU have a copy of HostIOMMUContext. If VFIO container is released
> (e.g. hotpulg out device), HostIOMMUContext will alos be released. This
> will trigger the pci_device_unset_iommu_context() to clean the copy. To
> avoid using a staled HostIOMMUContext in vIOMMU, vIOMMU should have a
> lock to block the pci_device_unset_iommu_context() calling until other
> threads finished their HostIOMMUContext usage. Do you want a description
> update here or other preference?
Yeah, but hot plug/unplug will still take the BQL?
Ah btw I think it's also OK to take the lock if you want or not sure
about whether we'll always take the BQL in these paths. But if so,
instead of adding another "Protect the ..." sentence to the comment,
would you mind list out what the lock is protecting?
/*
* iommu_lock protects:
* - per-IOMMU IOTLB caches
* - context entry caches
* - ...
*/
Or anything better than that. Thanks,
--
Peter Xu
- RE: [PATCH v1 06/22] hw/pci: introduce pci_device_set/unset_iommu_context(), (continued)
[PATCH v1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support, Liu Yi L, 2020/03/22
[PATCH v1 07/22] intel_iommu: add set/unset_iommu_context callback, Liu Yi L, 2020/03/22
[PATCH v1 17/22] intel_iommu: do not pass down pasid bind for PASID #0, Liu Yi L, 2020/03/22
[PATCH v1 11/22] intel_iommu: process PASID cache invalidation, Liu Yi L, 2020/03/22
[PATCH v1 02/22] header file update VFIO/IOMMU vSVA APIs, Liu Yi L, 2020/03/22