{"id":808515,"url":"http://patchwork.ozlabs.org/api/patches/808515/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504231805-30957-2-git-send-email-douly.fnst@cn.fujitsu.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1504231805-30957-2-git-send-email-douly.fnst@cn.fujitsu.com>","list_archive_url":null,"date":"2017-09-01T02:10:02","name":"[v6,1/4] hw/acpi-build: Fix SRAT memory building in case of node 0 without RAM","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"01659f1055c821015555dea35930e2508d6dcc00","submitter":{"id":69629,"url":"http://patchwork.ozlabs.org/api/people/69629/?format=json","name":"Dou Liyang","email":"douly.fnst@cn.fujitsu.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/1504231805-30957-2-git-send-email-douly.fnst@cn.fujitsu.com/mbox/","series":[{"id":941,"url":"http://patchwork.ozlabs.org/api/series/941/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=941","date":"2017-09-01T02:10:02","name":"[v6,1/4] hw/acpi-build: Fix SRAT memory building in case of node 0 without RAM","version":6,"mbox":"http://patchwork.ozlabs.org/series/941/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/808515/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808515/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xk2mD5WMnz9sPt\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 12:11:22 +1000 (AEST)","from localhost ([::1]:39379 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dnbQN-0004a1-N3\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 22:11:11 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:39748)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dnbPi-0004Z6-Ac\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 22:10:31 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dnbPe-0007GQ-Hl\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 22:10:30 -0400","from mail.cn.fujitsu.com ([183.91.158.132]:16790\n\thelo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dnbPe-0007Fx-6i\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 22:10:26 -0400","from localhost (HELO cn.fujitsu.com) ([10.167.33.5])\n\tby heian.cn.fujitsu.com with ESMTP; 01 Sep 2017 10:10:18 +0800","from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80])\n\tby cn.fujitsu.com (Postfix) with ESMTP id 7319C472403E;\n\tFri,  1 Sep 2017 10:10:17 +0800 (CST)","from localhost.localdomain.localdomain (10.167.226.106) by\n\tG08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP\n\tServer (TLS) id 14.3.319.2; Fri, 1 Sep 2017 10:10:17 +0800"],"X-IronPort-AV":"E=Sophos;i=\"5.41,456,1498492800\"; d=\"scan'208\";a=\"25087498\"","From":"Dou Liyang <douly.fnst@cn.fujitsu.com>","To":"<qemu-devel@nongnu.org>","Date":"Fri, 1 Sep 2017 10:10:02 +0800","Message-ID":"<1504231805-30957-2-git-send-email-douly.fnst@cn.fujitsu.com>","X-Mailer":"git-send-email 2.5.5","In-Reply-To":"<1504231805-30957-1-git-send-email-douly.fnst@cn.fujitsu.com>","References":"<1504231805-30957-1-git-send-email-douly.fnst@cn.fujitsu.com>","MIME-Version":"1.0","Content-Type":"text/plain","X-Originating-IP":"[10.167.226.106]","X-yoursite-MailScanner-ID":"7319C472403E.ADABC","X-yoursite-MailScanner":"Found to be clean","X-yoursite-MailScanner-From":"douly.fnst@cn.fujitsu.com","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"183.91.158.132","Subject":"[Qemu-devel] [PATCH v6 1/4] hw/acpi-build: Fix SRAT memory building\n\tin case of node 0 without RAM","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"imammedo@redhat.com, rth@twiddle.net, ehabkost@redhat.com,\n\tDou Liyang <douly.fnst@cn.fujitsu.com>, mst@redhat.com","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"From: Eduardo Habkost <ehabkost@redhat.com>\n\nCurrently, Using the fisrt node without memory on the machine makes\nQEMU unhappy. With this example command line:\n  ... \\\n  -m 1024M,slots=4,maxmem=32G \\\n  -numa node,nodeid=0 \\\n  -numa node,mem=1024M,nodeid=1 \\\n  -numa node,nodeid=2 \\\n  -numa node,nodeid=3 \\\nGuest reports \"No NUMA configuration found\" and the NUMA topology is\nwrong.\n\nThis is because when QEMU builds ACPI SRAT, it regards node 0 as the\ndefault node to deal with the memory hole(640K-1M). this means the\nnode0 must have some memory(>1M), but, actually it can have no\nmemory.\n\nFix this problem by cut out the 640K hole in the same way the PCI\n4G hole does.\n\nSigned-off-by: Eduardo Habkost <ehabkost@redhat.com>\nSigned-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n---\n hw/i386/acpi-build.c | 28 ++++++++++++++++++++++------\n 1 file changed, 22 insertions(+), 6 deletions(-)","diff":"diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\nindex 98dd424..a0cf3bf 100644\n--- a/hw/i386/acpi-build.c\n+++ b/hw/i386/acpi-build.c\n@@ -2318,6 +2318,9 @@ build_tpm2(GArray *table_data, BIOSLinker *linker)\n                  (void *)tpm2_ptr, \"TPM2\", sizeof(*tpm2_ptr), 4, NULL, NULL);\n }\n \n+#define HOLE_640K_START  (640 * 1024)\n+#define HOLE_640K_END   (1024 * 1024)\n+\n static void\n build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n {\n@@ -2373,17 +2376,30 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n     next_base = 0;\n     numa_start = table_data->len;\n \n-    numamem = acpi_data_push(table_data, sizeof *numamem);\n-    build_srat_memory(numamem, 0, 640 * 1024, 0, MEM_AFFINITY_ENABLED);\n-    next_base = 1024 * 1024;\n     for (i = 1; i < pcms->numa_nodes + 1; ++i) {\n         mem_base = next_base;\n         mem_len = pcms->node_mem[i - 1];\n-        if (i == 1) {\n-            mem_len -= 1024 * 1024;\n-        }\n         next_base = mem_base + mem_len;\n \n+        /* Cut out the 640K hole */\n+        if (mem_base <= HOLE_640K_START &&\n+            next_base > HOLE_640K_START) {\n+            mem_len -= next_base - HOLE_640K_START;\n+            if (mem_len > 0) {\n+                numamem = acpi_data_push(table_data, sizeof *numamem);\n+                build_srat_memory(numamem, mem_base, mem_len, i - 1,\n+                                  MEM_AFFINITY_ENABLED);\n+            }\n+\n+            /* Check for the rare case: 640K < RAM < 1M */\n+            if (next_base <= HOLE_640K_END) {\n+                next_base = HOLE_640K_END;\n+                continue;\n+            }\n+            mem_base = HOLE_640K_END;\n+            mem_len = next_base - HOLE_640K_END;\n+        }\n+\n         /* Cut out the ACPI_PCI hole */\n         if (mem_base <= pcms->below_4g_mem_size &&\n             next_base > pcms->below_4g_mem_size) {\n","prefixes":["v6","1/4"]}