qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] cpus: verify that number of created cpus do not exceed smp p


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] cpus: verify that number of created cpus do not exceed smp params
Date: Fri, 23 Oct 2020 10:10:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

On 10/23/20 9:34 AM, Pavel Dovgalyuk wrote:
Machine definitions may miss some vCPU-related parameters.
E.g., xlnx-versal-virt missed min_cpus and it was set to 1 by default.
This allowed using -smp 1 command line argument. But the machine
still created 2 vCPUs and passed all checks.
This patch adds one more check that does not allow creating
extra cpus that exceed the values specified in machine/smp.

Signed-off-by: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
---
  0 files changed

diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 47cceddd80..da74794e09 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -603,6 +603,11 @@ void qemu_init_vcpu(CPUState *cpu)
  {
      MachineState *ms = MACHINE(qdev_get_machine());
+ if (cpu->cpu_index >= ms->smp.cpus) {
+        fprintf(stderr, "Machine definition error: trying to create too many 
CPUs\n");
+        exit(1);

Shouldn't this be an assert()?

+    }
+
      cpu->nr_cores = ms->smp.cores;
      cpu->nr_threads =  ms->smp.threads;
      cpu->stopped = true;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]