From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKDd-0000Ie-Im for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:42:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VjKDX-0004RF-II for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:42:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VjKDX-0004RB-65 for qemu-devel@nongnu.org; Wed, 20 Nov 2013 21:42:07 -0500 From: Igor Mammedov Date: Thu, 21 Nov 2013 03:38:47 +0100 Message-Id: <1385001528-12003-27-git-send-email-imammedo@redhat.com> In-Reply-To: <1385001528-12003-1-git-send-email-imammedo@redhat.com> References: <1385001528-12003-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 26/27] pc: ACPI BIOS: reserve SRAT entry for hotplug mem hole List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, stefanha@redhat.com, mst@redhat.com, chegu_vinod@hp.com, stefanb@linux.vnet.ibm.com, mjt@tls.msk.ru, mdroth@linux.vnet.ibm.com, armbru@redhat.com, vasilis.liaskovitis@profitbricks.com, quintela@redhat.com, kraxel@redhat.com, aliguori@amazon.com, hutao@cn.fujitsu.com, pbonzini@redhat.com, marcel.a@redhat.com, lcapitulino@redhat.com, afaerber@suse.de Needed for Windows to use hotplugged memory device, otherwise it complains that server is not configured for memory hotplug. Tests shows that aftewards it uses dynamically provided proximity value from _PXM() method if available. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 33 +++++++++++++++++++++++++++++++++ 1 files changed, 33 insertions(+), 0 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 86c1372..ab8e923 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -50,6 +50,7 @@ #include "qapi/qmp/qint.h" #include "qom/qom-qobject.h" +#include "hw/mem/dimm.h" typedef struct AcpiCpuInfo { DECLARE_BITMAP(found_cpus, MAX_CPUMASK_BITS + 1); @@ -1058,6 +1059,31 @@ acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, numamem->range_length = cpu_to_le64(len); } +typedef struct { + AcpiSratMemoryAffinity **numamem; + GArray *table_data; +} AcpiSratHotplugMemoryArg; + +static int acpi_add_hotplug_memory_region_entry(Object *obj, void *opaque) +{ + AcpiSratHotplugMemoryArg *arg = opaque; + DimmBus *bus = (DimmBus *)object_dynamic_cast(obj, TYPE_DIMM_BUS); + + if (bus) { + uint64_t size = memory_region_size(&bus->as); + if (size) { + *arg->numamem = acpi_data_push(arg->table_data, + sizeof **arg->numamem); + acpi_build_srat_memory(*arg->numamem, bus->base, size, 0, + HOT_PLUGGABLE_MEM | ENABLED_MEM); + } + } + + object_child_foreach(obj, acpi_add_hotplug_memory_region_entry, + opaque); + return 0; +} + static void build_srat(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, PcGuestInfo *guest_info) @@ -1133,6 +1159,13 @@ build_srat(GArray *table_data, GArray *linker, acpi_build_srat_memory(numamem, 0, 0, 0, NOFLAGS_MEM); } + { + AcpiSratHotplugMemoryArg arg = { .numamem = &numamem, + .table_data = table_data }; + object_child_foreach(qdev_get_machine(), + acpi_add_hotplug_memory_region_entry, &arg); + } + build_header(linker, table_data, (void *)(table_data->data + srat_start), ACPI_SRAT_SIGNATURE, -- 1.7.1