From nobody Sat Sep 26 20:02:31 2026 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; dmarc=pass(p=quarantine dis=none) header.from=proton.me ARC-Seal: i=1; a=rsa-sha256; t=1788906577; cv=none; d=zohomail.com; s=zohoarc; b=hCLMNlXVdzQqF2sAyPHrzJwHKL5IqJ+AZzCIab0wp/IuoV5Ox+a6qWHrcv+BO8uN99wh5wmgWR4ExMEvob/kKSMf9I/tzmopHo4pXoLSVE8DWGP+NVxAgaA8ku57BIAefVvUPoIOavrgpY9Gw/fzyMCWgtLNauS4kC4H4u2Kqls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788906577; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=nLpx2lqQ0DWsi+a/I0joa4s81akdIU9FBes1DibMwZ8=; b=i4Sem6EH6CRHNGSyySbu7NirUyeHM5X/KMTThfZpm87IBy9VeeW0o8gYNX7By9c9E4+VJO7MvWvbKv27x5QNM2K09f2LIabQLbQdHf50jv62n8nIEbXofMOPRoS28cANNG8jaqo5f2Se3nbDFTAZe2R7YfZ3F76QGZ3Y9Mg3aSo= 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788906577094754.7008100912601; Tue, 8 Sep 2026 15:29:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x44JD-0006xe-Vs; Tue, 08 Sep 2026 18:28:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x44JC-0006xK-7H for qemu-devel@nongnu.org; Tue, 08 Sep 2026 18:28:54 -0400 Received: from mail-06.mail-europe.com ([85.9.210.45]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x44J9-0004CU-1b for qemu-devel@nongnu.org; Tue, 08 Sep 2026 18:28:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1788906523; x=1789165723; bh=nLpx2lqQ0DWsi+a/I0joa4s81akdIU9FBes1DibMwZ8=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=Mlq9ee/QiY+5PmkkBGphbUQBQavyOU/fDRmxyjjXzFJrQBlzyrg+p2ofUmjvL7LyT 9O6EQ0t1ZhzM8WukOonXKMdARSpbBQe0V/YQRAMq/4YM+epTFELZvonf1BO/xPR6Jx 3slV5gtZtZpRagd85GkhPPJwmeETgeXO2/Fwjs2SiZlE73ygsq6Awnw9RA3o22OTKJ rbzSYUjI2yMe0rDYWYqR65ONd+qYEhowutgU6572FRv/Nsh8R36sTL6RFOKbzelrGs 6hms8at7MVD7veX0rWhbbKY5K7wWVPWmUl0TsfKg4stIs5MMPfos3xNAtSVjYKRA1B UTk8PkFtwYXBg== Date: Tue, 08 Sep 2026 22:28:33 +0000 To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Chao Liu From: "Christian S. Lima" Subject: [PATCH] target/riscv/tcg: svinval instructions raise virtual instruction Message-ID: <20260908222825.84642-1-christianslima@proton.me> Feedback-ID: 169431447:user:proton X-Pm-Message-ID: c073632b9e255ea6bb115b66eb91bc9884ce03d6 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=lists1p.gnu.org; Received-SPF: pass client-ip=85.9.210.45; envelope-from=christianslima@proton.me; helo=mail-06.mail-europe.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 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: qemu development 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 @proton.me) X-ZM-MESSAGEID: 1788906581273158500 Content-Type: text/plain; charset="utf-8" The risc v privileged specification requires hinval.vvma, hinval.gvma, sfence.w.inval and sfence.inval.ir should raise a virtual instruction exception when executed in the vu-mode. This patch add the check to raise the virtual instruction exception when is in the vu-mode. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3621 Signed-off-by: Christian S. Lima --- target/riscv/tcg/insn_trans/trans_svinval.c.inc | 4 ++++ target/riscv/tcg/insn_trans/trans_xthead.c.inc | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/target/riscv/tcg/insn_trans/trans_svinval.c.inc b/target/riscv= /tcg/insn_trans/trans_svinval.c.inc index 4614c1489c..251d9c5815 100644 --- a/target/riscv/tcg/insn_trans/trans_svinval.c.inc +++ b/target/riscv/tcg/insn_trans/trans_svinval.c.inc @@ -25,8 +25,12 @@ /* Test if priv level is M or S. */ #define REQUIRE_PRIV_MS(ctx) do { \ if (ctx->priv =3D=3D PRV_U) { \ + if (ctx->virt_enabled) { \ + ctx->virt_inst_excp =3D true; \ + } \ return false; \ } \ + return true; \ } while (0) =20 static bool trans_sinval_vma(DisasContext *ctx, arg_sinval_vma *a) diff --git a/target/riscv/tcg/insn_trans/trans_xthead.c.inc b/target/riscv/= tcg/insn_trans/trans_xthead.c.inc index f4e3051000..c00b007895 100644 --- a/target/riscv/tcg/insn_trans/trans_xthead.c.inc +++ b/target/riscv/tcg/insn_trans/trans_xthead.c.inc @@ -267,11 +267,14 @@ static bool trans_th_tst(DisasContext *ctx, arg_th_ts= t *a) #define REQUIRE_PRIV_MSU(ctx) =20 /* Test if priv level is M or S. */ -#define REQUIRE_PRIV_MS(ctx) \ -do { \ - if (ctx->priv =3D=3D PRV_U) { \ - return false; \ - } \ +#define REQUIRE_PRIV_MS(ctx) do { \ + if (ctx->priv =3D=3D PRV_U) { \ + if (ctx->virt_enabled) { \ + ctx->virt_inst_excp =3D true; \ + } \ + return false; \ + } \ + return true; \ } while (0) =20 #define NOP_PRIVCHECK(insn, extcheck, privcheck) \ --=20 2.55.0