From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: Igor Mammedov 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> Subject: [Qemu-devel] [PATCH 5/9] pc: acpi: create Processor and Notify objects only for valid lapics List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, ehabkost@redhat.com, mst@redhat.com 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 --- 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); -- 1.8.3.1