From patchwork Mon Jun 15 13:23:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 30317 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5FDOPri028570 for ; Mon, 15 Jun 2009 13:24:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760904AbZFONXR (ORCPT ); Mon, 15 Jun 2009 09:23:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755550AbZFONXR (ORCPT ); Mon, 15 Jun 2009 09:23:17 -0400 Received: from mx2.redhat.com ([66.187.237.31]:44158 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760709AbZFONXQ (ORCPT ); Mon, 15 Jun 2009 09:23:16 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5FDNJwC026646 for ; Mon, 15 Jun 2009 09:23:19 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5FDNIOg009552; Mon, 15 Jun 2009 09:23:18 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5FDNHhJ025624; Mon, 15 Jun 2009 09:23:18 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 50C5D18D47B; Mon, 15 Jun 2009 16:23:17 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 2/8] Do not use env->halted to decide where halted state should be handled. Date: Mon, 15 Jun 2009 16:23:11 +0300 Message-Id: <1245072197-7538-3-git-send-email-gleb@redhat.com> In-Reply-To: <1245072197-7538-1-git-send-email-gleb@redhat.com> References: <1245072197-7538-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use kvm_irqchip_in_kernel() for that. If irq chip is not handled by userspace kernel should be entered even when CPU is halted. Signed-off-by: Gleb Natapov --- hw/apic.c | 3 +-- qemu-kvm.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/apic.c b/hw/apic.c index c5d97b2..f186202 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -467,8 +467,7 @@ static void apic_init_ipi(APICState *s) cpu_reset(s->cpu_env); - if (!(s->apicbase & MSR_IA32_APICBASE_BSP) && - (!kvm_enabled() || !qemu_kvm_irqchip_in_kernel())) + if (!(s->apicbase & MSR_IA32_APICBASE_BSP)) s->cpu_env->halted = 1; if (kvm_enabled() && !qemu_kvm_irqchip_in_kernel()) diff --git a/qemu-kvm.c b/qemu-kvm.c index ec911ef..7676e02 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -217,6 +217,8 @@ static int has_work(CPUState *env) { if (!vm_running || (env && env->kvm_cpu_state.stopped)) return 0; + if (kvm_irqchip_in_kernel(kvm_context)) + return 1; if (!env->halted) return 1; return kvm_arch_has_work(env); @@ -390,8 +392,6 @@ static int kvm_main_loop_cpu(CPUState *env) setup_kernel_sigmask(env); pthread_mutex_lock(&qemu_mutex); - if (kvm_irqchip_in_kernel(kvm_context)) - env->halted = 0; kvm_qemu_init_env(env); #ifdef TARGET_I386 @@ -412,7 +412,7 @@ static int kvm_main_loop_cpu(CPUState *env) if (env->kvm_cpu_state.sipi_needed) update_regs_for_sipi(env); } - if (!env->halted) + if (!env->halted || kvm_irqchip_in_kernel(kvm_context)) kvm_cpu_exec(env); env->exit_request = 0; env->exception_index = EXCP_INTERRUPT;