From nobody Wed Nov 5 08:00:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533910219667205.98132467573214; Fri, 10 Aug 2018 07:10:19 -0700 (PDT) Received: from localhost ([::1]:56449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo87O-0005go-5R for importer@patchew.org; Fri, 10 Aug 2018 10:10:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fo84P-0003SY-Kt for qemu-devel@nongnu.org; Fri, 10 Aug 2018 10:07:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fo84M-0002oQ-Eq for qemu-devel@nongnu.org; Fri, 10 Aug 2018 10:07:13 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34418 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fo84M-0002nr-8r; Fri, 10 Aug 2018 10:07:10 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42C2C40216F5; Fri, 10 Aug 2018 14:07:09 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 744287C50; Fri, 10 Aug 2018 14:07:06 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 10 Aug 2018 16:06:57 +0200 Message-Id: <1533910017-55158-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 14:07:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 10 Aug 2018 14:07:09 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH] acpi: SRAT: do not create reserved gap entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-stable@nongnu.org, lersek@redhat.com, ehabkost@redhat.com, mst@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 848a1cc1e8b04 while introducing SRAT entries for DIMM and NVDIMM also introduced fake entries for gaps between memory devices, assuming that we need all possible range covered with SRAT entries. And it did it wrong since gap would overlap with preceeding entry. Reproduced with following CLI: -m 1G,slots=3D4,maxmem=3D8 \ -object memory-backend-ram,size=3D1G,id=3Dm0 \ -device pc-dimm,memdev=3Dm0,addr=3D0x101000000 \ -object memory-backend-ram,size=3D1G,id=3Dm1 \ -device pc-dimm,memdev=3Dm1 However recent development (10efd7e108) showed that gap entries might be not need. And indeed testing with WS2008DC-WS2016DC guests range shows that memory hotplug works just fine without gap entries. So rather than fixing gap entry borders, just drop them altogether and simplify code around it. Spotted-by: Laszlo Ersek Signed-off-by: Igor Mammedov --- There is no need to update reference blobs since gaps beween dimms aren't generated by any exsting test case. Considering issue is not visible by default lets just merge it into 3.1 and stable 3.0.1 --- hw/i386/acpi-build.c | 62 +++++++++++++++++++-----------------------------= ---- 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e1ee8ae..d3d690f 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2254,48 +2254,16 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, = GArray *tcpalog) static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t ba= se, uint64_t len, int default_node) { - MemoryDeviceInfoList *info_list =3D qmp_memory_device_list(); MemoryDeviceInfoList *info; - MemoryDeviceInfo *mi; - PCDIMMDeviceInfo *di; - uint64_t end =3D base + len, cur, size; - bool is_nvdimm; AcpiSratMemoryAffinity *numamem; - MemoryAffinityFlags flags; + MemoryDeviceInfoList *info_list =3D qmp_memory_device_list();; =20 - for (cur =3D base, info =3D info_list; - cur < end; - cur +=3D size, info =3D info->next) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - - if (!info) { - /* - * Entry is required for Windows to enable memory hotplug in OS - * and for Linux to enable SWIOTLB when booted with less than - * 4G of RAM. Windows works better if the entry sets proximity - * to the highest NUMA node in the machine at the end of the - * reserved space. - * Memory devices may override proximity set by this entry, - * providing _PXM method if necessary. - */ - build_srat_memory(numamem, end - 1, 1, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); - break; - } - - mi =3D info->value; - is_nvdimm =3D (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM); - di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; - - if (cur < di->addr) { - build_srat_memory(numamem, cur, di->addr - cur, default_node, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENA= BLED); - numamem =3D acpi_data_push(table_data, sizeof *numamem); - } - - size =3D di->size; + for (info =3D info_list; info !=3D NULL; info =3D info->next) { + MemoryAffinityFlags flags =3D MEM_AFFINITY_ENABLED; + MemoryDeviceInfo *mi =3D info->value; + bool is_nvdimm =3D (mi->type =3D=3D MEMORY_DEVICE_INFO_KIND_NVDIMM= ); + PCDIMMDeviceInfo *di =3D !is_nvdimm ? mi->u.dimm.data : mi->u.nvdi= mm.data; =20 - flags =3D MEM_AFFINITY_ENABLED; if (di->hotpluggable) { flags |=3D MEM_AFFINITY_HOTPLUGGABLE; } @@ -2303,10 +2271,24 @@ static void build_srat_hotpluggable_memory(GArray *= table_data, uint64_t base, flags |=3D MEM_AFFINITY_NON_VOLATILE; } =20 - build_srat_memory(numamem, di->addr, size, di->node, flags); + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, di->addr, di->size, di->node, flags); } - qapi_free_MemoryDeviceInfoList(info_list); + + /* + * Entry is required for Windows to enable memory hotplug in OS + * and for Linux to enable SWIOTLB when booted with less than + * 4G of RAM. Windows works better if the entry sets proximity + * to the highest NUMA node in the machine at the end of the + * reserved space. + * Memory devices may override proximity set by this entry, + * providing _PXM method if necessary. + */ + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, base + len - 1, 1, default_node, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); + } =20 static void --=20 2.7.4