From patchwork Fri Feb 2 15:21:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543031 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2499C48291 for ; Fri, 2 Feb 2024 15:23:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvMn-0008KO-Tr; Fri, 02 Feb 2024 10:22:09 -0500 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 1rVvMl-0008Je-TD for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:07 -0500 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 1rVvMk-0004Tg-BU for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:07 -0500 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d7858a469aso16966455ad.2 for ; Fri, 02 Feb 2024 07:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887324; x=1707492124; 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=L1eBy9OUF1KhxciHsZoO2+9UUkK89QSvYzrFDbFxj1A=; b=MqY74xdAJkrwp1IsTNc0rWFs7/PnlLDDZh7gTxVOsLMNICG8dVWlhVnuveAusAIKw4 tzuRPQ4iHfdr6BhUZuDilLNPhfqik5YRwIJQngbC9oH2c9CVUtnfMkIkch+GX1N/8cDd /GT+8S/zmQkWW55SQ3eyE7+c3Ca/lzqUpazqov0sdh+9v6V77Dh9sSZDSUAxzd0kDsmn shfj0ukugVwrJKzWo7WfvJLrWloQClytdYVMcPZrUOMCNUxaMhObwjR5aP2yRMZn7UFV QxLQq/Y5+IZ/Oq+qXmaMsO26PKUxdvKAiN2mSJif7xi+xBghDTP2OEBFXyJ41rA5pZj+ sFbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887324; x=1707492124; 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=L1eBy9OUF1KhxciHsZoO2+9UUkK89QSvYzrFDbFxj1A=; b=oi4gz/CxYCXr/j+XZd9kCb8cnqHnGqj5gIwh/OPkK8Eux4ge2XmA8RojA9S41xVR6Z N2dVmJdvuUJLD7NM6Ga0oNdSPypQAzOPHJh/jcovUM0HN4SPPbV1X8ApYMMeEooejURc ynYpFUmUlUa4elh6jR80C9avotFVTWbnDab2nnXzarec1br3MPgB6Vav9It2eVNUxxEf u1VVNl2u1ktDYNtDZP7FC2KN8/VfsM7cnPKfrTnItInj8K9rBqppwC0BplhE5APn0ouz qpMeX5KmQoHCHkCcF0TXotSob8axrVGcYzb9g21Ri7Rm1auVfWDRNmUgXkEL3yjAMhZw N/mA== X-Gm-Message-State: AOJu0YxixX1ZQGk5uG0Qe+270km1eGCBawjl10rTnd0fyP1xhOyh/raw HJruJtNp9jZpNry0ItlcsI1RiHjIeLLm0HZ5yVhlY8dU30ot5SHqMX1MbLt0iwHnJQgO0HLgjj1 Z X-Google-Smtp-Source: AGHT+IHHgc10WU5KDxEajZP2C4XS3CdWqS/shyT+hcGqzPWu9BtiGVQEJlNFSg4Wb0QKeGGDRIzx1g== X-Received: by 2002:a17:902:f811:b0:1d9:5038:f116 with SMTP id ix17-20020a170902f81100b001d95038f116mr5246635plb.34.1706887324130; Fri, 02 Feb 2024 07:22:04 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUY+b4a9Uob9vNELTmeFd1bTRPJJ2SJ1QH2j/1JhSUCxCWhj33RQ39TC7JNJ8T7y+R7sGXhVTXqcPtfGo7iRK6yfQMWGOHiqc3qSkuuOhmvaSsfdOv2F1cjdeaTUuCPs9BNg3N21RLFkH/+Zvyg6sGTIpk87z9g5zNus70cO/fLVarGegZuEXif0CgjJbX2XO7PJAm94DDCNwZqiJTV7zEx52EwCGUzOU8RanlCg7vp57SBnCiqr5eXJMKfKuCYFG66KeRag1EQFCB9Ngut/YEORLoK0Gq7KA== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:03 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 1/6] target/riscv/tcg: set 'mmu' with 'satp' in cpu_set_profile() Date: Fri, 2 Feb 2024 12:21:49 -0300 Message-ID: <20240202152154.773253-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Recent changes in options handling removed the 'mmu' default the bare CPUs had, meaning that we must enable 'mmu' by hand when using the rva22s64 profile CPU. Given that this profile is setting a satp mode, it already implies that we need a 'mmu'. Enable the 'mmu' in this case. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- target/riscv/tcg/tcg-cpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index da437975b4..88f92d1c7d 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -1107,6 +1107,7 @@ static void cpu_set_profile(Object *obj, Visitor *v, const char *name, #ifndef CONFIG_USER_ONLY if (profile->satp_mode != RISCV_PROFILE_ATTR_UNUSED) { + object_property_set_bool(obj, "mmu", true, NULL); const char *satp_prop = satp_mode_str(profile->satp_mode, riscv_cpu_is_32bit(cpu)); object_property_set_bool(obj, satp_prop, profile->enabled, NULL); From patchwork Fri Feb 2 15:21:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543035 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2E031C48295 for ; Fri, 2 Feb 2024 15:24:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvMu-0008Lz-Qq; Fri, 02 Feb 2024 10:22:16 -0500 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 1rVvMq-0008Ks-VM for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:13 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVvMo-0004UM-7M for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:12 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d746856d85so17099565ad.0 for ; Fri, 02 Feb 2024 07:22:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887327; x=1707492127; 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=GoIunxXhtFCkVShty0mhpMMgPwob/3WXAOiWsujH6mU=; b=irXiDKYvo+Un/lHZ1sAhXtwLTC1ORSxdDfOMjIfFYKC5oeqmkMoxcgpmagNKWOp1sP eKStE3MyX03CFmUmV1LCcdyxNt1cWyTck//os4qaBZTeUIKdeVc2V+lTwxvC4Xbvnbfb 7gU2tHd8q38+m4tSHpkdEO3G6OTSApprf3WAkWInIPm54drKbBhxluaZgW29S3eES+pZ p3C5/7M8PJ06RoKYbdNjKshCTc4JGKpgqXeG5DC/b5sPXoe1SqK40rEDKy/EM+1LOaKu H8j9+ULO054oefQe1FVTe5Rdgc3DEkXKg3qhYsHPkQEkcivcKhzFY2aI9NBd9ia31nlT rNZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887327; x=1707492127; 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=GoIunxXhtFCkVShty0mhpMMgPwob/3WXAOiWsujH6mU=; b=BMPsERzmB6X744hfz2/gECF+fcnc1aWEGyeTMFQYcwmGvObUwm9fTWOhU+4oOJyMCR 53IHjVoz83l6fkZ/wHwMw0pqwHK1WtGRxm+O+93mtePnf0d2vGuFRcXnTnTG8L4O4Klz RBTBI7mYwfqg0oWMyTOrxtobtXVyGLocfXFLgba95+Yr1ECH2XjfT9af3VuvqAl0eEcC D61uOlj+SMduQut1PuyDEOxYczNPg/ECzyxD703qYIT8qpL4M75TFwG4cAAkMC0NEn1W C2nVPjZKItILt1n0Qt/o3TjVRBj3MCVGf0Fc2n0LqgVwHvjAZqwfjSFISKMjPaRAWcII 7OLQ== X-Gm-Message-State: AOJu0Yx7rLetb2nrQ6GHvwZeKhgsdKM5eogCnu+YIjaLlPGy9o/NLyE2 O6PRofchdyuSwpWovWrvoMt8+K5rLqDgY/2Je9ICDGbCYp8hMK9SBZkBVX4YjzOqmlz7L1ALx1Q z X-Google-Smtp-Source: AGHT+IEB9lQ74SMLh8kDBCsAc4ObcfHaCzVdR/O5FXFxZDiss+YnA28ie1uRuhD3PXdDWb+VCPfEuA== X-Received: by 2002:a17:902:c643:b0:1d8:ef06:12b6 with SMTP id s3-20020a170902c64300b001d8ef0612b6mr1905325pls.39.1706887327219; Fri, 02 Feb 2024 07:22:07 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWOVAJXFKEqGRsAsSjosurg/S3aud6n/tqVyY6Yp1smkhXVdn8vwI8zKJEJSF2yjorWQLfG81u0LyKdaD1513ucfCj1OOuEn+pZSQqMd6kDEreoqlibh9q5wdPBssv15tRN7pNlhVqsvJkZjlUZ5Euq5FAClrRvdGTzdOy9s3hyItsOaKbd8qT08TbBi3z/u9tKAOq2dCoZG5OPY1H45VxxBJiR6lrmhphzs3tS/gIVNPw1foaPvrggp1tIb40ONDk37Px15vXlEgCSEvQ98NwcrB3qiCiTCg== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:06 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 2/6] target/riscv: add riscv,isa to named features Date: Fri, 2 Feb 2024 12:21:50 -0300 Message-ID: <20240202152154.773253-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x634.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Further discussions after the introduction of rva22 support in QEMU revealed that what we've been calling 'named features' are actually regular extensions, with their respective riscv,isa DTs. This is clarified in [1]. [2] is a bug tracker asking for the profile spec to be less cryptic about it. As far as QEMU goes we understand extensions as something that the user can enable/disable in the command line. This isn't the case for named features, so we'll have to reach a middle ground. We'll keep our existing nomenclature 'named features' to refer to any extension that the user can't control in the command line. We'll also do the following: - 'svade' and 'zic64b' flags are renamed to 'ext_svade' and 'ext_zic64b'. 'ext_svade' and 'ext_zic64b' now have riscv,isa strings and priv_spec versions; - skip name feature check in cpu_bump_multi_ext_priv_ver(). Now that named features have a riscv,isa and an entry in isa_edata_arr[] we don't need to gate the call to cpu_cfg_ext_get_min_version() anymore. [1] https://github.com/riscv/riscv-profiles/issues/121 [2] https://github.com/riscv/riscv-profiles/issues/142 Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 17 +++++++++++++---- target/riscv/cpu_cfg.h | 6 ++++-- target/riscv/tcg/tcg-cpu.c | 16 ++++++---------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 88e8cc8681..28d3cfa8ce 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -97,6 +97,7 @@ bool riscv_cpu_option_set(const char *optname) * instead. */ const RISCVIsaExtData isa_edata_arr[] = { + ISA_EXT_DATA_ENTRY(zic64b, PRIV_VERSION_1_12_0, ext_zic64b), ISA_EXT_DATA_ENTRY(zicbom, PRIV_VERSION_1_12_0, ext_zicbom), ISA_EXT_DATA_ENTRY(zicbop, PRIV_VERSION_1_12_0, ext_zicbop), ISA_EXT_DATA_ENTRY(zicboz, PRIV_VERSION_1_12_0, ext_zicboz), @@ -171,6 +172,7 @@ const RISCVIsaExtData isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf), ISA_EXT_DATA_ENTRY(sstc, PRIV_VERSION_1_12_0, ext_sstc), + ISA_EXT_DATA_ENTRY(svade, PRIV_VERSION_1_11_0, ext_svade), ISA_EXT_DATA_ENTRY(svadu, PRIV_VERSION_1_12_0, ext_svadu), ISA_EXT_DATA_ENTRY(svinval, PRIV_VERSION_1_12_0, ext_svinval), ISA_EXT_DATA_ENTRY(svnapot, PRIV_VERSION_1_12_0, ext_svnapot), @@ -1510,9 +1512,16 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { DEFINE_PROP_END_OF_LIST(), }; +/* + * 'Named features' is the name we give to extensions that we + * don't want to expose to users. They are either immutable + * (always enabled/disable) or they'll vary depending on + * the resulting CPU state. They have riscv,isa strings + * and priv_ver like regular extensions. + */ const RISCVCPUMultiExtConfig riscv_cpu_named_features[] = { - MULTI_EXT_CFG_BOOL("svade", svade, true), - MULTI_EXT_CFG_BOOL("zic64b", zic64b, true), + MULTI_EXT_CFG_BOOL("svade", ext_svade, true), + MULTI_EXT_CFG_BOOL("zic64b", ext_zic64b, true), DEFINE_PROP_END_OF_LIST(), }; @@ -2130,7 +2139,7 @@ static RISCVCPUProfile RVA22U64 = { CPU_CFG_OFFSET(ext_zicbop), CPU_CFG_OFFSET(ext_zicboz), /* mandatory named features for this profile */ - CPU_CFG_OFFSET(zic64b), + CPU_CFG_OFFSET(ext_zic64b), RISCV_PROFILE_EXT_LIST_END } @@ -2161,7 +2170,7 @@ static RISCVCPUProfile RVA22S64 = { CPU_CFG_OFFSET(ext_svinval), /* rva22s64 named features */ - CPU_CFG_OFFSET(svade), + CPU_CFG_OFFSET(ext_svade), RISCV_PROFILE_EXT_LIST_END } diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index e241922f89..698f926ab1 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -117,13 +117,15 @@ struct RISCVCPUConfig { bool ext_smepmp; bool rvv_ta_all_1s; bool rvv_ma_all_1s; - bool svade; - bool zic64b; uint32_t mvendorid; uint64_t marchid; uint64_t mimpid; + /* Named features */ + bool ext_svade; + bool ext_zic64b; + /* Vendor-specific custom extensions */ bool ext_xtheadba; bool ext_xtheadbb; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 88f92d1c7d..90861cc065 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -197,12 +197,12 @@ static bool cpu_cfg_offset_is_named_feat(uint32_t ext_offset) static void riscv_cpu_enable_named_feat(RISCVCPU *cpu, uint32_t feat_offset) { switch (feat_offset) { - case CPU_CFG_OFFSET(zic64b): + case CPU_CFG_OFFSET(ext_zic64b): cpu->cfg.cbom_blocksize = 64; cpu->cfg.cbop_blocksize = 64; cpu->cfg.cboz_blocksize = 64; break; - case CPU_CFG_OFFSET(svade): + case CPU_CFG_OFFSET(ext_svade): cpu->cfg.ext_svadu = false; break; default: @@ -219,10 +219,6 @@ static void cpu_bump_multi_ext_priv_ver(CPURISCVState *env, return; } - if (cpu_cfg_offset_is_named_feat(ext_offset)) { - return; - } - ext_priv_ver = cpu_cfg_ext_get_min_version(ext_offset); if (env->priv_ver < ext_priv_ver) { @@ -349,11 +345,11 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu) static void riscv_cpu_update_named_features(RISCVCPU *cpu) { - cpu->cfg.zic64b = cpu->cfg.cbom_blocksize == 64 && - cpu->cfg.cbop_blocksize == 64 && - cpu->cfg.cboz_blocksize == 64; + cpu->cfg.ext_zic64b = cpu->cfg.cbom_blocksize == 64 && + cpu->cfg.cbop_blocksize == 64 && + cpu->cfg.cboz_blocksize == 64; - cpu->cfg.svade = !cpu->cfg.ext_svadu; + cpu->cfg.ext_svade = !cpu->cfg.ext_svadu; } static void riscv_cpu_validate_g(RISCVCPU *cpu) From patchwork Fri Feb 2 15:21:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543034 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5AA4EC4828F for ; Fri, 2 Feb 2024 15:24:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvMu-0008MG-DK; Fri, 02 Feb 2024 10:22:16 -0500 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 1rVvMs-0008LT-F9 for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:14 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rVvMq-0004VE-B6 for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:14 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d73066880eso18963105ad.3 for ; Fri, 02 Feb 2024 07:22:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887330; x=1707492130; 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=crMs0TjlIW4LbTUJXKCF3/deGXPHxSvc3WCGvBYMo2o=; b=Ig50XAki2gnkp168Sj0GWfj86+gGnbDKBtHMZDSF7g4IfrO8xi6C50JDiOWYib2BaK dQDlysjN+bNipMrAMkNcJpQm4GasvhsVncXmv/K9ufKAObR3pIQ0pV6+0r+yLm4kiiNJ Y9svuPOGC9pRywiyLYVtSq0oJii/7JNFrFcy7PoWwxgXr4PuieiEKD+zVbePAVohvZ6c 2KT0WhSQ7sLm6H6vby98VkmZYA+fkQeScH+sK/3yUbVHEoKOkUN31fH8CEgJGNq0coxI HMidWJwc3AycUGk1etd3K9hMVDfD8oNcPK9Ugc6lMp/rWC0UQMzh1VG69dvDpqm8ZUaR UUBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887330; x=1707492130; 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=crMs0TjlIW4LbTUJXKCF3/deGXPHxSvc3WCGvBYMo2o=; b=Bsy+XExWl9mj73VBdUulNDyuLYSe+KOxkJgeV+IjfxDVQqlqIMph5FHIqWHlDSXWuQ bajjUSuoOHDyTF43jbkSCpbRtf57UMbOus5589vlv0fLAS1kUYYJZHUvR4nkSPRycgEr eJHJ7ckPm+cIPy1h7Tfj1jjzoSLWORap0Ha6m19fbdaw6qf7530gnQnDC75Pi0olcOPl Q+Dkg2MpQKIe6XV+Dj6FtZ/Rcb09nio4e/noj9GrqRiqWSeHLFiI8JKgM6in8Vhb1Kho Yd9BxbACmWrGqV7c2ZK9jWyvSNQLaEuUf6BiN0CCBtVH7nVwgovxpalz/WcGvpCoF7HV AeJA== X-Gm-Message-State: AOJu0YwCd+kOc5e1f37qlHupiKzlPSroAe5F7QPgxlqC7fymO1tTF2yI MTEgSm5mGqKYKoDE3uY2xU6fS+jyswEO/RMB21UT6UjLjFIoXsDrffnzusRzIxtFERQSg9JRowF a X-Google-Smtp-Source: AGHT+IGcJv3l8xid/Rk44dgQjXYbJ9MvHk8sLRdxHIFGUQeGxk1oF4JOtfY3glBNi7GvtXKEVgrMwg== X-Received: by 2002:a17:902:e844:b0:1d8:ec96:ad43 with SMTP id t4-20020a170902e84400b001d8ec96ad43mr10150786plg.12.1706887330314; Fri, 02 Feb 2024 07:22:10 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVDMFsSzYO6uiI+j7IGOHl4eXP4xJrDjXCpvEpNAYfD6maWsNUC5M0fNW00F7sJ7//BP0DK1ouvs5peOA4KvxUWAPVPQ5d7/CwREekDSc4REhZ6YEF4mt7jjBJZBGfCCk47yvnYJLFP29zmeBlWIyNRJZgk51i1WQCm7sPj2Uvdgko+vY9YGOrJ+zAgpAiC8x4mTX+ghgCc2oXDj1tJkr+HrIyhQWvNYXThuz6Vny1EGqyn89sUYzo04KjCcdJQLQeWFvny4iGiBtb1S9iQ8Hcs2mzNxU1oaQ== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:09 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 3/6] target/riscv: add remaining named features Date: Fri, 2 Feb 2024 12:21:51 -0300 Message-ID: <20240202152154.773253-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x634.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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The RVA22U64 and RVA22S64 profiles mandates certain extensions that, until now, we were implying that they were available. We can't do this anymore since named features also has a riscv,isa entry. Let's add them to riscv_cpu_named_features[]. Instead of adding one bool for each named feature that we'll always implement, i.e. can't be turned off, add a 'ext_always_enabled' bool in cpu->cfg. This bool will be set to 'true' in TCG accel init, and all named features will point to it. This also means that KVM won't see these features as always enable, which is our intention. If any accelerator adds support to disable one of these features, we'll have to promote them to regular extensions and allow users to disable it via command line. After this patch, here's the riscv,isa from a buildroot using the 'rva22s64' CPU: # cat /proc/device-tree/cpus/cpu@0/riscv,isa rv64imafdc_zic64b_zicbom_zicbop_zicboz_ziccamoa_ziccif_zicclsm_ziccrse_ zicntr_zicsr_zifencei_zihintpause_zihpm_za64rs_zfhmin_zca_zcd_zba_zbb_ zbs_zkt_ssccptr_sscounterenw_sstvala_sstvecd_svade_svinval_svpbmt# Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 42 +++++++++++++++++++++++++++++++------- target/riscv/cpu_cfg.h | 6 ++++++ target/riscv/tcg/tcg-cpu.c | 2 ++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 28d3cfa8ce..94843c4f6e 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -101,6 +101,10 @@ const RISCVIsaExtData isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(zicbom, PRIV_VERSION_1_12_0, ext_zicbom), ISA_EXT_DATA_ENTRY(zicbop, PRIV_VERSION_1_12_0, ext_zicbop), ISA_EXT_DATA_ENTRY(zicboz, PRIV_VERSION_1_12_0, ext_zicboz), + ISA_EXT_DATA_ENTRY(ziccamoa, PRIV_VERSION_1_11_0, ext_always_enabled), + ISA_EXT_DATA_ENTRY(ziccif, PRIV_VERSION_1_11_0, ext_always_enabled), + ISA_EXT_DATA_ENTRY(zicclsm, PRIV_VERSION_1_11_0, ext_always_enabled), + ISA_EXT_DATA_ENTRY(ziccrse, PRIV_VERSION_1_11_0, ext_always_enabled), ISA_EXT_DATA_ENTRY(zicond, PRIV_VERSION_1_12_0, ext_zicond), ISA_EXT_DATA_ENTRY(zicntr, PRIV_VERSION_1_12_0, ext_zicntr), ISA_EXT_DATA_ENTRY(zicsr, PRIV_VERSION_1_10_0, ext_zicsr), @@ -109,6 +113,7 @@ const RISCVIsaExtData isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(zihintpause, PRIV_VERSION_1_10_0, ext_zihintpause), ISA_EXT_DATA_ENTRY(zihpm, PRIV_VERSION_1_12_0, ext_zihpm), ISA_EXT_DATA_ENTRY(zmmul, PRIV_VERSION_1_12_0, ext_zmmul), + ISA_EXT_DATA_ENTRY(za64rs, PRIV_VERSION_1_12_0, ext_always_enabled), ISA_EXT_DATA_ENTRY(zacas, PRIV_VERSION_1_12_0, ext_zacas), ISA_EXT_DATA_ENTRY(zawrs, PRIV_VERSION_1_12_0, ext_zawrs), ISA_EXT_DATA_ENTRY(zfa, PRIV_VERSION_1_12_0, ext_zfa), @@ -170,8 +175,12 @@ const RISCVIsaExtData isa_edata_arr[] = { ISA_EXT_DATA_ENTRY(smepmp, PRIV_VERSION_1_12_0, ext_smepmp), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen), ISA_EXT_DATA_ENTRY(ssaia, PRIV_VERSION_1_12_0, ext_ssaia), + ISA_EXT_DATA_ENTRY(ssccptr, PRIV_VERSION_1_11_0, ext_always_enabled), ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf), + ISA_EXT_DATA_ENTRY(sscounterenw, PRIV_VERSION_1_12_0, ext_always_enabled), ISA_EXT_DATA_ENTRY(sstc, PRIV_VERSION_1_12_0, ext_sstc), + ISA_EXT_DATA_ENTRY(sstvala, PRIV_VERSION_1_12_0, ext_always_enabled), + ISA_EXT_DATA_ENTRY(sstvecd, PRIV_VERSION_1_12_0, ext_always_enabled), ISA_EXT_DATA_ENTRY(svade, PRIV_VERSION_1_11_0, ext_svade), ISA_EXT_DATA_ENTRY(svadu, PRIV_VERSION_1_12_0, ext_svadu), ISA_EXT_DATA_ENTRY(svinval, PRIV_VERSION_1_12_0, ext_svinval), @@ -1512,6 +1521,11 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { DEFINE_PROP_END_OF_LIST(), }; +#define ALWAYS_ENABLED_FEATURE(_name) \ + {.name = _name, \ + .offset = CPU_CFG_OFFSET(ext_always_enabled), \ + .enabled = true} + /* * 'Named features' is the name we give to extensions that we * don't want to expose to users. They are either immutable @@ -1523,6 +1537,23 @@ const RISCVCPUMultiExtConfig riscv_cpu_named_features[] = { MULTI_EXT_CFG_BOOL("svade", ext_svade, true), MULTI_EXT_CFG_BOOL("zic64b", ext_zic64b, true), + /* + * cache-related extensions that are always enabled + * in TCG since QEMU RISC-V does not have a cache + * model. + */ + ALWAYS_ENABLED_FEATURE("za64rs"), + ALWAYS_ENABLED_FEATURE("ziccif"), + ALWAYS_ENABLED_FEATURE("ziccrse"), + ALWAYS_ENABLED_FEATURE("ziccamoa"), + ALWAYS_ENABLED_FEATURE("zicclsm"), + ALWAYS_ENABLED_FEATURE("ssccptr"), + + /* Other named features that TCG always implements */ + ALWAYS_ENABLED_FEATURE("sstvecd"), + ALWAYS_ENABLED_FEATURE("sstvala"), + ALWAYS_ENABLED_FEATURE("sscounterenw"), + DEFINE_PROP_END_OF_LIST(), }; @@ -2116,13 +2147,10 @@ static const PropertyInfo prop_marchid = { }; /* - * RVA22U64 defines some 'named features' or 'synthetic extensions' - * that are cache related: Za64rs, Zic64b, Ziccif, Ziccrse, Ziccamoa - * and Zicclsm. We do not implement caching in QEMU so we'll consider - * all these named features as always enabled. - * - * There's no riscv,isa update for them (nor for zic64b, despite it - * having a cfg offset) at this moment. + * RVA22U64 defines some 'named features' that are cache + * related: Za64rs, Zic64b, Ziccif, Ziccrse, Ziccamoa + * and Zicclsm. They are always implemented in TCG and + * doesn't need to be manually enabled by the profile. */ static RISCVCPUProfile RVA22U64 = { .parent = NULL, diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 698f926ab1..c5049ec664 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -126,6 +126,12 @@ struct RISCVCPUConfig { bool ext_svade; bool ext_zic64b; + /* + * Always 'true' boolean for named features + * TCG always implement/can't be disabled. + */ + bool ext_always_enabled; + /* Vendor-specific custom extensions */ bool ext_xtheadba; bool ext_xtheadbb; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 90861cc065..673097c6e4 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -1347,6 +1347,8 @@ static void riscv_tcg_cpu_instance_init(CPUState *cs) RISCVCPU *cpu = RISCV_CPU(cs); Object *obj = OBJECT(cpu); + cpu->cfg.ext_always_enabled = true; + misa_ext_user_opts = g_hash_table_new(NULL, g_direct_equal); multi_ext_user_opts = g_hash_table_new(NULL, g_direct_equal); riscv_cpu_add_user_properties(obj); From patchwork Fri Feb 2 15:21:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543033 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C1F5EC48291 for ; Fri, 2 Feb 2024 15:23:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvMy-0008Mw-UI; Fri, 02 Feb 2024 10:22:20 -0500 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 1rVvMx-0008Mh-76 for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:19 -0500 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 1rVvMt-0004W5-GH for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:17 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d71cb97937so20948815ad.3 for ; Fri, 02 Feb 2024 07:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887333; x=1707492133; 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=fxKoQ94zKlqMPCHHDl0lpsAYUVMqT6+u0BOsNpnJVKQ=; b=NrD/L9pLQlCfSKrmakZWkZ851jj4ACkHnLxH8Q6b9v5zvnFlKH2FtE6A8793FxsM91 k45T7lpAoKTWeiOMXakqaDMZDjgh/f5QkXRpk6w64M4M3pW4jqNDFGa5gPm9Nfia7POJ ulVCFUHA5t/eBvZ9EyikMng+nBoxJpbqR0RuVHQdcBcHb+89psKooqgfHRgWPS3qVu0O 48g7Hl4rKj7Q36DqKoqFGUZ3HZxejQExV0KndQkG/B/nQLpL5e1Fr5wO2S40vqDwfIOS sZLidxVxmwurEjD00aD8i5FnmNhnP2K0BSQQ6Vb7oPz6Bn4JEilyuFgY7ku7t2LvgVMs +meQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887333; x=1707492133; 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=fxKoQ94zKlqMPCHHDl0lpsAYUVMqT6+u0BOsNpnJVKQ=; b=JUh/N3Ar6daIHhD/qIMXRo3M/qmtk/db6eh3AnQfJIRpMgtB5u135V2iUSL8M6McDS RTsNzbKJIxJdoae2AfFD0Xi/vLQNSj5k6KVihkGftXVM+r/eC6UexP/Tnyz420W41iXR akuuKny7d+m//ZK2OwVCsFnguaAgULOpULLKtyPfp9ZtdTNU9Kll7UnrsKpHMjNU3wOd TiAviFJz/G08GKEjuWukVgru8OcZRI5wKLHGX7D15W9SiBJvL26ZXBpLxeGnbyM+OIwm uarXgsOwpluAep79cpZM1kpx5jZMMT6XuboVuYPcQpJSLZ9/ncwqohL7fJg42lCJ76xk E8AQ== X-Gm-Message-State: AOJu0Yw1VMwXaNxC2djaOU23tvL9v2j1Aa9vxEdLdRLdvxI+ZuzZGAYK E6nnvNcKE023TrieC0u4BiyDGjEdPjscm4tNIl5AcArc+/us2uzzCBUFFItASRAme1xibzCTxAy e X-Google-Smtp-Source: AGHT+IGeKfI3rE5yQ1xzei8JXqlGxs5Y2nUTMqBsYExa8HRDj551u6lvjbx+vpihFZxFbA118igXww== X-Received: by 2002:a17:903:40cc:b0:1d9:8b7:52b3 with SMTP id t12-20020a17090340cc00b001d908b752b3mr10918984pld.10.1706887333225; Fri, 02 Feb 2024 07:22:13 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXnqd7ivKG+QDlhPAE+WhPavl4RJWsgvEYzZlRzQf6YgetxkymCAjNbsCEXu+0x6Vd0SKzpvMH0VzuOWnhTN7OIgSylNMeyOr61r6QRf9JR0g1J/UeI+xXJwPbWbbrmik8bpkgV5+D54Nn0JY1DGjeExuLOUhDKiYCOcZrognVQSlx8BYMfMYqsn6OtL/2fdep6D8DffEnXIeKj0g3rlsNoRTQ9IE2XyOQUTZKuDxOOCSth1SgHhMOKUjv9zZRVeoG6rqHSbEAsBIcGQvnLtGVL8U4pDn499g== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:12 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 4/6] target/riscv: Reset henvcfg to zero Date: Fri, 2 Feb 2024 12:21:52 -0300 Message-ID: <20240202152154.773253-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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: -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=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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Andrew Jones The hypervisor should decide what it wants to enable. Zero all configuration enable bits on reset. Also, commit ed67d63798f2 ("target/riscv: Update CSR bits name for svadu extension") missed one reference to 'hade'. Change it now. Fixes: 0af3f115e68e ("target/riscv: Add *envcfg.HADE related check in address translation") Fixes: ed67d63798f2 ("target/riscv: Update CSR bits name for svadu extension") Reviewed-by: Daniel Henrique Barboza Signed-off-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 3 +-- target/riscv/csr.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 94843c4f6e..9045f87481 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -961,8 +961,7 @@ static void riscv_cpu_reset_hold(Object *obj) env->menvcfg = (cpu->cfg.ext_svpbmt ? MENVCFG_PBMTE : 0) | (cpu->cfg.ext_svadu ? MENVCFG_ADUE : 0); - env->henvcfg = (cpu->cfg.ext_svpbmt ? HENVCFG_PBMTE : 0) | - (cpu->cfg.ext_svadu ? HENVCFG_ADUE : 0); + env->henvcfg = 0; /* Initialized default priorities of local interrupts. */ for (i = 0; i < ARRAY_SIZE(env->miprio); i++) { diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d9a010387f..93f7bc2cb4 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2115,7 +2115,7 @@ static RISCVException read_henvcfg(CPURISCVState *env, int csrno, /* * henvcfg.pbmte is read_only 0 when menvcfg.pbmte = 0 * henvcfg.stce is read_only 0 when menvcfg.stce = 0 - * henvcfg.hade is read_only 0 when menvcfg.hade = 0 + * henvcfg.adue is read_only 0 when menvcfg.adue = 0 */ *val = env->henvcfg & (~(HENVCFG_PBMTE | HENVCFG_STCE | HENVCFG_ADUE) | env->menvcfg); From patchwork Fri Feb 2 15:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543029 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6C806C48291 for ; Fri, 2 Feb 2024 15:23:31 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvN0-0008P0-CS; Fri, 02 Feb 2024 10:22:22 -0500 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 1rVvMy-0008Mt-R9 for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:20 -0500 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 1rVvMv-0004Wn-TP for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:20 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d934c8f8f7so19858035ad.2 for ; Fri, 02 Feb 2024 07:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887336; x=1707492136; 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=anWEskpMfYSpOmzCuTelqUtl/bkEW7KZuVaTU0mxJhE=; b=Nt+/BQRe6CmF1v4b4avBbiWSTqQgFD3NckxBg/OIljXPZDJtyUzCFQWRBzILU2DAgc fhQ2AH92+TRnEzA2IyJMZ7HWgHUCYYIi4b4yWEzxNdnVw7M+rDYmjWp9vMiEfjwYJOCc /2qG2a5T0GsYiqlohbddRtXndlauWoGPalqBfR64isZWnr805PIwUAf8rqqv5iYsFxo2 3LlA89s0I/tvLI04iOGMz6Cj9nlkwFFMmbtzCKyiSVPOU991qirUef4Q1R2MMwcYoYPf PzahHvuElCQSFo44BA5K6o/zBGIp9Ck539ujnikwxHMyIn4djmIinDEu4PqWIEGUbGM2 SlHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887336; x=1707492136; 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=anWEskpMfYSpOmzCuTelqUtl/bkEW7KZuVaTU0mxJhE=; b=nuFfNW8a0ZtTmuZ4IabO3NZNg/a4jIJ+D5jz15lgEMKJ/WShs5DawNa8w1IqlTE5C2 0/md5zSoUduAb0CYhpSLGzxfy6F8bRIqau+eITy8JfezTPzs94BsakYpKshk6VCtpDDn eBuB6LN1e22Hopb3cTY2AJk01dRVdXjGA440fiWMd0etJH1KaAY7V4HQGM8oTzCWBcmp fUvy61mKdrpHlii8aTPTDgt29q9A2Pz4kVfrETg2GMQOWrniQjxxNEopM2nS+y1PcUfb 3IGJKt2g0WFvJfHqQ4bjeHoXwKoCTM7i1kGEJUv0krvb5EMZCZ1buGY0f2XBwyqEBZCs DScA== X-Gm-Message-State: AOJu0YwBoRwYWK9VMt/i7UfVcAnaVfKmd+AU11lB708Bhvg6AkEsngi4 Bz+xX/FRPSpruK3h88dA0PKVEt5HZblyiU/4mEc14MBFoLaGvJTYwFShdZ8QdI1c4IKTaykd0TD p X-Google-Smtp-Source: AGHT+IE+hS26wdIHKQ8z7rcq7rrPmSeGFGMImUYRoIyFca8TEGTDf11ZhRA/VZl/zmTIIj4Sn9vplQ== X-Received: by 2002:a17:902:7d87:b0:1d8:a5c7:a383 with SMTP id a7-20020a1709027d8700b001d8a5c7a383mr4799907plm.60.1706887336122; Fri, 02 Feb 2024 07:22:16 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWg8r0g33+iSTrGclldXtZRykaLvP5JIiZo9cglgwQDmzo7U2RhXsG3nkmP7CEw+RBX0hdfj76lbUxBWMNpX62wuVg1P92UPyitUPZKxdlL8Ah2YfhjOJOqKmzFhYUbZN0B6KiAFUtvoUHwoJt0caopIB7U8/soKYqUPCMPIogk6b7n0gFG/qI5mHUhK2ocC/TPm3HpEufUNGNNkGSPX4X138QJP4zdcsKh+Ve2+X5i7tlFlSX0W54y4yKBtlOqaOWlnN0ln1KGdsM54hP6aGkAYSRqFT7zaA== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:15 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 5/6] target/riscv: Gate hardware A/D PTE bit updating Date: Fri, 2 Feb 2024 12:21:53 -0300 Message-ID: <20240202152154.773253-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Andrew Jones Gate hardware A/D PTE bit updating on {m,h}envcfg.ADUE and only enable menvcfg.ADUE on reset if svade has not been selected. Now that we also consider svade, we have four possible configurations: 1) !svade && !svadu use hardware updating and there's no way to disable it (the default, which maintains past behavior. Maintaining the default, even with !svadu is a change that fixes [1]) 2) !svade && svadu use hardware updating, but also provide {m,h}envcfg.ADUE, allowing software to switch to exception mode (being able to switch is a change which fixes [1]) 3) svade && !svadu use exception mode and there's no way to switch to hardware updating (this behavior change fixes [2]) 4) svade && svadu use exception mode, but also provide {m,h}envcfg.ADUE, allowing software to switch to hardware updating (this behavior change fixes [2]) Fixes: 0af3f115e68e ("target/riscv: Add *envcfg.HADE related check in address translation") [1] Fixes: 48531f5adb2a ("target/riscv: implement svade") [2] Reviewed-by: Daniel Henrique Barboza Signed-off-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 3 ++- target/riscv/cpu_helper.c | 19 +++++++++++++++---- target/riscv/tcg/tcg-cpu.c | 15 +++++---------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 9045f87481..50ac7845a8 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -960,7 +960,8 @@ static void riscv_cpu_reset_hold(Object *obj) env->two_stage_lookup = false; env->menvcfg = (cpu->cfg.ext_svpbmt ? MENVCFG_PBMTE : 0) | - (cpu->cfg.ext_svadu ? MENVCFG_ADUE : 0); + (!cpu->cfg.ext_svade && cpu->cfg.ext_svadu ? + MENVCFG_ADUE : 0); env->henvcfg = 0; /* Initialized default priorities of local interrupts. */ diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 8da9104da4..3a440833f8 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -907,7 +907,9 @@ static int get_physical_address(CPURISCVState *env, hwaddr *physical, } bool pbmte = env->menvcfg & MENVCFG_PBMTE; - bool adue = env->menvcfg & MENVCFG_ADUE; + bool svade = riscv_cpu_cfg(env)->ext_svade; + bool svadu = riscv_cpu_cfg(env)->ext_svadu; + bool adue = svadu ? env->menvcfg & MENVCFG_ADUE : !svade; if (first_stage && two_stage && env->virt_enabled) { pbmte = pbmte && (env->henvcfg & HENVCFG_PBMTE); @@ -1082,9 +1084,18 @@ restart: return TRANSLATE_FAIL; } - /* If necessary, set accessed and dirty bits. */ - target_ulong updated_pte = pte | PTE_A | - (access_type == MMU_DATA_STORE ? PTE_D : 0); + target_ulong updated_pte = pte; + + /* + * If ADUE is enabled, set accessed and dirty bits. + * Otherwise raise an exception if necessary. + */ + if (adue) { + updated_pte |= PTE_A | (access_type == MMU_DATA_STORE ? PTE_D : 0); + } else if (!(pte & PTE_A) || + (access_type == MMU_DATA_STORE && !(pte & PTE_D))) { + return TRANSLATE_FAIL; + } /* Page table updates need to be atomic with MTTCG enabled */ if (updated_pte != pte && !is_debug) { diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 673097c6e4..43c32b4a15 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -196,17 +196,14 @@ static bool cpu_cfg_offset_is_named_feat(uint32_t ext_offset) static void riscv_cpu_enable_named_feat(RISCVCPU *cpu, uint32_t feat_offset) { - switch (feat_offset) { - case CPU_CFG_OFFSET(ext_zic64b): + /* + * All other named features are already enabled + * in riscv_tcg_cpu_instance_init(). + */ + if (feat_offset == CPU_CFG_OFFSET(ext_zic64b)) { cpu->cfg.cbom_blocksize = 64; cpu->cfg.cbop_blocksize = 64; cpu->cfg.cboz_blocksize = 64; - break; - case CPU_CFG_OFFSET(ext_svade): - cpu->cfg.ext_svadu = false; - break; - default: - g_assert_not_reached(); } } @@ -348,8 +345,6 @@ static void riscv_cpu_update_named_features(RISCVCPU *cpu) cpu->cfg.ext_zic64b = cpu->cfg.cbom_blocksize == 64 && cpu->cfg.cbop_blocksize == 64 && cpu->cfg.cboz_blocksize == 64; - - cpu->cfg.ext_svade = !cpu->cfg.ext_svadu; } static void riscv_cpu_validate_g(RISCVCPU *cpu) From patchwork Fri Feb 2 15:21:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 13543032 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 503E0C4828F for ; Fri, 2 Feb 2024 15:23:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rVvN2-0008QQ-4m; Fri, 02 Feb 2024 10:22:24 -0500 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 1rVvN0-0008PW-Oy for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:22 -0500 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 1rVvMz-0004Xj-3D for qemu-devel@nongnu.org; Fri, 02 Feb 2024 10:22:22 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1d93f2c3701so13354555ad.3 for ; Fri, 02 Feb 2024 07:22:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706887339; x=1707492139; 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=8DbEnVS8J5zrAAvxjFOvjXj3Aby0zHgBTzHL04v/6hI=; b=bu1HXh/0M0bpccN9i285lZ2Pui8JwXdPLjk/SJSopPJ6mQ+GyMJaV+hA9SbtYV9FdV f6RGrQVoIQFG+PesSzPn4yNBqTL71UJaaIVhWHGuxBL6UPelrYDeje/AWVFTiBQgkHkw DkgYJoeI/0hzksPqBvRGy9Woo7/310fGZuQKVfB/fGnz6rvPvlKkkTZBwXjiKF7+mSNM HUhoaEH8ADs4ZDkEjFUL2xmeCFAkeLH+DGq5rDZJE0IewiOCAtgI6cxarozgm9vEbqdS 32O91aIpS16wcezaAhuV+5VANsbgmJ3+gHdYtozfF1D/VT8hZWiNJhzKAqCX2e+pSM/q f8fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706887339; x=1707492139; 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=8DbEnVS8J5zrAAvxjFOvjXj3Aby0zHgBTzHL04v/6hI=; b=k1dEZHhOw2inGzxnMrE25xU0dwuGDFlhL0U/cakPPX5CAg380tcRkm2WUFBxKp+JHb dV89rmkbpkS4JFdbOilqzmQY2B8fCo1JMlkh58XZf0c3qh2muu7le+1L9RlWkRKiJC2H 9DducKYCpOWbFklFbZDOquicmKDVIgm7a9kb1CZf9575+JplAvltEPW6SGSea4HnUOD0 4eYqdktew2je3Fd95MJ0mOKGwVvC+2/t4ECLPA42haYIGokkjFWoDEaH0qXiIl/phXWu QAU/zK5kjing7/GSgyKz/pz68infxtB50+vAOFEv00hJor/bt1JDVsdbODP2CwS7BUYn wMRg== X-Gm-Message-State: AOJu0YwT1/3uwEMBrBEV1mmfsd9P+pxtv1UeU8f+a0DpKBBkcNPMmi9v 2U0D5N89XsO6eedkVcgsrWXmVp5jhezqRqRUib5N5hhfgU+paCTNxfEWs4n+CrM1WbFqpFDDBX8 v X-Google-Smtp-Source: AGHT+IHT1XsNDgSPfUCCCDiPFwVqOBxjOssyPrbHFUL5Srg8UbHJoglxOPQpP/cqrFzTtPOkNYPPaQ== X-Received: by 2002:a17:902:d488:b0:1d7:102b:2e60 with SMTP id c8-20020a170902d48800b001d7102b2e60mr9660353plg.52.1706887339086; Fri, 02 Feb 2024 07:22:19 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUzswlhazj650tmffHcSUO3FplQtlkk3cjoVrz7L2N1uUqSGVmFqPHh1cuKEuoANGdVjI0rMUD0uTzxSGH6fOBmkRLhAcge6IrjCO31Cp7Z5CuQBwFzftE1X0R5bR03mF49GxRBYP7kfn2pjDXkcg1tNAmMm2RMvgsjBjyluXSmhMkAAwIi+ivJUdhSsSz1EQakWopl5XIQ3/tlrWmJA6BulkH7KPgAtNqRbJ17mcoCSkYazEFXC9PgJDhtu07ws+QEeau82bMCzy8XYabmrSLcByV1ogJ8CQ== Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id j3-20020a170902f24300b001d714a1530bsm1734381plc.176.2024.02.02.07.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 07:22:18 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v3 6/6] target/riscv: Promote svade to a normal extension Date: Fri, 2 Feb 2024 12:21:54 -0300 Message-ID: <20240202152154.773253-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202152154.773253-1-dbarboza@ventanamicro.com> References: <20240202152154.773253-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Andrew Jones Named features are extensions which don't make sense for users to control and are therefore not exposed on the command line. However, svade is an extension which makes sense for users to control, so treat it like a "normal" extension. The default is false, even for the max cpu type, since QEMU has always implemented hardware A/D PTE bit updating, so users must opt into svade (or get it from a CPU type which enables it by default). Reviewed-by: Daniel Henrique Barboza Signed-off-by: Andrew Jones Reviewed-by: Alistair Francis --- target/riscv/cpu.c | 9 ++------- target/riscv/tcg/tcg-cpu.c | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 50ac7845a8..f036b153a1 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1422,6 +1422,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { MULTI_EXT_CFG_BOOL("smepmp", ext_smepmp, false), MULTI_EXT_CFG_BOOL("smstateen", ext_smstateen, false), + MULTI_EXT_CFG_BOOL("svade", ext_svade, false), MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true), MULTI_EXT_CFG_BOOL("svinval", ext_svinval, false), MULTI_EXT_CFG_BOOL("svnapot", ext_svnapot, false), @@ -1534,7 +1535,6 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = { * and priv_ver like regular extensions. */ const RISCVCPUMultiExtConfig riscv_cpu_named_features[] = { - MULTI_EXT_CFG_BOOL("svade", ext_svade, true), MULTI_EXT_CFG_BOOL("zic64b", ext_zic64b, true), /* @@ -2182,8 +2182,6 @@ static RISCVCPUProfile RVA22U64 = { * Other named features that we already implement: Sstvecd, Sstvala, * Sscounterenw * - * Named features that we need to enable: svade - * * The remaining features/extensions comes from RVA22U64. */ static RISCVCPUProfile RVA22S64 = { @@ -2195,10 +2193,7 @@ static RISCVCPUProfile RVA22S64 = { .ext_offsets = { /* rva22s64 exts */ CPU_CFG_OFFSET(ext_zifencei), CPU_CFG_OFFSET(ext_svpbmt), - CPU_CFG_OFFSET(ext_svinval), - - /* rva22s64 named features */ - CPU_CFG_OFFSET(ext_svade), + CPU_CFG_OFFSET(ext_svinval), CPU_CFG_OFFSET(ext_svade), RISCV_PROFILE_EXT_LIST_END } diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 43c32b4a15..9fc64979f1 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -1314,6 +1314,12 @@ static void riscv_init_max_cpu_extensions(Object *obj) isa_ext_update_enabled(cpu, prop->offset, true); } + /* + * Some extensions can't be added without backward compatibilty concerns. + * Disable those, the user can still opt in to them on the command line. + */ + cpu->cfg.ext_svade = false; + /* set vector version */ env->vext_ver = VEXT_VERSION_1_00_0;