ARM SMMUv3: Fix spurious notification errors and assert with vfio
v3 cover ARM SMMUv3: Fix spurious notification errors and assert with vfio
As of today when a guest is assigned with a host PCI device and an SMMUv3, VFIO calls memory_region_iommu_replay() default implementation. This translates the whole address range and completely stalls the execution. As VFIO/SMMUv3 integration is not supported yet (it requires SMMUv3 HW nested paging), let's recognize this situation and simply assert.
Also the series silences some spurious translation configuration decoding errors (STE out of span or invalid STE) that may happen on guest IOVA invalidation notifications.
Best Regards
Eric
Eric Auger (5):
memory: Remove unused memory_region_iommu_replay_all()
memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute hw/vfio/common: Assert in case of nested mode hw/arm/smmuv3: Log a guest error when decoding an invalid STE hw/arm/smmuv3: Remove spurious error messages on IOVA invalidations
hw/arm/smmuv3-internal.h | 1 + hw/arm/smmuv3.c | 26 ++++++++++++++++++++------ hw/vfio/common.c | 8 ++++++++ include/exec/memory.h | 13 ++----------- memory.c | 9 --------- 5 files changed, 31 insertions(+), 26 deletions(-)
Signature · 1 line
2.20.1
PATCH v3 1/5 memory: Remove unused memory_region_iommu_replay_all()
memory_region_iommu_replay_all is not used. Remove it.
--- include/exec/memory.h | 10 ---------- memory.c | 9 --------- 2 files changed, 19 deletions(-)
include/exec/memory.h +0 -10
@@ -1076,16 +1076,6 @@ void memory_region_register_iommu_notifier(MemoryRegion *mr,*/ void memory_region_iommu_replay (IOMMUMemoryRegion *iommu_mr,IOMMUNotifier *n); -/** -* memory_region_iommu_replay_all: replay existing IOMMU translations -* to all the notifiers registered. -* -* Note: this is not related to record-and-replay functionality. -* -* @iommu_mr: the memory region to observe -*/ -void memory_region_iommu_replay_all (IOMMUMemoryRegion *iommu_mr); -/** * memory_region_unregister_iommu_notifier: unregister a notifier for * changes to IOMMU translation entries.
memory.c +0 -9
@@ -1910,15 +1910,6 @@ void memory_region_iommu_replay(IOMMUMemoryRegion *iommu_mr, IOMMUNotifier *n) } } -void memory_region_iommu_replay_all (IOMMUMemoryRegion *iommu_mr) -{ -IOMMUNotifier *notifier; - - IOMMU_NOTIFIER_FOREACH(notifier, iommu_mr) { -memory_region_iommu_replay (iommu_mr, notifier); - } -} -void memory_region_unregister_iommu_notifier (MemoryRegion *mr,IOMMUNotifier *n) {
Signature · 1 line
2.20.1
PATCH v3 2/5 memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute
In reply to Eric AugerWe introduce a new IOMMU Memory Region attribute, IOMMU_ATTR_VFIO_NESTED that tells whether the virtual IOMMU requires HW nested paging for VFIO integration.
Current Intel virtual IOMMU device supports "Caching Mode" and does not require 2 stages at physical level to be integrated with VFIO. However SMMUv3 does not implement such "caching mode" and requires to use HW nested paging.
As such SMMUv3 is the first IOMMU device to advertise this attribute.
--- hw/arm/smmuv3.c | 12 ++++++++++++ include/exec/memory.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)
hw/arm/smmuv3.c +12 -0
@@ -1490,6 +1490,17 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, } } +static int smmuv3_get_attr (IOMMUMemoryRegion *iommu, +enum IOMMUMemoryRegionAttr attr, +void *data) +{ +if (attr ==IOMMU_ATTR_VFIO_NESTED ) { + *(bool *) data = true; +return 0 ; + } +return -EINVAL ; +} +static void smmuv3_iommu_memory_region_class_init (ObjectClass *klass,void *data) {
@@ -1497,6 +1508,7 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = smmuv3_translate; imrc->notify_flag_changed = smmuv3_notify_flag_changed; + imrc->get_attr = smmuv3_get_attr; }static const TypeInfo smmuv3_type_info = {
include/exec/memory.h +2 -1
@@ -204,7 +204,8 @@ struct MemoryRegionOps { };enum IOMMUMemoryRegionAttr { -IOMMU_ATTR_SPAPR_TCE_FD +IOMMU_ATTR_SPAPR_TCE_FD , +IOMMU_ATTR_VFIO_NESTED , };/**
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH-for-4.2 v3 2/5] memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute
Quoted 5 lines · Eric Auger
We introduce a new IOMMU Memory Region attribute,
IOMMU_ATTR_VFIO_NESTEDthat tells whether the virtual IOMMU requires HW nested paging for VFIO integration.
Quoted 7 lines
Current Intel virtual IOMMU device supports "Caching Mode" and does not require 2 stages at physical level to be integrated with VFIO. However SMMUv3 does not implement such "caching mode" and requires to use HW nested paging.
As such SMMUv3 is the first IOMMU device to advertise this attribute.
I'm not sure the name of the attribute really captures the intention here, though I don't have any better suggestions. Maybe IOMMU_ATTR_VFIO_NEEDS_HW_NESTED_PAGING ?
Quoted 11 lines
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3.c | 12 ++++++++++++ include/exec/memory.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)hw/arm/smmuv3.c +0
-0
hw/arm/smmuv3.c static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, · line 1498
Quoted 9 lines
hw/arm/smmuv3.c +6
-0@@ -1490,6 +1490,17 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, } } +static int smmuv3_get_attr (IOMMUMemoryRegion *iommu, +enum IOMMUMemoryRegionAttr attr, +void *data) +{ +if (attr ==IOMMU_ATTR_VFIO_NESTED ) { + *(bool *) data = true;
I'm surprised checkpatch doesn't warn about the space after the cast here.
Quoted 21 lines
hw/arm/smmuv3.c +6
-0+return 0 ; + } +return -EINVAL ; +} +static void smmuv3_iommu_memory_region_class_init (ObjectClass *klass,void *data) {@@ -1497,6 +1508,7 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = smmuv3_translate; imrc->notify_flag_changed = smmuv3_notify_flag_changed; + imrc->get_attr = smmuv3_get_attr; }static const TypeInfo smmuv3_type_info = {include/exec/memory.h +0
-0
include/exec/memory.h struct MemoryRegionOps { · line 209
Quoted 7 lines
include/exec/memory.h +2
-1@@ -204,7 +204,8 @@ struct MemoryRegionOps { };enum IOMMUMemoryRegionAttr { -IOMMU_ATTR_SPAPR_TCE_FD +IOMMU_ATTR_SPAPR_TCE_FD , +IOMMU_ATTR_VFIO_NESTED , };
Could we have a comment documenting what the attribute's meaning and semantics are, please? (including what the type is that the data pointer is expected to point to, ie 'bool'.)
(We ought also to document the spapr-specific attribute...)
thanks
-- PMM
Re: [Qemu-arm] [PATCH-for-4.2 v3 2/5] memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute
In reply to Eric AugerQuoted 53 lines · On Thu, 11 Jul 2019 08:18:54 +0200 Eric Auger <[email protected]> wrote:
We introduce a new IOMMU Memory Region attribute,
IOMMU_ATTR_VFIO_NESTEDthat tells whether the virtual IOMMU requires HW nested paging for VFIO integration.Current Intel virtual IOMMU device supports "Caching Mode" and does not require 2 stages at physical level to be integrated with VFIO. However SMMUv3 does not implement such "caching mode" and requires to use HW nested paging.
As such SMMUv3 is the first IOMMU device to advertise this attribute.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3.c | 12 ++++++++++++ include/exec/memory.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)hw/arm/smmuv3.c +12
-0@@ -1490,6 +1490,17 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, } } +static int smmuv3_get_attr (IOMMUMemoryRegion *iommu, +enum IOMMUMemoryRegionAttr attr, +void *data) +{ +if (attr ==IOMMU_ATTR_VFIO_NESTED ) { + *(bool *) data = true; +return 0 ; + } +return -EINVAL ; +} +static void smmuv3_iommu_memory_region_class_init (ObjectClass *klass,void *data) {@@ -1497,6 +1508,7 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = smmuv3_translate; imrc->notify_flag_changed = smmuv3_notify_flag_changed; + imrc->get_attr = smmuv3_get_attr; }static const TypeInfo smmuv3_type_info = {include/exec/memory.h +0
-0
include/exec/memory.h struct MemoryRegionOps { · line 211
Quoted 9 lines
include/exec/memory.h +2
-1@@ -204,7 +204,8 @@ struct MemoryRegionOps { };enum IOMMUMemoryRegionAttr { -IOMMU_ATTR_SPAPR_TCE_FD +IOMMU_ATTR_SPAPR_TCE_FD , +IOMMU_ATTR_VFIO_NESTED , };/**
Why VFIO_NESTED vs simply NESTED? I figure any time we need to include "VFIO" in the descriptions of something, we're probably not describing the requirement correctly and it just becomes a meaningless tag that gets ignored outside of VFIO related things. If we're trying to describe an IOMMU MemoryRegion that supports dynamic faulting rather than requiring a replay to pre-populate it, then simply define that semantic rather than hand waving some vfio specific interaction. Thanks,
Alex
Re: [Qemu-devel] [PATCH-for-4.2 v3 2/5] memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute
Hi Alex, Peter,
Quoted 64 lines · Alex Williamson
Quoted 61 lines · On Thu, 11 Jul 2019 08:18:54 +0200 Eric Auger <[email protected]> wrote:
We introduce a new IOMMU Memory Region attribute,
IOMMU_ATTR_VFIO_NESTEDthat tells whether the virtual IOMMU requires HW nested paging for VFIO integration.Current Intel virtual IOMMU device supports "Caching Mode" and does not require 2 stages at physical level to be integrated with VFIO. However SMMUv3 does not implement such "caching mode" and requires to use HW nested paging.
As such SMMUv3 is the first IOMMU device to advertise this attribute.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3.c | 12 ++++++++++++ include/exec/memory.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)hw/arm/smmuv3.c +12
-0@@ -1490,6 +1490,17 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, } } +static int smmuv3_get_attr (IOMMUMemoryRegion *iommu, +enum IOMMUMemoryRegionAttr attr, +void *data) +{ +if (attr ==IOMMU_ATTR_VFIO_NESTED ) { + *(bool *) data = true; +return 0 ; + } +return -EINVAL ; +} +static void smmuv3_iommu_memory_region_class_init (ObjectClass *klass,void *data) {@@ -1497,6 +1508,7 @@ static void smmuv3_iommu_memory_region_class_init(ObjectClass *klass, imrc->translate = smmuv3_translate; imrc->notify_flag_changed = smmuv3_notify_flag_changed; + imrc->get_attr = smmuv3_get_attr; }static const TypeInfo smmuv3_type_info = {include/exec/memory.h +2
-1@@ -204,7 +204,8 @@ struct MemoryRegionOps { };enum IOMMUMemoryRegionAttr { -IOMMU_ATTR_SPAPR_TCE_FD +IOMMU_ATTR_SPAPR_TCE_FD , +IOMMU_ATTR_VFIO_NESTED , };
Quoted 10 lines
include/exec/memory.h struct MemoryRegionOps { · line 211
Quoted 1 line
include/exec/memory.h +0
-0/** Why
VFIO_NESTEDvs simply NESTED? I figure any time we need to include "VFIO" in the descriptions of something, we're probably not describing the requirement correctly and it just becomes a meaningless tag that gets ignored outside of VFIO related things. If we're trying to describe an IOMMU MemoryRegion that supports dynamic faulting rather than requiring a replay to pre-populate it, then simply define that semantic rather than hand waving some vfio specific interaction. Thanks,
I replaced it by IOMMU_ATTR_HW_NESTED_PAGING instead.
Thanks
Eric
Quoted 3 lines
Alex
PATCH v3 3/5 hw/vfio/common: Assert in case of nested mode
In reply to Eric AugerAs of today, VFIO only works along with vIOMMU supporting caching mode. The SMMUv3 does not support this mode and requires HW nested paging to work properly with VFIO.
So any attempt to run a VFIO device protected by such IOMMU would prevent the assigned device from working and at the moment the guest does not even boot as the default memory_region_iommu_replay() implementation attempts to translate the whole address space and completely stalls the execution.
So let's assert if we recognize nested mode case.
--- hw/vfio/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)
hw/vfio/common.c +8 -0
@@ -604,9 +604,17 @@ static void vfio_listener_region_add(MemoryListener *listener,if (memory_region_is_iommu (section->mr)) {VFIOGuestIOMMU *giommu;IOMMUMemoryRegion *iommu_mr =IOMMU_MEMORY_REGION (section->mr); +bool nested;int iommu_idx;trace_vfio_listener_region_add_iommu (iova, end); + +if (!memory_region_iommu_get_attr (iommu_mr,IOMMU_ATTR_VFIO_NESTED , + (void *)&nested) && nested) { +error_report ("VFIO/vIOMMU integration based on HW nested paging " +"is not yet supported" ); +abort (); + }/* * FIXME: For VFIO iommu types which have KVM acceleration to * avoid bouncing all map/unmaps through qemu this way, this
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH-for-4.2 v3 3/5] hw/vfio/common: Assert in case of nested mode
Quoted 31 lines · Eric Auger
As of today, VFIO only works along with vIOMMU supporting caching mode. The SMMUv3 does not support this mode and requires HW nested paging to work properly with VFIO.
So any attempt to run a VFIO device protected by such IOMMU would prevent the assigned device from working and at the moment the guest does not even boot as the default
memory_region_iommu_replay()implementation attempts to translate the whole address space and completely stalls the execution.So let's assert if we recognize nested mode case.
Signed-off-by Eric Auger <[email protected]>--- hw/vfio/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/vfio/common.c +1
-0@@ -604,9 +604,17 @@ static void vfio_listener_region_add(MemoryListener *listener,if (memory_region_is_iommu (section->mr)) {VFIOGuestIOMMU *giommu;IOMMUMemoryRegion *iommu_mr =IOMMU_MEMORY_REGION (section->mr); +bool nested;int iommu_idx;trace_vfio_listener_region_add_iommu (iova, end);
hw/vfio/common.c static void vfio_listener_region_add(MemoryListener *listener, · line 620
Quoted 10 lines
hw/vfio/common.c +7
-0+ +if (!memory_region_iommu_get_attr (iommu_mr,IOMMU_ATTR_VFIO_NESTED , + (void *)&nested) && nested) { +error_report ("VFIO/vIOMMU integration based on HW nested paging " +"is not yet supported" ); +abort (); + }/* * FIXME: For VFIO iommu types which have KVM acceleration to * avoid bouncing all map/unmaps through qemu this way, this
Other failure paths in this function mostly seem to do an error_report() and return (apart from the one call to hw_error() at the bottom of the function). Is an abort() OK here?
thanks
-- PMM
Re: [Qemu-arm] [Qemu-devel] [PATCH-for-4.2 v3 3/5] hw/vfio/common: Assert in case of nested mode
Hi Peter,
Quoted 31 lines · Peter Maydell
Quoted 30 lines · Eric Auger
As of today, VFIO only works along with vIOMMU supporting caching mode. The SMMUv3 does not support this mode and requires HW nested paging to work properly with VFIO.
So any attempt to run a VFIO device protected by such IOMMU would prevent the assigned device from working and at the moment the guest does not even boot as the default
memory_region_iommu_replay()implementation attempts to translate the whole address space and completely stalls the execution.So let's assert if we recognize nested mode case.
Signed-off-by Eric Auger <[email protected]>--- hw/vfio/common.c | 8 ++++++++ 1 file changed, 8 insertions(+)hw/vfio/common.c +1
-0@@ -604,9 +604,17 @@ static void vfio_listener_region_add(MemoryListener *listener,if (memory_region_is_iommu (section->mr)) {VFIOGuestIOMMU *giommu;IOMMUMemoryRegion *iommu_mr =IOMMU_MEMORY_REGION (section->mr); +bool nested;int iommu_idx;
Quoted 15 lines
hw/vfio/common.c static void vfio_listener_region_add(MemoryListener *listener, · line 620
Quoted 11 lines
hw/vfio/common.c +7
-0trace_vfio_listener_region_add_iommu (iova, end); + +if (!memory_region_iommu_get_attr (iommu_mr,IOMMU_ATTR_VFIO_NESTED , + (void *)&nested) && nested) { +error_report ("VFIO/vIOMMU integration based on HW nested paging " +"is not yet supported" ); +abort (); + }/* * FIXME: For VFIO iommu types which have KVM acceleration to * avoid bouncing all map/unmaps through qemu this way, this Other failure paths in this function mostly seem to do an
error_report()and return (apart from the one call tohw_error()at the bottom of the function). Is anabort()OK here?
Yes I should rather jump to the fail label instead.
Thanks!
Eric
Quoted 4 lines
thanks
-- PMM
PATCH v3 4/5 hw/arm/smmuv3: Log a guest error when decoding an invalid STE
In reply to Eric AugerLog a guest error when encountering an invalid STE.
--- hw/arm/smmuv3.c | 1 + 1 file changed, 1 insertion(+)
hw/arm/smmuv3.c +1 -0
@@ -320,6 +320,7 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,uint32_t config;if (!STE_VALID (ste)) { +qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); goto bad_ste; }
Signature · 1 line
2.20.1
PATCH v3 5/5 hw/arm/smmuv3: Remove spurious error messages on IOVA invalidations
In reply to Eric AugerAn IOVA/ASID invalidation is notified to all IOMMU Memory Regions through smmuv3_inv_notifiers_iova/smmuv3_notify_iova.
When the notification occurs it is possible that some of the PCIe devices associated to the notified regions do not have a valid stream table entry. In that case we output a LOG_GUEST_ERROR message, for example:
invalid sid=<SID> (L1STD span=0)
"smmuv3_notify_iova error decoding the configuration for iommu mr=<MR>
This is unfortunate as the user gets the impression that there are some translation decoding errors whereas there are not.
This patch adds a new field in SMMUEventInfo that tells whether the detection of an invalid STE must lead to an error report. invalid_ste_allowed is set before doing the invalidations and kept unset on actual translation.
The other configuration decoding error messages are kept since if the STE is valid then the rest of the config must be correct.
--- hw/arm/smmuv3-internal.h | 1 + hw/arm/smmuv3.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-)
hw/arm/smmuv3-internal.h +1 -0
@@ -381,6 +381,7 @@ typedef struct SMMUEventInfo {uint32_t sid;bool recorded;bool record_trans_faults; +bool inval_ste_allowed; union { struct { uint32_t ssid;
hw/arm/smmuv3.c +8 -7
@@ -320,7 +320,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,uint32_t config;if (!STE_VALID (ste)) { -qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); +if (!event->inval_ste_allowed) { +qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); + } goto bad_ste; }
@@ -405,7 +407,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, span =L1STD_SPAN (&l1std); -if (!span) { +if (!span && !event->inval_ste_allowed) {/* l2ptr is not valid */ qemu_log_mask (LOG_GUEST_ERROR ,"invalid sid=%d (L1STD span=0)\n" , sid);
@@ -603,7 +605,9 @@ static IOMMUTLBEntry smmuv3_translate(IOMMUMemoryRegion *mr, hwaddr addr,SMMUDevice *sdev =container_of (mr, SMMUDevice, iommu);SMMUv3State *s = sdev->smmu;uint32_t sid =smmu_get_sid (sdev); -SMMUEventInfo event = {.type =SMMU_EVT_NONE , .sid = sid}; +SMMUEventInfo event = {.type =SMMU_EVT_NONE , + .sid = sid, + .inval_ste_allowed = false};SMMUPTWEventInfo ptw_info = {};SMMUTranslationStatus status;SMMUState *bs =ARM_SMMU (s);
@@ -796,16 +800,13 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, dma_addr_t iova) {SMMUDevice *sdev =container_of (mr, SMMUDevice, iommu); -SMMUEventInfo event = {}; +SMMUEventInfo event = {.inval_ste_allowed = true};SMMUTransTableInfo *tt;SMMUTransCfg *cfg;IOMMUTLBEntry entry; cfg =smmuv3_get_config (sdev, &event);if (!cfg) { -qemu_log_mask (LOG_GUEST_ERROR , -"%s error decoding the configuration for iommu mr=%s\n" , - __func__, mr->parent_obj.name);return ; }
Signature · 1 line
2.20.1
Re: [Qemu-arm] [PATCH-for-4.2 v3 5/5] hw/arm/smmuv3: Remove spurious error messages on IOVA invalidations
Quoted 46 lines · Eric Auger
An IOVA/ASID invalidation is notified to all IOMMU Memory Regions through smmuv3_inv_notifiers_iova/smmuv3_notify_iova.
When the notification occurs it is possible that some of the PCIe devices associated to the notified regions do not have a valid stream table entry. In that case we output a
LOG_GUEST_ERRORmessage, for example:invalid sid=<SID> (L1STD span=0)
"smmuv3_notify_iovaerror decoding the configuration for iommu mr=<MR>This is unfortunate as the user gets the impression that there are some translation decoding errors whereas there are not.
This patch adds a new field in SMMUEventInfo that tells whether the detection of an invalid STE must lead to an error report.
invalid_ste_allowedis set before doing the invalidations and kept unset on actual translation.The other configuration decoding error messages are kept since if the STE is valid then the rest of the config must be correct.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3-internal.h | 1 + hw/arm/smmuv3.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-)hw/arm/smmuv3-internal.h +1
-0@@ -381,6 +381,7 @@ typedef struct SMMUEventInfo {uint32_t sid;bool recorded;bool record_trans_faults; +bool inval_ste_allowed; union { struct { uint32_t ssid;hw/arm/smmuv3.c +0
-0
hw/arm/smmuv3.c static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, · line 325
Quoted 7 lines
hw/arm/smmuv3.c +3
-1@@ -320,7 +320,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,uint32_t config;if (!STE_VALID (ste)) { -qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); +if (!event->inval_ste_allowed) { +qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); + }
Here the new flag check just suppresses the error log...
hw/arm/smmuv3.c static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, · line 413
Quoted 12 lines
hw/arm/smmuv3.c +1
-1goto bad_ste; }@@ -405,7 +407,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, span =L1STD_SPAN (&l1std); -if (!span) { +if (!span && !event->inval_ste_allowed) {/* l2ptr is not valid */ qemu_log_mask (LOG_GUEST_ERROR ,"invalid sid=%d (L1STD span=0)\n" , sid);
...but here it suppresses both the error logging and also the setting of event->type and returning -EINVAL. Instead we'll fall through to the following code. Is that really OK?
thanks
-- PMM
Re: [Qemu-arm] [PATCH-for-4.2 v3 5/5] hw/arm/smmuv3: Remove spurious error messages on IOVA invalidations
Hi Peter,
Quoted 64 lines · Peter Maydell
Quoted 46 lines · Eric Auger
An IOVA/ASID invalidation is notified to all IOMMU Memory Regions through smmuv3_inv_notifiers_iova/smmuv3_notify_iova.
When the notification occurs it is possible that some of the PCIe devices associated to the notified regions do not have a valid stream table entry. In that case we output a
LOG_GUEST_ERRORmessage, for example:invalid sid=<SID> (L1STD span=0)
"smmuv3_notify_iovaerror decoding the configuration for iommu mr=<MR>This is unfortunate as the user gets the impression that there are some translation decoding errors whereas there are not.
This patch adds a new field in SMMUEventInfo that tells whether the detection of an invalid STE must lead to an error report.
invalid_ste_allowedis set before doing the invalidations and kept unset on actual translation.The other configuration decoding error messages are kept since if the STE is valid then the rest of the config must be correct.
Signed-off-by Eric Auger <[email protected]>--- hw/arm/smmuv3-internal.h | 1 + hw/arm/smmuv3.c | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-)hw/arm/smmuv3-internal.h +1
-0@@ -381,6 +381,7 @@ typedef struct SMMUEventInfo {uint32_t sid;bool recorded;bool record_trans_faults; +bool inval_ste_allowed; union { struct { uint32_t ssid;hw/arm/smmuv3.c +0
-0hw/arm/smmuv3.c static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg, · line 325
Quoted 7 lines
hw/arm/smmuv3.c +3
-1@@ -320,7 +320,9 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,uint32_t config;if (!STE_VALID (ste)) { -qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); +if (!event->inval_ste_allowed) { +qemu_log_mask (LOG_GUEST_ERROR ,"invalid STE\n" ); + }Here the new flag check just suppresses the error log...
Quoted 7 lines
hw/arm/smmuv3.c +0
-0goto bad_ste; }@@ -405,7 +407,7 @@ static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, span =L1STD_SPAN (&l1std);
Quoted 9 lines
hw/arm/smmuv3.c static int smmu_find_ste(SMMUv3State *s, uint32_t sid, STE *ste, · line 413
Quoted 5 lines
hw/arm/smmuv3.c +1
-1-if (!span) { +if (!span && !event->inval_ste_allowed) {/* l2ptr is not valid */ qemu_log_mask (LOG_GUEST_ERROR ,"invalid sid=%d (L1STD span=0)\n" , sid);...but here it suppresses both the error logging and also the setting of
event->typeand returning-EINVAL. Instead we'll fall through to the following code. Is that really OK?
Sorry for the delay, I was off.
Yes it's wrong I should only suppress the log. Curiously it had no other impact on the execution while testing.
Thanks
Eric
Quoted 4 lines
thanks
-- PMM