accel: Remove AccelOpsClass::supports_guest_debug
Now accelerators hold the 'guest debug supported' information in their state, accessible by the common code. No need to call a per-accelerator handler, simply check for the SSTEP_ENABLE in AccelGdbConfig::sstep_flags. Remove all AccelOpsClass::supports_guest_debug implementations, inline gdb_supports_guest_debug() and remove the now unnecessary KVMState::have_guest_debug field. Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260705215729.62196-18-philmd@oss.qualcomm.com>
Philippe Mathieu-Daudé committed
Jul 3, 2026 at 15:06 UTC
0533f0841378ae17b96169a2ddafe8b1b010b09b
18 files changed
+10
-70
accel/accel-common.c
+5
@@ -70,6 +70,11 @@ void accel_init_interfaces(AccelClass *ac)
70
accel_init_cpu_interfaces(ac);
71
}
72
73
+bool accel_supports_guest_debug(AccelState *accel)
74
+{
75
+ return accel->gdbstub.sstep_flags & SSTEP_ENABLE;
76
+}
77
+
78
void accel_cpu_instance_init(CPUState *cpu)
79
{
80
if (cpu->cc->accel_cpu && cpu->cc->accel_cpu->cpu_instance_init) {
accel/hvf/hvf-accel-ops.c
-1
@@ -369,7 +369,6 @@ static void hvf_accel_ops_class_init(ObjectClass *oc, const void *data)
369
ops->remove_breakpoint = hvf_remove_breakpoint;
370
ops->remove_all_breakpoints = hvf_remove_all_breakpoints;
371
ops->update_guest_debug = hvf_update_guest_debug;
372
- ops->supports_guest_debug = hvf_arch_supports_guest_debug;
372
373
ops->get_vcpu_stats = hvf_get_vcpu_stats;
374
};
accel/kvm/kvm-accel-ops.c
-1
@@ -105,7 +105,6 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, const void *data)
105
ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
106
ops->handle_interrupt = generic_handle_interrupt;
107
108
- ops->supports_guest_debug = kvm_supports_guest_debug;
108
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
109
ops->update_guest_debug = kvm_update_guest_debug_ops;
110
ops->insert_breakpoint = kvm_insert_breakpoint;
accel/kvm/kvm-all.c
+1
-12
@@ -3036,10 +3036,7 @@ static int kvm_init(AccelState *as, MachineState *ms)
3036
(kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
3037
3038
#ifdef TARGET_KVM_HAVE_GUEST_DEBUG
3039
- s->have_guest_debug =
3040
- (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0);
3041
-
3042
- if (s->have_guest_debug) {
3039
+ if (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0) {
3040
as->gdbstub.sstep_flags = SSTEP_ENABLE;
3041
3042
int guest_debug_flags =
@@ -3829,14 +3826,6 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
3826
return data.err;
3827
}
3828
3832
-bool kvm_supports_guest_debug(void)
3833
-{
3834
- KVMState *s = KVM_STATE(as);
3835
-
3836
- /* probed during kvm_init() */
3837
- return s->have_guest_debug;
3838
-}
3839
-
3829
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len)
3830
{
3831
struct kvm_sw_breakpoint *bp;
accel/kvm/kvm-cpus.h
-1
@@ -16,7 +16,6 @@ void kvm_destroy_vcpu(CPUState *cpu);
16
void kvm_cpu_synchronize_post_reset(CPUState *cpu);
17
void kvm_cpu_synchronize_post_init(CPUState *cpu);
18
void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu);
19
-bool kvm_supports_guest_debug(void);
19
int kvm_insert_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
20
int kvm_remove_breakpoint(CPUState *cpu, int type, vaddr addr, vaddr len);
21
void kvm_remove_all_breakpoints(CPUState *cpu);
accel/tcg/tcg-accel-ops.c
-6
@@ -109,11 +109,6 @@ void tcg_handle_interrupt(CPUState *cpu, int mask)
109
}
110
}
111
112
-static bool tcg_supports_guest_debug(void)
113
-{
114
- return true;
115
-}
116
-
112
/* Translate GDB watchpoint type to a flags value for cpu_watchpoint_* */
113
static inline int xlat_gdb_type(CPUState *cpu, int gdbtype)
114
{
@@ -221,7 +216,6 @@ static void tcg_accel_ops_init(AccelClass *ac)
216
}
217
218
ops->cpu_reset_hold = tcg_cpu_reset_hold;
224
- ops->supports_guest_debug = tcg_supports_guest_debug;
219
ops->insert_breakpoint = tcg_insert_breakpoint;
220
ops->remove_breakpoint = tcg_remove_breakpoint;
221
ops->remove_all_breakpoints = tcg_remove_all_breakpoints;
accel/whpx/whpx-accel-ops.c
-6
@@ -82,11 +82,6 @@ static bool whpx_vcpu_thread_is_idle(CPUState *cpu)
82
return !whpx_irqchip_in_kernel();
83
}
84
85
-static bool whpx_supports_guest_debug(void)
86
-{
87
- return whpx_arch_supports_guest_debug();
88
-}
89
-
85
86
static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
87
{
@@ -96,7 +91,6 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
91
ops->kick_vcpu_thread = whpx_kick_vcpu_thread;
92
ops->cpu_thread_is_idle = whpx_vcpu_thread_is_idle;
93
ops->handle_interrupt = generic_handle_interrupt;
99
- ops->supports_guest_debug = whpx_supports_guest_debug;
94
95
ops->synchronize_post_reset = whpx_cpu_synchronize_post_reset;
96
ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
docs/system/gdb.rst
+1
-1
@@ -54,7 +54,7 @@ While GDB can always fall back to inserting breakpoints into memory
54
accelerator. For TCG system emulation we advertise an infinite number
55
of hardware assisted breakpoints and watchpoints. For other
56
accelerators it will depend on if support has been added (see
57
-supports_guest_debug and related hooks in AccelOpsClass).
57
+the AccelGdbConfig structure).
58
59
As TCG cannot track all memory accesses in user-mode there is no
60
support for watchpoints.
gdbstub/system.c
+1
-12
@@ -331,8 +331,6 @@ static void create_processes(GDBState *s)
331
gdb_create_default_process(s);
332
}
333
334
-static bool gdb_supports_guest_debug(void);
335
-
334
bool gdbserver_start(const char *device, Error **errp)
335
{
336
Chardev *chr = NULL;
@@ -345,7 +343,7 @@ bool gdbserver_start(const char *device, Error **errp)
343
return false;
344
}
345
348
- if (!gdb_supports_guest_debug()) {
346
+ if (!accel_supports_guest_debug(current_accel())) {
347
error_setg(errp, "gdbstub: current accelerator doesn't "
348
"support guest debugging");
349
return false;
@@ -624,15 +622,6 @@ int gdb_signal_to_target(int sig)
622
* Break/Watch point helpers
623
*/
624
627
-static bool gdb_supports_guest_debug(void)
628
-{
629
- const AccelOpsClass *ops = cpus_get_accel();
630
- if (ops->supports_guest_debug) {
631
- return ops->supports_guest_debug();
632
- }
633
- return false;
634
-}
635
-
625
int gdb_breakpoint_insert(CPUState *cs, int type, vaddr addr, vaddr len)
626
{
627
const AccelOpsClass *ops = cpus_get_accel();
include/accel/accel-cpu-ops.h
-1
@@ -84,7 +84,6 @@ struct AccelOpsClass {
84
int64_t (*get_elapsed_ticks)(void);
85
86
/* gdbstub hooks */
87
- bool (*supports_guest_debug)(void);
87
int (*update_guest_debug)(CPUState *cpu);
88
int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
89
int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
include/qemu/accel.h
+2
@@ -84,4 +84,6 @@ typedef struct AccelGdbConfig {
84
bool can_reverse;
85
} AccelGdbConfig;
86
87
+bool accel_supports_guest_debug(AccelState *accel);
88
+
89
#endif /* QEMU_ACCEL_H */
include/system/hvf_int.h
-5
@@ -104,11 +104,6 @@ void hvf_arch_remove_all_hw_breakpoints(void);
104
*/
105
int hvf_update_guest_debug(CPUState *cpu);
106
107
-/*
108
- * Return whether the guest supports debugging.
109
- */
110
-bool hvf_arch_supports_guest_debug(void);
111
-
107
bool hvf_arch_cpu_realize(CPUState *cpu, Error **errp);
108
uint32_t hvf_arch_get_default_ipa_bit_size(void);
109
uint32_t hvf_arch_get_max_ipa_bit_size(void);
include/system/kvm_int.h
-1
@@ -118,7 +118,6 @@ struct KVMState
118
#endif
119
int max_nested_state_len;
120
int kvm_shadow_mem;
121
- bool have_guest_debug;
121
bool kernel_irqchip_allowed;
122
bool kernel_irqchip_required;
123
OnOffAuto kernel_irqchip_split;
include/system/whpx-all.h
-3
@@ -22,7 +22,4 @@ void whpx_translate_cpu_breakpoints(
22
void whpx_arch_destroy_vcpu(CPUState *cpu);
23
void whpx_arch_accel_class_init(ObjectClass *oc);
24
25
-/* called by whpx-accel-ops */
26
-bool whpx_arch_supports_guest_debug(void);
27
-
25
#endif
target/arm/hvf/hvf.c
-5
@@ -2900,8 +2900,3 @@ void hvf_arch_update_guest_debug(CPUState *cpu)
2900
2901
hvf_arch_set_traps(cpu);
2902
}
2903
-
2904
-bool hvf_arch_supports_guest_debug(void)
2905
-{
2906
- return true;
2907
-}
target/arm/whpx/whpx-all.c
-5
@@ -295,11 +295,6 @@ void whpx_translate_cpu_breakpoints(
295
/* Breakpoints aren’t supported on this platform */
296
}
297
298
-bool whpx_arch_supports_guest_debug(void)
299
-{
300
- return false;
301
-}
302
-
298
void whpx_arch_destroy_vcpu(CPUState *cpu)
299
{
300
/* currently empty on Arm */
target/i386/hvf/hvf.c
-5
@@ -1066,8 +1066,3 @@ void hvf_arch_remove_all_hw_breakpoints(void)
1066
void hvf_arch_update_guest_debug(CPUState *cpu)
1067
{
1068
}
1069
-
1070
-bool hvf_arch_supports_guest_debug(void)
1071
-{
1072
- return false;
1073
-}
target/i386/whpx/whpx-all.c
-5
@@ -1853,11 +1853,6 @@ void whpx_apply_breakpoints(
1853
}
1854
}
1855
1856
-bool whpx_arch_supports_guest_debug(void)
1857
-{
1858
- return true;
1859
-}
1860
-
1856
void whpx_arch_destroy_vcpu(CPUState *cpu)
1857
{
1858
X86CPU *x86cpu = X86_CPU(cpu);