From patchwork Sun Jun 14 10:52:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 30143 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 n5EAqdfp017533 for ; Sun, 14 Jun 2009 10:52:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756681AbZFNKw3 (ORCPT ); Sun, 14 Jun 2009 06:52:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756669AbZFNKw2 (ORCPT ); Sun, 14 Jun 2009 06:52:28 -0400 Received: from mx2.redhat.com ([66.187.237.31]:33923 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756075AbZFNKwX (ORCPT ); Sun, 14 Jun 2009 06:52:23 -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 n5EAqPlr023669 for ; Sun, 14 Jun 2009 06:52:25 -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 n5EAqOYl020587; Sun, 14 Jun 2009 06:52:24 -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 n5EAqNka003118; Sun, 14 Jun 2009 06:52:23 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id C67CA18D47B; Sun, 14 Jun 2009 13:52:22 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 4/6] Handle vcpu init/sipi by calling a function on vcpu Date: Sun, 14 Jun 2009 13:52:20 +0300 Message-Id: <1244976742-22926-4-git-send-email-gleb@redhat.com> In-Reply-To: <1244976742-22926-1-git-send-email-gleb@redhat.com> References: <1244976742-22926-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 Instead of having special case in vcpu event loop. Signed-off-by: Gleb Natapov --- cpu-defs.h | 2 -- qemu-kvm.c | 51 +++++++++++++++++---------------------------------- 2 files changed, 17 insertions(+), 36 deletions(-) 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/qemu-kvm.c b/qemu-kvm.c index 5fa7154..af3fd91 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -134,19 +134,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) @@ -331,30 +318,32 @@ static void kvm_vm_state_change_handler(void *context, int running, int reason) pause_all_threads(); } -static void update_regs_for_sipi(CPUState *env) +static void update_regs_for_sipi(void *data) { - kvm_arch_update_regs_for_sipi(env); - env->kvm_cpu_state.sipi_needed = 0; + kvm_arch_update_regs_for_sipi(data); } -static void update_regs_for_init(CPUState *env) +void kvm_update_after_sipi(CPUState *env) { -#ifdef TARGET_I386 - SegmentCache cs = env->segs[R_CS]; -#endif - - cpu_reset(env); + on_vcpu(env, update_regs_for_sipi, env); +} -#ifdef TARGET_I386 - /* restore SIPI vector */ - if(env->kvm_cpu_state.sipi_needed) - env->segs[R_CS] = cs; -#endif +static void update_regs_for_init(void *data) +{ + CPUState *env = data; - env->kvm_cpu_state.init = 0; kvm_arch_load_regs(env); } +void kvm_apic_init(CPUState *env) +{ + if (env->cpu_index != 0) { + if (env->kvm_cpu_state.created) + on_vcpu(env, update_regs_for_init, env); + } else + kvm_update_interrupt_request(env); +} + static void setup_kernel_sigmask(CPUState *env) { sigset_t set; @@ -406,12 +395,6 @@ static int kvm_main_loop_cpu(CPUState *env) kvm_main_loop_wait(env, 1000); if (env->interrupt_request & (CPU_INTERRUPT_HARD | CPU_INTERRUPT_NMI)) env->halted = 0; - if (!kvm_irqchip_in_kernel(kvm_context)) { - 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->halted || kvm_irqchip_in_kernel(kvm_context)) kvm_cpu_exec(env); env->exit_request = 0;