Skip to content

Commit 2c91bcf

Browse files
committed
iommu: Add IOMMU index argument to translate method
Add an IOMMU index argument to the translate method of IOMMUs. Since all of our current IOMMU implementations support only a single IOMMU index, this has no effect on the behaviour. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20180604152941.20374-4-peter.maydell@linaro.org
1 parent cb1efcf commit 2c91bcf

File tree

12 files changed

+24
-13
lines changed

12 files changed

+24
-13
lines changed

exec.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,15 @@ static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion *iomm
501501
do {
502502
hwaddr addr = *xlat;
503503
IOMMUMemoryRegionClass *imrc = memory_region_get_iommu_class_nocheck(iommu_mr);
504-
IOMMUTLBEntry iotlb = imrc->translate(iommu_mr, addr, is_write ?
505-
IOMMU_WO : IOMMU_RO);
504+
int iommu_idx = 0;
505+
IOMMUTLBEntry iotlb;
506+
507+
if (imrc->attrs_to_index) {
508+
iommu_idx = imrc->attrs_to_index(iommu_mr, attrs);
509+
}
510+
511+
iotlb = imrc->translate(iommu_mr, addr, is_write ?
512+
IOMMU_WO : IOMMU_RO, iommu_idx);
506513

507514
if (!(iotlb.perm & (1 << is_write))) {
508515
goto unassigned;

hw/alpha/typhoon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ static bool window_translate(TyphoonWindow *win, hwaddr addr,
666666
Pchip and generate a machine check interrupt. */
667667
static IOMMUTLBEntry typhoon_translate_iommu(IOMMUMemoryRegion *iommu,
668668
hwaddr addr,
669-
IOMMUAccessFlags flag)
669+
IOMMUAccessFlags flag,
670+
int iommu_idx)
670671
{
671672
TyphoonPchip *pchip = container_of(iommu, TyphoonPchip, iommu);
672673
IOMMUTLBEntry ret;

hw/arm/smmuv3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static int smmuv3_decode_config(IOMMUMemoryRegion *mr, SMMUTransCfg *cfg,
538538
}
539539

540540
static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,
541-
IOMMUAccessFlags flag)
541+
IOMMUAccessFlags flag, int iommu_idx)
542542
{
543543
SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
544544
SMMUv3State *s = sdev->smmu;

hw/dma/rc4030.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ static const MemoryRegionOps jazzio_ops = {
491491
};
492492

493493
static IOMMUTLBEntry rc4030_dma_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
494-
IOMMUAccessFlags flag)
494+
IOMMUAccessFlags flag, int iommu_idx)
495495
{
496496
rc4030State *s = container_of(iommu, rc4030State, dma_mr);
497497
IOMMUTLBEntry ret = {

hw/i386/amd_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static inline bool amdvi_is_interrupt_addr(hwaddr addr)
991991
}
992992

993993
static IOMMUTLBEntry amdvi_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
994-
IOMMUAccessFlags flag)
994+
IOMMUAccessFlags flag, int iommu_idx)
995995
{
996996
AMDVIAddressSpace *as = container_of(iommu, AMDVIAddressSpace, iommu);
997997
AMDVIState *s = as->iommu_state;

hw/i386/intel_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2471,7 +2471,7 @@ static void vtd_mem_write(void *opaque, hwaddr addr,
24712471
}
24722472

24732473
static IOMMUTLBEntry vtd_iommu_translate(IOMMUMemoryRegion *iommu, hwaddr addr,
2474-
IOMMUAccessFlags flag)
2474+
IOMMUAccessFlags flag, int iommu_idx)
24752475
{
24762476
VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
24772477
IntelIOMMUState *s = vtd_as->iommu_state;

hw/ppc/spapr_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ static void spapr_tce_free_table(uint64_t *table, int fd, uint32_t nb_table)
112112
/* Called from RCU critical section */
113113
static IOMMUTLBEntry spapr_tce_translate_iommu(IOMMUMemoryRegion *iommu,
114114
hwaddr addr,
115-
IOMMUAccessFlags flag)
115+
IOMMUAccessFlags flag,
116+
int iommu_idx)
116117
{
117118
sPAPRTCETable *tcet = container_of(iommu, sPAPRTCETable, iommu);
118119
uint64_t tce;

hw/s390x/s390-pci-bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ uint16_t s390_guest_io_table_walk(uint64_t g_iota, hwaddr addr,
484484
}
485485

486486
static IOMMUTLBEntry s390_translate_iommu(IOMMUMemoryRegion *mr, hwaddr addr,
487-
IOMMUAccessFlags flag)
487+
IOMMUAccessFlags flag, int iommu_idx)
488488
{
489489
S390PCIIOMMU *iommu = container_of(mr, S390PCIIOMMU, iommu_mr);
490490
S390IOTLBEntry *entry;

hw/sparc/sun4m_iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ static void iommu_bad_addr(IOMMUState *s, hwaddr addr,
282282
/* Called from RCU critical section */
283283
static IOMMUTLBEntry sun4m_translate_iommu(IOMMUMemoryRegion *iommu,
284284
hwaddr addr,
285-
IOMMUAccessFlags flags)
285+
IOMMUAccessFlags flags,
286+
int iommu_idx)
286287
{
287288
IOMMUState *is = container_of(iommu, IOMMUState, iommu);
288289
hwaddr page, pa;

hw/sparc64/sun4u_iommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
/* Called from RCU critical section */
7474
static IOMMUTLBEntry sun4u_translate_iommu(IOMMUMemoryRegion *iommu,
7575
hwaddr addr,
76-
IOMMUAccessFlags flag)
76+
IOMMUAccessFlags flag, int iommu_idx)
7777
{
7878
IOMMUState *is = container_of(iommu, IOMMUState, iommu);
7979
hwaddr baseaddr, offset;

0 commit comments

Comments
 (0)