From patchwork Wed May 23 03:07:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 160832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A529AB7017 for ; Wed, 23 May 2012 15:07:35 +1000 (EST) Received: from localhost ([::1]:36811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1y1-0002lj-5V for incoming@patchwork.ozlabs.org; Tue, 22 May 2012 23:10:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44890) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wi-0000Kw-3A for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SX1wc-0005aM-Id for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:07 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35557 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SX1wc-0005ZV-8G for qemu-devel@nongnu.org; Tue, 22 May 2012 23:09:02 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id E9021977E6; Wed, 23 May 2012 05:08:59 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 23 May 2012 05:07:29 +0200 Message-Id: <1337742502-28565-7-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1337742502-28565-1-git-send-email-afaerber@suse.de> References: <1337742502-28565-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Anthony Liguori , Marcelo Tosatti , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "open list:X86" , Avi Kivity Subject: [Qemu-devel] [PATCH qom-next 06/59] pc: Pass X86CPU to cpu_is_bsp() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Also change return type to bool. Signed-off-by: Andreas Färber --- hw/apic.h | 2 +- hw/apic_common.c | 2 +- hw/pc.c | 6 +++--- target-i386/helper.c | 2 +- target-i386/kvm.c | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hw/apic.h b/hw/apic.h index 62179ce..1030097 100644 --- a/hw/apic.h +++ b/hw/apic.h @@ -22,7 +22,7 @@ void apic_handle_tpr_access_report(DeviceState *d, target_ulong ip, TPRAccess access); /* pc.c */ -int cpu_is_bsp(CPUX86State *env); +bool cpu_is_bsp(X86CPU *cpu); DeviceState *cpu_get_current_apic(void); #endif diff --git a/hw/apic_common.c b/hw/apic_common.c index 46a9ff7..bea885b 100644 --- a/hw/apic_common.c +++ b/hw/apic_common.c @@ -207,7 +207,7 @@ static void apic_reset_common(DeviceState *d) APICCommonClass *info = APIC_COMMON_GET_CLASS(s); bool bsp; - bsp = cpu_is_bsp(&s->cpu->env); + bsp = cpu_is_bsp(s->cpu); s->apicbase = 0xfee00000 | (bsp ? MSR_IA32_APICBASE_BSP : 0) | MSR_IA32_APICBASE_ENABLE; diff --git a/hw/pc.c b/hw/pc.c index 6bb3d2a..f0cbfef 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -870,10 +870,10 @@ void pc_init_ne2k_isa(ISABus *bus, NICInfo *nd) nb_ne2k++; } -int cpu_is_bsp(CPUX86State *env) +bool cpu_is_bsp(X86CPU *cpu) { /* We hard-wire the BSP to the first CPU. */ - return env->cpu_index == 0; + return cpu->env.cpu_index == 0; } DeviceState *cpu_get_current_apic(void) @@ -945,7 +945,7 @@ static void pc_cpu_reset(void *opaque) CPUX86State *env = &cpu->env; cpu_reset(CPU(cpu)); - env->halted = !cpu_is_bsp(env); + env->halted = !cpu_is_bsp(cpu); } static X86CPU *pc_new_cpu(const char *cpu_model) diff --git a/target-i386/helper.c b/target-i386/helper.c index 2cc8097..018a98f 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1191,7 +1191,7 @@ void do_cpu_init(X86CPU *cpu) env->interrupt_request = sipi; env->pat = pat; apic_init_reset(env->apic_state); - env->halted = !cpu_is_bsp(env); + env->halted = !cpu_is_bsp(cpu); } void do_cpu_sipi(X86CPU *cpu) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0d0d8f6..97a2cb1 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -579,11 +579,13 @@ int kvm_arch_init_vcpu(CPUX86State *env) void kvm_arch_reset_vcpu(CPUX86State *env) { + X86CPU *cpu = x86_env_get_cpu(env); + env->exception_injected = -1; env->interrupt_injected = -1; env->xcr0 = 1; if (kvm_irqchip_in_kernel()) { - env->mp_state = cpu_is_bsp(env) ? KVM_MP_STATE_RUNNABLE : + env->mp_state = cpu_is_bsp(cpu) ? KVM_MP_STATE_RUNNABLE : KVM_MP_STATE_UNINITIALIZED; } else { env->mp_state = KVM_MP_STATE_RUNNABLE;