From nobody Fri Nov 14 23:30:24 2025 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=1759744852; cv=none; d=zohomail.com; s=zohoarc; b=F7uwmk+O9Dkh/1vcqLxYV4Y3OU1wZ9WVo4g4kfDmxk0q5pk+B1mSAtDH8ieHwEL/NRKL24AUyU0nT4fNATbpvzgb2NcHmEcMRzfK+FgVSv5Au4AbOg+rUfaMQZMLwipQtpem/igy5QFpPsgOQlivX3n5os/Ke43KXOsx363xoiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744852; 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=aNwFFCYRh5jyr2MjyNQtywsnU6ZzmVHrHn4w8elQor0=; b=KQfymDDPWqlf0JSm4u1LwDln5Tlfam9YABaiqiVfuYIfq5rMoG72mQFa+ihTGz9AeU1nhIoVKvvieZo0H13le6RG+/mB3hW4oUuxQD0W2dnvHMCpeVYJaZ1b5G2ShnOo+PYf2DX4T95K0ttpuNBZkrR1XxJs2l7W0WcwQ/MGo/U= 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 1759744852722121.79005587974132; Mon, 6 Oct 2025 03:00:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyo-0006Xl-Mq; Mon, 06 Oct 2025 05:58:07 -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 1v5hyn-0006VO-PO for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:05 -0400 Received: from mailgate01.uberspace.is ([2001:1a50:11:0:c83f:a8ff:fea6:c8da]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hym-0003qU-7V for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:05 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 413FB60BB8 for ; Mon, 6 Oct 2025 11:57:42 +0200 (CEST) Received: (qmail 18855 invoked by uid 990); 6 Oct 2025 09:57:42 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:42 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Daniel Henrique Barboza , Alistair Francis , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v7 16/25] target/riscv: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:11 +0200 Message-ID: <5341ba320abba90ea040975ce4ef7d2015c39786.1759744337.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.992975) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.592975 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6jnG3wDchPvR9iC7OeKM71ZvHzTjOj/B4aMwSwCZlYo=; b=bjbFCBiXzXh4GWnqos/uLfVGcC9Kxg55wuM8GBgaZrzWxHmfTkl+As8NEjpbkamDMMVEjCknk9 jGM6qR4s/s3J5kfYca2EBrbWWpNFs41eFOLJ9thHBHzYvC09obNg4o/yIPuuAKC658O4xR+ztjq6 YxI9ab4s1VALdG1vz/eH2U7oBTcv8m7lcoAr/JoSTRDlxKAmwD7KFEcsWMOF4R8yjRpEkb0mCsoR 6emgnybIW1yhXCo9ivrzwh/myb/Bkq9I+ogUL9tCnHI6uImPtu89YAkhdYgA5aCKrS5tbfE6HBqL tusvsgI1lEdZscqzHPX3SSE1n5FrwOZj7ayaZsRMHMDxJwogGRMEDS9wybpswfhvoQj6AzI9Vh0x GFXiCz9DpLkAxE9WmguKyXb0TZ36AiGVsnYHukV0fiW5zr6DY7/qAl2At02xPvZiZEzOLwhuzmUd q+eoW5fp51hmbnXAXQsxdLHnYnkVI7y5JMZJ+XMPuw2wHZOpH7/dme7413IqZjzCtkwXZwFx3at1 s3bu3kdkRXl424wD5xFmUUH0jyb0yot5dnAxY39si5C1UdpfZgXZ1N9hd6hgCuUIgYRvvcbf1pMr WRfE9yqN3SanlWVR1UJnnF+sMhLh0orH3hhLXXzR4bvvnLUCiHzAP1xWIKqJYdyKNRvJFjaD/1DT 4= 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=2001:1a50:11:0:c83f:a8ff:fea6:c8da; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is 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=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 @nut.email) X-ZM-MESSAGEID: 1759744858490116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for RISC-V targets. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Signed-off-by: Julian Ganz --- target/riscv/cpu_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 3479a62cc7..10a10dcd90 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -36,6 +36,7 @@ #include "cpu_bits.h" #include "debug.h" #include "pmp.h" +#include "qemu/plugin.h" =20 int riscv_env_mmu_index(CPURISCVState *env, bool ifetch) { @@ -2176,6 +2177,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) uint64_t hdeleg =3D async ? env->hideleg : env->hedeleg; const bool prev_virt =3D env->virt_enabled; const target_ulong prev_priv =3D env->priv; + uint64_t last_pc =3D env->pc; target_ulong tval =3D 0; target_ulong tinst =3D 0; target_ulong htval =3D 0; @@ -2198,6 +2200,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) case RISCV_EXCP_SEMIHOST: do_common_semihosting(cs); env->pc +=3D 4; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; #endif case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT: @@ -2467,6 +2470,12 @@ void riscv_cpu_do_interrupt(CPUState *cs) prev_priv, prev_virt); } =20 + if (async) { + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + /* * Interrupt/exception/trap delivery is asynchronous event and as per * zicfilp spec CPU should clear up the ELP state. No harm in clearing --=20 2.49.1