From patchwork Fri Mar 22 20:37:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 2322461 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C58D1DFE82 for ; Fri, 22 Mar 2013 20:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422961Ab3CVUhx (ORCPT ); Fri, 22 Mar 2013 16:37:53 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:36856 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422948Ab3CVUh0 (ORCPT ); Fri, 22 Mar 2013 16:37:26 -0400 Received: by mail-wi0-f170.google.com with SMTP id hm11so9080170wib.5 for ; Fri, 22 Mar 2013 13:37:24 -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=iUeF/tjDABqpDYrKgkiQ0xA86DYBld2z+3Ur1Iow50s=; b=NsYMs2HbV/D/elvUOo7aBIE2qcc46zv5XAuT+4zwly5OJfZva+z1mLd94I/sK9KzG4 emtaJgBBWTBsTHZYfji+rlUggicYnRirnhoLM0UhVaucjERR91+KCEOATNMag9Zf++tD 184qYNa9yLhZTKvxp4Kp6ccWerC40cHmVLcQUJQ5AZxMRsHdEt4c3fNV0pIIvjwMFtK5 di2hi9oShb3jIoxSS+Oi+AFc7aFEu8CSvo6+UH/3LrMVqmJCqNBBg9Q07Nz0fALjq1cm ie8Jtu597ssZCVA5MtJUprtqm0bL5Qpniir+tbcGAZQ8T0NUiTFwu1vL57I0e6JRUtk8 xZwA== X-Received: by 10.180.185.239 with SMTP id ff15mr13815294wic.2.1363984644777; Fri, 22 Mar 2013 13:37:24 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id j4sm13077190wiz.10.2013.03.22.13.37.22 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Mar 2013 13:37:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Gleb Natapov , Marcelo Tosatti , Alexander Graf Subject: [PATCH uq/master v2 1/2] kvm: reset state from the CPU's reset method Date: Fri, 22 Mar 2013 21:37:16 +0100 Message-Id: <1363984637-18132-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1363984637-18132-1-git-send-email-pbonzini@redhat.com> References: <1363984637-18132-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.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. As a side effect, a CPU reset (cpu_reset) will reset the KVM state too. Signed-off-by: Paolo Bonzini --- 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 | 1 + 8 files changed, 11 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 82e2e08..841b85f 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 a0640db..a5746cd 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 e663ff0..0adea12 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -424,10 +424,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..fc84159 100644 --- a/target-s390x/cpu.h +++ b/target-s390x/cpu.h @@ -352,6 +352,7 @@ 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,