From nobody Mon Feb 9 08:56:36 2026 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=1690496075; cv=none; d=zohomail.com; s=zohoarc; b=SFA0m5csWRqa0X9ewNFju9X/H98p4bXKURdgRfPTG++e/6h1Ls3A/cyA/Ci/UvSES6avMKnK69n5+xPJ8HbL6cwuHSFRmicKG1zbOjHcw9EtNW5PHuNbjkZImYQBc0ZTQRgIo7/0qyDhKVWfQnKEESwwX/WpNIZjsns0EO4qSWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690496075; 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=42PIj32buZwdPK3ft7O84bBw+UCjeAyJ2u2SBVdq0V4=; b=HorZT+lPz73ruaFqZF9s71AqVCtTh393Kvi2i/6qXiOemSsv/0Qbfsun0clLboX+m+xzgN1NRdyJ/P5dOM3P6jbE9a9AK3M3V2YvGJxqkLNa0sVUeXA2arJ+z39Snl2RRs51m8kMjHBIDkFtYBrxMpnMrucuuLOtKN0A8zQYVY8= 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 1690496075854731.5267684042444; Thu, 27 Jul 2023 15:14:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qP9Ax-0001Fn-Jt; Thu, 27 Jul 2023 18:09:39 -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 1qP9Aw-0001F3-1n for qemu-devel@nongnu.org; Thu, 27 Jul 2023 18:09:38 -0400 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qP9Au-0004rS-Bk for qemu-devel@nongnu.org; Thu, 27 Jul 2023 18:09:37 -0400 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-1bba7717d3bso1099028fac.1 for ; Thu, 27 Jul 2023 15:09:36 -0700 (PDT) Received: from grind.. (201-69-66-36.dial-up.telesp.net.br. [201.69.66.36]) by smtp.gmail.com with ESMTPSA id y136-20020a4a458e000000b0051134f333d3sm1070471ooa.16.2023.07.27.15.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 15:09:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1690495775; x=1691100575; 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=42PIj32buZwdPK3ft7O84bBw+UCjeAyJ2u2SBVdq0V4=; b=eFX0Ms8qtnR0TsGdWMsXaLRrg4Vnak/spflVDKZJXMWsb9BjTt8tGNz5EfYKioj2Zv TE+jVjjrCAZAz7fwhh1Cq+EbeYJozeMIlJ4r9VQdkEuSoIGNJeyCG98YhkFiKK/rRE9y ptK48exymhzZcYm1RkH1XHKQEpil10OgPId7V5O3PvRvz2Tt129JjgE0AAtigAm7mFHT BRj3CbBogalyvALbKnkwosPAQBSfwXO53O0YR8uo/bDNTJEwQosh5SBNZ+xrFopgiqiq 44S+n8BCPW1IaZqvKzP7WxKi/ucoHDR/BwyLxeKbAly+/+SsDEe3CPFWBkYhXwrXgf1e dGUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690495775; x=1691100575; 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=42PIj32buZwdPK3ft7O84bBw+UCjeAyJ2u2SBVdq0V4=; b=Ur8PSuV/x2XHBCRKQL612bYDs2B69HMF2PgTh4HdsZFlS5LfMi1Rupd/lDY2AoNNOx qNh9KRTl+zedDkGI6MV74dMnNqYYsi9Ja8dYYqD5Ps/v0xSBgPDymwPc8TBZVhSA/xHX iJrDnwsnrYLNqsZ9OHCp+I9cGd2tIfW11SoxFp6FLeMvPD1ls9s8byD09w2i5T0IVfn5 2h5/oQ3BvoT64KcFpZnoo5ofhMpRsaMyfPM5/BOWjo9wucJe+0Xf57tJkjpDBcRoVK1D KHmFFpDYZn7t8CCkTfPWHZcASS90/IH+AHKoqWMoxUDzypCzOk9Se5FwlyIeH961ZsrD 5zmw== X-Gm-Message-State: ABy/qLb+xzVpZtEo53gzMoEeNDwayrdJqtWcniv8JdQyNQI/rOsuVxzB Y0vWZZcGG4nMCEpF8iSjHmN1PDBr5s5y7EQi7u1Gkw== X-Google-Smtp-Source: APBJJlGf3DCjXUhInbVH4d5jTNT3TlV4WG2buaMqY9lHhtyijXYizfLf3vAwvRkEhXAze4ny0MA7VQ== X-Received: by 2002:a05:6870:b155:b0:1bb:9b40:268 with SMTP id a21-20020a056870b15500b001bb9b400268mr790815oal.44.1690495775100; Thu, 27 Jul 2023 15:09: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, Daniel Henrique Barboza Subject: [PATCH v6 01/12] target/riscv/cpu.c: split CPU options from riscv_cpu_extensions[] Date: Thu, 27 Jul 2023 19:09:16 -0300 Message-ID: <20230727220927.62950-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230727220927.62950-1-dbarboza@ventanamicro.com> References: <20230727220927.62950-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::2a; envelope-from=dbarboza@ventanamicro.com; helo=mail-oa1-x2a.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1690496076520100001 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 --- 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 921c19e6cd..61bce2dc55 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1759,7 +1759,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), @@ -1771,15 +1770,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), @@ -1810,9 +1802,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 @@ -1856,6 +1846,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, @@ -1924,6 +1929,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