From patchwork Sun Jun 28 15:46:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 32757 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 n5SFkOPO024324 for ; Sun, 28 Jun 2009 15:46:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752282AbZF1PqK (ORCPT ); Sun, 28 Jun 2009 11:46:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753328AbZF1PqJ (ORCPT ); Sun, 28 Jun 2009 11:46:09 -0400 Received: from mx2.redhat.com ([66.187.237.31]:42310 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669AbZF1PqI (ORCPT ); Sun, 28 Jun 2009 11:46:08 -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 n5SFkBgd017007 for ; Sun, 28 Jun 2009 11:46:11 -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 n5SFkAUB011886; Sun, 28 Jun 2009 11:46:11 -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 n5SFk90b007737; Sun, 28 Jun 2009 11:46:09 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 97B3A18D479; Sun, 28 Jun 2009 18:46:08 +0300 (IDT) Date: Sun, 28 Jun 2009 18:46:08 +0300 From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] Use upstream QEMU apic init/sipi handling Message-ID: <20090628154608.GP20289@redhat.com> MIME-Version: 1.0 Content-Disposition: inline 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 Remove KVM specific init/sipi handling from hw/apic.c. Now when upstream QEMU handles init/sipi in a cpu loop KVM can do the same. Signed-off-by: Gleb Natapov --- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/cpu-defs.h b/cpu-defs.h index e17209a..7570096 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -140,8 +140,6 @@ typedef struct CPUWatchpoint { struct qemu_work_item; struct KVMCPUState { - int sipi_needed; - int init; pthread_t thread; int signalled; int stop; diff --git a/hw/apic.c b/hw/apic.c index 7ac926a..1a0d38b 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -492,9 +492,6 @@ void apic_init_reset(CPUState *env) s->wait_for_sipi = 1; env->halted = !(s->apicbase & MSR_IA32_APICBASE_BSP); - - if (kvm_enabled() && !qemu_kvm_irqchip_in_kernel()) - kvm_apic_init(s->cpu_env); } static void apic_startup(APICState *s, int vector_num) @@ -517,8 +514,6 @@ void apic_sipi(CPUState *env) 0xffff, 0); env->halted = 0; s->wait_for_sipi = 0; - if (kvm_enabled() && !qemu_kvm_irqchip_in_kernel()) - kvm_update_after_sipi(env); } static void apic_deliver(APICState *s, uint8_t dest, uint8_t dest_mode, diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index a78073e..1eb147e 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -1576,45 +1576,10 @@ uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t function, return kvm_get_supported_cpuid(kvm_context, function, reg); } -void kvm_update_after_sipi(CPUState *env) -{ - env->kvm_cpu_state.sipi_needed = 1; - kvm_update_interrupt_request(env); -} - -void kvm_apic_init(CPUState *env) -{ - if (!cpu_is_bsp(env)) - env->kvm_cpu_state.init = 1; - kvm_update_interrupt_request(env); -} - -static void update_regs_for_sipi(CPUState *env) -{ - kvm_arch_update_regs_for_sipi(env); - env->kvm_cpu_state.sipi_needed = 0; -} - -static void update_regs_for_init(CPUState *env) -{ - SegmentCache cs = env->segs[R_CS]; - - cpu_reset(env); - /* cpu_reset() clears env->halted, cpu should be halted after init */ - env->halted = 1; - - /* restore SIPI vector */ - if(env->kvm_cpu_state.sipi_needed) - env->segs[R_CS] = cs; - - env->kvm_cpu_state.init = 0; - kvm_arch_load_regs(env); -} - void kvm_arch_process_irqchip_events(CPUState *env) { - if (env->kvm_cpu_state.init) - update_regs_for_init(env); - if (env->kvm_cpu_state.sipi_needed) - update_regs_for_sipi(env); + if (env->interrupt_request & CPU_INTERRUPT_INIT) + do_cpu_init(env); + if (env->interrupt_request & CPU_INTERRUPT_SIPI) + do_cpu_sipi(env); }