mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
intel_iommu: Set address mask when a translation fails and adjust W permission
Implements the behavior defined in section 10.2.3.5 of PCIe spec rev 5. This is needed by devices that support ATS. Signed-off-by: Clement Mathieu--Drif <clement.mathieu--drif@eviden.com> Message-Id: <20250628180226.133285-10-clement.mathieu--drif@eviden.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
35b47759c7
commit
580b926344
@@ -2091,7 +2091,8 @@ static bool vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
|
||||
uint8_t bus_num = pci_bus_num(bus);
|
||||
VTDContextCacheEntry *cc_entry;
|
||||
uint64_t pte, page_mask;
|
||||
uint32_t level, pasid = vtd_as->pasid;
|
||||
uint32_t level = UINT32_MAX;
|
||||
uint32_t pasid = vtd_as->pasid;
|
||||
uint16_t source_id = PCI_BUILD_BDF(bus_num, devfn);
|
||||
int ret_fr;
|
||||
bool is_fpd_set = false;
|
||||
@@ -2250,14 +2251,19 @@ out:
|
||||
entry->iova = addr & page_mask;
|
||||
entry->translated_addr = vtd_get_pte_addr(pte, s->aw_bits) & page_mask;
|
||||
entry->addr_mask = ~page_mask;
|
||||
entry->perm = access_flags;
|
||||
entry->perm = (is_write ? access_flags : (access_flags & (~IOMMU_WO)));
|
||||
return true;
|
||||
|
||||
error:
|
||||
vtd_iommu_unlock(s);
|
||||
entry->iova = 0;
|
||||
entry->translated_addr = 0;
|
||||
entry->addr_mask = 0;
|
||||
/*
|
||||
* Set the mask for ATS (the range must be present even when the
|
||||
* translation fails : PCIe rev 5 10.2.3.5)
|
||||
*/
|
||||
entry->addr_mask = (level != UINT32_MAX) ?
|
||||
(~vtd_pt_level_page_mask(level)) : (~VTD_PAGE_MASK_4K);
|
||||
entry->perm = IOMMU_NONE;
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user