Skip to contentSkip to conversation

arm: force flag recalculation when messing with DAIF

RFC PATCH Applied Alex Bennée 4 participants 4 messages Feb 2, 2022 – Feb 7, 2022

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 arm: force flag recalculation when messing with DAIF

The recently introduced debug tests in kvm-unit-tests exposed an error in our handling of singlestep cause by stale hflags. This is caught by --enable-debug-tcg when running the tests.

Cc Richard Henderson <[email protected]>
Cc Andrew Jones <[email protected]>
---
 target/arm/helper-a64.c | 2 ++
 1 file changed, 2 insertions(+)
target/arm/helper-a64.c +2 -0
index d6a6fd73d9..7cf953b1e6 100644
@@ -83,12 +83,14 @@ void HELPER(msr_i_daifset)(CPUARMState *env, uint32_t imm)
 {
     daif_check(env, 0x1e, imm, GETPC());
     env->daif |= (imm << 6) & PSTATE_DAIF;
+    arm_rebuild_hflags(env);
 }
 
 void HELPER(msr_i_daifclear)(CPUARMState *env, uint32_t imm)
 {
     daif_check(env, 0x1f, imm, GETPC());
     env->daif &= ~((imm << 6) & PSTATE_DAIF);
+    arm_rebuild_hflags(env);
 }
 
 /* Convert a softfloat float_relation_ (as returned by
Signature · 1 line
2.30.2
Tested-by on v1 1/1
#1 lore raw
Quoted 7 lines · Alex Bennée

The recently introduced debug tests in kvm-unit-tests exposed an error in our handling of singlestep cause by stale hflags. This is caught by --enable-debug-tcg when running the tests.

Cc Richard Henderson <[email protected]>
Cc Andrew Jones <[email protected]>

s/Cc: Andrew/Reported-by: Andrew/

and now also

Thanks,
drew

Quoted 26 lines
---
 target/arm/helper-a64.c | 2 ++
 1 file changed, 2 insertions(+)
target/arm/helper-a64.c +2 -0
index d6a6fd73d9..7cf953b1e6 100644
@@ -83,12 +83,14 @@ void HELPER(msr_i_daifset)(CPUARMState *env, uint32_t imm)
 {
     daif_check(env, 0x1e, imm, GETPC());
     env->daif |= (imm << 6) & PSTATE_DAIF;
+    arm_rebuild_hflags(env);
 }
 
 void HELPER(msr_i_daifclear)(CPUARMState *env, uint32_t imm)
 {
     daif_check(env, 0x1f, imm, GETPC());
     env->daif &= ~((imm << 6) & PSTATE_DAIF);
+    arm_rebuild_hflags(env);
 }
 
 /* Convert a softfloat float_relation_ (as returned by
Signature · 1 line
2.30.2
Reviewed-by on v1 1/1
#2 lore raw
In reply to Alex Bennée
Quoted 3 lines · Alex Bennée

The recently introduced debug tests in kvm-unit-tests exposed an error in our handling of singlestep cause by stale hflags. This is caught by --enable-debug-tcg when running the tests.

You could mention that PSTATE_D is used by aa64_generate_debug_exceptions.

Quoted 15 lines
Cc Richard Henderson <[email protected]>
Cc Andrew Jones <[email protected]>
---
  target/arm/helper-a64.c | 2 ++
  1 file changed, 2 insertions(+)
target/arm/helper-a64.c +0 -0
index d6a6fd73d9..7cf953b1e6 100644
@@ -83,12 +83,14 @@ void HELPER(msr_i_daifset)(CPUARMState *env, uint32_t imm)
  {
      daif_check(env, 0x1e, imm, GETPC());

target/arm/helper-a64.c void HELPER(msr_i_daifset)(CPUARMState *env, uint32_t imm) · line 94

Quoted 10 lines
target/arm/helper-a64.c +2 -0
      env->daif |= (imm << 6) & PSTATE_DAIF;
+    arm_rebuild_hflags(env);
  }
 
  void HELPER(msr_i_daifclear)(CPUARMState *env, uint32_t imm)
  {
      daif_check(env, 0x1f, imm, GETPC());
      env->daif &= ~((imm << 6) & PSTATE_DAIF);
+    arm_rebuild_hflags(env);
  }

You could call helper_rebuild_hflags_a64 directly, since we know that we must be in a64 state to get here. Regardless,

r~

#3 lore raw
In reply to Alex Bennée
Quoted 11 lines · Alex Bennée

The recently introduced debug tests in kvm-unit-tests exposed an error in our handling of singlestep cause by stale hflags. This is caught by --enable-debug-tcg when running the tests.

Cc Richard Henderson <[email protected]>
Cc Andrew Jones <[email protected]>
---
 target/arm/helper-a64.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to target-arm.next, thanks.

-- PMM