[PATCH] [Userspace] kvm/ia64: Qemu : Add get/set_mpstate for Ipf.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From 1de77b49314cfbabd65a6aef4d25430de22f2a61 Mon Sep 17 00:00:00 2001
From: Xiantao Zhang <xiantao.zhang@xxxxxxxxx>
Date: Thu, 28 Aug 2008 11:04:02 +0800
Subject: [PATCH] kvm/ia64: Qemu : Add get/set_mpstate for Ipf.

Add get/set_mpstate for Ipf.
Signed-off-by: Xiantao Zhang <xiantao.zhang@xxxxxxxxx>
---
 libkvm/libkvm.c            |    7 +++++--
 qemu/hw/serial.c           |    4 ++--
 qemu/qemu-kvm-ia64.c       |   37 +++++++++++++++++++++++++++++++++++++
 qemu/target-ia64/cpu.h     |    2 +-
 qemu/target-ia64/machine.c |   12 ++++++++++++
 5 files changed, 57 insertions(+), 5 deletions(-)

diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 5edfad7..bb503ff 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -285,7 +285,8 @@ int kvm_create_vcpu(kvm_context_t kvm, int slot)
 {
 	long mmap_size;
 	int r;
-
+	
+	fprintf(stderr, "kvm_create_vcpu\n");
 	r = ioctl(kvm->vm_fd, KVM_CREATE_VCPU, slot);
 	if (r == -1) {
 		r = -errno;
@@ -836,11 +837,13 @@ int kvm_set_mpstate(kvm_context_t kvm, int vcpu,
struct kvm_mp_state *mp_state)
 }
 #endif
 
+int log_flag =0;
 static int handle_mmio(kvm_context_t kvm, struct kvm_run *kvm_run)
 {
 	unsigned long addr = kvm_run->mmio.phys_addr;
 	void *data = kvm_run->mmio.data;
-
+	if (log_flag)
+		fprintf(stderr,"addr:%lx\n", addr);
 	/* hack: Red Hat 7.1 generates these weird accesses. */
 	if ((addr > 0xa0000-4 && addr <= 0xa0000) && kvm_run->mmio.len
== 3)
 	    return 0;
diff --git a/qemu/hw/serial.c b/qemu/hw/serial.c
index d70207e..a08c675 100644
--- a/qemu/hw/serial.c
+++ b/qemu/hw/serial.c
@@ -676,10 +676,10 @@ static int serial_load(QEMUFile *f, void *opaque,
int version_id)
     return 0;
 }
 
+
 static void serial_reset(void *opaque)
 {
     SerialState *s = opaque;
-
     s->rbr = 0;
     s->ier = 0;
     s->iir = UART_IIR_NO_INT;
@@ -702,8 +702,8 @@ static void serial_reset(void *opaque)
     s->thr_ipending = 0;
     s->last_break_enable = 0;
     qemu_irq_lower(s->irq);
+    fprintf(stderr, "serial called!\n");
 }
-
 static void serial_init_core(SerialState *s, qemu_irq irq, int
baudbase,
 			     CharDriverState *chr)
 {
diff --git a/qemu/qemu-kvm-ia64.c b/qemu/qemu-kvm-ia64.c
index d227d22..042c7ed 100644
--- a/qemu/qemu-kvm-ia64.c
+++ b/qemu/qemu-kvm-ia64.c
@@ -62,6 +62,43 @@ void kvm_arch_update_regs_for_sipi(CPUState *env)
 {
 }
 
+void kvm_save_mpstate(CPUState *env)
+{
+#ifdef KVM_CAP_MP_STATE
+    int r;
+    struct kvm_mp_state mp_state;
+
+    r = kvm_get_mpstate(kvm_context, env->cpu_index, &mp_state);
+    if (r < 0)
+        env->mp_state = -1;
+    else
+        env->mp_state = mp_state.mp_state;
+#endif
+}
+
+void kvm_load_mpstate(CPUState *env)
+{
+#ifdef KVM_CAP_MP_STATE
+    struct kvm_mp_state mp_state = { .mp_state = env->mp_state };
+
+    /*
+     * -1 indicates that the host did not support GET_MP_STATE ioctl,
+     *  so don't touch it.
+     */
+    if (env->mp_state != -1)
+        kvm_set_mpstate(kvm_context, env->cpu_index, &mp_state);
+#endif
+}
+
 void kvm_arch_cpu_reset(CPUState *env)
 {
+    if (kvm_irqchip_in_kernel(kvm_context)) {
+#ifdef KVM_CAP_MP_STATE
+	kvm_reset_mpstate(kvm_context, env->cpu_index);
+#endif
+    } else {
+	env->interrupt_request &= ~CPU_INTERRUPT_HARD;
+	env->halted = 1;
+	env->exception_index = EXCP_HLT;
+    }
 }
diff --git a/qemu/target-ia64/cpu.h b/qemu/target-ia64/cpu.h
index a3ff7a8..e65e628 100644
--- a/qemu/target-ia64/cpu.h
+++ b/qemu/target-ia64/cpu.h
@@ -44,7 +44,7 @@
 typedef struct CPUIA64State {
    CPU_COMMON;
    uint32_t hflags;
-
+   int mp_state;
 } CPUIA64State;
 
 #define CPUState CPUIA64State
diff --git a/qemu/target-ia64/machine.c b/qemu/target-ia64/machine.c
index 4dc5d5e..a32b01a 100644
--- a/qemu/target-ia64/machine.c
+++ b/qemu/target-ia64/machine.c
@@ -11,9 +11,21 @@ void register_machines(void)
 
 void cpu_save(QEMUFile *f, void *opaque)
 {
+    CPUState *env = opaque;
+
+    if (kvm_enabled()) {
+        kvm_save_registers(env);
+        kvm_save_mpstate(env);
+    }
 }
 
 int cpu_load(QEMUFile *f, void *opaque, int version_id)
 {
+    CPUState *env = opaque;
+
+    if (kvm_enabled()) {
+        kvm_load_registers(env);
+        kvm_load_mpstate(env);
+    }
     return 0;
 }
-- 
1.5.1

Attachment: 0001-kvm-ia64-Qemu-Add-get-set_mpstate-for-Ipf.patch
Description: 0001-kvm-ia64-Qemu-Add-get-set_mpstate-for-Ipf.patch


[Index of Archives]     [Linux KVM Devel]     [Linux Virtualization]     [Big List of Linux Books]     [Linux SCSI]     [Yosemite Forum]

  Powered by Linux