From nobody Sat May 18 14:01:39 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=1696598575; cv=none; d=zohomail.com; s=zohoarc; b=V78i8PKPMMaKneSr6f8TLDGK93Y2xPxgW9zxQF7S+xf5Ih7HRvC2mV0C5EubICXcoU3ID2ctjpt1Uy7i/SCwGFDnwRON4JAUGn8exYehBqImPRMdbFjC0qIgo8KB96OSw8riNmH5LK2dqr/xWe1aBY+ItaKBpNBjNK3jUT/4b1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598575; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NMVHuyiFsO42tjOxhFdYGTRZuQvgsaSYtjyQZSpJNtk=; b=X7G27+ZAvMTLsC98sJFchhSKX4yEg3DYR4vmze65246sn8ABAB2mj6k8QxR06tRZ5Cqs6rUv+djJl3IM3+mpMsndTWvIc9+pDeS6FAQtixsHM3i4ad2v+7rwgjRkQDI3fVrb4bklPK9iS6Fi6sFtGNGb1H+m7vFXkAa0IpqKhFM= 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 1696598575712340.538930132524; Fri, 6 Oct 2023 06:22:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmI-0005vX-HC; Fri, 06 Oct 2023 09:22: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 1qokm4-0005sf-DM for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:48 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokm1-00037I-Tw for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:47 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1c735473d1aso16472885ad.1 for ; Fri, 06 Oct 2023 06:21:45 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598504; x=1697203304; 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=NMVHuyiFsO42tjOxhFdYGTRZuQvgsaSYtjyQZSpJNtk=; b=Kwib4899l1QuxYp3brFTxtyOUaCVfqYr6uZMb5NuHlXnBsYhdvhtXR3zvotM25OCan RHEp0TqROZzE88m+mEG6VLzujifZtg/Y5pekfLE4rJa3eqwwhmrFkWZUBEHu4SR1kYOY QGuODtp1j2euKIX8wmqBD0bqTmBR3e425uPkKSP6aDPK6eskjktTRH+eMnP3Q8U9DxO9 G+tzQ83zOCzFNsxmkjyClXZhvsapEADTYbAzhJ6PE3cAS4Tf0nLSTZn9x/mDWru8YtZ1 ojkwKTsOQrL5x9nUwsTLykLwgnHhAQstSQ3H8XJz/EtIlU1PAxaktmUmqjy9qSyguoyM yxbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598504; x=1697203304; 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=NMVHuyiFsO42tjOxhFdYGTRZuQvgsaSYtjyQZSpJNtk=; b=Yq43InljTMkzQ3A7HsKihk8zIdQn/HPgFUQGtchXSZ5TQl2yhq0V34etC5LKLk6Ag1 JSVo6GwkP39kmxkkKnksy+5uYS5da5ayAT4DnbWZLlwOWgZaIxTZNQFkBlWwQM+EBCYD 7JutD6Ql5LW2efKHv/Y9sgRYQAhEHixj6W3X4a0/u1OdYbbBhDSyr96A2wBzJGYBJJ0u tMfD8qwocr9nhr831wNEL3yCl4FfUYqYTu5n/h14jO+YmJpgsl0D71YvNcRZXlVfCg3L oZt9SmvvBIeNbad5jsbRNz0Enjh79G31pgv18W7kPOXLtIgjpQ/ocHRa2CzjmdC8KSh7 C1dA== X-Gm-Message-State: AOJu0YxhLjlsAIMS5QXxVCra02eOuwW92LfGRF1Nqc+grXIkAYTWAWMF lR/i9Ns+MAT2fmXAuMVS05jgTBC0U6NEri4zSa8= X-Google-Smtp-Source: AGHT+IHXubwCsYypi86M5fRc36Q851Bd3TVtsIiIzN7COwCHwcQARNg22kWD/dqiCXKn81TfxJr2aQ== X-Received: by 2002:a17:902:d485:b0:1c8:791c:d782 with SMTP id c5-20020a170902d48500b001c8791cd782mr8151288plg.29.1696598504016; Fri, 06 Oct 2023 06:21:44 -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 v2 01/10] target/riscv/cpu.c: add zicntr extension flag Date: Fri, 6 Oct 2023 10:21:25 -0300 Message-ID: <20231006132134.1135297-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::632; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x632.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: 1696598578110100005 Content-Type: text/plain; charset="utf-8" zicntr is the Base Counters and Timers extension described in chapter 12 of the unprivileged spec. It describes support for RDCYCLE, RDTIME and RDINSTRET. QEMU already implements it way before it was a discrete extension. zicntr is part of the RVA22 profile, so let's add it to QEMU to make the future profile implementation flag complete. Given than it represents an already existing feature, default it to 'true'. Change the realize() time validation to disable it in case its dependency (icsr) isn't present. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 7 +++++++ target/riscv/cpu_cfg.h | 1 + target/riscv/tcg/tcg-cpu.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 521bb88538..8783a415b1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -79,6 +79,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zicbom, PRIV_VERSION_1_12_0, ext_icbom), ISA_EXT_DATA_ENTRY(zicboz, PRIV_VERSION_1_12_0, ext_icboz), ISA_EXT_DATA_ENTRY(zicond, PRIV_VERSION_1_12_0, ext_zicond), + ISA_EXT_DATA_ENTRY(zicntr, PRIV_VERSION_1_12_0, ext_icntr), ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_icsr), ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei), ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl), @@ -1265,6 +1266,12 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), =20 + /* + * Always default true - we'll disable it during + * realize() if needed. + */ + MULTI_EXT_CFG_BOOL("zicntr", ext_icntr, true), + MULTI_EXT_CFG_BOOL("zba", ext_zba, true), MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), MULTI_EXT_CFG_BOOL("zbc", ext_zbc, true), diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 0e6a0f245c..671b8c7cb8 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -62,6 +62,7 @@ struct RISCVCPUConfig { bool ext_zksh; bool ext_zkt; bool ext_ifencei; + bool ext_icntr; bool ext_icsr; bool ext_icbom; bool ext_icboz; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 08b806dc07..df187bc143 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -542,6 +542,10 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) cpu_cfg_ext_auto_update(cpu, CPU_CFG_OFFSET(ext_zksh), true); } =20 + if (cpu->cfg.ext_icntr && !cpu->cfg.ext_icsr) { + cpu->cfg.ext_icntr =3D false; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need. --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598575; cv=none; d=zohomail.com; s=zohoarc; b=hCKo4rkP/ny798Bc7RWxeMAJOxnBOs4EH1yDZsi8e2jJxiYCgCswyAT2tYCRGD1fzq6ToMncflk3mheQE6hRQGLB1FydsOjUkeb3KmkIdfipwCnDMWh2hxwc2Wztmc2uAIhQ4m5+46Ng9/WogZse+uf4FAK2L6Rad5rvAC9Joc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598575; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JbnzSkOzkT7RwUBPFn5o2jf/o1bS6Xd4GXhN/0XZO6w=; b=kyi79VvyBJhE3H+wGL0fMcwlv+osEXddny3gHD3E26kn31GYwinOuhr5sv1XJfdTQSCh7pXE64OogHw22MpNXDKQ3l7MEf4ynSfMnDATgw8j9eJObiwyHUAO0UJEKCP240Qiq9FfQ5Sw1IgA02TwJ7YtyBxZxM8XlMv+r8/jqNk= 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 1696598575452545.4946087601204; Fri, 6 Oct 2023 06:22:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmL-0005xv-2I; Fri, 06 Oct 2023 09:22: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 1qokm6-0005t1-JW for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:51 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokm4-00037y-VQ for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:50 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c0ecb9a075so15934635ad.2 for ; Fri, 06 Oct 2023 06:21:48 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598507; x=1697203307; 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=JbnzSkOzkT7RwUBPFn5o2jf/o1bS6Xd4GXhN/0XZO6w=; b=Iq2pItOkxqUbcxImtrNNsXaT82Mz98lTvvcTiJd9alC91Ry2AvccoDNtfkKSix+w6E kEbND5Mdpyc+4+yuJhhw+OQwnDI9Mr4UyuIgrhnWUOkJ3tE4be/YFvKvi5kbLlkuO1hC GOw3yIhBPPXboy2/VmxN04BPJtDd5syjKC3CQ20nDWSnN1fjAZ4/m7OqKsukRBNVH56U HX+qLIB9HVrUFX6jfV1Lkma+khjsce5DlfnIsO8lfe8l3rsdlsftufjL7eIrkc1bZQP4 Vx6Ilp5vzGrG0qK2vw/80yFfBaiA89BKHJHLRlX10nEFX3HrK/8MyhSclPivDEkbT+vp o6dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598507; x=1697203307; 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=JbnzSkOzkT7RwUBPFn5o2jf/o1bS6Xd4GXhN/0XZO6w=; b=e8p6bDP3mc2Wvs+K0ZRRt9OnnEkiHqGrVHf03ElGZpiHTG4OHBhXjyR6ZJJa2wSWri /upDqt32EgDvDoRwHA4Lgkr+5+gE5yNZjiKHKFc2pnBLFuObVUMQsKJ9XvvklCHF4dbL vQFq41rBh0wJ2IfoTmhIWN8KqbtoIblnQRCeIDkSY0BxQAzK1tY7Bkbhhy9mMTe2XE9q S52bnNaRePCzmAAXfNWtw3gSoZBLANVLbn7e3RhwrnaIV2TAvT+cKwFYZg+hhSeR+E7B eof8B4YYEJ/fGlwU4j0IfTRZgoDU0BnBPLE67L3INEOmeGYQiFpKR0z7r6wKmNpK/TVi mRHw== X-Gm-Message-State: AOJu0Yzvv1Kllll9D8yS/Q9PiSeMHECKRZBJfpjYc/EIgbBYsVOKYiol pet9EnOkYGqK9gbLyFXg4Akjn/uWoW4f3WpTHrk= X-Google-Smtp-Source: AGHT+IEuWQUsU+YzhNksQebgak8RSI7NuLrQlNJSb/2TFUNbasH9gUN5hpXa+jQIVH6Oq/FifQ9yJg== X-Received: by 2002:a17:903:184:b0:1c8:8f61:967b with SMTP id z4-20020a170903018400b001c88f61967bmr1482760plg.3.1696598507097; Fri, 06 Oct 2023 06:21:47 -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 v2 02/10] target/riscv/cpu.c: add zihpm extension flag Date: Fri, 6 Oct 2023 10:21:26 -0300 Message-ID: <20231006132134.1135297-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::635; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x635.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: 1696598577946100001 Content-Type: text/plain; charset="utf-8" zihpm is the Hardware Performance Counters extension described in chapter 12 of the unprivileged spec. It describes support for 29 unprivileged performance counters, hpmcounter3-hpmcounter21. As with zicntr, QEMU already implements zihpm before it was even an extension. zihpm is also part of the RVA22 profile, so add it to QEMU to complement the future future profile implementation. Default it to 'true' since it was always present in the code. Change the realize() time validation to disable it in case 'icsr' isn't present and if there's no hardware counters (cpu->cfg.pmu_num is zero). Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 4 +++- target/riscv/cpu_cfg.h | 1 + target/riscv/tcg/tcg-cpu.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 8783a415b1..b3befccf89 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -84,6 +84,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zifencei, PRIV_VERSION_1_10_0, ext_ifencei), ISA_EXT_DATA_ENTRY(zihintntl, PRIV_VERSION_1_10_0, ext_zihintntl), ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause), + ISA_EXT_DATA_ENTRY(zihpm, PRIV_VERSION_1_12_0, ext_ihpm), ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul), ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa), @@ -1267,10 +1268,11 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[]= =3D { MULTI_EXT_CFG_BOOL("svpbmt", ext_svpbmt, false), =20 /* - * Always default true - we'll disable it during + * Always default true - we'll disable them during * realize() if needed. */ MULTI_EXT_CFG_BOOL("zicntr", ext_icntr, true), + MULTI_EXT_CFG_BOOL("zihpm", ext_ihpm, true), =20 MULTI_EXT_CFG_BOOL("zba", ext_zba, true), MULTI_EXT_CFG_BOOL("zbb", ext_zbb, true), diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 671b8c7cb8..cf228546da 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -66,6 +66,7 @@ struct RISCVCPUConfig { bool ext_icsr; bool ext_icbom; bool ext_icboz; + bool ext_ihpm; bool ext_zicond; bool ext_zihintntl; bool ext_zihintpause; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index df187bc143..731192bafc 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -546,6 +546,10 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) cpu->cfg.ext_icntr =3D false; } =20 + if (cpu->cfg.ext_ihpm && (!cpu->cfg.ext_icsr || cpu->cfg.pmu_num =3D= =3D 0)) { + cpu->cfg.ext_ihpm =3D false; + } + /* * Disable isa extensions based on priv spec after we * validated and set everything we need. --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598663; cv=none; d=zohomail.com; s=zohoarc; b=lzfdCaD3OqBn85hiiLAlchC4Rdkz4puF9NwIUSnXmMQevYH9UtaPoij4Lmjxh4NXFYkK+opGrhl6Nc7TY0gieARvYQlq2X1WTl+q0wakiEZb1a8Kz+NFIOSQh4lj+AmmCbfVFI0JPX+Y4v4Jp5zMGzjZ+7sFJWUlhJOFMAZ2nx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598663; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rvFPTIiAXaXHOXezY7X5+ACmqmm2s3KN/IMfdAwxSwI=; b=eZV6riHvkUBJWJZKgXOJ9qKtlwkfeK0422TAJHOS9+3avfSNnKpPZWzdg6894QeZnBIQGVrLZ+fi7h/Zjk432le2nqFL1oIbU+hvlHOi5lxxNoUEme7vSbvSXwKqACFMVlqjMm3uxdJKMK8vln0Y9UKkCeQ9QU1aB4MvNhKE8QM= 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 1696598663717510.0548854981572; Fri, 6 Oct 2023 06:24:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmP-00061O-Vs; Fri, 06 Oct 2023 09:22:10 -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 1qokm9-0005tU-I4 for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:56 -0400 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokm7-00038q-Kf for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:53 -0400 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-578e33b6fb7so1476102a12.3 for ; Fri, 06 Oct 2023 06:21:51 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598510; x=1697203310; 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=rvFPTIiAXaXHOXezY7X5+ACmqmm2s3KN/IMfdAwxSwI=; b=M1M+ER2h79xQu/lLD/h47uDVpAnifngOeK6ouDYw4sDW5oB7kxhnzo+u9y9hnVy/XD MCYxrCJaMFO+Du4lsncNS3MtQvJxwYem+xxsdT2j/hkZgMVEylT/zbmEmjZxkVnqA3k5 KBaQ7bkEc6a9edPgv+qyjxPs6F1Iwk2SLFnSNyCMTRbafwvN/FNfUQfOfhQ7dW9/h1ar /dLxuhLWp+pe1rEwMg8pTmdE+yRIi6tTvRNXFTGlp3SjrkeAcYBgtr/C+N5/g7v0TrTb FFt8a7QIkYjGwqrEroHudmiKDlxHV4F30yAcM9LM6IR69KbaO2uPOa0gwX9RQgS3ksX3 43bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598510; x=1697203310; 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=rvFPTIiAXaXHOXezY7X5+ACmqmm2s3KN/IMfdAwxSwI=; b=lnlh+yCeFKpbhRnSGfIMOh++J2moMaUoJyjKF1WQyH2mkIrlrK0qpBKM3HlKYXkmij O2odqUaTP5SXhR33qC7ezvxw0tQig0Cm6d3Wy65amCR/7GKyKGASSaBvdYSL503MwHEK HCi99jS4JPYcp03hOz0Vjo02nmra8Fy1vAMnpP52fvbYSMc2BCTvGb16v8BxVEFtUmSH y+Uh5GXCe+qeXrqvZe8fPdzw8BDhTADE90Fr0vqK20ba1I8vL+QUVxy/uONzTW4WQ14H CpU5qCYmdTRlU/KE6+1Lj+gZ3Z5wCJyIHjTbhV/+s/9nqgqs37OjkdP5B7sveztxCoLn 6/0w== X-Gm-Message-State: AOJu0YzNsTEcM7mfstZPNKaJlh/oKnTv2D9kV+jXkz/08hm6Sh1/G/Ui oli8zmgIY6+un2TVci9jIloxZGFTa61al5OAo+Y= X-Google-Smtp-Source: AGHT+IGuSdAB8YsPPrxavCT2IzRuDtsih4P0NRvM4LngbRB7DO18RYhXDuJtAsYhO38qF31XubTIJw== X-Received: by 2002:a05:6a21:a5aa:b0:15d:fc71:1b9e with SMTP id gd42-20020a056a21a5aa00b0015dfc711b9emr10932126pzc.49.1696598509884; Fri, 06 Oct 2023 06:21: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, Daniel Henrique Barboza Subject: [PATCH v2 03/10] target/riscv: add rva22u64 profile definition Date: Fri, 6 Oct 2023 10:21:27 -0300 Message-ID: <20231006132134.1135297-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::52e; envelope-from=dbarboza@ventanamicro.com; helo=mail-pg1-x52e.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: 1696598664187100001 Content-Type: text/plain; charset="utf-8" The rva22U64 profile, described in: https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva22-profi= les Contains a set of CPU extensions aimed for 64-bit userspace applications. Enabling this set to be enabled via a single user flag makes it convenient to enable a predictable set of features for the CPU, giving users more predicability when running/testing their workloads. QEMU implements all possible extensions of this profile. The exception is Zicbop (Cache-Block Prefetch Operations) that is not available since QEMU RISC-V does not implement a cache model. For this same reason all the so called 'synthetic extensions' described in the profile that are cache related are ignored (Za64rs, Zic64b, Ziccif, Ziccrse, Ziccamoa, Zicclsm). An abstraction called RISCVCPUProfile is created to store the profile. 'ext_offsets' contains mandatory extensions that QEMU supports. Same thing with the 'misa_ext' mask. Optional extensions must be enabled manually in the command line if desired. The design here is to use the common target/riscv/cpu.c file to store the profile declaration and export it to the accelerator files. Each accelerator is then responsible to expose it (or not) to users and how to enable the extensions. Next patches will implement the profile for TCG and KVM. Signed-off-by: Daniel Henrique Barboza Acked-by: Alistair Francis --- target/riscv/cpu.c | 20 ++++++++++++++++++++ target/riscv/cpu.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b3befccf89..a439ff57a4 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1376,6 +1376,26 @@ Property riscv_cpu_options[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +/* Optional extensions left out: RVV, zfh, zkn, zks */ +static RISCVCPUProfile RVA22U64 =3D { + .name =3D "rva22u64", + .misa_ext =3D RVM | RVA | RVF | RVD | RVC, + .ext_offsets =3D { + CPU_CFG_OFFSET(ext_icsr), CPU_CFG_OFFSET(ext_zihintpause), + CPU_CFG_OFFSET(ext_zba), CPU_CFG_OFFSET(ext_zbb), + CPU_CFG_OFFSET(ext_zbs), CPU_CFG_OFFSET(ext_zfhmin), + CPU_CFG_OFFSET(ext_zkt), CPU_CFG_OFFSET(ext_icntr), + CPU_CFG_OFFSET(ext_ihpm), CPU_CFG_OFFSET(ext_icbom), + CPU_CFG_OFFSET(ext_icboz), + + RISCV_PROFILE_EXT_LIST_END + } +}; + +RISCVCPUProfile *riscv_profiles[] =3D { + &RVA22U64, NULL, +}; + static Property riscv_cpu_properties[] =3D { DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), =20 diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 3f11e69223..216bbbe7cd 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -66,6 +66,18 @@ const char *riscv_get_misa_ext_description(uint32_t bit); =20 #define CPU_CFG_OFFSET(_prop) offsetof(struct RISCVCPUConfig, _prop) =20 +typedef struct riscv_cpu_profile { + const char *name; + uint32_t misa_ext; + bool enabled; + bool user_set; + const int32_t ext_offsets[]; +} RISCVCPUProfile; + +#define RISCV_PROFILE_EXT_LIST_END -1 + +extern RISCVCPUProfile *riscv_profiles[]; + /* Privileged specification version */ enum { PRIV_VERSION_1_10_0 =3D 0, --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598575; cv=none; d=zohomail.com; s=zohoarc; b=N58hQsuFzJtGgiF1T1D48b3h4zyBfVsM3eO6hzSbKcZC99jQnm/o03fzdRlHB6faBivjzbHDW5Gagvh50UTJ/iKiGZzsl0MkJ1i4jNUFg1mnDvnqbUx7IrA2QQkqnvpB3J5vIoRWPH6Sr12EAHGvdO0q5kKT4tn84bcl5Uh147k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598575; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CYrtWgCLjuFqK3RmFRFzS2KEs06tGcGYHPYhy2oGVUI=; b=LOCb0LNoHVG287h9fFrc9qCYGO0BCiko+NNeW0aw4o/uaLSMy102m+aiI3SktuITXF3IF8w9fBA4hSnoj1ZfR1l3bAsBQ0KRh2XbLYqj2qsHRYTcXTCxyRvKvK6gX+PuGKIzRVz62IXcQ6kB3ygmWjepdY5y32fdr3rWZpIUZaY= 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 1696598575272837.7934854784406; Fri, 6 Oct 2023 06:22:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmR-000634-5S; Fri, 06 Oct 2023 09:22:11 -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 1qokmD-0005vV-7N for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:01 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmB-00039S-4R for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:21:56 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c60778a3bfso17088325ad.1 for ; Fri, 06 Oct 2023 06:21:54 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598512; x=1697203312; 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=CYrtWgCLjuFqK3RmFRFzS2KEs06tGcGYHPYhy2oGVUI=; b=UkPejgKzu0l0Yx0toS13WXd3wE/JEhy7D3GGqiMHeszY5x+uj6dBcRLLWTR/RrOkO7 +cIjVO37DVlrSps2vwlCmC9epEnUKcp4YDhOEVljFE5oFaIt2kk5PBPsssho3x7tCRYr sPd7kvPS+2e5JbyKR9YbWXNx/BkWa+ZGQS0pY952gyn93A2rHYAwkqhl5auFnlYzXawk 36lRqSEtcZQlmgzYfqvfmTkJnMB5TFJWXmmEdLJWW3z4k0CEIS8xApXSx9RAe64Kmp5J n35x/DstvMfDqDNAM0bFASfGVAvJxRO6e8hcBMVePduEIgyMdHLR7CggHcYnq/V3yB99 sO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598512; x=1697203312; 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=CYrtWgCLjuFqK3RmFRFzS2KEs06tGcGYHPYhy2oGVUI=; b=JeWQq7RilMGq00hDtgv8Xc38FXYChLFEkSjGtBN+jlqgdDSJiILOlQIyKFdWyCCd+p z29pAO48oAbnHxOZ9Gkww0c9ptg1CcB9L8tu/WcjcSMiHY4dzuR0FsaOqaKGeN0K5rkF j9gXvdb+zLhoaEfgrmiExw2RrF1qVvKR9GTi9wOtd1AEOlunXkJ1bicAr3iBEXa6I9My DD2P0WD5l9LVYRRwXChGtIg/OtwTMTQAvWv7n9eaqRqM9qy1yJ3RBstR/DaOlorTEj1v V7Ryt/joqqdTf9MQNiwUMpsbCfM8YJaF4fn40F2x8DhQvdcrULp1F9iHKVgvOEOrcQFD +gzQ== X-Gm-Message-State: AOJu0YxxGLMvpv51+Z32Gmr+nujFaId3/oA2tdS4Yh2+Mwo8s4aeMqdF MpGuhfskeSwxmZ0/2b0frS5clGet3ub39nYiV3c= X-Google-Smtp-Source: AGHT+IEOgbMCTfZ9XPgmSRJCClN+KXwcn9ZvK1QY0n80DqJN11EhaQFcMQnrgeVThD22BZzFR7nSew== X-Received: by 2002:a17:902:d349:b0:1c5:e527:68b0 with SMTP id l9-20020a170902d34900b001c5e52768b0mr8051272plk.62.1696598512680; Fri, 06 Oct 2023 06:21: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, Daniel Henrique Barboza Subject: [PATCH v2 04/10] target/riscv/kvm: add 'rva22u64' flag as unavailable Date: Fri, 6 Oct 2023 10:21:28 -0300 Message-ID: <20231006132134.1135297-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::62c; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62c.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: 1696598577951100002 Content-Type: text/plain; charset="utf-8" KVM does not have the means to support enabling the rva22u64 profile. The main reasons are: - we're missing support for some mandatory rva22u64 extensions in the KVM module; - we can't make promises about enabling a profile since it all depends on host support in the end. We'll revisit this decision in the future if needed. For now mark the 'rva22u64' profile as unavailable when running a KVM CPU: $ qemu-system-riscv64 -machine virt,accel=3Dkvm -cpu rv64,rva22u64=3Dtrue qemu-system-riscv64: can't apply global rv64-riscv-cpu.rva22u64=3Dtrue: 'rva22u64' is not available with KVM Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/kvm/kvm-cpu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c index c6615cb807..5f563b83df 100644 --- a/target/riscv/kvm/kvm-cpu.c +++ b/target/riscv/kvm/kvm-cpu.c @@ -358,7 +358,7 @@ static void cpu_set_cfg_unavailable(Object *obj, Visito= r *v, } =20 if (value) { - error_setg(errp, "extension %s is not available with KVM", + error_setg(errp, "'%s' is not available with KVM", propname); } } @@ -438,6 +438,11 @@ static void kvm_riscv_add_cpu_user_properties(Object *= cpu_obj) riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_extensions); riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_vendor_exts); riscv_cpu_add_kvm_unavail_prop_array(cpu_obj, riscv_cpu_experimental_e= xts); + + /* We don't have the needed KVM support for profiles */ + for (i =3D 0; riscv_profiles[i] !=3D NULL; i++) { + riscv_cpu_add_kvm_unavail_prop(cpu_obj, riscv_profiles[i]->name); + } } =20 static int kvm_riscv_get_regs_core(CPUState *cs) --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598660; cv=none; d=zohomail.com; s=zohoarc; b=WEBybrxYfp1lix+OwF+o8nBs4Jj/Hov66OGsVx0znVjlzVmaYBKCLEa/oFrQ15Nnkuz/JlfK7yjp1fIRSNqaFlAi8WKgVLtnab3XgT/VsWKTfZMRIiInkt+PjoiFUYgvcoQMSoVLrDmDZmmO5sqsoBkQKnikfyUhD0VJuSRyQSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598660; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3NJuHZOqU1ESRxMo2wNeFNr0U6gZOZRqM9wqvjboqRM=; b=YyDR6yZbc8qN9P7rnjJnoNCvsX0gl6r+DkmFM0cTo/i8Pa/SPgVwJlLq/OpLhgORSWY/l0axqnS3xh7EkcRAaKeTCxguihHbzhH81vl3yY7k62MW3pEMkwqNMW77qkmIUlpEYxhBz8FpQEjqnsoMb8eqt8RyxonHt5xGY4boWVw= 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 1696598660283738.6861453782427; Fri, 6 Oct 2023 06:24:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmT-00064y-Su; Fri, 06 Oct 2023 09:22:13 -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 1qokmH-0005x2-En for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:02 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmD-0003BT-9p for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:00 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c88b467ef8so10894565ad.0 for ; Fri, 06 Oct 2023 06:21:56 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598515; x=1697203315; 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=3NJuHZOqU1ESRxMo2wNeFNr0U6gZOZRqM9wqvjboqRM=; b=UsXpwSPqIWxhteb24oGbRTqX3cD2y2rR58JxoxBRhOvG965/FSHtd/lnXBCsWctRwj JsZJibJ9ep9Nm7e7ieix1MgXvN/gLFXyqk9HUSbbQZlgpqoEpBCEWFHSyqSSiEzYpVFF nn7LRbuv6FS/4Fe5B2lxkvOXECsWpi3IIbw6U+P7M2xrI/o7qWznGyjDRrgTCyboXbB+ 1Ars6GdPd0A+FrH5ZTk/rY/D/pS8xbGooXuDa4ewyBLI23khGeuHyGqQrpE4nrWlneGI TZ8PjV1O+CdwgISBkA4QsXc5fuGi5pkVqD+ybiXVI5qxKLtai4VYv8rt7Igp56d84yPn PTdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598515; x=1697203315; 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=3NJuHZOqU1ESRxMo2wNeFNr0U6gZOZRqM9wqvjboqRM=; b=odDpMs8A+fBL0TsVNfDMfhZdUONVbxydoLHAUrUciZOo4OoLSSyn0ehKJC8KAdWrVc fb71Qae84xPt5EVpUMIp7P0ZU2Vh8UDURe1oZpYCLLe8IQoZ38pUxtF40VzVYV8J/aFR B19HhRLX+NB8spy3+Wf3yi7kEFfFxVn9Ofsj01JETNkZfvujA4+WQRZKTLDnOzNr4BIC tmsMiYtTcFb5O6vXxWgF40yT1UfJFterNOUss9QwKW8B8vgaXG3Wt767Z0rb+F8vNUOu i2ykHepenD39BYlL4TfaX2kb/L4mSqzNJJEPG06YFobr0q2aLGpT0BMdUvUYMbtkz5wD sCVg== X-Gm-Message-State: AOJu0YyBdXIMxeCMxE4Q7Cv6XuXJunXXMvDO9FY7ox9r/zpBsWKik0gm OAuk7dv1LxiFYDzjShnGEHicgD+r4VXR0OJZH2A= X-Google-Smtp-Source: AGHT+IGWmLWlXYZASmli0LYVKzV0l8agCyUsELJk0/PCba+Zxb4TtJGucMcJh+WV2ri+eGH5Sl4Rcw== X-Received: by 2002:a17:902:d342:b0:1c5:b1cc:fe0e with SMTP id l2-20020a170902d34200b001c5b1ccfe0emr7513060plk.53.1696598515592; Fri, 06 Oct 2023 06:21: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, Daniel Henrique Barboza Subject: [PATCH v2 05/10] target/riscv/tcg: add user flag for profile support Date: Fri, 6 Oct 2023 10:21:29 -0300 Message-ID: <20231006132134.1135297-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::633; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x633.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: 1696598662108100005 Content-Type: text/plain; charset="utf-8" The TCG emulation implements all the extensions described in the RVA22U64 profile, both mandatory and optional. The mandatory extensions will be enabled via the profile flag. We'll leave the optional extensions to be enabled by hand. Given that this is the first profile we're implementing in TCG we'll need some ground work first: - all profiles declared in riscv_profiles[] will be exposed to users. TCG is the main accelerator we're considering when adding profile support in QEMU, so for now it's safe to assume that all profiles in riscv_profiles[] will be relevant to TCG; - the set() callback for the profile user property will set the 'user_set' flag for each profile that users enable/disable in the command line; - we'll not support user profile settings for vendor CPUs. The flags will still be exposed but users won't be able to change them. The idea is that vendor CPUs in the future can enable profiles internally in their cpu_init() functions, showing to the external world that the CPU supports a certain profile. But users won't be able to enable/disable it. For now we'll just expose the user flags for all profiles. Next patch will introduce the 'commit profile' logic. Signed-off-by: Daniel Henrique Barboza --- target/riscv/tcg/tcg-cpu.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 731192bafc..a8ea869e6e 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -740,6 +740,50 @@ static void riscv_cpu_add_misa_properties(Object *cpu_= obj) } } =20 +static void cpu_set_profile(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPUProfile *profile =3D opaque; + bool value; + + if (object_dynamic_cast(obj, TYPE_RISCV_DYNAMIC_CPU) =3D=3D NULL) { + error_setg(errp, "Profile %s only available for generic CPUs", + profile->name); + return; + } + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + + profile->user_set =3D true; + profile->enabled =3D value; +} + +static void cpu_get_profile(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPUProfile *profile =3D opaque; + bool value =3D profile->enabled; + + visit_type_bool(v, name, &value, errp); +} + +static void riscv_cpu_add_profiles(Object *cpu_obj) +{ + for (int i =3D 0;; i++) { + const RISCVCPUProfile *profile =3D riscv_profiles[i]; + + if (!profile) { + break; + } + + object_property_add(cpu_obj, profile->name, "bool", + cpu_get_profile, cpu_set_profile, + NULL, (void *)profile); + } +} + static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *nam= e, void *opaque, Error **errp) { @@ -834,6 +878,8 @@ static void riscv_cpu_add_user_properties(Object *obj) riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_vendor_exts); riscv_cpu_add_multiext_prop_array(obj, riscv_cpu_experimental_exts); =20 + riscv_cpu_add_profiles(obj); + for (Property *prop =3D riscv_cpu_options; prop && prop->name; prop++)= { qdev_property_add_static(DEVICE(obj), prop); } --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598620; cv=none; d=zohomail.com; s=zohoarc; b=hZdo5YTnGLrYCGrGGez86ojRzBxK5yG/9Gpb+G80opd8BMke9+bxJGXTpzy8IDaXfSj6kTIakXbKxhjioDXWgeezL7h5oDD09YtQ1ef/1Kk8EwjicmAle4OKwe1EF51ceug+AQ5BSEzyLBma88zB4FtmVEa33rsDTUhPox/TPdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598620; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0OY+Z7p8EVlJtkdrqr2A47PoI19IqT3Z+EwZbD1sy2A=; b=R42hLfqFlzKE81osGzv/Z5HkwjbLR/jZ2R0/ca0z0BcmpXA8fNn/uJLZ6vFpTweRV5IJHOSXEtNnOwSgTNOMC99CMYRv8n5irenHjhhHp/TRdC9u4air9pKM2n5BaWTfM4ITkknCGkCuWd/1XIH0wc6HKbdhXFBUDrlphZBSBgw= 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 1696598620776784.3724043184365; Fri, 6 Oct 2023 06:23:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmS-00064N-83; Fri, 06 Oct 2023 09:22: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 1qokmJ-0005xw-FB for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:04 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmH-0003C8-6s for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:03 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c0ecb9a075so15936695ad.2 for ; Fri, 06 Oct 2023 06:21:59 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598518; x=1697203318; 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=0OY+Z7p8EVlJtkdrqr2A47PoI19IqT3Z+EwZbD1sy2A=; b=b4N95K8NogURwGCoOcouRC5P/KQmYrhzg94Z0uhtUY0aWfkU05hREwoZNKFx4ObleW FucnboRAkNGqOOlBwEKrxPL2HVm487oAY4AwZUf7pqIABQsCT7y+riBFwWkX95QrIow+ I0zhknRzlp9xWqEi5IDKuehamjHoRRxCakVHNhh/zsOBu5K9Uz3toxMR5jLPA6AI+LOd 6ajRJ7uFdocMMtxFRw7aTRPp5JGfvw/IGoV3H5fSaAOOV+mMamqkw4DhuADM5Y++WgFp lR7jxj8hIGrgZdi1uy7lrg5NFVA3gOjhpqXpcbGdhc9I5l+GJN5v7ggOYf+pVd8Tjdu1 yNZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598518; x=1697203318; 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=0OY+Z7p8EVlJtkdrqr2A47PoI19IqT3Z+EwZbD1sy2A=; b=lJXEMCPOOvylKX94lNhrFQ1fg9NQLGeNlAfn7vMBqliiTEsi8OUv/QKOjpYERpzCX1 o6pAH5MMzs+ShIlhaMramyXR+0RckJkynBksUm+MdmzEP4vX7ym3MEUTilf61AIcJ1Hb 08bEYsPk4ZWtmFAApGwgMWBLaUNuXpmOlo65L7XFfijuRmOr0Z/mV0uMrBxmdG8S4pBr ic0LsnNhYFngN2IeLqC7xc98/Gw5WxVfTuLtPEZ2xja3XQIi4IBmZ6/Bi7HaZ4Iix8m1 xauhdVZtRPqgo29wJ4ILSTOX4LWbjF/IFNmSeRleN3TnBNnFmxB7oOpfvZ13pIpJi8rt p0Cw== X-Gm-Message-State: AOJu0YypSFz8TzWHAjxaYoKYWtyuhKCrRiwmlMupg8N3nVaqfIEe0RUo yeR4qwU8nCWX/EG4mJsugLoZTHka/9EW3x/gNvM= X-Google-Smtp-Source: AGHT+IFmE41nzQcqBj8qDSxndjfxQ8EBAtOhf2+dLeZF70CE0rXYGqYdOUtPYueJzHVhiGVYPxIFLA== X-Received: by 2002:a17:902:6b04:b0:1b7:e86f:7631 with SMTP id o4-20020a1709026b0400b001b7e86f7631mr7702793plk.19.1696598518406; Fri, 06 Oct 2023 06:21: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, Daniel Henrique Barboza Subject: [PATCH v2 06/10] target/riscv/tcg: commit profiles during realize() Date: Fri, 6 Oct 2023 10:21:30 -0300 Message-ID: <20231006132134.1135297-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::62d; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62d.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: 1696598621422100002 Content-Type: text/plain; charset="utf-8" To 'commit' a profile means enabling/disabling all its mandatory extensions after taking into account individual user choice w.r.t MISA and multi-letter extensions. We'll handle multi-letter extennsions now - MISA extensions needs additional steps that we'll take care later. riscv_cpu_manage_profiles() will scroll through all profiles available in QEMU and call riscv_cpu_commit_profile() for any profile that the user set, either to 'true' or 'false'. Setting a profile to 'true' means 'enable all mandatory extensions of this profile'. Setting it to 'false' means disabling all its mandatory extensions. Since we're doing it during realize() time we already have all user choices for individual extensions sorted out, and they'll take precedence. This will make us independent of left-to-right ordering in the QEMU command line, i.e. the following QEMU command lines: -cpu rv64,zicbom=3Dfalse,rva22u64=3Dtrue,Zifencei=3Dfalse -cpu rv64,zicbom=3Dfalse,Zifencei=3Dfalse,rva22u64=3Dtrue -cpu rv64,rva22u64=3Dtrue,zicbom=3Dfalse,Zifencei=3Dfalse They mean the same thing: "enable all mandatory extensions of the rva22u64 profile while keeping zicbom and Zifencei disabled". Enabling extensions in the profile is also considered an user choice, so all extensions enabled will be added in the multi_ext_user_opts hash. Signed-off-by: Daniel Henrique Barboza --- target/riscv/tcg/tcg-cpu.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index a8ea869e6e..8fb77e9e35 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -264,6 +264,41 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCV= CPU *cpu) } } =20 +static void riscv_cpu_commit_profile(RISCVCPU *cpu, RISCVCPUProfile *profi= le) +{ + int i; + + for (i =3D 0;; i++) { + int ext_offset =3D profile->ext_offsets[i]; + + if (ext_offset =3D=3D RISCV_PROFILE_EXT_LIST_END) { + break; + } + + if (cpu_cfg_ext_is_user_set(ext_offset)) { + continue; + } + + g_hash_table_insert(multi_ext_user_opts, + GUINT_TO_POINTER(ext_offset), + (gpointer)profile->enabled); + isa_ext_update_enabled(cpu, ext_offset, profile->enabled); + } +} + +static void riscv_cpu_manage_profiles(RISCVCPU *cpu) +{ + for (int i =3D 0; riscv_profiles[i] !=3D NULL; i++) { + RISCVCPUProfile *profile =3D riscv_profiles[i]; + + if (!profile->user_set) { + continue; + } + + riscv_cpu_commit_profile(cpu, profile); + } +} + /* * Check consistency between chosen extensions while setting * cpu->cfg accordingly. @@ -273,6 +308,8 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, E= rror **errp) CPURISCVState *env =3D &cpu->env; Error *local_err =3D NULL; =20 + riscv_cpu_manage_profiles(cpu); + /* Do some ISA extension error checking */ if (riscv_has_ext(env, RVG) && !(riscv_has_ext(env, RVI) && riscv_has_ext(env, RVM) && --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598660; cv=none; d=zohomail.com; s=zohoarc; b=RIlyBuLVH84ZpbZPJ0uOJLs5dl8AGeqj/iGyPSOFflv36lx5EtzHuguC9fb+dqg97nfgKKr2N12XtPfGHdwNrjbALAGTSxuZqzMOnezB/pLAhChhVUz4YNiW7dx1Z/CYJDAsdrxi4tNjm0wk1FCc56o87Bzio5NgtUM//6+vMDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598660; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4rRpxw8LIPQ5JNxN3LijsZM4c9QFIOVzja2k6Lddpcs=; b=e/u7khbWIMNjXl3oS9c4dh70NcRkv1ursTeQ1r7E79stJrSdke/1kNmWVAPPmkShDGjWcXy2rrCyrZ4WLGLeCa2KQVLwEcmCnZjMKninrN7r50lYnCH4HlALlKd6Fb6EhpB53a3imdnmSevkmDVq+74RGbfbvADLF7mu9hntjis= 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 1696598660181699.1545574108399; Fri, 6 Oct 2023 06:24:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmT-00064c-7N; Fri, 06 Oct 2023 09:22:13 -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 1qokmK-0005yA-UK for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:05 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmJ-0003Cp-09 for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:04 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c62d61dc96so15551045ad.0 for ; Fri, 06 Oct 2023 06:22:02 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.21.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598521; x=1697203321; 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=4rRpxw8LIPQ5JNxN3LijsZM4c9QFIOVzja2k6Lddpcs=; b=bI+fOmTWoHG5C9/Ri2CLyeznCBSYMvcb1jk1sZ0BfHm0rVsPFlfUv5fo2pG3yl8lFj gG8E5Hdm+XTKd0cduAtczTrs2cp8INkKJfA9NSWa+wnSt+cWJh1R2bv7fZfcBRkkbFbT TMDC4FHwNaMrc4XZE9oGCgjMNpuatFes0Ndd5h8UOiGKyl/KVroHj8OqNPsOUBEDv/bm qNX0j4vNrcYPmXTOVVJal1tabyk1/o887HjUfQvvBjFZdfiBUKPng83cDIpeBlp0IjdL uFBGPL29KKVVT7NI8tiM6IY/HHeoul6yZN9D4wntwbRH71MFcEXJpCuAFELCLkpW1f2q GewA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598521; x=1697203321; 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=4rRpxw8LIPQ5JNxN3LijsZM4c9QFIOVzja2k6Lddpcs=; b=xP+S7X46s4EOLqADiUmtHu2q+Kh/xGX25Giy50vg9wEcsXDLsbEhfiNJc7yff0/qPn sQgMdkO83KOo0tIEI9VQxHoMWSlMNIZnEUgy6P7aoDISEL8h9OBTk+a1s8bG2OKbLVbO h1WDEdme78PdFf96KT+kaEtDGKB1pwI9DDeb9ZuByErF99xv3JZkgQclY7uhwJt/LtIY v84b7LydHxOc3wRNRy2iff9ygbbMRtC6igJheEWuumoLxtIe89pJ9q+3pmHzViTaYdg3 ZzfJlc3EvMxGR13Cbe8Jvn6Jt/7PjE+FswF84inqe0zOkWbM5d3J+T9yCzAbRo9TBQCd /V8Q== X-Gm-Message-State: AOJu0YwXlqh0JqbRER/yB7LRpFfB0IYD38xr+vJgKlqErIHKNUyJtBmf k+mlB5P6x7yK5GwAANAg8RhXrCcv8rwpDDpYQu0= X-Google-Smtp-Source: AGHT+IGKaC0WseqgCcViSXNyTHqdckP7EsOkn/IGR1FxQvtTUdmipH7CwIM25tNNCKwM4bGFCRJviA== X-Received: by 2002:a17:903:509:b0:1bf:557c:5a2c with SMTP id jn9-20020a170903050900b001bf557c5a2cmr7165169plb.44.1696598521364; Fri, 06 Oct 2023 06:22:01 -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 v2 07/10] target/riscv/tcg: add MISA user options hash Date: Fri, 6 Oct 2023 10:21:31 -0300 Message-ID: <20231006132134.1135297-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::630; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x630.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: 1696598662115100006 Content-Type: text/plain; charset="utf-8" We already track user choice for multi-letter extensions because we needed to honor user choice when enabling/disabling extensions during realize(). We refrained from adding the same mechanism for MISA extensions since we didn't need it. Profile support requires tne need to check for user choice for MISA extensions, so let's add the corresponding hash now. It works like the existing multi-letter hash (multi_ext_user_opts) but tracking MISA bits options in the cpu_set_misa_ext_cfg() callback. Note that we can't re-use the same hash from multi-letter extensions because that hash uses cpu->cfg offsets as keys, while for MISA extensions we're using MISA bits as keys. After adding the user hash in cpu_set_misa_ext_cfg(), setting default values with object_property_set_bool() in add_misa_properties() will end up marking the user choice hash with them. Set the default value manually to avoid it. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 8fb77e9e35..58de4428a9 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -34,6 +34,7 @@ =20 /* Hash that stores user set extensions */ static GHashTable *multi_ext_user_opts; +static GHashTable *misa_ext_user_opts; =20 static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) { @@ -689,6 +690,10 @@ static void cpu_set_misa_ext_cfg(Object *obj, Visitor = *v, const char *name, return; } =20 + g_hash_table_insert(misa_ext_user_opts, + GUINT_TO_POINTER(misa_bit), + (gpointer)value); + prev_val =3D env->misa_ext & misa_bit; =20 if (value =3D=3D prev_val) { @@ -752,6 +757,7 @@ static const RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { */ static void riscv_cpu_add_misa_properties(Object *cpu_obj) { + CPURISCVState *env =3D &RISCV_CPU(cpu_obj)->env; bool use_def_vals =3D riscv_cpu_is_generic(cpu_obj); int i; =20 @@ -772,7 +778,13 @@ static void riscv_cpu_add_misa_properties(Object *cpu_= obj) NULL, (void *)misa_cfg); object_property_set_description(cpu_obj, name, desc); if (use_def_vals) { - object_property_set_bool(cpu_obj, name, misa_cfg->enabled, NUL= L); + if (misa_cfg->enabled) { + env->misa_ext |=3D bit; + env->misa_ext_mask |=3D bit; + } else { + env->misa_ext &=3D ~bit; + env->misa_ext_mask &=3D ~bit; + } } } } @@ -967,6 +979,7 @@ static void tcg_cpu_instance_init(CPUState *cs) RISCVCPU *cpu =3D RISCV_CPU(cs); Object *obj =3D OBJECT(cpu); =20 + misa_ext_user_opts =3D g_hash_table_new(NULL, g_direct_equal); multi_ext_user_opts =3D g_hash_table_new(NULL, g_direct_equal); riscv_cpu_add_user_properties(obj); =20 --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598615; cv=none; d=zohomail.com; s=zohoarc; b=TbpVrn6n+ui5vWNt5Lo2wgpUA90zxdnAGhb2RziyAEL/yXavGxygTxYaMSZBUp/ltJ9j9IW0XTKgO/xZ7LpFuBmsZdn4ZGZI3DOdUyibagaZ8e/XNd4+2FDkOkQHZt4dNQPCLHFqRWI9al+4r3qdCdqxqMEVaRn0Q9N8IFqThq0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598615; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KvKZS7XsbHTlH5mCfjOVY2NDos1DmofvmwtvjcTHu6A=; b=YENRo/TGrD1ua2mh00Aa9B9gY6z3Wppc3TAGBcS8G+8rWfh0l/Tr4DO5JOQmtAg7+NF4onoBcvrONadzPdtf+O8GN1zB1QgdT6YYW5ZZYlU9+mTCA7Au2JysnMpIZSkuII7cEF9j+Mn/jQ1fHkqksUGa2479nvblsupa16O7940= 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 1696598615592865.8176353395431; Fri, 6 Oct 2023 06:23:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmR-00063l-Rh; Fri, 06 Oct 2023 09:22:11 -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 1qokmP-000615-Mj for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:09 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmM-0003Dy-SP for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:08 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c5c91bec75so16444625ad.3 for ; Fri, 06 Oct 2023 06:22:05 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:22:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598524; x=1697203324; 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=KvKZS7XsbHTlH5mCfjOVY2NDos1DmofvmwtvjcTHu6A=; b=bh7knsF1aXub7txu/fKMpttiJ9GS+nRfCgIe251hmHUSmpp+/M7piGloHLEFWrt+9f lMwvXHCNDmWlJvNZ2StEShM3wg2Pg5FjnVS2QjrGB4U7Aplghnhd27423POc/ku2wCiv 8tWOafeKGWWaiKqiISJgLW3UaG7ruDSmbE+9eucJoNhzIMVnRQEYPKNNkHfrCkTR2BjP 4L2JwhMx3NCq85Th52MHceJhsXZzzrIspVgbvh5rgQFX/UEYNuiPlRs7nGlAt7XjRKiA lxjGVhqK4r4U9KQe296t7Wlz/X0jbCFoNRcuKikgyB3/LlvRc9KWe352fAwXVvMORq1c EnCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598524; x=1697203324; 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=KvKZS7XsbHTlH5mCfjOVY2NDos1DmofvmwtvjcTHu6A=; b=nhAh340SmvQ5SEuQQMevg8ZI3X2BfkKefM//+7jcb2qxXfEy0jodMmBcuy0T35U1KS nQ4ql7/3Kzvib4yuhOGptt/HRTVyQA3cIl8wbYMhbdHYnBeCV/Fm2sX+up9xhynAHFG7 qfjrUMYmFdNQRkEeMzgur0JG0eIT70XKY9hFPU8Xney9JXDbvljGKB4Zttp7ZRaiQCmp 5NgdW6fq1lt6+CJbteRcH8n8xSNSZYQuAdbTVme+nxWl9+kQB2hB6pl4i8NWgPd9yt3j D5fiy4shB/c30CHqXeFncjbhsU7ff9Lv0dHV5S/gImlGpOG03GhFw/KIqu72ob66mLVs 2zSA== X-Gm-Message-State: AOJu0YyVix6/VkGlpB72SsvRPecSLySq2n88tgsOQyypPJMZRHjdGRjF y0znSN9rRjqOj//xQoJRfP47bJC9GqEUIMdQWMA= X-Google-Smtp-Source: AGHT+IHLN0pkchy8VcODabrbm1ux3O8JSc46uoLJ7NJawlp+1Smu0XOIhaXdFGsNS1m8OuTHVoNi3w== X-Received: by 2002:a17:903:2348:b0:1c5:6dbc:7938 with SMTP id c8-20020a170903234800b001c56dbc7938mr8567430plh.69.1696598524177; Fri, 06 Oct 2023 06:22:04 -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 v2 08/10] target/riscv/tcg: add riscv_cpu_write_misa_bit() Date: Fri, 6 Oct 2023 10:21:32 -0300 Message-ID: <20231006132134.1135297-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::62d; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62d.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: 1696598617341100001 Content-Type: text/plain; charset="utf-8" We have two instances of the setting/clearing a MISA bit from env->misa_ext and env->misa_ext_mask pattern. And the next patch will end up adding one more. Create a helper to avoid code repetition. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 58de4428a9..b1e778913c 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -42,6 +42,20 @@ static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) GUINT_TO_POINTER(ext_offset)); } =20 +static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint32_t bit, + bool enabled) +{ + CPURISCVState *env =3D &cpu->env; + + if (enabled) { + env->misa_ext |=3D bit; + env->misa_ext_mask |=3D bit; + } else { + env->misa_ext &=3D ~bit; + env->misa_ext_mask &=3D ~bit; + } +} + static void riscv_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { @@ -700,20 +714,14 @@ static void cpu_set_misa_ext_cfg(Object *obj, Visitor= *v, const char *name, return; } =20 - if (value) { - if (!generic_cpu) { - g_autofree char *cpuname =3D riscv_cpu_get_name(cpu); - error_setg(errp, "'%s' CPU does not allow enabling extensions", - cpuname); - return; - } - - env->misa_ext |=3D misa_bit; - env->misa_ext_mask |=3D misa_bit; - } else { - env->misa_ext &=3D ~misa_bit; - env->misa_ext_mask &=3D ~misa_bit; + if (value && !generic_cpu) { + g_autofree char *cpuname =3D riscv_cpu_get_name(cpu); + error_setg(errp, "'%s' CPU does not allow enabling extensions", + cpuname); + return; } + + riscv_cpu_write_misa_bit(cpu, misa_bit, value); } =20 static void cpu_get_misa_ext_cfg(Object *obj, Visitor *v, const char *name, @@ -757,7 +765,6 @@ static const RISCVCPUMisaExtConfig misa_ext_cfgs[] =3D { */ static void riscv_cpu_add_misa_properties(Object *cpu_obj) { - CPURISCVState *env =3D &RISCV_CPU(cpu_obj)->env; bool use_def_vals =3D riscv_cpu_is_generic(cpu_obj); int i; =20 @@ -778,13 +785,8 @@ static void riscv_cpu_add_misa_properties(Object *cpu_= obj) NULL, (void *)misa_cfg); object_property_set_description(cpu_obj, name, desc); if (use_def_vals) { - if (misa_cfg->enabled) { - env->misa_ext |=3D bit; - env->misa_ext_mask |=3D bit; - } else { - env->misa_ext &=3D ~bit; - env->misa_ext_mask &=3D ~bit; - } + riscv_cpu_write_misa_bit(RISCV_CPU(cpu_obj), bit, + misa_cfg->enabled); } } } --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598642; cv=none; d=zohomail.com; s=zohoarc; b=jULGX8AJUv1jLGQdP6cwDhNVCQ5lBxWGuUGf5V7O/3CnBBZeLWvJuuFrrgNtNmkgYnrwo04g9QmIQ7mHST8sBo8o0VriDXRelztNgibCYHLmgnp1vrgIjsjaS3yPCUd6LGQNkApFsuNQZjseQY+u8m9M0ghErN0SDkZ6c9BdWBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598642; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5y/dBuqHy/oa9m7Jxo7pCMhDxA4Tb2pKxeV4ExkQA0w=; b=j9DW9TAlcl6JCv1Nu232Do/Fr4HWD+hwPdAjzj/wg2CCXo6phAFAdAvByE9ECvLfQi2o2qjrzNBD7nfBup7sxQL14j8qvWpTB7ee8Ab7hkpkDYZZ7t8NLDfj7ih4kNZ9QzrqqHl6LnmXPBoDoVE/OwPtEbMR3y4zpawuRwIVIBQ= 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 1696598642566554.7577376733566; Fri, 6 Oct 2023 06:24:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokmU-00065n-Lu; Fri, 06 Oct 2023 09:22:14 -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 1qokmR-00062x-2R for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:11 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmO-0003EZ-Qt for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:10 -0400 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-2776d882214so1579791a91.2 for ; Fri, 06 Oct 2023 06:22:08 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598527; x=1697203327; 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=5y/dBuqHy/oa9m7Jxo7pCMhDxA4Tb2pKxeV4ExkQA0w=; b=ZCremqsY0yZ8SI8uLsoYNadJy2yj1rVByZcnAXaYaFD+s8eNZrMWzkSaSN1jZZlyhk EvTJoJkDBzQFPfgA+GhCtmSs+bxI2vxWRyOMPwUY2O0ucB1FmVn7bnfGE78lw7OgwSV0 2kbb3a0pRYd+PJrC2rGUxHCG/RjOrmjXxSAsUHWCJKTT810cL8ELLTMqnOETqcn18fcV L0ba9Dk+oHzC/8XpyAM51Qvf2u2QlPJYCW8elM9dOWLAZp4yMgc4FATbUHajOAm7JVXV vz2GOZeX6EfbjGCy7NMmiQlt97XCAHdd4ac3MGCligmJ+gRqC3TYlSBY8DXqeM2vSuEL lpyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598527; x=1697203327; 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=5y/dBuqHy/oa9m7Jxo7pCMhDxA4Tb2pKxeV4ExkQA0w=; b=gc2p4i7dlW2XSzqyNchglY9oHwWOzX3ccJTw61TVZhlo8yN1QKDm1A9w1iUrXmNn8G /niXgE5MbaJxIgeiS3SmzvDNbJEmEJpDxZmihnJpKdnPlVlTEWVSqwCxuUFcnQujLth2 iWIRFCZd1Gt9MWTTV0A+of2iW9L3gwUWWro/HbtPNDMyJUhnm2dJtIkglaZl0l2dfTUI rbKGYe198D3MiRZliVRMO7Y+bvNC4uSaJlfSZ4kol7vM/7ap/Ws01KEnwgyLIttCPMI/ 01wfDFFEHQqMoJF22HCbW21tItGrUhJyECfGesuTMbiUiWS6GmCihkPIE/0oL0ACSSKF VMNw== X-Gm-Message-State: AOJu0YzEH0ELGVCQTw4YyRTOh10qYyTyCQqZ2H4zpm001T5vWWQilcl8 tBxWEJ9rJ//1VGMRuhS3J4wrePbu+kAKqDq7H5o= X-Google-Smtp-Source: AGHT+IGG0G9JtxcE00GjjE2AGRUcbI1bITetQwY3cCO5XFIvmwSFx/6kb5TYjknEcO4xTRUp5Ndidg== X-Received: by 2002:a17:90b:3907:b0:273:e255:2235 with SMTP id ob7-20020a17090b390700b00273e2552235mr6762083pjb.49.1696598527051; Fri, 06 Oct 2023 06:22:07 -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 v2 09/10] target/riscv/tcg: handle MISA bits on profile commit Date: Fri, 6 Oct 2023 10:21:33 -0300 Message-ID: <20231006132134.1135297-10-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::102a; envelope-from=dbarboza@ventanamicro.com; helo=mail-pj1-x102a.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: 1696598643870100003 Content-Type: text/plain; charset="utf-8" The profile support is handling multi-letter extensions only. Let's add support for MISA bits as well. We'll go through every known MISA bit. If the user set the bit, doesn't matter if to 'true' or 'false', ignore it. If the profile doesn't declare the bit as mandatory, ignore it. Otherwise, set or clear the bit in env->misa_ext and env->misa_ext_mask depending on whether the profile was set to 'true' or 'false'. Signed-off-by: Daniel Henrique Barboza --- target/riscv/tcg/tcg-cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index b1e778913c..d7540274f4 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -42,6 +42,12 @@ static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) GUINT_TO_POINTER(ext_offset)); } =20 +static bool cpu_misa_ext_is_user_set(uint32_t misa_bit) +{ + return g_hash_table_contains(misa_ext_user_opts, + GUINT_TO_POINTER(misa_bit)); +} + static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint32_t bit, bool enabled) { @@ -283,6 +289,20 @@ static void riscv_cpu_commit_profile(RISCVCPU *cpu, RI= SCVCPUProfile *profile) { int i; =20 + for (i =3D 0; misa_bits[i] !=3D 0; i++) { + uint32_t bit =3D misa_bits[i]; + + if (cpu_misa_ext_is_user_set(bit) || !(profile->misa_ext & bit)) { + continue; + } + + g_hash_table_insert(misa_ext_user_opts, + GUINT_TO_POINTER(bit), + (gpointer)profile->enabled); + + riscv_cpu_write_misa_bit(cpu, bit, profile->enabled); + } + for (i =3D 0;; i++) { int ext_offset =3D profile->ext_offsets[i]; =20 --=20 2.41.0 From nobody Sat May 18 14:01:39 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=1696598610; cv=none; d=zohomail.com; s=zohoarc; b=mNmT7t4ELSMOqucNzmCD80Y9LHdD9UADq3Ptm5KgNnKHzBQP1nv/kQRRnp0I/a4hRCfmAt2dfkyT+5B4qpRxEzm7nD/MN9eUr9MyLwqGdPFZza0TzcuyTBDR3UbrU1FaqPOoeWLbqSAVc4K8J3cg3VtohaND8q9QLwow3dr9C74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696598610; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hEKxFBV3S1LkNsoZYztGI8sqhw9WeeKCrlL2/nre/QY=; b=MdOAeqvLFfShGjs8y/BNDoxPDcb7WGCvS/nJPrLNh4k5eajo8adRcKbMF3X3AB/DEqDo2+W3eI6YkUtynzmAdXKh0UXDPaxEHF3qnOo02gW1rnVUapZfU5SGQ83Nc95MrhMwRYABotalNxT03QwXObcTF2LxqIUnBuDvHe0lQec= 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 1696598610107580.0860786450214; Fri, 6 Oct 2023 06:23:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qokma-00067O-FL; Fri, 06 Oct 2023 09:22:20 -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 1qokmY-000672-Hy for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:18 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qokmR-0003Fy-Mx for qemu-devel@nongnu.org; Fri, 06 Oct 2023 09:22:16 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c724577e1fso16884245ad.0 for ; Fri, 06 Oct 2023 06:22:11 -0700 (PDT) Received: from grind.. ([177.94.42.196]) by smtp.gmail.com with ESMTPSA id c12-20020a170902c1cc00b001c60a548331sm3796669plc.304.2023.10.06.06.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 06:22:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696598530; x=1697203330; 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=hEKxFBV3S1LkNsoZYztGI8sqhw9WeeKCrlL2/nre/QY=; b=DsfSk1yQfNyR6JrVRv6isqNo3bVzkUJSbrMng3xdj44yA+MWnpEXGlVyxZ5zRlV6ch 3tIcB70vZ0HDK6CKM761upDvJFOzmrC0ww2LBrCyYTNCxO01v9LoVB8nqhixJwqw88UH KQVymTkXrbqJzeAjFI/K7ukGkNv8boToGz/jI+/t0YpXk9+Tr6pfl9D5REBBxwLwrATA P447P5PKdOx6CQKcwNPQjkwSrBoNnKZqtlfi24lxBaPnUhK/e8hkM0+w3SL6VuBke7Tx tVebhS2tmuMsCZG9F502ye6fuhDJDEP+kye2ygaIMqRHr4FPhSB/9YgVXFYVaXmf2qYH qJrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696598530; x=1697203330; 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=hEKxFBV3S1LkNsoZYztGI8sqhw9WeeKCrlL2/nre/QY=; b=bRqLABdJzUjLDquSubCs1X3n72mccacRx3qUHdXOXbj0t8DSRHbfLEtSNOart+Ullv z9qsWY9SewR/XA0HE1oL4+4IgCuZPOTjsxbDnN7XpbTWlSSORgxM9vnhSfmi+rK0U/V4 UtkqLpVE/Yi/JlLB9UFiFWCTiFZ0tQR/CS+XBL4nr0i8kEofI+duJh/W/xhYTd+WYvHJ ga7XHSyXJVUf9JjhydTWbUvLo+rjpgln7kjqhUQ6WVSbx6qBp+N380AQHzpexnl8P0SQ KGZkOwJ1pM5UYgD+EVMBz1+vo1DHi1ytSbhNEMJAMPwPaIpFnw7fwJUQ+QvOKHB3NXVH Xk5Q== X-Gm-Message-State: AOJu0Yytb5BlX74cZTr1QAObEntWDIRqDAqoTYWKXJa7vdq/d7sObGcl d/ft+qeCGuioKeAyOAEIznf99IdE+/GAa4m/g7Q= X-Google-Smtp-Source: AGHT+IE6UaiuR1mO4+CJRpKhir9aZgcIAdKA27V92jRfB9Iprt05UlBfkOQ1Dr8kmDiQ19pKfggnzA== X-Received: by 2002:a17:903:41c1:b0:1c3:c687:478c with SMTP id u1-20020a17090341c100b001c3c687478cmr9934905ple.8.1696598530069; Fri, 06 Oct 2023 06:22:10 -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 v2 10/10] target/riscv/tcg: add hash table insert helpers Date: Fri, 6 Oct 2023 10:21:34 -0300 Message-ID: <20231006132134.1135297-11-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231006132134.1135297-1-dbarboza@ventanamicro.com> References: <20231006132134.1135297-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::631; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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: 1696598611358100002 Content-Type: text/plain; charset="utf-8" Latest patches added several g_hash_table_insert() patterns. Add two helpers, one for each user hash, to make the code cleaner. Signed-off-by: Daniel Henrique Barboza --- target/riscv/tcg/tcg-cpu.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index d7540274f4..d4ad1c09b3 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -42,12 +42,24 @@ static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) GUINT_TO_POINTER(ext_offset)); } =20 +static void cpu_cfg_ext_add_user_opt(uint32_t ext_offset, bool value) +{ + g_hash_table_insert(multi_ext_user_opts, GUINT_TO_POINTER(ext_offset), + (gpointer)value); +} + static bool cpu_misa_ext_is_user_set(uint32_t misa_bit) { return g_hash_table_contains(misa_ext_user_opts, GUINT_TO_POINTER(misa_bit)); } =20 +static void cpu_misa_ext_add_user_opt(uint32_t bit, bool value) +{ + g_hash_table_insert(misa_ext_user_opts, GUINT_TO_POINTER(bit), + (gpointer)value); +} + static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint32_t bit, bool enabled) { @@ -296,9 +308,7 @@ static void riscv_cpu_commit_profile(RISCVCPU *cpu, RIS= CVCPUProfile *profile) continue; } =20 - g_hash_table_insert(misa_ext_user_opts, - GUINT_TO_POINTER(bit), - (gpointer)profile->enabled); + cpu_misa_ext_add_user_opt(bit, profile->enabled); =20 riscv_cpu_write_misa_bit(cpu, bit, profile->enabled); } @@ -314,9 +324,8 @@ static void riscv_cpu_commit_profile(RISCVCPU *cpu, RIS= CVCPUProfile *profile) continue; } =20 - g_hash_table_insert(multi_ext_user_opts, - GUINT_TO_POINTER(ext_offset), - (gpointer)profile->enabled); + cpu_cfg_ext_add_user_opt(ext_offset, profile->enabled); + isa_ext_update_enabled(cpu, ext_offset, profile->enabled); } } @@ -724,9 +733,7 @@ static void cpu_set_misa_ext_cfg(Object *obj, Visitor *= v, const char *name, return; } =20 - g_hash_table_insert(misa_ext_user_opts, - GUINT_TO_POINTER(misa_bit), - (gpointer)value); + cpu_misa_ext_add_user_opt(misa_bit, value); =20 prev_val =3D env->misa_ext & misa_bit; =20 @@ -867,9 +874,7 @@ static void cpu_set_multi_ext_cfg(Object *obj, Visitor = *v, const char *name, return; } =20 - g_hash_table_insert(multi_ext_user_opts, - GUINT_TO_POINTER(multi_ext_cfg->offset), - (gpointer)value); + cpu_cfg_ext_add_user_opt(multi_ext_cfg->offset, value); =20 prev_val =3D isa_ext_is_enabled(cpu, multi_ext_cfg->offset); =20 --=20 2.41.0