@@ -2320,6 +2320,15 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
return data.err;
}
+void kvm_set_singlestep(CPUState *cs, int enabled)
+{
+ if (kvm_has_guestdbg_singlestep()) {
+ kvm_update_guest_debug(cs, 0);
+ } else {
+ kvm_arch_set_singlestep(cs, enabled);
+ }
+}
+
int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
target_ulong len, int type)
{
@@ -79,6 +79,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap)
return -ENOSYS;
}
+void kvm_set_singlestep(CPUState *cs, int enabled)
+{
+}
+
int kvm_insert_breakpoint(CPUState *cpu, target_ulong addr,
target_ulong len, int type)
{
@@ -1234,7 +1234,7 @@ 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);
+ kvm_set_singlestep(cpu, enabled);
} else {
/* must flush all the translated code to avoid inconsistencies */
/* XXX: only flush what is necessary */
@@ -247,6 +247,7 @@ bool kvm_memcrypt_enabled(void);
*/
int kvm_memcrypt_encrypt_data(uint8_t *ptr, uint64_t len);
+void kvm_arch_set_singlestep(CPUState *cpu, int enabled);
#ifdef NEED_CPU_H
#include "cpu.h"
@@ -259,6 +260,7 @@ int kvm_remove_breakpoint(CPUState *cpu, target_ulong addr,
target_ulong len, int type);
void kvm_remove_all_breakpoints(CPUState *cpu);
int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap);
+void kvm_set_singlestep(CPUState *cs, int enabled);
int kvm_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
int kvm_on_sigbus(int code, void *addr);
@@ -16,6 +16,7 @@ stub-obj-y += get-vm-name.o
stub-obj-y += iothread.o
stub-obj-y += iothread-lock.o
stub-obj-y += is-daemonized.o
+stub-obj-y += kvm-arch-set-singlestep.o
stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
stub-obj-y += machine-init-done.o
stub-obj-y += migr-blocker.o
new file mode 100644
@@ -0,0 +1,8 @@
+#include "qemu/osdep.h"
+#include "qemu/error-report.h"
+#include "sysemu/kvm.h"
+
+void kvm_arch_set_singlestep(CPUState *cpu, int enabled)
+{
+ warn_report("KVM does not support single stepping");
+}
This will allow architecture-specifc implementations of a fallback mechanism for single stepping in cases where KVM does not support it via the KVM_SET_GUEST_DEBUG ioctl. Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com> --- accel/kvm/kvm-all.c | 9 +++++++++ accel/stubs/kvm-stub.c | 4 ++++ exec.c | 2 +- include/sysemu/kvm.h | 2 ++ stubs/Makefile.objs | 1 + stubs/kvm-arch-set-singlestep.c | 8 ++++++++ 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 stubs/kvm-arch-set-singlestep.c