hw/arm/smmuv3: Pass the real perm to returned IOMMUTLBEntry in smmuv3_translate()
PATCH 1/1 hw/arm/smmuv3: Pass the real perm to returned IOMMUTLBEntry in smmuv3_translate()
From: Xiang Chen <[email protected]>
In function memory_region_iommu_replay(), it decides to notify() or not according to the perm of returned IOMMUTLBEntry. But for smmuv3, the returned perm is always IOMMU_NONE even if the translation success. Pass the real perm to returned IOMMUTLBEntry to avoid the issue.
--- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/smmuv3.c +1 -1
@@ -760,7 +760,7 @@ epilogue:qemu_mutex_unlock (&s->mutex);switch (status) {case SMMU_TRANS_SUCCESS : - entry.perm = flag; + entry.perm = cached_entry->entry.perm; entry.translated_addr = cached_entry->entry.translated_addr + (addr & cached_entry->entry.addr_mask); entry.addr_mask = cached_entry->entry.addr_mask;
Signature · 1 line
2.33.0
Hi Chenxiang,
Quoted 5 lines · chenxiang via
From: Xiang Chen <[email protected]>
In function
memory_region_iommu_replay(), it decides tonotify()or not according to the perm of returned IOMMUTLBEntry. But for smmuv3, the returned perm is alwaysIOMMU_NONEeven if the translation success.
I think you should precise in the commit message that memory_region_iommu_replay() always calls the IOMMU MR translate() callback with flag=IOMMU_NONE and thus, currently, translate() returns an IOMMUTLBEntry with perm set to IOMMU_NONE if the translation succeeds, whereas it is expected to return the actual permission set in the table entry.
Quoted 12 lines
Pass the real perm to returned IOMMUTLBEntry to avoid the issue.
Signed-off-by Xiang Chen <[email protected]>--- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/smmuv3.c +0
-0
hw/arm/smmuv3.c epilogue: · line 763
Quoted 5 lines
hw/arm/smmuv3.c +1
-1@@ -760,7 +760,7 @@ epilogue:qemu_mutex_unlock (&s->mutex);switch (status) {case SMMU_TRANS_SUCCESS : - entry.perm = flag; + entry.perm = cached_entry->entry.perm;
With that clarification
the translate() doc in ./include/exec/memory.h states
"
If IOMMU_NONE is passed then the IOMMU must do the
* full page table walk and report the permissions in the returned
* IOMMUTLBEntry. (Note that this implies that an IOMMU may not
* return different mappings for reads and writes.)
"
Thanks
Eric
Quoted 3 lines
hw/arm/smmuv3.c +0
-0entry.translated_addr = cached_entry->entry.translated_addr + (addr & cached_entry->entry.addr_mask); entry.addr_mask = cached_entry->entry.addr_mask;
Hi Eric,
Quoted 8 lines · Eric Auger
Hi Chenxiang,
Quoted 5 lines · chenxiang via
From: Xiang Chen <[email protected]>
In function
memory_region_iommu_replay(), it decides tonotify()or not according to the perm of returned IOMMUTLBEntry. But for smmuv3, the returned perm is alwaysIOMMU_NONEeven if the translation success.
Quoted 6 lines
I think you should precise in the commit message that
memory_region_iommu_replay()always calls the IOMMU MRtranslate()callback with flag=IOMMU_NONE and thus, currently,translate()returns an IOMMUTLBEntry with perm set toIOMMU_NONEif the translation succeeds, whereas it is expected to return the actual permission set in the table entry.
Thank you for your comments.
I will change the commit message in next version.
Quoted 20 lines
Quoted 14 lines
Pass the real perm to returned IOMMUTLBEntry to avoid the issue.
Signed-off-by Xiang Chen <[email protected]>--- hw/arm/smmuv3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/arm/smmuv3.c +0
-0hw/arm/smmuv3.c epilogue: · line 763
Quoted 5 lines
hw/arm/smmuv3.c +1
-1@@ -760,7 +760,7 @@ epilogue:qemu_mutex_unlock (&s->mutex);switch (status) {case SMMU_TRANS_SUCCESS : - entry.perm = flag; + entry.perm = cached_entry->entry.perm;With that clarification
Quoted 1 line
Reviewed-by Eric Auger <[email protected]>
Ok, thanks
Quoted 18 lines
the
translate()doc in./include/exec/memory.hstates
"
IfIOMMU_NONEis passed then the IOMMU must do the
* full page table walk and report the permissions in the returned
* IOMMUTLBEntry. (Note that this implies that an IOMMU may not
* return different mappings for reads and writes.)
"Thanks
Eric
hw/arm/smmuv3.c epilogue: · line 766
Quoted 3 lines
hw/arm/smmuv3.c +0
-0entry.translated_addr = cached_entry->entry.translated_addr + (addr & cached_entry->entry.addr_mask); entry.addr_mask = cached_entry->entry.addr_mask;.