From nobody Tue Feb 10 17:52:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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 1640074328341844.7842702625532; Tue, 21 Dec 2021 00:12:08 -0800 (PST) Received: from localhost ([::1]:50750 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mzaFf-0004L1-Lp for importer@patchew.org; Tue, 21 Dec 2021 03:12:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59748) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZL9-0006sa-Dx; Tue, 21 Dec 2021 02:13:41 -0500 Received: from forward501o.mail.yandex.net ([37.140.190.203]:43570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mzZL3-00032P-Je; Tue, 21 Dec 2021 02:13:38 -0500 Received: from vla1-1036dc7f3b07.qloud-c.yandex.net (vla1-1036dc7f3b07.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:3ea2:0:640:1036:dc7f]) by forward501o.mail.yandex.net (Yandex) with ESMTP id A11F045C47D2; Tue, 21 Dec 2021 10:13:25 +0300 (MSK) Received: from vla1-1bc5b51c612f.qloud-c.yandex.net (vla1-1bc5b51c612f.qloud-c.yandex.net [2a02:6b8:c0d:89c:0:640:1bc5:b51c]) by vla1-1036dc7f3b07.qloud-c.yandex.net (mxback/Yandex) with ESMTP id p25vq7wupy-DOeStMGQ; Tue, 21 Dec 2021 10:13:25 +0300 Received: by vla1-1bc5b51c612f.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id GfSzoPAyYr-DOPu7akR; Tue, 21 Dec 2021 10:13:24 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maquefel.me; s=mail; t=1640070805; bh=iFZjoIvyiBLmwbiVxyUQqe/MuA1I1tK7XBYwrWyKyao=; h=In-Reply-To:References:Date:Subject:To:From:Message-Id:Cc; b=fKfvPMSGuIDT3hq5qSFnwbVPhXZAMSi+fk5kGc2tm7PPiv6uCSSOr7Mdr9LkLw7js Inl8DjCQOziQWP3uPpZId1jgmbFAdegzt4PaK94tLP5zDz7nkkU6Zy2IV2fW6aHLRo VEF8ajDnzH8hkQvsGDXv5eiCI+kQtemChgDYCUwI= Authentication-Results: vla1-1036dc7f3b07.qloud-c.yandex.net; dkim=pass header.i=@maquefel.me X-Yandex-Fwd: 2 From: Nikita Shubin To: Subject: [PATCH] target/riscv/pmp: fix no pmp illegal intrs Date: Tue, 21 Dec 2021 10:13:24 +0300 Message-Id: <20211221071324.6213-1-nikita.shubin@maquefel.me> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: 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=37.140.190.203; envelope-from=nikita.shubin@maquefel.me; helo=forward501o.mail.yandex.net 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_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-riscv@nongnu.org, Nikita Shubin , Bin Meng , qemu-devel@nongnu.org, Palmer Dabbelt , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1640074333707100001 Content-Type: text/plain; charset="utf-8" From: Nikita Shubin As per the privilege specification, any access from S/U mode should fail if no pmp region is configured and pmp is present, othwerwise access should succeed. Fixes: d102f19a208 (target/riscv/pmp: Raise exception if no PMP entry is co= nfigured) Resolves: https://gitlab.com/qemu-project/qemu/-/issues/585 Signed-off-by: Nikita Shubin Reviewed-by: Alistair Francis --- target/riscv/op_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index ee7c24efe7..58d992e98a 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -146,7 +146,8 @@ target_ulong helper_mret(CPURISCVState *env, target_ulo= ng cpu_pc_deb) uint64_t mstatus =3D env->mstatus; target_ulong prev_priv =3D get_field(mstatus, MSTATUS_MPP); =20 - if (!pmp_get_num_rules(env) && (prev_priv !=3D PRV_M)) { + if (riscv_feature(env, RISCV_FEATURE_PMP) && + !pmp_get_num_rules(env) && (prev_priv !=3D PRV_M)) { riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); } =20 --=20 2.31.1