From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247107531523.7673271031142; Sun, 3 Oct 2021 00:45:07 -0700 (PDT) Received: from localhost ([::1]:54754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwBF-0005uF-Fs for importer@patchew.org; Sun, 03 Oct 2021 03:45:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36640) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9B-00038p-7e for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:57 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:41662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw99-0000jk-2x for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:56 -0400 Received: by mail-ed1-x532.google.com with SMTP id bm13so1798419edb.8 for ; Sun, 03 Oct 2021 00:42:54 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QBaM+Y80mgyN7Ia3X+TH5nDhKBewjU9UfIHCLGMa7G4=; b=jmO/vDHI5l03/xBNPcm8K0kLpq7e/7ntYYTyX3XzZWu/RJjnL4VUSeLeKKVuOZneE4 vdTPwZBCMySoez856PNofw0oix1TNJnh1MuFe1UPrDmXik8nLwTIsoYYGvv45eDir1Jf TxW5kT7+8Qvp4xRmqbD/bzMb9QonoCG3pDtBIX01UYV1CBt3ooZYmhm/t7WY9u2X07/V 1qwoZibt4Ft2X60FeDapYXz0UUUwE8pUk3j/l0QBEI40kVcyNU+mLmuCBZQ4ZXr4KqRp SoPO6nglZSxPsAnYglcvx5qyLE/RVU5TtwagEVxS1INFF6Vn/9OjE9jXTz8xAsZ6/O0b Shkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=QBaM+Y80mgyN7Ia3X+TH5nDhKBewjU9UfIHCLGMa7G4=; b=dKVRzLyMJY6OLBjIUdArczPLBUPqNtSUMo1eVWN6WZTotzrkPiTZt2jGnO2QJK5eCB /h8sb9MiLXTXXoCh1RKv67zCJGuZD3OwvVVrP861F/0sovMw9MNgXep/h00L0MSf0tYC cQodbtzry2ni34VPuY5BxrH625R4wm+3dx0tNQtVcw6W4mKw8Jay51lVblsbE66T8NQR 59aWROgQxDRHGLaYebK/SZlokGI01+AUKlaCjynySUZd24TcDp8FzYyZJTN5Wdx8s1Gh j1UiY+spiA4IsJrATRl+ciZ7lKp6/mIqOONZn84OMiGKksZ4GMOGrOtpeWYbhSkG3LTx QF0A== X-Gm-Message-State: AOAM531796ocqAgBDN3+YqHKkmWc7cvK0RN6ol4Z1wpN67+ocDUYhrE3 Rgbi+u7SoLgGbcEwngJmC9uDte1HZaQ= X-Google-Smtp-Source: ABdhPJxNqKR6gOlGSt8TC5WUb5NOE3l7+M/F/sL9740v1FnUq35BcTpBVGathzlPQhiSYllmHBB8YQ== X-Received: by 2002:a05:6402:4305:: with SMTP id m5mr6516409edc.277.1633246973378; Sun, 03 Oct 2021 00:42:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 01/30] qapi/machine: Fix an incorrect comment of SMPConfiguration Date: Sun, 3 Oct 2021 09:42:21 +0200 Message-Id: <20211003074250.60869-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247109368100001 From: Yanan Wang The explanation of @cores should be "number of cores per die" but not "number of cores per thread". Let's fix it. Fixes: 1e63fe685804 ("machine: pass QAPI struct to mc->smp_parse") Signed-off-by: Yanan Wang Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-2-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- qapi/machine.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/machine.json b/qapi/machine.json index f1c4983b64..0e91a57a76 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1393,7 +1393,7 @@ # # @dies: number of dies per socket in the CPU topology # -# @cores: number of cores per thread in the CPU topology +# @cores: number of cores per die in the CPU topology # # @threads: number of threads per core in the CPU topology # --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247347840148.8771484094883; Sun, 3 Oct 2021 00:49:07 -0700 (PDT) Received: from localhost ([::1]:34878 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwF8-0003LD-Pr for importer@patchew.org; Sun, 03 Oct 2021 03:49:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9C-000395-Fv for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]:34446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw99-0000kC-Fu for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: by mail-ed1-x531.google.com with SMTP id g7so50878211edv.1 for ; Sun, 03 Oct 2021 00:42:55 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8xHug5FjGPs5JZhes9WoDYRkpuVcomb9e+VGlwSX9NE=; b=nsxEFFoTyLjDO3ihdbuCtH81r35P9DK2Z/uD09T3YJTlypVI4CBhJtNLP3l9uLK8sf qRWDOSyqXoMIiKT7ZyeKw6WkYDKEqxbbf35qopEavB1PvzP8/azWXYl1olxnII8i0OQQ IhUrXyztllreTP+PpR0IwwXSifHT6Zg9WN64FUr3HzfMqMSoqRFQ5vtNKOp1GxvniMXo JKubzLjVo4HPPsjJxOBCz/id3OHEw41/66T6i/yNM0RJWkN9XvGvrWJH0SRBO4M4BuRW s3JjkDeQElJUNsrwpA6BLUXWIXiAqcxVjSHj/9V3GJQt6EWH63UPDSPGd8TXuD99xF+I Sdcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8xHug5FjGPs5JZhes9WoDYRkpuVcomb9e+VGlwSX9NE=; b=OKpvkJce3t7Ybod8DnG9waHLgm03P1JwqlzwyzWqv1RohycKvlMoYN65ofLudhIRhi WfaBUvm640qQOkN2CCnux9ah0RLDSmkBH1RHd8OJvXqXwCxIfj83jMdCP2/Vi0GNtnhP yJMmc7gEo2KtlwfQssraFXI/WhgPemVPZE5GaL9W7TbqF3cZUDmfqXRsuhWEPk36sjwA JXyrcqSCFJhkFO2rVkjgWj2bTLRlgn1kI6HdD1vhOjCDhpqcn3u7VqhWSNAFSAT2FpiF oo2jEiD01nXOFJb5GVTyshu4iodbFbMkDccVmKxRmT7l4i8mR/WrkZ7B7bzMs46VFspi ha4A== X-Gm-Message-State: AOAM532XmV6XKLsmqrw9d/62pAohlEculsZ65SrKO+xAEdUAczd2NLoI oqRiEEmFMHFLEUhUcSGaHzUsufIPs9A= X-Google-Smtp-Source: ABdhPJwTTScNNOlXLfMm8RaDTrV/81pPbf2I2ORFKk2IBhGc3nBfzbz3UHkqHwGsVxVvccAu1Ec27g== X-Received: by 2002:aa7:c988:: with SMTP id c8mr1394261edt.94.1633246974084; Sun, 03 Oct 2021 00:42:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 02/30] machine: Deprecate "parameter=0" SMP configurations Date: Sun, 3 Oct 2021 09:42:22 +0200 Message-Id: <20211003074250.60869-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::531; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Cornelia Huck , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247349462100001 From: Yanan Wang In the SMP configuration, we should either provide a topology parameter with a reasonable value (greater than zero) or just omit it and QEMU will compute the missing value. The users shouldn't provide a configuration with any parameter of it specified as zero (e.g. -smp 8,sockets=3D0) which could possibly cause unexpected results in the -smp parsing. So we deprecate this kind of configurations since 6.2 by adding the explicit sanity check. Signed-off-by: Yanan Wang Reviewed-by: Cornelia Huck Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-3-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- docs/about/deprecated.rst | 15 +++++++++++++++ hw/core/machine.c | 14 ++++++++++++++ qemu-options.hx | 12 +++++++----- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 2f7db9a98d..0bed6ecb1d 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -160,6 +160,21 @@ Use ``-display sdl`` instead. =20 Use ``-display curses`` instead. =20 +``-smp`` ("parameter=3D0" SMP configurations) (since 6.2) +''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +Specified CPU topology parameters must be greater than zero. + +In the SMP configuration, users should either provide a CPU topology +parameter with a reasonable value (greater than zero) or just omit it +and QEMU will compute the missing value. + +However, historically it was implicitly allowed for users to provide +a parameter with zero value, which is meaningless and could also possibly +cause unexpected results in the -smp parsing. So support for this kind of +configurations (e.g. -smp 8,sockets=3D0) is deprecated since 6.2 and will +be removed in the near future, users have to ensure that all the topology +members described with -smp are greater than zero. =20 Plugin argument passing through ``arg=3D`` (since 6.1) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' diff --git a/hw/core/machine.c b/hw/core/machine.c index 067f42b528..4e409261c9 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -835,6 +835,20 @@ static void machine_set_smp(Object *obj, Visitor *v, c= onst char *name, return; } =20 + /* + * Specified CPU topology parameters must be greater than zero, + * explicit configuration like "cpus=3D0" is not allowed. + */ + if ((config->has_cpus && config->cpus =3D=3D 0) || + (config->has_sockets && config->sockets =3D=3D 0) || + (config->has_dies && config->dies =3D=3D 0) || + (config->has_cores && config->cores =3D=3D 0) || + (config->has_threads && config->threads =3D=3D 0) || + (config->has_maxcpus && config->maxcpus =3D=3D 0)) { + warn_report("Deprecated CPU topology (considered invalid): " + "CPU topology parameters must be greater than zero"); + } + mc->smp_parse(ms, config, errp); if (*errp) { goto out_free; diff --git a/qemu-options.hx b/qemu-options.hx index ceca52818a..4a092a092a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -233,11 +233,13 @@ SRST of computing the CPU maximum count. =20 Either the initial CPU count, or at least one of the topology paramete= rs - must be specified. Values for any omitted parameters will be computed - from those which are given. Historically preference was given to the - coarsest topology parameters when computing missing values (ie sockets - preferred over cores, which were preferred over threads), however, this - behaviour is considered liable to change. + must be specified. The specified parameters must be greater than zero, + explicit configuration like "cpus=3D0" is not allowed. Values for any + omitted parameters will be computed from those which are given. + Historically preference was given to the coarsest topology parameters + when computing missing values (ie sockets preferred over cores, which + were preferred over threads), however, this behaviour is considered + liable to change. ERST =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247108327746.4523478857155; Sun, 3 Oct 2021 00:45:08 -0700 (PDT) Received: from localhost ([::1]:54844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwBG-0005xq-Pq for importer@patchew.org; Sun, 03 Oct 2021 03:45:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9C-00039B-Ng for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:46683) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9A-0000l4-6m for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: by mail-ed1-x535.google.com with SMTP id z20so466494edc.13 for ; Sun, 03 Oct 2021 00:42:55 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zDzcsXFs2FnCddJFWE6HMcr+FeF5rfRj7mIGSwEkPOI=; b=N4TbO8yBTBQhgC1fwWOpLumioYnqRspac7JVKY7DDQeiEniC/T7tQyFgr1GkvBaiTf KL6QtRG86SsLmgOQLpc1UgDq2VL9ssmHjoymua2sfj2dTMCrt7tk75z2oNlhy/T66HX0 zN0Ok3B2Eliyc6TGUa2zicL1W9Z5ZZEfnJMTOUtTv4EUiQsQTGBR1IvFbFrzRz0mhUXX TU2CN/uFRB69BCRgLQWUNmQRv7LznI3xhSTwrPzxVi7O9k3gVHs0FPu1/sA9PBhguYu6 e0dUx+r37ZYXbspMlAtGYKBwJiNO4occq5a+G2/7xT/swxUQVLFjzy/nIdtw2peM8EXn gHJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zDzcsXFs2FnCddJFWE6HMcr+FeF5rfRj7mIGSwEkPOI=; b=mEdF7LHJI0M7MWHzL0MWYexHkX8LHNxbXjhxHmoruehiAqbb/7/PsDLQUCDKDsBdla iQqJ6HFRNjnfCU+wvH7qgiTDVZ4facaSuiPpI50GoAhe5mt7lMCgwNtoPK7SUdVRIq5H qs35eRKH0irBDkzLVqzWwXROlrx4EKjAK8slmWTj9Cqo/0QNfEFNWyCPYKqHORAI3o4P jIMG7W2mGqOTLYn2M2W2W+7zfcRWEqaZe2Vlu/McdsPtIY/DLYR4VznbbjVmPQyQIt6X O/WBBHojLnVGbOqqiTVPwSynYWIN/BL8RCS0vRklj2ekhqkTQvDZ6W9wM9KjeE+Hbpdr i1Xg== X-Gm-Message-State: AOAM532wSLRHtfAmwVJzXcS3pO5ImDle+1Ni2jyy8fCppdpLg2YxsEj8 gqFPVVGciTigsLij08SFSgPxpSxad1Y= X-Google-Smtp-Source: ABdhPJxwhblVHKhFZKkkeG5PjstxsfPCKnFH85N8sn353uTJahOzVZ9DbAsx8Sc0GPRv61LHZ5lPrg== X-Received: by 2002:a17:906:9501:: with SMTP id u1mr8964076ejx.496.1633246974872; Sun, 03 Oct 2021 00:42:54 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 03/30] machine: Minor refactor/fix for the smp parsers Date: Sun, 3 Oct 2021 09:42:23 +0200 Message-Id: <20211003074250.60869-4-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247109388100003 From: Yanan Wang To pave the way for the functional improvement in later patches, make some refactor/cleanup for the smp parsers, including using local maxcpus instead of ms->smp.max_cpus in the calculation, defaulting dies to 0 initially like other members, cleanup the sanity check for dies. We actually also fix a hidden defect by avoiding directly using the provided *zero value* in the calculation, which could cause a segment fault (e.g. using dies=3D0 in the calculation). Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-4-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 18 ++++++++++-------- hw/i386/pc.c | 23 ++++++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 4e409261c9..8e719e2932 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -752,8 +752,9 @@ static void smp_parse(MachineState *ms, SMPConfiguratio= n *config, Error **errp) unsigned sockets =3D config->has_sockets ? config->sockets : 0; unsigned cores =3D config->has_cores ? config->cores : 0; unsigned threads =3D config->has_threads ? config->threads : 0; + unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; =20 - if (config->has_dies && config->dies !=3D 0 && config->dies !=3D 1) { + if (config->has_dies && config->dies > 1) { error_setg(errp, "dies not supported by this machine's CPU topolog= y"); return; } @@ -766,8 +767,8 @@ static void smp_parse(MachineState *ms, SMPConfiguratio= n *config, Error **errp) sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * sockets; } else { - ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : c= pus; - sockets =3D ms->smp.max_cpus / (cores * threads); + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + sockets =3D maxcpus / (cores * threads); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; @@ -784,26 +785,27 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) return; } =20 - ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : cpus; + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; =20 - if (ms->smp.max_cpus < cpus) { + if (maxcpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); return; } =20 - if (sockets * cores * threads !=3D ms->smp.max_cpus) { + if (sockets * cores * threads !=3D maxcpus) { error_setg(errp, "Invalid CPU topology: " "sockets (%u) * cores (%u) * threads (%u) " "!=3D maxcpus (%u)", sockets, cores, threads, - ms->smp.max_cpus); + maxcpus); return; } =20 ms->smp.cpus =3D cpus; + ms->smp.sockets =3D sockets; ms->smp.cores =3D cores; ms->smp.threads =3D threads; - ms->smp.sockets =3D sockets; + ms->smp.max_cpus =3D maxcpus; } =20 static void machine_get_smp(Object *obj, Visitor *v, const char *name, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index df457eceba..92c78d9933 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -718,9 +718,13 @@ static void pc_smp_parse(MachineState *ms, SMPConfigur= ation *config, Error **err { unsigned cpus =3D config->has_cpus ? config->cpus : 0; unsigned sockets =3D config->has_sockets ? config->sockets : 0; - unsigned dies =3D config->has_dies ? config->dies : 1; + unsigned dies =3D config->has_dies ? config->dies : 0; unsigned cores =3D config->has_cores ? config->cores : 0; unsigned threads =3D config->has_threads ? config->threads : 0; + unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; + + /* directly default dies to 1 if it's omitted */ + dies =3D dies > 0 ? dies : 1; =20 /* compute missing values, prefer sockets over cores over threads */ if (cpus =3D=3D 0 || sockets =3D=3D 0) { @@ -730,8 +734,8 @@ static void pc_smp_parse(MachineState *ms, SMPConfigura= tion *config, Error **err sockets =3D sockets > 0 ? sockets : 1; cpus =3D cores * threads * dies * sockets; } else { - ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : c= pus; - sockets =3D ms->smp.max_cpus / (cores * threads * dies); + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + sockets =3D maxcpus / (dies * cores * threads); } } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; @@ -748,27 +752,28 @@ static void pc_smp_parse(MachineState *ms, SMPConfigu= ration *config, Error **err return; } =20 - ms->smp.max_cpus =3D config->has_maxcpus ? config->maxcpus : cpus; + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; =20 - if (ms->smp.max_cpus < cpus) { + if (maxcpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); return; } =20 - if (sockets * dies * cores * threads !=3D ms->smp.max_cpus) { + if (sockets * dies * cores * threads !=3D maxcpus) { error_setg(errp, "Invalid CPU topology deprecated: " "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " "!=3D maxcpus (%u)", sockets, dies, cores, threads, - ms->smp.max_cpus); + maxcpus); return; } =20 ms->smp.cpus =3D cpus; - ms->smp.cores =3D cores; - ms->smp.threads =3D threads; ms->smp.sockets =3D sockets; ms->smp.dies =3D dies; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + ms->smp.max_cpus =3D maxcpus; } =20 static --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247116430825.4001811788231; Sun, 3 Oct 2021 00:45:16 -0700 (PDT) Received: from localhost ([::1]:55118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwBP-0006Bp-FQ for importer@patchew.org; Sun, 03 Oct 2021 03:45:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9C-00039N-TE for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:45946) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9B-0000li-37 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:58 -0400 Received: by mail-ed1-x52f.google.com with SMTP id r18so51665155edv.12 for ; Sun, 03 Oct 2021 00:42:56 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KqAXlvGMDEYnNdVIQ0K7jDAn8Tks9UOdxFcSEoaFxTg=; b=GkZ/sY15TQgCzaQACobSsmaWLbDZ3n5mjdIZtLlz8GiSlH+ZEFgDWiGQZs8IzH9C9G 8I6Zxc8FfXknUo8iYipvIL68DYTqBBV0QoMQbgg7mPcoe/2GagM0qanTBiXhmMjFjvGt SDwF9dvB7clr9N6l/t3g0jBSnGcDyXsR/i4wzmbKQ5hkW2sRIn1AJjyVuvOGDHMacikx aRTUYDhQ5ohVSe1/OLvojh0qxg0gHeoUtdrNfZf72dGQzXbzMyYRZq/OrWx8Gcvc5fNy wW/oPux/5V9IVh4EPlFUtccyFllAk+R0SaKTvhf3NbMraSPY5SAQ0yQ7eyfb2RAu8swe zOCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=KqAXlvGMDEYnNdVIQ0K7jDAn8Tks9UOdxFcSEoaFxTg=; b=RkBeKQxUgeIRvbA1E6jfSDFdqs9GJib3UqEjH2f2dKdWpQv++rmJr8zKy3xv02rhfU hdmEPwfhi+3vC/hhLFSnKrwPcShE9YO253/U0M+RWp7OOQyyVI9bHR5cfV9+vyqA4eJf FzWW1rQAthmqzmuNkaJ7q+EvC6SYtujICnnfx89jklfyDA3hgatYjiUsQbYv2TDY6nP/ CXNo1h6v2ncmiuEUPXib1X5SZL6PetA9MpSTIZ1v41PwXrLkpYb8ROhUJ1ABTB7r/+3m XtJe2hZlHIQnSWni6iR9SsaBE3RGwT6UKG34Zn3mzo0cvkGxnkTLJfCB1mk1c5B4WyY7 juPA== X-Gm-Message-State: AOAM530w4oIsa6PpLFuO33Mmovci9mDd9iz3ddS08vZLHrN3hXK66Crg kT8Zj5EaGpULJCrkI4k3Bu3bT0JslkU= X-Google-Smtp-Source: ABdhPJyy5CXIk8x+1H9b8g5MVOsuAa/NQ+heyGlHPeCLyIlsIMD2q3pKbsCu66JUzEoPmKiOWMLIXg== X-Received: by 2002:a05:6402:27cf:: with SMTP id c15mr9458736ede.131.1633246975600; Sun, 03 Oct 2021 00:42:55 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 04/30] machine: Uniformly use maxcpus to calculate the omitted parameters Date: Sun, 3 Oct 2021 09:42:24 +0200 Message-Id: <20211003074250.60869-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Pankaj Gupta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247117716100001 From: Yanan Wang We are currently using maxcpus to calculate the omitted sockets but using cpus to calculate the omitted cores/threads. This makes cmdlines like: -smp cpus=3D8,maxcpus=3D16 -smp cpus=3D8,cores=3D4,maxcpus=3D16 -smp cpus=3D8,threads=3D2,maxcpus=3D16 work fine but the ones like: -smp cpus=3D8,sockets=3D2,maxcpus=3D16 -smp cpus=3D8,sockets=3D2,cores=3D4,maxcpus=3D16 -smp cpus=3D8,sockets=3D2,threads=3D2,maxcpus=3D16 break the sanity check. Since we require for a valid config that the product of "sockets * cores * threads" should equal to the maxcpus, we should uniformly use maxcpus to calculate their omitted values. Also the if-branch of "cpus =3D=3D 0 || sockets =3D=3D 0" was split into two branches of "cpus =3D=3D 0" and "sockets =3D=3D 0" so that we can clearly r= ead that we are parsing the configuration with a preference on cpus over sockets over cores over threads. Note: change in this patch won't affect any existing working cmdlines but improves consistency and allows more incomplete configs to be valid. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-5-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 30 +++++++++++++++--------------- hw/i386/pc.c | 30 +++++++++++++++--------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 8e719e2932..596e758133 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -760,24 +760,26 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) } =20 /* compute missing values, prefer sockets over cores over threads */ - if (cpus =3D=3D 0 || sockets =3D=3D 0) { + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - if (cpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * sockets; - } else { - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - sockets =3D maxcpus / (cores * threads); - } + cpus =3D sockets * cores * threads; + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + } else if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (cores * threads); } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * threads); - cores =3D cores > 0 ? cores : 1; + cores =3D maxcpus / (sockets * threads); } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * sockets); - threads =3D threads > 0 ? threads : 1; - } else if (sockets * cores * threads < cpus) { + threads =3D maxcpus / (sockets * cores); + } + + if (sockets * cores * threads < cpus) { error_setg(errp, "cpu topology: " "sockets (%u) * cores (%u) * threads (%u) < " "smp_cpus (%u)", @@ -785,8 +787,6 @@ static void smp_parse(MachineState *ms, SMPConfiguratio= n *config, Error **errp) return; } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - if (maxcpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); return; diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 92c78d9933..e37e84cc7b 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -727,24 +727,26 @@ static void pc_smp_parse(MachineState *ms, SMPConfigu= ration *config, Error **err dies =3D dies > 0 ? dies : 1; =20 /* compute missing values, prefer sockets over cores over threads */ - if (cpus =3D=3D 0 || sockets =3D=3D 0) { + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + + if (cpus =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - if (cpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cpus =3D cores * threads * dies * sockets; - } else { - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - sockets =3D maxcpus / (dies * cores * threads); - } + cpus =3D sockets * dies * cores * threads; + maxcpus =3D maxcpus > 0 ? maxcpus : cpus; + } else if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (dies * cores * threads); } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D cpus / (sockets * dies * threads); - cores =3D cores > 0 ? cores : 1; + cores =3D maxcpus / (sockets * dies * threads); } else if (threads =3D=3D 0) { - threads =3D cpus / (cores * dies * sockets); - threads =3D threads > 0 ? threads : 1; - } else if (sockets * dies * cores * threads < cpus) { + threads =3D maxcpus / (sockets * dies * cores); + } + + if (sockets * dies * cores * threads < cpus) { error_setg(errp, "cpu topology: " "sockets (%u) * dies (%u) * cores (%u) * threads (%u) <= " "smp_cpus (%u)", @@ -752,8 +754,6 @@ static void pc_smp_parse(MachineState *ms, SMPConfigura= tion *config, Error **err return; } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - if (maxcpus < cpus) { error_setg(errp, "maxcpus must be equal to or greater than smp"); return; --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247347881547.0670647256123; Sun, 3 Oct 2021 00:49:07 -0700 (PDT) Received: from localhost ([::1]:35004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwF8-0003Q7-Sv for importer@patchew.org; Sun, 03 Oct 2021 03:49:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9D-0003AA-Co for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:59 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]:37828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9B-0000lo-Nj for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:59 -0400 Received: by mail-ed1-x530.google.com with SMTP id ba1so51822799edb.4 for ; Sun, 03 Oct 2021 00:42:57 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SoQkCnkgqJjlJOEvR3S53h35evZiqhHpq/ld+Wj0kZs=; b=n7c0ym+gAWv3g6KOSCybw5kvoRMAtsuTs3x67qIHP3Rx77Jx9vzh8du7ndv0dJV/Gn vtUEnYpyV46TXd6hZpuRjNUjw6YXOwh7zb2g8T048uqW1+V0QmmMUnrBtyLGla+0np8d Cv5fHW66s6neGelxSq9lCwZJ8MTbrKB5VPXigfuDN0cAKiHMbR0Vd5cPMc2sX8e4bu9p Cs2xkM/eMOkh4xnLUU1J/jzfr51jct0SsiAE/A7nfVfbaVExUtd7olS2EtTVVpbILJxT BEfj1OBpN4fVpP0gCDgedfrusJFRzmlffaAxdj5SU/Wo18LlJupLAQ4ibe+ZVaXFvY+s 6btQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=SoQkCnkgqJjlJOEvR3S53h35evZiqhHpq/ld+Wj0kZs=; b=MsKmRO1KN+3b/dQk5UyisVicy1KPzBKK5r2LW4m3h52cZYU/kdD1kyle/U9mnteo+f XB2YFlf3xcfcivHBeiO6R5vt+iB+VdYbmgY0YFpVsKLN4La1yTN1Az3wH0Sc8GapncAW ux0YXaMKtKPl5h5WK9W6zGhby26IgFCGccyGpVEYLj0gHq0XL/kZqe8xERaI9AuQKNc/ Jidpw3KkCzQs90gCEoWs6ZRs2dwmQx/Kg3Xu3gemR1pRDqN6v/QHy9mXTC8i8sFalvPJ Wd1WsADwaEmgwsiaHKNbbTLKrtCJGO95FY8/zgBrajIHkm5nQ0bH+yQXmW4yO7FRiuvU S8Pw== X-Gm-Message-State: AOAM5325w6McRJ8rouG20bKbMNu4rutbEF2uywolV6WVvVFIRwi83xgt RL4QcbCQa/jQQcFpiXkwOkbUU2a45vw= X-Google-Smtp-Source: ABdhPJwnIQYNxcLxnhJG4P9O4E1/ZFl3rruodI9dYaQnVxLjbhP8jJT+6sfPczehod0EKFX22sw26A== X-Received: by 2002:a17:906:39cd:: with SMTP id i13mr8664758eje.227.1633246976275; Sun, 03 Oct 2021 00:42:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 05/30] machine: Set the value of cpus to match maxcpus if it's omitted Date: Sun, 3 Oct 2021 09:42:25 +0200 Message-Id: <20211003074250.60869-6-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::530; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x530.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247349469100002 From: Yanan Wang Currently we directly calculate the omitted cpus based on the given incomplete collection of parameters. This makes some cmdlines like: -smp maxcpus=3D16 -smp sockets=3D2,maxcpus=3D16 -smp sockets=3D2,dies=3D2,maxcpus=3D16 -smp sockets=3D2,cores=3D4,maxcpus=3D16 not work. We should probably set the value of cpus to match maxcpus if it's omitted, which will make above configs start to work. So the calculation logic of cpus/maxcpus after this patch will be: When both maxcpus and cpus are omitted, maxcpus will be calculated from the given parameters and cpus will be set equal to maxcpus. When only one of maxcpus and cpus is given then the omitted one will be set to its counterpart's value. Both maxcpus and cpus may be specified, but maxcpus must be equal to or greater than cpus. Note: change in this patch won't affect any existing working cmdlines but allows more incomplete configs to be valid. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-6-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 29 ++++++++++++++++------------- hw/i386/pc.c | 29 ++++++++++++++++------------- qemu-options.hx | 11 ++++++++--- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 596e758133..d8f458db60 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -760,25 +760,28 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) } =20 /* compute missing values, prefer sockets over cores over threads */ - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - - if (cpus =3D=3D 0) { + if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - cpus =3D sockets * cores * threads; + } else { maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - } else if (sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (cores * threads); - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * threads); - } else if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * cores); + + if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (cores * threads); + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * threads); + } else if (threads =3D=3D 0) { + threads =3D maxcpus / (sockets * cores); + } } =20 + maxcpus =3D maxcpus > 0 ? maxcpus : sockets * cores * threads; + cpus =3D cpus > 0 ? cpus : maxcpus; + if (sockets * cores * threads < cpus) { error_setg(errp, "cpu topology: " "sockets (%u) * cores (%u) * threads (%u) < " diff --git a/hw/i386/pc.c b/hw/i386/pc.c index e37e84cc7b..f24a1d72ad 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -727,25 +727,28 @@ static void pc_smp_parse(MachineState *ms, SMPConfigu= ration *config, Error **err dies =3D dies > 0 ? dies : 1; =20 /* compute missing values, prefer sockets over cores over threads */ - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - - if (cpus =3D=3D 0) { + if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - cpus =3D sockets * dies * cores * threads; + } else { maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - } else if (sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * cores * threads); - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * threads); - } else if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * dies * cores); + + if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (dies * cores * threads); + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * dies * threads); + } else if (threads =3D=3D 0) { + threads =3D maxcpus / (sockets * dies * cores); + } } =20 + maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * cores * threads; + cpus =3D cpus > 0 ? cpus : maxcpus; + if (sockets * dies * cores * threads < cpus) { error_setg(errp, "cpu topology: " "sockets (%u) * dies (%u) * cores (%u) * threads (%u) <= " diff --git a/qemu-options.hx b/qemu-options.hx index 4a092a092a..2eac830fdb 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -220,9 +220,14 @@ SRST Simulate a SMP system with '\ ``n``\ ' CPUs initially present on the machine type board. On boards supporting CPU hotplug, the optional '\ ``maxcpus``\ ' parameter can be set to enable further CPUs to be - added at runtime. If omitted the maximum number of CPUs will be - set to match the initial CPU count. Both parameters are subject to - an upper limit that is determined by the specific machine type chosen. + added at runtime. When both parameters are omitted, the maximum number + of CPUs will be calculated from the provided topology members and the + initial CPU count will match the maximum number. When only one of them + is given then the omitted one will be set to its counterpart's value. + Both parameters may be specified, but the maximum number of CPUs must + be equal to or greater than the initial CPU count. Both parameters are + subject to an upper limit that is determined by the specific machine + type chosen. =20 To control reporting of CPU topology information, the number of socket= s, dies per socket, cores per die, and threads per core can be specified. --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247349649137.56850412010078; Sun, 3 Oct 2021 00:49:09 -0700 (PDT) Received: from localhost ([::1]:35098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwFA-0003U2-Kc for importer@patchew.org; Sun, 03 Oct 2021 03:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9D-0003Bj-Ux for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:59 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:39878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9C-0000n9-CN for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:42:59 -0400 Received: by mail-ed1-x52b.google.com with SMTP id x7so50488374edd.6 for ; Sun, 03 Oct 2021 00:42:57 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yqw/945/MMuiqJfE7USyGnzWaaT3DCE0yzcYLl8IjNI=; b=LrpJNFbO/D7P3/sXQ/2dfENmCKnlkytzD96FFFyNpmeyodzhfaA9kljUQHtdyTWxvH mfH85JDfBKqkcsKxm1I50Pjzt2i1Y+oHn3gV5WoMWz/UojTHIu97dYYwGvJ9soomuBu+ aH7JmJL7PGMwUl4O5fqpiWlc8R1oKhMXcaV6yn+8qtxBt1gMM8KXxNUhK+dfG5aO7a/H hdXzOmFRHetByKi7wDh7glVinoNlJad1lkzZ0pL6qqZBP9HMyXwV4MX53QiojZYINjoe XNZtjsMDB+7lTUG3/ra4jtq4z1Q5GplLufTyPcQl+awEHXAQn4MHVuxE8+YrH/MFeZsb hrIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yqw/945/MMuiqJfE7USyGnzWaaT3DCE0yzcYLl8IjNI=; b=IgIc7gP0C5Dwh3CsrS5ruUr+8/bIvDwpakz8xbjqmayVJFdrM9EtsIXCUzBO9BTDsC 5SX4pZHBr+GZeLiziOpzJTPUxg02GTImw0XY/TGe0cwxMmlStoU912rfVF0eko91TgDO H0SOTQV9Vqt5IdLysF5Sgz7gwk0IozbBpSrl9mk8lvWxHUmCHeKF1pAnD25mo8a0nAw+ FVPwgGLkdgvecWRhV5wKKXagnec3IBAQCRXzdz0K1zP53UE5MIZ6Cf23HU0t4jWdY2zT /fNnVL+dl0AwCAmqMV537USaMeDia/jd6owKKR2KRhpLEWbEAZ2WZimhlfwtjKW+R6c9 9u9Q== X-Gm-Message-State: AOAM533WwffM9RNo48Ux9bLpZ1VBTOoh7Oqrg6c8yiJZJc05YEFc1vR9 /E0uWljro9S0CPsvHlqtJ5Cuq5STt/Y= X-Google-Smtp-Source: ABdhPJwZwqgxyMJ+k52ae2XE0La2RFYoC5m+C2pHjYswTwQRiBk6Vfz+vEwu8fbk5XyALUplga9Dkg== X-Received: by 2002:a05:6402:50cc:: with SMTP id h12mr9704254edb.112.1633246977077; Sun, 03 Oct 2021 00:42:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 06/30] machine: Improve the error reporting of smp parsing Date: Sun, 3 Oct 2021 09:42:26 +0200 Message-Id: <20211003074250.60869-7-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Pankaj Gupta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247351543100001 From: Yanan Wang We have two requirements for a valid SMP configuration: the product of "sockets * cores * threads" must represent all the possible cpus, i.e., max_cpus, and then must include the initially present cpus, i.e., smp_cpus. So we only need to ensure 1) "sockets * cores * threads =3D=3D maxcpus" at first and then ensure 2) "maxcpus >=3D cpus". With a reasonable order of the sanity check, we can simplify the error reporting code. When reporting an error message we also report the exact value of each topology member to make users easily see what's going on. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210929025816.21076-7-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 22 +++++++++------------- hw/i386/pc.c | 24 ++++++++++-------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index d8f458db60..e38ab760e6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -782,25 +782,21 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) maxcpus =3D maxcpus > 0 ? maxcpus : sockets * cores * threads; cpus =3D cpus > 0 ? cpus : maxcpus; =20 - if (sockets * cores * threads < cpus) { - error_setg(errp, "cpu topology: " - "sockets (%u) * cores (%u) * threads (%u) < " - "smp_cpus (%u)", - sockets, cores, threads, cpus); + if (sockets * cores * threads !=3D maxcpus) { + error_setg(errp, "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "sockets (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, cores, threads, maxcpus); return; } =20 if (maxcpus < cpus) { - error_setg(errp, "maxcpus must be equal to or greater than smp"); - return; - } - - if (sockets * cores * threads !=3D maxcpus) { error_setg(errp, "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " "sockets (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, cores, threads, - maxcpus); + "=3D=3D maxcpus (%u) < smp_cpus (%u)", + sockets, cores, threads, maxcpus, cpus); return; } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f24a1d72ad..9216ad163d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -749,25 +749,21 @@ static void pc_smp_parse(MachineState *ms, SMPConfigu= ration *config, Error **err maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * cores * threads; cpus =3D cpus > 0 ? cpus : maxcpus; =20 - if (sockets * dies * cores * threads < cpus) { - error_setg(errp, "cpu topology: " - "sockets (%u) * dies (%u) * cores (%u) * threads (%u) <= " - "smp_cpus (%u)", - sockets, dies, cores, threads, cpus); + if (sockets * dies * cores * threads !=3D maxcpus) { + error_setg(errp, "Invalid CPU topology: " + "product of the hierarchy must match maxcpus: " + "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " + "!=3D maxcpus (%u)", + sockets, dies, cores, threads, maxcpus); return; } =20 if (maxcpus < cpus) { - error_setg(errp, "maxcpus must be equal to or greater than smp"); - return; - } - - if (sockets * dies * cores * threads !=3D maxcpus) { - error_setg(errp, "Invalid CPU topology deprecated: " + error_setg(errp, "Invalid CPU topology: " + "maxcpus must be equal to or greater than smp: " "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, dies, cores, threads, - maxcpus); + "=3D=3D maxcpus (%u) < smp_cpus (%u)", + sockets, dies, cores, threads, maxcpus, cpus); return; } =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16332474050461021.2430936257632; Sun, 3 Oct 2021 00:50:05 -0700 (PDT) Received: from localhost ([::1]:37536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwG4-0005Ap-1w for importer@patchew.org; Sun, 03 Oct 2021 03:50:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9E-0003Du-Hs for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:00 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:36731) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9D-0000nq-4P for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:00 -0400 Received: by mail-ed1-x536.google.com with SMTP id l7so28172044edq.3 for ; Sun, 03 Oct 2021 00:42:58 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FWjVtE1T0s2M/PhRXdlUzw1YZjKSI7qerdNFlVrMk9c=; b=QIKAUVqzhvP/1EiWHZhaNMAde2GBescSgYQSmUX35jhV5VhB/k9t/ElEgnaQGCtK3A 2VKcYjbMR4pU9LVkAt75+Cjf2inYwDDrEEc/TztCWbJ0j90k4skpa/KA4gXa7oMjFJ6j HVBwnotYNTMbzioYohCac7L3Yq3Iau0vn/iYLrLKBKeHLGdVl04EkRZ1h50p7WJsl+mt /uqVI3q3b+Ku2DqVOMLmviQaKPM5U8rixyCcN8HNkr1bHyg4qCdSOKaYos5JuzDEHEwy U2QFp592dPbXk3ydCeeHhINuxn07JOwCLKgUnULRVdU6/bBEw4GF1GJKWsp/XeM9A9y/ /uJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FWjVtE1T0s2M/PhRXdlUzw1YZjKSI7qerdNFlVrMk9c=; b=rAlvpEEqvdEuzC4Q4q2IYoERywnzrOOpBi9bGw5J24NO94UMc9tjOYaRG9NHvrZc/r OdlxpbH6xMipYnjWjPN1G3oYPbMCDwQTqXuIiROQqGnocMztP57hXIvmHjMNiw4ZUwaO SQah7QVLxMGo9HNQfuj50SvDKjmsu6ppQOre2qK03rwOGBzbijzQQ0wKBwOPGV9Vq9NU GHIlGiU2G982URXo4dkgyISK463IUXz630DAVOj76IEzLQ1d7xetF+/IAHv2pfg1abDw O1EaRyZKvAMdwa9WwPI3HaJ2zFNn/I8q/gbCwnhOb/wEX8J1BJbO32BWty/XW0nA8Mk1 xUGQ== X-Gm-Message-State: AOAM531xtR3/WXDam2If6Mggi/Alzz7geGAimk2wgewLS/UCuyGKbnbo kVY4CUxrKX13+Sy7l03kL06fdU3iBDU= X-Google-Smtp-Source: ABdhPJwsB6HQpCEkAl5mTOY6aRsm/brDO2sauYJ3rPU1AITEHe9GKvQjnu6Ov3FWgfHD7/CMSsMYHg== X-Received: by 2002:a05:6402:5252:: with SMTP id t18mr9329144edd.13.1633246977804; Sun, 03 Oct 2021 00:42:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 07/30] qtest/numa-test: Use detailed -smp CLIs in pc_dynamic_cpu_cfg Date: Sun, 3 Oct 2021 09:42:27 +0200 Message-Id: <20211003074250.60869-8-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247405517100001 From: Yanan Wang Since commit 80d7835749 (qemu-options: rewrite help for -smp options), the preference of sockets/cores in -smp parsing is considered liable to change, and actually we are going to change it in a coming commit. So it'll be more stable to use detailed -smp CLIs in testing if we have strong dependency on the parsing results. pc_dynamic_cpu_cfg currently assumes/needs that there will be 2 CPU sockets with "-smp 2". To avoid breaking the test because of parsing logic change, now explicitly use "-smp 2,sockets=3D2". Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210929025816.21076-8-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- tests/qtest/numa-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index c677cd63c4..fd7a2e80a0 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -265,7 +265,8 @@ static void pc_dynamic_cpu_cfg(const void *data) QTestState *qs; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-nodefaults --preconfig -machine smp.cpus=3D2"= ); + cli =3D make_cli(data, "-nodefaults --preconfig " + "-machine smp.cpus=3D2,smp.sockets=3D2"); qs =3D qtest_init(cli); =20 /* create 2 numa nodes */ --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247549174150.04714882438998; Sun, 3 Oct 2021 00:52:29 -0700 (PDT) Received: from localhost ([::1]:43632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwIO-00010N-6D for importer@patchew.org; Sun, 03 Oct 2021 03:52:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9F-0003Gh-AL for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:01 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:33744) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9D-0000oj-Q9 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:01 -0400 Received: by mail-ed1-x535.google.com with SMTP id p13so23616814edw.0 for ; Sun, 03 Oct 2021 00:42:59 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K6TQCFQzXuXQd9NucqfZ6yW3PdHeHGmJiGpTXeBzS4s=; b=CzlzJX/YKjdTF1nRiuiPY1d2bwtqAhjYcaRu7nUoBizvJSvou2+Fgj5Ci5db4lzzmw KA3NK0VOd8tNoUO1cxJpJFVBAvS4WAkltUmUOm/qXaGb3abAR/9cMM4xQOb92en320ok vO0XRlpFgaAhqBK+kqlKDNrCqvj9j7Qp47WeTx7aVglcPURZGCQ6KwNf6VvqCOURTnPI FO/zsyO+FMKSpoYuvcNPiLB5x5yTBWm6/arOQ/bDjwY9aYG8lAgOot7vH51F54N1SRw6 s7azPfwOpreRYQ0qrUCSP+hqrGLCqwB7juyq7kOmXD2Vjj2xpKOW1j0ORGAAgtZ3WqVQ 14nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=K6TQCFQzXuXQd9NucqfZ6yW3PdHeHGmJiGpTXeBzS4s=; b=ksZeqkxrYY2fsdzG1923YvAz2wC0hmE7VvODoNNv5R/UvpXB4vJvuGD7YohX5tuz4w sfeCYGyWsA+Jcft8uI7MaRsOahHgPp1m6tLeaFIxoxf2Rpww8LMvKxKHsuPkUX897und YBiSgLcEtfU7mH8Hcjg2x7zlN9Xd+j2qo2XgodEGIPw9NlSn2/N2Mw7g2wyA8f2R/7fO /LA0YU5iEBaVvu9NG34rzoTg1SxPfVPQthdSMexui5wQuA6je6T9llksDi30eQTMPY1L AKXlxFAst1mxZ72PdX6NP/zO7eVDMyqT2MFWVV/jvF5pRRkeUraKe0+y+vLjfqXTbtK6 oPoA== X-Gm-Message-State: AOAM530R2fGeQYcKVBnPeHaDDxjGexMtO8UUa2B7bmIpEzqFQIx3n5DU A7eISjc0W2sLRGFEOwcqgz59IL+hhy4= X-Google-Smtp-Source: ABdhPJwKvMqPnjPANoCr/J3s8oEEm1S+57zLLHJjHL+ulmNe0DdzfVNIW61DTPzdvvhQxmrgskjK/Q== X-Received: by 2002:a17:906:2bc7:: with SMTP id n7mr8746342ejg.238.1633246978568; Sun, 03 Oct 2021 00:42:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 08/30] qtest/numa-test: Use detailed -smp CLIs in test_def_cpu_split Date: Sun, 3 Oct 2021 09:42:28 +0200 Message-Id: <20211003074250.60869-9-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247550654100001 From: Yanan Wang Since commit 80d7835749 (qemu-options: rewrite help for -smp options), the preference of sockets/cores in -smp parsing is considered liable to change, and actually we are going to change it in a coming commit. So it'll be more stable to use detailed -smp CLIs in the testcases that have strong dependency on the parsing results. Currently, test_def_cpu_split use "-smp 8" and will get 8 CPU sockets based on current parsing rule. But if we change to prefer cores over sockets we will get one CPU socket with 8 cores, and this testcase will not get expected numa set by default on x86_64 (Ok on aarch64). So now explicitly use "-smp 8,sockets=3D8" to avoid affect from parsing logic change. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210929025816.21076-9-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- tests/qtest/numa-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/numa-test.c b/tests/qtest/numa-test.c index fd7a2e80a0..90bf68a5b3 100644 --- a/tests/qtest/numa-test.c +++ b/tests/qtest/numa-test.c @@ -42,7 +42,8 @@ static void test_def_cpu_split(const void *data) g_autofree char *s =3D NULL; g_autofree char *cli =3D NULL; =20 - cli =3D make_cli(data, "-machine smp.cpus=3D8 -numa node,memdev=3Dram = -numa node"); + cli =3D make_cli(data, "-machine smp.cpus=3D8,smp.sockets=3D8 " + "-numa node,memdev=3Dram -numa node"); qts =3D qtest_init(cli); =20 s =3D qtest_hmp(qts, "info numa"); --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163324761448348.34654167171709; Sun, 3 Oct 2021 00:53:34 -0700 (PDT) Received: from localhost ([::1]:45860 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwJR-0002Vl-En for importer@patchew.org; Sun, 03 Oct 2021 03:53:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9G-0003Lz-U1 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:02 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:46684) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9E-0000p1-Oe for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:02 -0400 Received: by mail-ed1-x535.google.com with SMTP id z20so466919edc.13 for ; Sun, 03 Oct 2021 00:43:00 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DN0tulJi69ThOUd7hhj1vMp2XEuspWIX9kmvQJNwQXc=; b=OhEjPNTqf2GD2odGw5F8W8FRAH+bqEHD3QMHfV8jYcoZSJ5jCvloGphV0Ji72/2t87 4CILEZZXc2cPBHfV235yfLLm1Oi4azAcsDAofCoUQAVYK3b+ZUlzATRKrKKLOtkmUxko 8kV9QfZA7qwSuTPcHOezJBlz+Xc4bd5z8QPGY52gjjkrx56ZEIZqPu8Y0vPmgQ2nsGxf Q1axW+d3rZ8oK0evTe7Oe7tXcHFspLPI03N35x/D6aGmm0rAWH405TGQnNniQiPJCV6O rA8RTA3pM/6JrBX6edYTI7pD3Zs5Zgo8fqTIVPqHq0g4ed74GhIMJRl9QP3KsCrxkNLm VF3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=DN0tulJi69ThOUd7hhj1vMp2XEuspWIX9kmvQJNwQXc=; b=1x58qQX7xc7+w7pY85F5z6lnvpa5oCdUvO6FiYeigYFgi+ADkJUr5qpVaMKdhEwFX1 8D2L91cipHmMfeLJK2Zb6MqzUFUAI2WrGaMFOBmRl3Dz8ELQI3JaIo44pj4un6CUxMxm FdpJsm3ZXy9kC9ePYVlV6HgCz3okXhtpBRWtemJKsw/AEKLfXeFQgxxLUjhveAvhPSwS obAntdQtgJ1dwVBtQHN6Vib5DIEY5zmXxoV0TOUJZZSj0EMdCFJ+CUX+aG+IKR7RJQsp fYYsji9OstJE8Od1SQ3mzP5keNwtEb+WNDkkg+OKpEZCY+EhNCpgdzNgttpDEpwLTiSy oBHQ== X-Gm-Message-State: AOAM5310qu6uTiXkAqQ5hvNeoXngh2nr5UD2ynTBPRDYlLr0EhqA1wo1 /6y/S2tDpMvkbkbgq5AAXPfWIh7TyI4= X-Google-Smtp-Source: ABdhPJxN0U/i+z0JUzHajVml4WxKMkzTKTjM51IxLGT4kZ5mR0P567IpdFyUdEG+8E2d1y7cBTME8A== X-Received: by 2002:a17:906:6b0c:: with SMTP id q12mr9233839ejr.0.1633246979400; Sun, 03 Oct 2021 00:42:59 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 09/30] machine: Prefer cores over sockets in smp parsing since 6.2 Date: Sun, 3 Oct 2021 09:42:29 +0200 Message-Id: <20211003074250.60869-10-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Andrew Jones , "Daniel P . Berrange" , Cornelia Huck , Pankaj Gupta , Yanan Wang , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247615148100001 From: Yanan Wang In the real SMP hardware topology world, it's much more likely that we have high cores-per-socket counts and few sockets totally. While the current preference of sockets over cores in smp parsing results in a virtual cpu topology with low cores-per-sockets counts and a large number of sockets, which is just contrary to the real world. Given that it is better to make the virtual cpu topology be more reflective of the real world and also for the sake of compatibility, we start to prefer cores over sockets over threads in smp parsing since machine type 6.2 for different arches. In this patch, a boolean "smp_prefer_sockets" is added, and we only enable the old preference on older machines and enable the new one since type 6.2 for all arches by using the machine compat mechanism. Suggested-by: Daniel P. Berrange Signed-off-by: Yanan Wang Acked-by: David Gibson Acked-by: Cornelia Huck Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-10-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/arm/virt.c | 1 + hw/core/machine.c | 35 ++++++++++++++++++++++++++--------- hw/i386/pc.c | 35 ++++++++++++++++++++++++++--------- hw/i386/pc_piix.c | 1 + hw/i386/pc_q35.c | 1 + hw/ppc/spapr.c | 1 + hw/s390x/s390-virtio-ccw.c | 1 + include/hw/boards.h | 1 + qemu-options.hx | 3 ++- 9 files changed, 60 insertions(+), 19 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 1d59f0e59f..8c13deb5db 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2815,6 +2815,7 @@ static void virt_machine_6_1_options(MachineClass *mc) =20 virt_machine_6_2_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); + mc->smp_prefer_sockets =3D true; =20 /* qemu ITS was introduced with 6.2 */ vmc->no_tcg_its =3D true; diff --git a/hw/core/machine.c b/hw/core/machine.c index e38ab760e6..f2a34d98c0 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -748,6 +748,7 @@ void machine_set_cpu_numa_node(MachineState *machine, =20 static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **= errp) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; unsigned sockets =3D config->has_sockets ? config->sockets : 0; unsigned cores =3D config->has_cores ? config->cores : 0; @@ -759,7 +760,7 @@ static void smp_parse(MachineState *ms, SMPConfiguratio= n *config, Error **errp) return; } =20 - /* compute missing values, prefer sockets over cores over threads */ + /* compute missing values based on the provided ones */ if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; @@ -767,14 +768,30 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) } else { maxcpus =3D maxcpus > 0 ? maxcpus : cpus; =20 - if (sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (cores * threads); - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * threads); - } else if (threads =3D=3D 0) { + if (mc->smp_prefer_sockets) { + /* prefer sockets over cores before 6.2 */ + if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (cores * threads); + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * threads); + } + } else { + /* prefer cores over sockets since 6.2 */ + if (cores =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * threads); + } else if (sockets =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (cores * threads); + } + } + + /* try to calculate omitted threads at last */ + if (threads =3D=3D 0) { threads =3D maxcpus / (sockets * cores); } } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 9216ad163d..6cc32f4048 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -716,6 +716,7 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int l= evel) */ static void pc_smp_parse(MachineState *ms, SMPConfiguration *config, Error= **errp) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; unsigned sockets =3D config->has_sockets ? config->sockets : 0; unsigned dies =3D config->has_dies ? config->dies : 0; @@ -726,7 +727,7 @@ static void pc_smp_parse(MachineState *ms, SMPConfigura= tion *config, Error **err /* directly default dies to 1 if it's omitted */ dies =3D dies > 0 ? dies : 1; =20 - /* compute missing values, prefer sockets over cores over threads */ + /* compute missing values based on the provided ones */ if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; cores =3D cores > 0 ? cores : 1; @@ -734,14 +735,30 @@ static void pc_smp_parse(MachineState *ms, SMPConfigu= ration *config, Error **err } else { maxcpus =3D maxcpus > 0 ? maxcpus : cpus; =20 - if (sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * cores * threads); - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * threads); - } else if (threads =3D=3D 0) { + if (mc->smp_prefer_sockets) { + /* prefer sockets over cores before 6.2 */ + if (sockets =3D=3D 0) { + cores =3D cores > 0 ? cores : 1; + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (dies * cores * threads); + } else if (cores =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * dies * threads); + } + } else { + /* prefer cores over sockets since 6.2 */ + if (cores =3D=3D 0) { + sockets =3D sockets > 0 ? sockets : 1; + threads =3D threads > 0 ? threads : 1; + cores =3D maxcpus / (sockets * dies * threads); + } else if (sockets =3D=3D 0) { + threads =3D threads > 0 ? threads : 1; + sockets =3D maxcpus / (dies * cores * threads); + } + } + + /* try to calculate omitted threads at last */ + if (threads =3D=3D 0) { threads =3D maxcpus / (sockets * dies * cores); } } diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6cc834aff6..932e6e2cfe 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -432,6 +432,7 @@ static void pc_i440fx_6_1_machine_options(MachineClass = *m) m->is_default =3D false; compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); + m->smp_prefer_sockets =3D true; } =20 DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 5481d5c965..57ab07e5b7 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -372,6 +372,7 @@ static void pc_q35_6_1_machine_options(MachineClass *m) m->alias =3D NULL; compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); + m->smp_prefer_sockets =3D true; } =20 DEFINE_Q35_MACHINE(v6_1, "pc-q35-6.1", NULL, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b7bee5f4ff..2986108b5a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4685,6 +4685,7 @@ static void spapr_machine_6_1_class_options(MachineCl= ass *mc) spapr_machine_6_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); smc->pre_6_2_numa_affinity =3D true; + mc->smp_prefer_sockets =3D true; } =20 DEFINE_SPAPR_MACHINE(6_1, "6.1", false); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 61aeccb163..5401c985cf 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -814,6 +814,7 @@ static void ccw_machine_6_1_class_options(MachineClass = *mc) { ccw_machine_6_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); + mc->smp_prefer_sockets =3D true; } DEFINE_CCW_MACHINE(6_1, "6.1", false); =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index 463a5514f9..2ae039b74f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -247,6 +247,7 @@ struct MachineClass { bool nvdimm_supported; bool numa_mem_supported; bool auto_enable_numa; + bool smp_prefer_sockets; const char *default_ram_id; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, diff --git a/qemu-options.hx b/qemu-options.hx index 2eac830fdb..8ef178180d 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -244,7 +244,8 @@ SRST Historically preference was given to the coarsest topology parameters when computing missing values (ie sockets preferred over cores, which were preferred over threads), however, this behaviour is considered - liable to change. + liable to change. Prior to 6.2 the preference was sockets over cores + over threads. Since 6.2 the preference is cores over sockets over thre= ads. ERST =20 DEF("numa", HAS_ARG, QEMU_OPTION_numa, --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247756184143.71459898251032; Sun, 3 Oct 2021 00:55:56 -0700 (PDT) Received: from localhost ([::1]:52118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwLj-0006hl-5w for importer@patchew.org; Sun, 03 Oct 2021 03:55:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9K-0003Y3-0w for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:06 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:37828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9F-0000q2-F9 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:05 -0400 Received: by mail-ed1-x52f.google.com with SMTP id ba1so51823195edb.4 for ; Sun, 03 Oct 2021 00:43:01 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=O+L6LDgBylGhLfbTqHLm7sHl8WXqmG3KPJ3RVD1qdSM=; b=mmxw78likKF7v+hVArH1QvCe9J5jAhv+QNx37o99VOViWa1sPV1lCrjE+iCrJobMr4 CAwod9tOoNdS1ap1+I32zIo6UajbzkF7DHLZ6hmz0RbA7qko7SH82dYXkun4U4S1Z17V gtoDjb6Idj5OQB72q3tkbZqGmW7WWpWkZ5XVypN03Kdj4L/K7OMKxzrtp8C0BmC3E6CX PQ8MaRfgwEz2YgZvUMOGnTppX+HG54FvvUzgJP4MyLOJiqc2s3eF813VoNQY9yIH9bsg H7eZpubd9A5Sa7Vc3bbryulV8ZPqrN8kZbRQyrychwjZjORIn7KrFu9P0tCP5oaP+o1q rVQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=O+L6LDgBylGhLfbTqHLm7sHl8WXqmG3KPJ3RVD1qdSM=; b=l5laIzknAy65Dht25LPqblC5ucxYe4z//FMeCG9xA8CbJ4lFs3oDWCMo+PyG2uOV7p ZDfHt55VGpUqTlG1JNl3iIoZa/dGc9CVg5WRaj1PtK5O5gwdxEmHlWEAxhjy4jZo0+em Tr4vVWdv3HsJIZxZh7HUn4u05Cc0aYPP6Mp/siLYGRHaTXPocNYDDe9XP7LAnELOS7ic 1/jvUHLUUCNZAsPnSlq4AFo0pgIhs6U5e+jvXyr6kUPGW2JtrC6hQMqOnUL2IOCbdfvD o4ABqZcPa0u7PUwLYj4xNhkO7387aShIwq+XpTmfiwOcnwUm9kHSPQkusGaYqilKB2nw Guzg== X-Gm-Message-State: AOAM532prV5ip6ISpcUakTI+XTzOuE/8qeg+S491C0b+kUwOQwbYLRiI PLlwo1UP9FkacynYqtzIsrQeqTmitPo= X-Google-Smtp-Source: ABdhPJyi6Wv4OahNULtjDT4EQPVRvxVD72i5F2QNLVZEF6lyc6yMTmf7VCRG5ThU8G0QtsVJb7kdiA== X-Received: by 2002:a17:907:984d:: with SMTP id jj13mr9368561ejc.211.1633246980159; Sun, 03 Oct 2021 00:43:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 10/30] machine: Use ms instead of global current_machine in sanity-check Date: Sun, 3 Oct 2021 09:42:30 +0200 Message-Id: <20211003074250.60869-11-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Cornelia Huck , Pankaj Gupta , Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247756868100005 From: Yanan Wang In the sanity-check of smp_cpus and max_cpus against mc in function machine_set_smp(), we are now using ms->smp.max_cpus for the check but using current_machine->smp.max_cpus in the error message. Tweak this by uniformly using the local ms. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Cornelia Huck Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210929025816.21076-11-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index f2a34d98c0..12d7416053 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -881,7 +881,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, } else if (ms->smp.max_cpus > mc->max_cpus) { error_setg(errp, "Invalid SMP CPUs %d. The max CPUs " "supported by machine '%s' is %d", - current_machine->smp.max_cpus, + ms->smp.max_cpus, mc->name, mc->max_cpus); } =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247535700135.2291626943686; Sun, 3 Oct 2021 00:52:15 -0700 (PDT) Received: from localhost ([::1]:43186 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwI9-0000iR-MV for importer@patchew.org; Sun, 03 Oct 2021 03:52:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9H-0003Pq-UA for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:03 -0400 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:46676) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9G-0000r6-6m for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:03 -0400 Received: by mail-ed1-x52c.google.com with SMTP id z20so467024edc.13 for ; Sun, 03 Oct 2021 00:43:01 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mM9K9NR20pwXDZhctbZ4eqVhCWyvVt/GAiaTV9nM3fg=; b=aXOE3zyrnD27zfNFrR4gXcPdnKP4KKJdBZ9nKAms/eLPLuJ8WSL6aK1kVvT3LNoz5a Pf/dN6T4iwEEbLpeMh/AvB5OQ2hW9Jh6jqMY7574Hrdz0153xoogsOdIkakS67ULa0W7 GuqxY1vkaDtnC4ciS1O3jx1gAu5zBK81ThD/YjhcyNX0VvGESNZJv10FYEXkdWXZZEeh 3JTZufg/FKsOygtmcg0wrpclCyY2oJKTu5MMga+kU3PfcJxsu6OOp6MbyGnIT1iJlQoL NfmZ5wawPrYV0irmW0cQU8QlqgR3KSroBn3pc0fMHP3vQJ4Y4zv6mDvYTxRO9K8ErGCy jgaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mM9K9NR20pwXDZhctbZ4eqVhCWyvVt/GAiaTV9nM3fg=; b=s8rq9kwJfbm2hgxRQd5ysfKYAAvS4Iyk46x66AyMBo0sHa4DWiPr+vcaT7Fth1v4y7 +f/vjKbVTRfIHrOVDFjYeEflKS5WeaXBKGz0felEuJ7mbe7D9pPoy4EQQaL1nV+F2OKb oD0jFhi4Gdgx3HZHw3SLImENk0kMhAXVEQKobwYWoSInY6vMGKMBy7tBYqmxQ6N1cMWU dVM7vDdz2yMyMw/0+5Gq315yrmDLr5vefQs+79Oza1NRRmaDlQ2LpBQvmM2bUpFVHUQa zExSo1CnvJ3QUV3KzqLl2WuyLQBzR30dbUqUl+6In5laIY1DIm2PY8V7OcjhNgn7gouv Ji9Q== X-Gm-Message-State: AOAM530ZvZ2M1l4FUphFxhTCoaYs0FQBEORKSH7GNZQl0IMODocWvuq3 Eb8RENKU1LOqjtT4i0Iq+vSw3R2f2qw= X-Google-Smtp-Source: ABdhPJzSF5lgbu4HyqUeOwBwRFiK4jof0wohI4YCf8SxeE/4RHCkFkXXjyOaQ/sp834BsCUmdx0rrw== X-Received: by 2002:a17:906:f2cd:: with SMTP id gz13mr1859676ejb.278.1633246980930; Sun, 03 Oct 2021 00:43:00 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 11/30] machine: Tweak the order of topology members in struct CpuTopology Date: Sun, 3 Oct 2021 09:42:31 +0200 Message-Id: <20211003074250.60869-12-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Pankaj Gupta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247536113100001 From: Yanan Wang Now that all the possible topology parameters are integrated in struct CpuTopology, tweak the order of topology members to be "cpus/sockets/ dies/cores/threads/maxcpus" for readability and consistency. We also tweak the comment by adding explanation of dies parameter. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20210929025816.21076-12-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 10 +++++----- include/hw/boards.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 12d7416053..83cbdcce47 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -829,11 +829,11 @@ static void machine_get_smp(Object *obj, Visitor *v, = const char *name, { MachineState *ms =3D MACHINE(obj); SMPConfiguration *config =3D &(SMPConfiguration){ - .has_cores =3D true, .cores =3D ms->smp.cores, + .has_cpus =3D true, .cpus =3D ms->smp.cpus, .has_sockets =3D true, .sockets =3D ms->smp.sockets, .has_dies =3D true, .dies =3D ms->smp.dies, + .has_cores =3D true, .cores =3D ms->smp.cores, .has_threads =3D true, .threads =3D ms->smp.threads, - .has_cpus =3D true, .cpus =3D ms->smp.cpus, .has_maxcpus =3D true, .maxcpus =3D ms->smp.max_cpus, }; if (!visit_type_SMPConfiguration(v, name, &config, &error_abort)) { @@ -1060,10 +1060,10 @@ static void machine_initfn(Object *obj) /* default to mc->default_cpus */ ms->smp.cpus =3D mc->default_cpus; ms->smp.max_cpus =3D mc->default_cpus; - ms->smp.cores =3D 1; - ms->smp.dies =3D 1; - ms->smp.threads =3D 1; ms->smp.sockets =3D 1; + ms->smp.dies =3D 1; + ms->smp.cores =3D 1; + ms->smp.threads =3D 1; } =20 static void machine_finalize(Object *obj) diff --git a/include/hw/boards.h b/include/hw/boards.h index 2ae039b74f..2a1bba86c0 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -275,17 +275,18 @@ typedef struct DeviceMemoryState { /** * CpuTopology: * @cpus: the number of present logical processors on the machine - * @cores: the number of cores in one package - * @threads: the number of threads in one core * @sockets: the number of sockets on the machine + * @dies: the number of dies in one socket + * @cores: the number of cores in one die + * @threads: the number of threads in one core * @max_cpus: the maximum number of logical processors on the machine */ typedef struct CpuTopology { unsigned int cpus; + unsigned int sockets; unsigned int dies; unsigned int cores; unsigned int threads; - unsigned int sockets; unsigned int max_cpus; } CpuTopology; =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247812269968.8767321656062; Sun, 3 Oct 2021 00:56:52 -0700 (PDT) Received: from localhost ([::1]:54576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwMd-0008Rs-7l for importer@patchew.org; Sun, 03 Oct 2021 03:56:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9J-0003Wg-Kp for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:05 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:36721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9H-0000rl-5L for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:05 -0400 Received: by mail-ed1-x52a.google.com with SMTP id l7so28172549edq.3 for ; Sun, 03 Oct 2021 00:43:02 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fpK85ZIjHJ05jxJoXDyWdj2igy2Sl/lx3Pqb1u/G/W0=; b=MRDZdGwkQZTr4e6B83ex6nUcvslpxIAV9xascsN8sARDFACzIwwVoTd/rYByh8wfxj qr4XwqADYHtyrz19/RTU0wL6UFn8RxFkGq7SbUe4SDjKJtNFiHJhdUpdFEus9he7kO+u IgMj6MS0dC+GFbJGy4yjLwhcnxcT8gFK/D03GtygnwNQw8M9yCV68bB6KoNZdEnhAr71 7TSbS5aiysRnbI9vrctNzOuB2LOwopM1orTG9eqSJU2A75eAmKdWKCUk9MDuZkp6Gz/E NMTMRTICIhcO2ehJ2rZZbQjN/YrJGQV6WcDyWA4JLkxB8yxQXZsPcrddvkS3/vd8sNVy 0zAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=fpK85ZIjHJ05jxJoXDyWdj2igy2Sl/lx3Pqb1u/G/W0=; b=57847Mrq4IfdPwq0B4iljXM/q6IPQKmd6quRy967TUtQmzfq15uTFaG/5bBGY0g88O rbpRV+LzjEgCfTAltkyhF30txA1DQnRXxMNH/zibl6plNlaMnJasM/a2DrEcLX2PtJ1J XNchwBlhGbxK7A54jK+fzQZVKJ37NeH/cnqd3vpHZvfHWpHHtDeN/PBTikxa06jcrfBA GpH/WfJUk7N7OtD/ScCNWsjz+yezY71P1RSFAXlnvGLxLeoYU0CdTMo1mPc5lrx125jd P7jqQ22viz4jFE/f+0lPuslH2isoJX+wG8gPRjFoRLEe4milZebBheJuUU2sK85bRhnF QnWw== X-Gm-Message-State: AOAM5314ey2rVSadr7I3nSss0PFtYn6mwDmGPVVibJayqVQ6SNQWuNNt PfuWI9AtZ9YBfpvAGEvTHKOpwIV56Bc= X-Google-Smtp-Source: ABdhPJwxLqePI8fRu0mcQ3o6hef0iRCVml1rWtL/tj4gR840QA27Y5WRuWBUnMJ86sqgI/0kp7PwNw== X-Received: by 2002:a05:6402:2793:: with SMTP id b19mr9737501ede.291.1633246981725; Sun, 03 Oct 2021 00:43:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 12/30] machine: Make smp_parse generic enough for all arches Date: Sun, 3 Oct 2021 09:42:32 +0200 Message-Id: <20211003074250.60869-13-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247814549100001 From: Yanan Wang Currently the only difference between smp_parse and pc_smp_parse is the support of dies parameter and the related error reporting. With some arch compat variables like "bool dies_supported", we can make smp_parse generic enough for all arches and the PC specific one can be removed. Making smp_parse() generic enough can reduce code duplication and ease the code maintenance, and also allows extending the topology with more arch specific members (e.g., clusters) in the future. Suggested-by: Andrew Jones Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Yanan Wang Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-13-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 91 +++++++++++++++++++++++++++++++++++---------- hw/i386/pc.c | 84 +---------------------------------------- include/hw/boards.h | 9 +++++ 3 files changed, 81 insertions(+), 103 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 83cbdcce47..12872d7715 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -746,20 +746,69 @@ void machine_set_cpu_numa_node(MachineState *machine, } } =20 +/* + * Report information of a machine's supported CPU topology hierarchy. + * Topology members will be ordered from the largest to the smallest + * in the string. + */ +static char *cpu_hierarchy_to_string(MachineState *ms) +{ + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + GString *s =3D g_string_new(NULL); + + g_string_append_printf(s, "sockets (%u)", ms->smp.sockets); + + if (mc->smp_props.dies_supported) { + g_string_append_printf(s, " * dies (%u)", ms->smp.dies); + } + + g_string_append_printf(s, " * cores (%u)", ms->smp.cores); + g_string_append_printf(s, " * threads (%u)", ms->smp.threads); + + return g_string_free(s, false); +} + +/* + * smp_parse - Generic function used to parse the given SMP configuration + * + * Any missing parameter in "cpus/maxcpus/sockets/cores/threads" will be + * automatically computed based on the provided ones. + * + * In the calculation of omitted sockets/cores/threads: we prefer sockets + * over cores over threads before 6.2, while preferring cores over sockets + * over threads since 6.2. + * + * In the calculation of cpus/maxcpus: When both maxcpus and cpus are omit= ted, + * maxcpus will be computed from the given parameters and cpus will be set + * equal to maxcpus. When only one of maxcpus and cpus is given then the + * omitted one will be set to its given counterpart's value. Both maxcpus = and + * cpus may be specified, but maxcpus must be equal to or greater than cpu= s. + * + * For compatibility, apart from the parameters that will be computed, new= ly + * introduced topology members which are likely to be target specific shou= ld + * be directly set as 1 if they are omitted (e.g. dies for PC since 4.1). + */ static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **= errp) { MachineClass *mc =3D MACHINE_GET_CLASS(ms); unsigned cpus =3D config->has_cpus ? config->cpus : 0; unsigned sockets =3D config->has_sockets ? config->sockets : 0; + unsigned dies =3D config->has_dies ? config->dies : 0; unsigned cores =3D config->has_cores ? config->cores : 0; unsigned threads =3D config->has_threads ? config->threads : 0; unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; =20 - if (config->has_dies && config->dies > 1) { + /* + * If not supported by the machine, a topology parameter must be + * omitted or specified equal to 1. + */ + if (!mc->smp_props.dies_supported && dies > 1) { error_setg(errp, "dies not supported by this machine's CPU topolog= y"); return; } =20 + dies =3D dies > 0 ? dies : 1; + /* compute missing values based on the provided ones */ if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; @@ -773,55 +822,57 @@ static void smp_parse(MachineState *ms, SMPConfigurat= ion *config, Error **errp) if (sockets =3D=3D 0) { cores =3D cores > 0 ? cores : 1; threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (cores * threads); + sockets =3D maxcpus / (dies * cores * threads); } else if (cores =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * threads); + cores =3D maxcpus / (sockets * dies * threads); } } else { /* prefer cores over sockets since 6.2 */ if (cores =3D=3D 0) { sockets =3D sockets > 0 ? sockets : 1; threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * threads); + cores =3D maxcpus / (sockets * dies * threads); } else if (sockets =3D=3D 0) { threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (cores * threads); + sockets =3D maxcpus / (dies * cores * threads); } } =20 /* try to calculate omitted threads at last */ if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * cores); + threads =3D maxcpus / (sockets * dies * cores); } } =20 - maxcpus =3D maxcpus > 0 ? maxcpus : sockets * cores * threads; + maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * cores * threads; cpus =3D cpus > 0 ? cpus : maxcpus; =20 - if (sockets * cores * threads !=3D maxcpus) { + ms->smp.cpus =3D cpus; + ms->smp.sockets =3D sockets; + ms->smp.dies =3D dies; + ms->smp.cores =3D cores; + ms->smp.threads =3D threads; + ms->smp.max_cpus =3D maxcpus; + + /* sanity-check of the computed topology */ + if (sockets * dies * cores * threads !=3D maxcpus) { + g_autofree char *topo_msg =3D cpu_hierarchy_to_string(ms); error_setg(errp, "Invalid CPU topology: " "product of the hierarchy must match maxcpus: " - "sockets (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, cores, threads, maxcpus); + "%s !=3D maxcpus (%u)", + topo_msg, maxcpus); return; } =20 if (maxcpus < cpus) { + g_autofree char *topo_msg =3D cpu_hierarchy_to_string(ms); error_setg(errp, "Invalid CPU topology: " "maxcpus must be equal to or greater than smp: " - "sockets (%u) * cores (%u) * threads (%u) " - "=3D=3D maxcpus (%u) < smp_cpus (%u)", - sockets, cores, threads, maxcpus, cpus); + "%s =3D=3D maxcpus (%u) < smp_cpus (%u)", + topo_msg, maxcpus, cpus); return; } - - ms->smp.cpus =3D cpus; - ms->smp.sockets =3D sockets; - ms->smp.cores =3D cores; - ms->smp.threads =3D threads; - ms->smp.max_cpus =3D maxcpus; } =20 static void machine_get_smp(Object *obj, Visitor *v, const char *name, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6cc32f4048..28e1b83b9d 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -710,88 +710,6 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int = level) } } =20 -/* - * This function is very similar to smp_parse() - * in hw/core/machine.c but includes CPU die support. - */ -static void pc_smp_parse(MachineState *ms, SMPConfiguration *config, Error= **errp) -{ - MachineClass *mc =3D MACHINE_GET_CLASS(ms); - unsigned cpus =3D config->has_cpus ? config->cpus : 0; - unsigned sockets =3D config->has_sockets ? config->sockets : 0; - unsigned dies =3D config->has_dies ? config->dies : 0; - unsigned cores =3D config->has_cores ? config->cores : 0; - unsigned threads =3D config->has_threads ? config->threads : 0; - unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; - - /* directly default dies to 1 if it's omitted */ - dies =3D dies > 0 ? dies : 1; - - /* compute missing values based on the provided ones */ - if (cpus =3D=3D 0 && maxcpus =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - } else { - maxcpus =3D maxcpus > 0 ? maxcpus : cpus; - - if (mc->smp_prefer_sockets) { - /* prefer sockets over cores before 6.2 */ - if (sockets =3D=3D 0) { - cores =3D cores > 0 ? cores : 1; - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * cores * threads); - } else if (cores =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * threads); - } - } else { - /* prefer cores over sockets since 6.2 */ - if (cores =3D=3D 0) { - sockets =3D sockets > 0 ? sockets : 1; - threads =3D threads > 0 ? threads : 1; - cores =3D maxcpus / (sockets * dies * threads); - } else if (sockets =3D=3D 0) { - threads =3D threads > 0 ? threads : 1; - sockets =3D maxcpus / (dies * cores * threads); - } - } - - /* try to calculate omitted threads at last */ - if (threads =3D=3D 0) { - threads =3D maxcpus / (sockets * dies * cores); - } - } - - maxcpus =3D maxcpus > 0 ? maxcpus : sockets * dies * cores * threads; - cpus =3D cpus > 0 ? cpus : maxcpus; - - if (sockets * dies * cores * threads !=3D maxcpus) { - error_setg(errp, "Invalid CPU topology: " - "product of the hierarchy must match maxcpus: " - "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " - "!=3D maxcpus (%u)", - sockets, dies, cores, threads, maxcpus); - return; - } - - if (maxcpus < cpus) { - error_setg(errp, "Invalid CPU topology: " - "maxcpus must be equal to or greater than smp: " - "sockets (%u) * dies (%u) * cores (%u) * threads (%u) " - "=3D=3D maxcpus (%u) < smp_cpus (%u)", - sockets, dies, cores, threads, maxcpus, cpus); - return; - } - - ms->smp.cpus =3D cpus; - ms->smp.sockets =3D sockets; - ms->smp.dies =3D dies; - ms->smp.cores =3D cores; - ms->smp.threads =3D threads; - ms->smp.max_cpus =3D maxcpus; -} - static void pc_machine_done(Notifier *notifier, void *data) { @@ -1755,7 +1673,6 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) mc->auto_enable_numa_with_memdev =3D true; mc->has_hotpluggable_cpus =3D true; mc->default_boot_order =3D "cad"; - mc->smp_parse =3D pc_smp_parse; mc->block_default_type =3D IF_IDE; mc->max_cpus =3D 255; mc->reset =3D pc_machine_reset; @@ -1766,6 +1683,7 @@ static void pc_machine_class_init(ObjectClass *oc, vo= id *data) hc->unplug =3D pc_machine_device_unplug_cb; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; mc->nvdimm_supported =3D true; + mc->smp_props.dies_supported =3D true; mc->default_ram_id =3D "pc.ram"; =20 object_class_property_add(oc, PC_MACHINE_MAX_RAM_BELOW_4G, "size", diff --git a/include/hw/boards.h b/include/hw/boards.h index 2a1bba86c0..72a23e4e0f 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -108,6 +108,14 @@ typedef struct { CPUArchId cpus[]; } CPUArchIdList; =20 +/** + * SMPCompatProps: + * @dies_supported - whether dies are supported by the machine + */ +typedef struct { + bool dies_supported; +} SMPCompatProps; + /** * MachineClass: * @deprecation_reason: If set, the machine is marked as deprecated. The @@ -248,6 +256,7 @@ struct MachineClass { bool numa_mem_supported; bool auto_enable_numa; bool smp_prefer_sockets; + SMPCompatProps smp_props; const char *default_ram_id; =20 HotplugHandler *(*get_hotplug_handler)(MachineState *machine, --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247546497907.8111927725814; Sun, 3 Oct 2021 00:52:26 -0700 (PDT) Received: from localhost ([::1]:43406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwIK-0000rW-K1 for importer@patchew.org; Sun, 03 Oct 2021 03:52:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9J-0003Vz-EL for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:05 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:34445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9H-0000rr-OF for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:05 -0400 Received: by mail-ed1-x52e.google.com with SMTP id g7so50879123edv.1 for ; Sun, 03 Oct 2021 00:43:03 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d5KVo7fwa78aJLS92JAbYmvR8UXHXfLItQt4hY4PWJw=; b=ZisFnKaPxRh1/aOL7viemcY1TfOqEbf90l2c8sM+nwL6lxx5fCu7MhG7Ya9FTLXvlP 8Z6USkuy5eICP+Mlhq7NyCd3gooQTlxZcvRrJPzIW66rGcj0cLcYPDZJ/SMD8RoBx3o9 nkyI/XzetWx/WmleNBjC8c3wRMvBFfr3Bh3gKLKwfCT3xXRYTrsAfXjTQ8avWE0Hyb/t DkgRm3pVOVLI7O2YCkvMNIzsUUrgwLzblQODWTjlzhMrxQqoK62SwJHD9xYa7A605Nuz Ze7J4kx/8SS90bSMXFnvaE/Aiyvf+3by/5kksSX7oeZLWh49neaFZDLC8zwn9SzncmsS sp/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=d5KVo7fwa78aJLS92JAbYmvR8UXHXfLItQt4hY4PWJw=; b=FiydVdZUupYA1e+AHHM6yWfcYaqz4WN7ydiN4HdSPPMaenrMiOfP8VNQpFzMWN6Fcj Lesg88bye7YZWKQn40TJLTJ7mdyzX1xcu89+i5Vt+DH2e/CpoH2i2bojwaQQ15nH/s6j fLgSV3gwYdEoLxGQCH818BaUl4HifMMDVc1jEe2CAhETeRbe+ROtL6VDtTEt7UboSxkX z+mu2SvuAd5Ty9wYRR/FVVYq8VvxeY9XcPPEyVlwW6wXupPGFC0YVElALLqFaYyyYKm5 N6cGT/IzfBS2MX3dW0JyOFiGKL6+07en7JA7tvpm6yo/ojgygmWxk8aMX1fvmxaRP9ih WX9w== X-Gm-Message-State: AOAM532wp/Z8MosRhKW5ZIUmm4O7gZb0QPFdVkZlnpN3tdJS1O4ofgG0 U2TPvAHQWVPOD3yzDZPTlMw47C827tg= X-Google-Smtp-Source: ABdhPJwp6l285xOoKFs/x2Z16s8ChLNabXqLqbZgO7gJuj38F9NU48Hsog5QgvbzlbG/9hyqukcwJA== X-Received: by 2002:a17:906:3ce2:: with SMTP id d2mr9273306ejh.410.1633246982420; Sun, 03 Oct 2021 00:43:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 13/30] machine: Remove smp_parse callback from MachineClass Date: Sun, 3 Oct 2021 09:42:33 +0200 Message-Id: <20211003074250.60869-14-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247548534100001 From: Yanan Wang Now we have a generic smp parser for all arches, and there will not be any other arch specific ones, so let's remove the callback from MachineClass and call the parser directly. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-14-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 3 +-- include/hw/boards.h | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 12872d7715..8b0f1aed83 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -918,7 +918,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, "CPU topology parameters must be greater than zero"); } =20 - mc->smp_parse(ms, config, errp); + smp_parse(ms, config, errp); if (*errp) { goto out_free; } @@ -947,7 +947,6 @@ static void machine_class_init(ObjectClass *oc, void *d= ata) /* Default 128 MB as guest ram size */ mc->default_ram_size =3D 128 * MiB; mc->rom_file_has_mr =3D true; - mc->smp_parse =3D smp_parse; =20 /* numa node memory size aligned on 8MB by default. * On Linux, each node's border has to be 8MB aligned diff --git a/include/hw/boards.h b/include/hw/boards.h index 72a23e4e0f..fa284e01e9 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -177,10 +177,6 @@ typedef struct { * kvm-type may be NULL if it is not needed. * @numa_mem_supported: * true if '--numa node.mem' option is supported and false otherwise - * @smp_parse: - * The function pointer to hook different machine specific functions for - * parsing "smp-opts" from QemuOpts to MachineState::CpuTopology and mo= re - * machine specific topology fields, such as smp_dies for PCMachine. * @hotplug_allowed: * If the hook is provided, then it'll be called for each device * hotplug to check whether the device hotplug is allowed. Return @@ -217,7 +213,6 @@ struct MachineClass { void (*reset)(MachineState *state); void (*wakeup)(MachineState *state); int (*kvm_type)(MachineState *machine, const char *arg); - void (*smp_parse)(MachineState *ms, SMPConfiguration *config, Error **= errp); =20 BlockInterfaceType block_default_type; int units_per_default_bus; --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163324790397852.38721936900242; Sun, 3 Oct 2021 00:58:23 -0700 (PDT) Received: from localhost ([::1]:60592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwO6-00043E-Pr for importer@patchew.org; Sun, 03 Oct 2021 03:58:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9L-0003c4-3T for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:07 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:44565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9I-0000sN-Fu for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:06 -0400 Received: by mail-ed1-x532.google.com with SMTP id v18so50891982edc.11 for ; Sun, 03 Oct 2021 00:43:04 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+vOdH4m3hrFvFRhYahy/3RG4y7EYfgtFN7DPdj5//eE=; b=Rv/erQvzX9HHDoRn1wGUCp7OxBIeny23YgRp9UV3fPt+L7FkdvC+CtIc2GXikaT68D pIjvrGs874cZ2Sa/bOBMocn8tJEIUgxZrchRAsVeGNxnZGwGi6L9Gu1FOoknex7wVh2j glk1ifS4RH4lR8eXq3ZjQU9S706rUZ7Jak4IsWsF9RFrcE61hWr0Z9s1EZwYQVcE29Ig p7/7FGNcIgs8/12SA/CXWs+jB1urFSIOm8jRfh/OpTRqT8miwcrZ91ksNUkNU7KYyhmj XyOrorgP2JH9v0YJXhjjAmm3CXYbPWoAFMdCaIvKfE/tAtGy4QLBvtMxQ2KUdtBBflGH ENbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+vOdH4m3hrFvFRhYahy/3RG4y7EYfgtFN7DPdj5//eE=; b=QYraf0+XYj6cMU/zX6ByCT5wxMp6y++MN1V+0J61ltO3RKfWbqxaRnPqyjNhW566St i+4axaIVoMJ+OSnkzGOXsiWcT8AANWCf+lYqJrbpwv+F7aNtbTch9ZKsSY8rbPdZpLIK cekWF71Dh33jDcRQSekuK0kifagDaG2b0/50UWfm8vyoO1jpk7oeMX0PvbcQ3J1CmJUA xuGrTIL9k0bc3PwfyoWe/sOMPTQYTzEM5fVJw0SqzIY+Z2aO9aUbCFonWW15vT6OC+ST L21l8yY2Dn1JEgvDNHmFpiU83QAEieTfIeuHYTFp43LUY4PqRt56LfR1VjGF9NTXOwfI QiBg== X-Gm-Message-State: AOAM5319BpKE+IugLxJEAORl2GLwNm//i654wVEvppoiksOxe2Sbt9SI v+n0oIvpHMGpbTFPoyRxJFKBp9XJeLQ= X-Google-Smtp-Source: ABdhPJxd6gCMGv87Gx/gCOOx4UvxVZ+LnTq4ws7nXtJYcLbCbl24XM1a++AOVbiYkIRP5x7cb4xNrA== X-Received: by 2002:a17:906:5051:: with SMTP id e17mr8921694ejk.481.1633246983135; Sun, 03 Oct 2021 00:43:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 14/30] machine: Move smp_prefer_sockets to struct SMPCompatProps Date: Sun, 3 Oct 2021 09:42:34 +0200 Message-Id: <20211003074250.60869-15-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247904949100001 From: Yanan Wang Now we have a common structure SMPCompatProps used to store information about SMP compatibility stuff, so we can also move smp_prefer_sockets there for cleaner code. No functional change intended. Signed-off-by: Yanan Wang Acked-by: David Gibson Reviewed-by: Andrew Jones Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-15-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/arm/virt.c | 2 +- hw/core/machine.c | 2 +- hw/i386/pc_piix.c | 2 +- hw/i386/pc_q35.c | 2 +- hw/ppc/spapr.c | 2 +- hw/s390x/s390-virtio-ccw.c | 2 +- include/hw/boards.h | 3 ++- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8c13deb5db..7170aaacd5 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2815,7 +2815,7 @@ static void virt_machine_6_1_options(MachineClass *mc) =20 virt_machine_6_2_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); - mc->smp_prefer_sockets =3D true; + mc->smp_props.prefer_sockets =3D true; =20 /* qemu ITS was introduced with 6.2 */ vmc->no_tcg_its =3D true; diff --git a/hw/core/machine.c b/hw/core/machine.c index 8b0f1aed83..54f04a5ac6 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -817,7 +817,7 @@ static void smp_parse(MachineState *ms, SMPConfiguratio= n *config, Error **errp) } else { maxcpus =3D maxcpus > 0 ? maxcpus : cpus; =20 - if (mc->smp_prefer_sockets) { + if (mc->smp_props.prefer_sockets) { /* prefer sockets over cores before 6.2 */ if (sockets =3D=3D 0) { cores =3D cores > 0 ? cores : 1; diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 932e6e2cfe..6ad0d763c5 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -432,7 +432,7 @@ static void pc_i440fx_6_1_machine_options(MachineClass = *m) m->is_default =3D false; compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); - m->smp_prefer_sockets =3D true; + m->smp_props.prefer_sockets =3D true; } =20 DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 57ab07e5b7..fcc6e4eb2b 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -372,7 +372,7 @@ static void pc_q35_6_1_machine_options(MachineClass *m) m->alias =3D NULL; compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); - m->smp_prefer_sockets =3D true; + m->smp_props.prefer_sockets =3D true; } =20 DEFINE_Q35_MACHINE(v6_1, "pc-q35-6.1", NULL, diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 2986108b5a..163c90388a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4685,7 +4685,7 @@ static void spapr_machine_6_1_class_options(MachineCl= ass *mc) spapr_machine_6_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); smc->pre_6_2_numa_affinity =3D true; - mc->smp_prefer_sockets =3D true; + mc->smp_props.prefer_sockets =3D true; } =20 DEFINE_SPAPR_MACHINE(6_1, "6.1", false); diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 5401c985cf..653587ea62 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -814,7 +814,7 @@ static void ccw_machine_6_1_class_options(MachineClass = *mc) { ccw_machine_6_2_class_options(mc); compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len); - mc->smp_prefer_sockets =3D true; + mc->smp_props.prefer_sockets =3D true; } DEFINE_CCW_MACHINE(6_1, "6.1", false); =20 diff --git a/include/hw/boards.h b/include/hw/boards.h index fa284e01e9..5adbcbb99b 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -110,9 +110,11 @@ typedef struct { =20 /** * SMPCompatProps: + * @prefer_sockets - whether sockets are preferred over cores in smp parsi= ng * @dies_supported - whether dies are supported by the machine */ typedef struct { + bool prefer_sockets; bool dies_supported; } SMPCompatProps; =20 @@ -250,7 +252,6 @@ struct MachineClass { bool nvdimm_supported; bool numa_mem_supported; bool auto_enable_numa; - bool smp_prefer_sockets; SMPCompatProps smp_props; const char *default_ram_id; =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247753511353.76681282212905; Sun, 3 Oct 2021 00:55:53 -0700 (PDT) Received: from localhost ([::1]:51862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwLg-0006Vh-FQ for importer@patchew.org; Sun, 03 Oct 2021 03:55:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9K-0003bg-Ut for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:06 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:37824) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9I-0000t4-Vb for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:06 -0400 Received: by mail-ed1-x52a.google.com with SMTP id ba1so51823516edb.4 for ; Sun, 03 Oct 2021 00:43:04 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kxJKQjT+RSitACC85MwIyDhGgyneKK19VDnydBrIezo=; b=fiMnr6QD+n0arIU5h7hGN0n+veU92PSeji6sLmPv6nSIPcPE1E8ywBz3BG7H5NwRQV zwya2E/lKLsw628WhId2KUNnd0HIw8OHNJEVoyf2t4+qcjtqNPuDJWXsxZfCwdWQbt/v 2CSwWOji065GyjpOc9UBk6gjgfY2XimL7DVTM7iwX6P7phMX+n58zYq1e3qiiOxzqjgJ ecrIZloMqE4SB2hwXVOBlpukguAmXqNu0+3ynZoKG9jHYgpxXaZMunJDl5QLgaJycWPN H4YM9cnB6NaZw7sOr+N1PKHqmFnvPZlvM5Ps+uW+u5v7aOznslEtQBByglD03VypHuaJ 2y+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=kxJKQjT+RSitACC85MwIyDhGgyneKK19VDnydBrIezo=; b=aX/4B3gxEznlqHMjspc7syGpNFiQzQUJI57NQnre4ZxDQYPYXtz2tkzMHqM7IzDW6A qnRcVxxQjS+Bp9irWkdjEveIke9ANgQO6FWZrzG1wMur/cg+VIprWYdzCXt9JkLjblrC QklG4fklBuP//+8AfxcfEolqyqQdQ3TK+CchbDolArRYelYZZJTRn2hm+jjY7YLidorL 8oAS7ZExWQ9xkvZL+AJX7C0RapPfbilWBoVK71H6wOgY1TRMdjqcqxjh5MOrzTJX9yXB Y+cCzQUvPV9i2MRTXdbm3GTckOf1yMdKDJkOlti4ZtKpUUwNVnBrlbmoeveercxzIBg6 X5uA== X-Gm-Message-State: AOAM533whVEPi8YB6vlMkvqI0aRhVYTdiK6XijZFenefJnz9l8fOdrh7 Fc9KF/dFDPg9/G7ho5wg5mUiniTnhCk= X-Google-Smtp-Source: ABdhPJzOX5tq2IA7bm3E5uUagujT9MVN0/e6QKuSv6sNGggjUlZTWfNncDvLLPeJ1hJ8bUiz6zjINA== X-Received: by 2002:a05:6402:3088:: with SMTP id de8mr9561706edb.76.1633246983774; Sun, 03 Oct 2021 00:43:03 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 15/30] machine: Use g_autoptr in machine_set_smp Date: Sun, 3 Oct 2021 09:42:35 +0200 Message-Id: <20211003074250.60869-16-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247754841100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 54f04a5ac6..d49ebc24e2 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -897,7 +897,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, { MachineClass *mc =3D MACHINE_GET_CLASS(obj); MachineState *ms =3D MACHINE(obj); - SMPConfiguration *config; + g_autoptr(SMPConfiguration) config =3D NULL; ERRP_GUARD(); =20 if (!visit_type_SMPConfiguration(v, name, &config, errp)) { @@ -920,7 +920,7 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, =20 smp_parse(ms, config, errp); if (*errp) { - goto out_free; + return; } =20 /* sanity-check smp_cpus and max_cpus against mc */ @@ -935,9 +935,6 @@ static void machine_set_smp(Object *obj, Visitor *v, co= nst char *name, ms->smp.max_cpus, mc->name, mc->max_cpus); } - -out_free: - qapi_free_SMPConfiguration(config); } =20 static void machine_class_init(ObjectClass *oc, void *data) --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247752395734.2857703699219; Sun, 3 Oct 2021 00:55:52 -0700 (PDT) Received: from localhost ([::1]:51708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwLd-0006Pf-3t for importer@patchew.org; Sun, 03 Oct 2021 03:55:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9L-0003eM-M6 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:07 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:44025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9J-0000u4-TL for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:07 -0400 Received: by mail-ed1-x535.google.com with SMTP id v10so52142881edj.10 for ; Sun, 03 Oct 2021 00:43:05 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1wFA3sfoHmjtt243SXZVGaLCwA0Tmjm2zolvW91KgQI=; b=ZtK+28SD21WaqlxCico4ZTZtWnd1hKcq1hnVqxCxk/s5pRJnTfhrWWgm9a2kC55WZ+ FxmDHMlnrf0yBrTcMBYbLQFx2dhFXxQXtKhgmdM4Y92FiUD4RpVGl6le7qd1Ndtrtwvh iv5rGSizIrFARDaOJejU4GRAboMaOhn7Ya9UFrLHUXtUv/uQ2qzpRMpWUStEogUrnYCR ddGD3z0Z2+ioC11fl3+xOzICiavBlonzivEqWQrwZtHZImfP2AJ2cRYEkfi5cBxcjF5I BhvWOLvUw0G59+yso2j2JtczxhbAPm81Et0e6bi4n1MNO0y8d2dDoqw8YuTPDJLPtoIQ mSLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=1wFA3sfoHmjtt243SXZVGaLCwA0Tmjm2zolvW91KgQI=; b=GrZWc/pM3PJ8I50fD2SKcfOE2XFq0LCEJiabaGGkrv5S7l/YRf2GFp5wjIz43afirq BSjkJCfndiw7M5S8w/4mbbXgSQsMY+bVeVxCaOhIWpFw8dvYnVKbLAUsKmTy1dBAM1ck KwkEa789+Odr9O0547ET3gfPUsqqiKEHIGa5vyma+B7EA13FCBknR2CEz81y5xv/HB1a oTKs0h3O+d84JJdpIkUTYWgvfedDaZhcfKqShB9KQAh2da8/Ntf8sCxCMwehJFAjSwct lHL0pfOGq/WMyk5m5G+TJ6D8DU3xuKT/Nz3rqazK/xnljbLcO74OZ0c5rmA9eFDrCCst kt1Q== X-Gm-Message-State: AOAM530byc4hQeasTPhrA0XujLzwRoOA9ifI7JchW5WEScpoJdEJjAko HQotllVrT0UdhmexxzMN8jKHyPkiQRQ= X-Google-Smtp-Source: ABdhPJwAwrA3o6oUpk6T+MemdmT+2I/uc8ATiYIvOyU8MdZJwuOPTC3E1VsengEnoy0IGFymPbb5Yw== X-Received: by 2002:a50:dac4:: with SMTP id s4mr9017498edj.374.1633246984543; Sun, 03 Oct 2021 00:43:04 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/30] machine: Put all sanity-check in the generic SMP parser Date: Sun, 3 Oct 2021 09:42:36 +0200 Message-Id: <20211003074250.60869-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Yanan Wang , Andrew Jones , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , Pankaj Gupta Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247753011100001 From: Yanan Wang Put both sanity-check of the input SMP configuration and sanity-check of the output SMP configuration uniformly in the generic parser. Then machine_set_smp() will become cleaner, also all the invalid scenarios can be tested only by calling the parser. Signed-off-by: Yanan Wang Reviewed-by: Andrew Jones Reviewed-by: Pankaj Gupta Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20210929025816.21076-16-wangyanan55@huawei.com> Signed-off-by: Paolo Bonzini --- hw/core/machine.c | 62 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index d49ebc24e2..3920a2f2af 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -798,6 +798,20 @@ static void smp_parse(MachineState *ms, SMPConfigurati= on *config, Error **errp) unsigned threads =3D config->has_threads ? config->threads : 0; unsigned maxcpus =3D config->has_maxcpus ? config->maxcpus : 0; =20 + /* + * Specified CPU topology parameters must be greater than zero, + * explicit configuration like "cpus=3D0" is not allowed. + */ + if ((config->has_cpus && config->cpus =3D=3D 0) || + (config->has_sockets && config->sockets =3D=3D 0) || + (config->has_dies && config->dies =3D=3D 0) || + (config->has_cores && config->cores =3D=3D 0) || + (config->has_threads && config->threads =3D=3D 0) || + (config->has_maxcpus && config->maxcpus =3D=3D 0)) { + warn_report("Deprecated CPU topology (considered invalid): " + "CPU topology parameters must be greater than zero"); + } + /* * If not supported by the machine, a topology parameter must be * omitted or specified equal to 1. @@ -873,6 +887,22 @@ static void smp_parse(MachineState *ms, SMPConfigurati= on *config, Error **errp) topo_msg, maxcpus, cpus); return; } + + if (ms->smp.cpus < mc->min_cpus) { + error_setg(errp, "Invalid SMP CPUs %d. The min CPUs " + "supported by machine '%s' is %d", + ms->smp.cpus, + mc->name, mc->min_cpus); + return; + } + + if (ms->smp.max_cpus > mc->max_cpus) { + error_setg(errp, "Invalid SMP CPUs %d. The max CPUs " + "supported by machine '%s' is %d", + ms->smp.max_cpus, + mc->name, mc->max_cpus); + return; + } } =20 static void machine_get_smp(Object *obj, Visitor *v, const char *name, @@ -895,46 +925,14 @@ static void machine_get_smp(Object *obj, Visitor *v, = const char *name, static void machine_set_smp(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - MachineClass *mc =3D MACHINE_GET_CLASS(obj); MachineState *ms =3D MACHINE(obj); g_autoptr(SMPConfiguration) config =3D NULL; - ERRP_GUARD(); =20 if (!visit_type_SMPConfiguration(v, name, &config, errp)) { return; } =20 - /* - * Specified CPU topology parameters must be greater than zero, - * explicit configuration like "cpus=3D0" is not allowed. - */ - if ((config->has_cpus && config->cpus =3D=3D 0) || - (config->has_sockets && config->sockets =3D=3D 0) || - (config->has_dies && config->dies =3D=3D 0) || - (config->has_cores && config->cores =3D=3D 0) || - (config->has_threads && config->threads =3D=3D 0) || - (config->has_maxcpus && config->maxcpus =3D=3D 0)) { - warn_report("Deprecated CPU topology (considered invalid): " - "CPU topology parameters must be greater than zero"); - } - smp_parse(ms, config, errp); - if (*errp) { - return; - } - - /* sanity-check smp_cpus and max_cpus against mc */ - if (ms->smp.cpus < mc->min_cpus) { - error_setg(errp, "Invalid SMP CPUs %d. The min CPUs " - "supported by machine '%s' is %d", - ms->smp.cpus, - mc->name, mc->min_cpus); - } else if (ms->smp.max_cpus > mc->max_cpus) { - error_setg(errp, "Invalid SMP CPUs %d. The max CPUs " - "supported by machine '%s' is %d", - ms->smp.max_cpus, - mc->name, mc->max_cpus); - } } =20 static void machine_class_init(ObjectClass *oc, void *data) --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247908955323.3662596101693; Sun, 3 Oct 2021 00:58:28 -0700 (PDT) Received: from localhost ([::1]:60778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwOB-0004Ae-VU for importer@patchew.org; Sun, 03 Oct 2021 03:58:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9M-0003gq-76 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:08 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:37828) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9K-0000uq-HW for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:07 -0400 Received: by mail-ed1-x52e.google.com with SMTP id ba1so51823714edb.4 for ; Sun, 03 Oct 2021 00:43:06 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=K/0LAETsbZkY8Peist9OmS0kPYlNSupnjACkLzhKPxQ=; b=T7Tju7D+MWFK+Pe6UBbxSc8ZGe1fQSAvxVBmP/deL/jJ/0t8MqF3lJliJB7UMHaJEl Md+jvKviqfhrFjwkzWYFIB24xym6fak49tZvt09s+IZzRlRzgnYrtFHFnlCJiX+qdSQW JerkdaT5xyauvMQYh8yUJbY7ooK67Zxv+DqHkqC6QkXriqXB9lY6KH69/3dS6Ah+p7Ya CsoHQ9U2Bl02lRUR5In+Aur7P2HqwoGKLqmP3WrSj/cjFsSwGqGyaRMPe13JZ1Gzze97 pHUX3bN1Y6tbrW70ARuqXOS48TTBg1sbdnsBIfvAYMHIcVUeazgHEP6DKB9Frxc715Pl lsKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=K/0LAETsbZkY8Peist9OmS0kPYlNSupnjACkLzhKPxQ=; b=vCZdobsPI+TdVoxdwFXjzt3lt0cIxQSy4oEJnM42VIyiPT/jycsyIUvbseo/Gd8SFz iUqtidAS7RaBKYBqsSRvWzTKBUW6bnWE8IQMZDHqhVyTDKLpERpXu3hMQZTaRklEY9I+ 655pRToiUp1EUtYoOBd0ualoqG0X/ixZoR7b4091tHAjzEyOVOp+PkzwvJ4EjfMEI98/ Mt5Pizxc5jJaLHiGCvtXPd7Ww2FbBtAOm/1yCjcJfqvZdiDoYBqytBAqnSbsFEQVn3RA EYMiVVnKm6JYJDtlYPAoFaq+rM9GX8obZUFhvihBgTDM+HWJmxpmvjJEOFVdBETGcVJp ZVsA== X-Gm-Message-State: AOAM532s6XH3wnCE4T4l+EPQ1owIPvJKJ5W0qVLQmAy/wmdh4KqrMAMx Cc495x8H4k234bC1sk9fFzxaP5tglCU= X-Google-Smtp-Source: ABdhPJzt/+PPr5H/DALWTleMg7OL6TblgptP058WnR8KubKiZuYRqsYBS6QPGGZjqf89w6627bA3Fw== X-Received: by 2002:a17:907:9604:: with SMTP id gb4mr9186209ejc.142.1633246985217; Sun, 03 Oct 2021 00:43:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 17/30] i386: Support KVM_CAP_ENFORCE_PV_FEATURE_CPUID Date: Sun, 3 Oct 2021 09:42:37 +0200 Message-Id: <20211003074250.60869-18-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247911103100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov By default, KVM allows the guest to use all currently supported PV features even when they were not announced in guest visible CPUIDs. Introduce a new "kvm-pv-enforce-cpuid" flag to limit the supported feature set to the exposed features. The feature is supported by Linux >=3D 5.10 and is not enabled by default in QEMU. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-4-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/cpu.c | 2 ++ target/i386/cpu.h | 3 +++ target/i386/kvm/kvm.c | 10 ++++++++++ 3 files changed, 15 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index cacec605bf..598019de12 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6860,6 +6860,8 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), + DEFINE_PROP_BOOL("kvm-pv-enforce-cpuid", X86CPU, kvm_pv_enforce_cpuid, + false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), DEFINE_PROP_BOOL("tcg-cpuid", X86CPU, expose_tcg, true), DEFINE_PROP_BOOL("x-migrate-smi-count", X86CPU, migrate_smi_count, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 29552dc2a7..c990150373 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1802,6 +1802,9 @@ struct X86CPU { /* Stop SMI delivery for migration compatibility with old machines */ bool kvm_no_smi_migration; =20 + /* Forcefully disable KVM PV features not exposed in guest CPUIDs */ + bool kvm_pv_enforce_cpuid; + /* Number of physical address bits supported */ uint32_t phys_bits; =20 diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 7f1b060e6d..d6a70c27e5 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1629,6 +1629,16 @@ int kvm_arch_init_vcpu(CPUState *cs) =20 cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); =20 + if (cpu->kvm_pv_enforce_cpuid) { + r =3D kvm_vcpu_enable_cap(cs, KVM_CAP_ENFORCE_PV_FEATURE_CPUID, 0,= 1); + if (r < 0) { + fprintf(stderr, + "failed to enable KVM_CAP_ENFORCE_PV_FEATURE_CPUID: %s= ", + strerror(-r)); + abort(); + } + } + for (i =3D 0; i <=3D limit; i++) { if (cpuid_i =3D=3D KVM_MAX_CPUID_ENTRIES) { fprintf(stderr, "unsupported level value: 0x%x\n", limit); --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16332480861341020.5385261101748; Sun, 3 Oct 2021 01:01:26 -0700 (PDT) Received: from localhost ([::1]:40842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwR3-0001Hg-09 for importer@patchew.org; Sun, 03 Oct 2021 04:01:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9M-0003jy-VJ for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:08 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:40749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9L-0000v0-60 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:08 -0400 Received: by mail-ed1-x535.google.com with SMTP id g8so51965085edt.7 for ; Sun, 03 Oct 2021 00:43:06 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WoWiryGI2T3SkhDO1+fsiuderDI9swQzYrgJaWsDXkM=; b=FjMIYvqm3kSpKey+bTtF81Iv2jo9pAYmjh1VPmRzoLOqmLby3QVWDOq9WAzvjokLcQ tIOxiqldqumEhg6dVmXmvb5rVWTKej6lTknaDLiq+0wcIE+BlHAjl4qyG1oGHka59uWk zANxmCMA6YO8STt+GisSi+Y0VJgz7PIA1+i8hPirnK7hNWBiE/EQnaqciZh4+H6Pt99e 7Gc7wwiYoMs5eid0wegtD4Ub3/cBI5HjNFejbhDaOMhiXiiGIFzXP9YABmytUsWY7q4p SIp/QHqLLkIz80pL1OYwtovlpOLlLZWWu5HFDqHo/WaxCmbyKiJB8o8J2uDQX6MussLk Jl8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=WoWiryGI2T3SkhDO1+fsiuderDI9swQzYrgJaWsDXkM=; b=Ci6JTWfy0fgqZsTEeGAleV1UWUt3qm7wM4pcfJYAt+rYRv14t63dDjg1VUC39062Hk 6JUUshHJLYBYHdir6XA8dgiDNLmCxnGHeZDMs8KWDQj8/PdrylxAeiak8RIsvssUJAvn +410sm1aICF667ngWMer43Kc8b6KeV3h8dDE9hC2KL5R/zW1yUdcII288YgaX/Qclanw FVZpdAm1OVlzkOP1MfTDzlsJ1Y/8d/OUUMC1q+rTJMfdVtdXvp1QgD/53i0dvTNFj6Gn tI6+e0lRJEy+bZn6+Ibzpmb+wMP7hdqbXhomoq6k4tFwJ7nxt5WzsnPI2WA03HUgYEhW zjhA== X-Gm-Message-State: AOAM531J2Yco33UVhg23wu4e0AshE6fz/JYjgkqzDY8GN+KE34WypRbQ vHM+Z/X79pziVE+HQxy6PQJyBiBMI2E= X-Google-Smtp-Source: ABdhPJzagyFzJGKh8lMe7N6vclUmobooAVdzrLUV4TEyeen/nv5VsBq0M94wDE9ocVTE1igvUQwNVQ== X-Received: by 2002:a05:6402:713:: with SMTP id w19mr9719440edx.366.1633246985887; Sun, 03 Oct 2021 00:43:05 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 18/30] i386: Support KVM_CAP_HYPERV_ENFORCE_CPUID Date: Sun, 3 Oct 2021 09:42:38 +0200 Message-Id: <20211003074250.60869-19-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248088185100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov By default, KVM allows the guest to use all currently supported Hyper-V enlightenments when Hyper-V CPUID interface was exposed, regardless of if some features were not announced in guest visible CPUIDs. hv-enforce-cpuid feature alters this behavior and only allows the guest to use exposed Hyper-V enlightenments. The feature is supported by Linux >=3D 5.14 and is not enabled by default in QEMU. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-5-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 17 ++++++++++++++--- target/i386/cpu.c | 1 + target/i386/cpu.h | 1 + target/i386/kvm/kvm.c | 9 +++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 000638a2fd..072709a68f 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -203,8 +203,11 @@ When the option is set to 'on' QEMU will always enable= the feature, regardless of host setup. To keep guests secure, this can only be used in conjunction= with exposing correct vCPU topology and vCPU pinning. =20 -4. Development features -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +4. Supplementary features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + +4.1. hv-passthrough +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D In some cases (e.g. during development) it may make sense to use QEMU in 'pass-through' mode and give Windows guests all enlightenments currently supported by KVM. This pass-through mode is enabled by "hv-passthrough" CPU @@ -215,8 +218,16 @@ values from KVM to QEMU. "hv-passthrough" overrides al= l other "hv-*" settings on the command line. Also, enabling this flag effectively prevents migration = as the list of enabled enlightenments may differ between target and destination h= osts. =20 +4.2. hv-enforce-cpuid +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +By default, KVM allows the guest to use all currently supported Hyper-V +enlightenments when Hyper-V CPUID interface was exposed, regardless of if +some features were not announced in guest visible CPUIDs. 'hv-enforce-cpui= d' +feature alters this behavior and only allows the guest to use exposed Hype= r-V +enlightenments. =20 -4. Useful links + +5. Useful links =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Hyper-V Top Level Functional specification and other information: https://github.com/MicrosoftDocs/Virtualization-Documentation diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 598019de12..2a19eba56d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6834,6 +6834,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), + DEFINE_PROP_BOOL("hv-enforce-cpuid", X86CPU, hyperv_enforce_cpuid, fal= se), =20 DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index c990150373..8a7209bbf2 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1719,6 +1719,7 @@ struct X86CPU { uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; uint32_t hyperv_nested[4]; + bool hyperv_enforce_cpuid; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index d6a70c27e5..fbe6b7ac72 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1531,6 +1531,15 @@ static int hyperv_init_vcpu(X86CPU *cpu) cpu->hyperv_nested[0] =3D evmcs_version; } =20 + if (cpu->hyperv_enforce_cpuid) { + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENFORCE_CPUID, 0, 1= ); + if (ret < 0) { + error_report("failed to enable KVM_CAP_HYPERV_ENFORCE_CPUID: %= s", + strerror(-ret)); + return ret; + } + } + return 0; } =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248088581251.0501614204079; Sun, 3 Oct 2021 01:01:28 -0700 (PDT) Received: from localhost ([::1]:41076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwR5-0001W9-8m for importer@patchew.org; Sun, 03 Oct 2021 04:01:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9N-0003lm-Cr for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:09 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]:34446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9L-0000vG-Rb for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:09 -0400 Received: by mail-ed1-x52e.google.com with SMTP id g7so50879612edv.1 for ; Sun, 03 Oct 2021 00:43:07 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ol7KFbHD80KvHnsxeRqvbBuP7yXULEZLE36r8xBpq44=; b=S6rweDqgrR4OjG1F9obJp5KkAXsTf2KyB8fmw57fPbN5UFcoqQp2X0IM3iRm66YZQv ulcvl6hNQTN5KHpyqTFc3ezQMsAjMxy+loR9Kc6sKnQKASrWSUSe1/vaWQsa6u4CG1ga NTHafT48yr5pC8q6iMUkm/cjvvavufPzODi2X4kQSYhuBSl+9mpy2n+Jufz4ulzHa8Cv l0NuAOwiJreLyj3MQ8hNCIaeBJhF0XkZDCIem6MdZeU5gU7XW+bdeoF0HIYvG2pMtqFi w7AbqwtvHxQcZdq+mSKSt2PBNUFtY571z1BJnVySEqC33HPIlwHsvU0OOptHwntJEQIl PlZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ol7KFbHD80KvHnsxeRqvbBuP7yXULEZLE36r8xBpq44=; b=V+TU7KxzBMQ/BLVFOzUnixegZCBmrrllHQPv+NuaB4ly50OJhjVJThqL8w9DEK1cMr RtiMe2OQKYpzZuetVD38D9HHsPRhnA9BDY8N/bmoCWUJHspqs/HY/tVI4w1QaxQ2F5WI IkNSUFXpwEkaUu6rlyEvYZrShG8B1Qbod0yvrEjSIb7fXKdetnentjoyyxslXsTb22kh 5jspm/040fEWk+d4AMG3skrgIwNdvx+Q12xaQtePHHWXC8BT0u/LTFn7nGwJBo4AbfeN 7LqQyiuuHbWROpLBjUt1FiWXxC2wov/1uyfC5tnjd8yfjQEyWcIrt79cZRQUllBPd4hY zZ4A== X-Gm-Message-State: AOAM530FEFCpkCCQxwic8d9zgtXdRq5oDQaydM5Wka1MVphXF01eEmWE mJl+JZaJEfKxi6KzjN1FqLyF/oNQWPY= X-Google-Smtp-Source: ABdhPJyStHcgOWrcfMnpf+ajGqoEl147ffSP7n+OGn8FbLJUd8h8idR6TaruVwNT2XYLM9nEirYYww== X-Received: by 2002:a17:906:3181:: with SMTP id 1mr9358224ejy.388.1633246986561; Sun, 03 Oct 2021 00:43:06 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 19/30] i386: Move HV_APIC_ACCESS_RECOMMENDED bit setting to hyperv_fill_cpuids() Date: Sun, 3 Oct 2021 09:42:39 +0200 Message-Id: <20211003074250.60869-20-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52e; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52e.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248090353100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov In preparation to enabling Hyper-V + APICv/AVIC move HV_APIC_ACCESS_RECOMMENDED setting out of kvm_hyperv_properties[]: the 'real' feature bit for the vAPIC features is HV_APIC_ACCESS_AVAILABLE, HV_APIC_ACCESS_RECOMMENDED is a recommendation to use the feature which we may not always want to give. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-6-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- target/i386/kvm/kvm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index fbe6b7ac72..a9a8f77df3 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -821,9 +821,7 @@ static struct { .desc =3D "virtual APIC (hv-vapic)", .flags =3D { {.func =3D HV_CPUID_FEATURES, .reg =3D R_EAX, - .bits =3D HV_APIC_ACCESS_AVAILABLE}, - {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, - .bits =3D HV_APIC_ACCESS_RECOMMENDED} + .bits =3D HV_APIC_ACCESS_AVAILABLE} } }, [HYPERV_FEAT_TIME] =3D { @@ -1366,6 +1364,7 @@ static int hyperv_fill_cpuids(CPUState *cs, c->ebx |=3D HV_POST_MESSAGES | HV_SIGNAL_EVENTS; } =20 + /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ c->edx |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILABLE; =20 @@ -1374,6 +1373,10 @@ static int hyperv_fill_cpuids(CPUState *cs, c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC)) { + c->eax |=3D HV_APIC_ACCESS_RECOMMENDED; + } + if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_ON) { c->eax |=3D HV_NO_NONARCH_CORESHARING; } else if (cpu->hyperv_no_nonarch_cs =3D=3D ON_OFF_AUTO_AUTO) { --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248729795103.27064285231211; Sun, 3 Oct 2021 01:12:09 -0700 (PDT) Received: from localhost ([::1]:33612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwbQ-0007eY-Hp for importer@patchew.org; Sun, 03 Oct 2021 04:12:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9P-0003tq-DN for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:11 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:39884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9M-0000w2-Fp for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:10 -0400 Received: by mail-ed1-x52f.google.com with SMTP id x7so50489424edd.6 for ; Sun, 03 Oct 2021 00:43:08 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yLqMqgJN/wHxsEfbXmoW7r8LgoKq8VIYgSuC7Xehijk=; b=Ijlw/BLADUteyvxYjC/LImngxPYV3neOFa2eTCnJ+5lm50pa33nRMYJ1tYnP5Caar2 KHkNG+nWrm/6SfAioXEQuGHOEeJT7aXdgeD9YXOj98RQfmnZewO4oDvUUfv49JA+9Mzw xJDr6m63Jed9e03NMdS9ZapXgX2utaLW14SiW34q7VDS9ES629V8KCOUPXnzsals0G31 4yOA/8n/pw9onbgANpMjnt4xlch7HYYid2O5fKKDZ15TYz17tegAiTz4pDDJeuQOOcS2 tJrdaUEymp3lO6AOGr6M8eHm3iEAFpsQID+bB+oGzve9kYphzjriQjjawc2Krm9rd1OV arHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=yLqMqgJN/wHxsEfbXmoW7r8LgoKq8VIYgSuC7Xehijk=; b=jQYSPBNlto6wX87icnKrOwspE/nB6/Eg3ARPhft2dSkkp0vvmS0wvWbmfEmfslYNAM 7+O9tSReITDuyXIi3Cg/HO+MrT32+O0AIF/3idbnSnc7U1GwkSqaw9l7Qr7lcuvGZA1q 0mwm4BUJDI+mYdi/WWQOXzsNUeVib66FRocCQxFDm/UmCIEGAQok1NC5idtEiGXoCtcz oKrFl3a8QTc7aT3NOwV5qcv79EbdvKTKtYtFYmtFP0ZCh25scDqCb+V5prK/5ob5g3VX tRQj8hcpWWPUgzQcuE6C7A+4oN0KVRZNIP19GYpJsqRVEAut07WmieqTkWqd1mOWNt5m UUSQ== X-Gm-Message-State: AOAM531D4TvkvD9XCafZ9PuQNRby44yMs6e+0AXqwb7+Vyhesc42n5cs 0HVL9PmiyZHp53L7gcBy956EmBAAR2c= X-Google-Smtp-Source: ABdhPJyeb+ojWGEMRA4TyIDfxNa26u7O7mDXK74ZwksIBIKL+Jt0IYl9xcTXLDJBMYRLGiNbaF5wGA== X-Received: by 2002:a17:906:5282:: with SMTP id c2mr9257299ejm.162.1633246987206; Sun, 03 Oct 2021 00:43:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 20/30] i386: Implement pseudo 'hv-avic' ('hv-apicv') enlightenment Date: Sun, 3 Oct 2021 09:42:40 +0200 Message-Id: <20211003074250.60869-21-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52f; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248731998100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC enabled. Normally, Hyper-V SynIC disables these hardware features and suggests the guest to use paravirtualized AutoEOI feature. Linux-4.15 gains support for conditional APICv/AVIC disablement, the feature stays on until the guest tries to use AutoEOI feature with SynIC. With 'HV_DEPRECATING_AEOI_RECOMMENDED' bit exposed, modern enough Windows/ Hyper-V versions should follow the recommendation and not use the (unwanted) feature. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-7-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 10 +++++++++- target/i386/cpu.c | 4 ++++ target/i386/cpu.h | 1 + target/i386/kvm/hyperv-proto.h | 1 + target/i386/kvm/kvm.c | 10 +++++++++- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 072709a68f..cd1ea3bbe9 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -189,7 +189,15 @@ enabled. =20 Requires: hv-vpindex, hv-synic, hv-time, hv-stimer =20 -3.17. hv-no-nonarch-coresharing=3Don/off/auto +3.18. hv-avic (hv-apicv) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +The enlightenment allows to use Hyper-V SynIC with hardware APICv/AVIC ena= bled. +Normally, Hyper-V SynIC disables these hardware feature and suggests the g= uest +to use paravirtualized AutoEOI feature. +Note: enabling this feature on old hardware (without APICv/AVIC support) m= ay +have negative effect on guest's performace. + +3.19. hv-no-nonarch-coresharing=3Don/off/auto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This enlightenment tells guest OS that virtual processors will never share= a physical core unless they are reported as sibling SMT threads. This inform= ation diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2a19eba56d..8154343cc4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6644,6 +6644,8 @@ static void x86_cpu_initfn(Object *obj) object_property_add_alias(obj, "sse4_1", obj, "sse4.1"); object_property_add_alias(obj, "sse4_2", obj, "sse4.2"); =20 + object_property_add_alias(obj, "hv-apicv", obj, "hv-avic"); + if (xcc->model) { x86_cpu_load_model(cpu, xcc->model); } @@ -6831,6 +6833,8 @@ static Property x86_cpu_properties[] =3D { HYPERV_FEAT_IPI, 0), DEFINE_PROP_BIT64("hv-stimer-direct", X86CPU, hyperv_features, HYPERV_FEAT_STIMER_DIRECT, 0), + DEFINE_PROP_BIT64("hv-avic", X86CPU, hyperv_features, + HYPERV_FEAT_AVIC, 0), DEFINE_PROP_ON_OFF_AUTO("hv-no-nonarch-coresharing", X86CPU, hyperv_no_nonarch_cs, ON_OFF_AUTO_OFF), DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 8a7209bbf2..65f0ee2caf 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1056,6 +1056,7 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; #define HYPERV_FEAT_EVMCS 12 #define HYPERV_FEAT_IPI 13 #define HYPERV_FEAT_STIMER_DIRECT 14 +#define HYPERV_FEAT_AVIC 15 =20 #ifndef HYPERV_SPINLOCK_NEVER_NOTIFY #define HYPERV_SPINLOCK_NEVER_NOTIFY 0xFFFFFFFF diff --git a/target/i386/kvm/hyperv-proto.h b/target/i386/kvm/hyperv-proto.h index 5fbb385cc1..89f81afda7 100644 --- a/target/i386/kvm/hyperv-proto.h +++ b/target/i386/kvm/hyperv-proto.h @@ -66,6 +66,7 @@ #define HV_APIC_ACCESS_RECOMMENDED (1u << 3) #define HV_SYSTEM_RESET_RECOMMENDED (1u << 4) #define HV_RELAXED_TIMING_RECOMMENDED (1u << 5) +#define HV_DEPRECATING_AEOI_RECOMMENDED (1u << 9) #define HV_CLUSTER_IPI_RECOMMENDED (1u << 10) #define HV_EX_PROCESSOR_MASKS_RECOMMENDED (1u << 11) #define HV_ENLIGHTENED_VMCS_RECOMMENDED (1u << 14) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index a9a8f77df3..68faf72e34 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -924,6 +924,13 @@ static struct { }, .dependencies =3D BIT(HYPERV_FEAT_STIMER) }, + [HYPERV_FEAT_AVIC] =3D { + .desc =3D "AVIC/APICv support (hv-avic/hv-apicv)", + .flags =3D { + {.func =3D HV_CPUID_ENLIGHTMENT_INFO, .reg =3D R_EAX, + .bits =3D HV_DEPRECATING_AEOI_RECOMMENDED} + } + }, }; =20 static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, @@ -1373,7 +1380,8 @@ static int hyperv_fill_cpuids(CPUState *cs, c->eax =3D hv_build_cpuid_leaf(cs, HV_CPUID_ENLIGHTMENT_INFO, R_EAX); c->ebx =3D cpu->hyperv_spinlock_attempts; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC)) { + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC) && + !hyperv_feat_enabled(cpu, HYPERV_FEAT_AVIC)) { c->eax |=3D HV_APIC_ACCESS_RECOMMENDED; } =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248599344542.0148630914654; Sun, 3 Oct 2021 01:09:59 -0700 (PDT) Received: from localhost ([::1]:57646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwZK-0004ey-Bp for importer@patchew.org; Sun, 03 Oct 2021 04:09:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36902) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9P-0003to-Bo for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:11 -0400 Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]:36723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9N-0000x0-9m for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:10 -0400 Received: by mail-ed1-x52b.google.com with SMTP id l7so28173080edq.3 for ; Sun, 03 Oct 2021 00:43:08 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rnxp7ibYXa4U48aH5PXvrbUL74+jjocUih8G8Jy9CQw=; b=d9CieDTYHjeI6wwd1LMAwQH25t25KGbvdj5CtXzjAlo4EwzTJZoPj6nrv/ucFxMCdx L5IanSb3ptYLN8LMhO0Jktv9MgcNze8GqQhvaexYQR8fndLcmDfg5SjpZd7GTZk/UeNm DaKp8hcZTdNckOjmqWaDLs+lO49P201SmELp/wbXU6mzcY+UdDRQNFgk40WqcUq81+v0 oxxYuIcf2Ye2wDps+MaALkE1OGi41sr/rncOGVdRr/TFvLrypR+o3whFeeZXp9yAKWTM 9QL9/3SMQ+ioOumhTLKYGAtByuic8pSNtVtNYwX1GEs0U6b/f2gYuc5UQ67V3H7ScNni pE7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Rnxp7ibYXa4U48aH5PXvrbUL74+jjocUih8G8Jy9CQw=; b=bcrD4QJXZmVWlBkvmlQgbCHVcNDby93+UJl4jiiQw0FvZWVcyiEYA+kMtO+yrDEMSo sfiTz08MDJKDOF5KRZzz1B+TyC6n2suKoxyOiqq8oymjTWqnFFWlBbffBzy6rPbHMEd2 C27QbNElIqQHvb++gzd0ul0K8h2mUZEKifgJWwYN3bVlnPeRyplfj3wRxqGGDShO1nB5 50T0JWLWhqYVRFE/xSpQGtpbOUDlS5fqItHEObEwpYm4vjgM7h5hHu9BbW2v5ltAITKr Io6YNsdaV/T+xqEX5+rnI/l4582nDnb5X3rVK/lcXHA1ZjLPBW0N7XD9ME4HyoTlsAgS YmhQ== X-Gm-Message-State: AOAM5331djhye41zYt4efpTNG9esVV/y17ZSy5sdr+/164Wuv38x1v0l AwkDIVLf9DCwRzHKCerCxHo5rKNpRKg= X-Google-Smtp-Source: ABdhPJzsmAWohuQLSgfjVXGDB81KaS0JJnV6VLsaPv5bc/hG3zpLcf56tr+v5gawayXdkBkxDTyPTQ== X-Received: by 2002:a17:906:6c84:: with SMTP id s4mr9264252ejr.121.1633246987832; Sun, 03 Oct 2021 00:43:07 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 21/30] i386: Make Hyper-V version id configurable Date: Sun, 3 Oct 2021 09:42:41 +0200 Message-Id: <20211003074250.60869-22-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52b; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52b.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248599851100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov Currently, we hardcode Hyper-V version id (CPUID 0x40000002) to WS2008R2 and it is known that certain tools in Windows check this. It seems useful to provide some flexibility by making it possible to change this info at will. CPUID information is defined in TLFS as: EAX: Build Number EBX Bits 31-16: Major Version Bits 15-0: Minor Version ECX Service Pack EDX Bits 31-24: Service Branch Bits 23-0: Service Number Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-8-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 14 ++++++++++++++ target/i386/cpu.c | 15 +++++++++++---- target/i386/cpu.h | 7 ++++++- target/i386/kvm/kvm.c | 26 ++++++++++++++++---------- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index cd1ea3bbe9..7803495468 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -211,6 +211,20 @@ When the option is set to 'on' QEMU will always enable= the feature, regardless of host setup. To keep guests secure, this can only be used in conjunction= with exposing correct vCPU topology and vCPU pinning. =20 +3.20. hv-version-id-{build,major,minor,spack,sbranch,snumber} +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX fr= om the +default (WS2008R2). +- hv-version-id-build sets 'Build Number' (32 bits) +- hv-version-id-major sets 'Major Version' (16 bits) +- hv-version-id-minor sets 'Minor Version' (16 bits) +- hv-version-id-spack sets 'Service Pack' (32 bits) +- hv-version-id-sbranch sets 'Service Branch' (8 bits) +- hv-version-id-snumber sets 'Service Number' (24 bits) + +Note: hv-version-id-* are not enlightenments and thus don't enable Hyper-V +identification when specified without any other enlightenments. + 4. Supplementary features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 8154343cc4..d1d057fabe 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6258,10 +6258,6 @@ static void x86_cpu_hyperv_realize(X86CPU *cpu) cpu->hyperv_interface_id[2] =3D 0; cpu->hyperv_interface_id[3] =3D 0; =20 - /* Hypervisor system identity */ - cpu->hyperv_version_id[0] =3D 0x00001bbc; - cpu->hyperv_version_id[1] =3D 0x00060001; - /* Hypervisor implementation limits */ cpu->hyperv_limits[0] =3D 64; cpu->hyperv_limits[1] =3D 0; @@ -6840,6 +6836,17 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_BOOL("hv-passthrough", X86CPU, hyperv_passthrough, false), DEFINE_PROP_BOOL("hv-enforce-cpuid", X86CPU, hyperv_enforce_cpuid, fal= se), =20 + /* WS2008R2 identify by default */ + DEFINE_PROP_UINT32("hv-version-id-build", X86CPU, hyperv_ver_id_build, + 0x1bbc), + DEFINE_PROP_UINT16("hv-version-id-major", X86CPU, hyperv_ver_id_major, + 0x0006), + DEFINE_PROP_UINT16("hv-version-id-minor", X86CPU, hyperv_ver_id_minor, + 0x0001), + DEFINE_PROP_UINT32("hv-version-id-spack", X86CPU, hyperv_ver_id_sp, 0), + DEFINE_PROP_UINT8("hv-version-id-sbranch", X86CPU, hyperv_ver_id_sb, 0= ), + DEFINE_PROP_UINT32("hv-version-id-snumber", X86CPU, hyperv_ver_id_sn, = 0), + DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true), DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), DEFINE_PROP_BOOL("x-force-features", X86CPU, force_features, false), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 65f0ee2caf..3edaad7688 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1717,10 +1717,15 @@ struct X86CPU { OnOffAuto hyperv_no_nonarch_cs; uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; - uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; uint32_t hyperv_nested[4]; bool hyperv_enforce_cpuid; + uint32_t hyperv_ver_id_build; + uint16_t hyperv_ver_id_major; + uint16_t hyperv_ver_id_minor; + uint32_t hyperv_ver_id_sp; + uint8_t hyperv_ver_id_sb; + uint32_t hyperv_ver_id_sn; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 68faf72e34..f25837f63f 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -1258,14 +1258,18 @@ bool kvm_hyperv_expand_features(X86CPU *cpu, Error = **errp) cpu->hyperv_interface_id[3] =3D hv_cpuid_get_host(cs, HV_CPUID_INTERFACE, R_EDX); =20 - cpu->hyperv_version_id[0] =3D + cpu->hyperv_ver_id_build =3D hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EAX); - cpu->hyperv_version_id[1] =3D - hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX); - cpu->hyperv_version_id[2] =3D + cpu->hyperv_ver_id_major =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX) >> 16; + cpu->hyperv_ver_id_minor =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EBX) & 0xffff; + cpu->hyperv_ver_id_sp =3D hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_ECX); - cpu->hyperv_version_id[3] =3D - hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX); + cpu->hyperv_ver_id_sb =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX) >> 24; + cpu->hyperv_ver_id_sn =3D + hv_cpuid_get_host(cs, HV_CPUID_VERSION, R_EDX) & 0xffffff; =20 cpu->hv_max_vps =3D hv_cpuid_get_host(cs, HV_CPUID_IMPLEMENT_LIMIT= S, R_EAX); @@ -1351,10 +1355,12 @@ static int hyperv_fill_cpuids(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VERSION; - c->eax =3D cpu->hyperv_version_id[0]; - c->ebx =3D cpu->hyperv_version_id[1]; - c->ecx =3D cpu->hyperv_version_id[2]; - c->edx =3D cpu->hyperv_version_id[3]; + c->eax =3D cpu->hyperv_ver_id_build; + c->ebx =3D (uint32_t)cpu->hyperv_ver_id_major << 16 | + cpu->hyperv_ver_id_minor; + c->ecx =3D cpu->hyperv_ver_id_sp; + c->edx =3D (uint32_t)cpu->hyperv_ver_id_sb << 24 | + (cpu->hyperv_ver_id_sn & 0xffffff); =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_FEATURES; --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248412281803.8415741727014; Sun, 3 Oct 2021 01:06:52 -0700 (PDT) Received: from localhost ([::1]:49624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwWI-0007NL-Mw for importer@patchew.org; Sun, 03 Oct 2021 04:06:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9P-0003ti-Cv for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:11 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:44559) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9N-0000xi-NO for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:11 -0400 Received: by mail-ed1-x52a.google.com with SMTP id v18so50892439edc.11 for ; Sun, 03 Oct 2021 00:43:09 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FwA+wilZzoFxPcnuwn2ma5jaPENmzxYB5mdqfNqBOVY=; b=CodWZa8wnW/kL99qrSc1zf2Z7/VGVKYbDFnFTXd2ii4UcItVNjQqSsPuG69z8TCWcm rfJvTqeb0vU0A9BSx6W7T4As6FW7LKcTK7Z3I+G2Cj5LKMcN/5tCr7u9Ugmn08SUHGgc /nMReaE07y7ZupmDklcToujMqsqMM5Eov6fVgt52muJYFMmZ2phtGkuMhLpVtUjKWErH F5TuMVKvMHm9r/E5vD/tBQjGFGqdwHoaglHO0buFUOmezDhhXMR6ZKcUYuudtYZCplQ9 i2D0cnna6tEtb6CJxJrzRzZqpra+BCA/Uu8CjsA/kJbdSqR1hXD94ubzNxWjdRWGeBJf Uxkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=FwA+wilZzoFxPcnuwn2ma5jaPENmzxYB5mdqfNqBOVY=; b=nhP1UOYetxHWqSwyPUbWm7G+R8NYFO8if63Cu21QTvKqmcjDfNiBU8j2e02uZmBlrV EHsqvAlkDVXFN5OaqIHE37FgQmNLw/qdzQPHa7AzUoduByctd0aoIT/QsrsGOcrAct3k CEOHHThmwnLrWyrwIy8vqdNSgWhFuWTp7jiFF0tfyobStUcRdLoskVnLLNuUAs8iNfOu WjQY6ncOuY6olKmzClG65tNmHEgk78y1Q54MxP04BkgCn9Z9WIQGfwxJc6FxrBSUZy/r 21lVRmCke025+p3RBuODwlKrH7R0CO9WJ/Wb1h7Z34TLlRZNWcKkTXDzcWc0rdgODc2u W2sg== X-Gm-Message-State: AOAM5336mDYyWhn3VkXw/JVlteLRjOSR35lmE0U9eyfipgOQuIwtJd9p WPgrgB5oQaD4RiRVEaKaDC39vE1FVU0= X-Google-Smtp-Source: ABdhPJzSLgcM9MFIA0UE+O9mqsS4y415L6TUNJ7egvW7wu3lTjF1M1WtWleSrZAz3XgIpYmHfbKo2A== X-Received: by 2002:a17:906:128f:: with SMTP id k15mr8980626ejb.334.1633246988521; Sun, 03 Oct 2021 00:43:08 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 22/30] i386: Change the default Hyper-V version to match WS2016 Date: Sun, 3 Oct 2021 09:42:42 +0200 Message-Id: <20211003074250.60869-23-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Vitaly Kuznetsov Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248413062100001 Content-Type: text/plain; charset="utf-8" From: Vitaly Kuznetsov KVM implements some Hyper-V 2016 functions so providing WS2008R2 version is somewhat incorrect. While generally guests shouldn't care about it and always check feature bits, it is known that some tools in Windows actually check version info. For compatibility reasons make the change for 6.2 machine types only. Signed-off-by: Vitaly Kuznetsov Message-Id: <20210902093530.345756-9-vkuznets@redhat.com> Signed-off-by: Paolo Bonzini --- docs/hyperv.txt | 2 +- hw/i386/pc.c | 6 +++++- target/i386/cpu.c | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/hyperv.txt b/docs/hyperv.txt index 7803495468..5d99fd9a72 100644 --- a/docs/hyperv.txt +++ b/docs/hyperv.txt @@ -214,7 +214,7 @@ exposing correct vCPU topology and vCPU pinning. 3.20. hv-version-id-{build,major,minor,spack,sbranch,snumber} =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This changes Hyper-V version identification in CPUID 0x40000002.EAX-EDX fr= om the -default (WS2008R2). +default (WS2016). - hv-version-id-build sets 'Build Number' (32 bits) - hv-version-id-major sets 'Major Version' (16 bits) - hv-version-id-minor sets 'Minor Version' (16 bits) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 28e1b83b9d..86223acfd3 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -93,7 +93,11 @@ #include "trace.h" #include CONFIG_DEVICES =20 -GlobalProperty pc_compat_6_1[] =3D {}; +GlobalProperty pc_compat_6_1[] =3D { + { TYPE_X86_CPU, "hv-version-id-build", "0x1bbc" }, + { TYPE_X86_CPU, "hv-version-id-major", "0x0006" }, + { TYPE_X86_CPU, "hv-version-id-minor", "0x0001" }, +}; const size_t pc_compat_6_1_len =3D G_N_ELEMENTS(pc_compat_6_1); =20 GlobalProperty pc_compat_6_0[] =3D { diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d1d057fabe..a7b1b6aa93 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6838,11 +6838,11 @@ static Property x86_cpu_properties[] =3D { =20 /* WS2008R2 identify by default */ DEFINE_PROP_UINT32("hv-version-id-build", X86CPU, hyperv_ver_id_build, - 0x1bbc), + 0x3839), DEFINE_PROP_UINT16("hv-version-id-major", X86CPU, hyperv_ver_id_major, - 0x0006), + 0x000A), DEFINE_PROP_UINT16("hv-version-id-minor", X86CPU, hyperv_ver_id_minor, - 0x0001), + 0x0000), DEFINE_PROP_UINT32("hv-version-id-spack", X86CPU, hyperv_ver_id_sp, 0), DEFINE_PROP_UINT8("hv-version-id-sbranch", X86CPU, hyperv_ver_id_sb, 0= ), DEFINE_PROP_UINT32("hv-version-id-snumber", X86CPU, hyperv_ver_id_sn, = 0), --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633247949562625.2539990564052; Sun, 3 Oct 2021 00:59:09 -0700 (PDT) Received: from localhost ([::1]:35194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwOq-0005xS-JE for importer@patchew.org; Sun, 03 Oct 2021 03:59:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9Q-0003xX-7l for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:12 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:39890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9O-0000yC-D3 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:11 -0400 Received: by mail-ed1-x535.google.com with SMTP id x7so50489779edd.6 for ; Sun, 03 Oct 2021 00:43:09 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qcYxgU2BWHGdyqmbza1PuxPba8AZTnDNMxkoorI7FVY=; b=moNi+qHOV+loeVj2ooFDJ1iKQKTafV56PaMLPhdC3LS+NJljO9rcVtWqbhAVGUCX7w buGSxJvBkRst9H9C9Xjz3gBvVy1O30QYx0k8R9j6W3CWy7lK4rL9p/f5HHABzSMuFtuf SSQ3yS5BISUwp/aPjyB+Miz61uWfunvA0eXB+pdszjs5eTzXJq5PvuQKipWnZ/2xmavP aFqSMu6V47UyRe/CLbTAn/imYFHk9gNOdUAq4JN+zsjIktU7I90TiHH9Aho+CjzEX9J6 lJXn2V4s++vkFWLverY1niM6uR5vk7JYANnWpbnxDC47ni2J0qT0MHvpnMYOBdP4oPY/ nrbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qcYxgU2BWHGdyqmbza1PuxPba8AZTnDNMxkoorI7FVY=; b=pJJ8SodQuZKxql1AONVIE5ZTr2VL89KAksbJN8Gg0Mh3CKZSVojvZ0UcYfe8SEP/Uj N4QbsGUCw63ZD4Je/ZJjZ85U6Iv6DUHbXiXBRXaWY3UyyXyqevQ94Zme2za+XP6bCeI5 QNbqaffdHWBRsh8Kg9XGpqn39/IrxsPHcsfdIwvxurpGYt4dIYcdLtIcvnUeqprOWy5c dXDTUauJalgLD5fC4xHTtyUfTm9s1be2zvX+U/4gkwsfruccuwfS5nUVZSy0pX9HUll7 P4UXT45qShhOSBXJ6KmRV0hWpw7L1Z9uaUbLsyeOYrJnwu7yeW+B8gA8CcvVn471LQO6 VTxg== X-Gm-Message-State: AOAM53218qBh7tDs/7/5cVNs01OWrQLFhHuGEAhkfNmKnWNzR8QcHUIL YdCF+I5B7NxDC3Y1VlF9Tm8nDQ5WOIE= X-Google-Smtp-Source: ABdhPJz0eR2gFLXZbquq1l6Wz3X1OQ61rfxBn76U4iBciKSHem898DGHGh1D9w13c+Y5UvsUL3moBQ== X-Received: by 2002:a17:907:2091:: with SMTP id pv17mr8830617ejb.180.1633246989146; Sun, 03 Oct 2021 00:43:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 23/30] configure: Loosen GCC requirement from 7.5.0 to 7.4.0 Date: Sun, 3 Oct 2021 09:42:43 +0200 Message-Id: <20211003074250.60869-24-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: nia , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247950277100001 Content-Type: text/plain; charset="utf-8" From: nia As discussed in issue 614, we're shipping GCC 7.4.0 as the system compiler in NetBSD 9, the most recent stable branch, and are still actively interested in QEMU on this platform. The differences between GCC 7.5.0 and 7.4.0 are trivial. Signed-off-by: Nia Alarie Reviewed-by: Richard Henderson Message-Id: Signed-off-by: Paolo Bonzini --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 1043ccce4f..b0b1a1cc25 100755 --- a/configure +++ b/configure @@ -2094,8 +2094,8 @@ cat > $TMPC << EOF # endif # endif #elif defined(__GNUC__) && defined(__GNUC_MINOR__) -# if __GNUC__ < 7 || (__GNUC__ =3D=3D 7 && __GNUC_MINOR__ < 5) -# error You need at least GCC v7.5.0 to compile QEMU +# if __GNUC__ < 7 || (__GNUC__ =3D=3D 7 && __GNUC_MINOR__ < 4) +# error You need at least GCC v7.4.0 to compile QEMU # endif #else # error You either need GCC or Clang to compiler QEMU @@ -2103,7 +2103,7 @@ cat > $TMPC << EOF int main (void) { return 0; } EOF if ! compile_prog "" "" ; then - error_exit "You need at least GCC v7.5 or Clang v6.0 (or XCode Clang v= 10.0)" + error_exit "You need at least GCC v7.4 or Clang v6.0 (or XCode Clang v= 10.0)" fi =20 # Accumulate -Wfoo and -Wno-bar separately. --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248844751792.3222813134092; Sun, 3 Oct 2021 01:14:04 -0700 (PDT) Received: from localhost ([::1]:37922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwdH-000296-Gj for importer@patchew.org; Sun, 03 Oct 2021 04:14:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9R-00041y-9z; Sun, 03 Oct 2021 03:43:13 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:37833) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9P-0000yK-PP; Sun, 03 Oct 2021 03:43:12 -0400 Received: by mail-ed1-x532.google.com with SMTP id ba1so51824131edb.4; Sun, 03 Oct 2021 00:43:10 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BgpdyLnyiPwHCME2fmRt2m1yxap5kM3KZz3BIBf/qMo=; b=ocxpYwH1lxNTij3aQwGMpgMXBMS+Y6N0bbdd6GJ4Ot5HM/Gjg6+NDU7TtQynLCKjCo uO8pQNjNNX0mNCBrzLpxGDrJywpUKAB3TTrjDWVz+2cSwNG8kOiOc+btkEJfCj2PKkaI MlrjWreKRRa8WT0GGWKdiApS1K+rkTbgCR10cH7yl/VvLZLFSd1yVY1MUCRuYBDGL/Bx DdRy1vxxdwVqPq/EI+8WAwblHVOSZ7+Zmx+Mp+id/t1I+OuWe/49Hhb8dcKKJs1JLRhg D/enadQPREa66FUmRBjlHeR58er4tqdjnd3081QxM92D9YL1p7zAX50iwe8M+JYms7OT ajHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=BgpdyLnyiPwHCME2fmRt2m1yxap5kM3KZz3BIBf/qMo=; b=Q9LifEGajoE73de+GqNL7spLHJy7W4zwXgT/6abzgAJwdtbsNXvB5oJIdylI83wQDo WPrJo0CWzJwrxDQgosQjnkhKEoUEoxCasIw66hEJqPFOg6Q6r1efACQClpEIn1PGL2YS nkjZ7L3W/WHZ8jiYcURpSQlQ0etVgtwOxdrZcUCwaLuPvHQcJ0wPmyqYyoMzZgRTZeul XL3zgyWoB1wAtWo170jKSi0E5YjrqJKy0crolmx2zftwZkRTzzF8cfzcoXT+QXZnmnr1 VVqGsPA38ItFezKpHMhSstu8tM5OgsOtE1krwdjg9O9Nj4gxHhhMvIvXihY9UBoNCxR8 tAyg== X-Gm-Message-State: AOAM530pCFbHx4F/YRUS+syLqDWBnRJUqI1r+rmFkGKKbvj930jiaX55 j7I0NfPQPIT1XLC5CbbXeeSv9r8vGVs= X-Google-Smtp-Source: ABdhPJxl8QQGHSGdtFiUUmQkNb8bCwfAUCeZBxt9kRoObQHKMFHR2l6Im6KuhYtlTHdW377xuFIMGA== X-Received: by 2002:a17:906:ce2c:: with SMTP id sd12mr8961198ejb.488.1633246989920; Sun, 03 Oct 2021 00:43:09 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 24/30] virtio-mem-pci: Fix memory leak when creating MEMORY_DEVICE_SIZE_CHANGE event Date: Sun, 3 Oct 2021 09:42:44 +0200 Message-Id: <20211003074250.60869-25-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Markus Armbruster , qemu-stable@nongnu.org, David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248845199100001 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand Apparently, we don't have to duplicate the string. Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size= changes") Cc: qemu-stable@nongnu.org Signed-off-by: David Hildenbrand Reviewed-by: Markus Armbruster Message-Id: <20210929162445.64060-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mem-pci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index fa5395cd88..7e384b7397 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -88,13 +88,8 @@ static void virtio_mem_pci_size_change_notify(Notifier *= notifier, void *data) size_change_notifier); DeviceState *dev =3D DEVICE(pci_mem); const uint64_t * const size_p =3D data; - const char *id =3D NULL; =20 - if (dev->id) { - id =3D g_strdup(dev->id); - } - - qapi_event_send_memory_device_size_change(!!id, id, *size_p); + qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p); } =20 static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16332478845171015.8313883945323; Sun, 3 Oct 2021 00:58:04 -0700 (PDT) Received: from localhost ([::1]:60108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwNn-0003jb-A5 for importer@patchew.org; Sun, 03 Oct 2021 03:58:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36946) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9R-00043q-Lm for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:13 -0400 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:37837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9Q-0000yz-0H for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:13 -0400 Received: by mail-ed1-x536.google.com with SMTP id ba1so51824217edb.4 for ; Sun, 03 Oct 2021 00:43:11 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m3Y5hCRoZxoZcQML796y/BIVxhl18IJOQWKwSNYcpos=; b=d5a+djjuAeQwkYT9I820dvbEEDKiKWo8bkz9cyO++9WqRMQomfa+CbPR/ILB9Lihbe a339urxaG6o/lfbyjkgJYLUUOwV3UDjbq5WpS+ua/bytPwjqbHBipFANGeAAY8XmO9UW dHWeQ5aArOOgO4+YRf74eKXCZsu1kZgEChWssDBkJ7/OWoGpVNe4UuDCzjaPO/3jqRtu UjR91hsSLtuFFietULdM7SadRZDaENQO9/LkB1PQxeaf0HnI7ZVlc+jNlcAhF0ADc7hC QXpNW+RzQ/shXvb+/LfWZUmj3CF/vlMCpc/csqNEtecj1bIVU+V1W4l1S7oEKVUq1/Wd IJcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=m3Y5hCRoZxoZcQML796y/BIVxhl18IJOQWKwSNYcpos=; b=TPMkEeM0QWoUNNfFPmc99jYYNYn+KtzTtjd4emVpxceW99/z9UmCbIaHR25i6lL+Y3 zk7rJAHX/MwojWF44dDE6cwB8fRqD+CGTgKW0oj5nJAVRMAR+vjFv6Ilili5WKJTqwWS iFr6en+6/p/2YDCAJNRBEvoidcLl9nQsX04AjLhLsb8511qWliewRg8Ql66mnpZBSCGc X4nfOyNw401mxnulmdijzkOIUJ5tAABUUsQk+NqaAfMLvKh6yL097Nz6d4N2QFVka3lO Tneh7+lt+tMOWiIrBr8kHz15ZwLeq4NAXWLGUcec9VPty6S6jsNL91VKXRpfxdwANY5j CoTg== X-Gm-Message-State: AOAM533zIKmm8wzJG2DWonHFNSb97IhOIUdXZd5AbLq7u63ujoGePNvD 7bR230Q0K8+nmM0eM6YPKUwWF9ixVhE= X-Google-Smtp-Source: ABdhPJzkh3CkRinMoN5Sn9bKTDGRX036kMK2ewSpuopjEO3n9nK5dVnN4/bIis2MUkZv9bFWyKD8Tw== X-Received: by 2002:a17:906:c015:: with SMTP id e21mr8945822ejz.113.1633246990622; Sun, 03 Oct 2021 00:43:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 25/30] qapi: Include qom-path in MEMORY_DEVICE_SIZE_CHANGE qapi events Date: Sun, 3 Oct 2021 09:42:45 +0200 Message-Id: <20211003074250.60869-26-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::536; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Markus Armbruster , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633247886492100001 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand As we might not always have a device id, it is impossible to always match MEMORY_DEVICE_SIZE_CHANGE events to an actual device. Let's include the qom-path in the event, which allows for reliable mapping of events to devices. Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size= changes") Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: David Hildenbrand Message-Id: <20210929162445.64060-3-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/virtio/virtio-mem-pci.c | 5 ++++- qapi/machine.json | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-mem-pci.c b/hw/virtio/virtio-mem-pci.c index 7e384b7397..be2383b0c5 100644 --- a/hw/virtio/virtio-mem-pci.c +++ b/hw/virtio/virtio-mem-pci.c @@ -87,9 +87,12 @@ static void virtio_mem_pci_size_change_notify(Notifier *= notifier, void *data) VirtIOMEMPCI *pci_mem =3D container_of(notifier, VirtIOMEMPCI, size_change_notifier); DeviceState *dev =3D DEVICE(pci_mem); + char *qom_path =3D object_get_canonical_path(OBJECT(dev)); const uint64_t * const size_p =3D data; =20 - qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p); + qapi_event_send_memory_device_size_change(!!dev->id, dev->id, *size_p, + qom_path); + g_free(qom_path); } =20 static void virtio_mem_pci_class_init(ObjectClass *klass, void *data) diff --git a/qapi/machine.json b/qapi/machine.json index 0e91a57a76..5db54df298 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1336,8 +1336,11 @@ # action). # # @id: device's ID +# # @size: the new size of memory that the device provides # +# @qom-path: path to the device object in the QOM tree (since 6.2) +# # Note: this event is rate-limited. # # Since: 5.1 @@ -1350,7 +1353,7 @@ # ## { 'event': 'MEMORY_DEVICE_SIZE_CHANGE', - 'data': { '*id': 'str', 'size': 'size' } } + 'data': { '*id': 'str', 'size': 'size', 'qom-path' : 'str'} } =20 =20 ## --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248181241869.8710560519297; Sun, 3 Oct 2021 01:03:01 -0700 (PDT) Received: from localhost ([::1]:43784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwSa-0003MI-59 for importer@patchew.org; Sun, 03 Oct 2021 04:03:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9S-00046N-7j for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:14 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:44567) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9Q-00010B-L9 for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:13 -0400 Received: by mail-ed1-x532.google.com with SMTP id v18so50892741edc.11 for ; Sun, 03 Oct 2021 00:43:12 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=svEcy2fQeXi6q4rkfuuA5NEXM1FDvAAdImtJmYURyR8=; b=ihIyc8o4PAX2E4Wv3Alah3VQt/bXnrSlA9jO7yo3ayhfNFN4gmxURiWIgzUahjILbX ytVjP03xyKCFQ/dwTsEvxKdVcgLg/NlDFrRrYYHdXa1RGthizCoJ2yqrrrlCg4mgl7Q5 gnhpmuTbtcS0SHo0ctLDy8c/Ff2oXyxQ1rShy3wGcq6EUsMaRw/Y1yW6+8YJUNd/V6TZ gcUouuWDC4gTWIYQhKZEsxRuRaM+EVJR3zOmekVGieJWVjl56BqSRsSrOb+nSAlJ4OZh xDIodtQ61Q2ujNJvu32IrdS+LUvUwF4RIVh75OChYhKikZYYkd3vPgRKhdq4qT2M+8t3 LCLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=svEcy2fQeXi6q4rkfuuA5NEXM1FDvAAdImtJmYURyR8=; b=N3GZr/B7ObLrhclJOHYcVlSgbMYW2l+H4DNUXw0DeKShyOeM6XG8YW61loj44IeOEi kHrl+rVng7TVyWHb+T39niCKLj0XcfBEhD7mmL1+FOvZmvuR7huip/nJ1HLFsZHqmaxY 1V9p06JPG3rGHMjQwizWyEecZ6bxqm30A9xhCcNIU6q82JMEKFoYTlcy8MGeCWyU6IsR DlnbRbBd9PWSkerEkwM1pfwKTjtIVrdPpNwapNxykosvV/8GMuTIO8/QSGj6BeqKjxcb SduyB0lgyiCrcIivA9oAyAL3A98iag9Uk5ed4b0abaY5yVsQATGB8IgVl6ArrVz7Bkay 81bw== X-Gm-Message-State: AOAM531dG7lYZiEwjluGRqnqQd0zgNQbW2LMCjHIBb5nhJW5JT87Bj5M Zw0dlSQimPUUommYj7jo9dvHa+qqylo= X-Google-Smtp-Source: ABdhPJwrRZFreOA799SzNtq23mDfDoB1C7IYFL7PfalSUdfOknUyTdQDfdN2ylbkP19vEP/deTaHFw== X-Received: by 2002:a17:906:848b:: with SMTP id m11mr9126096ejx.270.1633246991351; Sun, 03 Oct 2021 00:43:11 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 26/30] monitor: Rate-limit MEMORY_DEVICE_SIZE_CHANGE qapi events per device Date: Sun, 3 Oct 2021 09:42:46 +0200 Message-Id: <20211003074250.60869-27-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> MIME-Version: 1.0 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=2a00:1450:4864:20::532; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Markus Armbruster , David Hildenbrand Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248181890100001 Content-Type: text/plain; charset="utf-8" From: David Hildenbrand We want to rate-limit MEMORY_DEVICE_SIZE_CHANGE events per device, otherwise we can lose some events for devices. We can now use the qom-path to reliably map an event to a device and make rate-limiting device-aware. This was noticed by starting a VM with two virtio-mem devices that each have a requested size > 0. The Linux guest will initialize both devices in parallel, resulting in losing MEMORY_DEVICE_SIZE_CHANGE events for one of the devices. Fixes: 722a3c783ef4 ("virtio-pci: Send qapi events when the virtio-mem size= changes") Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: David Hildenbrand Message-Id: <20210929162445.64060-4-david@redhat.com> Signed-off-by: Paolo Bonzini --- monitor/monitor.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/monitor/monitor.c b/monitor/monitor.c index 46a171bca6..21c7a68758 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -474,6 +474,10 @@ static unsigned int qapi_event_throttle_hash(const voi= d *key) hash +=3D g_str_hash(qdict_get_str(evstate->data, "node-name")); } =20 + if (evstate->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + hash +=3D g_str_hash(qdict_get_str(evstate->data, "qom-path")); + } + return hash; } =20 @@ -496,6 +500,11 @@ static gboolean qapi_event_throttle_equal(const void *= a, const void *b) qdict_get_str(evb->data, "node-name")); } =20 + if (eva->event =3D=3D QAPI_EVENT_MEMORY_DEVICE_SIZE_CHANGE) { + return !strcmp(qdict_get_str(eva->data, "qom-path"), + qdict_get_str(evb->data, "qom-path")); + } + return TRUE; } =20 --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248483024397.7274243728284; Sun, 3 Oct 2021 01:08:03 -0700 (PDT) Received: from localhost ([::1]:52308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwXS-0000uE-0d for importer@patchew.org; Sun, 03 Oct 2021 04:08:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9T-0004Ap-BV for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:15 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]:33747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9R-00011C-NX for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:15 -0400 Received: by mail-ed1-x535.google.com with SMTP id p13so23617987edw.0 for ; Sun, 03 Oct 2021 00:43:13 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QwdzjPR8WZDeMpfLkQQqWDyohKpDUiK9I55YvVVcH58=; b=PG3PcsJIpAQzSYqyIQWOkkS9TZTeeWdWexrR19gky2VaGekQMzGJzYakgGiUoio15q dhtsa7gTDOVWbsI0veNGr5/etfzJh2xm4uCrx8QkCc8kcr6kHurUFtHLW5QmDgC29+a8 jvATa6kZrK3cArU6IGf/z5JDElC93tT0G7ur5JwGR32iW6cCq6l26Uhp01VxJpZgPVBZ 2qFzunYdNU+P4w+4wjgjNmcJI4C8eCcz5WIrwTH6ehB19zyX5nYl3b0X69Dk+9AJdyn2 /TXhLYSiANYwb28wXzcWSGwDq3M0ULlHjio0WSHXLFP+jryKzbTHpJ43VAswNRFEkxZa cFZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=QwdzjPR8WZDeMpfLkQQqWDyohKpDUiK9I55YvVVcH58=; b=FfEcsbPRSkwY5RtoHMWxvRG8ZheBhWhMqWgdfZzpx2rzwJcLU//EhHYAm7PDwccslo yxJWwhUghoaoubAJ2g65+St7pdXLD6yq3SAckWgTXVZjsDrnqYX52L9GiXTgtrKp8GZc 7RNw2SCVbTvDkJ0M1W2TnOlsJcQJUJFAsmzAUsEjCPiDnkc/9ab9Dp2Axi+p3oXMKbAP RLgYooow+GgbIFFRz8h4FS9EVc/E++INDqohhOhNR8WIBMAktPs/cN+GsLG65N8TxfXR 4/uuOLbYjYeRtnPPKPIm5VUaEZMesNDqKRhmNSe53j81o8PS0Y7t1+1bkDeU96snhQ7f Opqg== X-Gm-Message-State: AOAM532d3O3mz3FTWx/raaePWNNHrBfaHLbTHdYFmUPQWk9DyWjOLYox IrZcAFn1E666ETOGH6tifw+EbHbiFLs= X-Google-Smtp-Source: ABdhPJz4s09VyCQELcMS4avZIhnsx8yjTPr/XpZ5oFO0QUg0zXo4zMelvoO2C1nu2POxFEPKxIlTKw== X-Received: by 2002:a17:906:29d0:: with SMTP id y16mr9585658eje.477.1633246992426; Sun, 03 Oct 2021 00:43:12 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 27/30] tpm: mark correct memory region range dirty when clearing RAM Date: Sun, 3 Oct 2021 09:42:47 +0200 Message-Id: <20211003074250.60869-28-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::535; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Stefan Berger , Eduardo Habkost , "Michael S. Tsirkin" , David Hildenbrand , "Dr . David Alan Gilbert" , Peter Xu , Alex Williamson , Claudio Fontana , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248484575100001 From: David Hildenbrand We might not start at the beginning of the memory region. Let's calculate the offset into the memory region via the difference in the host addresses. Acked-by: Stefan Berger Fixes: ffab1be70692 ("tpm: clear RAM when "memory overwrite" requested") Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Alex Williamson Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Claudio Fontana Cc: Thomas Huth Cc: "Alex Benn=C3=A9e" Cc: Peter Xu Cc: Laurent Vivier Cc: Stefan Berger Signed-off-by: David Hildenbrand Reviewed-by: Peter Xu Message-Id: <20210727082545.17934-2-david@redhat.com> Signed-off-by: Paolo Bonzini --- hw/tpm/tpm_ppi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/tpm/tpm_ppi.c b/hw/tpm/tpm_ppi.c index 362edcc5c9..274e9aa4b0 100644 --- a/hw/tpm/tpm_ppi.c +++ b/hw/tpm/tpm_ppi.c @@ -30,11 +30,14 @@ void tpm_ppi_reset(TPMPPI *tpmppi) guest_phys_blocks_init(&guest_phys_blocks); guest_phys_blocks_append(&guest_phys_blocks); QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) { + hwaddr mr_offs =3D block->host_addr - + (uint8_t *)memory_region_get_ram_ptr(block->m= r); + trace_tpm_ppi_memset(block->host_addr, block->target_end - block->target_start); memset(block->host_addr, 0, block->target_end - block->target_start); - memory_region_set_dirty(block->mr, 0, + memory_region_set_dirty(block->mr, mr_offs, block->target_end - block->target_star= t); } guest_phys_blocks_free(&guest_phys_blocks); --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248663459331.3927221174612; Sun, 3 Oct 2021 01:11:03 -0700 (PDT) Received: from localhost ([::1]:58926 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwaM-0005XO-Er for importer@patchew.org; Sun, 03 Oct 2021 04:11:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9U-0004EW-8i for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:16 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:40739) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9S-00011k-NK for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:15 -0400 Received: by mail-ed1-x529.google.com with SMTP id g8so51965798edt.7 for ; Sun, 03 Oct 2021 00:43:14 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ujUSnNBKpCXdL3RYZdQBq1D09EmZbvIdkpR1zAPinc=; b=WvxNoc2NLXgV0ihjuxNB9befRhx2GKvz0LEq9rc7R41KJ2TELoYZY+kPf2huWzG9GL G0GDCMzyqb6O4NdPzG2v0GnZo9Gukufbt6hwHcsIk/BSQTWNVSwUG9whQbTsZAsqsQDH 6sM7Zz+l/epRSou/EpJMJZjKvWiPk1XuTAmszHsnC91wuvLvZQqYikuvvhKfUiXM9MgY TANW6LJtXaaTbeUCI7DnT6Qe00XGhmGFSO626HiZU0a+tIm1mrLaxz+wugEXlwiJg4pe d6VuwxnNVtJywgJOn096vwQTHLZ/694UokoNCtKt1DBHfE1y8rOGHI+spW00Xz4g2vRJ g1sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=/ujUSnNBKpCXdL3RYZdQBq1D09EmZbvIdkpR1zAPinc=; b=xjeHOqM2rY0KrYpmfwd/XyMyemQNETEjXuhzGluFlM2JXjdsuJ7mX35Fi24SI8hE3u qNdZG6JhTL+qTlwB0DdNJvKhn+fNQsT4zBAzlYblCXu7HrLWCSc4VdJX36TpJC0wF9Yj GIoe0WcuTUMZ8JrEYBKiUvNv2dcSdYTFsuzcakAs1XnuhnN13iB8QfUSn5VgiIuxO06O C2vmm+S0u3onz+hZgv/6UqE8HgT9gZ/OnrYAgRCRV6w6kB4M/Hk+SHrlu+5LIFvjJkx3 3hAV4crR51Q4XpnFaH/jZSxkRxumQ9hMpKk9NXRiRqqMdZQY661i71mpICfopvDyg57E WZhg== X-Gm-Message-State: AOAM532JZy/WRfnFuONQ1oza5OzzZrLlRN16a+pwhYcW3WflmnJZuXrf vWNduaAWapVvzo+odPK2WLBkl0H8Jn4= X-Google-Smtp-Source: ABdhPJzsXQoNMnXgYxHUtfjUGRrol7SMqJ6bGpsQOGOVfzj/UqNz8wke6jY3xE3LplPmC/0nyMyrLA== X-Received: by 2002:a17:906:15cf:: with SMTP id l15mr9019193ejd.568.1633246993370; Sun, 03 Oct 2021 00:43:13 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 28/30] softmmu/memory_mapping: never merge ranges accross memory regions Date: Sun, 3 Oct 2021 09:42:48 +0200 Message-Id: <20211003074250.60869-29-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Eduardo Habkost , "Michael S. Tsirkin" , David Hildenbrand , "Dr . David Alan Gilbert" , Peter Xu , Alex Williamson , Claudio Fontana , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248664896100001 From: David Hildenbrand Let's make sure to not merge when different memory regions are involved. Unlikely, but theoretically possible. Acked-by: Stefan Berger Reviewed-by: Peter Xu Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Alex Williamson Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Claudio Fontana Cc: Thomas Huth Cc: "Alex Benn=C3=A9e" Cc: Peter Xu Cc: Laurent Vivier Cc: Stefan Berger Signed-off-by: David Hildenbrand Message-Id: <20210727082545.17934-3-david@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/memory_mapping.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c index e7af276546..d401ca7e31 100644 --- a/softmmu/memory_mapping.c +++ b/softmmu/memory_mapping.c @@ -229,7 +229,8 @@ static void guest_phys_blocks_region_add(MemoryListener= *listener, =20 /* we want continuity in both guest-physical and host-virtual memo= ry */ if (predecessor->target_end < target_start || - predecessor->host_addr + predecessor_size !=3D host_addr) { + predecessor->host_addr + predecessor_size !=3D host_addr || + predecessor->mr !=3D section->mr) { predecessor =3D NULL; } } --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248468539350.49761866582094; Sun, 3 Oct 2021 01:07:48 -0700 (PDT) Received: from localhost ([::1]:52168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwXD-0000nX-AH for importer@patchew.org; Sun, 03 Oct 2021 04:07:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9V-0004I0-9y for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:17 -0400 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]:46677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9T-00012Z-Lz for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:17 -0400 Received: by mail-ed1-x52a.google.com with SMTP id z20so468533edc.13 for ; Sun, 03 Oct 2021 00:43:15 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Iazzme8gW0iiwChNe0S4mE4gEWXWyIgyzE45wOse0ek=; b=QoAds/7SxGuQX7UN2AyLGGzlyeMhBTlgKf/MrYKvDYgvqV1kYY66LB+LS1DOJXUv0i 4b8CNP4U6RBv3cZ51XwESWKgqIt8FMwBQb4kJcBzpU+IZWlBkgJUuUkjJcunLIoHGjFZ 183NKv1KrIKyjcq3gi5Q8O1qx90eJpdKF1FFWdJc7+9TKXjwp3db7h+UlK8sNceCP1D0 yO3TW2g3bsQ69YZWg5AHEKSEJKnsxpBsDP21yJpnPZ0ueFK3tKmPwEaD0Njv+q/WJGI8 fodK93HLOpM0v33zlF8DsrJ/XPQ5GUmInimsxQ8Y8JSei2HBF3+WQRycJKqIL09jray9 edrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Iazzme8gW0iiwChNe0S4mE4gEWXWyIgyzE45wOse0ek=; b=njVZDVoI+4uSi4v+a+4NaMXO9adW+pD7fVGl5F72RNkZfP1b2aj1+75OMMqUxr6btj OikCnzLMDUOw1k6XAwmlNDsu9Tokx244R3QsyJpsBZyi5geIojRnmJORlSAI0dgBKORB m0tmyhBlTmRWaQyiw7zEr8jnkSaKQ/VKUHq+VpfwUj6Ny+CFgmxFTwej8oWHqN7hhOx6 LwAWrVL21XgBwI+fBVYDAxpSyQ45+zLL3cycikAAs2Z26COVUpsyTl/ul4uFAqiO2Pop Zl19Lked5ht00Id2XVkMi6Nj8Pmq4hJRyWK/HB4GrDbj+llEbUShoAuIf90OiDCkDUMv G9dQ== X-Gm-Message-State: AOAM530P8TwImMhrth3CnFsnC3tqHqxphIJqA26DCKdBtF7FTzwqmv3F ZqniGWGSQxPSL1sCDuSCcYhzWWH4uHA= X-Google-Smtp-Source: ABdhPJyxZN9AtNHAbvzajZc/7f58G0I4Xz1Kw/9gLYhsN0d6vt5OHAuMDn7evg/TMOXteRoFzmE69w== X-Received: by 2002:a17:906:39cd:: with SMTP id i13mr8665730eje.227.1633246994397; Sun, 03 Oct 2021 00:43:14 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 29/30] softmmu/memory_mapping: factor out adding physical memory ranges Date: Sun, 3 Oct 2021 09:42:49 +0200 Message-Id: <20211003074250.60869-30-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52a; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Eduardo Habkost , "Michael S. Tsirkin" , David Hildenbrand , "Dr . David Alan Gilbert" , Peter Xu , Alex Williamson , Claudio Fontana , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248469944100001 From: David Hildenbrand Let's factor out adding a MemoryRegionSection to the list, to be reused in RamDiscardManager context next. Reviewed-by: Stefan Berger Reviewed-by: Peter Xu Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Alex Williamson Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Claudio Fontana Cc: Thomas Huth Cc: "Alex Benn=C3=A9e" Cc: Peter Xu Cc: Laurent Vivier Cc: Stefan Berger Signed-off-by: David Hildenbrand Message-Id: <20210727082545.17934-4-david@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/memory_mapping.c | 41 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c index d401ca7e31..a2af02c41c 100644 --- a/softmmu/memory_mapping.c +++ b/softmmu/memory_mapping.c @@ -193,29 +193,14 @@ typedef struct GuestPhysListener { MemoryListener listener; } GuestPhysListener; =20 -static void guest_phys_blocks_region_add(MemoryListener *listener, +static void guest_phys_block_add_section(GuestPhysListener *g, MemoryRegionSection *section) { - GuestPhysListener *g; - uint64_t section_size; - hwaddr target_start, target_end; - uint8_t *host_addr; - GuestPhysBlock *predecessor; - - /* we only care about RAM */ - if (!memory_region_is_ram(section->mr) || - memory_region_is_ram_device(section->mr) || - memory_region_is_nonvolatile(section->mr)) { - return; - } - - g =3D container_of(listener, GuestPhysListener, listener); - section_size =3D int128_get64(section->size); - target_start =3D section->offset_within_address_space; - target_end =3D target_start + section_size; - host_addr =3D memory_region_get_ram_ptr(section->mr) + - section->offset_within_region; - predecessor =3D NULL; + const hwaddr target_start =3D section->offset_within_address_space; + const hwaddr target_end =3D target_start + int128_get64(section->size); + uint8_t *host_addr =3D memory_region_get_ram_ptr(section->mr) + + section->offset_within_region; + GuestPhysBlock *predecessor =3D NULL; =20 /* find continuity in guest physical address space */ if (!QTAILQ_EMPTY(&g->list->head)) { @@ -261,6 +246,20 @@ static void guest_phys_blocks_region_add(MemoryListene= r *listener, #endif } =20 +static void guest_phys_blocks_region_add(MemoryListener *listener, + MemoryRegionSection *section) +{ + GuestPhysListener *g =3D container_of(listener, GuestPhysListener, lis= tener); + + /* we only care about RAM */ + if (!memory_region_is_ram(section->mr) || + memory_region_is_ram_device(section->mr) || + memory_region_is_nonvolatile(section->mr)) { + return; + } + guest_phys_block_add_section(g, section); +} + void guest_phys_blocks_append(GuestPhysBlockList *list) { GuestPhysListener g =3D { 0 }; --=20 2.31.1 From nobody Mon Feb 9 05:55:44 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1633248077753980.7343845494332; Sun, 3 Oct 2021 01:01:17 -0700 (PDT) Received: from localhost ([::1]:40388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWwQt-0000xp-GJ for importer@patchew.org; Sun, 03 Oct 2021 04:01:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWw9W-0004NY-Lw for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:20 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:34447) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWw9V-00014C-0g for qemu-devel@nongnu.org; Sun, 03 Oct 2021 03:43:18 -0400 Received: by mail-ed1-x52d.google.com with SMTP id g7so50880602edv.1 for ; Sun, 03 Oct 2021 00:43:16 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id n6sm5560856eds.10.2021.10.03.00.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Oct 2021 00:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZPw8jJvn3jd8qiXtPJ9VzDsq2VSW8qdZuNX8z06CReY=; b=dvnUx29M5XeTUz/iWuYZcCZqpi7BZw3lScfDPCp3e9GA5eJ+izsGSDXoZuiPOpVmbb e9V7ZAsTQ2Dox8mgjKoApfkeZg589uyeHOfoDJUz+0eSlz9os8wdttk4aPdt2C3ZExuI 0Z+3RBTdnlLBpLL+pK3S6AwfOV/tBKj17wVC7beB/OCQFJILDASsba5tpA1b00pp10me msb0BwjR7ed2W2/BekV4YBx0xgT6W0OlvA60M39LXTxntaRSd6HrXTlwi4wHpsTX1s7k lje1b33+3LFuXRO7afwFyoOk1/q5yTpd3zL7CuIERp9n5iUj2nvjK67G0qnMwPMLdcnL WPKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ZPw8jJvn3jd8qiXtPJ9VzDsq2VSW8qdZuNX8z06CReY=; b=Y3kYgMq2S+VRKSYSGtI3uTyTGQ7Qo40ENR3snlSeDcsS8cwU23PbAFn97/J82pQM31 Q1AypfCZuY2xEgIHbIOOnw8QN45rIpTfR7UCKY2SZaCXHFrIXdfb+p4EMzzb/rLX35le Hxbu0VV2R33hDTlDbG8VtchrRZ7cxPef5IfZt7KnXunvLqTYIzSmp3ut369ed9hiTPka uAlIzMO7FTu/UNWR3y53s8AlqB/NZn4NyApg7QiDZ65Gb9m8NoCMjvr0vPucHSbDMRnt pShVneOxzRLS/MBOMKTRX6k7vLj/c/TXYsuSK5OfQn90uTm2RsePy6EDHy+DA56xX6Jc ZfWQ== X-Gm-Message-State: AOAM5315IDKkMi6cOAR3on//aJgWwqwczEQTL8+9yInX4A9kDx5/aT1N PozFZvVIiwVf9qq1nOFnKP/gbl/wAXw= X-Google-Smtp-Source: ABdhPJwTlTF7YvDrCzdd21kx+4inZhhDiEuBC5ctmewBovERbi3KV4WXtOU9rXsFuS9cCmJU6FT/MQ== X-Received: by 2002:a17:906:81da:: with SMTP id e26mr8984699ejx.296.1633246995643; Sun, 03 Oct 2021 00:43:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 30/30] softmmu/memory_mapping: optimize for RamDiscardManager sections Date: Sun, 3 Oct 2021 09:42:50 +0200 Message-Id: <20211003074250.60869-31-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211003074250.60869-1-pbonzini@redhat.com> References: <20211003074250.60869-1-pbonzini@redhat.com> 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=2a00:1450:4864:20::52d; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: Laurent Vivier , Thomas Huth , Eduardo Habkost , "Michael S. Tsirkin" , David Hildenbrand , "Dr . David Alan Gilbert" , Peter Xu , Alex Williamson , Claudio Fontana , Igor Mammedov , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Stefan Berger Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1633248079812100001 From: David Hildenbrand virtio-mem logically plugs/unplugs memory within a sparse memory region and notifies via the RamDiscardManager interface when parts become plugged (populated) or unplugged (discarded). Currently, we end up (via the two users) 1) zeroing all logically unplugged/discarded memory during TPM resets. 2) reading all logically unplugged/discarded memory when dumping, to figure out the content is zero. 1) is always bad, because we assume unplugged memory stays discarded (and is already implicitly zero). 2) isn't that bad with anonymous memory, we end up reading the zero page (slow and unnecessary, though). However, once we use some file-backed memory (future use case), even reading will populate memory. Let's cut out all parts marked as not-populated (discarded) via the RamDiscardManager. As virtio-mem is the single user, this now means that logically unplugged memory ranges will no longer be included in the dump, which results in smaller dump files and faster dumping. virtio-mem has a minimum granularity of 1 MiB (and the default is usually 2 MiB). Theoretically, we can see quite some fragmentation, in practice we won't have it completely fragmented in 1 MiB pieces. Still, we might end up with many physical ranges. Both, the ELF format and kdump seem to be ready to support many individual ranges (e.g., for ELF it seems to be UINT32_MAX, kdump has a linear bitmap). Reviewed-by: Peter Xu Cc: Marc-Andr=C3=A9 Lureau Cc: Paolo Bonzini Cc: "Michael S. Tsirkin" Cc: Eduardo Habkost Cc: Alex Williamson Cc: Dr. David Alan Gilbert Cc: Igor Mammedov Cc: Claudio Fontana Cc: Thomas Huth Cc: "Alex Benn=C3=A9e" Cc: Peter Xu Cc: Laurent Vivier Cc: Stefan Berger Signed-off-by: David Hildenbrand Message-Id: <20210727082545.17934-5-david@redhat.com> Signed-off-by: Paolo Bonzini --- softmmu/memory_mapping.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c index a2af02c41c..a62eaa49cc 100644 --- a/softmmu/memory_mapping.c +++ b/softmmu/memory_mapping.c @@ -246,6 +246,15 @@ static void guest_phys_block_add_section(GuestPhysList= ener *g, #endif } =20 +static int guest_phys_ram_populate_cb(MemoryRegionSection *section, + void *opaque) +{ + GuestPhysListener *g =3D opaque; + + guest_phys_block_add_section(g, section); + return 0; +} + static void guest_phys_blocks_region_add(MemoryListener *listener, MemoryRegionSection *section) { @@ -257,6 +266,17 @@ static void guest_phys_blocks_region_add(MemoryListene= r *listener, memory_region_is_nonvolatile(section->mr)) { return; } + + /* for special sparse regions, only add populated parts */ + if (memory_region_has_ram_discard_manager(section->mr)) { + RamDiscardManager *rdm; + + rdm =3D memory_region_get_ram_discard_manager(section->mr); + ram_discard_manager_replay_populated(rdm, section, + guest_phys_ram_populate_cb, g= ); + return; + } + guest_phys_block_add_section(g, section); } =20 --=20 2.31.1