With Non-secure S2P set and Secure SEL2 clear, decode_ste() tags Secure
stage-1 entries with STE.S2VMID, while CMD_TLBI_NH_ASID matches -1.
The mismatch can leave stale translations cached in the IOTLB.

Use the internal no-VMID value -1 for Secure stage-1 entries, keeping
Non-secure VMID handling unchanged.

Signed-off-by: Tao Tang <[email protected]>
---
 hw/arm/smmuv3.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
index fc5cd46d1a8..93d5b900806 100644
--- a/hw/arm/smmuv3.c
+++ b/hw/arm/smmuv3.c
@@ -643,11 +643,11 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cfg,
         goto bad_ste;
     }
 
-    if (STAGE2_SUPPORTED(s)) {
-        /* VMID is considered even if s2 is disabled. */
+    if (STAGE2_SUPPORTED(s) && !smmu_sec_sid_is_secure(sec_sid)) {
+        /* VMID is considered even if Non-secure stage 2 is disabled. */
         cfg->s2cfg.vmid = STE_S2VMID(ste);
     } else {
-        /* Default to -1 */
+        /* No VMID tagging without stage 2 in this Security state. */
         cfg->s2cfg.vmid = -1;
     }
 
-- 
2.34.1


Reply via email to