mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
hw/arm/smmuv3: Add stage-2 support in iova notifier
In smmuv3_notify_iova, read the granule based on translation stage and use VMID if valid value is sent. Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Tested-by: Eric Auger <eric.auger@redhat.com> Tested-by: Jean-Philippe Brucker <jean-philippe@linaro.org> Message-id: 20230516203327.2051088-10-smostafa@google.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
parent
ccc3ee3871
commit
32bd7baec2
2 changed files with 27 additions and 14 deletions
|
@ -1000,18 +1000,21 @@ epilogue:
|
||||||
* @mr: IOMMU mr region handle
|
* @mr: IOMMU mr region handle
|
||||||
* @n: notifier to be called
|
* @n: notifier to be called
|
||||||
* @asid: address space ID or negative value if we don't care
|
* @asid: address space ID or negative value if we don't care
|
||||||
|
* @vmid: virtual machine ID or negative value if we don't care
|
||||||
* @iova: iova
|
* @iova: iova
|
||||||
* @tg: translation granule (if communicated through range invalidation)
|
* @tg: translation granule (if communicated through range invalidation)
|
||||||
* @num_pages: number of @granule sized pages (if tg != 0), otherwise 1
|
* @num_pages: number of @granule sized pages (if tg != 0), otherwise 1
|
||||||
*/
|
*/
|
||||||
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
IOMMUNotifier *n,
|
IOMMUNotifier *n,
|
||||||
int asid, dma_addr_t iova,
|
int asid, int vmid,
|
||||||
uint8_t tg, uint64_t num_pages)
|
dma_addr_t iova, uint8_t tg,
|
||||||
|
uint64_t num_pages)
|
||||||
{
|
{
|
||||||
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
|
||||||
IOMMUTLBEvent event;
|
IOMMUTLBEvent event;
|
||||||
uint8_t granule;
|
uint8_t granule;
|
||||||
|
SMMUv3State *s = sdev->smmu;
|
||||||
|
|
||||||
if (!tg) {
|
if (!tg) {
|
||||||
SMMUEventInfo event = {.inval_ste_allowed = true};
|
SMMUEventInfo event = {.inval_ste_allowed = true};
|
||||||
|
@ -1026,11 +1029,20 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tt = select_tt(cfg, iova);
|
if (vmid >= 0 && cfg->s2cfg.vmid != vmid) {
|
||||||
if (!tt) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
granule = tt->granule_sz;
|
|
||||||
|
if (STAGE1_SUPPORTED(s)) {
|
||||||
|
tt = select_tt(cfg, iova);
|
||||||
|
if (!tt) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
granule = tt->granule_sz;
|
||||||
|
} else {
|
||||||
|
granule = cfg->s2cfg.granule_sz;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
granule = tg * 2 + 10;
|
granule = tg * 2 + 10;
|
||||||
}
|
}
|
||||||
|
@ -1044,9 +1056,10 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
|
||||||
memory_region_notify_iommu_one(n, &event);
|
memory_region_notify_iommu_one(n, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalidate an asid/iova range tuple in all mr's */
|
/* invalidate an asid/vmid/iova range tuple in all mr's */
|
||||||
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, int vmid,
|
||||||
uint8_t tg, uint64_t num_pages)
|
dma_addr_t iova, uint8_t tg,
|
||||||
|
uint64_t num_pages)
|
||||||
{
|
{
|
||||||
SMMUDevice *sdev;
|
SMMUDevice *sdev;
|
||||||
|
|
||||||
|
@ -1054,11 +1067,11 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova,
|
||||||
IOMMUMemoryRegion *mr = &sdev->iommu;
|
IOMMUMemoryRegion *mr = &sdev->iommu;
|
||||||
IOMMUNotifier *n;
|
IOMMUNotifier *n;
|
||||||
|
|
||||||
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova,
|
trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, vmid,
|
||||||
tg, num_pages);
|
iova, tg, num_pages);
|
||||||
|
|
||||||
IOMMU_NOTIFIER_FOREACH(n, mr) {
|
IOMMU_NOTIFIER_FOREACH(n, mr) {
|
||||||
smmuv3_notify_iova(mr, n, asid, iova, tg, num_pages);
|
smmuv3_notify_iova(mr, n, asid, vmid, iova, tg, num_pages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1089,7 +1102,7 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
|
||||||
if (!tg) {
|
if (!tg) {
|
||||||
trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
|
trace_smmuv3_range_inval(vmid, asid, addr, tg, 1, ttl, leaf);
|
||||||
smmuv3_inv_notifiers_iova(s, asid, addr, tg, 1);
|
smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, 1);
|
||||||
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
|
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, 1, ttl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1107,7 +1120,7 @@ static void smmuv3_range_inval(SMMUState *s, Cmd *cmd)
|
||||||
|
|
||||||
num_pages = (mask + 1) >> granule;
|
num_pages = (mask + 1) >> granule;
|
||||||
trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
|
trace_smmuv3_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
|
||||||
smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
|
smmuv3_inv_notifiers_iova(s, asid, vmid, addr, tg, num_pages);
|
||||||
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
|
smmu_iotlb_inv_iova(s, asid, vmid, addr, tg, num_pages, ttl);
|
||||||
addr += mask + 1;
|
addr += mask + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,5 +53,5 @@ smmuv3_cmdq_tlbi_s12_vmid(uint16_t vmid) "vmid=%d"
|
||||||
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
|
||||||
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
|
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
|
||||||
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
|
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
|
||||||
smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
|
smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint16_t vmid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d vmid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue