summary refs log tree commit diff stats
path: root/system/cpus.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2025-08-21 17:56:03 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2025-08-29 12:48:14 +0200
commit87511341c30d8c9c77178db16491a0ccacc5d64b (patch)
treef2a99d1629f140c57cd7bdfcae4f5fd681763d94 /system/cpus.c
parentb8217bbaf2bafef1a4f54082a3548613eeef8f2b (diff)
downloadfocaccia-qemu-87511341c30d8c9c77178db16491a0ccacc5d64b.tar.gz
focaccia-qemu-87511341c30d8c9c77178db16491a0ccacc5d64b.zip
add cpu_test_interrupt()/cpu_set_interrupt() helpers and use them tree wide
The helpers form load-acquire/store-release pair and ensure
that appropriate barriers are in place in case checks happen
outside of BQL.

Use them to replace open-coded checkers/setters across the code,
to make sure that barriers are not missed.  Helpers also make code a
bit more readable.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>
Link: https://lore.kernel.org/r/20250821155603.2422553-1-imammedo@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'system/cpus.c')
-rw-r--r--system/cpus.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/system/cpus.c b/system/cpus.c
index 256723558d..437848b5eb 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -254,9 +254,16 @@ int64_t cpus_get_elapsed_ticks(void)
     return cpu_get_ticks();
 }
 
+void cpu_set_interrupt(CPUState *cpu, int mask)
+{
+    /* Pairs with cpu_test_interrupt(). */
+    qatomic_store_release(&cpu->interrupt_request,
+        cpu->interrupt_request | mask);
+}
+
 void generic_handle_interrupt(CPUState *cpu, int mask)
 {
-    cpu->interrupt_request |= mask;
+    cpu_set_interrupt(cpu, mask);
 
     if (!qemu_cpu_is_self(cpu)) {
         qemu_cpu_kick(cpu);