From patchwork Thu Jun 25 12:20:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 32376 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 n5PCLCpm029365 for ; Thu, 25 Jun 2009 12:21:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753083AbZFYMVE (ORCPT ); Thu, 25 Jun 2009 08:21:04 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752959AbZFYMVD (ORCPT ); Thu, 25 Jun 2009 08:21:03 -0400 Received: from mx2.redhat.com ([66.187.237.31]:56670 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752266AbZFYMU7 (ORCPT ); Thu, 25 Jun 2009 08:20:59 -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 n5PCL3O4029496 for ; Thu, 25 Jun 2009 08:21:03 -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 n5PCL2fs006148; Thu, 25 Jun 2009 08:21:02 -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 n5PCL1LE018019; Thu, 25 Jun 2009 08:21:01 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id A89EF18D479; Thu, 25 Jun 2009 15:21:00 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] Move x86 specific code from qemu-kvm.c to qemu-kvm-x86.c Date: Thu, 25 Jun 2009 15:20:58 +0300 Message-Id: <1245932460-15616-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 Signed-off-by: Gleb Natapov --- qemu-kvm-ia64.c | 4 ++++ qemu-kvm-x86.c | 43 +++++++++++++++++++++++++++++++++++++++++++ qemu-kvm.c | 44 +------------------------------------------- qemu-kvm.h | 1 + 4 files changed, 49 insertions(+), 43 deletions(-) diff --git a/qemu-kvm-ia64.c b/qemu-kvm-ia64.c index 477d24c..582113f 100644 --- a/qemu-kvm-ia64.c +++ b/qemu-kvm-ia64.c @@ -142,3 +142,7 @@ void kvm_arch_do_ioperm(void *_data) struct ioperm_data *data = _data; ioperm(data->start_port, data->num, data->turn_on); } + +void kvm_arch_process_irqchip_events(CPUState *env) +{ +} diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 66b2b19..568df53 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -1574,3 +1574,46 @@ 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 (env->cpu_index != 0) + 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); +} diff --git a/qemu-kvm.c b/qemu-kvm.c index 2d0015c..c5cd038 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1647,19 +1647,6 @@ void kvm_update_interrupt_request(CPUState *env) } } -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 (env->cpu_index != 0) - env->kvm_cpu_state.init = 1; - kvm_update_interrupt_request(env); -} - #include static int kvm_try_push_interrupts(void *opaque) @@ -1863,32 +1850,6 @@ static void kvm_vm_state_change_handler(void *context, int running, int reason) pause_all_threads(); } -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) -{ -#ifdef TARGET_I386 - SegmentCache cs = env->segs[R_CS]; -#endif - - cpu_reset(env); - /* cpu_reset() clears env->halted, cpu should be halted after init */ - env->halted = 1; - -#ifdef TARGET_I386 - /* restore SIPI vector */ - if(env->kvm_cpu_state.sipi_needed) - env->segs[R_CS] = cs; -#endif - - env->kvm_cpu_state.init = 0; - kvm_arch_load_regs(env); -} - static void setup_kernel_sigmask(CPUState *env) { sigset_t set; @@ -1923,10 +1884,7 @@ static void qemu_kvm_system_reset(void) static void 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); + kvm_arch_process_irqchip_events(env); if (kvm_arch_has_work(env)) env->halted = 0; } diff --git a/qemu-kvm.h b/qemu-kvm.h index 68a5b40..9c28566 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -75,6 +75,7 @@ int kvm_arch_qemu_init_env(CPUState *cenv); void kvm_arch_pre_kvm_run(void *opaque, CPUState *env); void kvm_arch_post_kvm_run(void *opaque, CPUState *env); int kvm_arch_has_work(CPUState *env); +void kvm_arch_process_irqchip_events(CPUState *env); int kvm_arch_try_push_interrupts(void *opaque); void kvm_arch_push_nmi(void *opaque); void kvm_arch_update_regs_for_sipi(CPUState *env);