From nobody Sat May 18 16:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=ispras.ru ARC-Seal: i=1; a=rsa-sha256; t=1603438579; cv=none; d=zohomail.com; s=zohoarc; b=dKlLWws7VIh0aYBEMvwkfiawMS37bZAq0J3R6FY1dCvH4zdc4UG22VMnP6wJtzHhjdSS1W85iypSfl8Sk/Ck3902UGDvcJo+P8BzV1cQ5vew7I6RBxd1f9w8/eO68rrt+RiZNYPJaVwcPGRq5EcQ97c2MBhQAKkxo4VwEQyUrW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603438579; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=F/lJm4BjSL8aSbP6zJSnwHhn7LDBlryXaLY22cu/qX4=; b=luv7EXuglRsjiPZjyy7aomyGRpjw4O8lXrQirkL+s53t43kq5Fe9QfZqw0Hw0ZwvP32tf8pIP8QV16wjSv/mzon/O+y5754J+nwTJSkzTCNZm67Of7YCFWEm7tsjF6AzMVEUs3kvUFQjgs276M0Skb+UEFnm4mvA9GLpt+KOpNQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603438578316825.0041785185216; Fri, 23 Oct 2020 00:36:18 -0700 (PDT) Received: from localhost ([::1]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVrcX-0002K0-7h for importer@patchew.org; Fri, 23 Oct 2020 03:36:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVrb9-0000cO-G3 for qemu-devel@nongnu.org; Fri, 23 Oct 2020 03:34:51 -0400 Received: from mail.ispras.ru ([83.149.199.84]:38448) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVrb7-0003iV-1W for qemu-devel@nongnu.org; Fri, 23 Oct 2020 03:34:50 -0400 Received: from [127.0.1.1] (unknown [62.118.151.149]) by mail.ispras.ru (Postfix) with ESMTPSA id A3F2240A1DDC; Fri, 23 Oct 2020 07:34:41 +0000 (UTC) Subject: [PATCH] cpus: verify that number of created cpus do not exceed smp params From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Fri, 23 Oct 2020 10:34:41 +0300 Message-ID: <160343848141.8350.10469322440262034340.stgit@pasha-ThinkPad-X280> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=83.149.199.84; envelope-from=pavel.dovgalyuk@ispras.ru; helo=mail.ispras.ru X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/23 03:34:42 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, pavel.dovgalyuk@ispras.ru, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 =3D MACHINE(qdev_get_machine()); =20 + if (cpu->cpu_index >=3D ms->smp.cpus) { + fprintf(stderr, "Machine definition error: trying to create too ma= ny CPUs\n"); + exit(1); + } + cpu->nr_cores =3D ms->smp.cores; cpu->nr_threads =3D ms->smp.threads; cpu->stopped =3D true;