Received: from eggs.gnu.org ([208.118.235.92]:42773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sogwl-0004xO-0M for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sogwg-0001uB-Jl for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:22:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sogwg-0001tX-AX for qemu-devel@nongnu.org; Tue, 10 Jul 2012 16:22:06 -0400 From: Eduardo Habkost Date: Tue, 10 Jul 2012 17:22:19 -0300 Message-Id: <1341951743-2285-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1341951743-2285-1-git-send-email-ehabkost@redhat.com> References: <1341951743-2285-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [QEMU RFC PATCH 4/7] i386: create apic_id_for_cpu() function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Igor Mammedov , seabios@seabios.org, Gleb Natapov , Anthony Liguori Currently we need a way to calculate the Initial APIC ID using only the CPU index, as the CPU hotplug interface doesn't have a method to send the correct APIC ID to the ACPI hotplug code at hotplug-time. Signed-off-by: Eduardo Habkost --- target-i386/cpu.c | 2 +- target-i386/cpu.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index b257241..c54619a 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1770,7 +1770,7 @@ static void x86_cpu_initfn(Object *obj) x86_cpuid_get_tsc_freq, x86_cpuid_set_tsc_freq, NULL, NULL, NULL); - env->cpuid_apic_id = env->cpu_index; + env->cpuid_apic_id = apic_id_for_cpu(env->cpu_index); /* init various static tables used in TCG mode */ if (tcg_enabled() && !inited) { diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 6924c7f..e983c10 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -908,6 +908,23 @@ void cpu_clear_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx); + +/* Calculate initial APIC ID for a specific CPU index + * + * Currently we need to be able to calculate the APIC ID from the CPU index + * only, as the QEMU<->Seabios(ACPI) interface for CPU hotplug isn't able + * to let the ACPI CPU hotplug code to retrivew the APIC ID at hotplug + * time. + */ +static inline uint8_t apic_id_for_cpu(int cpu_index) +{ + /* right now APIC ID == CPU index. this will eventually change to use + * the CPU topology configuration properly + */ + return cpu_index; +} + + /* helper.c */ int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, int is_write, int mmu_idx); -- 1.7.10.4