From patchwork Mon Jun 9 10:25:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hu Tao X-Patchwork-Id: 357382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C20F91400A8 for ; Mon, 9 Jun 2014 20:28:20 +1000 (EST) Received: from localhost ([::1]:59920 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WtwoK-0003C1-Ez for incoming@patchwork.ozlabs.org; Mon, 09 Jun 2014 06:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wtwni-0002DW-C5 for qemu-devel@nongnu.org; Mon, 09 Jun 2014 06:27:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wtwnd-0000xd-Jz for qemu-devel@nongnu.org; Mon, 09 Jun 2014 06:27:38 -0400 Received: from [59.151.112.132] (port=38459 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wtwnd-0000xR-9U for qemu-devel@nongnu.org; Mon, 09 Jun 2014 06:27:33 -0400 X-IronPort-AV: E=Sophos;i="4.98,1001,1392134400"; d="scan'208";a="31650512" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Jun 2014 18:24:54 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s59ARVUu021579; Mon, 9 Jun 2014 18:27:31 +0800 Received: from G08FNSTD100614.fnst.cn.fujitsu.com (10.167.226.102) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Mon, 9 Jun 2014 18:27:32 +0800 From: Hu Tao To: Date: Mon, 9 Jun 2014 18:25:07 +0800 Message-ID: <463560c2fbe9c476d4a500008618f01740cd5631.1402299637.git.hutao@cn.fujitsu.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.167.226.102] X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 59.151.112.132 Cc: Eduardo Habkost , "Michael S. Tsirkin" , Igor Mammedov , Paolo Bonzini , Yasunori Goto , Wanlong Gao Subject: [Qemu-devel] [PATCH v4 02/29] NUMA: check if the total numa memory size is equal to ram_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Wanlong Gao If the total number of the assigned numa nodes memory is not equal to the assigned ram size, it will write the wrong data to ACPI table, then the guest will ignore the wrong ACPI table and recognize all memory to one node. It's buggy, we should check it to ensure that we write the right data to ACPI table. Signed-off-by: Wanlong Gao Reviewed-by: Eduardo Habkost Signed-off-by: Paolo Bonzini Signed-off-by: Hu Tao --- numa.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/numa.c b/numa.c index c419deb..b106531 100644 --- a/numa.c +++ b/numa.c @@ -26,6 +26,8 @@ #include "exec/cpu-common.h" #include "qemu/bitmap.h" #include "qom/cpu.h" +#include "qemu/error-report.h" +#include "include/exec/cpu-common.h" /* for RAM_ADDR_FMT */ static void numa_node_parse_cpus(int nodenr, const char *cpus) { @@ -126,6 +128,7 @@ void numa_add(const char *optarg) void set_numa_nodes(void) { if (nb_numa_nodes > 0) { + uint64_t numa_total; int i; if (nb_numa_nodes > MAX_NODES) { @@ -153,6 +156,17 @@ void set_numa_nodes(void) node_mem[i] = ram_size - usedmem; } + numa_total = 0; + for (i = 0; i < nb_numa_nodes; i++) { + numa_total += node_mem[i]; + } + if (numa_total != ram_size) { + error_report("qemu: total memory size for NUMA nodes (%" PRIu64 ")" + " should equal to RAM size (" RAM_ADDR_FMT ")\n", + numa_total, ram_size); + exit(1); + } + for (i = 0; i < nb_numa_nodes; i++) { if (!bitmap_empty(node_cpumask[i], MAX_CPUMASK_BITS)) { break;