From nobody Fri Dec 19 06:19:17 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=1733167698; cv=none; d=zohomail.com; s=zohoarc; b=O6cY6N98fJO0fPFLoZxtZOYH3V+EVlLLbdnBZCP1/tAPfEuVipUqg3yECJXW53eCRaje031Q/YxjouXI3avzAll1JrtXt9ZnIDv2uXfgO99vjzeJtRARoUW6Qa/FGWwniE3mb4lSoghH/F3QJlYJrZ1yyx05XbJftG6J6YYSwJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733167698; 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=271I1d19+hwrtCSmDoapYbFtiDg5Ri9aJhXD+6xgmYs=; b=g4A8exrPCJbKZ9crKrn/cOHgefT2RqntT2T1GWTOfZvXiYVK1t0R7v+4HqJXGt5yGUQR1wHf7cHjA1vhU4m+aPcmPxFtGNue9wqqXzB/GNf6NtNQa7QmJiAj5mK7fIsiuAk2Lv/GUuO0YzQviO5CRgPi/iK/OVzSak8O1nFshhI= 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 173316769844883.17129418514753; Mon, 2 Dec 2024 11:28:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIC55-0005l1-U3; Mon, 02 Dec 2024 14:27:39 -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 1tIC4u-0005jT-QL for qemu-devel@nongnu.org; Mon, 02 Dec 2024 14:27:29 -0500 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIC4s-0001xv-8Q for qemu-devel@nongnu.org; Mon, 02 Dec 2024 14:27:27 -0500 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id EE6681813AA for ; Mon, 2 Dec 2024 20:27:14 +0100 (CET) Received: (qmail 7256 invoked by uid 990); 2 Dec 2024 19:27:14 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 02 Dec 2024 20:27:14 +0100 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [RFC PATCH v3 09/11] target/riscv: call plugin trap callbacks Date: Mon, 2 Dec 2024 20:26:50 +0100 Message-ID: <1f9b7a8c8bca228529957a5ca62ad778870215ff.1733063076.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.901804) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.001804 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=4ZMPM+8dJ9Y3dLwFuA+XfDA4K4aLDiwK7sDI2OBteRM=; b=Cu0qkyvh+znyNjz3jL4sRpu57oKBQ5Tj1UzPtNuZMAXr1utoRcgK05xEl/SorY7xkCLVleP8VD pfd1/eMAd4H8PwFzR3udEZi9I1/imj2Go7SqZmtYGbaxYMa2e/xiR/rQpzMSZi4hou36YlegAIzS +EqdrmGS/xKZOd9Ye6+Ji0u51n+MCr3aXVpvMa3oxlayj3SL4gLuTVKFfTVM/AfuZzy/10UTsYWq IM8CUzfgOwCG/ZZIYmyKoUSa/eyc/YdoWNRi9VOWUV8C28NczuIv/SCfrJ2YytY10uo1LP0uRejp sr9/pSAKl0ilcV83WNntwz4Z1rlgYNFRPrHvPnzNUWPg4f+YYuKG5H6hMD/lb7da90hGr2ZYSCnr HgWvmTyg9I/k/uOMUEQZWM6rBsjO+qxZjK4Q15dQup2MqAN91g413HzbEEKdXpoZAQt2oCDfxCH5 OHQuU75dgxE4Y7M5nVw5jBIyUkQLVohl8fXPx87BtV3pQ5dxXM4OtvbWIQ41xkSe1yC6kAuq+tqb DNtYfh9Wb2q66+dlw2dOz8IutwymwTAciCdvVA67RHY4HYoZBbH61JGPJ5Qiov6G3se+OhWsnN+Q iR4PNFqCMciZttTAG0I0858PrPbimuIVglKGVfO5S9/CLvobbe+9ox8BNLB+NosMgA/5/3NNUlLd Y= 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: , 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: 1733167707956116600 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: Alistair Francis --- 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 0a3ead69ea..6da9bd4629 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -34,6 +34,7 @@ #include "debug.h" #include "tcg/oversized-guest.h" #include "pmp.h" +#include "qemu/plugin.h" =20 int riscv_env_mmu_index(CPURISCVState *env, bool ifetch) { @@ -1806,6 +1807,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) !(env->mip & (1 << cause)); bool vs_injected =3D env->hvip & (1 << cause) & env->hvien && !(env->mip & (1 << cause)); + uint64_t last_pc =3D env-> pc; target_ulong tval =3D 0; target_ulong tinst =3D 0; target_ulong htval =3D 0; @@ -1820,6 +1822,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, env->pc); return; #endif case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT: @@ -1999,6 +2002,12 @@ void riscv_cpu_do_interrupt(CPUState *cs) riscv_cpu_set_mode(env, PRV_M, virt); } =20 + if (async) { + qemu_plugin_vcpu_interrupt_cb(cs, last_pc, env->pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc, env->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.45.2