From nobody Fri Nov 14 22:12:42 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=1759744769; cv=none; d=zohomail.com; s=zohoarc; b=NNk/yIpbjO9/YuyQR+YbU1qPKEDdUngdyhw4a8ZHUJnTtTUGUy+p2JU+iIP/eRjTY9l3CeKW86ti0nCG3K6LLELiv6DdlYIqYtdTrzncCNf97guCEng1yFkvs3kQCSGY+TiLvN8OtUPG2pxBHpB8ShG/YJudEHX+Mq8RWfYYqPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744769; 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=+pK3q8m/FMDsacfnFH1mG5uLS8NfyetNM2acUZgOajU=; b=EtTfw5Y14OO6PCf5Sf56KxRXzp5fwyiED9eOvYDL3vMorixAndS7EpEciPb7IjqbPdEtE6kBInE/KB4VY89mNE6Ff2hB975OodT3uiWNraghhH9VKQkDdGfpHKj0sHYWjUbEl1pszOK53AO7irALsTDPaW8bSVgLlOU+MWiQPkQ= 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 17597447697211010.429246073636; Mon, 6 Oct 2025 02:59:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyb-0006Lo-Q0; Mon, 06 Oct 2025 05:57:53 -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 1v5hyY-0006Jz-Vs for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -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 1v5hyV-0003nc-IQ for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 5EF4660B7D for ; Mon, 6 Oct 2025 11:57:37 +0200 (CEST) Received: (qmail 18623 invoked by uid 990); 6 Oct 2025 09:57:37 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:37 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier , Richard Henderson Subject: [PATCH v7 01/25] plugins: add types for callbacks related to certain discontinuities Date: Mon, 6 Oct 2025 11:56:56 +0200 Message-ID: <7eb3da25409f1134671ab23ca4b092bae4a1b9ba.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(-3) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=hWfj2/Sc4P/xZWM7gWMClGalvp64ZdOEFyXk6Zm17AU=; b=KJKoiunNF5U7KDTTTYwvlGBN39PWfO0sZrkQCDFhxNCv5qIhMIm31Hu9lvGLWjg94tmtyzjuPe hcLNB+bVraoKd4U/v6ErjSh89QXK2sdn5Ui0v9fR5n2P+moofQnwZF0w6ns8Hc7cRTqpA7VmWmBu 7k7CRUGHMBtF0ajZDrT2PwwZRl0Eobs4cVo7QFAdE14Zf7JFEI1x21pRnjGG30P3da33ccMC5GRj kKRbuYy9MAOOgLpX+vmJh3UdMfwXCNHsBH/jUrjN5D2EUtdsSfxU54ebnVedX4BxT3RIip0UqS7g im1v7+E4XC9dIa7J7ya0KBnYlDJHYnUgb5c0hHiTXYpNEilMxAXdDpMqAkaLHivC+QCWV1o3LEeY ouOrr5IVEWFjB7OPFKbbGAMibjz3ufIK46XymDSpeRPoFdB2UgHIWK72RSZZpVmmzZ+bQg0dmUQ2 pQ0WV3gqgFfYyM0Xa4h8x6UW9KNnpGZb0V75UANCPItqBxvdoy/YTRV2WcoziqDeZd8E91rKSkYY AN5XvnuSC51cbgggOiTnbBZceFAuGfyvj11wknkOMedMuN6y2Xdz6GQ0vcboUNGDXbowJZknGWN3 DKJ4P44jHk50oVyHUivYHjniybBNu2g/Sf9Jukq9f3DuhsOMzB1rjdgwSYtg2Hr+vNCfSpQnbOER Q= 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=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: 1759744774282116600 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. However, traps of any kind, i.e. interrupts or exceptions, were previously not covered. These kinds of events are arguably quite significant and usually go hand in hand with a PC discontinuity. On most platforms, the discontinuity also includes a transition from some "mode" to another. Thus, plugins for the analysis of (virtualized) embedded systems may benefit from or even require the possiblity to perform work on the occurance of an interrupt or exception. This change introduces the concept of such a discontinuity event in the form of an enumeration. Currently only traps are covered. Specifically we (loosely) define interrupts, exceptions and host calls across all platforms. In addition, this change introduces a type to use for callback functions related to such events. Since possible modes and the enumeration of interupts and exceptions vary greatly between different architectures, the callback type only receives the VCPU id, the type of event as well as the old and new PC. Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz Reviewed-by: Alex Benn=C3=A9e --- include/qemu/plugin.h | 1 + include/qemu/qemu-plugin.h | 44 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index f355c7cb8a..8cf20cd96f 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -59,6 +59,7 @@ union qemu_plugin_cb_sig { qemu_plugin_udata_cb_t udata; qemu_plugin_vcpu_simple_cb_t vcpu_simple; qemu_plugin_vcpu_udata_cb_t vcpu_udata; + qemu_plugin_vcpu_discon_cb_t vcpu_discon; qemu_plugin_vcpu_tb_trans_cb_t vcpu_tb_trans; qemu_plugin_vcpu_mem_cb_t vcpu_mem; qemu_plugin_vcpu_syscall_cb_t vcpu_syscall; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c450106af1..08bf366e36 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -161,6 +161,50 @@ typedef void (*qemu_plugin_vcpu_simple_cb_t)(qemu_plug= in_id_t id, typedef void (*qemu_plugin_vcpu_udata_cb_t)(unsigned int vcpu_index, void *userdata); =20 + +/** + * enum qemu_plugin_discon_type - type of a (potential) PC discontinuity + * + * @QEMU_PLUGIN_DISCON_INTERRUPT: an interrupt, defined across all archite= ctures + * as an asynchronous event, usually origin= ating + * from outside the CPU + * @QEMU_PLUGIN_DISCON_EXCEPTION: an exception, defined across all archite= ctures + * as a synchronous event in response to a + * specific instruction being executed + * @QEMU_PLUGIN_DISCON_HOSTCALL: a host call, functionally a special kind = of + * exception that is not handled by code run= by + * the vCPU but machinery outside the vCPU + * @QEMU_PLUGIN_DISCON_ALL: all types of disconinuity events currently cov= ered + */ +enum qemu_plugin_discon_type { + QEMU_PLUGIN_DISCON_INTERRUPT =3D 1 << 0, + QEMU_PLUGIN_DISCON_EXCEPTION =3D 1 << 1, + QEMU_PLUGIN_DISCON_HOSTCALL =3D 1 << 2, + QEMU_PLUGIN_DISCON_ALL =3D -1 +}; + +/** + * typedef qemu_plugin_vcpu_discon_cb_t - vcpu discontinuity callback + * @id: plugin ID + * @vcpu_index: the current vcpu context + * @type: the type of discontinuity + * @from_pc: the source of the discontinuity, e.g. the PC before the + * transition + * @to_pc: the PC pointing to the next instruction to be executed + * + * The exact semantics of @from_pc depends on the @type of discontinuity. = For + * interrupts, @from_pc will point to the next instruction which would have + * been executed. For exceptions and host calls, @from_pc will point to the + * instruction that caused the exception or issued the host call. Note that + * in the case of exceptions, the instruction may not be retired and thus = not + * observable via general instruction exec callbacks. The same may be the = case + * for some host calls such as hypervisor call "exceptions". + */ +typedef void (*qemu_plugin_vcpu_discon_cb_t)(qemu_plugin_id_t id, + unsigned int vcpu_index, + enum qemu_plugin_discon_type = type, + uint64_t from_pc, uint64_t to= _pc); + /** * qemu_plugin_uninstall() - Uninstall a plugin * @id: this plugin's opaque ID --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744781; cv=none; d=zohomail.com; s=zohoarc; b=Rm9clkNuJtYDs0wjTkxXeQXLTl5gcoMBeQIs4zvOZOyGEhXM6g2JEYQajyzso4xCtiqtJAVaxDO/aUuSczG3tLwjD3jrFKG8jITfjyZMg+vzKLf3W5HJKxRuS4BTlyGxdY1tzd1BA4tjN1D6d9rB2/ngXlQWQz1hSm8e/vC+FcY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744781; 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=C5bR3Il/nQE+tYV8wJM2RISzU6mjtZUGQitJ3EoAgNE=; b=liFcP92dbr6IoKKzApeb0U2r/R+HxcRAsibBro5d4iZ6i5wGhNGtPhd4aH11wqP8qpdpbOg7dCNrZuSj+/DDs8ErpeLnYZd1SrO6FR9PY9U8hqeOAEKvrfx1dXbajzASJ5ZGYwOTMbND2TDumgC9wkUPXGU3yRo/tOm+s2lESj8= 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 1759744781149378.07447048098015; Mon, 6 Oct 2025 02:59:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyb-0006LQ-1d; Mon, 06 Oct 2025 05:57:53 -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 1v5hyY-0006Jy-V6 for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyV-0003nn-Ja for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C1CFA60B88 for ; Mon, 6 Oct 2025 11:57:37 +0200 (CEST) Received: (qmail 18639 invoked by uid 990); 6 Oct 2025 09:57:37 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:37 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v7 02/25] plugins: add API for registering discontinuity callbacks Date: Mon, 6 Oct 2025 11:56:57 +0200 Message-ID: <59887dbdf3cdaeb3906c3b9a26f8803b2d6e6bcf.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) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-3) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=eZeDp3ftAHd+yCWbIxQlyquRoNjVzYZB9b1+kn0WiH8=; b=CDL/eOyTg3Rza1nuASy+vABgw5LYGIOLLcDN1Zc7rcTtmGZZgkmSFQD7yzgNYNkHw1kNgrXd/j 92aw2S43ZlcvIIdTCoWr0KtkzyNzM6Ab9j30VJidEszbL5ktK0sh34yA8O+lgXFYcetiOKFBBqTs HJ7mADzG9y2CsB4kQqCVzCjo2tCnCEwqzLa+yze80IdYrPKmN1GkctKvkimP4ZoBebBVNj1LwcwQ SXc2mzbPpNH1TKQ0/h5uWisXCRE8GBSvbzalRuAldFomFe/P5EdH0FpNjNX0kDaLcdCBOUdW+BtY 36gEAF3al47ZS34BGISZrNDtzmp4z9NFeU4kXxmuwB20XK3QeTKIIFefGWhMrH5YqKfwbaTkstbo HESphpuKb3QX+/ahdoPfllXVYL8sy8/QR/c77chulIFASpkuNx1Tt3b883MJB1itGirgeZ0O/2EC CfMEpO/PwqlXnCioX9dgYZWodA9/FEvm+Ek5nhY+cJ8NZg9oaK2p9aFK+v+1mAdE4/C6kOWx8Lbo s0jKPoaKuhOOrmlb1g1jnfWstxJCjcoVIhbR5XgLYkGXzDQuDGjRjH1AZHp6o/MSgt9ipgkFtbk3 kVc393TL1/Y6DnZ5jTP3U76fcV0P6q6ZMcBloPg+VXIPvEtlt/JmbluYA48hJaIs+guJPB4J0WDA s= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744783407116600 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition to those events, we recently defined discontinuity events, which include traps. This change introduces a function to register callbacks for these events. We define one distinct plugin event type for each type of discontinuity, granting fine control to plugins in term of which events they receive. Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz Reviewed-by: Alex Benn=C3=A9e --- include/qemu/plugin-event.h | 3 +++ include/qemu/qemu-plugin.h | 16 ++++++++++++++++ plugins/core.c | 15 +++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h index 7056d8427b..1100dae212 100644 --- a/include/qemu/plugin-event.h +++ b/include/qemu/plugin-event.h @@ -20,6 +20,9 @@ enum qemu_plugin_event { QEMU_PLUGIN_EV_VCPU_SYSCALL_RET, QEMU_PLUGIN_EV_FLUSH, QEMU_PLUGIN_EV_ATEXIT, + QEMU_PLUGIN_EV_VCPU_INTERRUPT, + QEMU_PLUGIN_EV_VCPU_EXCEPTION, + QEMU_PLUGIN_EV_VCPU_HOSTCALL, QEMU_PLUGIN_EV_MAX, /* total number of plugin events we support */ }; =20 diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 08bf366e36..60de4fdd3f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -281,6 +281,22 @@ QEMU_PLUGIN_API void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); =20 +/** + * qemu_plugin_register_vcpu_discon_cb() - register a discontinuity callba= ck + * @id: plugin ID + * @type: types of discontinuities for which to call the callback + * @cb: callback function + * + * The @cb function is called every time a vCPU receives a discontinuity e= vent + * of the specified type(s), after the vCPU was prepared to handle the eve= nt. + * Preparation entails updating the PC, usually to some interrupt handler = or + * trap vector entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id, + enum qemu_plugin_discon_type type, + qemu_plugin_vcpu_discon_cb_t cb); + /** struct qemu_plugin_tb - Opaque handle for a translation block */ struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ diff --git a/plugins/core.c b/plugins/core.c index ead09fd2f1..40d001d39a 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -569,6 +569,21 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_i= d_t id, plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); } =20 +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id, + enum qemu_plugin_discon_type type, + qemu_plugin_vcpu_discon_cb_t cb) +{ + if (type & QEMU_PLUGIN_DISCON_INTERRUPT) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb); + } + if (type & QEMU_PLUGIN_DISCON_EXCEPTION) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb); + } + if (type & QEMU_PLUGIN_DISCON_HOSTCALL) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb); + } +} + void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744701; cv=none; d=zohomail.com; s=zohoarc; b=IBRvS5FwIcYv1Bf5c3VouEPjarcn7Z7MVyGNdbqcKoEWnE095eaw/evfO4KKKWDERNTuHEdF1Tsg1Xh6d9bGYv5VFqwmkMLc4+An/MNgCrl4woQHmOdAU2FCyAcmBNoM/fO8ME3TOZVZyIAzTNfgJfx9axc9VXkASLQDupqiEw0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744701; 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=3Zvbc+Klv904SNe9upTP7tPPH545R74vCPSDsWPMGiE=; b=ASOkygoZY8gXbCA7guL2MvHL+t78t2fm2arBJq6hfD9JmJMwLwmqWjV5MZ5w2KKSdZCWKlH08HpFVpn0km07Dkj/WiVCPrl2sYdtFshbPuDHVH3Yn9xKrmHO7D3TBdNguCSg77f3FEJvAKbI1+qLxeE7jIYTJlM+/wwsdXBn4g8= 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 1759744701440680.4865890158108; Mon, 6 Oct 2025 02:58:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyb-0006LP-1k; Mon, 06 Oct 2025 05:57:53 -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 1v5hyY-0006Jx-VK for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -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 1v5hyV-0003np-Jo for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:50 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 1E72A60B8F for ; Mon, 6 Oct 2025 11:57:38 +0200 (CEST) Received: (qmail 18656 invoked by uid 990); 6 Oct 2025 09:57:38 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:37 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour , Pierrick Bouvier Subject: [PATCH v7 03/25] plugins: add hooks for new discontinuity related callbacks Date: Mon, 6 Oct 2025 11:56:58 +0200 Message-ID: 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) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.999999) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=ZSHCzgddnSxTNbITRzGkKXj5uD5IHXB/jqzWZ1YJNrs=; b=k9NqGVod8UIsRLj0vhIM8Ghh0DMO83LROs2MK9sMKZq+pEIBHQknm2vY6dBmjsSpovMfziq36r pZj4aHuVpEa0tx7+rTQ3EIr4J5EqcWTrITuOQBOZ46dc4pkHTNk1Lw79CY6Ck0RMkEbDZOSXxDdb r6iklPMXTvhls4LniyowIMEtcblosvVTNwB0xx0DKyxmXgm0HRkFbUcT7rL08WranHs4+JbufCbS TuSMY6kkvTbKH0gQbyYp6RbarBX460TER+0g2UFj2VNkMRbznOTquDNCnEgK/mATyXOTXeeyTPs1 NJjq9M9ypRBeehFzas529rULFY7gkwHS46g7UNFt2yprhMUSRt7GdxeLbWJEVWzrpxqTZiOEYWba l8EB+Y+eRxhGX3//YS8MumUwPy+f0wzN5RXHVUCg5oBPtv6duwldcXl5+3Dv1nGdDmasBMAKz/9s o5WySK9dG87UefFrd5hMAzEbuzYO0wjr3EjUITGNN6meIdXpTvcuCcEGrxTK62vNPRlo63S0v7ms zaZ53Irr/zh9r9xnneFL/a2CgY2LEXcl5guNKtWCK+4izmlkFDBI/mQx7NY2meP1OgAM/4l9tjcs 3sFRrx6G/scRyeJEivvKoX1rWfA9eOXjhYWd3x7O/DsNBT9OgcEJoXXgmsfypHnfBhoBr54V6+yh Q= 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=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: 1759744705365116600 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition, we recently introduced API for registering callbacks for discontinuity events, specifically for interrupts, exceptions and host calls. This change introduces the corresponding hooks called from target specific code inside qemu. Signed-off-by: Julian Ganz --- include/qemu/plugin.h | 12 ++++++++++++ plugins/core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 8cf20cd96f..cea0a68858 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -161,6 +161,9 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu); void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb); void qemu_plugin_vcpu_idle_cb(CPUState *cpu); void qemu_plugin_vcpu_resume_cb(CPUState *cpu); +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t from); +void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from); +void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from); void qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a= 5, @@ -258,6 +261,15 @@ static inline void qemu_plugin_vcpu_idle_cb(CPUState *= cpu) static inline void qemu_plugin_vcpu_resume_cb(CPUState *cpu) { } =20 +static inline void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t f= rom) +{ } + +static inline void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t f= rom) +{ } + +static inline void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t fr= om) +{ } + static inline void qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t= a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a= 6, diff --git a/plugins/core.c b/plugins/core.c index 40d001d39a..35a252d272 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -105,6 +105,30 @@ static void plugin_vcpu_cb__simple(CPUState *cpu, enum= qemu_plugin_event ev) } } =20 +/* + * Disable CFI checks. + * The callback function has been loaded from an external library so we do= not + * have type information + */ +QEMU_DISABLE_CFI +static void plugin_vcpu_cb__discon(CPUState *cpu, + enum qemu_plugin_event ev, + enum qemu_plugin_discon_type type, + uint64_t from) +{ + struct qemu_plugin_cb *cb, *next; + uint64_t to =3D cpu->cc->get_pc(cpu); + + if (cpu->cpu_index < plugin.num_vcpus) { + /* iterate safely; plugins might uninstall themselves at any time = */ + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_discon_cb_t func =3D cb->f.vcpu_discon; + + func(cb->ctx->id, cpu->cpu_index, type, from, to); + } + } +} + /* * Disable CFI checks. * The callback function has been loaded from an external library so we do= not @@ -557,6 +581,24 @@ void qemu_plugin_vcpu_resume_cb(CPUState *cpu) } } =20 +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_INTERRUPT, + QEMU_PLUGIN_DISCON_INTERRUPT, from); +} + +void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_EXCEPTION, + QEMU_PLUGIN_DISCON_EXCEPTION, from); +} + +void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_HOSTCALL, + QEMU_PLUGIN_DISCON_HOSTCALL, from); +} + void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744788; cv=none; d=zohomail.com; s=zohoarc; b=Jni0SvJ3NPZnDejY03gqHwBItKwA+LUwX92kmH8Gktjo0J7SliMU32CWUfQ+womop+xiIckJdiv0rvrhy70qThVto6Cxb5mtEjmERuHlkUTkTAmjEJpf14OXw6tan81ddYkYa8J78rWrVhqI5VNXzHG5G9a6umjOe4A7znlTBbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744788; 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=f9mln+46sxl9Nc6VtvOXWdum14sxJkNBjXA63A+hu2M=; b=JAQZdo+l/j2K0qeHYndcg2qySpGsyFML2T/6wwuNf/IOTx1Q3TZCNHcVzWyNZXEpezbZU8nvfRviHsOh1Kb2Er1bPwOJhHZToK3ktuPojXZMl8BPSB502IZpZ2S9D9fTnX+OdMFOGM8BZl8vYJRSYBXN96VgsOzo+16W+HpjzcY= 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 1759744788198632.2931875623444; Mon, 6 Oct 2025 02:59:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyZ-0006K9-32; Mon, 06 Oct 2025 05:57:51 -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 1v5hyX-0006JT-FI for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:49 -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 1v5hyV-0003nu-HE for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:49 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 689AA60B90 for ; Mon, 6 Oct 2025 11:57:38 +0200 (CEST) Received: (qmail 18671 invoked by uid 990); 6 Oct 2025 09:57:38 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:38 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v7 04/25] contrib/plugins: add plugin showcasing new dicontinuity related API Date: Mon, 6 Oct 2025 11:56:59 +0200 Message-ID: <9ada544f3b3c1840f75d6e2bda8bc23783cd0b2b.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) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.999999) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=sIo30I4BBE3LeK1TKMviLgvsoCVdXVQrkLYXg/L4hsU=; b=eVmdOFXfuhsX+ECTATDtTUwd6atCYn0aJ0mVq9/5SDbZx9aKHwcf7ItjMfaDGFq8BsHB1madKa aSZjGeB2vtPzHHgz/P5IE92VkAHWXJaGW3OGbI/1tnJBQtyPOrVI4GE4sAcy0nCbcikHAPlwaxpG O+xEOdjHXKwv7RZTlqQoNeKQdmNYbHcDxdgmkRUUpzLaZSeT6sEz5qtVEzAr4bw7M3ilDvNtdGo7 Xhyq4FjQseJ8/JJSL3hyeLiJdkkQfoc1OjIZxWUbkNCGImuh5Q2SWMntQWl7KAIaLMFJ0djot/Ya Zo5NEwPGXYa7chX3Ef5m4suTy8k9hhXrTAlZfTAzSgcHrXYNqLJiUEPchHA5sVQrHrTpZ9HPJwu+ KbS6/NTX6jtPSRHPaRoGkvwSt551Guws/+gEdsH8mxG1Pw5g8bFIAYLRUmIpYw2+L3WBtPCnZFNY yk9YtP8B0GLhDYoBjYsAuJzr5Cb6NQnNSN85/JiMRIgURVAwhNacbVdzy/3ZOzXWJlXll9uU1UEC pSmGoYBvKkS9zuqGfrTTR7mUJCQAhfsxJNcIgaltrHsqS6d3qHojJ8W/bZZzwq4fEC66kxKXsmaF NT7UgMIU/42ysFkaNw+AVJ57aKEheQ0vY4oQ8Xy/GhHvxIeaWvzM+veX1gDon9KvB8Ks9gTNwczM k= 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: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 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, NEW_PRODUCTS=1.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1759744794638116600 Content-Type: text/plain; charset="utf-8" We recently introduced new plugin API for registration of discontinuity related callbacks. This change introduces a minimal plugin showcasing the new API. It simply counts the occurances of interrupts, exceptions and host calls per CPU and reports the counts when exitting. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz Reviewed-by: Alex Benn=C3=A9e --- contrib/plugins/meson.build | 2 +- contrib/plugins/traps.c | 83 +++++++++++++++++++++++++++++++++++++ docs/about/emulation.rst | 8 ++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/traps.c diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index 7eb3629c95..eb944b5159 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,6 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', - 'uftrace'] + 'traps', 'uftrace'] if host_os !=3D 'windows' # lockstep uses socket.h contrib_plugins +=3D 'lockstep' diff --git a/contrib/plugins/traps.c b/contrib/plugins/traps.c new file mode 100644 index 0000000000..d5ddc0f3dd --- /dev/null +++ b/contrib/plugins/traps.c @@ -0,0 +1,83 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2025, Julian Ganz + * + * Traps - count traps + * + * Count the number of interrupts (asyncronous events), exceptions (synchr= onous + * events) and host calls (e.g. semihosting) per cpu and report those coun= ts on + * exit. + */ + +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +typedef struct { + uint64_t interrupts; + uint64_t exceptions; + uint64_t hostcalls; +} TrapCounters; + +static struct qemu_plugin_scoreboard *traps; + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu_index); + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + rec->interrupts++; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + rec->exceptions++; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + rec->hostcalls++; + break; + default: + g_assert_not_reached(); + break; + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report; + report =3D g_string_new("VCPU, interrupts, exceptions, hostcalls\n"); + int max_vcpus =3D qemu_plugin_num_vcpus(); + int vcpu; + + for (vcpu =3D 0; vcpu < max_vcpus; vcpu++) { + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu); + g_string_append_printf(report, + "% 4d, % 10"PRId64", % 10"PRId64", % 10"PRI= d64 + "\n", vcpu, rec->interrupts, rec->exception= s, + rec->hostcalls); + } + + qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(traps); +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + if (!info->system_emulation) { + qemu_plugin_outs("Note: interrupts are only reported in system" + " emulation mode."); + } + + traps =3D qemu_plugin_scoreboard_new(sizeof(TrapCounters)); + + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, + vcpu_discon); + + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 8a5e128f67..92c219119e 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -1015,6 +1015,14 @@ interesting to generate them around a particular poi= nt of execution:: # generate trace around init execution (2 seconds): $ uftrace dump --chrome --time-range=3D1753122320~1753122322 > init.js= on =20 +Count traps +........... + +``contrib/plugins/traps.c`` + +This plugin counts the number of interrupts (asyncronous events), exceptio= ns +(synchronous events) and host calls (e.g. semihosting) per cpu. + Other emulation features ------------------------ =20 --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744970; cv=none; d=zohomail.com; s=zohoarc; b=BsOml0sKoD682wmFqZS7R7sYZWfmPZdGZl6+NqqJSQrs/oI6YAK92mvBMvgQxvqGYWi0nMhrefIE5fQm8U5LCC3EO4GBKOdqGBfC2f9rYuos4c21J3jgV/FWsn8p3tdMFpb/UcHI2HmJBw2kia9XRQR3KR6BK9HFJfgyQ6S3stQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744970; 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=6X/mg66Ujbgx3PeYRZ1lBPcVhcbnkVV8qymVGDX478M=; b=novh9wfzYnas+8kOsA/6K53mzoHX5kkmCXVkMTxZWR4n8Z35qr4NM904NWrvC7pJD4qA6NnpJksdyg5L6jyNIvoCCN8cJiIBH5DOHLI5GQ192F2YZwj2PTW7xIexVY/9IbsWXIkmyvgCLY7kpWUSsT5xWXcZMJ1Ur3rHUjV5HA4= 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 1759744969908385.113512922939; Mon, 6 Oct 2025 03:02:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hye-0006O3-Q8; Mon, 06 Oct 2025 05:57:56 -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 1v5hyZ-0006Kk-Uc for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:51 -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 1v5hyY-0003os-DP for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:51 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id A934260B7B for ; Mon, 6 Oct 2025 11:57:38 +0200 (CEST) Received: (qmail 18688 invoked by uid 990); 6 Oct 2025 09:57:38 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:38 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson Subject: [PATCH v7 05/25] target/alpha: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:00 +0200 Message-ID: <7c6fe7d9cb00f84bb912b1e4393c656815b5cc7d.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.995421) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.595421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=NQdS6b7lSZHjuzHV/xnNiUQELPfMS5Qhlg2RCswDKUA=; b=B3kpuZdbD/clCUytsY2r2M24fy77jOvlamf+MH5GiZur/NEf+uT6hMuV/EXa5vAv71UONBWj+P z9WQLlYo3tpApggUU4vpls+YzIWb0c9M36VBWiCla4O6lqh2E0QlpY7hH2sjHQEqZfVtfAay885v Ul3H0JY0WCNYNwxkPFB+ztw4yy+voVOhZfnDUSaBHa8qsOgMSI4ObWiWujhUou0S0bTpeDLghdje RdR2tpKkLTkZL8siokiJRTY1HGGQspnLupKktqFYOsD9EdoLsJsscQHlH4H1XCHCEtb0dK5ljqJq AI90CCNxTVGjhbvbU6va+Ez2dbrTVaMbWGpqaLDaK+jT4+vhzAx1I/2CBhEpqBbKDvkAolzBDG+H d8TFVkl/6VaQNdKWWlAtePXBQbF6S5uF34AHLIIp9j/HC5P4wpnV03NjZmZ4Ilhs4pwcpD2KprcS ARo9UF63KfW6m9tE5qeWyjGzv3xsfLQzrSUUZJ604XS7a9o+IzFfaKwF80jU7v4nguY5gYEUAY2M 7V1TB8h1Ky68MAtRDjn7Vy0ABfOGRGHInNxCDZOmpRr+f5OTTAniWxo0HoSNDCtgyViX/UhLRDQr zJ0sZiatcYgRI9O4G5/ehNlgknU8DmeJQoAIzmGuZYdGFjgNfws7e4kNvSS76XMGGlbLCxng81N6 A= 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=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: 1759744973350116600 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 Alpha targets. Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/alpha/helper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 096eac3445..a9af52a928 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -27,6 +27,7 @@ #include "exec/helper-proto.h" #include "qemu/qemu-print.h" #include "system/memory.h" +#include "qemu/plugin.h" =20 =20 #define CONVERT_BIT(X, SRC, DST) \ @@ -328,6 +329,7 @@ void alpha_cpu_do_interrupt(CPUState *cs) { CPUAlphaState *env =3D cpu_env(cs); int i =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; @@ -431,6 +433,17 @@ void alpha_cpu_do_interrupt(CPUState *cs) =20 /* Switch to PALmode. */ env->flags |=3D ENV_FLAG_PAL_MODE; + + switch (i) { + case EXCP_SMP_INTERRUPT: + case EXCP_CLK_INTERRUPT: + case EXCP_DEV_INTERRUPT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } } =20 bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744692; cv=none; d=zohomail.com; s=zohoarc; b=n6ndSePXDvg4mISxKdZUg9liznkOTKTHO26/D59Y/CNgsqcme8lSfQ1YcA1oURJbsBT88YUxhXFvwdn3M7UVctiMTCZdQroJz9ho8PSk9yvaL5MrYAnIDhnrw99/Vmv7esPyDxqe1mBqe+3CbDjpVVV0ncEOCWeORHYMbF+YXHs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744692; 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=i/MZpPxHebC+LKh7MnrWukgXH3udOcPrsCodUFmkm/s=; b=E9RyJ9yn2NEYxCzIVpQNdNsnVnZIEbqwN/iWkVNUQjWJACcfkNmRo9uVEfPspoH+rmo257XyYeDmxX1sNHPmtesQsPjj1Y0dPKoAqqqXJa3wFPvojRbRwzKysNqx0aoIBu2wwQJ72bhYXegW/HIIx4iy0qllPjcPzRLnbZDFrPo= 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 1759744692625657.7102200576469; Mon, 6 Oct 2025 02:58:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyd-0006NC-Rq; Mon, 06 Oct 2025 05:57:56 -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 1v5hyb-0006Le-Ch for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyZ-0003ot-5b for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id EEA1760B93 for ; Mon, 6 Oct 2025 11:57:38 +0200 (CEST) Received: (qmail 18700 invoked by uid 990); 6 Oct 2025 09:57:38 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:38 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v7 06/25] target/arm: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:01 +0200 Message-ID: <77e01129000585067c2f89d4c1a1efe027e6b0d9.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.999826) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=CcFiwhLtnsO0cl2Wu96ob52uGEm+WsI+gx83eM8jdCg=; b=S7D6+gA+SQp4it3Ej3VTL7Ongs1wZi+Hqnm3S3xct+dfWPqjyGCl8HwbO/I7hk0Fe9Y6quQ3OM uNmUGn00zl0H+QxrXTnLCaGZZwGvnPGNYOMVHCa/TfeuG+bxcAjt2qNOHPE8baib6kvLJUNFgRwe LlrfswtZCPmmGwFEBxXKmrtPoi3oc7NJY7Gpi8XAfAjWR8EcDTkTMSwzhssHb738ki7csnUZNE9M imOoe2MEgKgNAkGXs2lt2g8vls1kfKFl2PS65xELZua78/sFXz4bN2PC6//5RNDy5Qy7C8g8WgtQ l6GXAmagQ4swC/9YmqZXq2wYcOknvjTd2QxmoodaRR4fqaN2PIssdr/5N7xWxlUOflqgQuH7OZNd RYN6WfU5AZFFciZC9xW2QM1jO1f5koXQVZ1XEH4CHni1tpDVnoZAXB4faGhK6peteZSOW294ahy6 JAf+zpxpQ/yvUE2hrmDT9r92bit5/xeJCZcRghKV2beNCsEcNu+DdGdOFTApnZG1R819g35r4WCy 6IVm77cXnlq5n0DxgPqo4qT5M8InryWzhMOEY9PSEzeWQ9DCrl6lzEW6JPUQR692FQsQjn3t9wXr 7a6VbMLbP9bs61i7rdVi5kmL91jxiatSas2l/NrpLHANasoFU7F6DZRUIO3N6Qdhc8nis+QQpH6v 8= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1759744697901116600 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 ARM (and Aarch64) targets. We decided to treat the (V)IRQ, (VI/VF)NMI, (V)FIQ and VSERR exceptions as interrupts since they are, presumably, async in nature. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/arm/helper.c | 24 ++++++++++++++++++++++++ target/arm/internals.h | 1 + target/arm/tcg/m_helper.c | 5 +++++ 3 files changed, 30 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index aa730addf2..2916db4094 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -34,6 +34,7 @@ #endif #include "cpregs.h" #include "target/arm/gtimer.h" +#include "qemu/plugin.h" =20 #define HELPER_H "tcg/helper.h" #include "exec/helper-proto.h.inc" @@ -8439,6 +8440,24 @@ static void take_aarch32_exception(CPUARMState *env,= int new_mode, } } =20 +void arm_do_plugin_vcpu_discon_cb(CPUState *cs, uint64_t from) +{ + switch (cs->exception_index) { + case EXCP_IRQ: + case EXCP_VIRQ: + case EXCP_NMI: + case EXCP_VINMI: + case EXCP_FIQ: + case EXCP_VFIQ: + case EXCP_VFNMI: + case EXCP_VSERR: + qemu_plugin_vcpu_interrupt_cb(cs, from); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, from); + } +} + static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) { /* @@ -9105,6 +9124,7 @@ void arm_cpu_do_interrupt(CPUState *cs) ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; unsigned int new_el =3D env->exception.target_el; + uint64_t last_pc =3D cs->cc->get_pc(cs); =20 assert(!arm_feature(env, ARM_FEATURE_M)); =20 @@ -9121,6 +9141,7 @@ void arm_cpu_do_interrupt(CPUState *cs) if (tcg_enabled() && arm_is_psci_call(cpu, cs->exception_index)) { arm_handle_psci_call(cpu); qemu_log_mask(CPU_LOG_INT, "...handled as PSCI call\n"); + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; } =20 @@ -9132,6 +9153,7 @@ void arm_cpu_do_interrupt(CPUState *cs) #ifdef CONFIG_TCG if (cs->exception_index =3D=3D EXCP_SEMIHOST) { tcg_handle_semihosting(cs); + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; } #endif @@ -9157,6 +9179,8 @@ void arm_cpu_do_interrupt(CPUState *cs) if (!kvm_enabled()) { cpu_set_interrupt(cs, CPU_INTERRUPT_EXITTB); } + + arm_do_plugin_vcpu_discon_cb(cs, last_pc); } #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/arm/internals.h b/target/arm/internals.h index 1d958dbf68..6cbab5a8e5 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -373,6 +373,7 @@ static inline int r14_bank_number(int mode) =20 void arm_cpu_register(const ARMCPUInfo *info); =20 +void arm_do_plugin_vcpu_discon_cb(CPUState *cs, uint64_t from); void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu); =20 diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index d856e3bc8e..3fb24c7790 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -23,6 +23,7 @@ #if !defined(CONFIG_USER_ONLY) #include "hw/intc/armv7m_nvic.h" #endif +#include "qemu/plugin.h" =20 static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, uint32_t reg, uint32_t val) @@ -2194,6 +2195,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) CPUARMState *env =3D &cpu->env; uint32_t lr; bool ignore_stackfaults; + uint64_t last_pc =3D env->regs[15]; =20 arm_log_exception(cs); =20 @@ -2361,6 +2363,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) g_assert_not_reached(); #endif env->regs[15] +=3D env->thumb ? 2 : 4; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; case EXCP_BKPT: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); @@ -2427,6 +2430,8 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) =20 ignore_stackfaults =3D v7m_push_stack(cpu); v7m_exception_taken(cpu, lr, false, ignore_stackfaults); + + arm_do_plugin_vcpu_discon_cb(cs, last_pc); } =20 uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744688; cv=none; d=zohomail.com; s=zohoarc; b=D/lcHjxilYvpviBndKdK8zOzrNnK4lJvwKJJ8H16jzOY1FfEEeEcT2NnHiQVLePfHN2YZ8WN0DsZCDqdsvoAAOFJE4FkASpBi7N7R0I0jueIKITdBbVzz6IkJU5ACk6H6gsHuz/Evhyvefr/1HHMOUwMXTKDtJ56YkIp9WrNf3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744688; 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=2Ft/NUCkLxO2eY49vMtxcP5GmPhCIswNUkgiv+pX6c4=; b=nMjld+7yGZrPf4+jMuQlLLYFvTYslRxa0thwyM4MYWzVVLBmV1BD6jAJ83rZzCblqA033xj0qzg1pZKMfrls9HyqQ6oW2wYzrc4f9qee0FMoIHoNKl7FQPnYRaeJIpUJp5i2Fg3TASf7GVpcApCJDfHJClCKi3dpauh+TpgNM38= 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 1759744687984970.648376776724; Mon, 6 Oct 2025 02:58:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyb-0006Lp-QO; Mon, 06 Oct 2025 05:57:53 -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 1v5hya-0006Kt-Dm for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:52 -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 1v5hyY-0003p0-NR for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:52 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 6DB8C60B77 for ; Mon, 6 Oct 2025 11:57:39 +0200 (CEST) Received: (qmail 18717 invoked by uid 990); 6 Oct 2025 09:57:39 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:39 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , Michael Rolnik Subject: [PATCH v7 07/25] target/avr: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:02 +0200 Message-ID: <7ee40163fe5b9535b427934537936df18cd62785.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.995321) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.595321 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=2UlKhbKoOoVQGSJ3KTG/q+t+0tUNYOPi6CGni73Tih0=; b=oldR2IcHwLO8YV1ZIWOOHoQ997jgOCpfeDgACO5KQ4BpfB2yXdu8WAd41d/eFkWdRsxmXlHGoE PjvptFh5dMKj6HNuD1h9Xj3DRcTNUNlmFXHcfBXchyByt8LN4Wb4WDpTV+5GKS/46qgCIrvZjPZg r/jCpXXZhQFIUtCepJTAD00FJNvU2W44Ghm73e2x2ApY+7vVEeCe4cXSSkdk5pSVNE+uhWGx+TgF v8xoxGeG9pWlkRMLs+HxRVdZz5s+plDjvCbSBwDYhVfQG8SaowvH+XCfHUyK82sZE8FaqxYFG2MD fIX+C2MYs3nvJLn8PePmRUNo3Z++wM9MY+7zLtirx0BWRYRvGF5NbzYxK5GFGG97Jy1brbR5ylvW Sbh4zTIL1pZDDNwAut0SFMRczRt/XiSHwd2KHM0LG2Ks1GlN5gtfBaMoWne64U2TB7pqym+UXeMp 0Hcok4fNVDov3a/Ro6vLZAHoi3Pthihf6/m6GmjUpsQRNEffEJnvUmuAdcxLyJ8S9T9MsMIDnHps PmrSXaVs7A1gXB0X6riZiTZFP4xAdznDFR+kh3HfUmr3D0Di1por1dNcJJiMH73PhqpEg1CJNssA l1lVmuozZkE7JMTanv4yrgYDSDUPmv6A5b9p8MNeezpybC2YzvjYFRS+cqUzA0Y3KSt4m7Fz6nPh s= 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=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: 1759744697809116600 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 the hook for AVR targets. That architecture appears to only know interrupts. Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/avr/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/avr/helper.c b/target/avr/helper.c index 4b29ab3526..365c8c60e1 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -28,6 +28,7 @@ #include "exec/target_page.h" #include "accel/tcg/cpu-ldst.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { @@ -102,6 +103,8 @@ void avr_cpu_do_interrupt(CPUState *cs) env->sregI =3D 0; /* clear Global Interrupt Flag */ =20 cs->exception_index =3D -1; + + qemu_plugin_vcpu_interrupt_cb(cs, ret); } =20 hwaddr avr_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744702; cv=none; d=zohomail.com; s=zohoarc; b=QV76D24mRULH3+jWyn0oB5kE14/wPp9DNyXdZZutHaYAoELysPBnGKcKLr5ysyySs8MXwb2yYuDIcOAqPMNCasvkYdDjaDvC/HNVxwW2ebbvmx3hmTuMeK1nDhjZtRc922ZYJ7wwRnFnXDwRlBEG3ZkKR97JFOCOth0umYuQEuU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744702; 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=RNeTg/7PX6+4eiVVwK9iDSC/DlhTsWDcDpgPyID7fCg=; b=R3VwZg7T8x+sKlC1A7OlVIbx8l0RclWRMZtFt0jzjwpcQdzLKQK6pUSnU3JZvJWHPhhbns8gMZtoGPtugV6Pbt4ISdw0hyUkj1EglmkbhbEdgsyg9uOo/yF5+4NKmkzzvBPRb32D21gfR/wezn8pZPNm715x5jHWl6mQ/yHpS50= 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 1759744702846285.9842254471374; Mon, 6 Oct 2025 02:58:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyk-0006Qe-Oe; Mon, 06 Oct 2025 05:58:02 -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 1v5hyb-0006Lu-SW for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -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 1v5hyZ-0003pf-TT for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B3A3F60B94 for ; Mon, 6 Oct 2025 11:57:39 +0200 (CEST) Received: (qmail 18731 invoked by uid 990); 6 Oct 2025 09:57:39 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:39 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , Helge Deller Subject: [PATCH v7 08/25] target/hppa: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:03 +0200 Message-ID: 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.075005) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.675005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=91oBEkE9sM09e8POP/XtNPoBLu68yemmD0bUlcGlFTs=; b=E8ZMSpTxr0LcZm32SLheFcnZB5tophq03ZjHq52X6TdvvbIp0z5ozppe17qo+E5fKI3D4I3Ug6 PidghCZjjQJ9eb3x6tOK4biYxaszFvLLRwNMmxI0kmQ5e3ylzE+VQttbQYp3jLI6d7Yqrawu7Kfl muFcVL19yZaXNSk6hBXvNfudhBI5y4+s6qabhzWgSDkMf183YrASFF82Nrgcta22kTiZhCs6kDcr iozfjsI86NxQA6CKspkOT9/fB4jICQ3lB8jdvYAg+BK5UPJOh8Y7HGDQ1fpiEP/xJlFx/lRu/gVK XWeNuBseGD48yeGU9VITIxUg2ukQKfNn/+wP2oCMzfkUl2orrQSS+O9gHGFyo4wjFTg8kwUDxkdZ iLnSolezxzcJKf6NSx/CLXTR9fcie4phNdCrOyyCdtV/Q2M5Tz6a6JsBWX+9jcErIRKF1euWwOJ9 ktf4VbQpSW0GrysZvHLGCPlFoGIluQoyBQZSdF7oSVu3hH5wTC7HsfK+1VW0M+Hj+D7PqtA+CdcG 3KpePiY/NodkIUPwMBm1kiZbdygN1cOetJChaXYIcR9gphGY4AIeSAe5x7c4lE56awMtzOtBJCN/ liTs9zhrCQbS7KiMVdvhbP4aOlE9Xpwz1UW98GnuwbtDXW444XGGqQpRCjB1KeHJkWy2RjqMS4Mh A= 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=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: 1759744705281116601 Content-Type: text/plain; charset="utf-8" We identified a number of exceptions as interrupts, and we assume exceptions that are not explicitly listed do exist and should be regarded as interrupts. This unfortunately forces us to list all (syncroneous) exceptions. We decided to also list every single known interrupt as they are few and we prefer to complete an almost complete list, partially as a visual aid to confirm that we did not miss any named exception index. PA-RISC appears to not have any form of host-call. This change places the hook for PA-RISC targets. Signed-off-by: Julian Ganz --- target/hppa/int_helper.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 191ae19404..0742990c90 100644 --- a/target/hppa/int_helper.c +++ b/target/hppa/int_helper.c @@ -24,6 +24,7 @@ #include "exec/helper-proto.h" #include "hw/core/cpu.h" #include "hw/hppa/hppa_hardware.h" +#include "qemu/plugin.h" =20 static void eval_interrupt(HPPACPU *cpu) { @@ -95,6 +96,7 @@ void hppa_cpu_do_interrupt(CPUState *cs) CPUHPPAState *env =3D &cpu->env; int i =3D cs->exception_index; uint64_t old_psw, old_gva_offset_mask; + uint64_t last_pc =3D cs->cc->get_pc(cs); =20 /* As documented in pa2.0 -- interruption handling. */ /* step 1 */ @@ -212,6 +214,48 @@ void hppa_cpu_do_interrupt(CPUState *cs) env->iasq_f =3D 0; env->iasq_b =3D 0; =20 + switch (i) { + case EXCP_HPMC: + case EXCP_POWER_FAIL: + case EXCP_RC: + case EXCP_EXT_INTERRUPT: + case EXCP_LPMC: + case EXCP_PER_INTERRUPT: + case EXCP_TOC: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + case EXCP_ITLB_MISS: + case EXCP_IMP: + case EXCP_ILL: + case EXCP_BREAK: + case EXCP_PRIV_OPR: + case EXCP_PRIV_REG: + case EXCP_OVERFLOW: + case EXCP_COND: + case EXCP_ASSIST: + case EXCP_DTLB_MISS: + case EXCP_NA_ITLB_MISS: + case EXCP_NA_DTLB_MISS: + case EXCP_DMP: + case EXCP_DMB: + case EXCP_TLB_DIRTY: + case EXCP_PAGE_REF: + case EXCP_ASSIST_EMU: + case EXCP_HPT: + case EXCP_LPT: + case EXCP_TB: + case EXCP_DMAR: + case EXCP_DMPI: + case EXCP_UNALIGN: + case EXCP_SYSCALL: + case EXCP_SYSCALL_LWS: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + } + if (qemu_loglevel_mask(CPU_LOG_INT)) { static const char * const names[] =3D { [EXCP_HPMC] =3D "high priority machine check", --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744771; cv=none; d=zohomail.com; s=zohoarc; b=im6rlmYAmoMCzItBjZvqoNTzHQrct9CvpWGqKE2PZGbbwuVafP5sg59EVixmcyS8zZeyI5A0bhjZa7SUOhipZA2haLg9MtmbJ5HXn3pVmBZtBeLUv5yH4k+ccJXv/+Pi2uPOciezo8NyKIJfukqVmT3jeKMtrSlNGZJOKtXGNJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744771; 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=RM7wk8bQMjYoBIBt7ctC7jhswh4wFW6x2/3cltoHRfc=; b=WZrGq3Y/lA0mmkQBoHBHa4pvzYV16t6R5KM31wpRKSO0Ici4hV+9KjZLJAniUie+qqTLA4adDKTYyBU+R4onVd7WNvr+SPV1NlbjxGujmoPpYLTtjY1q7kgwPwzUeGaF9umJyczlMCIf2xoMXFTWBVzfRKnqHZLQZG9n04oEEU4= 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 1759744771728868.6770529883014; Mon, 6 Oct 2025 02:59:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyi-0006QM-T4; Mon, 06 Oct 2025 05:58:00 -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 1v5hyb-0006Lm-Ow for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyZ-0003pa-S6 for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0D0D860B83 for ; Mon, 6 Oct 2025 11:57:40 +0200 (CEST) Received: (qmail 18746 invoked by uid 990); 6 Oct 2025 09:57:39 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:39 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PATCH v7 09/25] target/i386: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:04 +0200 Message-ID: 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.999903) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599903 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=MaaCC1NnIoEHqjPuoSE9U+Utg1hySXIwLbGxGZHEZrM=; b=s8XuMnFcR2ogxxs7+YPW0rJjD83wI3KwsC9TR9VDq7jCPChwFgGM9P+EtOBxj4vwrw7LXgynqx gWA3pz9siwmm7sO1ugkEoWIOgP7Fh3Ww/t9X62Ma3dukPapZzwBETGYXI8o9CdpwXzbTzkENjibk E5NEnnshhTcxlUqfeUaJ6t8aHOMkwqQA4KaqXbskq1A1C+VzRohCokn7n1FMlcPbz8UWh6wjHtOH WHe+OpHW51K0b4EXBTtMxddHJ2ozZNcHh8Ys3yazFUkVTr0RGOSz2F3pQ7f+Mcvb/H7BwxfQIcWO JcdMWABmWCXC08gd8YbKxP2gcqLH6oA3auI41uSdO+XxXH7CoMb/LTv5KFZeiflGbJ+fD5GOR8Rd bggawd/zIN7aDHNww4YV1ZtrYKM/C0BiE5LB9z1VANzRkNrL+CRMTl4an/0kavglp51eXkrY42Mb 8D9TU3DxKr6CHEEQgWCuSEkVaC39d7c24w2+BMEAszp9lYwk89n2MB3aqZkbjfnYrfP04la6abyV nRvY6kytIOCMc0T5MZ+rQG6dH1BOo2aUpGGiGdXKNk4C/pbyhSS5EGyF333NS0ESh0QIJVZ3tnss VnMWj4UOSQ4xyCASdytEogvHw8ns3nQ0SlZTGYWNOHg/4lKYNKwps4iNSENMnLnAlPOoyHyO2YCV k= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744775130116600 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 the hook for x86 targets. Signed-off-by: Julian Ganz --- target/i386/tcg/excp_helper.c | 3 +++ target/i386/tcg/seg_helper.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/target/i386/tcg/excp_helper.c b/target/i386/tcg/excp_helper.c index 6fb8036d98..32f2784e92 100644 --- a/target/i386/tcg/excp_helper.c +++ b/target/i386/tcg/excp_helper.c @@ -23,6 +23,7 @@ #include "system/runstate.h" #include "exec/helper-proto.h" #include "helper-tcg.h" +#include "qemu/plugin.h" =20 G_NORETURN void helper_raise_interrupt(CPUX86State *env, int intno, int next_eip_addend) @@ -93,6 +94,7 @@ void raise_interrupt2(CPUX86State *env, int intno, uintptr_t retaddr) { CPUState *cs =3D env_cpu(env); + uint64_t last_pc =3D env->eip + env->segs[R_CS].base; =20 if (!is_int) { cpu_svm_check_intercept_param(env, SVM_EXIT_EXCP_BASE + intno, @@ -106,6 +108,7 @@ void raise_interrupt2(CPUX86State *env, int intno, env->error_code =3D error_code; env->exception_is_int =3D is_int; env->exception_next_eip =3D env->eip + next_eip_addend; + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit_restore(cs, retaddr); } =20 diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 071f3fbd83..db635aceee 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -29,6 +29,7 @@ #include "seg_helper.h" #include "access.h" #include "tcg-cpu.h" +#include "qemu/plugin.h" =20 #ifdef TARGET_X86_64 #define SET_ESP(val, sp_mask) \ @@ -1192,6 +1193,7 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, int error_code, target_ulong next_eip, int is_hw) { CPUX86State *env =3D &cpu->env; + uint64_t last_pc =3D env->eip + env->segs[R_CS].base; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { if ((env->cr[0] & CR0_PE_MASK)) { @@ -1263,6 +1265,8 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, event_inj & ~SVM_EVTINJ_VALID); } #endif + + qemu_plugin_vcpu_interrupt_cb(CPU(cpu), last_pc); } =20 void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744866; cv=none; d=zohomail.com; s=zohoarc; b=hIPSCN46eFOT3q9dkIDeyTrIeYCZINZXErFvOpSl1LSB72cq9PVhcMMYaXf5GPtotrXBvkrhGcjN8dlnQ+5p8/F8wnLWqzxJR7CIG9pUKW47LcdPsL0rY7G8l4DjPOMfihOcj5IXpZp4DzqznubFNdO2AN8dfa3E5UMx7U8brrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744866; 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=/5A/bovBlpuvLkmIUTm7b2Was0jp7inCPco0M4hZuj8=; b=Bw4lK2cBYeEvR28TnIQ5BYaglgb8ynznzkd8/xJwc7j5nxEW3QdW1UR1FQkt8pTQvvG4NFeVSa5JvfWtYNkPSzAU3+16C9yV7SePzB/N/D6xtHSl5UKtpR9fa7Vo+Lbzbtig9Sd6S1YZZKYnrsNIJ1oDseaY9OsZObwiS6NcSk8= 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 1759744866228655.7373417466549; Mon, 6 Oct 2025 03:01:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyl-0006RM-Hw; Mon, 06 Oct 2025 05:58:03 -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 1v5hyc-0006Mr-KE for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:54 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyZ-0003pW-Tf for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:54 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7CEDC60B7E for ; Mon, 6 Oct 2025 11:57:40 +0200 (CEST) Received: (qmail 18762 invoked by uid 990); 6 Oct 2025 09:57:40 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:40 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , Song Gao Subject: [PATCH v7 10/25] target/loongarch: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:05 +0200 Message-ID: <21a5bf2e810e2c1a3d278ba3ed98f4d4491763cb.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.996214) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.596214 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=T8phxctkNXHnTgk9Nb6JHfuj2CnAEADFPzUwA2KJPGI=; b=YNKff1zv9VfVWwBRIcECEbxwxaqQoyErVYWQ0R96/rjStO8wgLvxiR5skQv5ucyYYSId+GbqM2 f1PoFmZ/ETaMqOqO2UzKPV8Djf2x/vQtQCSPjkdpVvbWaRAgqy/IFVCIlYswfwhk7msni8mPBIBO aAITPgXleWaJQCrW6mRn+ByT8T2gSsuL4p6fMDc3z3zyH8q7e4zl1EuR26JEZzJp9iQwD3muKjig dEPJBOIYnxsJuTQWZMBoCjMnVs64EY3qls01U6C9mRhEo0z1xKPl6jivXHtwRjg0R/JLWEOCWC7p gNKm9YhTH0FR1SoMhMQQuuhsXOVHAFKrX+eszDULmvwUEkAIbnMy+dPJaF4YkitSz7jbDvuIpYGb LBk2P1YAFbN/4jWb+IhM38/UKG3HBWVO8BQNOHdKfH4JLepLAemJ2J23cjVay0stQrAoegOc2DIs FmUouPJmTUzFsN9pbYaKtC5r2/Ff8qbB9BUu1BWWYHbwqwh1O1CnzL/sPKtVmkRSYUQS0ZA5MLVX NqBRxBLGe0CA6LgPh6HYecU8rQoRTyUFhyv36wzhItWeLtmurPsBetJcWwvGrOxEUVROSytYwmFU Wem23pGgVew4ByyhS2g1CSs+mN0t4qDGO0xb2zQsLL7OgY4tiH7+wqPMQk8TSaVg+EBw203sPLeH M= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744868170116600 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 loongarch targets. This architecture has one special "exception" for interrupts and no host calls. Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/loongarch/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 993602fb8c..a8299dfee6 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -32,6 +32,7 @@ #include "accel/tcg/cpu-ldst.h" #include "accel/tcg/cpu-ops.h" #include "tcg/tcg.h" +#include "qemu/plugin.h" #endif #include "tcg/tcg_loongarch.h" =20 @@ -172,6 +173,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) int cause =3D -1; bool tlbfill =3D FIELD_EX64(env->CSR_TLBRERA, CSR_TLBRERA, ISTLBR); uint32_t vec_size =3D FIELD_EX64(env->CSR_ECFG, CSR_ECFG, VS); + uint64_t last_pc =3D env->pc; =20 if (cs->exception_index !=3D EXCCODE_INT) { qemu_log_mask(CPU_LOG_INT, @@ -282,6 +284,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) __func__, env->pc, env->CSR_ERA, cause, env->CSR_BADV, env->CSR_DERA, vector, env->CSR_ECFG, env->CSR_ESTAT); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); } else { if (tlbfill) { set_pc(env, env->CSR_TLBRENTRY); @@ -300,6 +303,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) tlbfill ? env->CSR_TLBRBADV : env->CSR_BADV, env->CSR_BADI, env->gpr[11], cs->cpu_index, env->CSR_ASID); + qemu_plugin_vcpu_exception_cb(cs, last_pc); } cs->exception_index =3D -1; } --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744705; cv=none; d=zohomail.com; s=zohoarc; b=fBBIHEwM2WdEKZqVjt+QkkKuADEELtX1mMXHtcdDrfKcChIXNFr+gdVdxhiP0jkGtSiISAQ1KnE43C8a9uTxCUyoPWn+vmbXwn/CnKz4UriTzicoxPLLuz/ZBk84Fzilv5KkEHi7LYBeT+/mkYklCMqpFhMxX9MvfVgEjTVMq/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744705; 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=FI9LfP1AfB0yl0huPQkH2lcYNsKZ7mWUVydSJ8Xji1s=; b=EKaFGaJa52g8GSvjRUnlvJv2g46BeMLHBgf7Spm4Q6G5mqRDsqBRPh7irG8Z45VZUHdOLMFv3yP7b0amezStVf8Nf1QkRhbt7botSE8tFzgr8CDO0KPqY47JuJhE6Rn4NKXM9JK5YBOVU0pY8Wf5EtBO2sPhHy+vs4rCx1NHZVg= 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 1759744705858899.194464727415; Mon, 6 Oct 2025 02:58:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyd-0006ND-SF; Mon, 06 Oct 2025 05:57:56 -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 1v5hyb-0006Ll-M5 for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -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 1v5hyZ-0003pU-Q6 for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B5C8E60B98 for ; Mon, 6 Oct 2025 11:57:40 +0200 (CEST) Received: (qmail 18776 invoked by uid 990); 6 Oct 2025 09:57:40 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:40 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Laurent Vivier Subject: [PATCH v7 11/25] target/m68k: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:06 +0200 Message-ID: <1246174a278a434ffae2f202fcdc586bebb01d95.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.994071) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.594071 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=FRZ2j8rbmm/3ycj8ZP5YixYFG9zzEquVSOdWN5ofsr0=; b=orFPOe8MEQC5yqX1iBZdCP6iobJgZ9GYxs8ncYtzkv32eAFuCTejCcdRjyw0Y4DNTWwg3ZYgrL sD/cinYP97ZlFE/SlAtbl7XO4vHqOFCrAX7PC58mQNGPigCTOPTqePZSS6hD7fAda0W1nV7Ocbtk GTfj+S/hXgFAGxrwEcFwhQbxRh8/a+drI7t42cYFSeVV20iJdqJrYx8RDsPjy0xKxUYVamwdQ36W iaYP7KaVMcEnCGiiyt+S2JlhpcgXtBhyARQ9s5T10kUYrMhWFpOE69SSn3/AysOZjIQxh5I/n94S 7hyNmZ5FzNK/l03TMZmKZETP7dp0L5C11s2AdOG3NaVpW3uGlM1bb3s6jpHEfJt+HsPrDlqHUiGr UG5gTMS6a7YbJgLR7ed4vJqxEveiXoj4h27ODWv4zPzuhDYs1mlVdEaRe+0duIhYmW8YwnlTyQBw SSOm61zAkMJXBwb+URDyx99UgHvZbmq8xlVgdMnefDdzU23D2XLjsLFxIhLdvt30quQFPGA47Ng2 eT6tRAZxWNXXmgkHBPH6VhWZX3eSHx+dSAKS2VQlVDTWyH29CsGHJhJ3GP8cABTtDMDgxVnWIgFq Q1l5w6Qh96J22WxV3WbGkaMfb69dFPNWjdIjIhL7YMHE0SamI+lwBhpOr4SHmprs3kmhR4Zad8JD k= 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=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: 1759744707316116600 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 Motorola 68000 targets. Signed-off-by: Julian Ganz --- target/m68k/op_helper.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index f29ae12af8..e9c20a8e03 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -22,6 +22,7 @@ #include "exec/helper-proto.h" #include "accel/tcg/cpu-ldst.h" #include "semihosting/semihost.h" +#include "qemu/plugin.h" =20 #if !defined(CONFIG_USER_ONLY) =20 @@ -183,6 +184,21 @@ static const char *m68k_exception_name(int index) return "Unassigned"; } =20 +static void do_plugin_vcpu_interrupt_cb(CPUState *cs, uint64_t from) +{ + switch (cs->exception_index) { + case EXCP_SPURIOUS ... EXCP_INT_LEVEL_7: + qemu_plugin_vcpu_interrupt_cb(cs, from); + break; + case EXCP_SEMIHOSTING: + qemu_plugin_vcpu_hostcall_cb(cs, from); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, from); + break; + } +} + static void cf_interrupt_all(CPUM68KState *env, int is_hw) { CPUState *cs =3D env_cpu(env); @@ -203,6 +219,7 @@ static void cf_interrupt_all(CPUM68KState *env, int is_= hw) return; case EXCP_SEMIHOSTING: do_m68k_semihosting(env, env->dregs[0]); + qemu_plugin_vcpu_hostcall_cb(cs, retaddr); return; } } @@ -239,6 +256,8 @@ static void cf_interrupt_all(CPUM68KState *env, int is_= hw) env->aregs[7] =3D sp; /* Jump to vector. */ env->pc =3D cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, = 0); + + do_plugin_vcpu_interrupt_cb(cs, retaddr); } =20 static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp, @@ -277,6 +296,7 @@ static void m68k_interrupt_all(CPUM68KState *env, int i= s_hw) uint32_t sp; uint32_t vector; uint16_t sr, oldsr; + uint64_t last_pc =3D env->pc; =20 if (!is_hw) { switch (cs->exception_index) { @@ -417,6 +437,8 @@ static void m68k_interrupt_all(CPUM68KState *env, int i= s_hw) env->aregs[7] =3D sp; /* Jump to vector. */ env->pc =3D cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, = 0); + + do_plugin_vcpu_interrupt_cb(cs, last_pc); } =20 static void do_interrupt_all(CPUM68KState *env, int is_hw) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744771; cv=none; d=zohomail.com; s=zohoarc; b=VcP00bV4r1/ZonvwKJNdYXlMcxSnwUApx0CX0LGUO1/67UDPSygXbCUUZHSZ6iW0UQJ67XV+r4uSTJ/Jr0IzQfFVxuV408c4NjYpU+Er5Uypr8GQj9++sHqwRRI1pJAWTt6dwjSDAyv2fBsdI+v6AFZySvCfkETY9YFuGbtq+I0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744771; 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=GfWrLCChDIPGQtG441x7aq6NZsqG+VfGd9i82c/KPrU=; b=OqVhOjCUV+Ix2ZzxVYY8v0CaUII/djqKW2yXvYxdVIcsTAhPKQGlfukBNIA9BokMkVYS0JstKwe1fwhuvtOnOSa81eCZR+m/ybYPMYG/Dqi1enIL5pdmHbP5MzfeurFf1RSi6PApf0FZWQl5ezzfjAzGFuaUPUij9wk91pKjiFs= 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 1759744771389437.0162089440547; Mon, 6 Oct 2025 02:59:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyl-0006Qf-3q; Mon, 06 Oct 2025 05:58:03 -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 1v5hyc-0006N0-Tv for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:54 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyZ-0003pb-VZ for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:54 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 018B560BAE for ; Mon, 6 Oct 2025 11:57:41 +0200 (CEST) Received: (qmail 18790 invoked by uid 990); 6 Oct 2025 09:57:40 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:40 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , "Edgar E. Iglesias" Subject: [PATCH v7 12/25] target/microblaze: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:07 +0200 Message-ID: <4c5496cbe92eb59503352e26968d183ee6272581.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.997498) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597498 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=rM5JX9zlQ9WGxAYK3Aunbsrp/Za/oYwP9iC2VqK2Yd4=; b=AoTi29uvqH5RlKyI7bmlGRGxOCUyPypkqZFbp9923HNaiPN/1bTBniKmdh4+CRZl8k1jF/Nhzr 3bCYwVxBqEC5ErfV1cYr0KrxLaRHgRkf44dxqq9ARUFVMV/KidKdi95cDtk95ytetAhUCw0i3K2d Cmvl3rGSUptCNScNZAmXi0F5DV1b85NiMcxdWw7Kw2/0XebLK9l9Rq/T/SIs14+APSBnfM+jzqRW dDJeZuSPtjPlPQDdq1o0zzh0SPAF/fA7YZRwE+/b4aRnsE28n4YpXKZtfxiD6W+BAK/FwJuTtS6W ReJGlQfZ1juOmdpC9MyfK7XbOb2IaZzpuB3y+UV9gJyaHoke1/7QlF9fdqC5AAAAx5LA8iapY5mU /i93muEhsi9hpbhjFUPlhzpTlsca0Sf6iQgS8aqo90+IH+QxEUUOlugeAsSJHVK64SKBMTH0dq+W Vic1bdjvhMbObK00MKagjR3c4g+L0nsro3pv0VYquLL6v9E3hbuFznKXNf7PuyVNgkvLzHb/ViUt RuW7z8wA2/6fH4WEk5c7Z1XkI/9s6gQgjP3VpWVKThTlK2jYAas0QIUTxlcFQOKLfXEDwxFbqd0o oLh+he8tuCJ8acjMsBL5SdhPubi6WHcVSoLXrD8ewsqweQdgJ9K27barxPzf6KCPVEemEF+corZ3 E= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744774223116600 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 the hook for MicroBlaze targets. This architecture has one special "exception" for interrupts and no host calls. Signed-off-by: Julian Ganz --- target/microblaze/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index ef0e2f973f..d66eab6e4b 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -27,6 +27,7 @@ #include "qemu/host-utils.h" #include "exec/log.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 =20 G_NORETURN @@ -35,6 +36,7 @@ static void mb_unaligned_access_internal(CPUState *cs, ui= nt64_t addr, { CPUMBState *env =3D cpu_env(cs); uint32_t esr, iflags; + uint64_t last_pc =3D env->pc; =20 /* Recover the pc and iflags from the corresponding insn_start. */ cpu_restore_state(cs, retaddr); @@ -54,6 +56,7 @@ static void mb_unaligned_access_internal(CPUState *cs, ui= nt64_t addr, env->ear =3D addr; env->esr =3D esr; cs->exception_index =3D EXCP_HW_EXCP; + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit(cs); } =20 @@ -152,6 +155,7 @@ void mb_cpu_do_interrupt(CPUState *cs) CPUMBState *env =3D &cpu->env; uint32_t t, msr =3D mb_cpu_read_msr(env); bool set_esr; + uint64_t last_pc =3D env->pc; =20 /* IMM flag cannot propagate across a branch and into the dslot. */ assert((env->iflags & (D_FLAG | IMM_FLAG)) !=3D (D_FLAG | IMM_FLAG)); @@ -256,6 +260,12 @@ void mb_cpu_do_interrupt(CPUState *cs) env->res_addr =3D RES_ADDR_NONE; env->iflags =3D 0; =20 + if (cs->exception_index =3D=3D EXCP_IRQ) { + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + if (!set_esr) { qemu_log_mask(CPU_LOG_INT, " to pc=3D%08x msr=3D%08x\n", env->pc, msr); --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744866; cv=none; d=zohomail.com; s=zohoarc; b=OvMmUVrGDolBtKFtqNU9n32tV6cCriYIHXQwCHx+b9T/adzFVXg0njU9jZd9SdQgCngfPbfrT0A3WpjZcwXS0bsIUwvEqMjn23/ByxSF13DOsB2NKG0mdl5nMQ9cbDeiln8O+2gq4IKK2j8bgbRWKSCLXLl6yaukT7144VZCtf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744866; h=Content-Type: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=4sWrccxdT+7/T6NQf9ZfnVL5gRC/gfSxiheMo483FI4=; b=KKr2o/rVBtFlyQgp509qtU3fbFCapPHidh9vfNYwcHiOHhCrDf6POUfnI4O2srin0+ParKM/vfAu562hTxljB40ux+P/7twp+2E2Ez5sQLDHvoq0RNQVORed0/IvDasDrNw1WaFx1STWvvjqEkkLfO+rpg2wn8ajF1djF3icOkM= 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 1759744866391785.0719470038837; Mon, 6 Oct 2025 03:01:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyf-0006O8-NP; Mon, 06 Oct 2025 05:57:57 -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 1v5hyc-0006M7-3N for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:54 -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 1v5hyZ-0003pV-Tf for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 5BCFE60BAC for ; Mon, 6 Oct 2025 11:57:41 +0200 (CEST) Received: (qmail 18810 invoked by uid 990); 6 Oct 2025 09:57:41 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:41 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH v7 13/25] target/mips: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:08 +0200 Message-ID: <01114d79e7ad2c9a8824a417f3869bdf0f0293e7.1759744337.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ------ X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.988632) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) X-Rspamd-Score: -6.088632 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=4QCLeRlIzG5ENUNvx1SoYVdpQIbTNKVldgdxK9RZn7c=; b=GWGTzzhPS5BW3tUOnoTERjTtfOqsaynRMzDNtHGWXnmHSQOvDsNRuMESDX6P7AfAxxXbBrtaJe 7q1jTK8HNroCEQ+9vRthHH5owWKPQ2lK8VzN0jkfi23/f8CV+LeRyc1Hojw/r52AM46YlVO0sMIk g33Z8ji+m04Zmf2U+37FBrx/zV/nKMMl9xWcLChL6O+u5FNMlOJxeSqKlVNgvUNSGPPxzpGMWejb URADMOq3RMa95/FGpsrLMyGICf6xpjq+dEpZOJ/MFpLgCAHDaSRbJXpZTwupP/5JWtdy8UdGMk8/ wQVgX0R4gg2iX6sH7XZW9rYxda+JMQJLnb8zwcU7ExJrUK3Mq3h0xObDzrJFjsixilbNnrlwhxLA PG79EvI/qpkxk5llBqY1zc16kJsvX7iWM8RVlQETmWa+gQK0md4K7pPldYKh5w5Kccs3l86dDuk5 SjoUDpBQYtJwCQis0/vyBYmpxcTawgEiVAXjWN0GtIMibhJQdnBthnnARhC6o+z/XPKhd3YYWu8r Lzg4omSdZNmBvRi9TUDHtL4OOVIo7aNGl4lpNdGmmrn/aOPw1mdsgXbpjlu5OW/ySgAxfUOjOdrI VspAUYcHnnzpnKViisnEuoT/uqMfbujk9ObYMayeOfec/e9ZaB4ylA1TWdnZxtfFk4JmwbI+YxEJ U= 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=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: 1759744869765116600 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 MIPS targets. We consider the exceptions NMI and EXT_INTERRUPT to be asynchronous interrupts rather than exceptions. Reviewed-by: Richard Henderson Acked-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Julian Ganz --- target/mips/tcg/system/tlb_helper.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/mips/tcg/system/tlb_helper.c b/target/mips/tcg/system/t= lb_helper.c index 1e8901556d..566924b079 100644 --- a/target/mips/tcg/system/tlb_helper.c +++ b/target/mips/tcg/system/tlb_helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "qemu/bitops.h" +#include "qemu/plugin.h" =20 #include "cpu.h" #include "internal.h" @@ -1034,6 +1035,7 @@ void mips_cpu_do_interrupt(CPUState *cs) bool update_badinstr =3D 0; target_ulong offset; int cause =3D -1; + uint64_t last_pc =3D env->active_tc.PC; =20 if (qemu_loglevel_mask(CPU_LOG_INT) && cs->exception_index !=3D EXCP_EXT_INTERRUPT) { @@ -1052,6 +1054,7 @@ void mips_cpu_do_interrupt(CPUState *cs) cs->exception_index =3D EXCP_NONE; mips_semihosting(env); env->active_tc.PC +=3D env->error_code; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; case EXCP_DSS: env->CP0_Debug |=3D 1 << CP0DB_DSS; @@ -1336,6 +1339,14 @@ void mips_cpu_do_interrupt(CPUState *cs) env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, env->CP0_DEPC); } + switch (cs->exception_index) { + case EXCP_NMI: + case EXCP_EXT_INTERRUPT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } cs->exception_index =3D EXCP_NONE; } =20 --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744843; cv=none; d=zohomail.com; s=zohoarc; b=mB11/m2NhiKlq6GzPfths2+EGxUDd36iBmnDkf3FTTJeWihcMFun7JC/bmrtOsn2BLLMfgWlbx/r8qYqllxdK72hEamUuejjV9KfM1FD18yEZe9katTOU13XNjW4N4Pd5DchnhCKWIwlz6Fd9XZgbiE6Y+EJv/Bw3rpcmlgz8Sk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744843; 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=+ER/MqjaWJVEABzSQpRm+HQU+L1QnRyBXkRMNclVuFY=; b=ndqKUZ9ZLaCPlgySNQpCAbDBfyczc8YvwnHJHG3IM7N1Kk8RZa7XTwj5dK9hA3r29JQ0FODPj0E4KA9wMtLQgv80wSV+opEMh4QTwtVou0fkmSngGBNLrw6frClCtQ/H5aEJvR4+VAmUcFhEcNiVLniVx1lIQfxfm+YNXVjCxhU= 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 1759744843597462.32289991968605; Mon, 6 Oct 2025 03:00:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyo-0006X5-AS; Mon, 06 Oct 2025 05:58:06 -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 1v5hym-0006SQ-Ey for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:04 -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 1v5hyk-0003q6-RV for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:04 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 9896060BAB for ; Mon, 6 Oct 2025 11:57:41 +0200 (CEST) Received: (qmail 18825 invoked by uid 990); 6 Oct 2025 09:57:41 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:41 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Stafford Horne Subject: [PATCH v7 14/25] target/openrisc: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:09 +0200 Message-ID: <5628d04291d8d77c3548bd3bf0856a5154970850.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.983381) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.583381 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6By6W6p63fDAcZVupcavoMH8cQUKrNcCRvR5J3edyUo=; b=qcn/yWWou/29XoGg1aRkCjTIpTlqHz1uyld30Pf7I86ckf5DZdW0w75SpbnboH+aXcFaDyO+D6 5kRWHnwg2zg1XhxcO5RJj2MmexgIz8hbJiBs4Va2CRsHoLuEikYTs6KR22ZxmiQj8wgE4ckkNTM9 a6LxcW/1U2dNaoiEKDZoO2iuVn61C90WQ6Tv9RwNk4D8IOYTtPmrNqMxfTWp/4gMRxEMifE6VZid kHebdz6nlVLj8wsGIVgzpNIaRFbi7wARW3ReKvKYpZIaHUmhBxTLlV47IqO77CxtDp27w5XVdl27 Ym9XznL8RC55fAnH/Qw/Rflsm8s+lZZ+eDAwk8QCUcm4ei7CncnYfnlN0uIOUOS2janm9XMEdrnt 7QAPV7Zja6EsBUGc5bJCVTQZAJV7E4hdI9OExDzVPD7eolSqaDBZcy6rBeZGJn9OS+x7cA2lHTd1 SaGXYPQLBTUecUR/gnqD/ucDIECrstthyGldwlui1/+3jZYOAmwH1rMv5cFQB0X5EebQUVK2GD7L 9CvVBEbVMJKwPq6zAbEvejTNuZ6O1uSxcbZKLBz7ylC6lkBQmN6sDNvNiNghs4AjoQ9euyCbPJoM NkHsYcHNlhhAQ7m+4wtUFy/srJagcwHzzYyQDWn0zuBaHy7GBQ3o3pqu4C34s3RsXNmApSr0jTti w= 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=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: 1759744849406116600 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 OpenRISC targets. We treat anything other than resets, timer and device interrupts as exceptions. Signed-off-by: Julian Ganz --- target/openrisc/interrupt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 486823094c..d357aaa7da 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -25,11 +25,13 @@ #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif +#include "qemu/plugin.h" =20 void openrisc_cpu_do_interrupt(CPUState *cs) { CPUOpenRISCState *env =3D cpu_env(cs); int exception =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 env->epcr =3D env->pc; =20 @@ -98,6 +100,19 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } =20 + switch (exception) { + case EXCP_RESET: + /* Resets are already exposed to plugins through a dedicated callb= ack */ + break; + case EXCP_TICK: + case EXCP_INT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } + cs->exception_index =3D -1; } =20 --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744763; cv=none; d=zohomail.com; s=zohoarc; b=VqxOnXdsYRiLQHYaLLCs8A1e2iIRQr/Wsuaba+qxQPxqoYmGtA5nmCMdciRMbZwFE5nqgQdhHqRnMfmv9uBMK+ve64Z1Rrh1XMLDsRVGDYCoFyPsdOkxyJSHi8p4WmfwfHH8oEr3cnaY1CaH4ihGTViueIxOm0oocHwRppZHLuk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744763; 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=v237/wWyU+kci5xAafOdud1umgh97l5cwck6V2Y5IW0=; b=jHCQRpIx1rrHdZlyGfY/IyFSSgMonUmgGo07ZDEzoDnnzKuQBuyCE6ymPM2UDMm6aw/99FPEjb1BYaVLjQh4CfYchWXH52Fwd4Z3UJlDC2l5vkDm559s/w05TO3/VPzPWtSM1QjBGzMun7Wf+db9QuuYF8iASmviHGVfXUjBr/0= 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 1759744763160624.6676400679258; Mon, 6 Oct 2025 02:59:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyf-0006O7-Ks; Mon, 06 Oct 2025 05:57:57 -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 1v5hyd-0006NF-Ky for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:55 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyb-0003qI-Aa for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:55 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id DC48760BB4 for ; Mon, 6 Oct 2025 11:57:41 +0200 (CEST) Received: (qmail 18837 invoked by uid 990); 6 Oct 2025 09:57:41 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:41 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Nicholas Piggin , Chinmay Rath , qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) Subject: [PATCH v7 15/25] target/ppc: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:10 +0200 Message-ID: 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.962428) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.562428 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=uQChR51oj+aG0zkY+/JvsLAbv/s6w2MfYyQgGOhbbLc=; b=tUXQi6UCmsDyeKT06HmgCe5SwRDGPANaL8B41oRkePhysJTKJRsSrRV29hhGZhM9EcnmnEPh37 PH9PiXhyPzIInUgk6IOUxgdGdBcT+xjTtFUIQMb0tFihU9jvVJhOQv4LEGwPqdOgfntjIhwvepar bka7PiUXv4pGtjizU4/IX9zVGgDVh38Ym5TYCZv+7T11MX4APpvZl0Wd8W+tKbi4PS/WjBZvXAhO KxpES34drR9P8Yzcohwp9YsBkNthJxPr0X/izPwgA+Cjkqf19XiSKOKx1hh13PmWHuUkyIOF8Q7u wJGYo7yq37ydHo3N6mPkBNNzC0cPpIP1hVmdFBu9KXshU2PyhdA5Yn1Bc9KnqwFLlKK5h0eRsN3h Rru5R6/CzeWx6LFSAyHreGGlZ1SEqkPDLasndPqzlkHbqXX07y2Dp54vex7HFa3OooT0L0Rnzs5t YpzOOzeeY0emjvbQqyQJVohgqY1Ul7obvm4ayH2tMWFJecT7vF0aXcXv5D3E3KzwR8Ugdw99Iq6U qcRTm+ZXagerSI7PTOl/BEHwpd+piUrVSo7zFy417fdIeMCU2A38Ik5Ml6W0dzLV7NixzA8uQxwp WTQfUEyEeAMPpwyExxQV6duOicnG4uqFwy3n4b6rLpGqb+cg6e4Ev6JHyVrOrPFEpiiAVthp/J/F Q= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1759744767434116600 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 Power PC targets. Signed-off-by: Julian Ganz --- target/ppc/excp_helper.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index d8bca19fff..6d05b86505 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -27,6 +27,7 @@ #include "internal.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" +#include "qemu/plugin.h" =20 #include "trace.h" =20 @@ -404,11 +405,31 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env) powerpc_checkstop(env, "machine check with MSR[ME]=3D0"); } =20 +static void powerpc_do_plugin_vcpu_interrupt_cb(CPUState *cs, int excp, + uint64_t from) +{ + switch (excp) { + case POWERPC_EXCP_NONE: + break; + case POWERPC_EXCP_FIT: + case POWERPC_EXCP_WDT: + case POWERPC_EXCP_PIT: + case POWERPC_EXCP_SMI: + case POWERPC_EXCP_PERFM: + case POWERPC_EXCP_THERM: + qemu_plugin_vcpu_interrupt_cb(cs, from); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, from); + } +} + static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -456,6 +477,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } env->spr[SPR_40x_ESR] =3D ESR_FP; @@ -510,12 +532,14 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int exc= p) env->spr[srr0] =3D env->nip; env->spr[srr1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -567,6 +591,7 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -653,12 +678,14 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int exc= p) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -708,6 +735,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -758,6 +786,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) if (lev =3D=3D 1 && cpu->vhyp) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } =20 @@ -803,12 +832,14 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int exc= p) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -858,6 +889,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -908,6 +940,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) if (lev =3D=3D 1 && cpu->vhyp) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } =20 @@ -947,6 +980,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_ppe42(PowerPCCPU *cpu, int excp) @@ -1073,6 +1107,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1; + uint64_t last_pc =3D env->nip; =20 /* * Book E does not play games with certain bits of xSRR1 being MSR save @@ -1144,6 +1179,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1252,6 +1288,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) env->spr[srr0] =3D env->nip; env->spr[srr1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 /* @@ -1373,6 +1410,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1, lev =3D -1; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -1472,6 +1510,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1516,6 +1555,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (lev =3D=3D 1 && books_vhyp_handles_hcall(cpu)) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } if (env->insns_flags2 & PPC2_ISA310) { @@ -1662,6 +1702,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) ppc_excp_apply_ail(cpu, excp, msr, &new_msr, &vector); powerpc_set_excp_state(cpu, vector, new_msr); } + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } #else static inline void powerpc_excp_books(PowerPCCPU *cpu, int excp) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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 From nobody Fri Nov 14 22:12:42 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=1759744775; cv=none; d=zohomail.com; s=zohoarc; b=NX8siiH5ze/lq0hpKUaHGep5hy1tuNc0dRNZp2eWL8g7GOrNxNenG39T64lrUcR+HIz9nuMx3+eKkuc4+iY4N0T0972XI/4Z918fqOluA9M+qjAhqespCeZP2Ix9MIZpwwd1liRmo+RDx//NF3vu3wbk50WbUGvxDhX2BxnwC/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744775; 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=bmqjE8ooXkFoPszGK8BczmMSyivRP35VpUeb6TNvd4M=; b=QUl1rWD5jtX86ZPYxG+5FeMpC6GEUIOAmBif+4H3r8i78T3OT8DRebJCyPrCMQSQksH2XM+XCea0hz0VmabQITVmvS/YCf/FOAeqH44VnxDOdaJQMTp/0DbViXcBR7FwXXtp3NkrRYE1eh2NYglELTN0zWXxHBNgxEmsJc9M270= 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 1759744775512697.4442863027289; Mon, 6 Oct 2025 02:59:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hym-0006SD-1H; Mon, 06 Oct 2025 05:58:04 -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 1v5hyd-0006NK-TA for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:56 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyb-0003qW-OI for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:55 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7C67460BE7 for ; Mon, 6 Oct 2025 11:57:42 +0200 (CEST) Received: (qmail 18872 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 , Richard Henderson , Yoshinori Sato Subject: [PATCH v7 17/25] target/rx: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:12 +0200 Message-ID: <4ff28541830b9df3ecbd7abc687b6ee539aa17ac.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.9869) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.5869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=uI/BjTYdC7z/7F5A6PPEG9j6lzk7xU/k4iG6aZX+MLQ=; b=pLkpPPQMCOVPx2O0CpNb9mK/9pFyVSxwX/d+IqE+LwNamNm4Y3pYbqxQSmlUp3bmguHa6DM2fJ AP6rdbY6k1drdmuCJBvbz5B/wvXUcvOnSwUEFx0DEgs103dXp882D4032eO+/bVnecvgNmAz5IHV Fg6mtSOC6OT+7299I9F2ClyVNww4rE7xBuw5d7iOr3/HI4uwMqFyM5Pygfd1P5+him7TxbjWVoaT JmxlNBwI6TiNJRo6F8hs44QKdaCD7w4UVHZctdMKPc2CaafPDeODMt2j8Kn93WINZOp8FwCKfkAR dSm/JPP4Dryp/Q/C5cSuIm7b5l4kmatWB5pq76aLIPK8a+9nBSJiwIU/camFqO2cbabAtikWiW/a RrKvI2jtUT6zeErGbsOtzkbYkH60fYwQX4c5nJI22wG0buUf0WNC+ECL8oOiiHSTblvrNFOpYy9/ yPgtPBGaSLXK6eMFVkga6RnwjGDz4nEGAHOI61RurO48oEk3BI8cDCuZuJcttfNGU601B67cZHHM /598xRiTKw/qHEJjomKilJtB9FVmMFy7odAezFYwwOPvghRbZGWgnu8iZAh5Z2KMgKBsHPRFs+8/ eOu33kIcIXxfbfQPG1tCkDx2SN6VG8ZmN3UonQt/sgmcMHsfLzuyTUZtwQv69inOKuGdmkm+7Di7 U= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744779238116600 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 Renesas Xtreme targets. Reviewed-by: Richard Henderson Reviewed-by: Yoshinori Sato Signed-off-by: Julian Ganz --- target/rx/helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/rx/helper.c b/target/rx/helper.c index 41c9606fd1..ef47e32add 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -22,6 +22,7 @@ #include "exec/log.h" #include "accel/tcg/cpu-ldst.h" #include "hw/irq.h" +#include "qemu/plugin.h" =20 void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte) { @@ -46,6 +47,7 @@ void rx_cpu_do_interrupt(CPUState *cs) CPURXState *env =3D cpu_env(cs); int do_irq =3D cpu_test_interrupt(cs, INT_FLAGS); uint32_t save_psw; + uint64_t last_pc =3D env->pc; =20 env->in_sleep =3D 0; =20 @@ -65,6 +67,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D 15; cpu_reset_interrupt(cs, CPU_INTERRUPT_FIR); qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); } else if (do_irq & CPU_INTERRUPT_HARD) { env->isp -=3D 4; @@ -75,6 +78,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D env->ack_ipl; cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "interrupt 0x%02x raised\n", env->ack_irq); } @@ -92,6 +96,14 @@ void rx_cpu_do_interrupt(CPUState *cs) } else { env->pc =3D cpu_ldl_data(env, env->intb + (vec & 0xff) * 4); } + + if (vec =3D=3D 30) { + /* Non-maskable interrupt */ + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + switch (vec) { case 20: expname =3D "privilege violation"; --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744966; cv=none; d=zohomail.com; s=zohoarc; b=Z06O9DKc7UwMtCzDDlQ0SKeCFEUm6k/Q1ioMyrszwn3bHG4HN1BtrAQ9xaKE/iAgQ5pAWmW9CopzdxxFHz8OVLvIZZt5zcQTfsjPx9SWCIvmNIIGn1ca6TFs9OihbvXCIcbtwSFMJjNMHdeaY+KqjOSx8RbOuI88kHOxiH/keqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744966; 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=6cwNCCXeLl88nZHQgXAG1TKJ3YUJ3wWLztMx0eG86/E=; b=WiHdBV+f221K9bbiGYUTUZjh1smHFnC45kzyUWcxpQs5wjwx2TnKtsyJf7WOKWGO871t5BtwomXdPw8cRGrj9silpbAt1aXsyYktpLeaKC2vKR8ECyzUHbEVv3mOeq61xzdwWge3W4UWqCLdxaC4SWM8lucPDFi05K/AR7jEl8w= 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 1759744966813698.1232902511035; Mon, 6 Oct 2025 03:02:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyg-0006OI-8i; Mon, 06 Oct 2025 05:57:58 -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 1v5hye-0006Np-6l for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:56 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hyc-0003qm-9g for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:57:55 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C3ADC60B87 for ; Mon, 6 Oct 2025 11:57:42 +0200 (CEST) Received: (qmail 18887 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 , David Hildenbrand , Richard Henderson , Ilya Leoshkevich , Thomas Huth , qemu-s390x@nongnu.org (open list:S390 TCG CPUs) Subject: [PATCH v7 18/25] target/s390x: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:13 +0200 Message-ID: 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.962272) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.562272 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=SaAf/mb9HEvbJAmt7DG7SMTiyDFoPmxYLnh5a2mc56Q=; b=TmxrrUoJKf9jdTpZBbYJ3i4NNHhlGQe7Mo85nQUR5iX8JFxJroCheorTjKxCQ4uJqowLgvX239 PypjGXtIUR4OqCfqpXdw9hHVfvLXU1sDuughoLCH3ap5Ihi1ECcL1kaB7b95pVi4WZMQFF+vO/20 TqrzoOLHYDZtKHtr34VlnpkBNgWMxFTaM6hXQ/adpZaAgr9GO9toMO+ft1OtzMwCOyvxOHEpX9MD tDY6tomx03iUU0tGh3zUSM8NGaDxRCu3p/9wQbLfuRDU2EtpH24rAkZzHDz+ZfIvt3SUhTcyiUyA pKVKbsTwQdjkVPOtZ7L6fWUTx19CQA4C6KUpmnWwgOs1c6j/hkaRNuNI3fhNnqDK+3QqGhVW3KAl qcbsO1Nov6ju8DVuciK8HAzCb24QcbS8Rvw2t70MbRL/Rwhgl+zOloqbpie0O3Y8DpyBmOnvJ4N4 zMi38zly3pFwzhxO5UdnIwJI06U3Kc04Qjw/1B1n9/ln2JZCTa84VXkr48qWt+Uf2C/aKKbWWqSx GmLmpN23ixu9UqMWlDwDomB6uCS/USB7hioVvFZbmxumiwiKyPXszNCM7aSipjRzWaXpVm7tTHKs aBNzfPhdQzfaUcbmU9vlPsQziLJjOy1ldN5ZouhZFpN58MNz73qmAazo1K7Y6IatjONtygMwhOQg c= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744973203116600 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 IBM System/390 targets. We treat "program interrupts" and service calls as exceptions. We treat external and io "exceptions" as well as resets as interrupts. Acked-by: David Hildenbrand Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/s390x/tcg/excp_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index 4c7faeee82..7265b610a6 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -34,6 +34,7 @@ #include "hw/s390x/s390_flic.h" #include "hw/boards.h" #endif +#include "qemu/plugin.h" =20 G_NORETURN void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra) @@ -499,6 +500,7 @@ void s390_cpu_do_interrupt(CPUState *cs) S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; bool stopped =3D false; + uint64_t last_pc =3D cpu->env.psw.addr; =20 qemu_log_mask(CPU_LOG_INT, "%s: %d at psw=3D%" PRIx64 ":%" PRIx64 "\n", __func__, cs->exception_index, env->psw.mask, env->psw.a= ddr); @@ -528,21 +530,27 @@ try_deliver: switch (cs->exception_index) { case EXCP_PGM: do_program_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_SVC: do_svc_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_EXT: do_ext_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_IO: do_io_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_MCHK: do_mchk_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_RESTART: do_restart_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_STOP: do_stop_interrupt(env); --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744834; cv=none; d=zohomail.com; s=zohoarc; b=e8Ib1TsgxlhbItUi/mWNpYWMVPJH1Wt348JZyEtZt6483GjU8llldlTRbbSUyOJC2DPjlDUL7C3y/8sQp0XFiwFcVf3Wz0Bu8XC0xG7V6YBHeQXurI/AlZoCv1/s7Vjn9O1meyr0cXgxlNUGQcwiIUcE5G3YOYGrdQvWg425Z5M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744834; 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=SndOjOVmcgU20dBIB2T8a8q2fH/uJ4W3PLEh4Ej54S8=; b=PLcs2ECTja+7RNAG05v99eyKLjcQedrog3o+f3zbJp93ox8Otounq94fWxc8DnGIno5lsx2AJ/yvfHm8jZe2SrInsWe4Xiatlk02M0KjQs82yx1acZmUgHi2dMgonywKOCHMRiS22z9cq0r6jpzCcY0gADDVvmUHQwSNicXx7bs= 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 1759744834915430.94268154676956; Mon, 6 Oct 2025 03:00:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyq-0006ae-Qc; Mon, 06 Oct 2025 05:58:08 -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 1v5hyp-0006Z0-CA for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:07 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hym-0003r0-IV for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:07 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0C6B260BF6 for ; Mon, 6 Oct 2025 11:57:43 +0200 (CEST) Received: (qmail 18903 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 , Richard Henderson , Yoshinori Sato Subject: [PATCH v7 19/25] target/sh4: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:14 +0200 Message-ID: <105995a312c0d20f0b5a816bdfc2ddfc5ceecd50.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.998048) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.598048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=SordwaBTTHwBeWWY9UP8KbtbiTHsyrq+7lo4143sRLc=; b=xsA8JYnyR4cPmMOPfhh7Z/UQzW3Amni5aYBE7qjlZBujFyU68Nm0AbXMo1dyy1CNOgkHTQK4+M 5VtPG3V68rHb5cfwVJ3FTGlVeAgT+izCNCGMqYoJJgs5O+uk/3xDm1FEXDaX2Xi2yeW6wvuZqnsH wxpJ3q+BM/4chH3lN4lBRyyYlH6DpWmLEXazqLCTj94n7l0UCytk/E2/0h8yJBF1/trTTgTwjW04 oVPgTTb/i2MI8wp6SYusbQu8H1hc7TeVdUr7UjPltZbW8BN8EIXaguvrw6jpqiMnBVT2DJ+IREbt hjjQNgvlnNWflAT2bjfdbq6AGrYGLHKKiXiTtrz+UPkPc8mxSZVRzflqjE9gLO99ZgyYCZbU75LY 7wNYvGWawN2n6NaDdD9YnEiUJdyNjZDHzfOoW4ICRCBRVgH8sK3p7ESz3mnT8MHqnO7GVLqcc6YS +VnbfAkkXJ7kNwguLNExcsHeFII7yF2lYzZ2WEu6H8p2CLtDJn5B6qIFvqkvHb7r874SiM63GqYZ Lg3ZLmDgdVflletodUo1qfYyrpuRRbnAQmUueBSyuU8nbT6cxTRcmbhMunJ5Pt1rNuWPK5gp6Wyp +lkkVO/7hGdR1EZXIXeBCF7fL4BcW0KPvUidte7ThVaUSefdt6AdYNp7e3DOj2xC95ifJ+OLHW+n k= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744838573116600 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 SuperH targets. Reviewed-by: Richard Henderson Reviewed-by: Yoshinori Sato Signed-off-by: Julian Ganz --- target/sh4/helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 1744ef0e6d..fb26d5c35d 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -24,6 +24,7 @@ #include "exec/page-protection.h" #include "exec/target_page.h" #include "exec/log.h" +#include "qemu/plugin.h" =20 #if !defined(CONFIG_USER_ONLY) #include "hw/sh4/sh_intc.h" @@ -60,6 +61,7 @@ void superh_cpu_do_interrupt(CPUState *cs) CPUSH4State *env =3D cpu_env(cs); int do_irq =3D cpu_test_interrupt(cs, CPU_INTERRUPT_HARD); int do_exp, irq_vector =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 /* prioritize exceptions over interrupts */ =20 @@ -176,12 +178,14 @@ void superh_cpu_do_interrupt(CPUState *cs) env->pc =3D env->vbr + 0x100; break; } + qemu_plugin_vcpu_exception_cb(cs, last_pc); return; } =20 if (do_irq) { env->intevt =3D irq_vector; env->pc =3D env->vbr + 0x600; + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); return; } } --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759745101; cv=none; d=zohomail.com; s=zohoarc; b=Fe27J1MVcFXRGaGYPyFYivnPARlKRYdPZ6g/VSUmJLG55lRUH/scsnR7s+OQ9pKRTMt67sk9ry8WaEWrAn0UF/C4joDl7wIDVuuXn/+fhmVEV6KpH406ffdtCR7EwitEKYwnKcNr9mwXDCyhE88IVE1bQvIhkqizYtzKr/TCvsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759745101; 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=FQ1lTYmLNDsPqKZZwbbhDxe358Eyermm/MkWd+cjcSY=; b=L7Ssd/ayiK/G4qoVk4l3r8qhJaHvCloWUSF1JUmdJgUNg4qgpjVmxZwKQZHT91Otf34p9nwypm3dzBZOM1Blkiz/LO40CsFKcemqOdXfeXxUl/I+g1lM4UYkIPJIm1zCwd5e2XW4oRv872AwE68y1DqOsx0BHkBKM2I3eHU0WS4= 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 1759745101512549.6228280618375; Mon, 6 Oct 2025 03:05:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5hyr-0006an-I7; Mon, 06 Oct 2025 05:58:09 -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 1v5hyp-0006Z5-CL for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:07 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5hym-0003r1-IE for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:58:06 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 4C28D60BDB for ; Mon, 6 Oct 2025 11:57:43 +0200 (CEST) Received: (qmail 18918 invoked by uid 990); 6 Oct 2025 09:57:43 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:57:43 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , Mark Cave-Ayland , Artyom Tarasenko Subject: [PATCH v7 20/25] target/sparc: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:57:15 +0200 Message-ID: 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.99945) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59945 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=XmfQC1pUHdirPeAvXHEzNtY0D5FB5BhCt4uiwodl8Ho=; b=eZWvw4PKS75E2t6SedZ8nVvv8oQN6WB/8q7FcVz33U01fUyEryO7DiPTfMla0EBAkd4JCm+9qm VI28lw8py49szgYB9DIQRahVO2L47rPb5fol//I9KQI5o4rglQTiR2U3YGil6XrcRb66hD3Ao++p weAq8QlZQF1aV8XXSP6cfhwKiTMsHA7h0mHs9/kaAtIDvXeOV87A9bKYD0Taw/znfw8qZ6dO9vCZ 2eMADywdtmaBupDemrBZ3irxxPyk608SkNjkJ2q8Uu8egQzXg0ME/bQGYDG2xZK2zivo4IdzcIGe xzkOoia/zBQRDMRtqLhHBJqLm75PX4Ctfxr44V/EMDX1WvyPQhmBd4+XjnwAoY0scsdq15BAcHDf CZUlJPg733JHtTj3b9+91C2BK5lMP5IT6mH0jGhW/DgV+8tA0RobnW1EoO7AW5ILI0C/bihAipcR 1Ejxuwz1DQlGSQGMdDT7Q+fUhzWwrxQIqnhcJhwcqW7OVT3tfOnflYWfMr2GNArt3uGl3f66QrsE P5kRpAMNZzVLkm5vTtV8CosgYPQ2DGbUoLE2FYmlOtdTV6sJHw1eXLvISI27MzDnT9ZmBRF1B/vh k3iyV7APME4jUC6Vf1ALGzgXyuDG1hNw0Ct+zNZO48WUa8FNNvguI2IEWxDhG9Mdwl7A2c1rt4B9 o= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759745107398116600 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 SPARC (32bit and 64bit) targets. We treat any interrupt other than EXTINT and IVEC as exceptions as they appear to be synchroneous events. Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/sparc/int32_helper.c | 7 +++++++ target/sparc/int64_helper.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index fdcaa0a578..b29f693a6b 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -24,6 +24,7 @@ #include "accel/tcg/cpu-ldst.h" #include "exec/log.h" #include "system/runstate.h" +#include "qemu/plugin.h" =20 static const char * const excp_names[0x80] =3D { [TT_TFAULT] =3D "Instruction Access Fault", @@ -174,4 +175,10 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->qemu_irq_ack(env, intno); } #endif + + if (intno =3D=3D TT_EXTINT) { + qemu_plugin_vcpu_interrupt_cb(cs, env->regwptr[9]); + } else { + qemu_plugin_vcpu_exception_cb(cs, env->regwptr[9]); + } } diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 23adda4cad..067d936cbd 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -23,6 +23,7 @@ #include "exec/helper-proto.h" #include "exec/log.h" #include "trace.h" +#include "qemu/plugin.h" =20 #define DEBUG_PCALL =20 @@ -255,6 +256,15 @@ void sparc_cpu_do_interrupt(CPUState *cs) } env->npc =3D env->pc + 4; cs->exception_index =3D -1; + + switch (intno) { + case TT_EXTINT: + case TT_IVEC: + qemu_plugin_vcpu_interrupt_cb(cs, tsptr->tpc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, tsptr->tpc); + } } =20 trap_state *cpu_tsptr(CPUSPARCState* env) --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759745077; cv=none; d=zohomail.com; s=zohoarc; b=nCgoJWamRUXE7FO1DflJlyDlrcRexR4Gtb+s/JDe9wpmaohGywt3aDiPn5ncgXjzNk2REq+uWEM2TFskLOcf5K1G/IpoOI56voVXQWtSVnJiXKtSVgk3j7ESrQZ8T2Cdn3KRq8t3II9ltHtUldHIgEXsSMx4kShuytPR2lDzJvA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759745077; 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=P7Zztw43UAiqxdi4e3UMo7xspQaoF+6Gc+slafGaNHo=; b=lBhZ5y3n+yd+vP6ZDJpU62QhJE7Qgt0OPRH9ryKad5TSneOLCNR+CwdAyBcGH4GcYocNjEC5R7mZdzfaF40PZAtDzcQDZO1UILm7hhfkoaA+pR1ZmH7oOu1QW0QZ65xowKdgl6wIh0JOYtN75KSqPHjr2IaBVcpbkwP5GwIVSF0= 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 1759745077816113.79854010213205; Mon, 6 Oct 2025 03:04:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5i0Z-0001eV-R5; Mon, 06 Oct 2025 05:59:59 -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 1v5i0P-0001TY-4i for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:45 -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 1v5i0N-000410-G8 for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:44 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id F1EF760B87 for ; Mon, 6 Oct 2025 11:59:41 +0200 (CEST) Received: (qmail 20981 invoked by uid 990); 6 Oct 2025 09:59:41 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:59:39 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Bastian Koppelmann , Richard Henderson Subject: [PATCH v7 21/25] target/tricore: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:59:16 +0200 Message-ID: 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.988061) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.588061 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=sikDKxVdoH/tFrpwzH0GPVt3AT9j5FuE97/PA4t+p6A=; b=Xj/Sks4SS5JapuY7jKvgDjjQAryqr5IYrHI+Ps3mgX6WYaTrGqld/pwI6Zk+j/JpQlzvbMViEF ZcDftLHxWMP1Xdf+xMue0LhkymgmQpzprIF4OrBY6YRPCvL2DFuofvhsf3cnnXG0kYbIlEmgoUWT DOEIJ+FiYEmHN7E558dhw11CF5HmV5GRcAn0lB7CRK5E0sEOgFKrn9XEatcRjkQZ9regYCNVXeks IWUFVbBu1pN8ENUQDM0E2W9b0uq+dPRYjBPRzfXBUkoSgJcadiBoTeH8V/mkYkwmUmsJZ9M1ufT5 id9iuZjM/4J69V7POtj9UrzBeS3L/6e5WiEScJ9pbaHslHDhMhSe+aMaq+2dpPJ4x2ugqlaqz3HZ DYQwAR8/dph2epR2h1ywvVQtXH8AjqGdOWOBVNRGhImnsz9m/P0T55zhMSH0LRAqN7MfuBPmbxxd ikUgE2/wXV3oVcvD8ojUPaotMpd+jiPz7QRHCPSsKIuWorTOlLudhToa4T/ipiF58bkcrvPLF/BP 9xyGyy2aV9uY3N9D9SZzR+esdin/qnoiB2Z8dWpbjAzDmM4AWEEDnVIE4Z4Q4aLQEuBJ7w9Ia77O 4TCWr10UVaBgV9RbcIEmIZBdFltNZAxrfTU/0J0gnoj5JZ/1BnrE5I8aSmnANYM+0bDIzf0vOwKT 0= 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=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: 1759745083264116600 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 an exception hook for TriCore targets. Interrupts are not implemented for this target and it has no host calls. Reviewed-by: Bastian Koppelmann Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/tricore/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index 9910c13f4b..9bd6ce55d1 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -19,6 +19,7 @@ #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "accel/tcg/cpu-ldst.h" +#include "qemu/plugin.h" #include /* for crc32 */ =20 =20 @@ -29,8 +30,11 @@ void raise_exception_sync_internal(CPUTriCoreState *env,= uint32_t class, int tin uintptr_t pc, uint32_t fcd_pc) { CPUState *cs =3D env_cpu(env); + uint64_t last_pc; + /* in case we come from a helper-call we need to restore the PC */ cpu_restore_state(cs, pc); + last_pc =3D env->PC; =20 /* Tin is loaded into d[15] */ env->gpr_d[15] =3D tin; @@ -90,6 +94,7 @@ void raise_exception_sync_internal(CPUTriCoreState *env, = uint32_t class, int tin /* Update PC using the trap vector table */ env->PC =3D env->BTV | (class << 5); =20 + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit(cs); } =20 --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759745076; cv=none; d=zohomail.com; s=zohoarc; b=TzvVYbmLls0LntPCtTLEqazpKsK+6mhTKdRFEv4dbUPsb7taojFX/iGDcvAk5etBhQPItEfJfJXHUlczW/R+73Vop84FBvL+Ai/MleMphOs87XTU47XeK1Uo/TUYRF/XmRwlkHNFZ9sHYKFZUvcbMepxQ+aDgBe08WZyPjk2w5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759745076; 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=H4jDzpHpAf/hVvBUd6LjTW3vQ0Lv+kEgDFsry6GepLg=; b=TEujwWb/hGwGgFPGXmdq78pk3rGCqx05nksdVGTzBDxj29qt44Wggz7ZygY/+rXReEbTUwWPDCgAGSCBo/HDn1n1vZ5OY1QEga/6Zyaoyr3dqAmIKUmHeiZNX5lnD1tvieyG8/nHvWaESDBgKnN6NEu/SBkXqdIjemeNE1gKsTo= 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 175974507627084.84989758485312; Mon, 6 Oct 2025 03:04:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5i0u-00023J-7S; Mon, 06 Oct 2025 06:00:17 -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 1v5i0P-0001WB-Rz for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:46 -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 1v5i0N-000412-Qn for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:45 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 3DD6060B8E for ; Mon, 6 Oct 2025 11:59:42 +0200 (CEST) Received: (qmail 20993 invoked by uid 990); 6 Oct 2025 09:59:42 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:59:42 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Max Filippov Subject: [PATCH v7 22/25] target/xtensa: call plugin trap callbacks Date: Mon, 6 Oct 2025 11:59:17 +0200 Message-ID: <1ea18c5c484ca0c1fc11738a3033cdacff3296e3.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.999997) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=4qMKxbL61NUaVuIspdY/J81NXPxh6lWuOHZ6cGQg8/w=; b=oe6i21s71975NDLuIwPvsELwPmDgk7DbtCxZimmROzXHgDeoDa/mJFfCWrgE6L81cLiVqAgtpB zFbWIuib7HVXvg1aCkc18jnSsWDpWPJEXgEoSI5NWKYqEu844xUs+dEiCief8kpNQfevvWAYPc67 LxOaFq+T1mmvf4coqwxyimSubWfQuoTTF2WK1MoKD/vW5K0kGExiBZprWfrPRRN4wFuIpBNSosu0 3bmiIbJ98nHaexUYNa5hTz6laK2h6RKJ2juUA+Cw0S3e+VUALYb7ygbgamqJmcm/UrvdejFZRPd1 H88gb66AP0Fcv6hBQnlmprB73b/VUqZlALFk4kLRn1j2JMR5sK7mgCLrSLLNkSjZcPm/mYUSDA2w 4vpYTzOs7lh4z/WnmNXkzrtBVD+bevJsHFKikUboGMbvJkT7T/KKPkuaw67yzZBIxxP3hoXajv1u uUHlQEobQsGULH41GGLgiWnICkuPW4Mb9C447Aia10Kt5jt+ex1g2l2FvIHJU+XWcDp/Tg6nBG1b zJdFOTf+BZH9gnx7CFuo6qqPOEJuyd1eQO2iWElwsIdTMVB2Co4vSPKM3ZaHfYxx97zZc7geLdbA +MYvrPu1f1xevIUfFOx/p8G9btgVojyaDN3o0SnxVbJQj+zhr3wUD3ft5gX4NWvePHbWhsQ+F8NT w= 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=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: 1759745085149116600 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 xtensa targets. Reviewed-by: Max Filippov Signed-off-by: Julian Ganz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/xtensa/exc_helper.c | 6 ++++++ target/xtensa/xtensa-semi.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index b611c9bf97..fdc522698d 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -32,6 +32,7 @@ #include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "qemu/atomic.h" +#include "qemu/plugin.h" =20 void HELPER(exception)(CPUXtensaState *env, uint32_t excp) { @@ -207,6 +208,8 @@ void xtensa_cpu_do_interrupt(CPUState *cs) CPUXtensaState *env =3D cpu_env(cs); =20 if (cs->exception_index =3D=3D EXC_IRQ) { + uint64_t last_pc =3D env->pc; + qemu_log_mask(CPU_LOG_INT, "%s(EXC_IRQ) level =3D %d, cintlevel =3D %d, " "pc =3D %08x, a0 =3D %08x, ps =3D %08x, " @@ -218,6 +221,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[INTSET], env->sregs[INTENABLE], env->sregs[CCOUNT]); handle_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); } =20 switch (cs->exception_index) { @@ -238,9 +242,11 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[CCOUNT]); if (env->config->exception_vector[cs->exception_index]) { uint32_t vector; + uint64_t last_pc =3D env->pc; =20 vector =3D env->config->exception_vector[cs->exception_index]; env->pc =3D relocated_vector(env, vector); + qemu_plugin_vcpu_exception_cb(cs, last_pc); } else { qemu_log_mask(CPU_LOG_INT, "%s(pc =3D %08x) bad exception_index: %d\n", diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index 636f421da2..129749c92d 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -34,6 +34,7 @@ #include "semihosting/uaccess.h" #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/plugin.h" =20 enum { TARGET_SYS_exit =3D 1, @@ -194,6 +195,7 @@ void HELPER(simcall)(CPUXtensaState *env) { CPUState *cs =3D env_cpu(env); uint32_t *regs =3D env->regs; + uint64_t last_pc =3D env->pc; =20 switch (regs[2]) { case TARGET_SYS_exit: @@ -430,4 +432,5 @@ void HELPER(simcall)(CPUXtensaState *env) regs[3] =3D TARGET_ENOSYS; break; } + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); } --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759745085; cv=none; d=zohomail.com; s=zohoarc; b=hLYEx2uuuQyI++1tcgAu7Ru9nPmnSQuMiF/9Cn659O1hlIH8bPA5HnW3/ae84qGhtxMqB8d8aJndJNwJFh1Bb8Sxhc3K2S/0pG0jfMInj/1DB06wGdo3+QiZcE/vjDUqup7I6FUdRqnNNurAf7G5JmIezGXNDcM+EncVI5VtPZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759745085; 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=BbiMI+KevS8E8Z0Bg03krlmr/m/lZTIuZKXVkR/IJb8=; b=ObEMGae5S4KMYpn9HmhNe/s8r/8KOCBLLCbRNdAecDq93OszzsWlkuCK+78Z8QOAKZ+2gt3dzvlmp6TiXtn7hn50ev0Vx4zRPweWVn4WlYdAzW+rIfGeH9d5V3o0uB/Oi8aHLE/qFkpgR6rdp1aTpT86Y6mD5GBQKTpwXcUzunU= 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 175974508546661.94737956241033; Mon, 6 Oct 2025 03:04:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5i0y-00025h-1u; Mon, 06 Oct 2025 06:00:21 -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 1v5i0R-0001Wk-0i for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:48 -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 1v5i0O-00041A-Md for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:46 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 9237B60B93 for ; Mon, 6 Oct 2025 11:59:42 +0200 (CEST) Received: (qmail 21008 invoked by uid 990); 6 Oct 2025 09:59:42 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:59:42 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PATCH v7 23/25] tests: add plugin asserting correctness of discon event's to_pc Date: Mon, 6 Oct 2025 11:59:18 +0200 Message-ID: <44a29c55c2ed358a216e542fc90724ca0f8e5c40.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) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.99992) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.09992 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=M66cb9o00ka1yDebj+//xx3Us6bJo1VzJeW7Zn7c/As=; b=eaBYqXlNvDotqG7YoQbMvsubKn0ZQmoMAv5ztZ5tiWDW0CMO+0wHL7vEIOE7JVT4FQJuh8C75V DwcD4bH6zc+fA+bzDSDWdHQNpvCbIJ/DRULkfvxGpesHdJNB2g09yK2xr+aOcNWhGkLfTrMpno9c EWBQBPqOsxRzD+PFa2c+Vowi8hdj8gzj4QB299uzahY2Tfs3YjXkAvTfOOP0TCPLmguwMlfPCIl8 yO4HFD9iU31NgVwl9MeB31Yh++Jr7vHDZMf3gmCO/X440vc4Ngl3CyVGgJ7+kHUtz+Y+kGorQ2vQ l8W8e2PELInBlKJ7a69iqpm5+f71wdMhPIhiy5rvzS/5P/S3iKAEmtBzzsK8+AQXvorGFuHR4GfA OSE6IjlTsMQqtcy89thqVL7GjPwRQtHkz9cM+EuEIrHiFrgR84/iBySTRa2JW56L0I6VpnSja4Ng F2SgOMadPNSffgPHnEzhtiUSgSKIvEc2BK6rdD4wbrp9rcHTa52GXV2CsDvh0QxJchllZScf0f8D E5TwyM1A0r0UFebWTDJxmnBN4vE9azOV7EjmEmCeUBKlL8N2F5Ic2mYBI9ECyFD1VFDPsEmYMqi5 98e/dDyh3FivGIdYSuAJkiDOhfFgmUYn8Ub/GT3Z2mO1ze9Ta+6fR3ucPRebb3fKoygk03dsSZcA 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=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=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: 1759745092176116600 Content-Type: text/plain; charset="utf-8" We recently introduced plugin API for the registration of callbacks for discontinuity events, specifically for interrupts, exceptions and host call events. The callback receives various bits of information, including the VCPU index and PCs. This change introduces a test plugin asserting the correctness of that behaviour in cases where this is possible with reasonable effort. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz --- tests/tcg/plugins/discons.c | 221 ++++++++++++++++++++++++++++++++++ tests/tcg/plugins/meson.build | 2 +- 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/plugins/discons.c diff --git a/tests/tcg/plugins/discons.c b/tests/tcg/plugins/discons.c new file mode 100644 index 0000000000..2e0e664e82 --- /dev/null +++ b/tests/tcg/plugins/discons.c @@ -0,0 +1,221 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2025, Julian Ganz + * + * This plugin exercises the discontinuity plugin API and asserts some + * of its behaviour regarding reported program counters. + */ +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +struct cpu_state { + uint64_t last_pc; + uint64_t from_pc; + uint64_t next_pc; + uint64_t has_from; + bool has_next; + enum qemu_plugin_discon_type next_type; +}; + +struct insn_data { + uint64_t addr; + uint64_t next_pc; + bool next_valid; +}; + +static struct qemu_plugin_scoreboard *states; + +static qemu_plugin_u64 last_pc; +static qemu_plugin_u64 from_pc; +static qemu_plugin_u64 has_from; + +static bool abort_on_mismatch; +static bool trace_all_insns; + +static bool addr_eq(uint64_t a, uint64_t b) +{ + if (a =3D=3D b) { + return true; + } + + uint64_t a_hw; + uint64_t b_hw; + if (!qemu_plugin_translate_vaddr(a, &a_hw) || + !qemu_plugin_translate_vaddr(b, &b_hw)) + { + return false; + } + + return a_hw =3D=3D b_hw; +} + +static void report_mismatch(const char *pc_name, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t la= st, + uint64_t expected, uint64_t encountered) +{ + gchar *report; + const char *discon_type_name =3D "unknown"; + + if (addr_eq(expected, encountered)) { + return; + } + + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + discon_type_name =3D "interrupt"; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + discon_type_name =3D "exception"; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + discon_type_name =3D "hostcall"; + break; + default: + break; + } + + report =3D g_strdup_printf("Discon %s PC mismatch on VCPU %d\n" + "Expected: %"PRIx64"\nEncountered: %" + PRIx64"\nExecuted Last: %"PRIx64 + "\nEvent type: %s\n", + pc_name, vcpu_index, expected, encountered, l= ast, + discon_type_name); + if (abort_on_mismatch) { + /* + * The qemu log infrastructure may lose messages when aborting. Us= ing + * fputs directly ensures the final report is visible to developer= s. + */ + fputs(report, stderr); + g_abort(); + } else { + qemu_plugin_outs(report); + } + g_free(report); +} + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (type =3D=3D QEMU_PLUGIN_DISCON_EXCEPTION && + addr_eq(state->last_pc, from_pc)) + { + /* + * For some types of exceptions, insn_exec will be called for the + * instruction that caused the exception. This is valid behaviour = and + * does not need to be reported. + */ + } else if (state->has_next) { + /* + * We may encounter discontinuity chains without any instructions + * being executed in between. + */ + report_mismatch("source", vcpu_index, type, state->last_pc, + state->next_pc, from_pc); + } else if (state->has_from) { + report_mismatch("source", vcpu_index, type, state->last_pc, + state->from_pc, from_pc); + } + + state->has_from =3D false; + + state->next_pc =3D to_pc; + state->next_type =3D type; + state->has_next =3D true; +} + +static void insn_exec(unsigned int vcpu_index, void *userdata) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (state->has_next) { + report_mismatch("target", vcpu_index, state->next_type, state->las= t_pc, + state->next_pc, state->last_pc); + state->has_next =3D false; + } + + if (trace_all_insns) { + g_autoptr(GString) report =3D g_string_new(NULL); + g_string_append_printf(report, "Exec insn at %"PRIx64" on VCPU %d\= n", + state->last_pc, vcpu_index); + qemu_plugin_outs(report->str); + } +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + for (size_t i =3D 0; i < n_insns; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + uint64_t pc =3D qemu_plugin_insn_vaddr(insn); + uint64_t next_pc =3D pc + qemu_plugin_insn_size(insn); + uint64_t has_next =3D (i + 1) < n_insns; + + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + last_pc, pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + from_pc, next_= pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + has_from, has_= next); + qemu_plugin_register_vcpu_insn_exec_cb(insn, insn_exec, + QEMU_PLUGIN_CB_NO_REGS, NUL= L); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + if (!info->system_emulation) { + qemu_plugin_outs("Testing of the disontinuity plugin API is only" + " possible in system emulation mode."); + return 0; + } + + /* Set defaults */ + abort_on_mismatch =3D true; + trace_all_insns =3D false; + + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "abort") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &abort_on_mismatch)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else if (g_strcmp0(tokens[0], "trace-all") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &trace_all_insns)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + states =3D qemu_plugin_scoreboard_new(sizeof(struct cpu_state)); + last_pc =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_st= ate, + last_pc); + from_pc =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_st= ate, + from_pc); + has_from =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_s= tate, + has_from); + + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, + vcpu_discon); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + + return 0; +} diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build index 61a007d9e7..561584159e 100644 --- a/tests/tcg/plugins/meson.build +++ b/tests/tcg/plugins/meson.build @@ -1,6 +1,6 @@ t =3D [] if get_option('plugins') - foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall',= 'patch'] + foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset',= 'syscall', 'patch'] if host_os =3D=3D 'windows' t +=3D shared_module(i, files(i + '.c') + '../../../contrib/plugins/= win32_linker.c', include_directories: '../../../include/qemu', --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744965; cv=none; d=zohomail.com; s=zohoarc; b=nMpAtV25aRdSmzkmJKqw5MiAOb3cmRkFtI4jW+Ybtr6Wd/HyzeMpksk/VHGdBM2WIHltvQxT5cxyf63HvCQMTIT6DWwvWBe9nUXmzbX9Xisg5ncF4BhCv/kdCfUjjzXwSbQEPy17Bb4acoqffvqCZcpzaI7I+x/HVbTgEwwgDOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744965; 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=AuQzKW7sRGaQfOTWCBASb8ZSeL+eRsL2UHL6SSjDFFk=; b=b3bbmVTs8m0eAZhdQatWlIrFiZlGh3/BQeaCEjFcfr/qRH+qBbYosuH64a05lG9yy07HoMRq61+QABGp6W63iWX+/NmX1Nw0zRRuyH+R6WmvbOKbIm/f2BYSpLm4//iEutvZpKrgfifj4GqsFMjFxdHpngxSCqIQfT5pAvP8ZuE= 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 17597449648970.932168265753603; Mon, 6 Oct 2025 03:02:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5i1C-0002IC-5s; Mon, 06 Oct 2025 06:00:39 -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 1v5i0V-0001aS-4s for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:51 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5i0P-00041C-3e for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:50 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id E3B4960BA5 for ; Mon, 6 Oct 2025 11:59:42 +0200 (CEST) Received: (qmail 21026 invoked by uid 990); 6 Oct 2025 09:59:42 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:59:42 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Daniel Henrique Barboza , Palmer Dabbelt , Alistair Francis , Weiwei Li , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v7 24/25] tests: add test for double-traps on rv64 Date: Mon, 6 Oct 2025 11:59:19 +0200 Message-ID: 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.976777) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.576777 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=hJeTNN+EDtHALUaN38ske2iZTHRjFTg++mevsB5iNj8=; b=A3JSSqzyzkkR/6vP0PPq2c+7dFFNJf8N5e7AjCARoeFtRen5aUsf0js1SBk2nr70N/5HwJCqSn EAf+f4FQFH7rhMIucSBOzpnrSKU//xc8Autzj7JJQrWaP+tPolFpespp6lj6PT/rijGha+HdQpUk vYk5pacsGmdxt2+zeOAl0uyjhP7YvhZZlJJWBEv3OiLK6MU6v63mfaCiNYkE+UZvelJIkpDjkIgS Js6U0lwUXBQlbM0urGI7Ek6J/SZbNNocZv4t6eojcLrcDjTjXnaznoh//PJfv7VXkupaqJIqKBYP QgJQa1tXW6C/7s+hf8O3kq/h/VrmBa9UwBVABoYN+r5JZqoEQw0CIXTxU63SnLepDaRalJWlOFZx DbofmbYNHO+fVujPb9sipIYydB2KZot7jaFSmC9+l3uuN/4tUgNXiiWxpekgiq2cRSOnJ4+be4UM IwWMARsdZ3MFcG+p8J5p8XAPYZKikO+n5WjFPRpmVA61XmvwVon77z6285oMkxCghnXjLQlRCwcz i6WNWQrj1Wj4FfRN775YJgYNXPtF13vbL82qZQg7IUIbE8FwGNiFPyhdv3MtlrQg6cF/YM7dae4g F/ItMacEMF9NSJiIlxkI0S4JkWAOqrnX/AHWW55sBjot/bZ+uX25iuRVoT/AhT93oL6Fex+enyDG w= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: 1759744973248116600 Content-Type: text/plain; charset="utf-8" We do have a number of test-case for various architectures exercising their interrupt/exception logic. However, for the recently introduced trap API we also want to exercise the logic for double traps on at least one architecture. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Julian Ganz Reviewed-by: Alistair Francis --- tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ tests/tcg/riscv64/doubletrap.S | 73 +++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/tcg/riscv64/doubletrap.S diff --git a/tests/tcg/riscv64/Makefile.softmmu-target b/tests/tcg/riscv64/= Makefile.softmmu-target index 3ca595335d..1a71a78653 100644 --- a/tests/tcg/riscv64/Makefile.softmmu-target +++ b/tests/tcg/riscv64/Makefile.softmmu-target @@ -24,5 +24,11 @@ EXTRA_RUNS +=3D run-test-mepc-masking run-test-mepc-masking: test-mepc-masking $(call run-test, $<, $(QEMU) $(QEMU_OPTS)$<) =20 +EXTRA_RUNS +=3D run-plugin-doubletrap +run-plugin-doubletrap: doubletrap + $(call run-test, $<, \ + $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ + $(QEMU_OPTS)$<) + # We don't currently support the multiarch system tests undefine MULTIARCH_TESTS diff --git a/tests/tcg/riscv64/doubletrap.S b/tests/tcg/riscv64/doubletrap.S new file mode 100644 index 0000000000..b61089c9c1 --- /dev/null +++ b/tests/tcg/riscv64/doubletrap.S @@ -0,0 +1,73 @@ + .option norvc + + .text + .global _start +_start: + # Set up vectored interrupts + lla t0, trap + add t0, t0, 1 + csrw mtvec, t0 + + # Enable sw interrupts + csrrsi zero, mie, 0x8 + csrrsi zero, mstatus, 0x8 + + # Engage the double trap: we trigger an machine-level software + # interrupt, which will trap to an illegal instruction + lui t1, 0x02000 + li t0, 1 + sw t0, 0(t1) + + # If we still not went out via the software interrupt route after a + # short while, we failed the test. + lui t0, 0x1 +0: + addi t0, t0, -1 + bnez t0, 0b + j fail + +trap: + j illegal_insn # Exceptions + j fail # Supervisor software interrupt + j fail + .insn i CUSTOM_0, 0, x0, x0, 0 # Machine software interrupt + j fail + j fail # Supervisor timer interrupt + j fail + j fail # Machine timer interrupt + j fail + j fail # Supervisor external interrupt + j fail + j fail # Machine external interrupt + j fail + j fail # Counter overflow interrupt + j fail + j fail + +illegal_insn: + # Check whether we really got an illegal instruction + csrr t0, mcause + li t1, 2 + bne t0, t1, fail + li a0, 0 + j _exit +fail: + li a0, 1 +_exit: + lla a1, semiargs + li t0, 0x20026 # ADP_Stopped_ApplicationExit + sd t0, 0(a1) + sd a0, 8(a1) + li a0, 0x20 # TARGET_SYS_EXIT_EXTENDED + + # Semihosting call sequence + .balign 16 + slli zero, zero, 0x1f + ebreak + srai zero, zero, 0x7 + j . + + .data + .balign 16 +semiargs: + .space 16 --=20 2.49.1 From nobody Fri Nov 14 22:12:42 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=1759744967; cv=none; d=zohomail.com; s=zohoarc; b=FqCqpsk9TXNHWt4vq6hL6Qj6TAb/PJ1K5TM3TF2MHDMlU9I38Q39kM4S3HG3WBRIGmyrAPvD96YZ3luCiWC6rvd30KRkkN7ZbCOCJplXmi2lzIzw/IAex1Au2DyzO9uU+6zIweiUUqIcC3RIGem0X8ZP2jmx1li4l/CyCWwgiTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759744967; 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=VQcknKM9Chi1JQ32rH/hZn3XNsgb4ohhFGV+75s3oYI=; b=BIfuZZWZJE9zeMFL677F9tFAjtIPJyq+1kjknTq0nmloIHetSvDM3ZFKxRQoQcHBJFNNs7VCi6YISAqi9NMyJK4HHdw5QdXSjxOg7ZLu4AUlHvRrlBRqomaWJ4DxyQVn7CJ10sOjyTL3ccDXMpg2HP6Gjp+5T6YrcLyV6N9cKJk= 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 1759744967642726.9071783446076; Mon, 6 Oct 2025 03:02:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v5i1M-0002XE-Oh; Mon, 06 Oct 2025 06:00:44 -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 1v5i0S-0001Y1-8k for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:49 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v5i0Q-00041U-Gz for qemu-devel@nongnu.org; Mon, 06 Oct 2025 05:59:48 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 4A9CD60B91 for ; Mon, 6 Oct 2025 11:59:45 +0200 (CEST) Received: (qmail 21069 invoked by uid 990); 6 Oct 2025 09:59:45 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 06 Oct 2025 11:59:45 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Daniel Henrique Barboza , Palmer Dabbelt , Alistair Francis , Weiwei Li , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v7 25/25] tests: add test with interrupted memory accesses on rv64 Date: Mon, 6 Oct 2025 11:59:20 +0200 Message-ID: <729c8db0f4b61033f5a460747ea50fced9dabc1e.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.214157) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.814157 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=mVLyiyy1HWjSWhu1/Q5w+icoVuven8S3d7VhRcdbntg=; b=ns2lwxA4B0p8ltBmZnDMEHNw0Bq5Ga6Y1QM+vbpm/5XynLaOFk2vRdl0z3AgZ0Stw+7b+/F/XH M68z3dtDsNwwfxZQ0Z6Mp1UzWu2eygtlTiPkCrIq9YHO2vtMdiv9HaVRd/hGJuoH9shb9xDPRE0g 0nEUonUD4B3KaRyVeZWIlI60J208FwcZalZHqWxcO0vDKX2mm4TgPS4s2kRTD6XgabwuXNM8BDld hGhjp11tFyBks+F9BHHoKGownnqcPohMYxbp85Vx9OnIdEcKyw8VsP5EIeJQvWOPQGbMxXLU48Ma /zNwBH5ytJE/8FsWNZCWo+MKrDE7i/1LEpr1W7YgP+fUI2wMN9TurOgK/UyIBDSLJ3tc7BlczeNp r6d4zcGt6AVve4FwvqmmbdaoPrt7BkkxvHXnqiz0bhtQxxJ7lPoHbMGZDsjrIIeCoW2GYy9KJO2m Vpj0reCAd4zAizhzLlny7qo5eNNnDsri8J8ZZZ8FxstKy3NFHygsesJEfobv9+biXzDzoWbHjfjh iqInSOPHfDv8khneqkrRZFEMnc+5cSdtdHuSPDCtVt2QNN47Iso5GQaIhUnmzaQGwJ+WQFJXIJXn Nt94ahfTZndbW6MbGi4YKsDEPKqPOuELNFf+Q2rcx/XwgpPYiRyJgwJzdhoTInMwibneeEDBY9mg w= 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=95.143.172.20; 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1759744973272116600 Content-Type: text/plain; charset="utf-8" This test aims at catching API misbehaviour w.r.t. the interaction between interrupts and memory accesses, such as the bug fixed in 27f347e6a1d269c533633c812321cabb249eada8 Because the condition for triggering misbehaviour may not be deterministic and the cross-section between memory accesses and interrupt handlers may be small, we have to place our trust in large numbers. Instead of guessing/trying an arbitrary, fixed loop-bound, we decided to loop for a fixed amount of real-time. This avoids the test running into a time-out on slower machines while enabling a high number of possible interactions on faster machines. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Julian Ganz --- tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ tests/tcg/riscv64/interruptedmemory.S | 67 +++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/tcg/riscv64/interruptedmemory.S diff --git a/tests/tcg/riscv64/Makefile.softmmu-target b/tests/tcg/riscv64/= Makefile.softmmu-target index 1a71a78653..d8f92b8e61 100644 --- a/tests/tcg/riscv64/Makefile.softmmu-target +++ b/tests/tcg/riscv64/Makefile.softmmu-target @@ -30,5 +30,11 @@ run-plugin-doubletrap: doubletrap $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ $(QEMU_OPTS)$<) =20 +EXTRA_RUNS +=3D run-plugin-interruptedmemory +run-plugin-interruptedmemory: interruptedmemory + $(call run-test, $<, \ + $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ + $(QEMU_OPTS)$<) + # We don't currently support the multiarch system tests undefine MULTIARCH_TESTS diff --git a/tests/tcg/riscv64/interruptedmemory.S b/tests/tcg/riscv64/inte= rruptedmemory.S new file mode 100644 index 0000000000..a32d672849 --- /dev/null +++ b/tests/tcg/riscv64/interruptedmemory.S @@ -0,0 +1,67 @@ + .option norvc + + .text + .global _start +_start: + # Set up trap vector + lla t0, trap + csrw mtvec, t0 + + # Set up timer + lui t1, 0x02004 + sd zero, 0(t1) # MTIMECMP0 + + # Enable timer interrupts + li t0, 0x80 + csrrs zero, mie, t0 + csrrsi zero, mstatus, 0x8 + + # Find out when to stop + call rtc_get + li t0, 60 + slli t0, t0, 30 # Approx. 10e9 ns + add t0, t0, a0 + + # Loop with memory accesses + la t1, semiargs +0: + ld t2, 0(t1) + sd t2, 0(t1) + call rtc_get + bltu a0, t0, 0b + + li a0, 0 + lla a1, semiargs + li t0, 0x20026 # ADP_Stopped_ApplicationExit + sd t0, 0(a1) + sd a0, 8(a1) + li a0, 0x20 # TARGET_SYS_EXIT_EXTENDED + + # Semihosting call sequence + .balign 16 + slli zero, zero, 0x1f + ebreak + srai zero, zero, 0x7 + j . + +rtc_get: + # Get current time from the goldfish RTC + lui t3, 0x0101 + lw a0, 0(t3) + lw t3, 4(t3) + slli t3, t3, 32 + add a0, a0, t3 + ret + +trap: + lui t5, 0x0200c + ld t6, -0x8(t5) # MTIME + addi t6, t6, 100 + lui t5, 0x02004 + sd t6, 0(t5) # MTIMECMP + mret + + .data + .balign 16 +semiargs: + .space 16 --=20 2.49.1