From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1fOC-0007Dm-JM for qemu-devel@nongnu.org; Tue, 23 Jul 2013 12:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1fOA-0007DW-8J for qemu-devel@nongnu.org; Tue, 23 Jul 2013 12:24:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1fO9-0007DI-Vv for qemu-devel@nongnu.org; Tue, 23 Jul 2013 12:24:38 -0400 From: Igor Mammedov Date: Tue, 23 Jul 2013 18:23:12 +0200 Message-Id: <1374596592-7027-17-git-send-email-imammedo@redhat.com> In-Reply-To: <1374596592-7027-1-git-send-email-imammedo@redhat.com> References: <1374596592-7027-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 16/16] 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: vasilis.liaskovitis@profitbricks.com, hutao@cn.fujitsu.com, pbonzini@redhat.com 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. Signed-off-by: Igor Mammedov --- hw/i386/acpi-build.c | 31 +++++++++++++++++++++++-------- 1 files changed, 23 insertions(+), 8 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7d7fa1f..69e8e68 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -477,15 +477,19 @@ build_hpet(GArray *table_data, GArray *linker) (void*)hpet, ACPI_HPET_SIGNATURE, sizeof(*hpet), 1); } +#define SRAT_MEM_ENABLED 1 +#define SRAT_MEM_HOTPLUG 2 + static void -acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, - uint64_t base, uint64_t len, int node, int enabled) +acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, + uint64_t len, int node, bool enabled, bool hotplug) { numamem->type = ACPI_SRAT_MEMORY; numamem->length = sizeof(*numamem); memset(numamem->proximity, 0, 4); numamem->proximity[0] = node; - numamem->flags = cpu_to_le32(!!enabled); + numamem->flags |= enabled ? cpu_to_le32(SRAT_MEM_ENABLED) : 0; + numamem->flags |= hotplug ? cpu_to_le32(SRAT_MEM_HOTPLUG) : 0; numamem->base_addr = cpu_to_le64(base); numamem->range_length = cpu_to_le64(len); } @@ -503,10 +507,13 @@ build_srat(GArray *table_data, GArray *linker, int srat_size; int slots; uint64_t mem_len, mem_base, next_base; + uint64_t hotplug_mem_size = guest_info->hotplug_mem_win.end - + guest_info->hotplug_mem_win.begin; srat_size = sizeof(*srat) + sizeof(AcpiSratProcessorAffinity) * guest_info->apic_id_limit + - sizeof(AcpiSratMemoryAffinity) * (guest_info->numa_nodes + 2); + sizeof(AcpiSratMemoryAffinity) * (guest_info->numa_nodes + 2 + + (hotplug_mem_size ? 1 : 0)); srat = acpi_data_push(table_data, srat_size); srat->reserved1 = cpu_to_le32(1); @@ -535,7 +542,7 @@ build_srat(GArray *table_data, GArray *linker, slots = 0; next_base = 0; - acpi_build_srat_memory(numamem, 0, 640*1024, 0, 1); + acpi_build_srat_memory(numamem, 0, 640*1024, 0, true, false); next_base = 1024 * 1024; numamem++; slots++; @@ -551,7 +558,8 @@ build_srat(GArray *table_data, GArray *linker, next_base > guest_info->ram_size) { mem_len -= next_base - guest_info->ram_size; if (mem_len > 0) { - acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1); + acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, + true, false); numamem++; slots++; } @@ -559,15 +567,22 @@ build_srat(GArray *table_data, GArray *linker, mem_len = next_base - guest_info->ram_size; next_base += (1ULL << 32) - guest_info->ram_size; } - acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, 1); + acpi_build_srat_memory(numamem, mem_base, mem_len, i-1, true, false); numamem++; slots++; } + for (; slots < guest_info->numa_nodes + 2; slots++) { - acpi_build_srat_memory(numamem, 0, 0, 0, 0); + acpi_build_srat_memory(numamem, 0, 0, 0, false, false); numamem++; } + /* allocate fake hotplug region upto maxmem for Windows */ + if (hotplug_mem_size) { + acpi_build_srat_memory(numamem, guest_info->hotplug_mem_win.begin, + hotplug_mem_size, 0, true, true); + } + build_header(linker, table_data, (void*)srat, ACPI_SRAT_SIGNATURE, srat_size, 1); } -- 1.7.1