[{"id":1761328,"web_url":"http://patchwork.ozlabs.org/comment/1761328/","msgid":"<20170831213618.GG7570@localhost.localdomain>","list_archive_url":null,"date":"2017-08-31T21:36:18","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":195,"url":"http://patchwork.ozlabs.org/api/people/195/","name":"Eduardo Habkost","email":"ehabkost@redhat.com"},"content":"On Thu, Aug 31, 2017 at 08:04:26PM +0800, Dou Liyang wrote:\n> From: Eduardo Habkost <ehabkost@redhat.com>\n> \n> Currently, Using the fisrt node without memory on the machine makes\n> QEMU 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 \\\n> Guest reports \"No NUMA configuration found\" and the NUMA topology is\n> wrong.\n> \n> This is because when QEMU builds ACPI SRAT, it regards node 0 as the\n> default node to deal with the memory hole(640K-1M). this means the\n> node0 must have some memory(>1M), but, actually it can have no\n> memory.\n> \n> Fix this problem by  cut out the 640K hole in the same way the PCI\n> 4G hole does. Also do some cleanup.\n> \n> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>\n> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n> ---\n>  hw/i386/acpi-build.c | 30 +++++++++++++++++++++++-------\n>  1 file changed, 23 insertions(+), 7 deletions(-)\n> \n> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\n> index 98dd424..48525a1 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> @@ -2395,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n>              }\n>              mem_base = 1ULL << 32;\n>              mem_len = next_base - pcms->below_4g_mem_size;\n> -            next_base += (1ULL << 32) - pcms->below_4g_mem_size;\n> +            next_base = mem_base + mem_len;\n\nIs this extra change intentional?\n\nI find the code more readable with it, but it should go in a\nseparate patch because it is unrelated to the bug fix.","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>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=ehabkost@redhat.com"],"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 3xjwgY4GS6z9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 07:36:56 +1000 (AEST)","from localhost ([::1]:57601 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 1dnX8t-0005n9-RO\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 17:36:51 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:52782)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <ehabkost@redhat.com>) id 1dnX8W-0005n0-SZ\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 17:36:29 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <ehabkost@redhat.com>) id 1dnX8T-0008Dh-PE\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 17:36:28 -0400","from mx1.redhat.com ([209.132.183.28]:47138)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <ehabkost@redhat.com>) id 1dnX8T-0008Ao-Fc\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 17:36:25 -0400","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id A8AA06146D;\n\tThu, 31 Aug 2017 21:36:22 +0000 (UTC)","from localhost (ovpn-116-66.gru2.redhat.com [10.97.116.66])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6069E5F92D;\n\tThu, 31 Aug 2017 21:36:20 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com A8AA06146D","Date":"Thu, 31 Aug 2017 18:36:18 -0300","From":"Eduardo Habkost <ehabkost@redhat.com>","To":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<20170831213618.GG7570@localhost.localdomain>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>","X-Fnord":"you can see the fnord","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.14","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tThu, 31 Aug 2017 21:36:22 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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, qemu-devel@nongnu.org,\n\tmst@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>"}},{"id":1761421,"web_url":"http://patchwork.ozlabs.org/comment/1761421/","msgid":"<68bc78e7-c928-8343-c9ee-ce7e531d35d4@cn.fujitsu.com>","list_archive_url":null,"date":"2017-09-01T01:29:13","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":69629,"url":"http://patchwork.ozlabs.org/api/people/69629/","name":"Dou Liyang","email":"douly.fnst@cn.fujitsu.com"},"content":"Hi, Eduardo\n\nAt 09/01/2017 05:36 AM, Eduardo Habkost wrote:\n> On Thu, Aug 31, 2017 at 08:04:26PM +0800, Dou Liyang wrote:\n>> From: Eduardo Habkost <ehabkost@redhat.com>\n>>\n>> Currently, Using the fisrt node without memory on the machine makes\n>> QEMU 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 \\\n>> Guest reports \"No NUMA configuration found\" and the NUMA topology is\n>> wrong.\n>>\n>> This is because when QEMU builds ACPI SRAT, it regards node 0 as the\n>> default node to deal with the memory hole(640K-1M). this means the\n>> node0 must have some memory(>1M), but, actually it can have no\n>> memory.\n>>\n>> Fix this problem by  cut out the 640K hole in the same way the PCI\n>> 4G hole does. Also do some cleanup.\n>>\n>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>\n>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n>> ---\n>>  hw/i386/acpi-build.c | 30 +++++++++++++++++++++++-------\n>>  1 file changed, 23 insertions(+), 7 deletions(-)\n>>\n>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\n>> index 98dd424..48525a1 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>> @@ -2395,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n>>              }\n>>              mem_base = 1ULL << 32;\n>>              mem_len = next_base - pcms->below_4g_mem_size;\n>> -            next_base += (1ULL << 32) - pcms->below_4g_mem_size;\n>> +            next_base = mem_base + mem_len;\n>\n> Is this extra change intentional?\n>\n\nYes, it is, Just for readability. :-)\n\n> I find the code more readable with it, but it should go in a\n> separate patch because it is unrelated to the bug fix.\n>\n\nIndeed, I will split it out.\n\nThanks,\n\tdou.","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 3xk1rS6WWlz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 11:29:59 +1000 (AEST)","from localhost ([::1]:37679 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 1dnamR-0002Bq-1q\n\tfor incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 21:29:55 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:34883)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dnam4-0002BW-7S\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 21:29:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dnalz-0001Zj-JX\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 21:29:32 -0400","from mail.cn.fujitsu.com ([183.91.158.132]:56037\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 1dnaly-0001Z3-OV\n\tfor qemu-devel@nongnu.org; Thu, 31 Aug 2017 21:29:27 -0400","from localhost (HELO cn.fujitsu.com) ([10.167.33.5])\n\tby heian.cn.fujitsu.com with ESMTP; 01 Sep 2017 09:29:20 +0800","from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80])\n\tby cn.fujitsu.com (Postfix) with ESMTP id CB55A472403D;\n\tFri,  1 Sep 2017 09:29:16 +0800 (CST)","from localhost.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 09:29:17 +0800"],"X-IronPort-AV":"E=Sophos;i=\"5.41,456,1498492800\"; d=\"scan'208\";a=\"25085513\"","To":"Eduardo Habkost <ehabkost@redhat.com>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<20170831213618.GG7570@localhost.localdomain>","From":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<68bc78e7-c928-8343-c9ee-ce7e531d35d4@cn.fujitsu.com>","Date":"Fri, 1 Sep 2017 09:29:13 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20170831213618.GG7570@localhost.localdomain>","Content-Type":"text/plain; charset=\"windows-1252\"; format=flowed","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[10.167.226.106]","X-yoursite-MailScanner-ID":"CB55A472403D.A9F95","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":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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, qemu-devel@nongnu.org,\n\tmst@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>"}},{"id":1762542,"web_url":"http://patchwork.ozlabs.org/comment/1762542/","msgid":"<20170904113907.2a6e0cc7@nial.brq.redhat.com>","list_archive_url":null,"date":"2017-09-04T09:39:07","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":11305,"url":"http://patchwork.ozlabs.org/api/people/11305/","name":"Igor Mammedov","email":"imammedo@redhat.com"},"content":"On Thu, 31 Aug 2017 20:04:26 +0800\nDou Liyang <douly.fnst@cn.fujitsu.com> wrote:\n\n> From: Eduardo Habkost <ehabkost@redhat.com>\n> \n> Currently, Using the fisrt node without memory on the machine makes\n> QEMU 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 \\\n> Guest reports \"No NUMA configuration found\" and the NUMA topology is\n> wrong.\n> \n> This is because when QEMU builds ACPI SRAT, it regards node 0 as the\n> default node to deal with the memory hole(640K-1M). this means the\n> node0 must have some memory(>1M), but, actually it can have no\n> memory.\n> \n> Fix this problem by  cut out the 640K hole in the same way the PCI\n> 4G hole does. Also do some cleanup.\n> \n> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>\n> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n> ---\n>  hw/i386/acpi-build.c | 30 +++++++++++++++++++++++-------\n>  1 file changed, 23 insertions(+), 7 deletions(-)\n> \n> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\n> index 98dd424..48525a1 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;\nIs this assignment really necessary?\n\nit seems that next_base will be set at the start of the loop.\n\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> @@ -2395,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n>              }\n>              mem_base = 1ULL << 32;\n>              mem_len = next_base - pcms->below_4g_mem_size;\n> -            next_base += (1ULL << 32) - pcms->below_4g_mem_size;\n> +            next_base = mem_base + mem_len;\n>          }\n>          numamem = acpi_data_push(table_data, sizeof *numamem);\n>          build_srat_memory(numamem, mem_base, mem_len, i - 1,","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>)","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx07.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=imammedo@redhat.com"],"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 3xm4ZL6KdGz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 19:39:53 +1000 (AEST)","from localhost ([::1]:47651 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 1donrD-0001SZ-6v\n\tfor incoming@patchwork.ozlabs.org; Mon, 04 Sep 2017 05:39:51 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:50952)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1donql-0001Ra-GI\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 05:39:27 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1donqb-0003nM-Jq\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 05:39:23 -0400","from mx1.redhat.com ([209.132.183.28]:36824)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <imammedo@redhat.com>) id 1donqb-0003m8-Ba\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 05:39:13 -0400","from smtp.corp.redhat.com\n\t(int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 35F7AC047B6B;\n\tMon,  4 Sep 2017 09:39:12 +0000 (UTC)","from nial.brq.redhat.com (unknown [10.43.2.241])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 43D647E677;\n\tMon,  4 Sep 2017 09:39:09 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 35F7AC047B6B","Date":"Mon, 4 Sep 2017 11:39:07 +0200","From":"Igor Mammedov <imammedo@redhat.com>","To":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<20170904113907.2a6e0cc7@nial.brq.redhat.com>","In-Reply-To":"<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.15","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.31]);\n\tMon, 04 Sep 2017 09:39:12 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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":"rth@twiddle.net, mst@redhat.com, qemu-devel@nongnu.org,\n\tehabkost@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>"}},{"id":1762558,"web_url":"http://patchwork.ozlabs.org/comment/1762558/","msgid":"<ec0c5471-5960-42aa-2723-f3dcb63d9fdc@cn.fujitsu.com>","list_archive_url":null,"date":"2017-09-04T10:16:31","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":69629,"url":"http://patchwork.ozlabs.org/api/people/69629/","name":"Dou Liyang","email":"douly.fnst@cn.fujitsu.com"},"content":"At 09/04/2017 05:39 PM, Igor Mammedov wrote:\n> On Thu, 31 Aug 2017 20:04:26 +0800\n> Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:\n>\n>> From: Eduardo Habkost <ehabkost@redhat.com>\n>>\n>> Currently, Using the fisrt node without memory on the machine makes\n>> QEMU 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 \\\n>> Guest reports \"No NUMA configuration found\" and the NUMA topology is\n>> wrong.\n>>\n>> This is because when QEMU builds ACPI SRAT, it regards node 0 as the\n>> default node to deal with the memory hole(640K-1M). this means the\n>> node0 must have some memory(>1M), but, actually it can have no\n>> memory.\n>>\n>> Fix this problem by  cut out the 640K hole in the same way the PCI\n>> 4G hole does. Also do some cleanup.\n>>\n>> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>\n>> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n>> ---\n>>  hw/i386/acpi-build.c | 30 +++++++++++++++++++++++-------\n>>  1 file changed, 23 insertions(+), 7 deletions(-)\n>>\n>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\n>> index 98dd424..48525a1 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> Is this assignment really necessary?\n>\n\nIt is necessary, because we set mem_base to next_base before setting\nnext_base;\n\nBut, I can refine it:\n\n                                    MEM_AFFINITY_ENABLED);\n              }\n\n+            mem_base = HOLE_640K_END;\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\nIs it?\n\nThanks,\n\tdou.\n\n> it seems that next_base will be set at the start of the loop.\n>\n\n\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>> @@ -2395,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n>>              }\n>>              mem_base = 1ULL << 32;\n>>              mem_len = next_base - pcms->below_4g_mem_size;\n>> -            next_base += (1ULL << 32) - pcms->below_4g_mem_size;\n>> +            next_base = mem_base + mem_len;\n>>          }\n>>          numamem = acpi_data_push(table_data, sizeof *numamem);\n>>          build_srat_memory(numamem, mem_base, mem_len, i - 1,\n>\n>\n>\n>","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 3xm5Pq6RzPz9s82\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 20:17:31 +1000 (AEST)","from localhost ([::1]:50324 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 1dooRc-00086i-6s\n\tfor incoming@patchwork.ozlabs.org; Mon, 04 Sep 2017 06:17:28 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:48233)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dooQz-00080r-9I\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 06:16:54 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dooQr-0005OZ-5f\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 06:16:49 -0400","from mail.cn.fujitsu.com ([183.91.158.132]:27667\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 1dooQq-0005N5-Ci\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 06:16:41 -0400","from localhost (HELO cn.fujitsu.com) ([10.167.33.5])\n\tby heian.cn.fujitsu.com with ESMTP; 04 Sep 2017 18:16:33 +0800","from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85])\n\tby cn.fujitsu.com (Postfix) with ESMTP id AEB944725543;\n\tMon,  4 Sep 2017 18:16:32 +0800 (CST)","from localhost.localdomain (10.167.226.106) by\n\tG08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP\n\tServer (TLS) id 14.3.361.1; Mon, 4 Sep 2017 18:16:38 +0800"],"X-IronPort-AV":"E=Sophos;i=\"5.41,474,1498492800\"; d=\"scan'208\";a=\"25189356\"","To":"Igor Mammedov <imammedo@redhat.com>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<20170904113907.2a6e0cc7@nial.brq.redhat.com>","From":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<ec0c5471-5960-42aa-2723-f3dcb63d9fdc@cn.fujitsu.com>","Date":"Mon, 4 Sep 2017 18:16:31 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20170904113907.2a6e0cc7@nial.brq.redhat.com>","Content-Type":"text/plain; charset=\"windows-1252\"; format=flowed","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[10.167.226.106]","X-yoursite-MailScanner-ID":"AEB944725543.A905E","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":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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":"rth@twiddle.net, mst@redhat.com, qemu-devel@nongnu.org,\n\tehabkost@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>"}},{"id":1762579,"web_url":"http://patchwork.ozlabs.org/comment/1762579/","msgid":"<20170904131118.4de9ed44@nial.brq.redhat.com>","list_archive_url":null,"date":"2017-09-04T11:11:18","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":11305,"url":"http://patchwork.ozlabs.org/api/people/11305/","name":"Igor Mammedov","email":"imammedo@redhat.com"},"content":"On Mon, 4 Sep 2017 18:16:31 +0800\nDou Liyang <douly.fnst@cn.fujitsu.com> wrote:\n\n> At 09/04/2017 05:39 PM, Igor Mammedov wrote:\n> > On Thu, 31 Aug 2017 20:04:26 +0800\n> > Dou Liyang <douly.fnst@cn.fujitsu.com> wrote:\n> >  \n> >> From: Eduardo Habkost <ehabkost@redhat.com>\n> >>\n> >> Currently, Using the fisrt node without memory on the machine makes\n> >> QEMU 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 \\\n> >> Guest reports \"No NUMA configuration found\" and the NUMA topology is\n> >> wrong.\n> >>\n> >> This is because when QEMU builds ACPI SRAT, it regards node 0 as the\n> >> default node to deal with the memory hole(640K-1M). this means the\n> >> node0 must have some memory(>1M), but, actually it can have no\n> >> memory.\n> >>\n> >> Fix this problem by  cut out the 640K hole in the same way the PCI\n> >> 4G hole does. Also do some cleanup.\n> >>\n> >> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>\n> >> Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com>\n> >> ---\n> >>  hw/i386/acpi-build.c | 30 +++++++++++++++++++++++-------\n> >>  1 file changed, 23 insertions(+), 7 deletions(-)\n> >>\n> >> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c\n> >> index 98dd424..48525a1 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> > Is this assignment really necessary?\n> >  \n> \n> It is necessary, because we set mem_base to next_base before setting\n> next_base;\n> \n> But, I can refine it:\n> \n>                                     MEM_AFFINITY_ENABLED);\n>               }\n> \n> +            mem_base = HOLE_640K_END;\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> Is it?\nI was wrong, so just leave it as it is now.\n\n> \n> Thanks,\n> \tdou.\n> \n> > it seems that next_base will be set at the start of the loop.\n> >  \n> \n> \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> >> @@ -2395,7 +2411,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, MachineState *machine)\n> >>              }\n> >>              mem_base = 1ULL << 32;\n> >>              mem_len = next_base - pcms->below_4g_mem_size;\n> >> -            next_base += (1ULL << 32) - pcms->below_4g_mem_size;\n> >> +            next_base = mem_base + mem_len;\n> >>          }\n> >>          numamem = acpi_data_push(table_data, sizeof *numamem);\n> >>          build_srat_memory(numamem, mem_base, mem_len, i - 1,  \n> >\n> >\n> >\n> >  \n> \n>","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>)","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=imammedo@redhat.com"],"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 3xm6cs34mqz9s8J\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 21:12:13 +1000 (AEST)","from localhost ([::1]:53961 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 1dopIZ-0000BE-Gq\n\tfor incoming@patchwork.ozlabs.org; Mon, 04 Sep 2017 07:12:11 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56643)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dopHs-00005f-Ou\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 07:11:35 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <imammedo@redhat.com>) id 1dopHn-0006XP-JX\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 07:11:28 -0400","from mx1.redhat.com ([209.132.183.28]:49204)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <imammedo@redhat.com>) id 1dopHn-0006Wl-BG\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 07:11:23 -0400","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 74E007E428;\n\tMon,  4 Sep 2017 11:11:22 +0000 (UTC)","from nial.brq.redhat.com (unknown [10.43.2.241])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 6F71F957BD;\n\tMon,  4 Sep 2017 11:11:19 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 74E007E428","Date":"Mon, 4 Sep 2017 13:11:18 +0200","From":"Igor Mammedov <imammedo@redhat.com>","To":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<20170904131118.4de9ed44@nial.brq.redhat.com>","In-Reply-To":"<ec0c5471-5960-42aa-2723-f3dcb63d9fdc@cn.fujitsu.com>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<20170904113907.2a6e0cc7@nial.brq.redhat.com>\n\t<ec0c5471-5960-42aa-2723-f3dcb63d9fdc@cn.fujitsu.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=US-ASCII","Content-Transfer-Encoding":"7bit","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.11","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.27]);\n\tMon, 04 Sep 2017 11:11:22 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","Subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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":"rth@twiddle.net, mst@redhat.com, qemu-devel@nongnu.org,\n\tehabkost@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>"}},{"id":1762904,"web_url":"http://patchwork.ozlabs.org/comment/1762904/","msgid":"<5c552a10-d329-d249-2efc-e117e8c1a2d4@cn.fujitsu.com>","list_archive_url":null,"date":"2017-09-05T00:59:42","subject":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in case of node 0 without RAM","submitter":{"id":69629,"url":"http://patchwork.ozlabs.org/api/people/69629/","name":"Dou Liyang","email":"douly.fnst@cn.fujitsu.com"},"content":"Hi Igor,\n\nAt 09/04/2017 07:11 PM, Igor Mammedov wrote:\n[...]\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>>> Is this assignment really necessary?\n>>>\n>>\n>> It is necessary, because we set mem_base to next_base before setting\n>> next_base;\n>>\n>> But, I can refine it:\n>>\n>>                                     MEM_AFFINITY_ENABLED);\n>>               }\n>>\n>> +            mem_base = HOLE_640K_END;\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>> Is it?\n> I was wrong, so just leave it as it is now.\n>\n\nOK, I see.\n\nThanks,\n\tdou.","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 3xmT0W4J1nz9s03\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  5 Sep 2017 11:00:26 +1000 (AEST)","from localhost ([::1]:56238 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 1dp2E2-0004L0-AY\n\tfor incoming@patchwork.ozlabs.org; Mon, 04 Sep 2017 21:00:22 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:42233)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dp2Db-0004Fj-6j\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 20:59:59 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <douly.fnst@cn.fujitsu.com>) id 1dp2DW-0004kP-Gn\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 20:59:55 -0400","from mail.cn.fujitsu.com ([183.91.158.132]:25152\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 1dp2DW-0004jW-4n\n\tfor qemu-devel@nongnu.org; Mon, 04 Sep 2017 20:59:50 -0400","from localhost (HELO cn.fujitsu.com) ([10.167.33.5])\n\tby heian.cn.fujitsu.com with ESMTP; 05 Sep 2017 08:59:47 +0800","from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85])\n\tby cn.fujitsu.com (Postfix) with ESMTP id DDC0F4725542;\n\tTue,  5 Sep 2017 08:59:43 +0800 (CST)","from localhost.localdomain (10.167.226.106) by\n\tG08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP\n\tServer (TLS) id 14.3.361.1; Tue, 5 Sep 2017 08:59:43 +0800"],"X-IronPort-AV":"E=Sophos;i=\"5.41,477,1498492800\"; d=\"scan'208\";a=\"25213423\"","To":"Igor Mammedov <imammedo@redhat.com>","References":"<1504181068-17822-1-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<1504181068-17822-2-git-send-email-douly.fnst@cn.fujitsu.com>\n\t<20170904113907.2a6e0cc7@nial.brq.redhat.com>\n\t<ec0c5471-5960-42aa-2723-f3dcb63d9fdc@cn.fujitsu.com>\n\t<20170904131118.4de9ed44@nial.brq.redhat.com>","From":"Dou Liyang <douly.fnst@cn.fujitsu.com>","Message-ID":"<5c552a10-d329-d249-2efc-e117e8c1a2d4@cn.fujitsu.com>","Date":"Tue, 5 Sep 2017 08:59:42 +0800","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101\n\tThunderbird/45.4.0","MIME-Version":"1.0","In-Reply-To":"<20170904131118.4de9ed44@nial.brq.redhat.com>","Content-Type":"text/plain; charset=\"windows-1252\"; format=flowed","Content-Transfer-Encoding":"7bit","X-Originating-IP":"[10.167.226.106]","X-yoursite-MailScanner-ID":"DDC0F4725542.AA32A","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":"Re: [Qemu-devel] [PATCH v5 1/3] hw/acpi-build: Fix SRAT memory\n\tbuilding in 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":"rth@twiddle.net, mst@redhat.com, qemu-devel@nongnu.org,\n\tehabkost@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>"}}]