From nobody Mon Feb 9 14:03:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1590682922; cv=none; d=zohomail.com; s=zohoarc; b=R/pXSnbWyobNsjxz/x0leCEEod792obEELPUizygLtOmJ+d4NaA1BOmP+MieRVbO2lsaCEzO3Rpkalv+YBFGZ6pnUJO9RkNmRlUwJIrj53PkF8qnZgOwjlYFF3yPjK1/I+2nkxQ91USFDjrCCnd4jmelQ99BRhkAhsxGDVbsx/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590682922; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N4s1quHsr225pknHtfQtecOeIWn9Lczlhu51ia8T9Js=; b=RF0Ez5KoTGLN3C/TzApzxIMaeVXQt7HGU+jvPTTU1fXnAFrAmvYtsgVwpltrVrnd+yv50vZZYlf2jok5Rzyesi+tXFOpnOPYkShO1J+xvpGV0R5G41Ntllh4Z/tDx7E5ESDdEeOlfveQe0drPowPOKJeZeQAt0wui5Qy/Yjrkpg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1590682922182862.9305544478873; Thu, 28 May 2020 09:22:02 -0700 (PDT) Received: from localhost ([::1]:50286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeLI8-0002SJ-Qp for importer@patchew.org; Thu, 28 May 2020 12:22:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeLGn-0000aN-Ej for qemu-devel@nongnu.org; Thu, 28 May 2020 12:20:38 -0400 Received: from mga11.intel.com ([192.55.52.93]:35636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeLGl-00010J-8N for qemu-devel@nongnu.org; Thu, 28 May 2020 12:20:36 -0400 Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 09:20:31 -0700 Received: from vverma7-mobl4.lm.intel.com ([10.251.139.189]) by orsmga006.jf.intel.com with ESMTP; 28 May 2020 09:20:30 -0700 IronPort-SDR: LE49tBhrR3VNS58wCAC6FS62kTuey49EA+IrEcrOTdLMRVNHq8wvu02C2eb3UEFQLlIDiob3d/ IGSsQsGcSG6w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False IronPort-SDR: yYLET34s3sxPaUAuMwRNwrhpMgK/deCcQI8ccUxSYd9wzu06M6E8hLbrgSSeAC8M0NKI8wWG+/ LKUVOK/grj6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,445,1583222400"; d="scan'208";a="270903778" From: Vishal Verma To: Subject: [PATCH v3 2/3] hw/acpi-build: account for NVDIMM numa nodes in SRAT Date: Thu, 28 May 2020 10:20:10 -0600 Message-Id: <20200528162011.16258-3-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200528162011.16258-1-vishal.l.verma@intel.com> References: <20200528162011.16258-1-vishal.l.verma@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.55.52.93; envelope-from=vishal.l.verma@intel.com; helo=mga11.intel.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/28 12:20:29 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Xiao Guangrong , "Michael S. Tsirkin" , jingqi.liu@intel.com, Dave Hansen , Eduardo Habkost , Vishal Verma , Paolo Bonzini , Igor Mammedov , Dan Williams , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" NVDIMMs can belong to their own proximity domains, as described by the NFIT. In such cases, the SRAT needs to have Memory Affinity structures in the SRAT for these NVDIMMs, otherwise Linux doesn't populate node data structures properly during NUMA initialization. See the following for an example failure case. https://lore.kernel.org/linux-nvdimm/20200416225438.15208-1-vishal.l.verma@= intel.com/ Fix this by adding device address range and node information from NVDIMMs to the SRAT in build_srat(). The relevant command line options to exercise this are below. Nodes 0-1 contain CPUs and regular memory, and nodes 2-3 are the NVDIMM address space. -numa node,nodeid=3D0,mem=3D2048M, -numa node,nodeid=3D1,mem=3D2048M, -numa node,nodeid=3D2,mem=3D0, -object memory-backend-file,id=3Dnvmem0,share,mem-path=3Dnvdimm-0,size=3D= 16384M,align=3D128M -device nvdimm,memdev=3Dnvmem0,id=3Dnv0,label-size=3D2M,node=3D2 -numa node,nodeid=3D3,mem=3D0, -object memory-backend-file,id=3Dnvmem1,share,mem-path=3Dnvdimm-1,size=3D= 16384M,align=3D128M -device nvdimm,memdev=3Dnvmem1,id=3Dnv1,label-size=3D2M,node=3D3 Cc: Jingqi Liu Cc: Michael S. Tsirkin Reviewed-by: Jingqi Liu Signed-off-by: Vishal Verma --- hw/acpi/nvdimm.c | 23 +++++++++++++++++++++++ hw/i386/acpi-build.c | 5 +++++ include/hw/mem/nvdimm.h | 1 + 3 files changed, 29 insertions(+) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 9316d12b70..8f7cc16add 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -28,6 +28,7 @@ =20 #include "qemu/osdep.h" #include "qemu/uuid.h" +#include "qapi/error.h" #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" #include "hw/acpi/bios-linker-loader.h" @@ -1334,6 +1335,28 @@ static void nvdimm_build_ssdt(GArray *table_offsets,= GArray *table_data, free_aml_allocator(); } =20 +void nvdimm_build_srat(GArray *table_data) +{ + GSList *device_list =3D nvdimm_get_device_list(); + + for (; device_list; device_list =3D device_list->next) { + AcpiSratMemoryAffinity *numamem =3D NULL; + DeviceState *dev =3D device_list->data; + Object *obj =3D OBJECT(dev); + uint64_t addr, size; + int node; + + node =3D object_property_get_int(obj, PC_DIMM_NODE_PROP, &error_ab= ort); + addr =3D object_property_get_uint(obj, PC_DIMM_ADDR_PROP, &error_a= bort); + size =3D object_property_get_uint(obj, PC_DIMM_SIZE_PROP, &error_a= bort); + + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, addr, size, node, + MEM_AFFINITY_ENABLED | MEM_AFFINITY_NON_VOLATILE= ); + } + g_slist_free(device_list); +} + void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, BIOSLinker *linker, NVDIMMState *state, uint32_t ram_slots) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2e15f6848e..d996525e2c 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2428,6 +2428,11 @@ build_srat(GArray *table_data, BIOSLinker *linker, M= achineState *machine) MEM_AFFINITY_ENABLED); } } + + if (machine->nvdimms_state->is_enabled) { + nvdimm_build_srat(table_data); + } + slots =3D (table_data->len - numa_start) / sizeof *numamem; for (; slots < pcms->numa_nodes + 2; slots++) { numamem =3D acpi_data_push(table_data, sizeof *numamem); diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h index a3c08955e8..b67a1aedf6 100644 --- a/include/hw/mem/nvdimm.h +++ b/include/hw/mem/nvdimm.h @@ -155,6 +155,7 @@ typedef struct NVDIMMState NVDIMMState; void nvdimm_init_acpi_state(NVDIMMState *state, MemoryRegion *io, struct AcpiGenericAddress dsm_io, FWCfgState *fw_cfg, Object *owner); +void nvdimm_build_srat(GArray *table_data); void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, BIOSLinker *linker, NVDIMMState *state, uint32_t ram_slots); --=20 2.26.2