On 7/4/2025 1:32 AM, Philippe Mathieu-Daudé wrote:
Update CPUState::interrupt_request once in cpu_interrupt().
Pass the old and new masks along.

Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
---
  accel/tcg/tcg-accel-ops-icount.h |  2 +-
  accel/tcg/tcg-accel-ops.h        |  2 +-
  include/system/accel-ops.h       |  2 +-
  accel/tcg/tcg-accel-ops-icount.c |  8 +++-----
  accel/tcg/tcg-accel-ops.c        |  4 +---
  system/cpus.c                    | 12 +++++++-----
  6 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/accel/tcg/tcg-accel-ops-icount.h b/accel/tcg/tcg-accel-ops-icount.h
index 16a301b6dc0..1d9d66f0707 100644
--- a/accel/tcg/tcg-accel-ops-icount.h
+++ b/accel/tcg/tcg-accel-ops-icount.h
@@ -15,6 +15,6 @@ void icount_prepare_for_run(CPUState *cpu, int64_t 
cpu_budget);
  int64_t icount_percpu_budget(int cpu_count);
  void icount_process_data(CPUState *cpu);
-void icount_handle_interrupt(CPUState *cpu, int mask);
+void icount_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
#endif /* TCG_ACCEL_OPS_ICOUNT_H */
diff --git a/accel/tcg/tcg-accel-ops.h b/accel/tcg/tcg-accel-ops.h
index 6feeb3f3e9b..6e7c2aae5a8 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -16,7 +16,7 @@
void tcg_cpu_destroy(CPUState *cpu);
  int tcg_cpu_exec(CPUState *cpu);
-void tcg_handle_interrupt(CPUState *cpu, int mask);
+void tcg_handle_interrupt(CPUState *cpu, int old_mask, int new_mask);
  void tcg_cpu_init_cflags(CPUState *cpu, bool parallel);
#endif /* TCG_ACCEL_OPS_H */
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index 2075691331c..d84eaa376c2 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -61,7 +61,7 @@ struct AccelOpsClass {
      void (*synchronize_pre_loadvm)(CPUState *cpu);
      void (*synchronize_pre_resume)(bool step_pending);
- void (*handle_interrupt)(CPUState *cpu, int mask);
+    void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
/**
       * @get_virtual_clock: fetch virtual clock
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c
index d0f7b410fab..500b5dd4942 100644
--- a/accel/tcg/tcg-accel-ops-icount.c
+++ b/accel/tcg/tcg-accel-ops-icount.c
@@ -147,14 +147,12 @@ void icount_process_data(CPUState *cpu)
      replay_mutex_unlock();
  }
-void icount_handle_interrupt(CPUState *cpu, int mask)
+void icount_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
  {
-    int old_mask = cpu->interrupt_request;
-
-    tcg_handle_interrupt(cpu, mask);
+    tcg_handle_interrupt(cpu, old_mask, new_mask);
      if (qemu_cpu_is_self(cpu) &&
          !cpu->neg.can_do_io
-        && (mask & ~old_mask) != 0) {
+        && (new_mask & ~old_mask) != 0) {

This patch changes the behavior,

Assume the @mask is the value passed to cpu_interrupt()

- before this patch:

        (mask & ~old_mask) is

        (@mask & ~cpu->interrupt_request)

- after this patch:

        (new_mask & ~old_mask) is

        ((@mask | cpu->interrupt_request) & ~cpu->interrupt_request)


Reply via email to