Some vIOMMU fixes
v3 cover Some vIOMMU fixes
Hi,
Here is a set of vIOMMU fixes:
SMMUv3:
- top SID computation overflow when handling SMMU_CMD_CFGI_ALL
- internal IOTLB handling (changes related to range invalidation)
- smmu_iotlb_inv_iova with asid = -1
- non power of 2 invalidation range handling.
VIRTIO-IOMMU:
- non power of 2 invalidation range handling.
Best Regards
Eric
v3: https://github.com/eauger/qemu/tree/viommu_fixes_for_6-v3
v2: https://github.com/eauger/qemu/tree/viommu_fixes_for_6-v2
History:
v2 -> v3:
- Collected R-b's
- Added doc-comment for dma_aligned_pow2_mask()
- Up to now I have kept a single TTL check to avoid the remove-by-key path in smmu_iotlb_inv_iova (not checking TG)
v1 -> v2:
- new:
- dma: Introduce dma_aligned_pow2_mask()
- intel_iommu: Fix mask may be uninitialized in vtd_context_device_invalidate
- hw/arm/smmuv3: Uniformize sid traces
Eric Auger (7):
intel_iommu: Fix mask may be uninitialized in
vtd_context_device_invalidate
dma: Introduce dma_aligned_pow2_mask()
virtio-iommu: Handle non power of 2 range invalidations hw/arm/smmu-common: Fix smmu_iotlb_inv_iova when asid is not set hw/arm/smmuv3: Enforce invalidation on a power of two range hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling hw/arm/smmuv3: Uniformize sid traces
hw/arm/smmu-common.c | 32 +++++++++++++--------- hw/arm/smmu-internal.h | 5 ++++ hw/arm/smmuv3.c | 58 +++++++++++++++++++++++++++------------- hw/arm/trace-events | 24 ++++++++--------- hw/i386/intel_iommu.c | 32 +++++++--------------- hw/virtio/virtio-iommu.c | 19 ++++++++++--- include/sysemu/dma.h | 12 +++++++++ softmmu/dma-helpers.c | 26 ++++++++++++++++++ 8 files changed, 139 insertions(+), 69 deletions(-)
Signature · 1 line
2.26.2
PATCH v3 1/7 intel_iommu: Fix mask may be uninitialized in vtd_context_device_invalidate
With -Werror=maybe-uninitialized configuration we get ../hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’:../hw/i386/intel_iommu.c:1888:10: error: ‘mask’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
1888 | mask = ~mask;
| ~~~~~^~~~~~~Add a g_assert_not_reached() to avoid the error.
---
v2 -> v3:
- Added Philippe and Peter's R-b
--- hw/i386/intel_iommu.c | 2 ++ 1 file changed, 2 insertions(+)
hw/i386/intel_iommu.c +2 -0
@@ -1884,6 +1884,8 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,case 3 : mask =7 ;/* Mask bit 2:0 in the SID field */ break ; +default : +g_assert_not_reached (); } mask = ~mask;
Signature · 1 line
2.26.2
PATCH v3 2/7 dma: Introduce dma_aligned_pow2_mask()
In reply to Eric AugerCurrently get_naturally_aligned_size() is used by the intel iommu to compute the maximum invalidation range based on @size which is a power of 2 while being aligned with the @start address and less than the maximum range defined by @gaw.
This helper is also useful for other iommu devices (virtio-iommu, SMMUv3) to make sure IOMMU UNMAP notifiers only are called with power of 2 range sizes.
Let's move this latter into dma-helpers.c and rename it into dma_aligned_pow2_mask(). Also rewrite the helper so that it accomodates UINT64_MAX values for the size mask and max mask. It now returns a mask instead of a size. Change the caller.
---
v2 -> v3:
- Added doc-comment as suggested by Peter Xu and Peter Maydell
--- hw/i386/intel_iommu.c | 30 +++++++----------------------- include/sysemu/dma.h | 12 ++++++++++++ softmmu/dma-helpers.c | 26 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 23 deletions(-)
hw/i386/intel_iommu.c +7 -23
@@ -35,6 +35,7 @@#include "hw/i386/x86-iommu.h" #include "hw/pci-host/q35.h" #include "sysemu/kvm.h" +#include "sysemu/dma.h" #include "sysemu/sysemu.h" #include "hw/i386/apic_internal.h" #include "kvm/kvm_i386.h"
@@ -3455,24 +3456,6 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)return vtd_dev_as; } -static uint64_t get_naturally_aligned_size (uint64_t start, -uint64_t size,int gaw) -{ -uint64_t max_mask =1ULL << gaw; -uint64_t alignment = start ? start & -start : max_mask; - - alignment =MIN (alignment, max_mask); - size =MIN (size, max_mask); - -if (alignment <= size) { -/* Increase the alignment of start */ -return alignment; - }else { -/* Find the largest page mask from size */ -return 1ULL << (63 -clz64 (size)); - } -} -/* Unmap the whole range in the notifier's scope. */ static void vtd_address_space_unmap (VTDAddressSpace *as,IOMMUNotifier *n) {
@@ -3501,13 +3484,14 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)while (remain >=VTD_PAGE_SIZE ) {IOMMUTLBEvent event; -uint64_t mask =get_naturally_aligned_size (start, remain, s->aw_bits); +uint64_t mask =dma_aligned_pow2_mask (start, end, s->aw_bits); +uint64_t size = mask +1 ; -assert (mask); +assert (size); event.type =IOMMU_NOTIFIER_UNMAP ; event.entry.iova = start; - event.entry.addr_mask = mask -1 ; + event.entry.addr_mask = mask; event.entry.target_as = &address_space_memory; event.entry.perm =IOMMU_NONE ;/* This field is meaningless for unmap */
@@ -3515,8 +3499,8 @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)memory_region_notify_iommu_one (n, &event); - start += mask; - remain -= mask; + start += size; + remain -= size; }assert (!remain);
include/sysemu/dma.h +12 -0
@@ -296,4 +296,16 @@ uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg);void dma_acct_start (BlockBackend *blk,BlockAcctCookie *cookie,QEMUSGList *sg,enum BlockAcctType type); +/** +* dma_aligned_pow2_mask: Return the address bit mask of the largest +* power of 2 size less or equal than @end - @start + 1, aligned with @start, +* and bounded by 1 << @max_addr_bits bits. +* +* @start: range start address +* @end: range end address (greater than @start) +* @max_addr_bits: max address bits (<= 64) +*/ +uint64_t dma_aligned_pow2_mask (uint64_t start,uint64_t end, +int max_addr_bits); +#endif
softmmu/dma-helpers.c +26 -0
@@ -330,3 +330,29 @@ void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie, {block_acct_start (blk_get_stats (blk), cookie, sg->size, type); } + +uint64_t dma_aligned_pow2_mask (uint64_t start,uint64_t end,int max_addr_bits) +{ +uint64_t max_mask =UINT64_MAX , addr_mask = end - start; +uint64_t alignment_mask, size_mask; + +if (max_addr_bits !=64 ) { + max_mask = (1ULL << max_addr_bits) -1 ; + } + + alignment_mask = start ? (start & -start) -1 : max_mask; + alignment_mask =MIN (alignment_mask, max_mask); + size_mask =MIN (addr_mask, max_mask); + +if (alignment_mask <= size_mask) { +/* Increase the alignment of start */ +return alignment_mask; + }else { +/* Find the largest page mask from size */ +if (addr_mask ==UINT64_MAX ) { +return UINT64_MAX ; + } +return (1ULL << (63 -clz64 (addr_mask +1 ))) -1 ; + } +} +
Signature · 1 line
2.26.2
Re: [PATCH v3 2/7] dma: Introduce dma_aligned_pow2_mask()
Quoted 9 lines · Eric Auger
Currently
get_naturally_aligned_size()is used by the intel iommu to compute the maximum invalidation range based on @size which is a power of 2 while being aligned with the @start address and less than the maximum range defined by @gaw.This helper is also useful for other iommu devices (virtio-iommu, SMMUv3) to make sure IOMMU UNMAP notifiers only are called with power of 2 range sizes.
Quoted 6 lines
Let's move this latter into
dma-helpers.cand rename it intodma_aligned_pow2_mask(). Also rewrite the helper so that it accomodatesUINT64_MAXvalues for the size mask and max mask. It now returns a mask instead of a size. Change the caller.Signed-off-by Eric Auger <[email protected]>
Signature · 1 line
Peter Xu
PATCH v3 3/7 virtio-iommu: Handle non power of 2 range invalidations
In reply to Eric AugerUnmap notifiers work with an address mask assuming an invalidation range of a power of 2. Nothing mandates this in the VIRTIO-IOMMU spec.
So in case the range is not a power of 2, split it into several invalidations.
---
v2 -> v3:
- added Peter's R-b
--- hw/virtio/virtio-iommu.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
hw/virtio/virtio-iommu.c +16 -3
@@ -155,6 +155,7 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, hwaddr virt_end) {IOMMUTLBEvent event; +uint64_t delta = virt_end - virt_start;if (!(mr->iommu_notify_flags &IOMMU_NOTIFIER_UNMAP )) {return ;
@@ -164,12 +165,24 @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start, event.type =IOMMU_NOTIFIER_UNMAP ; event.entry.target_as = &address_space_memory; - event.entry.addr_mask = virt_end - virt_start; - event.entry.iova = virt_start; event.entry.perm =IOMMU_NONE ; event.entry.translated_addr =0 ; + event.entry.addr_mask = delta; + event.entry.iova = virt_start; -memory_region_notify_iommu (mr,0 , event); +if (delta ==UINT64_MAX ) { +memory_region_notify_iommu (mr,0 , event); + } + + +while (virt_start != virt_end +1 ) { +uint64_t mask =dma_aligned_pow2_mask (virt_start, virt_end,64 ); + + event.entry.addr_mask = mask; + event.entry.iova = virt_start; +memory_region_notify_iommu (mr,0 , event); + virt_start += mask +1 ; + } } static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value,
Signature · 1 line
2.26.2
PATCH v3 4/7 hw/arm/smmu-common: Fix smmu_iotlb_inv_iova when asid is not set
In reply to Eric AugerIf the asid is not set, do not attempt to locate the key directly as all inserted keys have a valid asid.
Use g_hash_table_foreach_remove instead.
--- hw/arm/smmu-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/smmu-common.c +1 -1
@@ -151,7 +151,7 @@ inline void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl) { -if (ttl && (num_pages ==1 )) { +if (ttl && (num_pages ==1 ) && (asid >=0 )) {SMMUIOTLBKey key =smmu_get_iotlb_key (asid, iova, tg, ttl);g_hash_table_remove (s->iotlb, &key);
Signature · 1 line
2.26.2
PATCH v3 5/7 hw/arm/smmuv3: Enforce invalidation on a power of two range
In reply to Eric AugerAs of today, the driver can invalidate a number of pages that is not a power of 2. However IOTLB unmap notifications and internal IOTLB invalidations work with masks leading to erroneous invalidations.
In case the range is not a power of 2, split invalidations into power of 2 invalidations.
When looking for a single page entry in the vSMMU internal IOTLB, let's make sure that if the entry is not found using a g_hash_table_remove() we iterate over all the entries to find a potential range that overlaps it.
--- hw/arm/smmu-common.c | 30 ++++++++++++++++++------------ hw/arm/smmuv3.c | 24 ++++++++++++++++++++---- 2 files changed, 38 insertions(+), 16 deletions(-)
hw/arm/smmu-common.c +18 -12
@@ -151,22 +151,28 @@ inline void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova, uint8_t tg, uint64_t num_pages, uint8_t ttl) { +/* if tg is not set we use 4KB range invalidation */ +uint8_t granule = tg ? tg *2 +10 :12 ; +if (ttl && (num_pages ==1 ) && (asid >=0 )) {SMMUIOTLBKey key =smmu_get_iotlb_key (asid, iova, tg, ttl); -g_hash_table_remove (s->iotlb, &key); - }else { -/* if tg is not set we use 4KB range invalidation */ -uint8_t granule = tg ? tg *2 +10 :12 ; - -SMMUIOTLBPageInvInfo info = { - .asid = asid, .iova = iova, - .mask = (num_pages *1 << granule) -1 }; - -g_hash_table_foreach_remove (s->iotlb, - smmu_hash_remove_by_asid_iova, - &info); +if (g_hash_table_remove (s->iotlb, &key)) { +return ; + } +/* +* if the entry is not found, let's see if it does not +* belong to a larger IOTLB entry +*/ } + +SMMUIOTLBPageInvInfo info = { + .asid = asid, .iova = iova, + .mask = (num_pages *1 << granule) -1 }; + +g_hash_table_foreach_remove (s->iotlb, + smmu_hash_remove_by_asid_iova, + &info); }inline void smmu_iotlb_inv_asid (SMMUState *s,uint16_t asid)
hw/arm/smmuv3.c +20 -4
@@ -861,7 +861,8 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)uint16_t vmid =CMD_VMID (cmd);bool leaf =CMD_LEAF (cmd);uint8_t tg =CMD_TG (cmd); -hwaddr num_pages =1 ; +uint64_t first_page =0 , last_page; +uint64_t num_pages =1 ;int asid =-1 ;if (tg) {
@@ -874,9 +875,24 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)if (type ==SMMU_CMD_TLBI_NH_VA ) { asid =CMD_ASID (cmd); } -trace_smmuv3_s1_range_inval (vmid, asid, addr, tg, num_pages, ttl, leaf); -smmuv3_inv_notifiers_iova (s, asid, addr, tg, num_pages); -smmu_iotlb_inv_iova (s, asid, addr, tg, num_pages, ttl); + +/* Split invalidations into ^2 range invalidations */ + last_page = num_pages -1 ; +while (num_pages) { +uint8_t granule = tg *2 +10 ; +uint64_t mask, count; + + mask =dma_aligned_pow2_mask (first_page, last_page,64 - granule); + count = mask +1 ; + +trace_smmuv3_s1_range_inval (vmid, asid, addr, tg, count, ttl, leaf); +smmuv3_inv_notifiers_iova (s, asid, addr, tg, count); +smmu_iotlb_inv_iova (s, asid, addr, tg, count, ttl); + + num_pages -= count; + first_page += count; + addr += count *BIT_ULL (granule); + } }static int smmuv3_cmdq_consume (SMMUv3State *s)
Signature · 1 line
2.26.2
PATCH v3 6/7 hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling
In reply to Eric AugerIf the whole SID range (32b) is invalidated (SMMU_CMD_CFGI_ALL), @end overflows and we fail to handle the command properly.
Once this gets fixed, the current code really is awkward in the sense it loops over the whole range instead of removing the currently cached configs through a hash table lookup.
Fix both the overflow and the lookup.
---
Added Peter's R-b
--- hw/arm/smmu-internal.h | 5 +++++ hw/arm/smmuv3.c | 34 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-)
hw/arm/smmu-internal.h +5 -0
@@ -104,4 +104,9 @@ typedef struct SMMUIOTLBPageInvInfo { uint64_t mask; } SMMUIOTLBPageInvInfo; +typedef struct SMMUSIDRange { +uint32_t start; +uint32_t end; +}SMMUSIDRange ; +#endif
hw/arm/smmuv3.c +20 -14
@@ -32,6 +32,7 @@#include "hw/arm/smmuv3.h" #include "smmuv3-internal.h" +#include "smmu-internal.h" /** * smmuv3_trigger_irq - pulse @irq if enabled and update
@@ -895,6 +896,20 @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd) } } +static gboolean +smmuv3_invalidate_ste (gpointer key,gpointer value,gpointer user_data) +{ +SMMUDevice *sdev = (SMMUDevice *)key; +uint32_t sid =smmu_get_sid (sdev); +SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data; + +if (sid < sid_range->start || sid > sid_range->end) { +return false; + } +trace_smmuv3_config_cache_inv (sid); +return true; +} +static int smmuv3_cmdq_consume (SMMUv3State *s) {SMMUState *bs =ARM_SMMU (s);
@@ -965,27 +980,18 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) }case SMMU_CMD_CFGI_STE_RANGE :/* same as SMMU_CMD_CFGI_ALL */ { -uint32_t start =CMD_SID (&cmd), end, i; +uint32_t start =CMD_SID (&cmd);uint8_t range =CMD_STE_RANGE (&cmd); +uint64_t end = start + (1ULL << (range +1 )) -1 ; +SMMUSIDRange sid_range = {start, end};if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; } - - end = start + (1 << (range +1 )) -1 ;trace_smmuv3_cmdq_cfgi_ste_range (start, end); - -for (i = start; i <= end; i++) { -IOMMUMemoryRegion *mr =smmu_iommu_mr (bs, i); -SMMUDevice *sdev; - -if (!mr) { -continue ; - } - sdev =container_of (mr, SMMUDevice, iommu); -smmuv3_flush_config (sdev); - } +g_hash_table_foreach_remove (bs->configs, smmuv3_invalidate_ste, + &sid_range);break ; }case SMMU_CMD_CFGI_CD :
Signature · 1 line
2.26.2
Re: [PATCH v3 6/7] hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling
Quoted 11 lines · Eric Auger
If the whole SID range (32b) is invalidated (
SMMU_CMD_CFGI_ALL), @end overflows and we fail to handle the command properly.Once this gets fixed, the current code really is awkward in the sense it loops over the whole range instead of removing the currently cached configs through a hash table lookup.
Fix both the overflow and the lookup.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Peter Maydell <[email protected]>
Not much to do with this patch, but maybe we can take the fix a little further. We now take StreamID as the start of the invalidation range, regardless of whatever the Range is, whilst the spec clearly states that "the StreamID parameter (of *CMD_CFGI_ALL* command) is IGNORED". If there are some random bits in the StreamID field (who knows), we'll fail to perform the full invalidation but get a strange range (e.g., SMMUSIDRange={.start=1, .end=0}) instead.
And having looked at the spec again, 4.3.2 CMD_CFGI_STE_RANGE:
- "Invalidation is performed for an *aligned* range of 2^(Range+1) StreamIDs."
- "The bottom Range+1 bits of the StreamID parameter are IGNORED, aligning the range to its size."
which seems to be some bits that we had never taken into account. And what I'm saying is roughly something like below (compile tested), any thoughts?
hw/arm/smmuv3.c +8 -4
@@ -980,16 +980,20 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) }case SMMU_CMD_CFGI_STE_RANGE :/* same as SMMU_CMD_CFGI_ALL */ { -uint32_t start =CMD_SID (&cmd); +uint32_t sid =CMD_SID (&cmd), mask;uint8_t range =CMD_STE_RANGE (&cmd); -uint64_t end = start + (1ULL << (range +1 )) -1 ; -SMMUSIDRange sid_range = {start, end}; +SMMUSIDRange sid_range;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; } -trace_smmuv3_cmdq_cfgi_ste_range (start, end); + + mask = (1ULL << (range +1 )) -1 ; + sid_range.start = sid & ~mask; + sid_range.end = sid_range.start + mask; + +trace_smmuv3_cmdq_cfgi_ste_range (sid_range.start, sid_range.end); g_hash_table_foreach_remove(bs->configs,
smmuv3_invalidate_ste,
&sid_range);
break;Re: [PATCH v3 6/7] hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling
Hi Zenghui,
Quoted 60 lines · Zenghui Yu
Quoted 11 lines · Eric Auger
If the whole SID range (32b) is invalidated (
SMMU_CMD_CFGI_ALL), @end overflows and we fail to handle the command properly.Once this gets fixed, the current code really is awkward in the sense it loops over the whole range instead of removing the currently cached configs through a hash table lookup.
Fix both the overflow and the lookup.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Peter Maydell <[email protected]>Not much to do with this patch, but maybe we can take the fix a little further. We now take StreamID as the start of the invalidation range, regardless of whatever the Range is, whilst the spec clearly states that "the StreamID parameter (of *CMD_CFGI_ALL* command) is IGNORED". If there are some random bits in the StreamID field (who knows), we'll fail to perform the full invalidation but get a strange range (e.g., SMMUSIDRange={.start=1, .end=0}) instead.
And having looked at the spec again, 4.3.2
CMD_CFGI_STE_RANGE:- "Invalidation is performed for an *aligned* range of 2^(Range+1) StreamIDs."
- "The bottom Range+1 bits of the StreamID parameter are IGNORED, aligning the range to its size."
which seems to be some bits that we had never taken into account. And what I'm saying is roughly something like below (compile tested), any thoughts?
hw/arm/smmuv3.c +0
-0@@ -980,16 +980,20 @@ static int smmuv3_cmdq_consume(SMMUv3State *s) }case
SMMU_CMD_CFGI_STE_RANGE: /* same asSMMU_CMD_CFGI_ALL*/ {
-uint32_tstart =CMD_SID(&cmd);
+uint32_tsid =CMD_SID(&cmd), mask;
uint8_trange =CMD_STE_RANGE(&cmd);
-uint64_tend = start + (1ULL << (range + 1)) - 1; - SMMUSIDRangesid_range= {start, end};
+ SMMUSIDRangesid_range;if (
CMD_SSEC(&cmd)) {
cmd_error=SMMU_CERROR_ILL; break;
}
-trace_smmuv3_cmdq_cfgi_ste_range(start, end);hw/arm/smmuv3.c +6
-0+ + mask = (1ULL << (range + 1)) - 1; + sid_range.start = sid & ~mask; + sid_range.end = sid_range.start + mask; + + trace_smmuv3_cmdq_cfgi_ste_range(sid_range.start,
Quoted 6 lines
sid_range.end); g_hash_table_foreach_remove(bs->configs,
smmuv3_invalidate_ste,
&sid_range); break;
Thanks for spotting this discrepancy with the spec. This looks good to me, please feel free to then the patch.
Thanks
Eric
Re: [PATCH v3 6/7] hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling
Quoted 6 lines · Auger Eric
Hi Zenghui,
Quoted 3 lines · Zenghui Yu
which seems to be some bits that we had never taken into account. And what I'm saying is roughly something like below (compile tested), any thoughts?
[...]
Quoted 2 lines
Thanks for spotting this discrepancy with the spec. This looks good to me, please feel free to then the patch.
Okay, I'll have a patch for that. Thanks Eric.
Zenghui
PATCH v3 7/7 hw/arm/smmuv3: Uniformize sid traces
In reply to Eric AugerConvert all sid printouts to sid=0x%x.
---
v2 -> v3:
- added Philippe's R-b
--- hw/arm/trace-events | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
hw/arm/trace-events +12 -12
@@ -29,26 +29,26 @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s" smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d " smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d" smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)" -smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d" -smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x" +smmuv3_record_event(const char *type, uint32_t sid) "%s sid=0x%x" +smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x" smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d" smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64 -smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" -smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d" -smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d" -smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" +smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x STE bypass iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x abort on iova:0x%"PRIx64" is_write=%d" +smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=0x%x iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x" smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64 smmuv3_decode_cd(uint32_t oas) "oas=%d" smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz, bool had) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d had:%d" -smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d" +smmuv3_cmdq_cfgi_ste(int streamid) "streamid= 0x%x" smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x" -smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d" -smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)" -smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)" -smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" +smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x" +smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" +smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)" +smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d" smmuv3_cmdq_tlbi_nh(void) "" smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d" -smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d" +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_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
Signature · 1 line
2.26.2
Peter Maydell
AppliedQuoted 5 lines · Eric Auger
Hi,
Here is a set of vIOMMU fixes:
Quoted 8 lines
SMMUv3:
- top SID computation overflow when handlingSMMU_CMD_CFGI_ALL
- internal IOTLB handling (changes related to range invalidation)
-smmu_iotlb_inv_iovawith asid = -1
- non power of 2 invalidation range handling.VIRTIO-IOMMU:
- non power of 2 invalidation range handling.
Applied to target-arm.next, thanks.
-- PMM