Commit f2468e2f49 for qemu.org

commit f2468e2f4996e60723884e36f527a3e7d535aa66
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date:   Fri Jun 26 12:33:30 2026 +0200

    accel/kvm: Hold have_guest_debug in KVMState

    Prefer to store per-accelerator variables in the per-accelerator
    state, rather than as static variables. This is a good practice
    to allow concurrent accelerators in the future.

    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Message-ID: <20260705215729.62196-12-philmd@oss.qualcomm.com>

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 304467704e..b6125125f8 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -104,7 +104,6 @@ bool kvm_readonly_mem_allowed;
 bool kvm_vm_attributes_allowed;
 bool kvm_msi_use_devid;
 bool kvm_pre_fault_memory_supported;
-static bool kvm_has_guest_debug;
 static int kvm_sstep_flags;
 static bool kvm_immediate_exit;
 static uint64_t kvm_supported_memory_attributes;
@@ -3038,10 +3037,10 @@ static int kvm_init(AccelState *as, MachineState *ms)
         (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);

 #ifdef TARGET_KVM_HAVE_GUEST_DEBUG
-    kvm_has_guest_debug =
+    s->have_guest_debug =
         (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);

-    if (kvm_has_guest_debug) {
+    if (s->have_guest_debug) {
         kvm_sstep_flags = SSTEP_ENABLE;

         int guest_debug_flags =
@@ -3833,8 +3832,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)

 bool kvm_supports_guest_debug(void)
 {
+    KVMState *s = KVM_STATE(as);
+
     /* probed during kvm_init() */
-    return kvm_has_guest_debug;
+    return s->have_guest_debug;
 }

 int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
diff --git a/include/system/kvm_int.h b/include/system/kvm_int.h
index 0876aac938..53bb0fcf18 100644
--- a/include/system/kvm_int.h
+++ b/include/system/kvm_int.h
@@ -118,6 +118,7 @@ struct KVMState
 #endif
     int max_nested_state_len;
     int kvm_shadow_mem;
+    bool have_guest_debug;
     bool kernel_irqchip_allowed;
     bool kernel_irqchip_required;
     OnOffAuto kernel_irqchip_split;