From nobody Mon Feb 9 09:22:53 2026 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505853339604922.8741980550326; Tue, 19 Sep 2017 13:35:39 -0700 (PDT) Received: from localhost ([::1]:45289 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duPF4-0002Pz-Ja for importer@patchew.org; Tue, 19 Sep 2017 16:35:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duOzv-0005eC-69 for qemu-devel@nongnu.org; Tue, 19 Sep 2017 16:20:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duOzq-0004sX-JT for qemu-devel@nongnu.org; Tue, 19 Sep 2017 16:19:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59672) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duOzq-0004s0-Bh for qemu-devel@nongnu.org; Tue, 19 Sep 2017 16:19:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D5698123A; Tue, 19 Sep 2017 20:19:53 +0000 (UTC) Received: from localhost (ovpn-116-23.gru2.redhat.com [10.97.116.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 094435D98A; Tue, 19 Sep 2017 20:19:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D5698123A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 17:18:49 -0300 Message-Id: <20170919201850.14772-12-ehabkost@redhat.com> In-Reply-To: <20170919201850.14772-1-ehabkost@redhat.com> References: <20170919201850.14772-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 19 Sep 2017 20:19:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 11/12] hw/acpi-build: Fix SRAT memory building in case of node 0 without RAM 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: Marcel Apfelbaum , Igor Mammedov 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currently, Using the fisrt node without memory on the machine makes QEMU unhappy. With this example command line: ... \ -m 1024M,slots=3D4,maxmem=3D32G \ -numa node,nodeid=3D0 \ -numa node,mem=3D1024M,nodeid=3D1 \ -numa node,nodeid=3D2 \ -numa node,nodeid=3D3 \ Guest reports "No NUMA configuration found" and the NUMA topology is wrong. This is because when QEMU builds ACPI SRAT, it regards node 0 as the default node to deal with the memory hole(640K-1M). this means the node0 must have some memory(>1M), but, actually it can have no memory. Fix this problem by cut out the 640K hole in the same way the PCI 4G hole does. Signed-off-by: Eduardo Habkost Signed-off-by: Dou Liyang Message-Id: <1504231805-30957-2-git-send-email-douly.fnst@cn.fujitsu.com> Signed-off-by: Eduardo Habkost --- hw/i386/acpi-build.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4d19d91e1b..d72bcdcd49 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2288,6 +2288,9 @@ build_tpm2(GArray *table_data, BIOSLinker *linker) (void *)tpm2_ptr, "TPM2", sizeof(*tpm2_ptr), 4, NULL, NUL= L); } =20 +#define HOLE_640K_START (640 * 1024) +#define HOLE_640K_END (1024 * 1024) + static void build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine) { @@ -2343,17 +2346,30 @@ build_srat(GArray *table_data, BIOSLinker *linker, = MachineState *machine) next_base =3D 0; numa_start =3D table_data->len; =20 - numamem =3D acpi_data_push(table_data, sizeof *numamem); - build_srat_memory(numamem, 0, 640 * 1024, 0, MEM_AFFINITY_ENABLED); - next_base =3D 1024 * 1024; for (i =3D 1; i < pcms->numa_nodes + 1; ++i) { mem_base =3D next_base; mem_len =3D pcms->node_mem[i - 1]; - if (i =3D=3D 1) { - mem_len -=3D 1024 * 1024; - } next_base =3D mem_base + mem_len; =20 + /* Cut out the 640K hole */ + if (mem_base <=3D HOLE_640K_START && + next_base > HOLE_640K_START) { + mem_len -=3D next_base - HOLE_640K_START; + if (mem_len > 0) { + numamem =3D acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, mem_base, mem_len, i - 1, + MEM_AFFINITY_ENABLED); + } + + /* Check for the rare case: 640K < RAM < 1M */ + if (next_base <=3D HOLE_640K_END) { + next_base =3D HOLE_640K_END; + continue; + } + mem_base =3D HOLE_640K_END; + mem_len =3D next_base - HOLE_640K_END; + } + /* Cut out the ACPI_PCI hole */ if (mem_base <=3D pcms->below_4g_mem_size && next_base > pcms->below_4g_mem_size) { --=20 2.13.5