Patchwork [v4,2/2] qemu-kvm: x86: Add support for saving&restoring debug registers

login
register
mail settings
Submitter Jan Kiszka
Date March 12, 2010, 2:20 p.m.
Message ID <fa5172adaf39864c29e66da555e8b5e7e8b4e07e.1268403648.git.jan.kiszka@siemens.com>
Download mbox | patch
Permalink /patch/47681/
State New
Headers show

Comments

Jan Kiszka - March 12, 2010, 2:20 p.m.
Corresponding support for qemu-kvm.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 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(-)

Patch

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 0160fe9..65a3cfc 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -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,
diff --git a/qemu-kvm.c b/qemu-kvm.c
index e417f21..0e7d594 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -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()) {
diff --git a/qemu-kvm.h b/qemu-kvm.h
index f5db9e6..0cbc6f7 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -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
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index b5c3c27..8d00774 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -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;