Patchwork kvm: x86: Use separate exception_injected CPUState field

login
register
mail settings
Submitter Jan Kiszka
Date Dec. 9, 2009, 6:20 p.m.
Message ID <4B1FEA8A.6000603@siemens.com>
Download mbox | patch
Permalink /patch/40755/
State New
Headers show

Comments

Jan Kiszka - Dec. 9, 2009, 6:20 p.m.
Marcelo correctly remarked that there are usage conflicts between QEMU
core code and KVM /wrt exception_index. So spend a separate field and
also save/restore it properly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

NOTE: This obsoletes "kvm: x86: Save/restore exception_index".

 target-i386/cpu.h     |    1 +
 target-i386/kvm.c     |    6 +++---
 target-i386/machine.c |    1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

Patch

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 9c3e905..5207b4c 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -692,6 +692,7 @@  typedef struct CPUX86State {
 
     /* For KVM */
     uint32_t mp_state;
+    int32_t exception_injected;
     int32_t interrupt_injected;
     uint8_t soft_interrupt;
     uint8_t nmi_injected;
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 88b504c..001c6c6 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -705,8 +705,8 @@  static int kvm_put_vcpu_events(CPUState *env)
         return 0;
     }
 
-    events.exception.injected = (env->exception_index >= 0);
-    events.exception.nr = env->exception_index;
+    events.exception.injected = (env->exception_injected >= 0);
+    events.exception.nr = env->exception_injected;
     events.exception.has_error_code = env->has_error_code;
     events.exception.error_code = env->error_code;
 
@@ -740,7 +740,7 @@  static int kvm_get_vcpu_events(CPUState *env)
     if (ret < 0) {
        return ret;
     }
-    env->exception_index =
+    env->exception_injected =
        events.exception.injected ? events.exception.nr : -1;
     env->has_error_code = events.exception.has_error_code;
     env->error_code = events.exception.error_code;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index cdc8898..84737ef 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -448,6 +448,7 @@  static const VMStateDescription vmstate_cpu = {
         VMSTATE_INT32_V(interrupt_injected, CPUState, 9),
         VMSTATE_UINT32_V(mp_state, CPUState, 9),
         VMSTATE_UINT64_V(tsc, CPUState, 9),
+        VMSTATE_INT32_V(exception_injected, CPUState, 11),
         VMSTATE_UINT8_V(soft_interrupt, CPUState, 11),
         VMSTATE_UINT8_V(nmi_injected, CPUState, 11),
         VMSTATE_UINT8_V(nmi_pending, CPUState, 11),