From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597854; cv=none; d=zohomail.com; s=zohoarc; b=mOj19ImSYCkuO6Scgkce00yr1phySofSgJhkHH5q7hGsZf+TeHQH/pOvfBt8nC5uO/YYdHkbpW9A21tgwNgpyQ56+wgOvsl++CrWJjJSFf9fO0nX+Vh0i1BA/frPszC4Rjw+f6ELKkKRzdCj6TNOKGnKLQXMsLhcR4OBdlyentM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597854; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=HWkjsNVAKOG2SJy7sNxaI+YTscQLFV1hczt5Akb2SYYJ/vWtN97apw+8c/vYUldm8A6I0ZMIh9DECeO7TeT4nmxQ/LM8hxF6MtqUeyQuhju5f/lqsL1Py+QnjQPJf/cLTcJeZxY/3lhvEvTmgQhtD5L3W/rUX7/n3NYLaBAhhVo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597854883632.0752248627973; Fri, 1 Sep 2023 12:50:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6N-0007ml-F2; Fri, 01 Sep 2023 15:46:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6L-0007lz-RO for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:41 -0400 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6I-0002v1-Mu for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:41 -0400 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5735282d713so1390394eaf.2 for ; Fri, 01 Sep 2023 12:46:38 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597597; x=1694202397; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=EtVE++5RhSmQkuZc1oZ8DYuxoUHEGcnTTwLPe8qIx5mjNYtNTaRzBfwlMFoNU0kC0g Jy5vUdoPGCRjDftQqcQEGW/du7eeZXBgguLW5LGa6k84nuUt2bl8NSisIifOd30aAqHC 1gSxFQThBnzGA3Eb28d7f2lO1TL7DT9TnnvDMEYKWJ8wXd8+m4d4EMomYxXu+/DKNJTp +EDfVU2/24A9dH0av8bO/6a0io8kssr1upV21QoEhzOTEjwuoAE9w9GwCra8vyQpP2uK BUC1LT7HLYYPQV0UZbxdWSt4noke535hd3dM/mAO+dUHSwFilMjkJ6zqMdenf4xWmMQN EQtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597597; x=1694202397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0N0oTIyVCTE0+WINtqk5L95k/7qBHpAfwshUNyTE0mY=; b=cesP1KHoHxfadlVfPuGdBYcaxbAWvxnwPfTIYUE2R1nxEQrBna6/K9zOJSQc/GvyfO Kj0mGyYYEOR4ofM1Rr+hPCFphhQzQlOf11+ClBsV5LhHx7+rn0ythsAxq+DAAfUDe8ZR myuj/JLBT2CuwN/VoGOPW+RhraKNqewwxk5U4M/7Xm7Fbd4jj6j+C6AEdCRr/m05ZxYW BMjKhtA+LreSF6cgHwPkcv04tznSEExoVDx72KHLkEpvGeAeYp79+JnEjT9B1gnoEVKY /A0Xxjzwn8/zSTE+s2/DZsyzLCWJ2i6Zi6SssbmtQbaxl7auNJlXYhGCP+qCB8p5a5Oh b1UQ== X-Gm-Message-State: AOJu0YwkIiaDHoZO9bWj8TRcQUuglERgiX9fx2iWq49LHnw3m9Wdx9NS bsTkY/+MAODRqi9ObR59FKaJoN+umSNoPOU8DQc= X-Google-Smtp-Source: AGHT+IEJO1KAxLV8Y85h8Iosdc+PyEDc52U2feQYFUYjXN9ODDhPT0Ln/BrzlwMKYnHcRT6lvjH2Zw== X-Received: by 2002:a05:6820:284:b0:573:3fe0:cdd6 with SMTP id q4-20020a056820028400b005733fe0cdd6mr3978125ood.6.1693597596893; Fri, 01 Sep 2023 12:46:36 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 01/20] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[] Date: Fri, 1 Sep 2023 16:46:07 -0300 Message-ID: <20230901194627.1214811-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597855666100009 Content-Type: text/plain; charset="utf-8" We'll add a new CPU type that will enable a considerable amount of extensions. To make it easier for us we'll do a few cleanups in our existing riscv_cpu_extensions[] array. Start by splitting all CPU non-boolean options from it. Create a new riscv_cpu_options[] array for them. Add all these properties in riscv_cpu_add_user_properties() as it is already being done today. 'mmu' and 'pmp' aren't really extensions in the usual way we think about RISC-V extensions. These are closer to CPU features/options, so move both to riscv_cpu_options[] too. In the near future we'll need to match all extensions with all entries in isa_edata_arr[], and so it happens that both 'mmu' and 'pmp' do not have a riscv,isa string (thus, no priv spec version restriction). This further emphasizes the point that these are more a CPU option than an extension. No functional changes made. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index f227c7664e..fdbd8eb0b8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1810,7 +1810,6 @@ static void riscv_cpu_add_misa_properties(Object *cpu= _obj) =20 static Property riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), @@ -1823,15 +1822,8 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), - DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), =20 - DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), - DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), - DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), - DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), @@ -1862,9 +1854,7 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), =20 DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), =20 DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), =20 @@ -1918,6 +1908,21 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static Property riscv_cpu_options[] =3D { + DEFINE_PROP_UINT8("pmu-num", RISCVCPU, cfg.pmu_num, 16), + + DEFINE_PROP_BOOL("mmu", RISCVCPU, cfg.mmu, true), + DEFINE_PROP_BOOL("pmp", RISCVCPU, cfg.pmp, true), + + DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), + DEFINE_PROP_STRING("vext_spec", RISCVCPU, cfg.vext_spec), + + DEFINE_PROP_UINT16("vlen", RISCVCPU, cfg.vlen, 128), + DEFINE_PROP_UINT16("elen", RISCVCPU, cfg.elen, 64), + + DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), + DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), +}; =20 #ifndef CONFIG_USER_ONLY static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, @@ -1986,6 +1991,14 @@ static void riscv_cpu_add_user_properties(Object *ob= j) #endif qdev_property_add_static(dev, prop); } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597871; cv=none; d=zohomail.com; s=zohoarc; b=KkI+Ca85BEgLpiMKwn3TYnxMqrt/gGbJAA9MTIUigUi7cGZGIG6dArOLkEv+wbFkCnZdWN6sqnUuE5kxqM1Hb2A1yn1MlgxJWM5bZlQQnf07eYb3oLNz3e2w8drem834l8nfdVyQAJ/Zmq0IQvsLDP4CqTaVplWQZDvcldhKYkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597871; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=RQINmy69D9u8MALTeZvEO6TuapIuFjRqDNTXojZAPLEiKAf6dhaLjx8uBeMc6oRs82s6egc+FyHI5OIpc61ZcTEgWgLrq0TXhQ3tr/3E+jHLuDmHT165gwORKBtoUPJ2DfLG3F+EDd0VhnJKVmSFs48oQgUutMTTf0sr9fuBGTo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597871733442.2028151072378; Fri, 1 Sep 2023 12:51:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6P-0007nA-Gi; Fri, 01 Sep 2023 15:46:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6N-0007mu-L3 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:43 -0400 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6L-0002vd-GV for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:43 -0400 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-56d8bc0d909so1428031eaf.3 for ; Fri, 01 Sep 2023 12:46:41 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597600; x=1694202400; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=TLs128JIepnH2tICxi/SNomxHGHfJf2zUwQLT1HrEODgnrsjWH6We0LP2rlz+Yn6EZ JiSwD+OTjctx1hyHx6sbsGdgO3YkAWCee/lJHzvPwFGYAWoDwPHFjFaZWwpvRF0xfrB3 jnTzyYuHc8zSgdwI1iLq2nLBJXROBtbickt7Q2WHmKBg33GpUA6VgsDMRMfBMgXhchu6 Fz9BrrxL9k05AfqcvKic6kL3FOHiLNuS8NKDAPbZck9VxQbbCTfuy7/v+LamsRv7Ekx8 W1ydvLkOmhsPlDKjfBfpP09pYytTsKmrB033WHPGlNLJSGcsUFsUVIpc/H8auBl0P43h FVug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597600; x=1694202400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wQilM6mPMPBt/et0RgnK1omGUy9pg15ijboQ1qTt70s=; b=kq1/RF0po96N7MWDHuKylWE1S6z+gpPmEpMhHzdbGVC3m5iZ17OE24Z8Q+iW/Oa9OZ SgzcFIyhpUzvJuraWE1AejVGB97O0CuHWNQl/Vt4PVC7oDcMwZ/Wfaqg8OjhbxPcHNsj wSukR8/yNT6VqYyeJaJhXI0ve9ljUy+GK4t9i0vMUPBWZBCusr9H/kDIXJRJZ3GebKGu BBSpu/IIDc/CepELX3o+AQqMHE2SUYawV/UUte4goGcLqiHE3SiHrsL0BxLUCWULPSoY ThCk0lT3isoSnCoX5rEotsd674HWHbdoBKbm3qNk4UOYk6o4zXEXEd0QRF6DsfEA2hbr KSfw== X-Gm-Message-State: AOJu0YwoToTFbXSX7kxujZT66z7gcMFZ+JqzYRe0gAIEu2Y1PkU0LBfN qXuMdf2ysjEhoBBg2Fx/Ovu3+chPIx/UslZdrjg= X-Google-Smtp-Source: AGHT+IGwtjlRaYqxWuHsAttj4A84skLVst04AHEaIsW/ineDakiWgSxp/hf6PGwSwlPrqefS3mus8g== X-Received: by 2002:a4a:92d5:0:b0:571:281a:ef7 with SMTP id j21-20020a4a92d5000000b00571281a0ef7mr3450585ooh.7.1693597599961; Fri, 01 Sep 2023 12:46:39 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 02/20] target/riscv/cpu.c: skip 'bool' check when filtering KVM props Date: Fri, 1 Sep 2023 16:46:08 -0300 Message-ID: <20230901194627.1214811-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c35; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc35.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597873464100001 Content-Type: text/plain; charset="utf-8" After the introduction of riscv_cpu_options[] all properties in riscv_cpu_extensions[] are booleans. This check is now obsolete. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index fdbd8eb0b8..db640e7460 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1976,17 +1976,11 @@ static void riscv_cpu_add_user_properties(Object *o= bj) * Set the default to disabled for every extension * unknown to KVM and error out if the user attempts * to enable any of them. - * - * We're giving a pass for non-bool properties since they're - * not related to the availability of extensions and can be - * safely ignored as is. */ - if (prop->info =3D=3D &qdev_prop_bool) { - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } + object_property_add(obj, prop->name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop->name); + continue; } #endif qdev_property_add_static(dev, prop); --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597688; cv=none; d=zohomail.com; s=zohoarc; b=TvE7DDXmxoJoIH0nUTJJR3Gyt/QVViGJTpxFwUzGNVyE2SOOV4E3PQVGEzcg8DY/AvV3hLd85vj7kyvNdKfzBxB5EoE59zZh+3ccnM6GUCPK6+BZbexmVpa9IjH/e2N33mKI5qGYz74ThaKO9SuatovR3kGEzkfugE+n8eM+zX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597688; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tLI6XRWquA7GljCqRWTp6ZnGkttnS3Le6iqh21z4yTk=; b=M6qUTWesJXTBLYW/DmNX7xSG6hqjeJCVZQTHSSE40A3GfXwM++NMKceWdCKgTLQmc0NfBq7GZSxzQQT9ruO/n9JtAW9HKAYL1LSeB1XX0GZivZj3JGrzX04MESU4HI45jCYp6HB81Tm4MLZ3f/HHdvshSKoFbXpBdlXWgqm4T18= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597688293365.1541781837991; Fri, 1 Sep 2023 12:48:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6R-0007oS-V7; Fri, 01 Sep 2023 15:46:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6Q-0007nf-I0 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:46 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6O-0002wc-Bf for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:46 -0400 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-57124ee486dso1386036eaf.3 for ; Fri, 01 Sep 2023 12:46:43 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597603; x=1694202403; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tLI6XRWquA7GljCqRWTp6ZnGkttnS3Le6iqh21z4yTk=; b=KmEVoh9OtnMcSNJkosIvOBztHh1wdveFl90z5RK0mCz5cSsJ+XbF6z4NBjPt6LFOaN Hj0qG8SZs818mCAzBU9rtFzhVmwIpXceAD19uzyav2rFF8y7UDxQ1VWo2CNN0lL3jd+8 WPrZsIobSl04CtknK/jnT38H7t8mDfl93AfnJT7KvbsB2thkb6wElOTZzOz60fOw+IQr SYvZDJBhAYrOzXGShiaitp5hJ7jF6sj0KksjVcHPeP6wX2uDKNcoryhz3DHSW1XAWGMX dFQafhWHn5liGvfwyB9Z5NCO8prRZNbwOiwZ7HwTzPh8//LStwR7GVfBZLPYbkuUML8u N42Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597603; x=1694202403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tLI6XRWquA7GljCqRWTp6ZnGkttnS3Le6iqh21z4yTk=; b=jcusbs36JPaT6I+bWJT/u42bqMykLu3GgXVLzwftcYK3jWYoWqSV/oyqmtbB0Flfg4 6/yRF1gl/XOoRGDnISr+Pg/uD/Sx4DHp7u9A10Xsu4rk0wI7JpceHNq9EQEgItQoQ32v AEP1Qc84bjrGdRdtbt2oad+cYViw5cEIO0Yo5nUlg1JKZIKDvqE9DKBCOg5bEfmyRlEA KvsHMzw47US03tXDgm1qMFlvHujhaFvXTMDv/RCBBgKYQthCOOkZr5jOAPme5rGNHxJC ZzIpGHNicujPFIvp0pm6vfcDEQSp2Ke5iCAjzOam2kvLLZXDx1QFdAkb4x7c/4OmKbVs ud6A== X-Gm-Message-State: AOJu0Yz0x5JAIAnimwxvp1s9nPH4MwoXguZqupkIbEGfcdQ1uvd6HdWS xLSOvnJZljKHVzhrQW+flBWUmZfT5nldzVycHtA= X-Google-Smtp-Source: AGHT+IGb4I9titZFlufdJOylTkQKEIiyrMj45hZyH+ZAGqYtkx+Ub/cUCJKQdwQNz5KJt/ssjuG+Iw== X-Received: by 2002:a4a:2a0f:0:b0:573:55f4:5175 with SMTP id k15-20020a4a2a0f000000b0057355f45175mr3805552oof.0.1693597603002; Fri, 01 Sep 2023 12:46:43 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 03/20] target/riscv/cpu.c: split kvm prop handling to its own helper Date: Fri, 1 Sep 2023 16:46:09 -0300 Message-ID: <20230901194627.1214811-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c32; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597688837100001 Content-Type: text/plain; charset="utf-8" Future patches will split the existing Property arrays even further, and the existing code in riscv_cpu_add_user_properties() will start to scale bad with it because it's dealing with KVM constraints mixed in with TCG constraints. We're going to pay a high price to share a couple of common lines of code between the two. Create a new riscv_cpu_add_kvm_properties() that will be forked from riscv_cpu_add_user_properties() if we're running KVM. The helper includes all properties that a KVM CPU will add. The rest of riscv_cpu_add_user_properties() body will then be relieved from having to deal with KVM constraints. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 65 ++++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 23 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index db640e7460..8e6d316500 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1943,6 +1943,46 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +#ifndef CONFIG_USER_ONLY +static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) +{ + /* Check if KVM created the property already */ + if (object_property_find(obj, prop_name)) { + return; + } + + /* + * Set the default to disabled for every extension + * unknown to KVM and error out if the user attempts + * to enable any of them. + */ + object_property_add(obj, prop_name, "bool", + NULL, cpu_set_cfg_unavailable, + NULL, (void *)prop_name); +} + +static void riscv_cpu_add_kvm_properties(Object *obj) +{ + Property *prop; + DeviceState *dev =3D DEVICE(obj); + + kvm_riscv_init_user_properties(obj); + riscv_cpu_add_misa_properties(obj); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + + for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + /* Check if KVM created the property already */ + if (object_property_find(obj, riscv_cpu_options[i].name)) { + continue; + } + qdev_property_add_static(dev, &riscv_cpu_options[i]); + } +} +#endif + /* * Add CPU properties with user-facing flags. * @@ -1958,39 +1998,18 @@ static void riscv_cpu_add_user_properties(Object *o= bj) riscv_add_satp_mode_properties(obj); =20 if (kvm_enabled()) { - kvm_riscv_init_user_properties(obj); + riscv_cpu_add_kvm_properties(obj); + return; } #endif =20 riscv_cpu_add_misa_properties(obj); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { -#ifndef CONFIG_USER_ONLY - if (kvm_enabled()) { - /* Check if KVM created the property already */ - if (object_property_find(obj, prop->name)) { - continue; - } - - /* - * Set the default to disabled for every extension - * unknown to KVM and error out if the user attempts - * to enable any of them. - */ - object_property_add(obj, prop->name, "bool", - NULL, cpu_set_cfg_unavailable, - NULL, (void *)prop->name); - continue; - } -#endif qdev_property_add_static(dev, prop); } =20 for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { - continue; - } qdev_property_add_static(dev, &riscv_cpu_options[i]); } } --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597853; cv=none; d=zohomail.com; s=zohoarc; b=idyxdQEyANACRMdbCkF7s+dj4KArF2TfY3t9xhg6bW50KCWVFhFmXByUUblPCZKN7MqtNCqFNDBL9A/NrvToJKR8Sr+ci0VTFfiFpitRPmEq3fiaT4hB6s+jMNyDMGEi7nSq3q0Vs0aO/PIjuShKuxB6zOUOafpaIqRs7P1uHwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597853; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZD9FSoA3HWWEBgRcZ4qvcVAMe96asfJwEtuGAeb9z+U=; b=YRm+5omboPSAdoBL2a7ELKMMt93HilJa8h65fjW4xDwVGzGEYQl24R2P/Szg0LagkLMh8AxpCBfFYU938BQ4CqZMVTWiva82j+8sAeJoWukOqV3/8uDJYt59V7kUO3Ed74bIpf0qA80MQ51NxRE1eaC6bRZspfMfM7/94xBoI+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597853031234.82368761062696; Fri, 1 Sep 2023 12:50:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6V-0007pE-GZ; Fri, 01 Sep 2023 15:46:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6T-0007oo-MH for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:49 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6R-0002xR-FZ for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:49 -0400 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-573429f5874so1343296eaf.0 for ; Fri, 01 Sep 2023 12:46:47 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597606; x=1694202406; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZD9FSoA3HWWEBgRcZ4qvcVAMe96asfJwEtuGAeb9z+U=; b=ouoNSTbNlXPagz6mcML3hInD7aziySfgx9rCByW8J9BxzSKYCtnsC9GDjy5M1g5IcI J5PtZE40NoJnkWAe62DYwRklg7nvgfzOnlTdec80+a7wlx38p6lwzoUXnz+r1swd4td2 8c13NbrWaN4Mar+4QdpChX3KspuFmTRHiTb9tvXJLof7DBT6Ymmh4/uj50p2XNEuoOao j06INvAZW6vTf4bDZSRM0okzUC5L5AGpwEfKZDmcnwACfI/GSJ4WzvEKVAOhErtvvRrV P/ccvUwnRa6ZdHIR3RWfiKpRqooXe1w0UFGPwSf8udQVrFajYPJ6ligaFae3fgGuv0bH mOOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597606; x=1694202406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZD9FSoA3HWWEBgRcZ4qvcVAMe96asfJwEtuGAeb9z+U=; b=F615YrMEN9tHhtXBr+bQ7VWlwX0tW2nPIQfsV7t2yfR9VACvHyUoNroHIhmPzYeSbf AWIy6u6zRaKPcXbr4FFCLPnE5emp5MkaZQxQ+vgDAC941G6/Kp8E460/xItY9sUKIjRe XPH6nSCxbd1rFD2s0jMqvPAMT/sjDirOSheUzzYo/uElGUPWAqXNBrrQ4GvD3sEEvS9u YZIMR54fjhgTDPNdThIeqstHcOPnzmuqUDc8RrpA9OCXJuM47i//TC6/i0Vljs27qhhs liozPfM+C55pN3MYz9CIKOExzawjMo5uwrirMOHrGlIjlE9OF1wRGGKdonRk/hi8oJLH /Fuw== X-Gm-Message-State: AOJu0YyIG0Gn50iI7XuYZl7Jf9UElPcbrwpNNq7J4ThO+vdj1C4WVxPq 4h9FDJmUxBAgD57dKhRpNX3y8P3YeOx2QYSnzgk= X-Google-Smtp-Source: AGHT+IGIVA5ciR6n+YxEWky9LbdOYjQ3EapoXb/GoMzjZE/hUc9QodjYkC8ceTjGPdqhrD2ra/SAEw== X-Received: by 2002:a4a:250f:0:b0:56e:4bb5:3095 with SMTP id g15-20020a4a250f000000b0056e4bb53095mr3291202ooa.5.1693597606169; Fri, 01 Sep 2023 12:46:46 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 04/20] target/riscv: add DEFINE_PROP_END_OF_LIST() to riscv_cpu_options[] Date: Fri, 1 Sep 2023 16:46:10 -0300 Message-ID: <20230901194627.1214811-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c32; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597854056100002 Content-Type: text/plain; charset="utf-8" Add DEFINE_PROP_END_OF_LIST() and eliminate the ARRAY_SIZE() usage when iterating in the riscv_cpu_options[] array, making it similar to what we already do when working with riscv_cpu_extensions[]. We also have a more sophisticated motivation behind this change. In the future we might need to export riscv_cpu_options[] to other files, and ARRAY_LIST() doesn't work properly in that case because the array size isn't exposed to the header file. Here's a future sight of what we would deal with: ./target/riscv/kvm.c:1057:5: error: nested extern declaration of 'riscv_cpu= _add_misa_properties' [-Werror=3Dnested-externs] n file included from ../target/riscv/kvm.c:19: home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ | ^~~~~~~~~~ ./target/riscv/kvm.c:1059:5: note: in expansion of macro 'ADD_UNAVAIL_KVM_P= ROP_ARRAY' 1059 | ADD_UNAVAIL_KVM_PROP_ARRAY(obj, riscv_cpu_extensions); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ home/danielhb/work/qemu/include/qemu/osdep.h:473:31: error: invalid applica= tion of 'sizeof' to incomplete type 'const RISCVCPUMultiExtConfig[]' 473 | #define ARRAY_SIZE(x) ((sizeof(x) / sizeof((x)[0])) + \ | ^ ./target/riscv/kvm.c:1047:29: note: in expansion of macro 'ARRAY_SIZE' 1047 | for (int i =3D 0; i < ARRAY_SIZE(_array); i++) { \ Homogenize the present and change the future by using DEFINE_PROP_END_OF_LIST() in riscv_cpu_options[]. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8e6d316500..8662414906 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1922,6 +1922,8 @@ static Property riscv_cpu_options[] =3D { =20 DEFINE_PROP_UINT16("cbom_blocksize", RISCVCPU, cfg.cbom_blocksize, 64), DEFINE_PROP_UINT16("cboz_blocksize", RISCVCPU, cfg.cboz_blocksize, 64), + + DEFINE_PROP_END_OF_LIST(), }; =20 #ifndef CONFIG_USER_ONLY @@ -1973,12 +1975,12 @@ static void riscv_cpu_add_kvm_properties(Object *ob= j) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ - if (object_property_find(obj, riscv_cpu_options[i].name)) { + if (object_property_find(obj, prop->name)) { continue; } - qdev_property_add_static(dev, &riscv_cpu_options[i]); + qdev_property_add_static(dev, prop); } } #endif @@ -2009,8 +2011,8 @@ static void riscv_cpu_add_user_properties(Object *obj) qdev_property_add_static(dev, prop); } =20 - for (int i =3D 0; i < ARRAY_SIZE(riscv_cpu_options); i++) { - qdev_property_add_static(dev, &riscv_cpu_options[i]); + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); } } =20 --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597669; cv=none; d=zohomail.com; s=zohoarc; b=jgVuD+5z11nE1w5a2x69NxvggDjLzO2BW3NMsatrDVkUAyg4nSapvQy2e/E35COcbNG2sU9iJP27yF+xyeFeL42c2jzdzKHL72pSTVKTH8qQJYBTgoxFiPMYSsPwJrqpKdmjnoo+lbpm9OQ2q/T1+XigNz3JCehYPVmzH9CE8RE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597669; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wFowtOvUEba/kKqZrEXdKj+K1mBKqITpZ1FgtYYmnRU=; b=VBGVIUyAp/OfE6pemVjV8b1i/PjmwS0kh2iDiAv8igupp3yOGXv6U2Thfkys7miNiBOccrCrEYbgfKxj/xTIubIV7kKxmnMnzQVo7tE4Klr8HvhC1PH6w505GPvuf/v5unRkiTKesLC9f0DQqD2yoPTJSET4ConBV4bfMg4Fcco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597669304372.9337324302328; Fri, 1 Sep 2023 12:47:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6Z-0007qh-BS; Fri, 01 Sep 2023 15:46:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6X-0007pz-6p for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:53 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6V-0002z1-3h for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:52 -0400 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6befdad890eso1816376a34.3 for ; Fri, 01 Sep 2023 12:46:50 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597609; x=1694202409; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wFowtOvUEba/kKqZrEXdKj+K1mBKqITpZ1FgtYYmnRU=; b=Pbf9qXxTFi7A9wVbSspuwOonbN5Cbt0Rl+v9D863XLIHqRyuENtFgwxFKrLuMriGiD NS3BzLEdK8QHvusYsu4sNQWOeLfK9liOEM814SVz7dzwaLo4dn2HohNdS/h+FzK30s1s XzHkyiiAmCGmwMv++eRR4cdggbEjArByw8K20xUtbhpxqoKMwu2pcKdGn5O77WzrxC80 nCi8necGaKXEiidUi1c1KjuK8UXVN6GckuIvNlSIc0f/7O/vIxda7f9jOWKwkBiuuYls vHSxJ7M+EQTwdX4OlOPlcQu4MrqPy/VXbUEH8jURARpC4wzuPbETJMEd1bWr8asxSKyw s7QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597609; x=1694202409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wFowtOvUEba/kKqZrEXdKj+K1mBKqITpZ1FgtYYmnRU=; b=R8icAmCvgObrjtnmorRyMCSLO1/QYH1Qegc+8l48q4o5QBTlp9aCicX26uKC8p0XkI 9FD9fcGEyqgU7o29cdF4wCvWiN/RD+oqMrac8F+NMS5Fxwzl/vRwVF1JD1tGPDIorqKk AnkmFEpSK3ubodI1m7IXZbSUMFPpQ2hWQTn/uOcKi2AkCqDkRb/NTghtbCi6RJfBdbWu +3nQutoC9Y22KBIFHg3PiFGUbh8I3rV7sJjW41Ljmp+TwA6WMZXjPPJ8uOa3XPzBXQrF g42ByqhOgVJ0Fh0rSSAGmrcl5GTaVawGZStwQSdNrj9SAI5SO/UafI+DEGKe93LiE6Lm 2E/Q== X-Gm-Message-State: AOJu0Ywr+xE1XvL3XCu2RwetdQaYprdDtu7EyiYYhVvsfj8Ezj2TjELL y8f1hTRU4Wpn2LqLXemIwsxq4+a8EosFMJsZmvI= X-Google-Smtp-Source: AGHT+IEoKTT5nWgn9YuGUCMnPpnInn3vvQdrMKufRxvXZbLgrFJaXRKOSIQX5gWJUembQpDDfWD4Kg== X-Received: by 2002:a05:6870:d698:b0:1bf:1a58:c50 with SMTP id z24-20020a056870d69800b001bf1a580c50mr4290849oap.9.1693597609588; Fri, 01 Sep 2023 12:46:49 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 05/20] target/riscv/cpu.c: split non-ratified exts from riscv_cpu_extensions[] Date: Fri, 1 Sep 2023 16:46:11 -0300 Message-ID: <20230901194627.1214811-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::32f; envelope-from=dbarboza@ventanamicro.com; helo=mail-ot1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597671824100006 Content-Type: text/plain; charset="utf-8" Create a new riscv_cpu_experimental_exts[] to store the non-ratified extensions properties. Once they are ratified we'll move them back to riscv_cpu_extensions[]. riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() are changed to keep adding non-ratified properties to users. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8662414906..2349f813e4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1881,8 +1881,11 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), =20 - /* These are experimental so mark with 'x-' */ + DEFINE_PROP_END_OF_LIST(), +}; =20 +/* These are experimental so mark with 'x-' */ +static Property riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), @@ -1975,6 +1978,10 @@ static void riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ if (object_property_find(obj, prop->name)) { @@ -2014,6 +2021,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { qdev_property_add_static(dev, prop); } + + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { + qdev_property_add_static(dev, prop); + } } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597852; cv=none; d=zohomail.com; s=zohoarc; b=kq2vzluOgZiVB9e0oitBwqZ0ukKx1kX9NFS9yDJFuZHpdRTDSBwM7KfjEcl8tY/Aa+wzKCE20BHFSSZ9HpUeD2eGd/LtARYXAVr36IYovWdJrVmY4VFg1/25w6onWz4vHH31cX8z9ozCg9T/7QsMkQxMXuSPHlTASLKVCUYdaRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597852; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MoAd5LD1BxMnupNH6/trItdA1XMHMQzc01b70ikSrOQ=; b=fKsTx5QlwUfEfT3fIsO1xEXvcTQPci/W5rtEXJwD4wgXJ01mNBp4HXfwknZDkB+zIgkRwCzTdpWz4DiF7cCdtx8s+Lx5eDkxTyLJfHb0S9g4FJs8v8tHRiumyhTT7Cz5KT2W9nEYlJ96LKzPw10njWE/aWbY3oaavxabFS8rPrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597852552286.75039933006997; Fri, 1 Sep 2023 12:50:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6c-0007rB-22; Fri, 01 Sep 2023 15:46:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6a-0007qm-Hm for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:56 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6Y-00031a-AS for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:56 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-572a7141434so1325093eaf.2 for ; Fri, 01 Sep 2023 12:46:53 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597613; x=1694202413; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MoAd5LD1BxMnupNH6/trItdA1XMHMQzc01b70ikSrOQ=; b=e1XfyHZRN407giJeC4Eu5PuYLpioDSMqeSwHsM1X7OdNsWDNiUwJLI/pAXIm2KdPGj j71l5m+u94y8ymeqjxyMofoE4R9/82nlIonckidXEx5kJaVXWjWcJeZ4FCuMszlNlam3 o3w6qKFYYaNSbJUJxXLPWCKRD7dFv+RcGsv7BkAOKJoyXPmaxByIlmycluJn0yzXJDk2 kBCMv/X7ZP9DJkTTRLEvudTo6NO2/z+yv15k8AHqxlqkyGP8w5dIh32ljLIpZ6kYa+A8 ktctNvGuR5CTRw/8HBIvpc8iKx8tj08UzvHSbIBdihKpiR7ijhpZyQDL+TvqbP3njsnL YZFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597613; x=1694202413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MoAd5LD1BxMnupNH6/trItdA1XMHMQzc01b70ikSrOQ=; b=SL344T32Nl6MLhbRsi2mZT4US68NZ4fiqWwKN3nJRMeRZzNelBxO65rvX+BLxqmFMv fEntXcI8YSzyEtm27vQOqlHv0G43UayRWRA+kUFMccQGmHAYyYkkXws8wxJF/7cGRJ8z JUos1SY3OTxUuLoQpci/X9EDfo7TMCQISS1HD7FOF+5PzZA+0O/kS4w7iz3HsdycwrFJ QSgSJAuA76vs5Cr2wfvP7UxXxQMngFhF8L3z2gSpjxK2VTU0Ul1UVGuKR6dp7PIH7MeO 43yhLKUGmrFnh7ZJkfoHuK+oxfpCRwYZtiufeVZToSQygujIjZ+fgKYiRzP/DA7oRGSv n44g== X-Gm-Message-State: AOJu0YyFOjW+1Xb4ZIwmSs/xMWep60HVqvZX56o0mk92IzRhQA3LYvE+ z7sSKdnG3ujzOU4IoQGrf8tSitq4fxtmvaZbla8= X-Google-Smtp-Source: AGHT+IHOkNC9jRYjojBhKOytSV5l3b2FpU9OUydHcOPZWDsMX5IEstttMc2NABjLKtIhXyCMbui7dA== X-Received: by 2002:a4a:3416:0:b0:573:bf68:8dbc with SMTP id b22-20020a4a3416000000b00573bf688dbcmr3669027ooa.7.1693597612688; Fri, 01 Sep 2023 12:46:52 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 06/20] target/riscv/cpu.c: split vendor exts from riscv_cpu_extensions[] Date: Fri, 1 Sep 2023 16:46:12 -0300 Message-ID: <20230901194627.1214811-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597854026100001 Content-Type: text/plain; charset="utf-8" Our goal is to make riscv_cpu_extensions[] hold only ratified, non-vendor extensions. Create a new riscv_cpu_vendor_exts[] array for them, changing riscv_cpu_add_user_properties() and riscv_cpu_add_kvm_properties() accordingly. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 2349f813e4..86d536f242 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1867,7 +1867,10 @@ static Property riscv_cpu_extensions[] =3D { DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), =20 - /* Vendor-specific custom extensions */ + DEFINE_PROP_END_OF_LIST(), +}; + +static Property riscv_cpu_vendor_exts[] =3D { DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), @@ -1978,6 +1981,10 @@ static void riscv_cpu_add_kvm_properties(Object *obj) riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } @@ -2022,6 +2029,10 @@ static void riscv_cpu_add_user_properties(Object *ob= j) qdev_property_add_static(dev, prop); } =20 + for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } + for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { qdev_property_add_static(dev, prop); } --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597677; cv=none; d=zohomail.com; s=zohoarc; b=TuSZHH/Jz0AfxF0ze1d20BbXPEassrAHfIUTs3uPKZrZhxk6yUwUsXtuKXImhc3EXC8J6DweINrRY9dMlle3k8K8JUUinHndcP6ZuAyqwccCLTXvCuewIJCA06d7GWFiUqwLUZwnsZEatNfJXHMmbUHT9Sss4OfNIIwmbhRKbqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597677; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VlbGyX5m6KtgrJVMCPdMtGmiqD1bES604h+IzM7DCvA=; b=b1zk6ywYnhWkIKRICvIGgOsmfOWe6LYQdENnX7bnB+uxlbpmuSlc7BTnwHQIocaBGe0R9cQ+tyawW5RtNkdc0IeALLsziTUiug9m0nriDeEWyvwi1g7C4e553gticuW2YJ0NugmZK54yxooghINtz4cKcgxTd/MvpgNhs32rKF0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597677919370.4513257287624; Fri, 1 Sep 2023 12:47:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6g-0007sf-CX; Fri, 01 Sep 2023 15:47:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6e-0007s4-7E for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:00 -0400 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6b-00033n-Vf for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:46:59 -0400 Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-57358a689d2so1473265eaf.2 for ; Fri, 01 Sep 2023 12:46:56 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597615; x=1694202415; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VlbGyX5m6KtgrJVMCPdMtGmiqD1bES604h+IzM7DCvA=; b=ccL+n7phnDi+S5xNAsT0CNaMK5Cr8KqJaxYpDmFtyWg26bnE9nEhPgEh5mEbUnNEbs vCuYkwhrL+Pyyo4zq9GRM9WqtzVq8kw79l1CIi8mrJswLdlnLwQKZFE12jEKix98n95T dLe4wut3gB5BgMjRvEjHTxa781DUncsr/Hl4JbpwH84KL6jq4IiHObuaIpmo151GqM9L Wfl4Og3hgk9BXEJkOCubPCZjVzCZh+pI7vTIR7W7/18L0ZkocG15idtwy3HJSH5ybS03 0BoEn2Qr765aRpcsrbJawZfvKhZLoIj4UQDHAzxx6zkE83nChmbaV7wO0SrypyNco65K JGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597615; x=1694202415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VlbGyX5m6KtgrJVMCPdMtGmiqD1bES604h+IzM7DCvA=; b=HdqmafYkdgYdM4Does5O700P57J2uJetRl04UIwO2M3PlpV6dho3Acx8xqdgPTail0 EQU05gVQAifB0WnHqUeRibQj3kUlyE7RpzAVcEbSpRj24zf+lcNZ1JdQvoKYmfC7xwX3 EME3UEeL5ze3A5SYejRKbAbgE5o2W8d3Tz67MjnMqlQWJ8TUdB9rRCzcItwd8Lo3ojv7 WXOgGArHldUUADz43LCVHfKgrC9W49YekoDfERgZsg2eZainv0T3ylnUQ0zUQ0I4qcbG XwMV+jj8TsQchKboRnh/h9J/dsadS6/nGatcwXjREGBvv+CoxWbb1uhKsfri0SmaT8/k wNJg== X-Gm-Message-State: AOJu0YzJYd6n8FXwkR5FrtuMGMRpIbjlmd+eVcRBCkNz6aRXikHXQw6s tY1xteWM5xuZGKJhidv6uVoSzbYvL4B1gM7Yq04= X-Google-Smtp-Source: AGHT+IH44mryeYRuEWy93olBG9vKcgXh44ING2P3GjvKWFcjh8lR352c6056Z6AnRT4cHZfY2n4DPg== X-Received: by 2002:a4a:d1cc:0:b0:571:2b59:d697 with SMTP id a12-20020a4ad1cc000000b005712b59d697mr3387307oos.0.1693597615724; Fri, 01 Sep 2023 12:46:55 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 07/20] target/riscv/cpu.c: add riscv_cpu_add_qdev_prop_array() Date: Fri, 1 Sep 2023 16:46:13 -0300 Message-ID: <20230901194627.1214811-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c31; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc31.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597679360100003 Content-Type: text/plain; charset="utf-8" The code inside riscv_cpu_add_user_properties() became quite repetitive after recent changes. Add a helper to hide the repetition away. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 86d536f242..d484d63bcd 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1951,6 +1951,15 @@ static void cpu_set_cfg_unavailable(Object *obj, Vis= itor *v, } #endif =20 +static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + qdev_property_add_static(dev, prop); + } +} + #ifndef CONFIG_USER_ONLY static void riscv_cpu_add_kvm_unavail_prop(Object *obj, const char *prop_n= ame) { @@ -2007,7 +2016,6 @@ static void riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - Property *prop; DeviceState *dev =3D DEVICE(obj); =20 #ifndef CONFIG_USER_ONLY @@ -2021,21 +2029,10 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - qdev_property_add_static(dev, prop); - } + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); + riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 static Property riscv_cpu_properties[] =3D { --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597689; cv=none; d=zohomail.com; s=zohoarc; b=apDCIAud8Yj1rsy1ILcoEKrDnY02+ZcY/WLCmTOpIsf3mYnvG//cp2jdzHu9tLIpQ5uAWfjyg8gbF7DF01bGhvQnvdQMr6SuUG2BTwAbavRFhrk113WK9boLZFE1fOkCTWLXlM+oA4q1K8zL7DkGlhqbF+pbyqx7iWGEFiD+k0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597689; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=l2KbsGlOr8UMgf9yLtUtwDLL3EzfkGCFI4CkT7iJNrA=; b=aGrzgr87Mo87KIAdo+CgyVUadrLGzKyD+dl/XJqpZiA8TBxMjnaU9X+il7bAN3ZuAkbTHwKEYHzcSd7UJl+hkx3zlVVvL/zqLdGAk0qYH7ZMpLHXF9HuEA+tGyxLMnTpxRS/cC//6phVwMlJL7ks4ovs/SKeT3bAsMQhz29/k9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597689141649.9514852420202; Fri, 1 Sep 2023 12:48:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6i-0007tI-4E; Fri, 01 Sep 2023 15:47:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6g-0007so-J7 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:02 -0400 Received: from mail-oo1-xc2a.google.com ([2607:f8b0:4864:20::c2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6e-000369-85 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:02 -0400 Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5717f7b932aso1436464eaf.0 for ; Fri, 01 Sep 2023 12:46:59 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597619; x=1694202419; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l2KbsGlOr8UMgf9yLtUtwDLL3EzfkGCFI4CkT7iJNrA=; b=gwY2KuTcvGm8z/GbGLRRgwG84Qu5dLdDJKY1nMEDoSR9Mh3HWEfUmOO4EuvIIQdvNE hSURZJ3JIgBz+bhkWxY0Ds/Hz2VzSJQ3yXjDtQ9AkN87kaBgr128dOa/wqPCInpPkzis 6Zilm7ux1SFHeM+yT6ezX0RWaOYRB5unO9hNgvTyuPKVVZpEIZNFUehwIdfoFHgVxHP8 9PVtorY3LBfiPGtCYTx5a5dtl3LaPxqTJ0XmLGOyBo5E9T/Yp1vSL9zDM0C9FtCXTBuB /OBSDmlONeXzrkYsUqG11waU/s8O5cJIn1E4KqNQ+8WTeGs2x3kEPtMMLCrcBJNnO01O qvSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597619; x=1694202419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l2KbsGlOr8UMgf9yLtUtwDLL3EzfkGCFI4CkT7iJNrA=; b=hmtmPYdjokjekGhJW0BIRVec8iPYwcT8XS4gaC4M5fYXBrhyeB9yaedta0foercqt8 x/LBsJ/nPC6YtKP7cD5jA7mvbWY4Fn+LsQsVcSmrATSximRUmZFc2G/JmRspoajUiq9U Ndu2kqSsd1ucvdIRVaXc+79mnTCzg+wy9OvB8Gi8STZOh6VH+v+8R7eqpyYeZIuUobPM QXamd0Jji68bxp6tCt2iQteD1/dTZtUXcX7aQTwkhHEGe6SpDRjvgQ84y1IDqEtb72VH gJtmK2WQ2rum58788HcEY4U3kFiT3MoBkEZGPj/SVIN9zatnkWOUCGIkd1e3rs1sO6oW Buzw== X-Gm-Message-State: AOJu0YwCCVLtMftktx3BqYi5wgZecoYQlxk9pysCesapoh8zKc3EOpMi X31ei0wbDKLmVqglcNhbfIpVOMjhx1SWMzQAEco= X-Google-Smtp-Source: AGHT+IF+BEpytckmqut2nQflWkyG8OGraXzo3acsn8CxtxV7YvnwjDzA4fwW2DfeXWBOzHFTLxcqHA== X-Received: by 2002:a4a:764d:0:b0:56d:2229:5f94 with SMTP id w13-20020a4a764d000000b0056d22295f94mr3588754ooe.6.1693597618999; Fri, 01 Sep 2023 12:46:58 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 08/20] target/riscv/cpu.c: add riscv_cpu_add_kvm_unavail_prop_array() Date: Fri, 1 Sep 2023 16:46:14 -0300 Message-ID: <20230901194627.1214811-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597690637100005 Content-Type: text/plain; charset="utf-8" Use a helper in riscv_cpu_add_kvm_properties() to eliminate some of its code repetition. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d484d63bcd..8cd19a9b9c 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1978,6 +1978,16 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *o= bj, const char *prop_name) NULL, (void *)prop_name); } =20 +static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, + Property *array) +{ + g_assert(array); + + for (Property *prop =3D array; prop && prop->name; prop++) { + riscv_cpu_add_kvm_unavail_prop(obj, prop->name); + } +} + static void riscv_cpu_add_kvm_properties(Object *obj) { Property *prop; @@ -1986,17 +1996,9 @@ static void riscv_cpu_add_kvm_properties(Object *obj) kvm_riscv_init_user_properties(obj); riscv_cpu_add_misa_properties(obj); =20 - for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_vendor_exts; prop && prop->name; prop++) { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } - - for (prop =3D riscv_cpu_experimental_exts; prop && prop->name; prop++)= { - riscv_cpu_add_kvm_unavail_prop(obj, prop->name); - } + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_kvm_unavail_prop_array(obj, riscv_cpu_experimental_exts); =20 for (prop =3D riscv_cpu_options; prop && prop->name; prop++) { /* Check if KVM created the property already */ --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597755; cv=none; d=zohomail.com; s=zohoarc; b=AaIby0CysZDOkSVICmBRaT4i4OeF44J4TYh/M6R5O+1g6bcSmFZRymyvr9un2ZL63WqYcodYzoMJ+MamUFoFt82DLfwPkvv+lcE+ITfEbdJbxvE1ySvKn3h2C+8pLO1bnw/KwHt120xiizuiofOOTfPgVuvcX6M1EyshJLyrHhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597755; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y97HdxxmubvS3cqidCb6OPgwtQdSFtj5M29PXNDNmfI=; b=lmZhkOHDLbFjMW3szL370gi3fj6OEUHbJ/uH+1AmYIrentVh/Q2xGEWr0Vtd7wO6PGCE2/z4jqjHnw32tpzAzHr/Spt9OSnexGOos6HNBHcGCAAAtXu4QE8AgY4UwbhrvAwGPQr3Mqg/Hc+NePn3EUJ7MgjilzesqrLvNwH36m8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597755836522.6093940316196; Fri, 1 Sep 2023 12:49:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6n-0007vA-9O; Fri, 01 Sep 2023 15:47:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6l-0007uN-Nv for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:07 -0400 Received: from mail-oo1-xc36.google.com ([2607:f8b0:4864:20::c36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6j-000373-5y for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:07 -0400 Received: by mail-oo1-xc36.google.com with SMTP id 006d021491bc7-5712b68dbc0so1442025eaf.1 for ; Fri, 01 Sep 2023 12:47:03 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.46.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597623; x=1694202423; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y97HdxxmubvS3cqidCb6OPgwtQdSFtj5M29PXNDNmfI=; b=PmFXSEDnY9knbd16ej5Tbd7j6QfEf2zIPpQrSBsjYm0t7w1h/vdDoAMJvx6nNM5HX+ Pt/Qag9xhvNTlHzHnsVdew7gC3IxOYjaFbmpJZs5FK29+J1gXrqQdCNSR4N638nX0Qjg U1u+/hvYLjQffQMMFHiGuvAH6zszR1nztuGqoS3bn5qkfItwsFcu/bcSAgxWZEk5t2Qk 17CU0gqHC8/BJ6KB1oPWaQHpWc+0t+30mnT/auTUngjcKoDOJIoZQVcrBzhFmpkEbSnu raO7ZzZ9RuwL6HmGVwifD01omCI0g/3st5MY9ICdaBGNzHgB7oRGPK8XxdFBKYR/QsWn gmbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597623; x=1694202423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y97HdxxmubvS3cqidCb6OPgwtQdSFtj5M29PXNDNmfI=; b=Oe2WI1UtucmX06BGtZzyLXutPpSWBxWp2w7MBcS7fq4NUPNRXEKZMmcWAK4wAJNkRG 0nc66tDBhLInKuCZxRmSuX3fhIi9rPQFGC55PNIQTAXNtU8aw8VwUBAcrvqdkDR/D3o8 PTSFpAruzkN+hbfgCRRwAlJXBWrboI8aExT7BhkeSXIGOq5lvK1DLY4WP6Z5uJPi+LyI lcmLmVZJQv0tuG0TOWOotTgjS72DjBMG5kizDkIDAm51WYWJYlVlUMFA1h3YDgKZTXw/ pYONncf2wSAnK60nvyHaiCKKgyMOf/hSmzzVb8mEgCJDBJjDVr9jgGQoa/xQDkXvUlbs Sezw== X-Gm-Message-State: AOJu0YzjJA37N69+RQYdcLvvQvuBijUTwN8rKdJU7NG4S+eJ/kAKWL4Y oEAKGdDHFEFGkcl/vPWB1EKmcDQQNaZFwJNmiYs= X-Google-Smtp-Source: AGHT+IEwWIi1fmESz6XeCJq3RMjCEMKQ9NOxy+o6S8yCv468DMoFDy5F/JxJMvUIgGM9rAvoITJ8Lw== X-Received: by 2002:a4a:2545:0:b0:571:aceb:26c8 with SMTP id v5-20020a4a2545000000b00571aceb26c8mr3516315ooe.3.1693597622852; Fri, 01 Sep 2023 12:47:02 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 09/20] target/riscv/cpu.c: limit cfg->vext_spec log message Date: Fri, 1 Sep 2023 16:46:15 -0300 Message-ID: <20230901194627.1214811-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c36; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc36.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597757503100003 Content-Type: text/plain; charset="utf-8" Inside riscv_cpu_validate_v() we're always throwing a log message if the user didn't set a vector version via 'vext_spec'. We're going to include one case with the 'max' CPU where env->vext_ver will be set in the cpu_init(). But that alone will not stop the "vector version is not specified" message from appearing. The usefulness of this log message is debatable for the generic CPUs, but for a 'max' CPU type, where we are supposed to deliver a CPU model with all features possible, it's strange to force users to set 'vext_spec' to get rid of this message. Change riscv_cpu_validate_v() to not throw this log message if env->vext_ver is already set. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Weiwei Li --- target/riscv/cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8cd19a9b9c..3ba92c806b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -959,8 +959,6 @@ static void riscv_cpu_disas_set_info(CPUState *s, disas= semble_info *info) static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg, Error **errp) { - int vext_version =3D VEXT_VERSION_1_00_0; - if (!is_power_of_2(cfg->vlen)) { error_setg(errp, "Vector extension VLEN must be power of 2"); return; @@ -983,17 +981,18 @@ static void riscv_cpu_validate_v(CPURISCVState *env, = RISCVCPUConfig *cfg, } if (cfg->vext_spec) { if (!g_strcmp0(cfg->vext_spec, "v1.0")) { - vext_version =3D VEXT_VERSION_1_00_0; + env->vext_ver =3D VEXT_VERSION_1_00_0; } else { error_setg(errp, "Unsupported vector spec version '%s'", cfg->vext_spec); return; } - } else { + } else if (env->vext_ver =3D=3D 0) { qemu_log("vector version is not specified, " "use the default value v1.0\n"); + + env->vext_ver =3D VEXT_VERSION_1_00_0; } - env->vext_ver =3D vext_version; } =20 static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp) --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597831; cv=none; d=zohomail.com; s=zohoarc; b=BoZXfGXSt3hqt2IIxyV+NQdwl2r1pa27Hbiiw9fGfnkt0EAqWuFNoS+wdyrIp8ExE/BC+jweZNyZH14Tsbjq9fEqDpNSfOvxw3YI3Tq/7Wz2lHIQsyoGd54y7PEzFdr6fDhf2Usktt9/2fxc8kQHeugIy0fIsf+5eg0SuzRXW1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597831; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Zx/YsxPRcu3zLD6oZyfpDAXEzCiCtDACWsFKpgaNcnY=; b=XYJ4IsMKNnMCkpEvSC10ryKPudEtv0ojm/JB6cX04jj+JH1AHfVaBRwWyXPvxAQ4MW1dZskZkIHIpcgv3S0qtc5Q2f6mpxSPo2Y9mxGKNX8esbcXzy4tHUUEKYzhPTWQ5aY+SGqQmW76FDZjzmYrAAN4Y/iW4clX6sbpLowdjFQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597831417932.2226175305815; Fri, 1 Sep 2023 12:50:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6q-0007y2-0a; Fri, 01 Sep 2023 15:47:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6n-0007vT-T6 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:09 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6l-00038v-IZ for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:09 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-570e63f5224so194321eaf.0 for ; Fri, 01 Sep 2023 12:47:07 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597626; x=1694202426; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zx/YsxPRcu3zLD6oZyfpDAXEzCiCtDACWsFKpgaNcnY=; b=I8bxBJmanhrczRMX0qzHM5iDx1TqJ2JTAfNGsERjK/VI4fxMzi5nT3MUgpHKUwKECm IkzY94mMTeIDPlblQCU7RLWq3vCvkqQaSaISYTuGtz3RdKIa+Q7M4fVOe683h9f8Gb5E YS9PDMr8mRFC7Ybnl2H68IQ97B80fIr9m2s8OWF4kJ+EGc+AJzpNq7X/99nVSWZi5FLZ DadJ9AAzl2KszFFClNRl/guHrs00GxtSJbJ+HAXHGMjyinuFLsdx5sDAhtpUCF2k51Mu nxa3vNYfsh0qCloi8lwFwsgOK+mdFxhAH7ncz2MVMwohEg9qJlhVKDEOiHb+ceL0JQi8 YUqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597626; x=1694202426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zx/YsxPRcu3zLD6oZyfpDAXEzCiCtDACWsFKpgaNcnY=; b=UpMiMWesD51zRZFbjCOeIonhLItemtxhsxRED/lZFG9Qquhi5+i1DF5u0A6U3baUG6 oLRowwfERZ8ls2DbYV9Wt+ksSLoXQJJdTsFvvu4qz52Xu4ndshaL+fhKEXkfSe8oXQoX uVGY6aEbPvEY7PAedmAkmg5FczrfwaaqaSQtXVDZjAAxrIbgL4uPDl+n7J60VZL1omQj TzGHHIb3WObxQ4fxYBoAlf2mxSeuuFBkiHiNFEAqdFvOHz4gorL25F1J8vHHR0pQAaEN TQ31Yy4tr17GlRhk4jbwlxpoA5V0zgrfqWQUDeS6pLoI243GMlIWajjPhtC863ZcLOEr 3LKQ== X-Gm-Message-State: AOJu0YxI7XbT3AOfsxz3t8n57TzQm3f7L+5juQEr2cQly0ENBoAPOdz7 GbRqrZrzoDawWyiBPHTtj2Fhg16SIaJtEYeKi5c= X-Google-Smtp-Source: AGHT+IFo9JeaVNRKxTAdP79lVc1XWLO5AlkF2DQogL9Qsbc5lmvSx/V3Q1ZBTnvl9GUJhAbEx8QJAg== X-Received: by 2002:a05:6808:208a:b0:3a7:7b7e:f309 with SMTP id s10-20020a056808208a00b003a77b7ef309mr4189010oiw.10.1693597626235; Fri, 01 Sep 2023 12:47:06 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 10/20] target/riscv: add 'max' CPU type Date: Fri, 1 Sep 2023 16:46:16 -0300 Message-ID: <20230901194627.1214811-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597833552100007 Content-Type: text/plain; charset="utf-8" The 'max' CPU type is used by tooling to determine what's the most capable CPU a current QEMU version implements. Other archs such as ARM implements this type. Let's add it to RISC-V. What we consider "most capable CPU" in this context are related to ratified, non-vendor extensions. This means that we want the 'max' CPU to enable all (possible) ratified extensions by default. The reasoning behind this design is (1) vendor extensions can conflict with each other and we won't play favorities deciding which one is default or not and (2) non-ratified extensions are always prone to changes, not being stable enough to be enabled by default. All this said, we're still not able to enable all ratified extensions due to conflicts between them. Zfinx and all its dependencies aren't enabled because of a conflict with RVF. zce, zcmp and zcmt are also disabled due to RVD conflicts. When running with 64 bits we're also disabling zcf. MISA bits RVG, RVJ and RVV are also being set manually since they're default disabled. This is the resulting 'riscv,isa' DT for this new CPU: rv64imafdcvh_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zfa_ zfh_zfhmin_zca_zcb_zcd_zba_zbb_zbc_zbkb_zbkc_zbkx_zbs_zk_zkn_zknd_ zkne_zknh_zkr_zks_zksed_zksh_zkt_zve32f_zve64f_zve64d_ smstateen_sscofpmf_sstc_svadu_svinval_svnapot_svpbmt Signed-off-by: Daniel Henrique Barboza Reviewed-by: Weiwei Li Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index 04af50983e..f3fbe37a2c 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -30,6 +30,7 @@ #define CPU_RESOLVING_TYPE TYPE_RISCV_CPU =20 #define TYPE_RISCV_CPU_ANY RISCV_CPU_TYPE_NAME("any") +#define TYPE_RISCV_CPU_MAX RISCV_CPU_TYPE_NAME("max") #define TYPE_RISCV_CPU_BASE32 RISCV_CPU_TYPE_NAME("rv32") #define TYPE_RISCV_CPU_BASE64 RISCV_CPU_TYPE_NAME("rv64") #define TYPE_RISCV_CPU_BASE128 RISCV_CPU_TYPE_NAME("x-rv128") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3ba92c806b..365c2b3b56 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -259,6 +259,7 @@ static const char * const riscv_intr_names[] =3D { }; =20 static void riscv_cpu_add_user_properties(Object *obj); +static void riscv_init_max_cpu_extensions(Object *obj); =20 const char *riscv_cpu_get_trap_name(target_ulong cause, bool async) { @@ -396,6 +397,25 @@ static void riscv_any_cpu_init(Object *obj) cpu->cfg.pmp =3D true; } =20 +static void riscv_max_cpu_init(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + RISCVMXL mlx =3D MXL_RV64; + +#ifdef TARGET_RISCV32 + mlx =3D MXL_RV32; +#endif + set_misa(env, mlx, 0); + riscv_cpu_add_user_properties(obj); + riscv_init_max_cpu_extensions(obj); + env->priv_ver =3D PRIV_VERSION_LATEST; +#ifndef CONFIG_USER_ONLY + set_satp_mode_max_supported(RISCV_CPU(obj), mlx =3D=3D MXL_RV32 ? + VM_1_10_SV32 : VM_1_10_SV57); +#endif +} + #if defined(TARGET_RISCV64) static void rv64_base_cpu_init(Object *obj) { @@ -2036,6 +2056,41 @@ static void riscv_cpu_add_user_properties(Object *ob= j) riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); } =20 +/* + * The 'max' type CPU will have all possible ratified + * non-vendor extensions enabled. + */ +static void riscv_init_max_cpu_extensions(Object *obj) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + CPURISCVState *env =3D &cpu->env; + Property *prop; + + /* Enable RVG, RVJ and RVV that are disabled by default */ + set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); + + for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { + object_property_set_bool(obj, prop->name, true, NULL); + } + + /* set vector version */ + env->vext_ver =3D VEXT_VERSION_1_00_0; + + /* Zfinx is not compatible with F. Disable it */ + object_property_set_bool(obj, "zfinx", false, NULL); + object_property_set_bool(obj, "zdinx", false, NULL); + object_property_set_bool(obj, "zhinx", false, NULL); + object_property_set_bool(obj, "zhinxmin", false, NULL); + + object_property_set_bool(obj, "zce", false, NULL); + object_property_set_bool(obj, "zcmp", false, NULL); + object_property_set_bool(obj, "zcmt", false, NULL); + + if (env->misa_mxl !=3D MXL_RV32) { + object_property_set_bool(obj, "zcf", false, NULL); + } +} + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 @@ -2374,6 +2429,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { .abstract =3D true, }, DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_ANY, riscv_any_cpu_init), + DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_MAX, riscv_max_cpu_init), #if defined(CONFIG_KVM) DEFINE_CPU(TYPE_RISCV_CPU_HOST, riscv_host_cpu_init), #endif --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597881; cv=none; d=zohomail.com; s=zohoarc; b=AmmuknsFUTmXOI2D0OwTodM8gNet6NZX0N6UqPGWZcWVEbsjvaoarMEKTs8NdznSnF3GWK6PTlSZYQSrOT/EwdFfF0k5GtL+qnCIPMBIWjQ37+nrUrvYoSPKVHFagZpK9lY5kaj0fkH8l+HP7NY92YkGRKiiN7Wg/J0hykMPO3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597881; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rdvVF2+aoI8lzXMJPBhi2K9SUSXzJrx6SlpvXXkfYMI=; b=coV5PLUXet7k1S2VQRD6oY5BuHbtP4riBtOKg1x/3a80ok5gxpDxU0eS3HWLPnkZjmwYUwYYFHrPspdEI/5AUmZLpVDCPmEg5GkiS2LgWXlWjefHQ0+A44vD3oF8YrMxCScYa2Eo/gapcuMBPg8qdJEpmTcZPaSnAKslFw1KUXI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597881370159.57841262714953; Fri, 1 Sep 2023 12:51:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA6t-0007zk-0Z; Fri, 01 Sep 2023 15:47:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6r-0007z4-Ct for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:13 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6p-0003DK-Ab for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:13 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-573429f5874so1343466eaf.0 for ; Fri, 01 Sep 2023 12:47:10 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597630; x=1694202430; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rdvVF2+aoI8lzXMJPBhi2K9SUSXzJrx6SlpvXXkfYMI=; b=EJXqm5BtnzzGFa26MQRzUUFpPmi8dIsojvL88kZABJMAElOGAawUWbGv8VuTCAbCld TGDTz5/2sbj+WHi/8lcpvsz0Op3FKLxSvs9EY64/CE2l0HanmQVvbOaePNVYAry43Ubu 622MMOi77j7kvA4/udTqiR9QjRU1GzzcSOFLNMeQLdYMN+Hd7sod+3BF9RxSFO0tPcL6 XUvkd3F+drmuRRtEvu9+ddG8vX8aCtOkiw/AHcXpCxWRnXV9dKlniCRqqL95WTqoMvjz +K5HMjuA2wK8q1Zae8yZ7enXhBDRykZeMCn8+cIioapPzJ6Ox4MgjavleuqHLuUfxFwE aI2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597630; x=1694202430; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rdvVF2+aoI8lzXMJPBhi2K9SUSXzJrx6SlpvXXkfYMI=; b=XUD/S3pugoEcVz/qfD9vxotA5cn6za98vdNlZvJOUbY0t3jy6I2zzsCeeB2rdOILyy nGJe+RJIk2G1Atkw4nDI8lckDNLpYfNRZO0kLT9XpuzGlYqm01XZ4rH9c4yQf58NSxt/ 8EBAb32nviLGuMPXafIwPzw0LfL7hF1trpZMAc1DUjY2nNQm+5QeseN/F4ryGDhHUPp6 qzJx4Bn1Vt9AG2WgaV8TFAr7hZEkJZn1QjkcglR3+cXlAdAcfGsm7wG4wvomznCgUM1t NnhKDMNKaXrLNxnMa8v8fpMXNZgGvkegkNVGVnlIo+dLXh7AhFTLjUiL/qBkmFUCQFDX 6xPg== X-Gm-Message-State: AOJu0Yyyp8m8mb84Z+fOpY9zHzmaieyTDyBFBTlTW2tcbfnTZ7+wn3Kj kto7t7n++X/xv/INunbsG7o4Y/XUEL0ayKKC7TA= X-Google-Smtp-Source: AGHT+IHWmG264FFU6WgVYIvcsuT0hR6Wxxu7I87ZmEnHAVafW2sQd9RwpvlYNFx8fz0JQF/QD24l4A== X-Received: by 2002:a4a:2a14:0:b0:56c:820e:7f02 with SMTP id k20-20020a4a2a14000000b0056c820e7f02mr3705195oof.0.1693597629906; Fri, 01 Sep 2023 12:47:09 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 11/20] avocado, risc-v: add tuxboot tests for 'max' CPU Date: Fri, 1 Sep 2023 16:46:17 -0300 Message-ID: <20230901194627.1214811-12-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2b; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597883224100003 Content-Type: text/plain; charset="utf-8" Add smoke tests to ensure that we'll not break the 'max' CPU type when adding new frozen/ratified RISC-V extensions. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- tests/avocado/tuxrun_baselines.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/avocado/tuxrun_baselines.py b/tests/avocado/tuxrun_basel= ines.py index e12250eabb..c99bea6c0b 100644 --- a/tests/avocado/tuxrun_baselines.py +++ b/tests/avocado/tuxrun_baselines.py @@ -501,6 +501,38 @@ def test_riscv64(self): =20 self.common_tuxrun(csums=3Dsums) =20 + def test_riscv32_maxcpu(self): + """ + :avocado: tags=3Darch:riscv32 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv32 + """ + sums =3D { "Image" : + "89599407d7334de629a40e7ad6503c73670359eb5f5ae9d686353a3d= 6deccbd5", + "fw_jump.elf" : + "f2ef28a0b77826f79d085d3e4aa686f1159b315eff9099a37046b189= 36676985", + "rootfs.ext4.zst" : + "7168d296d0283238ea73cd5a775b3dd608e55e04c7b92b76ecce31bb= 13108cba" } + + self.common_tuxrun(csums=3Dsums) + + def test_riscv64_maxcpu(self): + """ + :avocado: tags=3Darch:riscv64 + :avocado: tags=3Dmachine:virt + :avocado: tags=3Dcpu:max + :avocado: tags=3Dtuxboot:riscv64 + """ + sums =3D { "Image" : + "cd634badc65e52fb63465ec99e309c0de0369f0841b7d9486f9729e1= 19bac25e", + "fw_jump.elf" : + "6e3373abcab4305fe151b564a4c71110d833c21f2c0a1753b7935459= e36aedcf", + "rootfs.ext4.zst" : + "b18e3a3bdf27be03da0b285e84cb71bf09eca071c3a087b42884b698= 2ed679eb" } + + self.common_tuxrun(csums=3Dsums) + def test_s390(self): """ :avocado: tags=3Darch:s390x --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597723; cv=none; d=zohomail.com; s=zohoarc; b=R+ukS+mlL8vS9IYUzc1f5b3Zqt2NYq5drhV6J0Vok4uNZJ51vwYdxI5iJ7j6XJhFaUwjBn+NyT5L7KlBrsAXoC0oTYwer0HAu5GGRG2B59TTLlN+uFTA1v31UNAkyd2MYL03Lg3Xm93PIHKrFN8f4Z6ypbS3MH9wYxmGolKfLlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597723; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6bz0dqSG1/NR9vONR3Zg7ZJ3UJqOsJUfrg/aOBJFGTs=; b=HS/xG/vnmPzIy+6MYoEy6GSGoSQllPnodK1RKq2DPL4ogEROp6wEJOc2j68d7har2Itb7n9f7DZDHSlTA05QMtSv2tbk0LPoAst1gIbeESwfBLJ5MjvWfWLTwc2g0DJYDgAvAQuC4rGi+/pjtmNMpjkqbzWHBcvlby8DbYKQk7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169359772355723.827311539781704; Fri, 1 Sep 2023 12:48:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA7K-0008IW-Lu; Fri, 01 Sep 2023 15:47:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6z-00080Z-7e for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:25 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6u-0003FR-3j for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:20 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1d0d3d40124so1544446fac.3 for ; Fri, 01 Sep 2023 12:47:15 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597633; x=1694202433; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6bz0dqSG1/NR9vONR3Zg7ZJ3UJqOsJUfrg/aOBJFGTs=; b=gDAbgfWLU3eXboE7DbyCfvJslz2o+7WlFXcKWYMeBPsutavAcbwsSCFCdczRbUvYag 63vTo/GMd6JjwWtWc6QfPpFGI4v409Il5alPga+cePnQA4+rai2oaEPFN1tRVT2Ldx0J DjKNH7MJFwccBZqwxmDZ+iihAExXO1Tiy2m8vnCardM46IKEgbz+z+wvxI/KtxsOu/SC bF2kM9i+J8GFjQBuA0V05ujq0A7+NK2xSjpo1BvY3AkM8AJYnSG9QqOQp6BxxFB/4D05 vpjZIpI6BkMaXP0Z0On/12w8XX0jZfjHkuthaSvQG5p3W/Wv5m8/XljcmDu2iRCNba3L UqHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597633; x=1694202433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6bz0dqSG1/NR9vONR3Zg7ZJ3UJqOsJUfrg/aOBJFGTs=; b=CG4JADlNPHm/xG8MyyYXWdAHJrSI5Y/arv9OhC/jiJXcJp2CGl99fSfffPNy9sS3kC kKCFvU2huhMLray848ur55zFkctLJByNCgo5HQg1dmZ7w0r6eDFq8/P7S7ScwFZHCMEn wM1O4vdG/bGLnKagvHmRAZIkfF7ikimXKP/Z9Bqo6w+6X4qBmq88lOOt5Z6knbH6Vcwu LVfa1mBWaw++UBUN1nDlumNNZ4roijgqqAk/HqwEuuQ1uciNUq+3RllHVyur2tLX+IcA pP6Edfv91eUS3VbMxLrxQEU5J83XLa6iRZhulpLftwk8Cp2HDMtMk/nNzWCm154GEQK5 y6aA== X-Gm-Message-State: AOJu0Yw644m6GUdpxXIi6rppOdy6Kad8pIYMeag/IJ2pU0Ol2sE7+TjZ Hm7ATGcFD+7/cliFfIXCqYQEG3jgviVcAikYf50= X-Google-Smtp-Source: AGHT+IEKEuW4D07TGSOb3OWzYiprA8+hyyIcBqHL5xjqhBcGGUIh8qxe6ZJbRXBOzs2q5E4xewrEoA== X-Received: by 2002:a05:6870:8327:b0:1bf:6ec:dd4d with SMTP id p39-20020a056870832700b001bf06ecdd4dmr3890147oae.28.1693597633285; Fri, 01 Sep 2023 12:47:13 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 12/20] target/riscv: deprecate the 'any' CPU type Date: Fri, 1 Sep 2023 16:46:18 -0300 Message-ID: <20230901194627.1214811-13-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2001:4860:4864:20::29; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597724672100001 Content-Type: text/plain; charset="utf-8" The 'any' CPU type was introduced in commit dc5bd18fa5725 ("RISC-V CPU Core Definition"), being around since the beginning. It's not an easy CPU to use: it's undocumented and its name doesn't tell users much about what the CPU is supposed to bring. 'git log' doesn't help us either in knowing what was the original design of this CPU type. The closest we have is a comment from Alistair [1] where he recalls from memory that the 'any' CPU is supposed to behave like the newly added 'max' CPU. He also suggested that the 'any' CPU should be removed. The default CPUs are rv32 and rv64, so removing the 'any' CPU will have impact only on users that might have a script that uses '-cpu any'. And those users are better off using the default CPUs or the new 'max' CPU. We would love to just remove the code and be done with it, but one does not simply remove a feature in QEMU. We'll put the CPU in quarantine first, letting users know that we have the intent of removing it in the future. [1] https://lists.gnu.org/archive/html/qemu-devel/2023-07/msg02891.html Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- docs/about/deprecated.rst | 12 ++++++++++++ target/riscv/cpu.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 92a2bafd2b..7277d4e8a4 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -371,6 +371,18 @@ QEMU's ``vhost`` feature, which would eliminate the hi= gh latency costs under which the 9p ``proxy`` backend currently suffers. However as of to date no= body has indicated plans for such kind of reimplementation unfortunately. =20 +RISC-V 'any' CPU type ``-cpu any`` (since 8.2) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The 'any' CPU type was introduced back in 2018 and has been around since t= he +initial RISC-V QEMU port. Its usage has always been unclear: users don't k= now +what to expect from a CPU called 'any', and in fact the CPU does not do an= ything +special that isn't already done by the default CPUs rv32/rv64. + +After the introduction of the 'max' CPU type, RISC-V now has a good covera= ge +of generic CPUs: rv32 and rv64 as default CPUs and 'max' as a feature comp= lete +CPU for both 32 and 64 bit builds. Users are then discouraged to use the '= any' +CPU type starting in 8.2. =20 Block device options '''''''''''''''''''' diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 365c2b3b56..0dae259e02 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1522,6 +1522,11 @@ static void riscv_cpu_realize(DeviceState *dev, Erro= r **errp) RISCVCPUClass *mcc =3D RISCV_CPU_GET_CLASS(dev); Error *local_err =3D NULL; =20 + if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_ANY) !=3D NULL) { + warn_report("The 'any' CPU is deprecated and will be " + "removed in the future."); + } + cpu_exec_realizefn(cs, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597734; cv=none; d=zohomail.com; s=zohoarc; b=eZt/AYrT2wUlgH6jMTq/mi8DhLr0ySgHA+7CPyJP9HlPuxZHKutDwEl6zN6dJaAJPZOQnjh21LHHGOzoyL3T1AteAGgdweXuP6xZIIzR6lMulM23WDFLJelLuLY4MchCVyaPmAwRWqtWpi2GIV0GbLksVKmKkB5D475qeCj4elk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q6U/kJmT8i79eDIx8//Bo6UHXfVCePxHVAlASyqB6rg=; b=iQdjmqPXisno2r0wkqPx2g1kwlGDWI0vbm2lOxGyYE4K9W1PAmPA2rJIMUv27BSSTWzgZbJODBZsuKjR139o4JSNHNypvcGPmrzeLv4tDfDNKSN5ddan8WGocVSpe9MC/SS7O6JpALW0GDpGiXhkaJ7Ip/udBr3fGRy12Tqd5Bs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169359773469414.859058539029547; Fri, 1 Sep 2023 12:48:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA89-0000VL-FS; Fri, 01 Sep 2023 15:48:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA6z-00080b-Lc for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:25 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6w-0003H7-7P for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:21 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1c8d895a602so1514578fac.2 for ; Fri, 01 Sep 2023 12:47:17 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597636; x=1694202436; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q6U/kJmT8i79eDIx8//Bo6UHXfVCePxHVAlASyqB6rg=; b=NklMquHBS6DmPZhQBQUZjyJH31dO5pxnK1OuiBZDq4KfYVqg9vS0xCjgNMcRAyVZfF jcP4JtSNQYi5mdXnafw7c6nTSj2IoR8VAYrqp6LMVJvO7qUxA2l95Csse3syjW1Cwhl+ M4kr3OJXiPmA1IBuKd8FPtNmud//Z3B9h+DGAqPXeuFRGNYw10KUBFHxoq3/cjuM/O1j YV3/dSr4rAC5DRpNopSqB1gu94PWGFzgJPfTArOYtDbD+sfWOKHR88jdwvZ24c0FagR+ o3OfijGRZDSA+w9WcaGEWdjjn0yb9SP94gyByfXV5GVqGZAeJShBc3S4BFK2tlVlSUK2 rixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597636; x=1694202436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q6U/kJmT8i79eDIx8//Bo6UHXfVCePxHVAlASyqB6rg=; b=J/mle0LH+pnDhjIs032ilrGClKhA5GoVgqwbAEUWSmnANJv3HTJ3vKsdgsJb4pwzx3 nvOBHImrsOnDWuHXzdr6MGPnSFI0PEpmP831nYueK/Zp2FGkVz95dteBRry4p8mV7yHT DJvEwsXqw/mymp0piAMMh7tlAvzUZIgQWDnTy0jALlRC2nO5bfSEV2w9SXanHqOa3VUp 8FDYjRk96X8YQVicVrS63DVq/Q5aMUHHDUkeAOjiL5wgFmA6SHgNhpDsQ9Wqkv+UtMUo 3I9mOItZ1S8lBqD6sXq2uDKG0IBosPEwo5HwDll/HQHRD6rHvkpUkTVdHr7t9hgW0qzl mdfw== X-Gm-Message-State: AOJu0Yy+FC/qNt3uC+FtgVcipBWUMRyCYzKTcJFj3ODKTmgLn3zexwTR i9YU7lMoWULsjHeCjbdeYcDrSOa8IluxZpRRezE= X-Google-Smtp-Source: AGHT+IGCqXPjvCr3fiX7JRXdG0KLJYZLSdMCigpsIAzRriouv6WRWq5U3nKQVBi7AM1I6s9hkp+vtg== X-Received: by 2002:a05:6870:35cd:b0:1ba:3ff0:4934 with SMTP id c13-20020a05687035cd00b001ba3ff04934mr3725930oak.12.1693597636642; Fri, 01 Sep 2023 12:47:16 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 13/20] target/riscv/cpu.c: use offset in isa_ext_is_enabled/update_enabled Date: Fri, 1 Sep 2023 16:46:19 -0300 Message-ID: <20230901194627.1214811-14-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2001:4860:4864:20::34; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597736875100003 Content-Type: text/plain; charset="utf-8" We'll have future usage for a function where, given an offset of the struct RISCVCPUConfig, the flag is updated to a certain val. Change all existing callers to use edata->ext_enable_offset instead of 'edata'. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 0dae259e02..03e936348a 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,18 +162,17 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 -static bool isa_ext_is_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata) +static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 return *ext_enabled; } =20 -static void isa_ext_update_enabled(RISCVCPU *cpu, - const struct isa_ext_data *edata, bool = en) +static void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, + bool en) { - bool *ext_enabled =3D (void *)&cpu->cfg + edata->ext_enable_offset; + bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; =20 *ext_enabled =3D en; } @@ -1045,9 +1044,10 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RIS= CVCPU *cpu) =20 /* Force disable extensions if priv spec version does not match */ for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i]) && + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset) && (env->priv_ver < isa_edata_arr[i].min_version)) { - isa_ext_update_enabled(cpu, &isa_edata_arr[i], false); + isa_ext_update_enabled(cpu, isa_edata_arr[i].ext_enable_offset, + false); #ifndef CONFIG_USER_ONLY warn_report("disabling %s extension for hart 0x" TARGET_FMT_lx " because privilege spec version does not match", @@ -2346,7 +2346,7 @@ static void riscv_isa_string_ext(RISCVCPU *cpu, char = **isa_str, int i; =20 for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { - if (isa_ext_is_enabled(cpu, &isa_edata_arr[i])) { + if (isa_ext_is_enabled(cpu, isa_edata_arr[i].ext_enable_offset)) { new =3D g_strconcat(old, "_", isa_edata_arr[i].name, NULL); g_free(old); old =3D new; --=20 2.41.0 From nobody Thu May 16 16:07:57 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597816; cv=none; d=zohomail.com; s=zohoarc; b=XcHYqptIdt5ybGSK5Ua90SEL80Xvq+I++v/mLFEowlmddcddTTUMy0FgpWnhrXexia6V6Gy4rURSmZt3YwxRy/yLA5GYxnHscK24rkAh+ZfratSVFer9D584+zrTyeZqGKn9aGQV4lRYj22HLj4MvpeP8rBi/ir0urURk9DyEWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597816; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OBydyKFWUP98r2ON5JCRCiGHqIfQ4WnnATiO49oGAgM=; b=S+46Jz/24E1xCn3KWcp+Bv/QIC/d2IF4k/5s5UZwYcnfKKoUjvq+vuf/vWd0Vb4Tm8Yns05ME9NdyEn08Ynx5fuGnwLfp1Tjxjp13kRdM5Kxo+Dp/w/E91EocNxhj+/Db3ABPVSnvNO6IugizjKVGZnTXhLluLdg63IrVDcWcec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597816267887.7761969334393; Fri, 1 Sep 2023 12:50:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA7O-0008NL-UL; Fri, 01 Sep 2023 15:47:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA71-00080i-LI for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:25 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA6z-0003HY-04 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:22 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-5732481b22eso1511917eaf.3 for ; Fri, 01 Sep 2023 12:47:20 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597639; x=1694202439; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OBydyKFWUP98r2ON5JCRCiGHqIfQ4WnnATiO49oGAgM=; b=aZWjO1Vfygdcx3RpZ2lMOHt6FQWkajQzbDLCFOlycQhGukTVSud1/GyXQEiZRnHLdg dG8EAsevGtcSY8Ft4npFsBWocuPsFb1aOKXFGUFmR+uEPbzvjYvsdokm5oTwqvmMy4n4 GwN/uF9QLluuqhgFDh1KXt/BgBFSZ5/LcuJ0ieWvJOseoERnAY/8z5wi1GlUwVoh6hGZ pHQkihWQBW8M043h6ZTCGUblaFmSPNmHpSfkEgvuAzhgqCcF8VohJ8OEkFkLSBOiRLN8 kCLZKu3d8ANT8qClzwz0Kjuc/GVjXOIj7HVXrhagUk+W9J7pLXIy5zdBiXLIkm0hbMpw QEmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597639; x=1694202439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OBydyKFWUP98r2ON5JCRCiGHqIfQ4WnnATiO49oGAgM=; b=ZxG/kj1FfXf5kduq3uMA1ixwKl+TYgssxKIokOl4IB9PV80cPZZg5JLNs/6FWFsMkf iTlrbMV/T9onPOOn+A7ZGUe+bU05h2KQXk/h4wCQJ9r4o0J3qFgWcqKUtPB2MFnVpX47 FDZsG12MaujPvHZ76GUprg9EqiGuU3/pGOll4ir/I+MWdCvmmp2aGK4IXorzieUZx/HT Om+vPsiktAmoBJlqfL21+0gbOP5+/raNw6nZ8ys5vdNScmYSbSByJpdqsW9H47mxWGMz lW7ll24YI5fWzNonS6TzauUWGKxQ9UoHPDl/1720vlgkRb6l1aJnCFNriKb2PGk3nGYj d5ug== X-Gm-Message-State: AOJu0Yw2U7lwoHt3xCQzxexq6Hw9NJsUlnztiY1j0CKWkKuCIIYhfyWI eaAjfzmbhsLSW6Yh9Gk+4s3lvrLWONRWoQooOwk= X-Google-Smtp-Source: AGHT+IF2QVz1RHlILlhr7uQZwnFBRPIUbradhSaYELXrrLwdMKq309t2a7UWeL2zmfZhnFv2qdcojg== X-Received: by 2002:a4a:2a59:0:b0:56e:4dea:bc5c with SMTP id x25-20020a4a2a59000000b0056e4deabc5cmr3806150oox.8.1693597639740; Fri, 01 Sep 2023 12:47:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 14/20] target/riscv: make CPUCFG() macro public Date: Fri, 1 Sep 2023 16:46:20 -0300 Message-ID: <20230901194627.1214811-15-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597816805100001 Content-Type: text/plain; charset="utf-8" The RISC-V KVM driver uses a CPUCFG() macro that calculates the offset of a certain field in the struct RISCVCPUConfig. We're going to use this macro in target/riscv/cpu.c as well in the next patches. Make it public. Rename it to CPU_CFG_OFFSET() for more clarity while we're at it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/cpu.c | 2 +- target/riscv/cpu.h | 2 ++ target/riscv/kvm.c | 8 +++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 03e936348a..43c68e1792 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -48,7 +48,7 @@ struct isa_ext_data { }; =20 #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ - {#_name, _min_ver, offsetof(struct RISCVCPUConfig, _prop)} + {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 /* * From vector_helper.c diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 6ea22e0eea..577abcd724 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -62,6 +62,8 @@ const char *riscv_get_misa_ext_name(uint32_t bit); const char *riscv_get_misa_ext_description(uint32_t bit); =20 +#define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) + /* Privileged specification version */ enum { PRIV_VERSION_1_10_0 =3D 0, diff --git a/target/riscv/kvm.c b/target/riscv/kvm.c index c01cfb03f4..14763ec0cd 100644 --- a/target/riscv/kvm.c +++ b/target/riscv/kvm.c @@ -205,10 +205,8 @@ static void kvm_riscv_update_cpu_misa_ext(RISCVCPU *cp= u, CPUState *cs) } } =20 -#define CPUCFG(_prop) offsetof(struct RISCVCPUConfig, _prop) - #define KVM_EXT_CFG(_name, _prop, _reg_id) \ - {.name =3D _name, .offset =3D CPUCFG(_prop), \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ .kvm_reg_id =3D _reg_id} =20 static KVMCPUConfig kvm_multi_ext_cfgs[] =3D { @@ -285,13 +283,13 @@ static void kvm_cpu_set_multi_ext_cfg(Object *obj, Vi= sitor *v, =20 static KVMCPUConfig kvm_cbom_blocksize =3D { .name =3D "cbom_blocksize", - .offset =3D CPUCFG(cbom_blocksize), + .offset =3D CPU_CFG_OFFSET(cbom_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicbom_block_size) }; =20 static KVMCPUConfig kvm_cboz_blocksize =3D { .name =3D "cboz_blocksize", - .offset =3D CPUCFG(cboz_blocksize), + .offset =3D CPU_CFG_OFFSET(cboz_blocksize), .kvm_reg_id =3D KVM_REG_RISCV_CONFIG_REG(zicboz_block_size) }; =20 --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597729; cv=none; d=zohomail.com; s=zohoarc; b=EXufpJh1npmKLxMpELkw8Uyyaj8uV7N37cV/ojIcfpPmYoomRf2ea8P38+Yobjuv5faPcdJAmh1Jc72IcGzkLg54Ok2bl/cK7iYre4CVZVaVV5WqHosv8uK7Oxw6uj+GfwpnonhoQanXnvjWnw4fkaJqJq8Nvt0VTbDDEdXGLHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597729; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eZZ2U72EJggfHwx80fzT+1XQBGT3ahOCx1fEjDzEhhg=; b=h7dSTY19oVHFTMFYOc9boDnNx3cMkx7TmcPdS3O+JnlusLhioWJ/tYoP2VFYZLX26oHY7WQ0jPeNVokwulWaSwedo13iI4tNoja8d7xcHoHrTkpwmkjo9L17VIgjx4IkalzpItwxvp1jUR6GL0ZaBPrIC2WpGOp1gKTPXI3XvEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597729708645.6466157628763; Fri, 1 Sep 2023 12:48:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA89-0000VK-FT; Fri, 01 Sep 2023 15:48:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA75-00087K-Jz for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:29 -0400 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA73-0003IU-4h for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:27 -0400 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-572a7141434so1325302eaf.2 for ; Fri, 01 Sep 2023 12:47:23 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597643; x=1694202443; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eZZ2U72EJggfHwx80fzT+1XQBGT3ahOCx1fEjDzEhhg=; b=er4u2I9IHRPcQlGBhfhJn/9c+NhF+p8VR9WjV1A4RXmU/WKu0kHCkHdzQga7SGHEJl N3fTGV3s3C7i41qx+i5kOnhDdcczHW3TjCMA8hf3ygMIz+FdSGp97k1+CGBlQmuZDhSy x+CWYxZ5UVNo+IJxmqF8O9FIOMOscPPpbO4ShvYR1bp2ed+2yJmJE/kJ48gJLFFgdXIQ kJEh/1WlZ67jx2RJoUxoPzhrj8jufMtEC4rYqIJvOSV54bGrQTZqzE/YU0iK4gXQRpei J/mPn49Y92wHmN9H3H6Pw7DSxzh9+x08m5a/rNhmK2u1T8ubMxoJAS1NrLy8GYoQgYsh ZB/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597643; x=1694202443; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eZZ2U72EJggfHwx80fzT+1XQBGT3ahOCx1fEjDzEhhg=; b=BzHMNEvBxrf3Xr7EYIBZiDvKidk8/FcHo7j/gIx+VmxwgEyc3NHjDgkBd2UfJeFPp3 W6N8UwT/fNOvjnOpk135gH3ZgaqvqMR2jTt5e8gHZ5YrZyEJxz3OYLDsbhcPpSSZNbOu UCHcrlpP0kBM+ngKQBTEQ3ooO62wJauXM+6ExNsSkG2ibEpbe+l9qSZQoY7Pb4ZNvdO8 hE+BLU/0Ek4Agt+hyCchl5QzjeaOzP82GgU1G6IcrkM9kJHG3PsSFuT7FJCcx4uHLsKS uZ6/n9k0bjoh+PJjuC1Ta15en40VtI5oEZQXiy3KwGlzH0OuXkoEDagoOz+urOy9tkVq JM+w== X-Gm-Message-State: AOJu0Yw7wt2lgBmHuyEhEFxZLOQmzJyfwQD0nErwgwPfwnS0oi5zMpPh SFVk65apNfiGpeSzMg+BpPbjsFgWK66wSK1Wi3k= X-Google-Smtp-Source: AGHT+IFCO87LB/eOPdJf5GTIkUHjAJ4qn3GcBdk4MGIMu6eqGxil2reW0T7fkTGzQnoeAOE77WM8eQ== X-Received: by 2002:a4a:9d57:0:b0:56c:a41c:f264 with SMTP id f23-20020a4a9d57000000b0056ca41cf264mr3067611ook.8.1693597642755; Fri, 01 Sep 2023 12:47:22 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 15/20] target/riscv/cpu.c: introduce cpu_cfg_ext_auto_update() Date: Fri, 1 Sep 2023 16:46:21 -0300 Message-ID: <20230901194627.1214811-16-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c29; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597730699100001 Content-Type: text/plain; charset="utf-8" During realize() time we're activating a lot of extensions based on some criteria, e.g.: if (cpu->cfg.ext_zk) { cpu->cfg.ext_zkn =3D true; cpu->cfg.ext_zkr =3D true; cpu->cfg.ext_zkt =3D true; } This practice resulted in at least one case where we ended up enabling something we shouldn't: RVC enabling zca/zcd/zcf when using a CPU that has priv_spec older than 1.12.0. We're also not considering user choice. There's no way of doing it now but this is about to change in the next few patches. cpu_cfg_ext_auto_update() will check for priv version mismatches before enabling extensions. If we have a mismatch between the current priv version and the extension we want to enable, do not enable it. In the near future, this same function will also consider user choice when deciding if we're going to enable/disable an extension or not. For now let's use it to handle zca/zcd/zcf enablement if RVC is enabled. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 43c68e1792..a4876df5f4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -177,6 +177,43 @@ static void isa_ext_update_enabled(RISCVCPU *cpu, uint= 32_t ext_offset, *ext_enabled =3D en; } =20 +static int cpu_cfg_ext_get_min_version(uint32_t ext_offset) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(isa_edata_arr); i++) { + if (isa_edata_arr[i].ext_enable_offset !=3D ext_offset) { + continue; + } + + return isa_edata_arr[i].min_version; + } + + g_assert_not_reached(); +} + +static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, + bool value) +{ + CPURISCVState *env =3D &cpu->env; + bool prev_val =3D isa_ext_is_enabled(cpu, ext_offset); + int min_version; + + if (prev_val =3D=3D value) { + return; + } + + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { + /* Do not enable it if priv_ver is older than min_version */ + min_version =3D cpu_cfg_ext_get_min_version(ext_offset); + if (env->priv_ver < min_version) { + return; + } + } + + isa_ext_update_enabled(cpu, ext_offset, value); +} + const char * const riscv_int_regnames[] =3D { "x0/zero", "x1/ra", "x2/sp", "x3/gp", "x4/tp", "x5/t0", "x6/t1", "x7/t2", "x8/s0", "x9/s1", "x10/a0", "x11/a1", "x12/a2", "x13/a3", @@ -1268,12 +1305,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) =20 /* zca, zcd and zcf has a PRIV 1.12.0 restriction */ if (riscv_has_ext(env, RVC) && env->priv_ver >=3D PRIV_VERSION_1_12_0)= { - cpu->cfg.ext_zca =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } if (riscv_has_ext(env, RVD)) { - cpu->cfg.ext_zcd =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcd), true); } } =20 --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597829; cv=none; d=zohomail.com; s=zohoarc; b=KE8ljU/TJuHiQNFDmXt2UutAe43kAbh9VqnYCTBOe+CRK952h/X6Rc7IvW04HWK7iHnJzLKA8zvsZLUkEpJjTkjkgZolEAVHTzO5gOfm8HyvPhic7U4sNllnwUtkEzK1UkS7NgniRCV1sNeks2IRBn0qG6XxNXHxDg+X9z1d+LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597829; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=v023n2PbxiR5ip3T4K94HNm0FMcZR3bFuZyEZiJsIlY=; b=YYrVuWdQ6HbGdTNpCz5TFFrU86R82eYY8yU7MmCq49QL5V6ASZ6RqxKzUU0JGBvZa8+8jKpM56giZWD+tQux7JjUwOBVODirp8ws5ljWdr6jL1uj3dI5CLqBpQotcK36D1pWHX7dJF74/jg+Fu04d79isJZXVOyb4dZDrDK6yIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597829303575.066354854946; Fri, 1 Sep 2023 12:50:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA8b-0001L1-NC; Fri, 01 Sep 2023 15:49:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA77-0008DB-U3 for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:34 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA75-0003NC-Ai for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:29 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-572a7141434so1325320eaf.2 for ; Fri, 01 Sep 2023 12:47:26 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597646; x=1694202446; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v023n2PbxiR5ip3T4K94HNm0FMcZR3bFuZyEZiJsIlY=; b=fCQbC7bhNXzZhgSX6kiyCVlQxoxMrD2mOSGjLMqfXZIMDUeqxgovbAW+5HEaCdtXm+ 6Q6we4cbtJkStcNDJU57fu04dz7qMvXVSCFqXzJtjlet14UWhE7fXNxC4gXG8cNYpsQC G5BZ0gzIN90Mqv5DluBjV4NPZeHPbVhSkjybejc5t7kAU2BnHK0E/AI0q0casMTtf8bb kxiohDdkfpjhPsvy1Ts/ROrqK2+AzQfEc4pw52lAZ/9BtHSdKqqqlBfNqTslLzV3c30n JBGaBHLd8chK7I5Y413ZV2zTK03yKK7OFo4ncDTjjwy9vHdvcOqBZD1Vs3fBjGArvbcc Qv5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597646; x=1694202446; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v023n2PbxiR5ip3T4K94HNm0FMcZR3bFuZyEZiJsIlY=; b=c7JvAVQY23iZrZeBb26LT7lZfFeZe9yVJo3In79q6FggAVOekUDyETTclHWsO1ZvaU 3Sn3jq9CBQLi9DwfLZqB3S+3FAX8Ckj3vtb4bUjCjzFTd3NiUm/kt0PE0gJmlzbuHA59 HI3yxdhaz3uiKEggaqZy2ZJBjAb1QsW3RyHjDcKvB/JwgMt3imq0Xy7OAXmQBjgS5XsB 1cFXARczxGaiKTKnL4A5dJKTWx+hSI2FfMf/hVseitucbZx0UIMUtAZ+W8C+OTu3cEts mAl0eMcm+hneBWUYeaHtDqwDAEfm1EgjqI9xmUXmaT5xTHp0xp4tdSv+nDLGzQMlfIAQ N3Ew== X-Gm-Message-State: AOJu0YxRYnybCqQd1MhdIqx9/UNSFwp7uFqMuWxWUVVoojfBqp79J0xD bNtCCOjwA68suxDaeHdgn7ppiVvtmbW2/JDNMVg= X-Google-Smtp-Source: AGHT+IH0sLe5nw96Y9FJOg6fUZ4LK0xgMlXGc7Ho0GkFa/CDEPj4CUkt0g7nb5j83BUp53Tyn8p5NQ== X-Received: by 2002:a4a:3008:0:b0:56c:e856:8b2c with SMTP id q8-20020a4a3008000000b0056ce8568b2cmr3440718oof.9.1693597645789; Fri, 01 Sep 2023 12:47:25 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 16/20] target/riscv/cpu.c: use cpu_cfg_ext_auto_update() during realize() Date: Fri, 1 Sep 2023 16:46:22 -0300 Message-ID: <20230901194627.1214811-17-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2c; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597831465100003 Content-Type: text/plain; charset="utf-8" Let's change the other instances in realize() where we're enabling an extension based on a certain criteria (e.g. it's a dependency of another extension). We're leaving icsr and ifencei being enabled during RVG for later - we'll want to error out in that case. Every other extension enablement during realize is now done via cpu_cfg_ext_auto_update(). The end goal is that only cpu init() functions will handle extension flags directly via "cpu->cfg.ext_N =3D true|false". Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a4876df5f4..eeaf69599e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1193,7 +1193,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zfh) { - cpu->cfg.ext_zfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zfhmin), true); } =20 if (cpu->cfg.ext_zfhmin && !riscv_has_ext(env, RVF)) { @@ -1219,17 +1219,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 /* The V vector extension depends on the Zve64d extension */ - cpu->cfg.ext_zve64d =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64d), true); } =20 /* The Zve64d extension depends on the Zve64f extension */ if (cpu->cfg.ext_zve64d) { - cpu->cfg.ext_zve64f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve64f), true); } =20 /* The Zve64f extension depends on the Zve32f extension */ if (cpu->cfg.ext_zve64f) { - cpu->cfg.ext_zve32f =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zve32f), true); } =20 if (cpu->cfg.ext_zve64d && !riscv_has_ext(env, RVD)) { @@ -1243,7 +1243,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) } =20 if (cpu->cfg.ext_zvfh) { - cpu->cfg.ext_zvfhmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zvfhmin), true); } =20 if (cpu->cfg.ext_zvfhmin && !cpu->cfg.ext_zve32f) { @@ -1273,7 +1273,7 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) =20 /* Set the ISA extensions, checks should have happened above */ if (cpu->cfg.ext_zhinx) { - cpu->cfg.ext_zhinxmin =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); } =20 if ((cpu->cfg.ext_zdinx || cpu->cfg.ext_zhinxmin) && !cpu->cfg.ext_zfi= nx) { @@ -1294,12 +1294,12 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zce) { - cpu->cfg.ext_zca =3D true; - cpu->cfg.ext_zcb =3D true; - cpu->cfg.ext_zcmp =3D true; - cpu->cfg.ext_zcmt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zca), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmp), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcmt), true); if (riscv_has_ext(env, RVF) && env->misa_mxl_max =3D=3D MXL_RV32) { - cpu->cfg.ext_zcf =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zcf), true); } } =20 @@ -1367,26 +1367,26 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cp= u, Error **errp) } =20 if (cpu->cfg.ext_zk) { - cpu->cfg.ext_zkn =3D true; - cpu->cfg.ext_zkr =3D true; - cpu->cfg.ext_zkt =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkn), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkt), true); } =20 if (cpu->cfg.ext_zkn) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zkne =3D true; - cpu->cfg.ext_zknd =3D true; - cpu->cfg.ext_zknh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zkne), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknd), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zknh), true); } =20 if (cpu->cfg.ext_zks) { - cpu->cfg.ext_zbkb =3D true; - cpu->cfg.ext_zbkc =3D true; - cpu->cfg.ext_zbkx =3D true; - cpu->cfg.ext_zksed =3D true; - cpu->cfg.ext_zksh =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkb), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkc), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zbkx), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksed), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); } =20 /* --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597811; cv=none; d=zohomail.com; s=zohoarc; b=Ago68HWAJIzc6D2FqunDWiibqM12HTrUwzWqJnftF5vAw5TldaUhLv9f+jitGVSNjwVH57tJH4jCpxIVwsYPvEKUScdkJ7XQ2AgVRDKucJC5X2A1I4Cn6IzipLphfBgtigNtAbIcW3BM6i7oMPDvQ+fiDuE6U9G8lx9yocawhrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597811; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wFkFJsJ4TtbEkILkB1AffGcLrXdhj34ME24gwddGiUM=; b=Y8Z/zAEaj8qRH5w6HtOHtYUdffFmauOqaYyPFxJDTX/ckdDyD7soyrR33dkAN2kVB9CMCa97aA1rziFUP42We142meZTWGGmuFx7/WEDWRjGl/4ggIKaXqrFI0loDHKf8oxaAAs10sF5O8IjlY4SwQHQYoymjHF7R2NAI2EmnJo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597811379320.89999607310756; Fri, 1 Sep 2023 12:50:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA8e-0001aZ-Ae; Fri, 01 Sep 2023 15:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA7H-0008IB-ED for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:40 -0400 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA78-0003QO-CZ for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:39 -0400 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-571194584e2so1390698eaf.3 for ; Fri, 01 Sep 2023 12:47:30 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597649; x=1694202449; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wFkFJsJ4TtbEkILkB1AffGcLrXdhj34ME24gwddGiUM=; b=CNY9yg94+DnhsYR4WS+V20Hxt7oyyJ+5sz92WdfO4dEYn8gon+B8Ctmw0PmgV0x/An H8t6xxiRIun+E979U2YlQ5PP+fjQNDfZsAk1iP+E9a/MFd+CiMxPuwKHbhAmxFwUXt8/ UkT43gpDLQ657c8zksUYvqQgKAcVK2qPBAFa+LgrgtcbVzLvIqwBl2/h/Q9uDORvxNg8 06GQgCGHZ86ETbgxPaAUzgSXF0/dy0QVhQpu68qb6+FBiyFLszMjRJbdF78St/OCN8qq Cqgw9NRKsivF1q4g/dWcnBHomUtvXdV21QyoM00vTHEF1WQWjg6CFEOCmddoKeBZi0OY R6jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597649; x=1694202449; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wFkFJsJ4TtbEkILkB1AffGcLrXdhj34ME24gwddGiUM=; b=cYR+rhfYv1fZcpl2E6LDBeSNtBvPY0OBI7E6avNoaFqWxFr8GhXo/bDp7kKWhZ6PBO ZqVh4JAmitPiNoYrjrjhJJHJ1AOmBNcq7bu8tnXVWkfjnwzcJywyFjeGqBt1Ot2zpZYi QWNUb1x0TbbUX/HNc0WtlJDH2szNgCtk6+iv7jS73OBsu/jwTnME7U0rkKNCb03dR4uj AhN9/vyx+cHlcN9UH5VsoQE+j92HZkdPRD5O/3OaDQA0QVnqBOoUQdGR1+U4rjgwctlz x5+ZCRWld2WXWWSuGxWx3BWmAyqlfCFvrUeUP6r2rXKJGUEZWCTinF58Hnh9gLioN9Ux XFOg== X-Gm-Message-State: AOJu0YxTHgSuYSZbJwG12H2nmMDBIeE0aUkxcT5D8OUkOAKQ5HVuPmlt 3rz84IkJcNw3rF0dQrnFJlwJDfCV7gUQw2WF5Jw= X-Google-Smtp-Source: AGHT+IEXzBIDH5Oc1Az8WsNtajsU7jEloIT17AGxzJaegVKwiYrVAB8KRuKIpnPwpXNTms4cFtPx2w== X-Received: by 2002:a4a:de9a:0:b0:571:28d5:2c77 with SMTP id v26-20020a4ade9a000000b0057128d52c77mr3055614oou.5.1693597648968; Fri, 01 Sep 2023 12:47:28 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 17/20] target/riscv/cpu.c: introduce RISCVCPUMultiExtConfig Date: Fri, 1 Sep 2023 16:46:23 -0300 Message-ID: <20230901194627.1214811-18-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c2d; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597813309100001 Content-Type: text/plain; charset="utf-8" If we want to make better decisions when auto-enabling extensions during realize() we need a way to tell if an user set an extension manually. The RISC-V KVM driver has its own solution via a KVMCPUConfig struct that has an 'user_set' flag that is set during the Property set() callback. The set() callback also does init() time validations based on the current KVM driver capabilities. For TCG we would want a 'user_set' mechanic too, but we would look ad-hoc via cpu_cfg_ext_auto_update() if a certain extension was user set or not. If we copy what was made in the KVM side we would look for 'user_set' for one into 60+ extension structs spreaded in 3 arrays (riscv_cpu_extensions, riscv_cpu_experimental_exts, riscv_cpu_vendor_exts). We'll still need an extension struct but we won't be using the 'user_set' flag: - 'RISCVCPUMultiExtConfig' will be our specialized structure, similar to wh= at we're already doing with the MISA extensions in 'RISCVCPUMisaExtConfig'. DEFINE_PROP_BOOL() for all 3 extensions arrays were replaced by MULTI_EXT_CFG_BOOL(), a macro that will init our specialized struct; - the 'multi_ext_user_opts' hash will be used to store the offset of each extension that the user set via the set() callback, cpu_set_multi_ext_cfg(). For now we're just initializing and populating it - next patch will use it to determine if a certain extension was user set; - cpu_add_multi_ext_prop() is a new helper that will replace the qdev_property_add_static() calls that our macros are doing to populate user properties. The macro was renamed to ADD_CPU_MULTIEXT_PROPS_ARRAY() for clarity. Note that the non-extension properties in riscv_cpu_options[] still need to be declared via qdev(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 258 ++++++++++++++++++++++++++++----------------- 1 file changed, 159 insertions(+), 99 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index eeaf69599e..1ca034e6da 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -162,6 +162,9 @@ static const struct isa_ext_data isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0, ext_XVentanaC= ondOps), }; =20 +/* Hash that stores user set extensions */ +static GHashTable *multi_ext_user_opts; + static bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset) { bool *ext_enabled =3D (void *)&cpu->cfg + ext_offset; @@ -1718,6 +1721,8 @@ static void riscv_cpu_init(Object *obj) qdev_init_gpio_in(DEVICE(cpu), riscv_cpu_set_irq, IRQ_LOCAL_MAX + IRQ_LOCAL_GUEST_MAX); #endif /* CONFIG_USER_ONLY */ + + multi_ext_user_opts =3D g_hash_table_new(NULL, g_direct_equal); } =20 typedef struct RISCVCPUMisaExtConfig { @@ -1869,108 +1874,118 @@ static void riscv_cpu_add_misa_properties(Object = *cpu_obj) } } =20 -static Property riscv_cpu_extensions[] =3D { +typedef struct RISCVCPUMultiExtConfig { + const char *name; + uint32_t offset; + bool enabled; +} RISCVCPUMultiExtConfig; + +#define MULTI_EXT_CFG_BOOL(_name, _prop, _defval) \ + {.name =3D _name, .offset =3D CPU_CFG_OFFSET(_prop), \ + .enabled =3D _defval} + +static RISCVCPUMultiExtConfig riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ - DEFINE_PROP_BOOL("sscofpmf", RISCVCPU, cfg.ext_sscofpmf, false), - DEFINE_PROP_BOOL("Zifencei", RISCVCPU, cfg.ext_ifencei, true), - DEFINE_PROP_BOOL("Zicsr", RISCVCPU, cfg.ext_icsr, true), - DEFINE_PROP_BOOL("Zihintntl", RISCVCPU, cfg.ext_zihintntl, true), - DEFINE_PROP_BOOL("Zihintpause", RISCVCPU, cfg.ext_zihintpause, true), - DEFINE_PROP_BOOL("Zawrs", RISCVCPU, cfg.ext_zawrs, true), - DEFINE_PROP_BOOL("Zfa", RISCVCPU, cfg.ext_zfa, true), - DEFINE_PROP_BOOL("Zfh", RISCVCPU, cfg.ext_zfh, false), - DEFINE_PROP_BOOL("Zfhmin", RISCVCPU, cfg.ext_zfhmin, false), - DEFINE_PROP_BOOL("Zve32f", RISCVCPU, cfg.ext_zve32f, false), - DEFINE_PROP_BOOL("Zve64f", RISCVCPU, cfg.ext_zve64f, false), - DEFINE_PROP_BOOL("Zve64d", RISCVCPU, cfg.ext_zve64d, false), - DEFINE_PROP_BOOL("sstc", RISCVCPU, cfg.ext_sstc, true), - - DEFINE_PROP_BOOL("smstateen", RISCVCPU, cfg.ext_smstateen, false), - DEFINE_PROP_BOOL("svadu", RISCVCPU, cfg.ext_svadu, true), - DEFINE_PROP_BOOL("svinval", RISCVCPU, cfg.ext_svinval, false), - DEFINE_PROP_BOOL("svnapot", RISCVCPU, cfg.ext_svnapot, false), - DEFINE_PROP_BOOL("svpbmt", RISCVCPU, cfg.ext_svpbmt, false), - - DEFINE_PROP_BOOL("zba", RISCVCPU, cfg.ext_zba, true), - DEFINE_PROP_BOOL("zbb", RISCVCPU, cfg.ext_zbb, true), - DEFINE_PROP_BOOL("zbc", RISCVCPU, cfg.ext_zbc, true), - DEFINE_PROP_BOOL("zbkb", RISCVCPU, cfg.ext_zbkb, false), - DEFINE_PROP_BOOL("zbkc", RISCVCPU, cfg.ext_zbkc, false), - DEFINE_PROP_BOOL("zbkx", RISCVCPU, cfg.ext_zbkx, false), - DEFINE_PROP_BOOL("zbs", RISCVCPU, cfg.ext_zbs, true), - DEFINE_PROP_BOOL("zk", RISCVCPU, cfg.ext_zk, false), - DEFINE_PROP_BOOL("zkn", RISCVCPU, cfg.ext_zkn, false), - DEFINE_PROP_BOOL("zknd", RISCVCPU, cfg.ext_zknd, false), - DEFINE_PROP_BOOL("zkne", RISCVCPU, cfg.ext_zkne, false), - DEFINE_PROP_BOOL("zknh", RISCVCPU, cfg.ext_zknh, false), - DEFINE_PROP_BOOL("zkr", RISCVCPU, cfg.ext_zkr, false), - DEFINE_PROP_BOOL("zks", RISCVCPU, cfg.ext_zks, false), - DEFINE_PROP_BOOL("zksed", RISCVCPU, cfg.ext_zksed, false), - DEFINE_PROP_BOOL("zksh", RISCVCPU, cfg.ext_zksh, false), - DEFINE_PROP_BOOL("zkt", RISCVCPU, cfg.ext_zkt, false), - - DEFINE_PROP_BOOL("zdinx", RISCVCPU, cfg.ext_zdinx, false), - DEFINE_PROP_BOOL("zfinx", RISCVCPU, cfg.ext_zfinx, false), - DEFINE_PROP_BOOL("zhinx", RISCVCPU, cfg.ext_zhinx, false), - DEFINE_PROP_BOOL("zhinxmin", RISCVCPU, cfg.ext_zhinxmin, false), - - DEFINE_PROP_BOOL("zicbom", RISCVCPU, cfg.ext_icbom, true), - DEFINE_PROP_BOOL("zicboz", RISCVCPU, cfg.ext_icboz, true), - - DEFINE_PROP_BOOL("zmmul", RISCVCPU, cfg.ext_zmmul, false), - - DEFINE_PROP_BOOL("zca", RISCVCPU, cfg.ext_zca, false), - DEFINE_PROP_BOOL("zcb", RISCVCPU, cfg.ext_zcb, false), - DEFINE_PROP_BOOL("zcd", RISCVCPU, cfg.ext_zcd, false), - DEFINE_PROP_BOOL("zce", RISCVCPU, cfg.ext_zce, false), - DEFINE_PROP_BOOL("zcf", RISCVCPU, cfg.ext_zcf, false), - DEFINE_PROP_BOOL("zcmp", RISCVCPU, cfg.ext_zcmp, false), - DEFINE_PROP_BOOL("zcmt", RISCVCPU, cfg.ext_zcmt, false), - DEFINE_PROP_BOOL("zicond", RISCVCPU, cfg.ext_zicond, false), + MULTI_EXT_CFG_BOOL("sscofpmf", ext_sscofpmf, false), + MULTI_EXT_CFG_BOOL("Zifencei", ext_ifencei, true), + MULTI_EXT_CFG_BOOL("Zicsr", ext_icsr, true), + MULTI_EXT_CFG_BOOL("Zihintntl", ext_zihintntl, true), + MULTI_EXT_CFG_BOOL("Zihintpause", ext_zihintpause, true), + MULTI_EXT_CFG_BOOL("Zawrs", ext_zawrs, true), + MULTI_EXT_CFG_BOOL("Zfa", ext_zfa, true), + MULTI_EXT_CFG_BOOL("Zfh", ext_zfh, false), + MULTI_EXT_CFG_BOOL("Zfhmin", ext_zfhmin, false), + MULTI_EXT_CFG_BOOL("Zve32f", ext_zve32f, false), + MULTI_EXT_CFG_BOOL("Zve64f", ext_zve64f, false), + MULTI_EXT_CFG_BOOL("Zve64d", ext_zve64d, false), + MULTI_EXT_CFG_BOOL("sstc", ext_sstc, true), + + MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), + MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true), + MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false), + MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), + MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), + + MULTI_EXT_CFG_BOOL("zba", ext_zba, true), + MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), + MULTI_EXT_CFG_BOOL("zbc", ext_zbc, true), + MULTI_EXT_CFG_BOOL("zbkb", ext_zbkb, false), + MULTI_EXT_CFG_BOOL("zbkc", ext_zbkc, false), + MULTI_EXT_CFG_BOOL("zbkx", ext_zbkx, false), + MULTI_EXT_CFG_BOOL("zbs", ext_zbs, true), + MULTI_EXT_CFG_BOOL("zk", ext_zk, false), + MULTI_EXT_CFG_BOOL("zkn", ext_zkn, false), + MULTI_EXT_CFG_BOOL("zknd", ext_zknd, false), + MULTI_EXT_CFG_BOOL("zkne", ext_zkne, false), + MULTI_EXT_CFG_BOOL("zknh", ext_zknh, false), + MULTI_EXT_CFG_BOOL("zkr", ext_zkr, false), + MULTI_EXT_CFG_BOOL("zks", ext_zks, false), + MULTI_EXT_CFG_BOOL("zksed", ext_zksed, false), + MULTI_EXT_CFG_BOOL("zksh", ext_zksh, false), + MULTI_EXT_CFG_BOOL("zkt", ext_zkt, false), + + MULTI_EXT_CFG_BOOL("zdinx", ext_zdinx, false), + MULTI_EXT_CFG_BOOL("zfinx", ext_zfinx, false), + MULTI_EXT_CFG_BOOL("zhinx", ext_zhinx, false), + MULTI_EXT_CFG_BOOL("zhinxmin", ext_zhinxmin, false), + + MULTI_EXT_CFG_BOOL("zicbom", ext_icbom, true), + MULTI_EXT_CFG_BOOL("zicboz", ext_icboz, true), + + MULTI_EXT_CFG_BOOL("zmmul", ext_zmmul, false), + + MULTI_EXT_CFG_BOOL("zca", ext_zca, false), + MULTI_EXT_CFG_BOOL("zcb", ext_zcb, false), + MULTI_EXT_CFG_BOOL("zcd", ext_zcd, false), + MULTI_EXT_CFG_BOOL("zce", ext_zce, false), + MULTI_EXT_CFG_BOOL("zcf", ext_zcf, false), + MULTI_EXT_CFG_BOOL("zcmp", ext_zcmp, false), + MULTI_EXT_CFG_BOOL("zcmt", ext_zcmt, false), + MULTI_EXT_CFG_BOOL("zicond", ext_zicond, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 -static Property riscv_cpu_vendor_exts[] =3D { - DEFINE_PROP_BOOL("xtheadba", RISCVCPU, cfg.ext_xtheadba, false), - DEFINE_PROP_BOOL("xtheadbb", RISCVCPU, cfg.ext_xtheadbb, false), - DEFINE_PROP_BOOL("xtheadbs", RISCVCPU, cfg.ext_xtheadbs, false), - DEFINE_PROP_BOOL("xtheadcmo", RISCVCPU, cfg.ext_xtheadcmo, false), - DEFINE_PROP_BOOL("xtheadcondmov", RISCVCPU, cfg.ext_xtheadcondmov, fal= se), - DEFINE_PROP_BOOL("xtheadfmemidx", RISCVCPU, cfg.ext_xtheadfmemidx, fal= se), - DEFINE_PROP_BOOL("xtheadfmv", RISCVCPU, cfg.ext_xtheadfmv, false), - DEFINE_PROP_BOOL("xtheadmac", RISCVCPU, cfg.ext_xtheadmac, false), - DEFINE_PROP_BOOL("xtheadmemidx", RISCVCPU, cfg.ext_xtheadmemidx, false= ), - DEFINE_PROP_BOOL("xtheadmempair", RISCVCPU, cfg.ext_xtheadmempair, fal= se), - DEFINE_PROP_BOOL("xtheadsync", RISCVCPU, cfg.ext_xtheadsync, false), - DEFINE_PROP_BOOL("xventanacondops", RISCVCPU, cfg.ext_XVentanaCondOps,= false), +static RISCVCPUMultiExtConfig riscv_cpu_vendor_exts[] =3D { + MULTI_EXT_CFG_BOOL("xtheadba", ext_xtheadba, false), + MULTI_EXT_CFG_BOOL("xtheadbb", ext_xtheadbb, false), + MULTI_EXT_CFG_BOOL("xtheadbs", ext_xtheadbs, false), + MULTI_EXT_CFG_BOOL("xtheadcmo", ext_xtheadcmo, false), + MULTI_EXT_CFG_BOOL("xtheadcondmov", ext_xtheadcondmov, false), + MULTI_EXT_CFG_BOOL("xtheadfmemidx", ext_xtheadfmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadfmv", ext_xtheadfmv, false), + MULTI_EXT_CFG_BOOL("xtheadmac", ext_xtheadmac, false), + MULTI_EXT_CFG_BOOL("xtheadmemidx", ext_xtheadmemidx, false), + MULTI_EXT_CFG_BOOL("xtheadmempair", ext_xtheadmempair, false), + MULTI_EXT_CFG_BOOL("xtheadsync", ext_xtheadsync, false), + MULTI_EXT_CFG_BOOL("xventanacondops", ext_XVentanaCondOps, false), =20 DEFINE_PROP_END_OF_LIST(), }; =20 /* These are experimental so mark with 'x-' */ -static Property riscv_cpu_experimental_exts[] =3D { +static RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] =3D { /* ePMP 0.9.3 */ - DEFINE_PROP_BOOL("x-epmp", RISCVCPU, cfg.epmp, false), - DEFINE_PROP_BOOL("x-smaia", RISCVCPU, cfg.ext_smaia, false), - DEFINE_PROP_BOOL("x-ssaia", RISCVCPU, cfg.ext_ssaia, false), + MULTI_EXT_CFG_BOOL("x-epmp", epmp, false), + MULTI_EXT_CFG_BOOL("x-smaia", ext_smaia, false), + MULTI_EXT_CFG_BOOL("x-ssaia", ext_ssaia, false), =20 - DEFINE_PROP_BOOL("x-zvfh", RISCVCPU, cfg.ext_zvfh, false), - DEFINE_PROP_BOOL("x-zvfhmin", RISCVCPU, cfg.ext_zvfhmin, false), + MULTI_EXT_CFG_BOOL("x-zvfh", ext_zvfh, false), + MULTI_EXT_CFG_BOOL("x-zvfhmin", ext_zvfhmin, false), =20 - DEFINE_PROP_BOOL("x-zfbfmin", RISCVCPU, cfg.ext_zfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfmin", RISCVCPU, cfg.ext_zvfbfmin, false), - DEFINE_PROP_BOOL("x-zvfbfwma", RISCVCPU, cfg.ext_zvfbfwma, false), + MULTI_EXT_CFG_BOOL("x-zfbfmin", ext_zfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfmin", ext_zvfbfmin, false), + MULTI_EXT_CFG_BOOL("x-zvfbfwma", ext_zvfbfwma, false), =20 /* Vector cryptography extensions */ - DEFINE_PROP_BOOL("x-zvbb", RISCVCPU, cfg.ext_zvbb, false), - DEFINE_PROP_BOOL("x-zvbc", RISCVCPU, cfg.ext_zvbc, false), - DEFINE_PROP_BOOL("x-zvkg", RISCVCPU, cfg.ext_zvkg, false), - DEFINE_PROP_BOOL("x-zvkned", RISCVCPU, cfg.ext_zvkned, false), - DEFINE_PROP_BOOL("x-zvknha", RISCVCPU, cfg.ext_zvknha, false), - DEFINE_PROP_BOOL("x-zvknhb", RISCVCPU, cfg.ext_zvknhb, false), - DEFINE_PROP_BOOL("x-zvksed", RISCVCPU, cfg.ext_zvksed, false), - DEFINE_PROP_BOOL("x-zvksh", RISCVCPU, cfg.ext_zvksh, false), + MULTI_EXT_CFG_BOOL("x-zvbb", ext_zvbb, false), + MULTI_EXT_CFG_BOOL("x-zvbc", ext_zvbc, false), + MULTI_EXT_CFG_BOOL("x-zvkg", ext_zvkg, false), + MULTI_EXT_CFG_BOOL("x-zvkned", ext_zvkned, false), + MULTI_EXT_CFG_BOOL("x-zvknha", ext_zvknha, false), + MULTI_EXT_CFG_BOOL("x-zvknhb", ext_zvknhb, false), + MULTI_EXT_CFG_BOOL("x-zvksed", ext_zvksed, false), + MULTI_EXT_CFG_BOOL("x-zvksh", ext_zvksh, false), =20 DEFINE_PROP_END_OF_LIST(), }; @@ -1993,6 +2008,49 @@ static Property riscv_cpu_options[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + + isa_ext_update_enabled(RISCV_CPU(obj), multi_ext_cfg->offset, value); + + g_hash_table_insert(multi_ext_user_opts, + GUINT_TO_POINTER(multi_ext_cfg->offset), + (gpointer)value); +} + +static void cpu_get_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, + void *opaque, Error **errp) +{ + const RISCVCPUMultiExtConfig *multi_ext_cfg =3D opaque; + bool value =3D isa_ext_is_enabled(RISCV_CPU(obj), multi_ext_cfg->offse= t); + + visit_type_bool(v, name, &value, errp); +} + +static void cpu_add_multi_ext_prop(Object *cpu_obj, + RISCVCPUMultiExtConfig *multi_cfg) +{ + object_property_add(cpu_obj, multi_cfg->name, "bool", + cpu_get_multi_ext_cfg, + cpu_set_multi_ext_cfg, + NULL, (void *)multi_cfg); + + /* + * Set def val directly instead of using + * object_property_set_bool() to save the set() + * callback hash for user inputs. + */ + isa_ext_update_enabled(RISCV_CPU(cpu_obj), multi_cfg->offset, + multi_cfg->enabled); +} + #ifndef CONFIG_USER_ONLY static void cpu_set_cfg_unavailable(Object *obj, Visitor *v, const char *name, @@ -2012,12 +2070,13 @@ static void cpu_set_cfg_unavailable(Object *obj, Vi= sitor *v, } #endif =20 -static void riscv_cpu_add_qdev_prop_array(DeviceState *dev, Property *arra= y) +static void riscv_cpu_add_multiext_prop_array(Object *obj, + RISCVCPUMultiExtConfig *arra= y) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { - qdev_property_add_static(dev, prop); + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { + cpu_add_multi_ext_prop(obj, prop); } } =20 @@ -2040,11 +2099,11 @@ static void riscv_cpu_add_kvm_unavail_prop(Object *= obj, const char *prop_name) } =20 static void riscv_cpu_add_kvm_unavail_prop_array(Object *obj, - Property *array) + RISCVCPUMultiExtConfig *a= rray) { g_assert(array); =20 - for (Property *prop =3D array; prop && prop->name; prop++) { + for (RISCVCPUMultiExtConfig *prop =3D array; prop && prop->name; prop+= +) { riscv_cpu_add_kvm_unavail_prop(obj, prop->name); } } @@ -2079,8 +2138,6 @@ static void riscv_cpu_add_kvm_properties(Object *obj) */ static void riscv_cpu_add_user_properties(Object *obj) { - DeviceState *dev =3D DEVICE(obj); - #ifndef CONFIG_USER_ONLY riscv_add_satp_mode_properties(obj); =20 @@ -2092,10 +2149,13 @@ static void riscv_cpu_add_user_properties(Object *o= bj) =20 riscv_cpu_add_misa_properties(obj); =20 - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_extensions); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_options); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_vendor_exts); - riscv_cpu_add_qdev_prop_array(dev, riscv_cpu_experimental_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_extensions); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_vendor_exts); + riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts); + + for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { + qdev_property_add_static(DEVICE(obj), prop); + } } =20 /* @@ -2106,7 +2166,7 @@ static void riscv_init_max_cpu_extensions(Object *obj) { RISCVCPU *cpu =3D RISCV_CPU(obj); CPURISCVState *env =3D &cpu->env; - Property *prop; + RISCVCPUMultiExtConfig *prop; =20 /* Enable RVG, RVJ and RVV that are disabled by default */ set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597826; cv=none; d=zohomail.com; s=zohoarc; b=X2cNfGObPZzh//1ND0eT5i1Q8sgU0v95QMavajkTYHOuonaCbAHg1gWbnjMAc9De88I+wxeQT+IQFwVN4FZ65qRcK7Exyksvr821s2GLTLVLnEQiEljF8nAkeuRomWe0EHz6vLstMW4TPxtUaZ5E2NFKKe+kdLWLDOhFR/KygdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AyVWaMmj9Qc4zQK9znRP2XVU6qSjLOqppOf0U1ZHYzA=; b=aXe7vuNPqsAC6T61g6piTku4q6EP4u9RiO8Y54+gi89KXvwnCxRR3+2Lv9S8UKOP9ARUHzGxRMJbwE25kNXWoyjSpC7yWSUh5d8SEt++KJPUPxtvhQOJfz4LyY6ipXMksyjlD8oXaQPh/+9rcwOi8UpISYLbBXthRqsOn+uAPVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597826510981.7125907557507; Fri, 1 Sep 2023 12:50:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA8d-0001aI-Pg; Fri, 01 Sep 2023 15:49:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA7G-0008H6-Sv for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:39 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA7C-0003VY-Aj for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:38 -0400 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-57325fcd970so1403508eaf.1 for ; Fri, 01 Sep 2023 12:47:33 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597652; x=1694202452; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AyVWaMmj9Qc4zQK9znRP2XVU6qSjLOqppOf0U1ZHYzA=; b=aHsKOslDmcDhAqnU5FFU4ndGJIzLSZa0Lkpg9jGEr7fUQwiexE28K/zD2SMRGdgKDj ks6DsATHC1rP3wno7ZO4eyoyisAv0zOsno22jLSntYN0vibpYOiheDycMLvJ/9Dm+e5p srWTs4K6PuaXCCtsxyxeDFBHLH0AkRCIwNaYyqAB6uVEYz3gJ90/uTEAAbjWoCpfH+7+ On56KnJma3erTVDTGpFE795OXTJWl/3TCl/X2R4yyHRmVk+6wpCyRBkGPSootG17y4bv KsNwB1zy0XAF5byQxqyKSn2Y9/c7HdHVoYhRfPnsQAgKe4QPXGOFKA3G6V4SK+OJZlkw SzXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597652; x=1694202452; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AyVWaMmj9Qc4zQK9znRP2XVU6qSjLOqppOf0U1ZHYzA=; b=KNN/eTF09D14ndEsf4HN2inq+ZEY95KrgJIt6FOgGRiYhyeSYkYLBZ5HykOJvUJ9J0 L/Pgu2yels9wFAYz1V9fGW3rpQqRzLuUtrx3mTaJfZuUReTTouGIIttp1oQNE2Ddjvwl q9v5twTLpsqQKW+KUVFEagSOiQFz7/ik+nWG6u4N3QZmSdxeq9NpVTqly398gBupvjbO E+K3LhT8zQx2zMB8V6dSXn7kUU2AZgqKIpsesk3xKuKT9k6jMNLP6jF1nqeNwLkkVqr/ 4D7FxfiEGHOU7BnUtppA6m6GKN5/lDEOvIHAL1QkQmfGcwyi5A1Dvh48rZq6uJ/Sh2z9 5Pug== X-Gm-Message-State: AOJu0YwRa9WoL6JiRxX5q02EubOsY3NuQ7tSPlK19+Bao9mqHkJKzDBY UaJG/PL1PACaQ5OiC8b4uXk3vIUWB27nE0aoJPY= X-Google-Smtp-Source: AGHT+IGCG1teF2QQF3cqTHEjdGEfK7jLswLSeY/ao8jbXwDLwrb45C0l8SZqoNpBQeHj8HqC0UjR7Q== X-Received: by 2002:a4a:385b:0:b0:570:c0c3:8319 with SMTP id o27-20020a4a385b000000b00570c0c38319mr3797690oof.3.1693597652015; Fri, 01 Sep 2023 12:47:32 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 18/20] target/riscv: use isa_ext_update_enabled() in init_max_cpu_extensions() Date: Fri, 1 Sep 2023 16:46:24 -0300 Message-ID: <20230901194627.1214811-19-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c32; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc32.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597827921100005 Content-Type: text/plain; charset="utf-8" Before adding support to detect if an extension was user set we need to handle how we're enabling extensions in riscv_init_max_cpu_extensions(). object_property_set_bool() calls the set() callback for the property, and we're going to use this callback to set the 'multi_ext_user_opts' hash. This means that, as is today, all extensions we're setting for the 'max' CPU will be seen as user set in the future. Let's change set_bool() to isa_ext_update_enabled() that will just enable/disable the flag on a certain offset. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1ca034e6da..617b861258 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -2172,24 +2172,24 @@ static void riscv_init_max_cpu_extensions(Object *o= bj) set_misa(env, env->misa_mxl, env->misa_ext | RVG | RVJ | RVV); =20 for (prop =3D riscv_cpu_extensions; prop && prop->name; prop++) { - object_property_set_bool(obj, prop->name, true, NULL); + isa_ext_update_enabled(cpu, prop->offset, true); } =20 /* set vector version */ env->vext_ver =3D VEXT_VERSION_1_00_0; =20 /* Zfinx is not compatible with F. Disable it */ - object_property_set_bool(obj, "zfinx", false, NULL); - object_property_set_bool(obj, "zdinx", false, NULL); - object_property_set_bool(obj, "zhinx", false, NULL); - object_property_set_bool(obj, "zhinxmin", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zfinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zdinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinx), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zhinxmin), false); =20 - object_property_set_bool(obj, "zce", false, NULL); - object_property_set_bool(obj, "zcmp", false, NULL); - object_property_set_bool(obj, "zcmt", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zce), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmp), false); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcmt), false); =20 if (env->misa_mxl !=3D MXL_RV32) { - object_property_set_bool(obj, "zcf", false, NULL); + isa_ext_update_enabled(cpu, CPU_CFG_OFFSET(ext_zcf), false); } } =20 --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597868; cv=none; d=zohomail.com; s=zohoarc; b=YfEURS2FjjH4Ics72nQJBw3XeQSSinP1zTJXV55C1xLAawyICDWh/gXVcTWSWUn8UnVmQc6tYGFOuuu4oftX+3pXbTrxsaMBhdWF+CnzUFuA+uEC8D6kDAlD8Rae80UJjmpaLRjr493HUUyh21oE7g24T0k4mnE6JtT31jCFXLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597868; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/8Xn0jJXaX08JsG0kfWuawoA09AWxio90yQ9CPlI+S0=; b=emFZjCaoD6uaqSl7CCUVA4mid9kmzsIZjediTv0eqO6s2/91Al3RL4fU3m9OMya5Cxy8COP+cElxWj7KhEpDzpIdoZQu3zav14CmV7ekATjhSh85SDOfjpjWcxVT7YnqL/1z6w9W3rviN+6fIp3noXMYV9Go1528mfvyO77ur7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169359786884388.1677127935202; Fri, 1 Sep 2023 12:51:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA8g-0001hX-Pc; Fri, 01 Sep 2023 15:49:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA7I-0008Ik-AS for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:41 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA7E-0003Y7-IY for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:39 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-1c50438636fso1493236fac.1 for ; Fri, 01 Sep 2023 12:47:36 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597655; x=1694202455; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/8Xn0jJXaX08JsG0kfWuawoA09AWxio90yQ9CPlI+S0=; b=YcL5BDsu2a0BLRa2tUeN2MQknocTJaI6DoizVjhhfNRbAwABhOv06sLmTUJ4zD0ad3 Vsi+2OTsJMPtm4zygZm8UkscuFiqJhGvq3NtWGOgwei+avucdv60l5HGFosk+nefuu+K 5dxE5IdW/Cwr6fp3Gdzu1/hBRQ68+H/V+RO/SmaFAKRsOuHcEi2ML4jdcUTXcNtT4vAr B6fYezO7KqvgAk6+gTL/RtTD3yRX2ZTdET7qh6j0wfhW6bNiT2tJHWR93+lGAx3I5+tY iZ0h6P3W46nHpE+uzck57gMwAA9/s8pXYSs2RIIEZfaxCRKNKoEyNgElzfra8KtrMftK LW+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597655; x=1694202455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/8Xn0jJXaX08JsG0kfWuawoA09AWxio90yQ9CPlI+S0=; b=JQ3Kqu4zzaDenybo67oe4PcNM6TQoO+bWybEo7hCGZXFin5YPMnXDYhkMH3x53DyPl eZ7mGBs6Zvzwhy72xH6uJm3uODh318UGn/kl6G+inRmpijIZC+teVAtKcnJmuGp2/3Ch B4LJl0SJeW6GtukATqdr2+SL4uHNAqRv4E8P5cylw5yD+8zWNOquyRbfXo2x9DmS4NS2 1k6PnAuFNYuABxUdUycg5afojEU1WidtGwgGPJ727PmeZfXjHtBBQ07ET1uMzZ7kMZuK OgDa7DROVc5Yw4XECQgWF23W6/zchS7YoTwlGaEk9Y8qVKZAZxkE8r5s8cLjhHcKrxP6 iZew== X-Gm-Message-State: AOJu0Yz4nep4GtNUwafCE+ou01AOYsCJJD1tWWM+z1nKwoMq4L9XfVWI C59ZH8dk2s66OmOmPWLK5Z3tcMG6yQBSrH+wy+Y= X-Google-Smtp-Source: AGHT+IGtQ0kdoEq0f9R0v+qMeyj9EErATQyRBGW7ocgtlFt6w0GOtjaF7JUWduFxI+tJ7lyHDqrBMQ== X-Received: by 2002:a4a:cb03:0:b0:573:f620:ec80 with SMTP id r3-20020a4acb03000000b00573f620ec80mr2974341ooq.2.1693597655313; Fri, 01 Sep 2023 12:47:35 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 19/20] target/riscv/cpu.c: honor user choice in cpu_cfg_ext_auto_update() Date: Fri, 1 Sep 2023 16:46:25 -0300 Message-ID: <20230901194627.1214811-20-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2001:4860:4864:20::34; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597870888100003 Content-Type: text/plain; charset="utf-8" Add a new cpu_cfg_ext_is_user_set() helper to check if an extension was set by the user in the command line. Use it inside cpu_cfg_ext_auto_update() to verify if the user set a certain extension and, if that's the case, do not change its value. This will make us honor user choice instead of overwriting the values. Users will then be informed whether they're using an incompatible set of extensions instead of QEMU setting a magic value that works. The reason why we're not implementing user choice for MISA extensions right now is because, today, we do not silently change any MISA bit during realize() time (we do warn when enabling bits if RVG is enabled). We do that - a lot - with multi-letter extensions though, so we're handling the most immediate concern first. After this patch, we'll now error out if the user explicitly set 'zce' to t= rue and 'zca' to false: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,zce=3Dtrue,zca=3Dfalse -nog= raphic qemu-system-riscv64: Zcf/Zcd/Zcb/Zcmp/Zcmt extensions require Zca extension This didn't happen before because we were enabling 'zca' if 'zce' was enabl= ed regardless if the user set 'zca' to false. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 617b861258..78382cb5f2 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -195,6 +195,12 @@ static int cpu_cfg_ext_get_min_version(uint32_t ext_of= fset) g_assert_not_reached(); } =20 +static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) +{ + return g_hash_table_contains(multi_ext_user_opts, + GUINT_TO_POINTER(ext_offset)); +} + static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uint32_t ext_offset, bool value) { @@ -206,6 +212,10 @@ static void cpu_cfg_ext_auto_update(RISCVCPU *cpu, uin= t32_t ext_offset, return; } =20 + if (cpu_cfg_ext_is_user_set(ext_offset)) { + return; + } + if (value && env->priv_ver !=3D PRIV_VERSION_LATEST) { /* Do not enable it if priv_ver is older than min_version */ min_version =3D cpu_cfg_ext_get_min_version(ext_offset); @@ -1847,6 +1857,12 @@ static RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { MISA_CFG(RVG, false), }; =20 +/* + * We do not support user choice tracking for MISA + * extensions yet because, so far, we do not silently + * change MISA bits during realize() (RVG enables MISA + * bits but the user is warned about it). + */ static void riscv_cpu_add_misa_properties(Object *cpu_obj) { int i; --=20 2.41.0 From nobody Thu May 16 16:07:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1693597826; cv=none; d=zohomail.com; s=zohoarc; b=lpT4LE4nmJqqlKiuvdmNQLDTw5xGl7jBz7swysvripV8Ka6pLxoiqSe6w9J/mpv6AiqhESh2CpmqkWZRWiTjA0jFFSbWSTznOoJ9GQeDrTXDxsbq6gzQfeJo6jq0l6BXHIi3gJSCYk+E7P6w0NzB0la58xt2Drmx8ZbFPLzG4Fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693597826; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8z25vDdEG5IVz8Qg1vlTTXuRnbOaZ4PfGqqUDmV7Do8=; b=cFzGfEZW4HEYuusmmTOifcyxulhVQOWJa3C3p3Yx1xhQOYcmDST0004f1e/Bt0mT+GKsLgHIO3UQTEdXwZ9KkbUVROoW4RoprRmY4+MnapsBXpPr8KDVZFg5ZOgVwjZi51H/Xgp4e6hGyMO+XK+BP6Z93pA10XNuYa+HRNVs6zU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693597826501412.08407245209196; Fri, 1 Sep 2023 12:50:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qcA8f-0001de-Ko; Fri, 01 Sep 2023 15:49:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qcA7S-0008Sy-Mt for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:48:02 -0400 Received: from mail-oo1-xc34.google.com ([2607:f8b0:4864:20::c34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qcA7I-0003bB-3B for qemu-devel@nongnu.org; Fri, 01 Sep 2023 15:47:48 -0400 Received: by mail-oo1-xc34.google.com with SMTP id 006d021491bc7-5739972accdso179707eaf.1 for ; Fri, 01 Sep 2023 12:47:39 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.94.15.194]) by smtp.gmail.com with ESMTPSA id h187-20020a4a5ec4000000b00565d41ba4d0sm2303002oob.35.2023.09.01.12.47.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Sep 2023 12:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1693597658; x=1694202458; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8z25vDdEG5IVz8Qg1vlTTXuRnbOaZ4PfGqqUDmV7Do8=; b=EcX8TUfKN40yN3/J2Jb3HKnId4CZ196dCkijgICIC71FlSxCEc05+yTwEma+Rw0Seg zP0djSjQQTYUb2ZluWREHCjp71+cEtz9m6Rt+OQabiek16Zf417faNc9De9bNMV3v/Jn S5DTOBn5GiU2Z3ThGn21Fm7nxGlZBc2YtmQKqMGvzPo++cJ4zVVNaHEDffvitfOwaE4j +cvwe6O/lM6ym943AEDwWLkd6SBlWb1xz2RTaXZs+KO7256HRC/1ntn0uB18RXPSv6xe QbivMQloGxcLC6AQ3FfABD703+q/FEtoXct+NzJHugveC3yrmEIynL+L0jHeWOuovR6u d+YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693597658; x=1694202458; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8z25vDdEG5IVz8Qg1vlTTXuRnbOaZ4PfGqqUDmV7Do8=; b=BBfw/5twLASsYCDQVnPriPKPIKEuK+j09qmVzDk7gz9JCe+W0Qd3d8xE7B2sGh9jOd LcNKFQE5ullRjuWbyZytQDCeG6ERhIE1YjTMFFFu4ikjdNLByeMhQSF9uSsazvB7a8+y W0+JqxW+MYU/2fODeNSMtZcyIxzNn4U1xdBKY12oWwE/kmzivKhVaSDVavtyfMNrnlFC DdzSdkGS/R2kGYiRjdbVnQz805lg6yRbab2FHZa5a/jPRv6cy15IY+jWBfVVIpcwBRi/ Ifr+Uc01CgCVXdm64sUZHUMPNy/djWRPQ14Zyx1nzw523OkzkMCHomI8fRVL6eTnG9Na uPCw== X-Gm-Message-State: AOJu0YyzBZ037UekFX+2Ip8imoqbu9vuZlxXkoGKSIUvu05nZzt0Pkf/ tNWTBYCMEg3x7RWhVVMrJSChzV1e1ef7M5DTcw0= X-Google-Smtp-Source: AGHT+IGqD5rMIXpbQri84SQdEkjC9n4pFEl7VUkXz7nVtgSCIA5rGHxrLZCBwftIYeuJmmGW5O/02g== X-Received: by 2002:aca:2809:0:b0:3a7:507d:7b20 with SMTP id 9-20020aca2809000000b003a7507d7b20mr3078626oix.8.1693597658639; Fri, 01 Sep 2023 12:47:38 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v9 20/20] target/riscv/cpu.c: consider user option with RVG Date: Fri, 1 Sep 2023 16:46:26 -0300 Message-ID: <20230901194627.1214811-21-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230901194627.1214811-1-dbarboza@ventanamicro.com> References: <20230901194627.1214811-1-dbarboza@ventanamicro.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=2607:f8b0:4864:20::c34; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1693597827375100003 Content-Type: text/plain; charset="utf-8" Enabling RVG will enable a set of extensions that we're not checking if the user was okay enabling or not. And in this case we want to error out, instead of ignoring, otherwise we will be inconsistent enabling RVG without all its extensions. After this patch, disabling ifencei or icsr while enabling RVG will result in error: $ ./build/qemu-system-riscv64 -M virt -cpu rv64,g=3Dtrue,Zifencei=3Dfalse -= -nographic qemu-system-riscv64: RVG requires Zifencei but user set Zifencei to false Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 78382cb5f2..be1c028095 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1153,9 +1153,23 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu= , Error **errp) riscv_has_ext(env, RVA) && riscv_has_ext(env, RVF) && riscv_has_ext(env, RVD) && cpu->cfg.ext_icsr && cpu->cfg.ext_ifencei)) { + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_icsr)) && + !cpu->cfg.ext_icsr) { + error_setg(errp, "RVG requires Zicsr but user set Zicsr to fal= se"); + return; + } + + if (cpu_cfg_ext_is_user_set(CPU_CFG_OFFSET(ext_ifencei)) && + !cpu->cfg.ext_ifencei) { + error_setg(errp, "RVG requires Zifencei but user set " + "Zifencei to false"); + return; + } + warn_report("Setting G will also set IMAFD_Zicsr_Zifencei"); - cpu->cfg.ext_icsr =3D true; - cpu->cfg.ext_ifencei =3D true; + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_icsr), true); + cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_ifencei), true); =20 env->misa_ext |=3D RVI | RVM | RVA | RVF | RVD; env->misa_ext_mask |=3D RVI | RVM | RVA | RVF | RVD; --=20 2.41.0