From patchwork Mon Apr 15 12:05:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 236573 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 611352C00EB for ; Mon, 15 Apr 2013 22:06:24 +1000 (EST) Received: from localhost ([::1]:53571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URiAw-0007ft-I1 for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 08:06:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URiAI-0007fJ-IF for qemu-devel@nongnu.org; Mon, 15 Apr 2013 08:05:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URiAH-0006LU-30 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 08:05:42 -0400 Received: from mail-bk0-x231.google.com ([2a00:1450:4008:c01::231]:52144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URiAG-0006LE-Ot for qemu-devel@nongnu.org; Mon, 15 Apr 2013 08:05:41 -0400 Received: by mail-bk0-f49.google.com with SMTP id w12so2318825bku.8 for ; Mon, 15 Apr 2013 05:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=wcJEbty1VoLZOHgbZ3n5T/tT5jSBIjPckHZvx9YVZzo=; b=S30j66wzGEw6hcrv9HcertJS1fsIN9hk9V1wQo1CZbdc8tin6CvxDkmBo8zp2LHPV8 yQocBgvxOZFAvvzPD4xaZaXdrwoqQb/E239NI6orAMsOn2ya/OQ6YdCAV04lliLozCMY ybPgsxM453h9SS2L6jWuHwGUZMzRUvKrPKsHgSvIn0wvBfsx61w1m1JbdI1FvvLS3wu4 UvB8RwxiNOplOKzFWNMDnlbLTrDMFs/LXYPtEbu8jBFqJM3qwDgQHQMquNTRpkgVBWya 9ggrpID/P31iDL5d4KhZAMSp+HEqMG3S1NsYHD13REU5erYzS4wa3PlCwFclJaVX82tL ZP9A== X-Received: by 10.204.239.197 with SMTP id kx5mr8127441bkb.71.1366027539880; Mon, 15 Apr 2013 05:05:39 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id fy17sm8381589bkc.6.2013.04.15.05.05.38 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 15 Apr 2013 05:05:38 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 15 Apr 2013 14:05:31 +0200 Message-Id: <1366027532-1120-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1366027532-1120-1-git-send-email-pbonzini@redhat.com> References: <1366027532-1120-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4008:c01::231 Cc: gnatapov@redhat.com, agraf@suse.de Subject: [Qemu-devel] [PATCH uq/master v3 1/2] kvm: reset state from the CPU's reset method X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Paolo Bonzini Reviewed-by: Andreas Färber --- v2->v3: add stub kvm_arch_reset_vcpu for s390 include/sysemu/kvm.h | 2 -- kvm-all.c | 11 ----------- target-arm/kvm.c | 4 ---- target-i386/cpu.c | 5 +++++ target-i386/kvm_i386.h | 1 + target-ppc/kvm.c | 4 ---- target-s390x/cpu.c | 4 ++++ target-s390x/cpu.h | 5 +++++ 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index f2d97b5..50072c5 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -199,8 +199,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 9b433d3..57616ef 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -207,13 +207,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; @@ -253,10 +246,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-arm/kvm.c b/target-arm/kvm.c index 6bfb103..f45a63d 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -430,10 +430,6 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) return 0; } -void kvm_arch_reset_vcpu(CPUState *cs) -{ -} - bool kvm_arch_stop_on_emulation_error(CPUState *cs) { return true; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 6dd993f..1754225 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" @@ -2015,6 +2016,10 @@ static void x86_cpu_reset(CPUState *s) } s->halted = !cpu_is_bsp(cpu); + + if (kvm_enabled()) { + kvm_arch_reset_vcpu(s); + } #endif } diff --git a/target-i386/kvm_i386.h b/target-i386/kvm_i386.h index 4392ab4..3accc2d 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(CPUState *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 5e9dddb..1e8b01d 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -425,10 +425,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 23fe51f..6321384 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -84,6 +84,10 @@ static void s390_cpu_reset(CPUState *s) * after incrementing the cpu counter */ #if !defined(CONFIG_USER_ONLY) s->halted = 1; + + if (kvm_enabled()) { + kvm_arch_reset_vcpu(s); + } #endif tlb_flush(env, 1); } diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h index e351005..cc51de5 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -352,11 +352,16 @@ void s390x_cpu_timer(void *opaque); int s390_virtio_hypercall(CPUS390XState *env); #ifdef CONFIG_KVM +void kvm_arch_reset_vcpu(CPUState *cs); 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_arch_reset_vcpu(CPUState *cs) +{ +} + static inline void kvm_s390_interrupt(S390CPU *cpu, int type, uint32_t code) { }