From nobody Sat Jul 12 10:18:47 2025 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1679170011; cv=none; d=zohomail.com; s=zohoarc; b=eowYsiGsCY0zLeTGXSU9D9REGbnD4mSsEi52b/658yCC5Ln6u4suNd4xFaxN0gSFtGqBhPnAJnScskc4gzQh0yL5JPKIsx11b52gtL3Lc393OOkEterRb/Gdn9TiFhiXYQFnZu4Zp4MTyaYhthGm0spfsr8oAVoJxXVzgPhz1lI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679170011; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gUrnUOKftNGP2FPSgVGe+TWqw1fM66zN2Xsxfp1nXPw=; b=KE/4/dXlvJaf5R5QLqHCpOwRmrsNF3S70QnTpjv4PP0FWCmFl4dLlqCgY6Q8bV0H7RrM7xfWEX7t11yLJpOv4jyWn+25cQE1rPVjkRBPvlFu/dGTxTOzSYF5KHK+EaKBt0xDuHqBXK6iuXCNCbS6IOdR7/uX23HiIArr3f4BEA4= 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+importer2=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 167917001189211.387196361661267; Sat, 18 Mar 2023 13:06:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pdcoE-0005WJ-GX; Sat, 18 Mar 2023 16:05:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pdco4-0005Mw-L7 for qemu-devel@nongnu.org; Sat, 18 Mar 2023 16:05:37 -0400 Received: from mail-oo1-xc30.google.com ([2607:f8b0:4864:20::c30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pdco2-0007Ar-FU for qemu-devel@nongnu.org; Sat, 18 Mar 2023 16:05:36 -0400 Received: by mail-oo1-xc30.google.com with SMTP id o26-20020a4ad49a000000b0053964a84b0fso687988oos.7 for ; Sat, 18 Mar 2023 13:05:34 -0700 (PDT) Received: from grind.dc1.ventanamicro.com ([177.95.89.231]) by smtp.gmail.com with ESMTPSA id f69-20020a4a5848000000b004a3d98b2ccdsm2122219oob.42.2023.03.18.13.05.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Mar 2023 13:05:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1679169933; 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=gUrnUOKftNGP2FPSgVGe+TWqw1fM66zN2Xsxfp1nXPw=; b=heibx168Er1sG2NUbiSDctbboJE/mqRffmb62ngiT8U6gUrVGJFEY8BXR+jDlkmmfK Dc7R1rTRpSKjVh7WEa0aitO0PdtwzmDD5N89ZtWHAr6/fcP15UlZehPJSEWDqqSfaIdK aeCXW1IxtGMBDv3R0gF441t0VmHrhVODi7Jc2LFKdqG4jeNhvtDiqLK7szPb71aAmS9B bXdMafDBsIsKX1tbved9KcZRn7Ko4MdCd0HndNxYzpwPCKRDurDFnRJ5Ywb/v3pBC3VM /eVx2KA78yspnv0NoPuhv7dw4vBI1nQGcHiQ778NLUaDZ7qJREa/RdKW5ckeLdLTyrjA 6lxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679169933; 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=gUrnUOKftNGP2FPSgVGe+TWqw1fM66zN2Xsxfp1nXPw=; b=WDFJ2pW9bUJB5/vwHXzBD9ZJq0Fmpays2P0T5Odye7BjZo2Gz8kDCwM8pD7bI+GQOa rz3DDR+lBSM6GXS623LQ9cqg91c+14bkOZKCUcziAn9DrayVbjFRKiiPG3Ggpl+cPbrO LxHJuTAmK3IGsFJkuMCkrTu1iMW3QqZ5FUf1aBEorDppH7Ev/wPriGHChJwlUZyVFIlU Ixr0muWcUw/ImBVsH/aUyF5AsYms632F8fmW8Dlx027sF1tT3Sfko/mQXswXTVvUgoZl KUGykrBfQf7o21+RLeZBlN3O4i+dwbvbmAcpS3yXRR+HQDpWAJ2eH1PYufFd0I0fWRD2 Nj6g== X-Gm-Message-State: AO0yUKVr3Usy3WSa1AyC91NMCXEAHa/uaebRaynVyRUsunAi3a2OTLY2 hNeKD75cSZeHey5dQ2k1S8mo5VPLx0zArwJ/bhk= X-Google-Smtp-Source: AK7set/NPEzzz7ZFgc9YqJ8BKDThOzNXtCYhO7/oiLO3z0SmSGtIxQXAGU8TwL+sLynvJ+X31Q8iLA== X-Received: by 2002:a4a:330d:0:b0:538:cf7f:d5cb with SMTP id q13-20020a4a330d000000b00538cf7fd5cbmr1506535ooq.1.1679169933445; Sat, 18 Mar 2023 13:05:33 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, Daniel Henrique Barboza Subject: [PATCH for-8.1 v3 18/26] target/riscv: error out on priv failure for RVH Date: Sat, 18 Mar 2023 17:04:28 -0300 Message-Id: <20230318200436.299464-19-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230318200436.299464-1-dbarboza@ventanamicro.com> References: <20230318200436.299464-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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c30; envelope-from=dbarboza@ventanamicro.com; helo=mail-oo1-xc30.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1679170012922100005 Content-Type: text/plain; charset="utf-8" riscv_cpu_disable_priv_spec_isa_exts(), at the end of riscv_cpu_validate_set_extensions(), will disable cpu->cfg.ext_h and cpu->cfg.ext_v if priv_ver check fails. This check can be done in riscv_cpu_validate_misa_ext(). The difference here is that we're not silently disable it: we'll error out. Silently disabling a MISA extension after all the validation is completed can can cause inconsistencies that we don't have to deal with. Verify ealier and fail faster. Note that we're ignoring RVV priv_ver validation since its minimal priv is also the minimal value we support. RVH will error out if enabled under priv_ver under 1_12_0. Signed-off-by: Daniel Henrique Barboza --- target/riscv/cpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1116686cd1..d8f2eca6ca 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1064,6 +1064,20 @@ static void riscv_cpu_validate_misa_ext(RISCVCPU *cp= u, Error **errp) return; } =20 + /* + * Check for priv spec version. RVH is 1_12_0, RVV is 1_10_0. + * We don't support anything under 1_10_0 so skip checking + * priv for RVV. + * + * We're hardcoding it here to avoid looping into the + * 50+ entries of isa_edata_arr[] just to check the RVH + * entry. + */ + if (cpu->cfg.ext_h && env->priv_ver < PRIV_VERSION_1_12_0) { + error_setg(errp, "H extension requires priv spec 1.12.0"); + return; + } + if (cpu->cfg.ext_v) { riscv_cpu_validate_v(env, &cpu->cfg, &local_err); if (local_err !=3D NULL) { --=20 2.39.2