From patchwork Tue May 4 12:45:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 51606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8A0EAB7D2D for ; Tue, 4 May 2010 23:30:40 +1000 (EST) Received: from localhost ([127.0.0.1]:35893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9Hvp-0000mi-Q8 for incoming@patchwork.ozlabs.org; Tue, 04 May 2010 09:13:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O9HnD-0006pW-6R for qemu-devel@nongnu.org; Tue, 04 May 2010 09:04:07 -0400 Received: from [140.186.70.92] (port=53985 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O9Hn3-0006lZ-Cb for qemu-devel@nongnu.org; Tue, 04 May 2010 09:04:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O9Hmv-0003Bx-Pk for qemu-devel@nongnu.org; Tue, 04 May 2010 09:03:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63971) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O9Hmv-0003BH-GC for qemu-devel@nongnu.org; Tue, 04 May 2010 09:03:49 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o44D3l6W011532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 4 May 2010 09:03:48 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o44D3l9L025746; Tue, 4 May 2010 09:03:47 -0400 Received: from amt.cnet (vpn2-10-150.ams2.redhat.com [10.36.10.150]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o44D20cc023683; Tue, 4 May 2010 09:03:38 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 9CEB468A9C9; Tue, 4 May 2010 09:55:05 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o44Ct36L016607; Tue, 4 May 2010 09:55:03 -0300 Message-Id: <20100504124634.632584455@redhat.com> User-Agent: quilt/0.47-1 Date: Tue, 04 May 2010 09:45:27 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org, qemu-devel@nongnu.org References: <20100504124518.979470863@redhat.com> Content-Disposition: inline; filename=enable-smp X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti Subject: [Qemu-devel] [patch uq/master 9/9] kvm: enable smp > 1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Process INIT/SIPI requests and enable -smp > 1. Signed-off-by: Marcelo Tosatti Index: qemu/kvm-all.c =================================================================== --- qemu.orig/kvm-all.c +++ qemu/kvm-all.c @@ -593,11 +593,6 @@ int kvm_init(int smp_cpus) int ret; int i; - if (smp_cpus > 1) { - fprintf(stderr, "No SMP KVM support, use '-smp 1'\n"); - return -EINVAL; - } - s = qemu_mallocz(sizeof(KVMState)); #ifdef KVM_CAP_SET_GUEST_DEBUG @@ -840,6 +835,11 @@ int kvm_cpu_exec(CPUState *env) } #endif + if (kvm_arch_process_irqchip_events(env)) { + ret = 0; + break; + } + if (env->kvm_vcpu_dirty) { kvm_arch_put_registers(env, KVM_PUT_RUNTIME_STATE); env->kvm_vcpu_dirty = 0; Index: qemu/kvm.h =================================================================== --- qemu.orig/kvm.h +++ qemu/kvm.h @@ -90,6 +90,8 @@ int kvm_arch_handle_exit(CPUState *env, int kvm_arch_pre_run(CPUState *env, struct kvm_run *run); +int kvm_arch_process_irqchip_events(CPUState *env); + int kvm_arch_get_registers(CPUState *env); /* state subset only touched by the VCPU itself during runtime */ Index: qemu/target-i386/kvm.c =================================================================== --- qemu.orig/target-i386/kvm.c +++ qemu/target-i386/kvm.c @@ -1073,6 +1073,22 @@ int kvm_arch_post_run(CPUState *env, str return 0; } +int kvm_arch_process_irqchip_events(CPUState *env) +{ + if (env->interrupt_request & CPU_INTERRUPT_INIT) { + kvm_cpu_synchronize_state(env); + do_cpu_init(env); + env->exception_index = EXCP_HALTED; + } + + if (env->interrupt_request & CPU_INTERRUPT_SIPI) { + kvm_cpu_synchronize_state(env); + do_cpu_sipi(env); + } + + return env->halted; +} + static int kvm_handle_halt(CPUState *env) { if (!((env->interrupt_request & CPU_INTERRUPT_HARD) && Index: qemu/target-ppc/kvm.c =================================================================== --- qemu.orig/target-ppc/kvm.c +++ qemu/target-ppc/kvm.c @@ -224,6 +224,11 @@ int kvm_arch_post_run(CPUState *env, str return 0; } +int kvm_arch_process_irqchip_events(CPUState *env) +{ + return 0; +} + static int kvmppc_handle_halt(CPUState *env) { if (!(env->interrupt_request & CPU_INTERRUPT_HARD) && (msr_ee)) { Index: qemu/target-s390x/kvm.c =================================================================== --- qemu.orig/target-s390x/kvm.c +++ qemu/target-s390x/kvm.c @@ -175,6 +175,11 @@ int kvm_arch_post_run(CPUState *env, str return 0; } +int kvm_arch_process_irqchip_events(CPUState *env) +{ + return 0; +} + static void kvm_s390_interrupt_internal(CPUState *env, int type, uint32_t parm, uint64_t parm64, int vm) {