Set PC to the tlblock instruction and leave the CPU loop when the lock is
contended. This retries tlblock after ownership is passed and prevents
execution without the lock.

Signed-off-by: Brian Cain <[email protected]>
---
 target/hexagon/hex_mmu.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/hexagon/hex_mmu.c b/target/hexagon/hex_mmu.c
index bdcfa057c21..b9fab949d0f 100644
--- a/target/hexagon/hex_mmu.c
+++ b/target/hexagon/hex_mmu.c
@@ -12,6 +12,7 @@
 #include "system/cpus.h"
 #include "internal.h"
 #include "exec/cpu-interrupt.h"
+#include "accel/tcg/cpu-loop.h"
 #include "cpu_helper.h"
 #include "exec/cputlb.h"
 #include "hex_mmu.h"
@@ -185,11 +186,14 @@ void hex_tlb_lock(CPUHexagonState *env)
             env->next_PC += 4;
             CPUState *cs = env_cpu(env);
             cpu_interrupt(cs, CPU_INTERRUPT_HALT);
+            cpu_loop_exit(cs);
             return;
         }
         env->tlb_lock_state = HEX_LOCK_WAITING;
+        env->gpr[HEX_REG_PC] = env->next_PC - 4;
         CPUState *cs = env_cpu(env);
         cpu_interrupt(cs, CPU_INTERRUPT_HALT);
+        cpu_loop_exit(cs);
     } else {
         env->next_PC += 4;
         env->tlb_lock_count++;
-- 
2.34.1

Reply via email to