qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yin Wang <yin.wang@intel.com>
To: qemu-devel@nongnu.org
Cc: "Yin Wang" <yin.wang@intel.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Yanan Wang" <wangyanan55@huawei.com>
Subject: [PATCH] Fix QEMU crash caused when NUMA nodes exceed available CPUs
Date: Tue,  9 May 2023 14:44:52 +0800	[thread overview]
Message-ID: <20230509064452.759834-1-yin.wang@intel.com> (raw)

command "qemu-system-riscv64 -machine virt
-m 2G -smp 1 -numa node,mem=1G -numa node,mem=1G"
would trigger this problem.
This commit fixes the issue by adding parameter checks.

Signed-off-by: Yin Wang <yin.wang@intel.com>
---
 hw/core/numa.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/core/numa.c b/hw/core/numa.c
index d8d36b16d8..ff249369be 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -168,6 +168,13 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
     numa_info[nodenr].present = true;
     max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);
     ms->numa_state->num_nodes++;
+    if (ms->smp.max_cpus < ms->numa_state->num_nodes) {
+        error_setg(errp,
+                   "Number of NUMA nodes:(%d)"
+                   " is larger than number of CPUs:(%d)",
+                   ms->numa_state->num_nodes, ms->smp.max_cpus);
+        return;
+    }
 }
 
 static
-- 
2.34.1



             reply	other threads:[~2023-05-09  6:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09  6:44 Yin Wang [this message]
2023-05-09 12:12 ` [PATCH] Fix QEMU crash caused when NUMA nodes exceed available CPUs Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230509064452.759834-1-yin.wang@intel.com \
    --to=yin.wang@intel.com \
    --cc=eduardo@habkost.net \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wangyanan55@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).