From nobody Sat Oct 25 23:33:51 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 1521517103501805.721358046187; Mon, 19 Mar 2018 20:38:23 -0700 (PDT) Received: from localhost ([::1]:45308 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey86J-0006zH-4K for importer@patchew.org; Mon, 19 Mar 2018 23:38:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50838) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ey7mB-0006Zw-PV for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ey7mA-00085z-GR for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42566 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 1ey7mA-00085f-An for qemu-devel@nongnu.org; Mon, 19 Mar 2018 23:17:26 -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 00AED4023BB3; Tue, 20 Mar 2018 03:17:26 +0000 (UTC) Received: from redhat.com (ovpn-121-0.rdu2.redhat.com [10.10.121.0]) by smtp.corp.redhat.com (Postfix) with SMTP id 2F9361DB26; Tue, 20 Mar 2018 03:17:23 +0000 (UTC) Date: Tue, 20 Mar 2018 05:17:23 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1521515720-612046-19-git-send-email-mst@redhat.com> References: <1521515720-612046-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1521515720-612046-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent 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.7]); Tue, 20 Mar 2018 03:17:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 20 Mar 2018 03:17:26 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@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] [PULL v2 18/50] hw/acpi-build: build SRAT memory affinity structures for DIMM devices 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: Peter Maydell , Eduardo Habkost , Haozhong Zhang , Paolo Bonzini , Marcel Apfelbaum , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Haozhong Zhang ACPI 6.2A Table 5-129 "SPA Range Structure" requires the proximity domain of a NVDIMM SPA range must match with corresponding entry in SRAT table. The address ranges of vNVDIMM in QEMU are allocated from the hot-pluggable address space, which is entirely covered by one SRAT memory affinity structure. However, users can set the vNVDIMM proximity domain in NFIT SPA range structure by the 'node' property of '-device nvdimm' to a value different than the one in the above SRAT memory affinity structure. In order to solve such proximity domain mismatch, this patch builds one SRAT memory affinity structure for each DIMM device present at boot time, including both PC-DIMM and NVDIMM, with the proximity domain specified in '-device pc-dimm' or '-device nvdimm'. The remaining hot-pluggable address space is covered by one or multiple SRAT memory affinity structures with the proximity domain of the last node as before. Signed-off-by: Haozhong Zhang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/i386/acpi-build.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index ebde2cd..1df9ed2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2250,6 +2250,55 @@ build_tpm2(GArray *table_data, BIOSLinker *linker, G= Array *tcpalog) #define HOLE_640K_START (640 * 1024) #define HOLE_640K_END (1024 * 1024) =20 +static void build_srat_hotpluggable_memory(GArray *table_data, uint64_t ba= se, + uint64_t len, int default_node) +{ + MemoryDeviceInfoList *info_list =3D qmp_pc_dimm_device_list(); + MemoryDeviceInfoList *info; + MemoryDeviceInfo *mi; + PCDIMMDeviceInfo *di; + uint64_t end =3D base + len, cur, size; + bool is_nvdimm; + AcpiSratMemoryAffinity *numamem; + MemoryAffinityFlags flags; + + 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) { + build_srat_memory(numamem, cur, end - cur, 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; + + flags =3D MEM_AFFINITY_ENABLED; + if (di->hotpluggable) { + flags |=3D MEM_AFFINITY_HOTPLUGGABLE; + } + if (is_nvdimm) { + flags |=3D MEM_AFFINITY_NON_VOLATILE; + } + + build_srat_memory(numamem, di->addr, size, di->node, flags); + } + + qapi_free_MemoryDeviceInfoList(info_list); +} + static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { @@ -2361,10 +2410,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) * providing _PXM method if necessary. */ if (hotplugabble_address_space_size) { - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, pcms->hotplug_memory.base, - hotplugabble_address_space_size, pcms->numa_node= s - 1, - MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED= ); + build_srat_hotpluggable_memory(table_data, pcms->hotplug_memory.ba= se, + hotplugabble_address_space_size, + pcms->numa_nodes - 1); } =20 build_header(linker, table_data, --=20 MST