From nobody Wed Nov 27 04:52:23 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=1700766985; cv=none; d=zohomail.com; s=zohoarc; b=FFgTHp4d8B9paEj+dCID/z7za3CWFf/l/SV42gs7qDX1fk39Gvt6oOk+XzkoCoMPJsQ/NKyfR8VA/QSqncS8/8NLlWSQmrwRO/bq7y8vjaeWBis58U5dT4HF0C6+VWc7NZ5VA6YOZIIUX9JubG2cb+deblo0kp/yaSqTFXMf4ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700766985; 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=JF5lkWbAc2C1VZm8P9TGmUDxxgv7XlATDWqvy4zet8o=; b=ZJey1r3L+PTu8YuiFNC1d4NmSNwlQHI06X57Sq6T3i2uo/Y9SD8saOv1RpPiu90V2epMwJpEBKe7Y80LVPGs9Cvrs5SNexJFSxKOkk4R4laPYW9gjzo+o9TMus2e/rb7yMQ08In4qR/OVruKtqIgpgqUT+N26ZOK8sI0sdiOh2s= 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 1700766985087262.5481134160507; Thu, 23 Nov 2023 11:16:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FB1-0008Q6-HE; Thu, 23 Nov 2023 14:15:51 -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 1r6FAv-0008Jf-2N for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:45 -0500 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6FAt-0003hw-Do for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:44 -0500 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ce656b9780so8458875ad.2 for ; Thu, 23 Nov 2023 11:15:42 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766941; x=1701371741; 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=JF5lkWbAc2C1VZm8P9TGmUDxxgv7XlATDWqvy4zet8o=; b=DZB2J/8ifAAuh4GDE5f19jnSGrf8wf21bZm6AKlx1ODiCnQqztCTzOgNCJwmwFJ6zi lXuLsRDgl3OUqIYELHNcyJy+UM+CDsgA6sqKqa486lF7YNwfzh0y65pfBcX/OiKK4XsG wVKOddB6zJobPDYWZJm5vY5jkvwNqOEGAmiTHBYAwWptb6Rv/XaqONutEWYVgHQhloSE Enr5tFouunz3LgztVVKl4TD2V2iLR4lKvfKwmd/7DgLr3MBqiMIWUZirAqgY3rTBADou tyDAtyHWs06n230sBc9QJ3f2uZhlMDhUiTKj3eoA921V2tphz2vPil5PYoKnqzopqkbN xajw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766941; x=1701371741; 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=JF5lkWbAc2C1VZm8P9TGmUDxxgv7XlATDWqvy4zet8o=; b=ftyvRYOdVaq6u4pHpimDYEWqUZwjAjbQPnNjpbF5ovT7hdm8AM3jVc/clRlpsHX3Ms RcoomoPVlMp7kQY33rz5ramdDtp/VF3fSG+3iusFJgGT6Lq3q00VB5oOSooTTYgdcLmP WgOwZcfYduGt0okmgBQk3H6XHLcaepy9ksb29pHc410IMH2jEYqWtMitMas38Fj7CKh9 UXJvaTOyBugyFuDvXti7j8rTfbKXXqDyxecOtxY+EWLH3+0eLg5FcGViOQXBmorbKZ1J Ry2DfHCnHu7I87eW7YQg8McOOoVt3+8u1SJF/E212drFqqzU1omN908eE4TPQImCWkQd zJeA== X-Gm-Message-State: AOJu0Ywqd0b/aQVspu+ZcLuoPleiMhqMzogayq4B+Cf90ck0P+yy9pJ2 UrcPT4uBlKugf+3PRTVXyc16JCENHYkLaqWsAKo= X-Google-Smtp-Source: AGHT+IGt5Gp93ztMxOj6W5t5ZLHIuaHvT4+3fCmozRu8+SA2mG6Xc0mUbRiQy62DZFMosqZqDqeDrg== X-Received: by 2002:a17:902:bb8f:b0:1cf:8c88:51cb with SMTP id m15-20020a170902bb8f00b001cf8c8851cbmr358719pls.62.1700766941614; Thu, 23 Nov 2023 11:15:41 -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 for-9.0 1/7] target/riscv: implement svade Date: Thu, 23 Nov 2023 16:15:26 -0300 Message-ID: <20231123191532.1101644-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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::62a; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700766986401100001 Content-Type: text/plain; charset="utf-8" 'svade' is a RVA22S64 profile requirement, a profile we're going to add shortly. It is a named feature (i.e. not a formal extension, not defined in riscv,isa DT at this moment) defined in [1] as: "Page-fault exceptions are raised when a page is accessed when A bit is clear, or written when D bit is clear.". As far as the spec goes, 'svade' is one of the two distinct modes of handling PTE_A and PTE_D. The other way, i.e. update PTE_A/PTE_D when they're cleared, is defined by the 'svadu' extension. Checking cpu_helper.c, get_physical_address(), we can verify that QEMU is compliant with that: we will update PTE_A/PTE_D if 'svadu' is enabled, or throw a page-fault exception if 'svadu' isn't enabled. So, as far as we're concerned, 'svade' translates to 'svadu must be disabled'. We'll implement it like 'zic64b': an internal flag that profiles can enable. The flag will not be exposed to users. [1] https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 1 + target/riscv/cpu_cfg.h | 1 + target/riscv/tcg/tcg-cpu.c | 9 +++++++++ 3 files changed, 11 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 3a230608cb..59b131c1fc 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1445,6 +1445,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_e= xts[] =3D { }; =20 const RISCVCPUMultiExtConfig riscv_cpu_named_features[] =3D { + MULTI_EXT_CFG_BOOL("svade", svade, true), MULTI_EXT_CFG_BOOL("zic64b", zic64b, true), =20 DEFINE_PROP_END_OF_LIST(), diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index 90f18eb601..46b06db68b 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -116,6 +116,7 @@ struct RISCVCPUConfig { bool ext_smepmp; bool rvv_ta_all_1s; bool rvv_ma_all_1s; + bool svade; bool zic64b; =20 uint32_t mvendorid; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 8fa8d61142..ddf37b25f3 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -188,6 +188,9 @@ static void riscv_cpu_enable_named_feat(RISCVCPU *cpu, = uint32_t feat_offset) cpu->cfg.cbop_blocksize =3D 64; cpu->cfg.cboz_blocksize =3D 64; break; + case CPU_CFG_OFFSET(svade): + cpu->cfg.ext_svadu =3D false; + break; default: g_assert_not_reached(); } @@ -383,8 +386,14 @@ static void riscv_cpu_validate_zic64b(RISCVCPU *cpu) cpu->cfg.cboz_blocksize =3D=3D 64; } =20 +static void riscv_cpu_validate_svade(RISCVCPU *cpu) +{ + cpu->cfg.svade =3D !cpu->cfg.ext_svadu; +} + static void riscv_cpu_validate_named_features(RISCVCPU *cpu) { + riscv_cpu_validate_svade(cpu); riscv_cpu_validate_zic64b(cpu); } =20 --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700767036; cv=none; d=zohomail.com; s=zohoarc; b=gRs3RB0oeCLpzsVjDgrMq0BfSgmNQKO9LcLZ9e5Q07cOxuRZDMt4nfZGhkoBtJV93hqLmUCxrzosdHc0+pI/SKoAfeRxSu7SUV+eeKkfAGdRtiuBfy1PY9RsAY0gGd7KackyaABF9C6LOKN2JZzvF7cxCdhNgJAOortsQ1MHSMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700767036; 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=ulovx9Gb5ru7ZFkz+gHPuuib2emkH4We+Ds4Yk+nbEs=; b=Wnr9BmweTItr3/OWNXdOwharflHtT7fJmUNBQF4UbDp5USeIBXTU7Dy/4XN8nzXkniEYAak7W90mX3++mPjMIjdXlmi4KQAwKaZdYUXf95HEZoQPreclcgRBVh/b9nI5s4Nq9/V4w1bV9r48KJSShYq4L4gYAOTPcxi2ule3waY= 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 1700767036413248.1919827373174; Thu, 23 Nov 2023 11:17:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FB2-0008Ss-EG; Thu, 23 Nov 2023 14:15:52 -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 1r6FAz-0008LY-0c for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:49 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6FAx-0003kG-11 for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:48 -0500 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1cc2575dfc7so9013785ad.1 for ; Thu, 23 Nov 2023 11:15:46 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766944; x=1701371744; 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=ulovx9Gb5ru7ZFkz+gHPuuib2emkH4We+Ds4Yk+nbEs=; b=NLceFD8ph1rBGcvOSFFgFYOk1cy+JQdqWEWp7PujR+muc6maxMlnQWF4Gqz0EEIIny B4lmcRG+X18FfrrnhYk5IEdOu1d6oJT/Y3G8r+JBPXZZFTLzDFDoUPagDlFpMbYRwb+y Ztou7qrlz+BxggDQgfqev+sYgPy3M9FyaNzrI9SBshHYen5pD+Q0Lzl3uXpQ99Hfp7Ky UIcz2p2F4+qmnjMHF9vkd9WOfEWWl5mMNaDBqLyENubz41J4XiJoDpPdUkc0w3RgmMa3 ZA4BtP0Xu1OFkGOX+jSwblZH3tLiJpyWgfDFfKlhiZ5fBCAUUAOm+WOkwJixV+RsMHVc JUEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766944; x=1701371744; 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=ulovx9Gb5ru7ZFkz+gHPuuib2emkH4We+Ds4Yk+nbEs=; b=DaT+ox99yp1nOXEuOwoDdtLmPA2OfYTggVrZr4glGJru29SXvNDIAeCqXL1CZB83Do 48Qa7volNJ6/3zsa+cn1gBG3l/7q10AFu0OhUU4xeUcD6hoOAwohMU7c1v+ENI04cFsL xPWJQkJT437hX+GJjayPnR9KUvQX3VJIcVPSdlJS2tNP9n80UV/j8wmTKDnmXV8ORfBh 3mUbzLqYBwgY1XFoX4Kr0qhkT+me83uW0b3Tfaqt324Y4LlwFBR6B+3FYnsHi9GSrOIR ZcwWkEPniRnSHJAjDDAupou89JGTozf/sKf3ZOg8r7E7nq5GDBVgK9qIpLJyXvKuWcVX r04Q== X-Gm-Message-State: AOJu0YxbzJNJHH3/i0nK1FeQqhHWQ6OlzeuovvYkNI43hessyZSogTH/ Ibu0J74xKfe/hcqQBwQ6hHck4glBIrCdyjiO0uA= X-Google-Smtp-Source: AGHT+IHD0oDq70RTenfG1UkGNIV1uTD4hNApISIuR+xRkY9vwUj0JTRjVoYel0L0jiZGetPBQwmtQA== X-Received: by 2002:a17:902:ea84:b0:1cf:65e1:b754 with SMTP id x4-20020a170902ea8400b001cf65e1b754mr423361plb.16.1700766944621; Thu, 23 Nov 2023 11:15:44 -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 for-9.0 2/7] target/riscv: add priv ver restriction to profiles Date: Thu, 23 Nov 2023 16:15:27 -0300 Message-ID: <20231123191532.1101644-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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::62e; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767038356100003 Content-Type: text/plain; charset="utf-8" Some profiles, like RVA22S64, has a priv_spec requirement. Make this requirement explicit for all profiles. We'll validate this requirement finalize() time and, in case the user chooses an incompatible priv_spec while activating a profile, a warning will be shown. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 2 ++ target/riscv/tcg/tcg-cpu.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 59b131c1fc..29a9f77702 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1537,6 +1537,7 @@ Property riscv_cpu_options[] =3D { static RISCVCPUProfile RVA22U64 =3D { .name =3D "rva22u64", .misa_ext =3D RVI | RVM | RVA | RVF | RVD | RVC | RVU, + .priv_spec =3D RISCV_PROFILE_ATTR_UNUSED, .ext_offsets =3D { CPU_CFG_OFFSET(ext_zicsr), CPU_CFG_OFFSET(ext_zihintpause), CPU_CFG_OFFSET(ext_zba), CPU_CFG_OFFSET(ext_zbb), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 5ff629650d..1f34eda1e4 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -81,10 +81,12 @@ typedef struct riscv_cpu_profile { uint32_t misa_ext; bool enabled; bool user_set; + int priv_spec; const int32_t ext_offsets[]; } RISCVCPUProfile; =20 #define RISCV_PROFILE_EXT_LIST_END -1 +#define RISCV_PROFILE_ATTR_UNUSED -1 =20 extern RISCVCPUProfile *riscv_profiles[]; =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index ddf37b25f3..a26cc6f093 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -74,6 +74,20 @@ static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint= 32_t bit, } } =20 +static const char *cpu_priv_ver_to_str(int priv_ver) +{ + switch (priv_ver) { + case PRIV_VERSION_1_10_0: + return "v1.10.0"; + case PRIV_VERSION_1_11_0: + return "v1.11.0"; + case PRIV_VERSION_1_12_0: + return "v1.12.0"; + } + + g_assert_not_reached(); +} + static void riscv_cpu_synchronize_from_tb(CPUState *cs, const TranslationBlock *tb) { @@ -764,11 +778,23 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,= Error **errp) static void riscv_cpu_validate_profile(RISCVCPU *cpu, RISCVCPUProfile *profile) { + CPURISCVState *env =3D &cpu->env; const char *warn_msg =3D "Profile %s mandates disabled extension %s"; bool send_warn =3D profile->user_set && profile->enabled; bool profile_impl =3D true; int i; =20 + if (profile->priv_spec !=3D env->priv_ver) { + profile_impl =3D false; + + if (send_warn) { + warn_report("Profile %s requires priv spec %s, " + "but priv ver %s was set", profile->name, + cpu_priv_ver_to_str(profile->priv_spec), + cpu_priv_ver_to_str(env->priv_ver)); + } + } + for (i =3D 0; misa_bits[i] !=3D 0; i++) { uint32_t bit =3D misa_bits[i]; =20 @@ -1057,6 +1083,10 @@ static void cpu_set_profile(Object *obj, Visitor *v,= const char *name, profile->user_set =3D true; profile->enabled =3D value; =20 + if (profile->enabled) { + cpu->env.priv_ver =3D profile->priv_spec; + } + for (i =3D 0; misa_bits[i] !=3D 0; i++) { uint32_t bit =3D misa_bits[i]; =20 --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700767038; cv=none; d=zohomail.com; s=zohoarc; b=kUg4WJPDgyHWCnK7tR61ONeFAFQs0Drg0kIXmki3PYki0Bwc5kML6n90BdiZzo5k3sTOdfoa90H+jJtq+h8UjF6w1Cs2uGVM/Vsc22jo/c0jDj4WixfJDT3kO0n7cWL3R/V5Hg10zU42l21YK8DUX1/7uiUbxHLzugTYMejKgJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700767038; 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=LzVLyJhe38kZFUDSFuU/9rcqCOh/CTumw3tEFLT/sDQ=; b=cXsyMgIVlbLlPhTg7AcNNa6Jjup0hjzruzQj+ajASlNvmvX1rtUHz7mxTENhVephqhY7whwC5ZIS0DkGbfQgk92rAAt7eQvuagvtxywgIh/333Oupt46ExW6t4g4hbpkIfzXU/rr10QAOBkny9HrUSEfu2aQ/rrRQE6NR6rd70Y= 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 1700767038398701.5738231441488; Thu, 23 Nov 2023 11:17:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FB3-0008Tr-EI; Thu, 23 Nov 2023 14:15:53 -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 1r6FB1-0008Qj-KJ for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:51 -0500 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 1r6FB0-0003m6-2M for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:51 -0500 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1cf98db3569so3851315ad.1 for ; Thu, 23 Nov 2023 11:15:49 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766948; x=1701371748; 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=LzVLyJhe38kZFUDSFuU/9rcqCOh/CTumw3tEFLT/sDQ=; b=onNyqg0Bxqn7U0lYW/c5TXeDW9gWGwRxIED+3wLOTonEahbimy5iwtvCobFG56peEm 6K0Ey4bAKZBlR0vE+gV4FbAnGAY2U5pFvi4FE4UdzYI9nfiXkveH/r/f8Ii2Qr9SKecW UelQIVbzx0PY29mst83wYtEpl9yifo8aVcw5Cm+iLy7BrUDoq3EBZxjLbFQpZHxXhDlL 9VLtjlVDPS6kyQOK3kV/R23NzatYM5wqfFzGiG0ChgHKVgOvqPucMljLzJf215KaT6Go FuQFkSVLJORe197neNGhMU4pGQHOM69VBeVRU8Xqjkv8QrjZsGXw8hgIfg0GowExzXgR GO8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766948; x=1701371748; 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=LzVLyJhe38kZFUDSFuU/9rcqCOh/CTumw3tEFLT/sDQ=; b=JeVZ5Ucinb7keH6St5e3lqmASrW3DF5oZbKOxGOePzwj5C2ceus8/wbZhLziWq35W5 IiCax3HLRi5ADWnuEGoSf2211iSf16/+IcmDFJdBwt1Z9FdCXKcF/I0JDDRNX29Ymx4I eotYoIKWfNmmhy6RR7obXVkP1Y+fKUHzV5V7Xwbtlb/lKqBcy6TltrwM1roSJglHvs+t bvAdMRa92ZcmgwU2k8FwQb2F788tkJAE9Rg8RwstNtJBIjpCEJP/oTLxR0Kg86IUXwo+ 92fVHayJncEZ3UShg9cR0eWtgUfun1dm0/G3Wr8j7/p1kuSFh/A/rt9jY6BqIeAJOS0E kG9A== X-Gm-Message-State: AOJu0Yy5LaIxEtwU657pa+EHfFiN2uL9JoKIKa1P8H+jKRckSZ2NLgbc 9cQRX9DgTrxg0/2afkf4w5ldinCpn1XwMHCvI6g= X-Google-Smtp-Source: AGHT+IE+yame+jBp2sa+nHl3H/sz6JSu3lqKs3lArrXzETxJ5BbxIHz55Ct6TZxeWNEbOA0y1a23MA== X-Received: by 2002:a17:903:22d2:b0:1cf:6bc2:223f with SMTP id y18-20020a17090322d200b001cf6bc2223fmr388837plg.51.1700766947694; Thu, 23 Nov 2023 11:15:47 -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 for-9.0 3/7] target/riscv/cpu.c: finalize satp_mode earlier Date: Thu, 23 Nov 2023 16:15:28 -0300 Message-ID: <20231123191532.1101644-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767040353100007 Content-Type: text/plain; charset="utf-8" Profiles will need to validate satp_mode during their own finalize methods. This will occur inside riscv_tcg_cpu_finalize_features() for TCG. Given that satp_mode does not have any pre-req from the accelerator finalize() method, it's safe to finalize it ealier. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 29a9f77702..a395c77bda 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1056,6 +1056,14 @@ void riscv_cpu_finalize_features(RISCVCPU *cpu, Erro= r **errp) { Error *local_err =3D NULL; =20 +#ifndef CONFIG_USER_ONLY + riscv_cpu_satp_mode_finalize(cpu, &local_err); + if (local_err !=3D NULL) { + error_propagate(errp, local_err); + return; + } +#endif + /* * KVM accel does not have a specialized finalize() * callback because its extensions are validated @@ -1068,14 +1076,6 @@ void riscv_cpu_finalize_features(RISCVCPU *cpu, Erro= r **errp) return; } } - -#ifndef CONFIG_USER_ONLY - riscv_cpu_satp_mode_finalize(cpu, &local_err); - if (local_err !=3D NULL) { - error_propagate(errp, local_err); - return; - } -#endif } =20 static void riscv_cpu_realize(DeviceState *dev, Error **errp) --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700767019; cv=none; d=zohomail.com; s=zohoarc; b=AofktPs5IPXjojyQKy3/sQEDMQi7BWfe/C2Qsy6yBN7r/Nlzu25lKV6FnWKQl5TZulDn8LPi7RSoy5ymI1S235NMKIRCyCdmuagwMFKbkiisshlWMJMYtx2/U8j/MeVfsr8qJx3oeFyh636QSbxpsSIrOpPyjzV3VTDTsmguylY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700767019; 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=oWy/56QLcu94omNIXXSZg231kAR+qHSOzpLGfnBUle8=; b=Qqpx80J+RQ+rhr6mFb3B2NlRNkYyP7zOyn15W1RLX4F9oonE6rChssr1He4K1Tm4M2f61h+VQjt+35DP1uxGzMIMrJ5M0X3yryhzoh0vjDaJlDLIvqeIMBB8lT+CCoCfdIUTJMwZJAeQ8tdYrthjCF4y+DYmOVAv5c+UkXx38Ok= 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 1700767019162360.42073076473605; Thu, 23 Nov 2023 11:16:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FB6-0008VI-S3; Thu, 23 Nov 2023 14:15:56 -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 1r6FB4-0008Ua-Va for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:55 -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 1r6FB2-0003nX-UW for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:54 -0500 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1cf7a8ab047so9003325ad.1 for ; Thu, 23 Nov 2023 11:15:52 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766951; x=1701371751; 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=oWy/56QLcu94omNIXXSZg231kAR+qHSOzpLGfnBUle8=; b=MoC+sTFf67khY9ChSnhL3JIVSdnpZSZcnxPTP2FzfZsc7vLZSNLcyClO5bdCOlbCs4 tds3bl+wDs4AsIfwZ+fMcxvE2om3d0RNM6RGGlJVOkBD0iW7+CjZST38oYpSZiWzmy9I vobFV/ceKY3Pu4rWhXp4g2ozhjUU4EMrmO8oQ3ntS0kRlk7cFlG5TAdFyRmhAKQzQ/jf vnsn+mEcAKdDmeq7/3hICrPA6wruuBYfNhkcCYNlaFRImhoWiA3c3LOYkWFKgw76hcgo GzoJbhgp3Z63gA+6IOtpNcf1Xpcdcqk6t8tH52Dcwp62ixMVVjJHeFjzXl815HGPcrNb FDNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766951; x=1701371751; 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=oWy/56QLcu94omNIXXSZg231kAR+qHSOzpLGfnBUle8=; b=n2KQh60ZRk3c8C+VTbLJSBXaTUdFjm3pwwrAG8/AY4CFR2TJH77atDieaB3/WDJMxx wRBjHlSbNDywmKVBmiRkrKBYKjVxGyqi+4w5lSFBsEeJsuAAU23VnBN5tbko3XPc4YYI nsRqW7xWdvpbRxiCKTN1u/n8Ss2dpOaYQiy6yQ2KLU0auDdjDhkppRHdBeQ/A9ge+KOZ 8FDNTVug5/IftbsEp/6RYwj/ZxNkjLA+jxzWMlK8tv5iNOW9nfhPZo5saPBIFm1vnrER BkRZ5kUhoVwDSK0Dq/nJNmgW2Tq96gIZIiZjjufD4ZfhaRF2Y9lgJNiYtg1SfqzxjQnT 7JHQ== X-Gm-Message-State: AOJu0YxlsnFr9bC1nlN0fMqXHpGItF6WLYhF+7jTiELD2Md1YfRKIH9J w1i9NRF+iNO2AuEhTQECvZutz+/qWSiY/b2WSFQ= X-Google-Smtp-Source: AGHT+IEiLCBVq8YGPC3ZqKTSPYvNhFobngrWIPSgAaMMtc5cr/tKwmCTdmDcENSquS+AHZRBcrUC7w== X-Received: by 2002:a17:902:e88a:b0:1ce:654a:81ef with SMTP id w10-20020a170902e88a00b001ce654a81efmr448397plg.18.1700766951000; Thu, 23 Nov 2023 11:15:51 -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 for-9.0 4/7] target/riscv/cpu: add riscv_cpu_is_32bit() Date: Thu, 23 Nov 2023 16:15:29 -0300 Message-ID: <20231123191532.1101644-5-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767020268100003 Content-Type: text/plain; charset="utf-8" Next patch will need to retrieve if a given RISCVCPU is 32 or 64 bit. The existing helper riscv_is_32bit() (hw/riscv/boot.c) will always check the first CPU of a given hart array, not any given CPU. Create a helper to retrieve the info for any given CPU, not the first CPU of the hart array. The helper is using the same 32 bit check that riscv_cpu_satp_mode_finalize() was doing. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 7 ++++++- target/riscv/cpu.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a395c77bda..2b79fe861b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -53,6 +53,11 @@ const uint32_t misa_bits[] =3D {RVI, RVE, RVM, RVA, RVF,= RVD, RVV, #define BYTE(x) (x) #endif =20 +bool riscv_cpu_is_32bit(RISCVCPU *cpu) +{ + return riscv_cpu_mxl(&cpu->env) =3D=3D MXL_RV32; +} + #define ISA_EXT_DATA_ENTRY(_name, _min_ver, _prop) \ {#_name, _min_ver, CPU_CFG_OFFSET(_prop)} =20 @@ -980,7 +985,7 @@ static void riscv_cpu_disas_set_info(CPUState *s, disas= semble_info *info) #ifndef CONFIG_USER_ONLY static void riscv_cpu_satp_mode_finalize(RISCVCPU *cpu, Error **errp) { - bool rv32 =3D riscv_cpu_mxl(&cpu->env) =3D=3D MXL_RV32; + bool rv32 =3D riscv_cpu_is_32bit(cpu); uint8_t satp_mode_map_max, satp_mode_supported_max; =20 /* The CPU wants the OS to decide which satp mode to use */ diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 1f34eda1e4..485d2da3c2 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -695,6 +695,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, vaddr *pc, uint64_t *cs_base, uint32_t *pflags); =20 void riscv_cpu_update_mask(CPURISCVState *env); +bool riscv_cpu_is_32bit(RISCVCPU *cpu); =20 RISCVException riscv_csrrw(CPURISCVState *env, int csrno, target_ulong *ret_value, --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700766998; cv=none; d=zohomail.com; s=zohoarc; b=LPImUG9TK6p0e76ReegRiB5Aj9sGx+ar2kJfA4QwdJbTcpHzm+bEK4yhIEsJE4JIxlgz7gmM14QpSpd/PDj4SfyW07zakF58BsVYU8nfrmMk9jCsV1oSREepyLjS1Gh4prWXTcjE0dD4j0gAJ/VogRkTXPuDLz4lkc8ClrNNMSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700766998; 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=F3cAPK7POkxyDf86f2CZfhfjK5yQaCv5kDXzXsqfuNk=; b=b1Blm1GXA5mD3msJD5AUvQosBqO8EvDgtXmQzfS+5LA4SUEwXShoQEvi/V2DeKUqkzsaP3Vz2gJkQBYgUG/VtvKcdAF2C2EtdJolepaIlINVbjdHMrORmR40F5a9BfMYjyW4LdPUT3CTvK/vGbO+X0JlQ7B6oPQVdAYrR6sgYQI= 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 170076699891926.720172091440645; Thu, 23 Nov 2023 11:16:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FB8-000085-Gh; Thu, 23 Nov 2023 14:15:58 -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 1r6FB7-0008Vo-Ho for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:57 -0500 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 1r6FB5-0003o0-W7 for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:15:57 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ce627400f6so8964655ad.2 for ; Thu, 23 Nov 2023 11:15:55 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766954; x=1701371754; 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=F3cAPK7POkxyDf86f2CZfhfjK5yQaCv5kDXzXsqfuNk=; b=lggOLv4q8nS0YJofNpPH8OaEEHr3YkP08YWE+TjoLxVfjx0ZotIozHONc2Dsn3wANd XPV3zDGoMpW47bjW9TKG1Io+L2sXvl77AC43UqbAlfmFeJZDFus6Sg2og6AcF5KEBIsM zpj3e24OzXykWvUVpTHzhFEimi/PtOPX0TeTCk3tsikYEluESIutw+vDB1Y1eolBuGYB dBo/gsCTcvu723TA4470y9g1r4grDi2FrDop1GoFiQgG3ORS8j96DWybbwBtxtmRRgiM pqQ3lPV5tae7JmrX4d5RHx/rxkQEg6BBjUnqQTM6XVZaIE2KhpGFzplHMbHCmTL0x2ot EzDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766954; x=1701371754; 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=F3cAPK7POkxyDf86f2CZfhfjK5yQaCv5kDXzXsqfuNk=; b=UhZSeCYVI8YI8wnhfA0rKrJozkPYjC75n+m+8cON2PKa3LeMtQaHNMPS3Evr6vnpvV XN4sV4qeHWQ1Hmpj9yiA9/1JGjtnaKtXYf5uV5RLI0Re9KaBW/XhZHCs36D85/YVdFCb 9orivBTbDmK6h9vszZ/cR36dm1MtlU25I2yQ1sgZwHolMVDkRyMadmL6D3gq8a1ZbchZ Ssufz1VbcSy0vilLsPA0GQyMqyRHZMysSgERh9dUEQw5Ou7Zd+vml+3OTWCABH/17kb/ z0dO0rhO+viK6Om1l5pkVTEHvfoaHI66N2g+eoelZDHRzlrwm+cCKEJ4GcJyXhLHN7xC SaiA== X-Gm-Message-State: AOJu0YwsXw2vSWmY9qbMZ4E3ZrXCIlPs5Q5vIZnO2E5ZEvL+KHnFzrwb C3TiMWP0bSQzvF+eL5aEvh8hvsQnqhndQSZyjWM= X-Google-Smtp-Source: AGHT+IF2zaRM69vieJYmziac3Wmy9Y01txIclsVs38rEJB4TKnnzzgD/hkGvIefladLrvjK5M9zXLA== X-Received: by 2002:a17:903:4282:b0:1c9:faef:5765 with SMTP id ju2-20020a170903428200b001c9faef5765mr416652plb.5.1700766954048; Thu, 23 Nov 2023 11:15:54 -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 for-9.0 5/7] target/riscv: add satp_mode profile support Date: Thu, 23 Nov 2023 16:15:30 -0300 Message-ID: <20231123191532.1101644-6-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767000158100001 Content-Type: text/plain; charset="utf-8" 'satp_mode' is a requirement for supervisor profiles like RVA22S64. User-mode/application profiles like RVA22U64 doesn't care. Add 'satp_mode' to the profile description. If a profile requires it, set it during cpu_set_profile(). We'll also check it during finalize() to validate if the running config implements the profile. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 1 + target/riscv/cpu.h | 1 + target/riscv/tcg/tcg-cpu.c | 41 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 2b79fe861b..a77118549b 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1543,6 +1543,7 @@ static RISCVCPUProfile RVA22U64 =3D { .name =3D "rva22u64", .misa_ext =3D RVI | RVM | RVA | RVF | RVD | RVC | RVU, .priv_spec =3D RISCV_PROFILE_ATTR_UNUSED, + .satp_mode =3D RISCV_PROFILE_ATTR_UNUSED, .ext_offsets =3D { CPU_CFG_OFFSET(ext_zicsr), CPU_CFG_OFFSET(ext_zihintpause), CPU_CFG_OFFSET(ext_zba), CPU_CFG_OFFSET(ext_zbb), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 485d2da3c2..6c5fceb5f5 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -82,6 +82,7 @@ typedef struct riscv_cpu_profile { bool enabled; bool user_set; int priv_spec; + int satp_mode; const int32_t ext_offsets[]; } RISCVCPUProfile; =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index a26cc6f093..8cfab26915 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -775,6 +775,31 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, = Error **errp) riscv_cpu_disable_priv_spec_isa_exts(cpu); } =20 +#ifndef CONFIG_USER_ONLY +static bool riscv_cpu_validate_profile_satp(RISCVCPU *cpu, + RISCVCPUProfile *profile, + bool send_warn) +{ + int satp_max =3D satp_mode_max_from_map(cpu->cfg.satp_mode.supported); + + if (profile->satp_mode > satp_max) { + if (send_warn) { + bool is_32bit =3D riscv_cpu_is_32bit(cpu); + const char *req_satp =3D satp_mode_str(profile->satp_mode, is_= 32bit); + const char *cur_satp =3D satp_mode_str(satp_max, is_32bit); + + warn_report("Profile %s requires satp mode %s, " + "but satp mode %s was set", profile->name, + req_satp, cur_satp); + } + + return false; + } + + return true; +} +#endif + static void riscv_cpu_validate_profile(RISCVCPU *cpu, RISCVCPUProfile *profile) { @@ -784,6 +809,13 @@ static void riscv_cpu_validate_profile(RISCVCPU *cpu, bool profile_impl =3D true; int i; =20 +#ifndef CONFIG_USER_ONLY + if (profile->satp_mode !=3D RISCV_PROFILE_ATTR_UNUSED) { + profile_impl =3D riscv_cpu_validate_profile_satp(cpu, profile, + send_warn); + } +#endif + if (profile->priv_spec !=3D env->priv_ver) { profile_impl =3D false; =20 @@ -1083,10 +1115,19 @@ static void cpu_set_profile(Object *obj, Visitor *v= , const char *name, profile->user_set =3D true; profile->enabled =3D value; =20 + if (profile->enabled) { cpu->env.priv_ver =3D profile->priv_spec; } =20 +#ifndef CONFIG_USER_ONLY + if (profile->satp_mode !=3D RISCV_PROFILE_ATTR_UNUSED) { + const char *satp_prop =3D satp_mode_str(profile->satp_mode, + riscv_cpu_is_32bit(cpu)); + object_property_set_bool(obj, satp_prop, profile->enabled, NULL); + } +#endif + for (i =3D 0; misa_bits[i] !=3D 0; i++) { uint32_t bit =3D misa_bits[i]; =20 --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700767011; cv=none; d=zohomail.com; s=zohoarc; b=K64cynp86mKNsYdtBidYCptUvvhGs10b1W6BnBzYuIr5nBp5Wd0LCEowQQFN+hRWT9y1siKVsJ9NCuIm2P7dUmDbQJcLZtr6zwCFv2J0uf9t87UAyck0YeuliRvYjpE29Pp2MYB3KEArle9SgvPjl0Z91hwYTDPa3T34E59sKpQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700767011; 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=2xYT9VwJycNlV2FpNWHCSbU8jav1y7pot436k+JUSRk=; b=Fd1vGrjX0TV6yqi0GnLthANJoy6pTPaGrR+MOBRuntrhnx1t/vzbB35639+QKG+aNHeViICnORONoxaGdEk/rh9LBFZdxwvQTZyBmfthdpO/uEfTw3mXGgQaPskliSebKxeRZ+2rLVJxzBc0ieke8CGIhYceVX+nG2pDhdlSCgs= 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 1700767011403591.1912355354505; Thu, 23 Nov 2023 11:16:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FBC-0000FA-Gz; Thu, 23 Nov 2023 14:16:02 -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 1r6FBA-0000Dn-HW for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:16:00 -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 1r6FB8-0003ok-Rt for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:16:00 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1cf59c07faeso8925065ad.2 for ; Thu, 23 Nov 2023 11:15:58 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766957; x=1701371757; 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=2xYT9VwJycNlV2FpNWHCSbU8jav1y7pot436k+JUSRk=; b=np+6LZ8SSPY+2vspv6DHTV08mebhO5lGyIahCsFqWmnJd+Vl0CxYVe3yjxZFSo2T1Q IBDr1A36Q+C3bBpinJgGOMr2EXGjY7kbhF6pfYNBfdLBpWjq3aIMPX8Ctv49/8SXqEoM gwUi6kRcdm4WSPQrRB60FnbyHhhm40w2fQTZBDhmiDjuAH6cF6nb9vrK7RMt4TaKL4jJ +cbfN8OoVoWs3PRzTsIfKqTaCgmLBIpR3DXD1qoaIuvI9Y8JUOK6QsOZttUtYJgl792/ WaCJXR13DECd1fMyFk3fYQyXANjCsb/aFIZq9mlnLmZcE8VlWy5/UPZdCoxJqmpqF7Ik Rzaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766957; x=1701371757; 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=2xYT9VwJycNlV2FpNWHCSbU8jav1y7pot436k+JUSRk=; b=HOhrOQYdI4KVmdNs6pcE79gt6WDvqG4oLSb9h0rvkO/yY+QdOiu7mgrgw7/wQ6dwFY G04OUu0aKpss5UwDpCnf8s4TqE9hCeHFlPI19JwXQ0TXm3yPuNTBEZY+dT+7FvQ9QKqc ZhxinPP7uIl0S7/rF66ml1RH1smTgOZIKRDpPIonqZOoWc8c/xbhfUSqG9K/hIGlN+cD oYRv6mR+W0ZkDknKaouetGitvlOiwW+ObhXB2g8YhkVewIxlr2VHEq4mkWl2wKXkotpU Ya/ZRMYoEpdfl4C1zm8IGPre9ldTuvhMNa6IaVRdauy5FZKAyPAKNoH+Vi5ozBf7NS1G ZX1Q== X-Gm-Message-State: AOJu0YwXozGu1xpBpo1Q0vwkHowAWoX6Kc0iN3m56HpmnL4AtxZsER8K 0zcIpwpfeo/MQiJeznmcUzY/jF+memBiz/IVdp0= X-Google-Smtp-Source: AGHT+IE3FOQblzcwAojZ+32l3sLjWATWAuf1oqViTOUCPAAHEuvT22HPJNA0ZvGrd8fIq4+AnEV6+g== X-Received: by 2002:a17:902:b487:b0:1cf:8ebd:4eaa with SMTP id y7-20020a170902b48700b001cf8ebd4eaamr338689plr.68.1700766957183; Thu, 23 Nov 2023 11:15:57 -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 for-9.0 6/7] target/riscv: add RVA22S64 profile Date: Thu, 23 Nov 2023 16:15:31 -0300 Message-ID: <20231123191532.1101644-7-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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::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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767012578100001 Content-Type: text/plain; charset="utf-8" The RVA22S64 profile consists of the following: - all mandatory extensions of RVA22U64; - priv spec v1.12.0; - satp mode sv39; - Ssccptr, a cache related named feature that we're assuming always enable since we don't implement a cache; - Other named features already implemented: Sstvecd, Sstvala, Sscounterenw; - the new Svade named feature that was recently added. Most of the work is already done, so this patch is enough to implement the profile. After this patch, the 'rva22s64' user flag alone can be used with the rva64i CPU to boot Linux: -cpu rv64i,rva22s64=3Dtrue This is the /proc/cpuinfo with this profile enabled: # cat /proc/cpuinfo processor : 0 hart : 0 isa : rv64imafdc_zicbom_zicbop_zicboz_zicntr_zicsr_zifencei_zihintpause_zi= hpm_zfhmin_zca_zcd_zba_zbb_zbs_zkt_svinval_svpbmt mmu : sv39 Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a77118549b..d00548d164 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1559,8 +1559,48 @@ static RISCVCPUProfile RVA22U64 =3D { } }; =20 +/* + * As with RVA22U64, RVA22S64 also defines 'named features'. + * + * Cache related features that we consider enabled since we don't + * implement cache: Ssccptr + * + * 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 =3D { + .name =3D "rva22s64", + .misa_ext =3D RVI | RVM | RVA | RVF | RVD | RVC | RVU | RVS, + .priv_spec =3D PRIV_VERSION_1_12_0, + .satp_mode =3D VM_1_10_SV39, + .ext_offsets =3D { + /* rva22u64 exts and features */ + CPU_CFG_OFFSET(ext_zicsr), 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_zicntr), + CPU_CFG_OFFSET(ext_zihpm), CPU_CFG_OFFSET(ext_zicbom), + CPU_CFG_OFFSET(ext_zicbop), CPU_CFG_OFFSET(ext_zicboz), + CPU_CFG_OFFSET(zic64b), + + /* rva22s64 exts */ + CPU_CFG_OFFSET(ext_zifencei), CPU_CFG_OFFSET(ext_svpbmt), + CPU_CFG_OFFSET(ext_svinval), + + /* rva22s64 named features */ + CPU_CFG_OFFSET(svade), + + RISCV_PROFILE_EXT_LIST_END + } +}; + RISCVCPUProfile *riscv_profiles[] =3D { &RVA22U64, + &RVA22S64, NULL, }; =20 --=20 2.41.0 From nobody Wed Nov 27 04:52:23 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=1700767012; cv=none; d=zohomail.com; s=zohoarc; b=XSt2NIEo+9MSboZMRV4Oe1yZg2BQyF299vSsBUyMEj5GQaU3D+lAxpzyR/5LEl5H1ToeeYTZH7j0uMi2LS39I0suXg1zNLDzWypYlnlhJpEp+5VvyHtKzgnClp3elkmREEL69d1cbl4yM7x1TcXRmdmO4Q6bl5xzW4lc3Q5mF1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1700767012; 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=yNmsJugvxGfWuNRNrzSMaJR8adV3KPuLw+7r7LQkB+M=; b=AHbuU9iyQTye8drLYYg+3507OE7rl+gAlGK+pVTKdkMSdpW3snrxnXeZbCaCr45jfVI5GgqMDOWfC6C3qJopoJa7GzUilhZ1peXHycfaXuWZRl62oNlBeu6vuZvfmFGrz12Mbjz+cVYQZcWd1PK3AzeZCO0tEAq1nd02deIDkmY= 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 1700767012703637.3630577483748; Thu, 23 Nov 2023 11:16:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6FBS-0000dk-Rk; Thu, 23 Nov 2023 14:16:18 -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 1r6FBR-0000WR-7z for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:16:17 -0500 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r6FBB-0003pV-S2 for qemu-devel@nongnu.org; Thu, 23 Nov 2023 14:16:16 -0500 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cc5fa0e4d5so9412625ad.0 for ; Thu, 23 Nov 2023 11:16:01 -0800 (PST) Received: from grind.. ([2804:7f0:bdcd:fb00:6501:2693:db52:c621]) by smtp.gmail.com with ESMTPSA id h21-20020a170902eed500b001bc21222e34sm1680760plb.285.2023.11.23.11.15.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 11:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1700766960; x=1701371760; 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=yNmsJugvxGfWuNRNrzSMaJR8adV3KPuLw+7r7LQkB+M=; b=mTcIkqufVidRCXhyg6Y0/Od6IeuEFfiU/9Oc8QYbgC3eQxClhBdiwuF0E2aLp30dzD A9nJDzmsehsucvR9TWLBFLyJSrh5XNtiJ9s3iI/YgcqPvfkKJ57gbO849Y2zvxfK4SQD xHJ7NLX6CgD835uNcwh82lQXXxXEw1tJNYcOgoGPaeX0qSwgdG0jFSTpFN4vUfZbBYRE NSVTekfQ49XYsScX0Zn0279Kj85pvBcQHqmldYcC2F8zy5QDNC+fwjp/jX2lLWWMnLKx M3c+mQBUz534sVD4rJA17EyA0xFJfj1hHrNwZ5E9Ly1AMnkDhbNpW0MUL3WVKT8K9Zcb Z3/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700766960; x=1701371760; 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=yNmsJugvxGfWuNRNrzSMaJR8adV3KPuLw+7r7LQkB+M=; b=BSH2SRK8D40yH7Gh/HzfDP7KhXzQz93EMHG5QAZh24mj98+76EgdrQHrAtPkKKEyPi cpVF+VuRPr7yaOpJ/6wjQPkcTKVqQzFS4VD4RcSSefyc9cDE2dSx/zAh2X4ESJtGyh3z poXQBvXSMsJl8qxuyPARV/bAC7dp8DohaCE+rVzea15tNugOQzMLDqupcumyWtyqMS56 bJzvTJSS1bVOP4bUrroej/4bAOX5kpl/0WS1xm7l4gjgbW1M+dGfruhURPLvbIZTyjhz 3R+4vz+jgM0lQ/hzF0n0g24Ysd/8DsfrpDitQ+pZGjkkvTgYfE2gng1dnuDYxNJwNNOO 6OZQ== X-Gm-Message-State: AOJu0YzeGhPQ+lHeHSWtmilt6dvWI3SztJBfunzHOFSojVpDiTwml6W1 QKk+QuPGKm3fD+0+MGCOttwv1yrgotU0f/8PwPo= X-Google-Smtp-Source: AGHT+IEM2ijHFSXrjft3fS5gZvpQwCiPw/C8ptm2Us9Rf9quIYAn5rxk6xYjSk7E972uLepGn98jOA== X-Received: by 2002:a17:902:a411:b0:1cf:669b:613c with SMTP id p17-20020a170902a41100b001cf669b613cmr406101plq.55.1700766960301; Thu, 23 Nov 2023 11:16:00 -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 for-9.0 7/7] target/riscv: add rva22s64 cpu Date: Thu, 23 Nov 2023 16:15:32 -0300 Message-ID: <20231123191532.1101644-8-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231123191532.1101644-1-dbarboza@ventanamicro.com> References: <20231123191532.1101644-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::629; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x629.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1700767014261100007 Content-Type: text/plain; charset="utf-8" Add a new profile CPU 'rva22s64' to work as an alias of -cpu rv64i,rva22s64 Like the existing rva22u64 CPU already does with the RVA22U64 profile. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/cpu-qom.h | 1 + target/riscv/cpu.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h index 12fe78fc52..9219c2fcc3 100644 --- a/target/riscv/cpu-qom.h +++ b/target/riscv/cpu-qom.h @@ -36,6 +36,7 @@ #define TYPE_RISCV_CPU_BASE128 RISCV_CPU_TYPE_NAME("x-rv128") #define TYPE_RISCV_CPU_RV64I RISCV_CPU_TYPE_NAME("rv64i") #define TYPE_RISCV_CPU_RVA22U64 RISCV_CPU_TYPE_NAME("rva22u64") +#define TYPE_RISCV_CPU_RVA22S64 RISCV_CPU_TYPE_NAME("rva22s64") #define TYPE_RISCV_CPU_IBEX RISCV_CPU_TYPE_NAME("lowrisc-ibex") #define TYPE_RISCV_CPU_SHAKTI_C RISCV_CPU_TYPE_NAME("shakti-c") #define TYPE_RISCV_CPU_SIFIVE_E31 RISCV_CPU_TYPE_NAME("sifive-e31") diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index d00548d164..f6d1d4c7a6 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1631,6 +1631,13 @@ static void rva22u64_profile_cpu_init(Object *obj) =20 RVA22U64.enabled =3D true; } + +static void rva22s64_profile_cpu_init(Object *obj) +{ + rv64i_bare_cpu_init(obj); + + RVA22S64.enabled =3D true; +} #endif =20 static const gchar *riscv_gdb_arch_name(CPUState *cs) @@ -1975,6 +1982,7 @@ static const TypeInfo riscv_cpu_type_infos[] =3D { DEFINE_DYNAMIC_CPU(TYPE_RISCV_CPU_BASE128, rv128_base_cpu_init), DEFINE_BARE_CPU(TYPE_RISCV_CPU_RV64I, rv64i_bare_cpu_init), DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22U64, rva22u64_profile_cpu_init), + DEFINE_PROFILE_CPU(TYPE_RISCV_CPU_RVA22S64, rva22s64_profile_cpu_init), #endif }; =20 --=20 2.41.0