[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/8] kvm: reset state from the CPU's reset method
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 1/8] kvm: reset state from the CPU's reset method |
Date: |
Tue, 29 Apr 2014 13:54:25 +0200 |
Now that we have a CPU object with a reset method, it is better to
keep the KVM reset close to the CPU reset. Using qemu_register_reset
as we do now keeps them far apart.
With this patch, ARM and PPC no longer call the kvm_arch_ function, so
it can get removed there. i386 and s390x call it from X86CPU/S390CPU
reset handler, and the function gets an X86CPU/S390CPU.
Note that s390-specific functions are called kvm_s390_*, while
x86-specific functions are called kvm_arch_*, so this series only
renames the S390 kvm_arch_reset_vcpu. Changing that is the topic of a
separate patch.
Reviewed-by: Gleb Natapov <address@hidden>
Reviewed-by: Andreas Färber <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/sysemu/kvm.h | 2 --
kvm-all.c | 11 -----------
target-i386/cpu.c | 5 +++++
target-i386/kvm.c | 3 +--
target-i386/kvm_i386.h | 1 +
target-ppc/kvm.c | 4 ----
target-s390x/cpu.c | 4 ++++
target-s390x/cpu.h | 5 +++++
target-s390x/kvm.c | 6 ++++--
9 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 0bee1e8..cab306d 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -245,8 +245,6 @@ int kvm_arch_init_vcpu(CPUState *cpu);
/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */
unsigned long kvm_arch_vcpu_id(CPUState *cpu);
-void kvm_arch_reset_vcpu(CPUState *cpu);
-
int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr);
int kvm_arch_on_sigbus(int code, void *addr);
diff --git a/kvm-all.c b/kvm-all.c
index 82a9119..1285cf0 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -223,13 +223,6 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot
*slot)
return kvm_vm_ioctl(s, KVM_SET_USER_MEMORY_REGION, &mem);
}
-static void kvm_reset_vcpu(void *opaque)
-{
- CPUState *cpu = opaque;
-
- kvm_arch_reset_vcpu(cpu);
-}
-
int kvm_init_vcpu(CPUState *cpu)
{
KVMState *s = kvm_state;
@@ -269,10 +262,6 @@ int kvm_init_vcpu(CPUState *cpu)
}
ret = kvm_arch_init_vcpu(cpu);
- if (ret == 0) {
- qemu_register_reset(kvm_reset_vcpu, cpu);
- kvm_arch_reset_vcpu(cpu);
- }
err:
return ret;
}
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 8fd1497..05c3005 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -24,6 +24,7 @@
#include "cpu.h"
#include "sysemu/kvm.h"
#include "sysemu/cpus.h"
+#include "kvm_i386.h"
#include "topology.h"
#include "qemu/option.h"
@@ -2486,6 +2487,10 @@ static void x86_cpu_reset(CPUState *s)
}
s->halted = !cpu_is_bsp(cpu);
+
+ if (kvm_enabled()) {
+ kvm_arch_reset_vcpu(cpu);
+ }
#endif
}
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 4389959..2319d78 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -724,9 +724,8 @@ int kvm_arch_init_vcpu(CPUState *cs)
return 0;
}
-void kvm_arch_reset_vcpu(CPUState *cs)
+void kvm_arch_reset_vcpu(X86CPU *cpu)
{
- X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;
env->exception_injected = -1;
diff --git a/target-i386/kvm_i386.h b/target-i386/kvm_i386.h
index 4392ab4..b0b2193 100644
--- a/target-i386/kvm_i386.h
+++ b/target-i386/kvm_i386.h
@@ -14,6 +14,7 @@
#include "sysemu/kvm.h"
bool kvm_allows_irq0_override(void);
+void kvm_arch_reset_vcpu(X86CPU *cs);
int kvm_device_pci_assign(KVMState *s, PCIHostDeviceAddress *dev_addr,
uint32_t flags, uint32_t *dev_id);
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 9974b10..ff15820 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -434,10 +434,6 @@ int kvm_arch_init_vcpu(CPUState *cs)
return ret;
}
-void kvm_arch_reset_vcpu(CPUState *cpu)
-{
-}
-
static void kvm_sw_tlb_put(PowerPCCPU *cpu)
{
CPUPPCState *env = &cpu->env;
diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index dfd83e8..c3082b7 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -152,6 +152,10 @@ static void s390_cpu_full_reset(CPUState *s)
* after incrementing the cpu counter */
#if !defined(CONFIG_USER_ONLY)
s->halted = 1;
+
+ if (kvm_enabled()) {
+ kvm_s390_reset_vcpu(cpu);
+ }
#endif
tlb_flush(s, 1);
}
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index f332d41..e40382e 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -353,11 +353,16 @@ void s390x_cpu_timer(void *opaque);
int s390_virtio_hypercall(CPUS390XState *env);
#ifdef CONFIG_KVM
+void kvm_s390_reset_vcpu(S390CPU *cpu);
void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code);
void kvm_s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token);
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm,
uint64_t parm64, int vm);
#else
+static inline void kvm_s390_reset_vcpu(S390CPU *cpu)
+{
+}
+
static inline void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code)
{
}
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 56b9af7..8c37a81 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -116,14 +116,16 @@ int kvm_arch_init_vcpu(CPUState *cpu)
return 0;
}
-void kvm_arch_reset_vcpu(CPUState *cpu)
+void kvm_s390_reset_vcpu(S390CPU *cpu)
{
+ CPUState *cs = CPU(cpu);
+
/* The initial reset call is needed here to reset in-kernel
* vcpu data that we can't access directly from QEMU
* (i.e. with older kernels which don't support sync_regs/ONE_REG).
* Before this ioctl cpu_synchronize_state() is called in common kvm
* code (kvm-all) */
- if (kvm_vcpu_ioctl(cpu, KVM_S390_INITIAL_RESET, NULL)) {
+ if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) {
perror("Can't reset vcpu\n");
}
}
--
1.8.3.1
- [Qemu-devel] [PATCH 0/8] x86: correctly implement soft reset, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 3/8] target-i386: fix set of registers zeroed on reset, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 1/8] kvm: reset state from the CPU's reset method,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 5/8] apic: do not accept SIPI on the bootstrap processor, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 4/8] target-i386: preserve FPU and MSR state on INIT, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 2/8] kvm: forward INIT signals coming from the chipset, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 6/8] cpu: make CPU_INTERRUPT_RESET available on all targets, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 7/8] pc: port 92 reset requires a low->high transition, Paolo Bonzini, 2014/04/29
- [Qemu-devel] [PATCH 8/8] x86: correctly implement soft reset, Paolo Bonzini, 2014/04/29