Skip to contentSkip to conversation

qemu-kvm: Save&restore debug registers

PATCH Applied Jan Kiszka 2 participants 4 messages Mar 12, 2010 – Mar 15, 2010 KVM

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

v4 cover qemu-kvm: Save&restore debug registers

Patch 1 is for upstream and should be applied to uq/master as well, patch 2 is for qemu-kvm only.

Jan Kiszka (2):
KVM: x86: Add debug register saving and restoring
qemu-kvm: x86: Add support for saving&restoring debug registers

 kvm-all.c         |   11 ++++++++++
 kvm.h             |    1 +
 qemu-kvm-x86.c    |    2 +
 qemu-kvm.c        |    5 ++++
 qemu-kvm.h        |    1 +
 target-i386/kvm.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 75 insertions(+), 0 deletions(-)
author
#1 lore raw

PATCH v4 1/2 KVM: x86: Add debug register saving and restoring

Make use of the new KVM_GET/SET_DEBUGREGS to save/restore the x86 debug registers.

---
 kvm-all.c         |   11 ++++++++++
 kvm.h             |    1 +
 target-i386/kvm.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 0 deletions(-)
kvm-all.c +11 -0
index 8ca480d..c469b6a 100644
@@ -67,6 +67,7 @@ struct KVMState
     int migration_log;
     int vcpu_events;
     int robust_singlestep;
+    int debugregs;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
     struct kvm_sw_breakpoint_head kvm_sw_breakpoints;
 #endif
@@ -676,6 +677,11 @@ int kvm_init(int smp_cpus)
         kvm_check_extension(s, KVM_CAP_X86_ROBUST_SINGLESTEP);
 #endif
 
+    s->debugregs = 0;
+#ifdef KVM_CAP_DEBUGREGS
+    s->debugregs = kvm_check_extension(s, KVM_CAP_DEBUGREGS);
+#endif
+
     ret = kvm_arch_init(s, smp_cpus);
     if (ret < 0)
         goto err;
@@ -955,6 +961,11 @@ int kvm_has_robust_singlestep(void)
     return kvm_state->robust_singlestep;
 }
 
+int kvm_has_debugregs(void)
+{
+    return kvm_state->debugregs;
+}
+
 void kvm_setup_guest_memory(void *start, size_t size)
 {
     if (!kvm_has_sync_mmu()) {
kvm.h +1 -0
index b0d07c8..c6faf20 100644
@@ -44,6 +44,7 @@ int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size);
 int kvm_has_sync_mmu(void);
 int kvm_has_vcpu_events(void);
 int kvm_has_robust_singlestep(void);
+int kvm_has_debugregs(void);
 
 void kvm_cpu_register_phys_memory_client(void);
 
target-i386/kvm.c +55 -0

73 lines not on this page · raw message

Signature · 1 line
1.6.0.2
author
#2 lore raw

PATCH v4 2/2 qemu-kvm: x86: Add support for saving&restoring debug registers

In reply to Jan Kiszka

Corresponding support for qemu-kvm.

---
 qemu-kvm-x86.c    |    2 ++
 qemu-kvm.c        |    5 +++++
 qemu-kvm.h        |    1 +
 target-i386/kvm.c |    2 +-
 4 files changed, 9 insertions(+), 1 deletions(-)
qemu-kvm-x86.c +2 -0
index 0160fe9..65a3cfc 100644
@@ -1012,6 +1012,7 @@ void kvm_arch_load_regs(CPUState *env, int level)
     }
 
     kvm_put_vcpu_events(env, level);
+    kvm_put_debugregs(env);
 
     /* must be last */
     kvm_guest_debug_workarounds(env);
@@ -1185,6 +1186,7 @@ void kvm_arch_save_regs(CPUState *env)
     kvm_arch_save_mpstate(env);
     kvm_save_lapic(env);
     kvm_get_vcpu_events(env);
+    kvm_get_debugregs(env);
 }
 
 static void do_cpuid_ent(struct kvm_cpuid_entry2 *e, uint32_t function,
qemu-kvm.c +5 -0
index e417f21..0e7d594 100644
@@ -2115,6 +2115,11 @@ static int kvm_create_context(void)
     kvm_state->vcpu_events = kvm_check_extension(kvm_state, KVM_CAP_VCPU_EVENTS);
 #endif
 
+    kvm_state->debugregs = 0;
+#ifdef KVM_CAP_DEBUGREGS
+    kvm_state->debugregs = kvm_check_extension(kvm_state, KVM_CAP_DEBUGREGS);
+#endif
+
     kvm_init_ap();
     if (kvm_irqchip) {
         if (!qemu_kvm_has_gsi_routing()) {
qemu-kvm.h +1 -0
index f5db9e6..0cbc6f7 100644
@@ -970,6 +970,7 @@ struct KVMState {
     int migration_log;
     int vcpu_events;
     int robust_singlestep;
+    int debugregs;
 #ifdef KVM_CAP_SET_GUEST_DEBUG
     QTAILQ_HEAD(, kvm_sw_breakpoint) kvm_sw_breakpoints;
 #endif
target-i386/kvm.c +1 -1
index b5c3c27..8d00774 100644
@@ -902,7 +902,6 @@ static int kvm_guest_debug_workarounds(CPUState *env)
     return ret;
 }
 
-#ifdef KVM_UPSTREAM
 static int kvm_put_debugregs(CPUState *env)
 {
 #ifdef KVM_CAP_DEBUGREGS
@@ -950,6 +949,7 @@ static int kvm_get_debugregs(CPUState *env)
     return 0;
 }
 
+#ifdef KVM_UPSTREAM
 int kvm_arch_put_registers(CPUState *env, int level)
 {
     int ret;
Signature · 1 line
1.6.0.2
#3 lore raw
In reply to Jan Kiszka
Quoted 7 lines · Jan Kiszka

Patch 1 is for upstream and should be applied to uq/master as well, patch 2 is for qemu-kvm only.

Jan Kiszka (2):
KVM: x86: Add debug register saving and restoring
qemu-kvm: x86: Add support for saving&restoring debug registers

Quoted 7 lines
 kvm-all.c         |   11 ++++++++++
 kvm.h             |    1 +
 qemu-kvm-x86.c    |    2 +
 qemu-kvm.c        |    5 ++++
 qemu-kvm.h        |    1 +
 target-i386/kvm.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 75 insertions(+), 0 deletions(-)

Applied, thanks.