qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Julian Armistead" <julian.armistead@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v3 66/68] accel/system: Pass old/new interrupt mask to handle_interrupt() handler
Date: Tue,  1 Jul 2025 16:40:14 +0200	[thread overview]
Message-ID: <20250701144017.43487-67-philmd@linaro.org> (raw)
In-Reply-To: <20250701144017.43487-1-philmd@linaro.org>

Update CPUState::interrupt_request once in cpu_interrupt().
Pass the old and new masks along.

Signed-off-by: Philippe Mathieu-Daudé <philmd@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 5f3ebea50ff..ddd53cc1e4f 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);
 void icount_update_percpu_budget(CPUState *cpu, 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 1263a666774..a95d97fca29 100644
--- a/accel/tcg/tcg-accel-ops.h
+++ b/accel/tcg/tcg-accel-ops.h
@@ -17,7 +17,7 @@
 void tcg_vcpu_thread_precreate(CPUState *cpu);
 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);
 
 int tcg_vcpu_init(CPUState *cpu);
diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h
index f98a1c9b662..9d2577fe67f 100644
--- a/include/system/accel-ops.h
+++ b/include/system/accel-ops.h
@@ -70,7 +70,7 @@ struct AccelOpsClass {
     void (*synchronize_state)(CPUState *cpu);
     void (*synchronize_pre_loadvm)(CPUState *cpu);
 
-    void (*handle_interrupt)(CPUState *cpu, int mask);
+    void (*handle_interrupt)(CPUState *cpu, int old_mask, int new_mask);
 
     void (*get_vcpu_stats)(CPUState *cpu, GString *buf);
 
diff --git a/accel/tcg/tcg-accel-ops-icount.c b/accel/tcg/tcg-accel-ops-icount.c
index ae1297ff7f3..d02b319951c 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) {
         cpu_abort(cpu, "Raised interrupt while not in I/O function");
     }
 }
diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c
index c6b5a567f9d..e7716dbc8da 100644
--- a/accel/tcg/tcg-accel-ops.c
+++ b/accel/tcg/tcg-accel-ops.c
@@ -109,10 +109,8 @@ static void tcg_cpu_reset_hold(CPUState *cpu)
 }
 
 /* mask must never be zero, except for A20 change call */
