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>
Philippe Mathieu-Daudé committed
Jun 26, 2026 at 12:33 UTC
f2468e2f4996e60723884e36f527a3e7d535aa66
2 files changed
+6
-4
accel/kvm/kvm-all.c
+5
-4
@@ -104,7 +104,6 @@ bool kvm_readonly_mem_allowed;
104
bool kvm_vm_attributes_allowed;
105
bool kvm_msi_use_devid;
106
bool kvm_pre_fault_memory_supported;
107
-static bool kvm_has_guest_debug;
107
static int kvm_sstep_flags;
108
static bool kvm_immediate_exit;
109
static uint64_t kvm_supported_memory_attributes;
@@ -3038,10 +3037,10 @@ static int kvm_init(AccelState *as, MachineState *ms)
3037
(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
3038
3039
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
3041
- kvm_has_guest_debug =
3040
+ s->have_guest_debug =
3041
(kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);
3042
3044
- if (kvm_has_guest_debug) {
3043
+ if (s->have_guest_debug) {
3044
kvm_sstep_flags = SSTEP_ENABLE;
3045
3046
int guest_debug_flags =
@@ -3833,8 +3832,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
3832
3833
bool kvm_supports_guest_debug(void)
3834
{
3835
+ KVMState *s = KVM_STATE(as);
3836
+
3837
/* probed during kvm_init() */
3837
- return kvm_has_guest_debug;
3838
+ return s->have_guest_debug;
3839
}
3840
3841
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
include/system/kvm_int.h
+1
@@ -118,6 +118,7 @@ struct KVMState
118
#endif
119
int max_nested_state_len;
120
int kvm_shadow_mem;
121
+ bool have_guest_debug;
122
bool kernel_irqchip_allowed;
123
bool kernel_irqchip_required;
124
OnOffAuto kernel_irqchip_split;