[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH v4 13/17] intel_iommu: piotlb invalidation should notify unma
From: |
Duan, Zhenzhong |
Subject: |
RE: [PATCH v4 13/17] intel_iommu: piotlb invalidation should notify unmap |
Date: |
Tue, 5 Nov 2024 07:25:39 +0000 |
>-----Original Message-----
>From: Liu, Yi L <yi.l.liu@intel.com>
>Sent: Tuesday, November 5, 2024 2:30 PM
>Subject: Re: [PATCH v4 13/17] intel_iommu: piotlb invalidation should notify
>unmap
>
>On 2024/11/4 16:15, Duan, Zhenzhong wrote:
>>
>>> vtd_piotlb_page_invalidate(IntelIOMMUState *s, uint16_t domain_id,
>>>> g_hash_table_foreach_remove(s->iotlb,
>>>> vtd_hash_remove_by_page_piotlb, &info);
>>>> vtd_iommu_unlock(s);
>>>> +
>>>> + QLIST_FOREACH(vtd_as, &s->vtd_as_with_notifiers, next) {
>>>> + if (!vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus),
>>>> + vtd_as->devfn, &ce) &&
>>>> + domain_id == vtd_get_domain_id(s, &ce, vtd_as->pasid)) {
>>>> + uint32_t rid2pasid = VTD_CE_GET_RID2PASID(&ce);
>>>> + IOMMUTLBEvent event;
>>>> +
>>>> + if ((vtd_as->pasid != PCI_NO_PASID || pasid != rid2pasid) &&
>>>> + vtd_as->pasid != pasid) {
>>>> + continue;
>>>
>>> not quite get the logic here. patch 4 has a similar logic.
>>
>> This code means we need to invalidate device tlb either when pasid matches
>address space's pasid or when pasid matches rid2pasid if this address space has
>no pasid.
>>
>> Yes, patch4 only deal with stage-2, while this patch deal with stage-1.
>
>vtd_iotlb_page_invalidate_notify() has a similar check as well. But
>it checks PCI_NO_PASID against the pasid instead of vtd_pas->pasid.
>So it looks confusing to me.
Yes, it's about difference of piotlb invalidation vs. iotlb invalidation.
vtd_piotlb_page_invalidate() has a parameter pasid which come from piotlb
invalidation descriptor and should never be PCI_NO_PASID(-1).
For vtd_iotlb_page_invalidate_notify(), pasid param is always PCI_NO_PASID
for iotlb Invalidation, reason is iotlb invalidation doesn't support pasid.
I had ever thought about expending and reusing
vtd_iotlb_page_invalidate_notify() for
piotlb invalidation, but it's cleaner to have a separate code for piotlb
invalidation.
Thanks
Zhenzhong