Skip to contentSkip to conversation

target/arm: Flush correct TLBs in tlbi_aa64_vae2is_write()

PATCH In review Peter Maydell 4 participants 5 messages Apr 20, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: Flush correct TLBs in tlbi_aa64_vae2is_write()

In tlbi_aa64_vae2is_write() the calculation
bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
pageaddr)

has the two arms of the ?: expression reversed. Fix the bug.

---
 target/arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +1 -1
index d9220be7c5a..957f4247010 100644
@@ -4742,7 +4742,7 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
     uint64_t pageaddr = sextract64(value << 12, 0, 56);
     bool secure = arm_is_secure_below_el3(env);
     int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
-    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
+    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2,
                                   pageaddr);
 
     tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
Signature · 1 line
2.20.1
#1 lore raw
Quoted 10 lines · Peter Maydell

In tlbi_aa64_vae2is_write() the calculation
bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
pageaddr)

has the two arms of the ?: expression reversed. Fix the bug.

3 seconds after sending this I realized that the subject isn't right:
we flush the correct TLBs, but we might consider the wrong number of bits in the page address to be significant if the TBI enable/disable state is different for SEL2 and NSEL2. Better subject:

target/arm: Fix tlbbits calculation in tlbi_aa64_vae2is_write()

thanks
-- PMM

Reviewed-by on v1 1/1
#2 lore raw
In reply to Peter Maydell

+Rémi

Quoted 19 lines · Peter Maydell

In tlbi_aa64_vae2is_write() the calculation
bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
pageaddr)

has the two arms of the ?: expression reversed. Fix the bug.

---
 target/arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +0 -0
index d9220be7c5a..957f4247010 100644

target/arm/helper.c static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, · line 4748

Quoted 8 lines
target/arm/helper.c +1 -1
@@ -4742,7 +4742,7 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
     uint64_t pageaddr = sextract64(value << 12, 0, 56);
     bool secure = arm_is_secure_below_el3(env);
     int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
-    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
+    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2,
                                   pageaddr);
 
     tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);
Reviewed-by on v1 1/1
#3 lore raw
In reply to Peter Maydell
Quoted 25 lines · Le tiistaina 20. huhtikuuta 2021, 15.31.06 EEST Peter Maydell a écrit :

In tlbi_aa64_vae2is_write() the calculation
bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
pageaddr)

has the two arms of the ?: expression reversed. Fix the bug.

---
 target/arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +0 -1
index d9220be7c5a..957f4247010 100644
@@ -4742,7 +4742,7 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env,
 const ARMCPRegInfo *ri, uint64_t pageaddr = sextract64(value << 12, 0, 56);
     bool secure = arm_is_secure_below_el3(env);
     int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
-    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 :

ARMMMUIdx_SE2, + int bits = tlbbits_for_regime(env, secure ?
ARMMMUIdx_SE2 : ARMMMUIdx_E2, pageaddr);

Quoted 2 lines

tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask,
bits);

Signature · 2 lines
Rémi Denis-Courmont
http://www.remlab.net/
Reviewed-by on v1 1/1
#4 lore raw
In reply to Peter Maydell
Quoted 19 lines · Peter Maydell

In tlbi_aa64_vae2is_write() the calculation
bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
pageaddr)

has the two arms of the ?: expression reversed. Fix the bug.

---
  target/arm/helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/helper.c +0 -0
index d9220be7c5a..957f4247010 100644

target/arm/helper.c static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri, · line 4748

Quoted 8 lines
target/arm/helper.c +1 -1
@@ -4742,7 +4742,7 @@ static void tlbi_aa64_vae2is_write(CPUARMState *env, const ARMCPRegInfo *ri,
      uint64_t pageaddr = sextract64(value << 12, 0, 56);
      bool secure = arm_is_secure_below_el3(env);
      int mask = secure ? ARMMMUIdxBit_SE2 : ARMMMUIdxBit_E2;
-    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_E2 : ARMMMUIdx_SE2,
+    int bits = tlbbits_for_regime(env, secure ? ARMMMUIdx_SE2 : ARMMMUIdx_E2,
                                    pageaddr);
 
      tlb_flush_page_bits_by_mmuidx_all_cpus_synced(cs, pageaddr, mask, bits);