Skip to contentSkip to conversation

target/arm: set the correct TI bits for WFIT traps

PATCH Applied Alex Bennée 3 participants 4 messages Feb 20 – Feb 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/arm: set the correct TI bits for WFIT traps

The WFIT trap should be reported as 0b10.

---
 target/arm/tcg/op_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/op_helper.c +1 -1
index 4d708635068..aa14f15eb62 100644
@@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
 
     if (target_el) {
         env->pc -= 4;
-        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
+        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
     }
 
     if (uadd64_overflow(timeout, offset, &nexttick)) {
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw

Hi Alex,

Quoted 12 lines · Alex Bennée

The WFIT trap should be reported as 0b10.

---
  target/arm/tcg/op_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/op_helper.c +0 -0
index 4d708635068..aa14f15eb62 100644

target/arm/tcg/op_helper.c void HELPER(wfit)(CPUARMState *env, uint64_t timeout) · line 451

Quoted 5 lines
target/arm/tcg/op_helper.c +1 -1
@@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
 
      if (target_el) {
          env->pc -= 4;
-        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
+        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);

As per the AArch64.WFxTrap() Arm Arm pseudo code:

Cheers,
Gustavo

Quoted 3 lines
target/arm/tcg/op_helper.c +0 -0
      }
 
      if (uadd64_overflow(timeout, offset, &nexttick)) {
#2 lore raw
In reply to Alex Bennée
Quoted 13 lines · Alex Bennée

The WFIT trap should be reported as 0b10.

---
 target/arm/tcg/op_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/op_helper.c +0 -0
index 4d708635068..aa14f15eb62 100644

target/arm/tcg/op_helper.c void HELPER(wfit)(CPUARMState *env, uint64_t timeout) · line 452

Quoted 6 lines
target/arm/tcg/op_helper.c +1 -1
@@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
 
     if (target_el) {
         env->pc -= 4;
-        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
+        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
     }

It would be nice to also report the register number in the syndrome (especially since KVM will use it if it's there), but that is architecturally optional, and getting the TI bits right is a bug fix.

Applied to target-arm.next, thanks.

-- PMM

#3 lore raw
Quoted 15 lines · Peter Maydell
Quoted 14 lines · Alex Bennée

The WFIT trap should be reported as 0b10.

---
 target/arm/tcg/op_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/tcg/op_helper.c +0 -0
index 4d708635068..aa14f15eb62 100644
@@ -448,7 +448,7 @@ void HELPER(wfit)(CPUARMState *env, uint64_t timeout)
 
Quoted 10 lines

target/arm/tcg/op_helper.c void HELPER(wfit)(CPUARMState *env, uint64_t timeout) · line 452

Quoted 5 lines
target/arm/tcg/op_helper.c +1 -1
     if (target_el) {
         env->pc -= 4;
-        raise_exception(env, excp, syn_wfx(1, 0xe, 0, false), target_el);
+        raise_exception(env, excp, syn_wfx(1, 0xe, 2, false), target_el);
     }

It would be nice to also report the register number in the syndrome (especially since KVM will use it if it's there), but that is architecturally optional, and getting the TI bits right is a bug fix.

Turned out just getting the rd information is trivially simple so I sent a follow-up series.

https://patchew.org/QEMU/[email protected]/

Quoted 6 lines

Applied to target-arm.next, thanks.

-- PMM

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro