From patchwork Thu Feb 4 11:47:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 8220361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AFAC89F4DD for ; Thu, 4 Feb 2016 11:51:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0521320392 for ; Thu, 4 Feb 2016 11:51:10 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ADC3420306 for ; Thu, 4 Feb 2016 11:51:08 +0000 (UTC) Received: from localhost ([::1]:41073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIRI-0005Ar-49 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 04 Feb 2016 06:51:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIO9-0007ZO-F7 for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRIO8-0000DF-CZ for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44513) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIO8-0000Cm-5S for qemu-devel@nongnu.org; Thu, 04 Feb 2016 06:47:52 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C4373C0A524C for ; Thu, 4 Feb 2016 11:47:51 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u14Blg7o002812; Thu, 4 Feb 2016 06:47:50 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 4 Feb 2016 12:47:31 +0100 Message-Id: <1454586455-10202-5-git-send-email-imammedo@redhat.com> In-Reply-To: <1454586455-10202-1-git-send-email-imammedo@redhat.com> References: <1454586455-10202-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, ehabkost@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 5/9] pc: acpi: create Processor and Notify objects only for valid lapics 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do not assume that all lapics in range 0..apic_id_limit are valid and do not create Processor and Notify objects for not possible lapics. Signed-off-by: Igor Mammedov Reviewed-by: Eduardo Habkost --- hw/i386/acpi-build.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 3077061..df13c7d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -960,7 +960,8 @@ static Aml *build_crs(PCIHostState *host, } static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, - AcpiCpuInfo *cpu, AcpiPmInfo *pm) + AcpiCpuInfo *cpu, AcpiPmInfo *pm, + MachineState *machine) { int i; Aml *dev; @@ -969,6 +970,8 @@ static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, Aml *field; Aml *ifctx; Aml *method; + MachineClass *mc = MACHINE_GET_CLASS(machine); + GArray *apic_id_list = mc->possible_cpu_arch_ids(); /* The current AML generator can cover the APIC ID range [0..255], * inclusive, for VCPU hotplug. */ @@ -998,22 +1001,27 @@ static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, aml_append(sb_scope, field); /* build Processor object for each processor */ - for (i = 0; i < acpi_cpus; i++) { - dev = aml_processor(i, 0, 0, "CP%.02X", i); + for (i = 0; i < apic_id_list->len; i++) { + CPUArchId id = FETCH_CPU_ARCH_ID(apic_id_list, i); + int apic_id = id.arch_id; + + assert(apic_id < ACPI_CPU_HOTPLUG_ID_LIMIT); + dev = aml_processor(apic_id, 0, 0, "CP%.02X", apic_id); method = aml_method("_MAT", 0, AML_NOTSERIALIZED); aml_append(method, - aml_return(aml_call1(CPU_MAT_METHOD, aml_int(i)))); + aml_return(aml_call1(CPU_MAT_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_STA", 0, AML_NOTSERIALIZED); aml_append(method, - aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(i)))); + aml_return(aml_call1(CPU_STATUS_METHOD, aml_int(apic_id)))); aml_append(dev, method); method = aml_method("_EJ0", 1, AML_NOTSERIALIZED); aml_append(method, - aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(i), aml_arg(0))) + aml_return(aml_call2(CPU_EJECT_METHOD, aml_int(apic_id), + aml_arg(0))) ); aml_append(dev, method); @@ -1025,10 +1033,13 @@ static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, */ /* Arg0 = Processor ID = APIC ID */ method = aml_method(AML_NOTIFY_METHOD, 2, AML_NOTSERIALIZED); - for (i = 0; i < acpi_cpus; i++) { - ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i))); + for (i = 0; i < apic_id_list->len; i++) { + CPUArchId id = FETCH_CPU_ARCH_ID(apic_id_list, i); + int apic_id = id.arch_id; + + ifctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id))); aml_append(ifctx, - aml_notify(aml_name("CP%.02X", i), aml_arg(1)) + aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1)) ); aml_append(method, ifctx); } @@ -1049,6 +1060,7 @@ static void build_processor_devices(Aml *sb_scope, unsigned acpi_cpus, aml_append(pkg, aml_int(b)); } aml_append(sb_scope, aml_name_decl(CPU_ON_BITMAP, pkg)); + g_array_free(apic_id_list, true); } static void build_memory_devices(Aml *sb_scope, int nr_mem, @@ -2244,7 +2256,8 @@ build_dsdt(GArray *table_data, GArray *linker, sb_scope = aml_scope("\\_SB"); { - build_processor_devices(sb_scope, guest_info->apic_id_limit, cpu, pm); + build_processor_devices(sb_scope, guest_info->apic_id_limit, cpu, pm, + machine); build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);