-void tcg_handle_interrupt(CPUState *cpu, int mask)
+void tcg_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
 {
-    cpu->interrupt_request |= mask;
-
     /*
      * If called from iothread context, wake the target cpu in
      * case its halted.
diff --git a/system/cpus.c b/system/cpus.c
index c2ad640980c..8c2647f5f19 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -246,10 +246,8 @@ int64_t cpus_get_elapsed_ticks(void)
     return cpu_get_ticks();
 }
 
-static void generic_handle_interrupt(CPUState *cpu, int mask)
+static void generic_handle_interrupt(CPUState *cpu, int old_mask, int new_mask)
 {
-    cpu->interrupt_request |= mask;
-
     if (!qemu_cpu_is_self(cpu)) {
         qemu_cpu_kick(cpu);
     }
@@ -257,12 +255,16 @@ static void generic_handle_interrupt(CPUState *cpu, int mask)
 
 void cpu_interrupt(CPUState *cpu, int mask)
 {
+    int old_mask = cpu->interrupt_request;
+
     g_assert(bql_locked());
 
+    cpu->interrupt_request |= mask;
+
     if (cpus_accel->handle_interrupt) {
-        cpus_accel->handle_interrupt(cpu, mask);
+        cpus_accel->handle_interrupt(cpu, old_mask, cpu->interrupt_request);
     } else {
-        generic_handle_interrupt(cpu, mask);
+        generic_handle_interrupt(cpu, old_mask, cpu->interrupt_request);
     }
 }
 
-- 
2.49.0



  parent reply	other threads:[~2025-07-01 14:57 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-01 14:39 [PATCH v3 00/68] accel: Preparatory cleanups for split-accel Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 01/68] system/runstate: Document qemu_add_vm_change_state_handler() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 02/68] system/cpus: Defer memory layout changes until vCPUs are realized Philippe Mathieu-Daudé
2025-07-02 15:06   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 03/68] system/cpus: Assert interrupt handling is done with BQL locked Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 04/68] accel: Keep reference to AccelOpsClass in AccelClass Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 05/68] accel: Introduce AccelOpsClass::cpu_target_realize() hook Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 06/68] accel/hvf: Add hvf_arch_cpu_realize() stubs Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 07/68] accel/kvm: Remove kvm_init_cpu_signals() stub Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 08/68] accel/kvm: Reduce kvm_create_vcpu() declaration scope Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 09/68] accel: Propagate AccelState to AccelClass::init_machine() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 10/68] accel/kvm: Prefer local AccelState over global MachineState::accel Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 11/68] accel/hvf: Re-use QOM allocated state Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 12/68] accel/tcg: Prefer local AccelState over global current_accel() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 13/68] accel: Directly pass AccelState argument to AccelClass::has_memory() Philippe Mathieu-Daudé
2025-07-02  2:45   ` Richard Henderson
2025-07-02 10:35   ` Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 14/68] accel/kvm: Directly pass KVMState argument to do_kvm_create_vm() Philippe Mathieu-Daudé
2025-07-02  2:46   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 15/68] accel: Remove unused MachineState argument of AccelClass::setup_post() Philippe Mathieu-Daudé
2025-07-02  7:17   ` Philippe Mathieu-Daudé
2025-07-02 14:55   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 16/68] accel: Pass AccelState argument to gdbstub_supported_sstep_flags() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 17/68] accel: Move supports_guest_debug() declaration to AccelClass Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 18/68] accel: Move cpus_are_resettable() " Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 19/68] accel: Move cpu_common_[un]realize() declarations to AccelOpsClass Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 20/68] accel/system: Introduce AccelClass::pre_resume_vm() handler Philippe Mathieu-Daudé
2025-07-02 14:59   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 21/68] accel/whpx: Convert ops::synchronize_pre_resume() -> pre_resume_vm() Philippe Mathieu-Daudé
2025-07-02  7:20   ` Philippe Mathieu-Daudé
2025-07-02 15:01     ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 22/68] accel/system: Remove AccelOpsClass::synchronize_pre_resume() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 23/68] hw/core/machine: Display CPU model name in 'info cpus' command Philippe Mathieu-Daudé
2025-07-02 15:02   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 24/68] accel/system: Add 'info accel' on human monitor Philippe Mathieu-Daudé
2025-07-02  4:58   ` Markus Armbruster
2025-07-02  7:13     ` Philippe Mathieu-Daudé
2025-07-02 12:00       ` Markus Armbruster
2025-07-02 12:13         ` Daniel P. Berrangé
2025-07-02 13:11           ` Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 25/68] accel/tcg: Factor tcg_dump_flush_info() out Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 26/68] accel/tcg: Implement get_[vcpu]_stats() Philippe Mathieu-Daudé
2025-07-03  7:14   ` Zhao Liu
2025-07-03 14:54     ` Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 27/68] accel/hvf: Implement get_vcpu_stats() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 28/68] accel/hvf: Report missing com.apple.security.hypervisor entitlement Philippe Mathieu-Daudé
2025-07-02 15:04   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 29/68] accel/hvf: Restrict internal declarations Philippe Mathieu-Daudé
2025-07-02 15:07   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 30/68] accel/hvf: Move per-cpu method declarations to hvf-accel-ops.c Philippe Mathieu-Daudé
2025-07-02 15:07   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 31/68] accel/hvf: Move generic method declarations to hvf-all.c Philippe Mathieu-Daudé
2025-07-02 15:08   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 32/68] cpus: Document CPUState::vcpu_dirty field Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 33/68] accel/hvf: Replace @dirty field by generic " Philippe Mathieu-Daudé
2025-07-02 15:09   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 34/68] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-02 15:09   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 35/68] accel/whpx: " Philippe Mathieu-Daudé
2025-07-02 15:11   ` Richard Henderson
2025-07-02 16:05     ` Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 36/68] accel/kvm: Remove kvm_cpu_synchronize_state() stub Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 37/68] accel/system: Document cpu_synchronize_state() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 38/68] accel/system: Document cpu_synchronize_state_post_init/reset() Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 39/68] accel/nvmm: Expose nvmm_enabled() to common code Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 40/68] accel/whpx: Expose whpx_enabled() " Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 41/68] accel/system: Introduce hwaccel_enabled() helper Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 42/68] target/arm: Use generic hwaccel_enabled() to check 'host' cpu type Philippe Mathieu-Daudé
2025-07-02 15:12   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 43/68] accel/dummy: Extract 'dummy-cpus.h' header from 'system/cpus.h' Philippe Mathieu-Daudé
2025-07-02 15:13   ` Richard Henderson
2025-07-01 14:39 ` [PATCH v3 44/68] accel/dummy: Factor dummy_thread_precreate() out Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 45/68] accel/tcg: Factor tcg_vcpu_thread_precreate() out Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 46/68] accel: Factor accel_create_vcpu_thread() out Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 47/68] accel: Introduce AccelOpsClass::cpu_thread_routine handler Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 48/68] accel/dummy: Convert to AccelOpsClass::cpu_thread_routine Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 49/68] accel/tcg: " Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 50/68] accel/hvf: " Philippe Mathieu-Daudé
2025-07-01 14:39 ` [PATCH v3 51/68] accel/kvm: " Philippe Mathieu-Daudé
2025-07-01 14:40 ` [PATCH v3 52/68] accel/nvmm: " Philippe Mathieu-Daudé
2025-07-01 14:40 ` [PATCH v3 53/68] accel/whpx: " Philippe Mathieu-Daudé
2025-07-01 14:40 ` [PATCH v3 54/68] accel: Factor accel_cpu_realize() out Philippe Mathieu-Daudé
2025-07-02 15:15   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 55/68] accel/tcg: Factor tcg_vcpu_init() out for re-use Philippe Mathieu-Daudé
2025-07-02 15:16   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 56/68] accel/tcg: Unregister the RCU before exiting RR thread Philippe Mathieu-Daudé
2025-07-02 15:17   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 57/68] accel/tcg: Expose vcpu_[un]register() for MTTCG Philippe Mathieu-Daudé
2025-07-02 15:19   ` Richard Henderson
2025-07-02 18:25     ` Philippe Mathieu-Daudé
2025-07-03 13:27       ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 58/68] accel/tcg: Factor mttcg_cpu_exec() out for re-use Philippe Mathieu-Daudé
2025-07-02 15:20   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 59/68] accel/tcg: Expose vcpu_[un]register() for RR Philippe Mathieu-Daudé
2025-07-02 15:24   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 60/68] accel/tcg: Factor rr_cpu_exec() out for re-use Philippe Mathieu-Daudé
2025-07-02 15:37   ` Richard Henderson
2025-07-02 15:39     ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 61/68] accel/tcg: Clear exit_request once in tcg_cpu_exec() Philippe Mathieu-Daudé
2025-07-02 15:25   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 62/68] accel/tcg: Add rr_vcpu_destroy() stub Philippe Mathieu-Daudé
2025-07-02 15:34   ` Richard Henderson
2025-07-02 16:28     ` Philippe Mathieu-Daudé
2025-07-01 14:40 ` [PATCH v3 63/68] accel/system: Declare init/exec/destroy vcpu hooks Philippe Mathieu-Daudé
2025-07-02 15:38   ` Richard Henderson
2025-07-01 14:40 ` [PATCH v3 64/68] accel/tcg: Register " Philippe Mathieu-Daudé
2025-07-01 14:40 ` [PATCH v3 65/68] accel/hvf: " Philippe Mathieu-Daudé
2025-07-02 15:41   ` Richard Henderson
2025-07-01 14:40 ` Philippe Mathieu-Daudé [this message]
2025-07-02 15:32   ` [PATCH v3 66/68] accel/system: Pass old/new interrupt mask to handle_interrupt() handler Richard Henderson
2025-07-01 14:40 ` [PATCH v3 67/68] accel: Have each accelerator implement the handle_interrupt() hook Philippe Mathieu-Daudé
2025-07-02 15:30   ` Richard Henderson
2025-07-02 17:52     ` Philippe Mathieu-Daudé
2025-07-01 14:40 ` [RFC PATCH v3 68/68] system/memory: Restrict eventfd dispatch_write() to emulators Philippe Mathieu-Daudé
2025-07-02 15:43   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250701144017.43487-67-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=julian.armistead@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).