[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 26/26] gdbstub: move update guest debug to accel ops
From: |
Alex Bennée |
Subject: |
[PATCH v4 26/26] gdbstub: move update guest debug to accel ops |
Date: |
Thu, 2 Mar 2023 19:08:46 +0000 |
From: Mads Ynddal <m.ynddal@samsung.com>
Continuing the refactor of a48e7d9e52 (gdbstub: move guest debug support
check to ops) by removing hardcoded kvm_enabled() from generic cpu.c
code, and replace it with a property of AccelOpsClass.
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-Id: <20230207131721.49233-1-mads@ynddal.dk>
[AJB: add ifdef around update_guest_debug_ops, fix brace]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/sysemu/accel-ops.h | 1 +
accel/kvm/kvm-accel-ops.c | 8 ++++++++
cpu.c | 11 ++++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 30690c71bd..3c1fab4b1e 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -48,6 +48,7 @@ struct AccelOpsClass {
/* gdbstub hooks */
bool (*supports_guest_debug)(void);
+ int (*update_guest_debug)(CPUState *cpu);
int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len);
void (*remove_all_breakpoints)(CPUState *cpu);
diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c
index fbf4fe3497..457eafa380 100644
--- a/accel/kvm/kvm-accel-ops.c
+++ b/accel/kvm/kvm-accel-ops.c
@@ -86,6 +86,13 @@ static bool kvm_cpus_are_resettable(void)
return !kvm_enabled() || kvm_cpu_check_are_resettable();
}
+#ifdef KVM_CAP_SET_GUEST_DEBUG
+static int kvm_update_guest_debug_ops(CPUState *cpu)
+{
+ return kvm_update_guest_debug(cpu, 0);
+}
+#endif
+
static void kvm_accel_ops_class_init(ObjectClass *oc, void *data)
{
AccelOpsClass *ops = ACCEL_OPS_CLASS(oc);
@@ -99,6 +106,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void
*data)
ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm;
#ifdef KVM_CAP_SET_GUEST_DEBUG
+ ops->update_guest_debug = kvm_update_guest_debug_ops;
ops->supports_guest_debug = kvm_supports_guest_debug;
ops->insert_breakpoint = kvm_insert_breakpoint;
ops->remove_breakpoint = kvm_remove_breakpoint;
diff --git a/cpu.c b/cpu.c
index e6abc6c76c..567b23af46 100644
--- a/cpu.c
+++ b/cpu.c
@@ -31,8 +31,8 @@
#include "hw/core/sysemu-cpu-ops.h"
#include "exec/address-spaces.h"
#endif
+#include "sysemu/cpus.h"
#include "sysemu/tcg.h"
-#include "sysemu/kvm.h"
#include "exec/replay-core.h"
#include "exec/cpu-common.h"
#include "exec/exec-all.h"
@@ -326,9 +326,14 @@ void cpu_single_step(CPUState *cpu, int enabled)
{
if (cpu->singlestep_enabled != enabled) {
cpu->singlestep_enabled = enabled;
- if (kvm_enabled()) {
- kvm_update_guest_debug(cpu, 0);
+
+#if !defined(CONFIG_USER_ONLY)
+ const AccelOpsClass *ops = cpus_get_accel();
+ if (ops->update_guest_debug) {
+ ops->update_guest_debug(cpu);
}
+#endif
+
trace_breakpoint_singlestep(cpu->cpu_index, enabled);
}
}
--
2.39.2
- [PATCH v4 07/26] includes: move tb_flush into its own header, (continued)
- [PATCH v4 07/26] includes: move tb_flush into its own header, Alex Bennée, 2023/03/02
- [PATCH v4 05/26] gdbstub: define separate user/system structures, Alex Bennée, 2023/03/02
- [PATCH v4 06/26] gdbstub: move GDBState to shared internals header, Alex Bennée, 2023/03/02
- [PATCH v4 08/26] gdbstub: move fromhex/tohex routines to internals, Alex Bennée, 2023/03/02
- [PATCH v4 04/26] gdbstub: clean-up indent on gdb_exit, Alex Bennée, 2023/03/02
- [PATCH v4 12/26] gdbstub: rationalise signal mapping in softmmu, Alex Bennée, 2023/03/02
- [PATCH v4 10/26] gdbstub: move chunk of softmmu functionality to own file, Alex Bennée, 2023/03/02
- [PATCH v4 09/26] gdbstub: make various helpers visible to the rest of the module, Alex Bennée, 2023/03/02
- [PATCH v4 11/26] gdbstub: move chunks of user code into own files, Alex Bennée, 2023/03/02
- [PATCH v4 26/26] gdbstub: move update guest debug to accel ops,
Alex Bennée <=
- [PATCH v4 23/26] testing: probe gdb for supported architectures ahead of time, Alex Bennée, 2023/03/02
- [PATCH v4 24/26] include: split target_long definition from cpu-defs, Alex Bennée, 2023/03/02
- [PATCH v4 13/26] gdbstub: abstract target specific details from gdb_put_packet_binary, Alex Bennée, 2023/03/02
- [PATCH v4 18/26] gdbstub: fix address type of gdb_set_cpu_pc, Alex Bennée, 2023/03/02
- [PATCH v4 22/26] gdbstub: only compile gdbstub twice for whole build, Alex Bennée, 2023/03/02
- [PATCH v4 17/26] gdbstub: specialise stub_can_reverse, Alex Bennée, 2023/03/02
- [PATCH v4 19/26] gdbstub: don't use target_ulong while handling registers, Alex Bennée, 2023/03/02
- [PATCH v4 15/26] gdbstub: specialise target_memory_rw_debug, Alex Bennée, 2023/03/02
- [PATCH v4 16/26] gdbstub: introduce gdb_get_max_cpus, Alex Bennée, 2023/03/02
- [PATCH v4 14/26] gdbstub: specialise handle_query_attached, Alex Bennée, 2023/03/02