From nobody Sat Sep 6 14:53:25 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=1757018956; cv=none; d=zohomail.com; s=zohoarc; b=GY4Lwv0GBNFrKRO7LxC7wJ+Dm+kwoDhZ47iYd4zT4JQo2Xu8YYCEFP4fTHKPwXJBhEAVnQz6Xz0pmVJY29Osqt07xOxmL39H7pPzLJ6EsoFQWwozwIkmTAen3Bc8xNmsf3H/1pL1XGaQ4HWi0VuCaUrn4zt1iLkTdqiI6Ep1lX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018956; 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=JcdTF7yH/JYLx+CFJsooYKzUrQSOdWeuc4b6e61YWpV13CsNam71bGDfLMCJMpwHmh2IRUc8HBBq+5+57azu+Mf5fY6ADh20p0wHzu73cxt0rR8BFWI5NnZEl16wbFhi2vpMGg5pj4SZc0MbWt/Ei22bGDnuRXe3o+SeISq1UZA= 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 1757018956490145.75476814783485; Thu, 4 Sep 2025 13:49:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGrs-0003Qi-7u; Thu, 04 Sep 2025 16:47:40 -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 1uuGro-0003P7-Gk for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:36 -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 1uuGrj-0000gn-NG for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:36 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7E68260BD3 for ; Thu, 4 Sep 2025 22:47:19 +0200 (CEST) Received: (qmail 32511 invoked by uid 990); 4 Sep 2025 20:47:19 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:19 +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 v6 01/25] plugins: add types for callbacks related to certain discontinuities Date: Thu, 4 Sep 2025 22:46:38 +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(-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=MpNUQaQaQz8UwFmd0lkIYzP9G5LVqqYbTSI8IGl64Fyoarxb3esct1zfkLGqZ8yOx8dvyFTUis IqneFO6MS/ivgblgkd6ogwWgOWC6eR//8cJEcm20hQ3bJHkeCHnlsDCNjx9GaH6CQMvPuy1z6SB+ oReq+e+pFGjHOvfiPi3icU4kF9Heiqw9/W1Mg/ZcwQ/u/BrBTr0V8k5f4TesBg/YoDKdg28NWDft vlAE0AGC47bGG5s3OmEsPTx8PUjBmgb1f/VCUMWt3AiEqwYLOQ9r5AbmHuvBCEyyyLO4fePq1nOT XUQUAAa506Kl/G1v/ZIdIkcclhBy45bC1N2s0QiPTjELrimzSfIaIqXpk/l0Oq4yul1h2McqAEx1 G5CRYaQwewsId0bGHYXRCNM/rY3mOarn1IrYG9VNQT6cQHh5AIqsBnpMcFzccdveqwbXfEPens0L Uj56tMAE0Uw838/TN54zwvGdBXiwmnAYMCffh/5XHhb+9h4jPMzT/GC94cryOLNu6POh58bEXUPv AjAJtQLcilsqgTUSKpK5v9c24OBHKpfXU+3uBoJiBiTN0QiTOnELrc4S8o0LSqMZXRmWA5LOv41g auoiH3D4PU8kNfYQZqd1UfzizXLIjNTXRcrMofkIp8M4N9Kz//Xs65YhzOB9eEZfMSgUc5ZwofEi 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=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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757018960897124100 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 --- 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 Sat Sep 6 14:53:25 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=1757018957; cv=none; d=zohomail.com; s=zohoarc; b=Du3RN+2uHtQZaUTwvRh66gAma6G4wKb8BAE2ylao4uEEkdAlf5tpY+Ye4ogDVNPoL3qshogmLy4FKX6AhIp7gdU9TEIjW4icFgzT+tGUmIY9/lmIjfR7OztLJtyVYrjDuYiG+BdzREtiFxGpfQyxH9vni6jIiIPvndh3piC887U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018957; 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=Z8JYaFyivPsHmLVTlcVcs+ofvJjinVopcQ0L7f+L7zg=; b=TSGgi80v0m9F/d/8VZEItlDX4FT0oC2UdoxtDFCiFAtwQoYTtz5jrevleWpFipElFP1cRMKdW8frWAXfxa3iBd+cYpJ8bMy7vG/DQJp/EearWEJRVOrAb2nKOYhzCOr7mEStZXVex2O5Oad78NQpLQDeyQ5hNzEpiR8lBvZq8Tg= 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 1757018957524540.5237741698772; Thu, 4 Sep 2025 13:49:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGrq-0003PW-Lw; Thu, 04 Sep 2025 16:47:38 -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 1uuGrn-0003On-9s for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:35 -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 1uuGrl-0000gd-4J for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:35 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id D098360BE5 for ; Thu, 4 Sep 2025 22:47:19 +0200 (CEST) Received: (qmail 32526 invoked by uid 990); 4 Sep 2025 20:47:19 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:19 +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 v6 02/25] plugins: add API for registering discontinuity callbacks Date: Thu, 4 Sep 2025 22:46:39 +0200 Message-ID: <4fb5ba949641dc4fc025755228a3587c3f751371.1757018626.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=A9aDKld+N+74OgdmO6BKuLjq9QJz4X1vpKo7S+gvQWc=; b=eN2y+xuqF/N/ZpfQdSeQC/H1R7asayLwC9VxC3RbGVwaZRgrN5slm/Hy8UFeWHEZldMJiMJvFk 3obmN6nfOVFAaVw21yy1UgHwlbWTKAfWGiWnt1D04UCJkaYwEGmwMlADqAeIlax+ITYu9CNIzJyB MKE+b9pK4hhJXnn2k3IHax3QIbZ12zjiiFzR63WAWJ66Ea/QpEfK9FDyTqhXjkRE4nvSs8x/wudJ gT2IOkM3oAfQe3lEQ/AzT2g+YAb0rrkBtqXKC7/dTJI98D5nZr6RLr562mZudcdv9LUjYUdxMZmr MaRwpDkesnHLGGql+2N+cG4WA27YcURl5SpTEMr3HDO78lLFp/qbmyJYr6x7+DMLTvTStLeCQAUa KGkOTXTQeXk9IcrcYeLDlDC/HtfmvpPBHcDMx97wNIBULN4iSXgUQdRQNO4atU6ovlQrQKxPi2+D +Q0vlHJaALpy+vj2k2z0XuqHLbdrUCPXW45iqnr0yCU7ERU47U6WMqoo8jhI3p7NbyqrRNFrGSB3 +AEu2xUzrveuXJikM3vQ7y2SRWqbbcfk0SnPgv8L5yx9sS/De48k47ZiLp4FYigLNGwWL05VLsB0 Wy/BU76mu3Rl+VtGEv81mgX3YyFvXlY2XZtvSj5vQZnWPlD3fAB6rF67a+VLd6MZqUfaECxBmkFn 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757018960573116600 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 --- 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 c6e9ef1478..a04cb2392d 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 Sat Sep 6 14:53:25 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=1757019010; cv=none; d=zohomail.com; s=zohoarc; b=QpbOKYAIxvB3l8bmVrw+qwHyahIwTNdbAoT8TM+gcLxsaJUM49Pln9L5P7JqTjLBbgAqJV20SRwwANw/MTVSm2Oo/y+0iu6beRehm5z1kMtmSBtCIeJRXN3M17bzI4C1t6dJUVkfm6JkCnD3v8eFx2bWPcBNpPSyGdYGKFWBsy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019010; 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=V5I4m2dF3y86ENPEKx+rC/ks2H21vVeeQsPMTjAoV08=; b=SL3Z8nyO8Ac0iiNzYmKXfAxB7coWerNTXP6cKLIPoedaxf/IxIhxLwTmA+w/hKbK1IICW64rpqnH1mquueCNL5lIlrFliMMajYd62MW1l9t/xFmQ/2BJk8lRVcAYicBYBh5YWsiIYVG0v+Wvyn7uZJia3eS6aTXid/XAKgCvD5M= 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 1757019010220152.6804751159541; Thu, 4 Sep 2025 13:50:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGrr-0003QD-HN; Thu, 04 Sep 2025 16:47: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 1uuGrn-0003Ow-NZ for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:35 -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 1uuGrj-0000gh-57 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:35 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 2ECF560BFE for ; Thu, 4 Sep 2025 22:47:20 +0200 (CEST) Received: (qmail 32546 invoked by uid 990); 4 Sep 2025 20:47:20 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:19 +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 v6 03/25] plugins: add hooks for new discontinuity related callbacks Date: Thu, 4 Sep 2025 22:46:40 +0200 Message-ID: <03eab59217365665b60ac169723ab689d2a97be4.1757018626.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=QGe1FS2XIyc0299hmaYlTYKuPdF+LQBEF6sscTzNBNA=; b=jdQwTJr5jMOWIG7sc+ZEZXWIJTMaLAs3/w6luwzxkTdKUXDg8HlMrcEOvsZ5LCmYTubLPvmQme 9C0u+eOU9oAXW9ZTMj5YgfVBb9S6FPHZZ84gzGSxCdJUCLyoAV7HaRhnIHcGSk+tFnx+fc+gr2e7 q1OwJd9VWTPTxSCaP5X9QI0lFscxMchV6XnCErd95yRTJXYI6AANkzeKllajOJc/glA2H3w8sXDF q9fZLosLKYt8ibPxSHQo7Eo/3RPsYVyFIRhGvda+m4EmxWdj8l1dH9A1/tkgaV7YZ7KFc1ejXulI swzK52QB+fxH7Vdi/MDJJBTrXZEW+gtPRCihgHpWQ93rHYDON1qSl4YaL4gNI4iSNgQOzOFaW6aZ ICZFg3uraygTxHZ2WqHP7olIn1h5GP9jO7U2tPSBqXMm9U37CaJTcM/f8kBh1IwaX3ytcjq/Z8v6 SEnjukOSJ9ql2shwvZYCMXXLzD0J7y7bSPfTvLvtTW2ySYfQTQsH89NyJBIye1xOPZGQhNVL0WzY QgSh3UJtIp4zFLx+z3KQo1Qcq04cQLBSUtNJwvVj/mH0OG2tfie6zZKng9twSMdWoRlbptW0mjOj Vj2m+cY35QTE+RKg/G2q/y+h+oqdfePanO4Na/t3WgYhDMqKNH/tJedwtCg4SDQ1KpimVtKj2/8t 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: 1757019013154116600 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 a04cb2392d..1f0ddebcbf 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 Sat Sep 6 14:53:25 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=1757019145; cv=none; d=zohomail.com; s=zohoarc; b=MjRKvxeAAj4s24Qzgl3Nav2EgEJeJd3sgXzouc63vPvJUdlPI83KVC/XfgFldkEDiaGpIDQBE8eCakSb7xly0jlT3EIihFHoGTcGN1ltb7hl+1+S+cLUlSKF2aK1xTtxJAwYRG+oZGV9XjpWQI0QrmXn9/jgd3AFCfgyyXIX+Eo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019145; 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=lkt7tydq++/IQ1dsBsOs4pEm4yWjPTTj9uBftmMWCxo=; b=kj2JdXc/MbHuRdpGTLIxMlpRmlraGOPcPtbXRj5XZIfV3XqkXtD7442G4aT+xBeHj89JB/BASfgqibLcrpeM1b5IRAkRkpxjvnzWQfOvdIFIa5EAlb1o1kliZnkI6O8VjFUTevdJ6WSkM9L3cJhr2ZQp1zchVaeoaGlanyVtOHY= 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 175701914587612.851344945223104; Thu, 4 Sep 2025 13:52:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGrw-0003RW-C4; Thu, 04 Sep 2025 16:47: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 1uuGrr-0003Q8-7M for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:39 -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 1uuGrj-0000gm-Nr for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:38 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 80CFC60C0C for ; Thu, 4 Sep 2025 22:47:20 +0200 (CEST) Received: (qmail 32561 invoked by uid 990); 4 Sep 2025 20:47:20 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:20 +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 v6 04/25] contrib/plugins: add plugin showcasing new dicontinuity related API Date: Thu, 4 Sep 2025 22:46:41 +0200 Message-ID: <084ccb18733dbacb68a8a107ff10ae0f96045772.1757018626.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=wqGaQOoNh2xzOYJ7EncGsJB5XEOWy/xryA/rfjKxSzE=; b=n7tzaE22TpUI10G5A806ttehBh+s4pHPDQT947hiMGksLHaJVcHwK7MI3/gZm2VgDQ4kXVdrxs HnRSjAzAluG1tncDO+Y1p8LMfmsEWck3+NRTod7R8Pt9rP+4A0x+RPnCRWCn+2dFWOU/wuKZ62HI D6oih0Jh8rYTgn1m4BRjMCErMYkJt7gYarCYFq9jXYS57PlUoGmA4YCbEOE+kJxZH114Ku1+FJpa v1F4Fn/5y8GUrT94St6tl7/3H9/q8WHwqgiuDlqxfpbOP9b1bMexJtHf/9+XzunCg7xm0jaSl/Y3 cefSb4LJvSUpDX7E5VFPiVHa6u5vCGu07nkJAdCSJeahuG5Ps/SklVVupGtHyPthY27l3Pq1JvfY 4DnB771779ugB8Bv+KCCFMcJM04wrkPOvvBBxJZJrsV2AU5z5iilk59uWmg80Jpk5BzkCpgQf4ud SkTLboWeahzpRHn2kyoVoWfmiFDdvrH3JM6FaDAPTcYDRmYLM/Y20gNH8bgAgZSlBlBJ1GMBVTWu 3vdRL1V+IS6ofrdKSmZ4uFZQi4CzpYJ5WeCUMMV8jWb8rLB8664kB6AyigmERH1G5qJSbCKChTof 96N9gPrslitWoC6z7dWZOr7ZNAYqJjK9bNmkLZl8PSdnDVKVzYL6pT9uiTsms/Vi9qnvTJfTofGC 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: -7 X-Spam_score: -0.8 X-Spam_bar: / X-Spam_report: (-0.8 / 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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: 1757019148211124100 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 --- contrib/plugins/meson.build | 3 +- contrib/plugins/traps.c | 84 +++++++++++++++++++++++++++++++++++++ docs/about/emulation.rst | 8 ++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/traps.c diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index 1876bc7843..85d3520f0c 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,5 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', - 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger'] + 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', + 'traps'] 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..c8672d8b1b --- /dev/null +++ b/contrib/plugins/traps.c @@ -0,0 +1,84 @@ +/* + * 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) { + fputs("trap plugin can only be used in system emulation mode.\n", + stderr); + return -1; + } + + 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 456d01d5b0..fb99563c04 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -816,6 +816,14 @@ This plugin can limit the number of Instructions Per S= econd that are executed:: The lower the number the more accurate time will be, but the less ef= ficient the plugin. Defaults to ips/10 =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 Sat Sep 6 14:53:25 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=1757019192; cv=none; d=zohomail.com; s=zohoarc; b=nsxTZQzA8ZVDaqwms+5Ck0MQK+x+SYR4HxcH6XdVaNcvwOsYncSckQTCewq32aFSJZhMZhAGdzVwOLZCevpqKwgEn4Tm8dmcV0iAsEHemAWfGwJFVv62UIb+wUpXEdFe9DhPush2tvmqvwH3K+XkRxxMvJ5Y68Rhd2V07qUOZ1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019192; 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=dJA/G82gtUfmN9vT6TIZFRK0FR+bIyCD2TF6M26YbJqEvuoMbjtBgzaHmtVT4DNo0LJnKAk+9H+yWvaMR+++Aq2V5bcC/fbCYUluPh2lrsMrEbUnbC2nOcvf/lrcaZpSNFKICvF5Qqo1/6b+qAbDBGbrpzwAG2cw7jvY+0XOq0Q= 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 17570191922711005.9434330537019; Thu, 4 Sep 2025 13:53:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGry-0003T5-Jt; Thu, 04 Sep 2025 16:47:46 -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 1uuGrv-0003Rg-JT for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:43 -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 1uuGrr-0000iS-P1 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:43 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C214160BFC for ; Thu, 4 Sep 2025 22:47:20 +0200 (CEST) Received: (qmail 32578 invoked by uid 990); 4 Sep 2025 20:47:20 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:20 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson Subject: [PATCH v6 05/25] target/alpha: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:42 +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.997587) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597587 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=wG0b7mo26FlJpnGblmTXt3v1+9IeMzN6KgMeBONME1fuzYCV5vNGVmowG/4Ae625Pep4afThtm 2ipIGiweGr4ah7VJZUxQtCBBolm5rj370DAy9dbsnP2HhlMWGkxedNJEV9BR2EXx7Ac+2mJkArWi tBF9bABwDWirp2Ys1W7zrGAt8FcHFEdbYR8hjlpZj4tnCq9na+kFZ4V4ThyOgKcjOk21XS7VP7yY 8OaEOl3ldivfUwXBjBOpIGdfZbvOmCylKToC5bfGe91hh6Z3UPLx8fmE5bsFmA1rdzDttyejJ5Fw lHNYoFsSeLrjurSYkSQUSQoYR4cLhrN2o0Qr6k611XhmRc5/e91QvvlxkN2E2QXFS6DH9pfw+uQf TplenyKZ0JKqHblgzCrfcwd0VjycxhXT0yIHa48Df/JbVB/bGdeKOBp6kfRWWYysR8rMVCXO8E7u KYPwUFUCd90BsHzTu8SJ3P1Cuk0xtSl0WyssVhWgxFzXetAjpVaBvbjt9QQOPJ+QGJSBrT5aMCpK 82GmGA5kcqZk1JzQdJiJs2fXzAWxXH8hRPFp0dWU8I92xiRmKtYuGfrqzFgE3Sb1o7E/9X0WShyM MiCmkG0bAHlTGsGbbJx3Y6K1ITgZPs0GIIZXkdhcXFP2dPFxUvh3sccexWGZwp7q6d2vUWDJ/xyn 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=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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019194717124100 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 Sat Sep 6 14:53:25 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=1757019100; cv=none; d=zohomail.com; s=zohoarc; b=dXFxKuGoJxZMzeupwqWs0hcmd/gIVHWpOXLUmp/L7KlpSoWgLdhdnMJZ1az54XflUOSA1mkoF256wqgQGjYn9abjWbM9K3rbowev8kVibZyaIcsxjwOasdm07mlqmJG7DNadzJbNvUv/jb1mcsv0lUl0faHO4dFqhb2ITOq+Ino= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019100; 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=MEYAmVBozLk3C+Qc9+mQ9xEXoM8Xek5j3CySplwhBug=; b=NfF4HIfjrd7WV893cu5rAvPd2xcOoPZm34VuBdKmjp8FlAbarqI4bz59vVsvV9qaXkh04DEACRe/cjbFsHDhHy9y5AKYKzAEmYzsV7RKtz3M9xRWb2Er8j+eHQj0qpp3ETaGY79hiP2INU1hCjs6Q+hN6i6kz1wZaQuFgLWUkUU= 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 1757019100903378.59669987097107; Thu, 4 Sep 2025 13:51:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGrt-0003RA-Gt; Thu, 04 Sep 2025 16:47:42 -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 1uuGrq-0003Q0-V7 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:38 -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 1uuGro-0000iT-IL for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:38 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 201CD60BF4 for ; Thu, 4 Sep 2025 22:47:21 +0200 (CEST) Received: (qmail 32593 invoked by uid 990); 4 Sep 2025 20:47:21 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:20 +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 v6 06/25] target/arm: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:43 +0200 Message-ID: <3230bddf690d5facd44fb22da9cc006ddb46465b.1757018626.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.999952) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599952 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=xNEb41Bq4Z4GtsJUyqVZtleo7SkSVedY+dily4e9McM=; b=bCcF3/o0Z94dGhWKbCz2jVr7BUjNzc7jNGTJCuuMtEzon5CC+TATf5FfDduAmedkHw9hRaI42X 5aMwMxeGArVX8jM8fx5rDoWlPSujptgRyG9XMK/kVVmO6I3ntdgfeRhFOMipDVJZ+CdmrmKQvTxv 2KW9YK1vG0bksKWvjnt9av2qWke1ZajkrdqCFI3/zW/feTurptErGquRtAu3wNjAzRR+NgiD7zU/ FyHiN2hNndijPNpXwhNc2ffRlb3TmdO3aRawW02yNFZwmVo6xQKTlEkRfb8mAa3qL0OMjOQst1qQ W/et+OTpBIxnaob13HrVf88LGQyIFuFkF5H8Ofn7UtIIpztsjr2q+3NMuk2Zuc1XB3vmond2clkW 9/Uc5OUGOcVY+VuFEpQrjquiTBHlB7FFb3iey/BDsUAbgsD/Lo2aD5zVnxErhaFA/TpItyCJp3x+ h7S6G5uyRbFJrzmkuddwZHPn2A/Ly5vRnDDSU04zASM/dq2Nxwo4QnNuhwffxnBKPDyObX4syDSV /YJXHpJqPqNMVGatO+2xcmas++4kl/dg4kGSJcZD649dMXu1McnHLa+Uq1fkY6EEKLJyJWejve1r wkoO6P1UxGIsCXnfoDxfPC+RfUvzbF11ZMRwvSU+RkWfHu2W9lRWbSHQbjmezNu1tIpBAP/eywY9 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019102065116600 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 --- 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 19637e7301..4812b30d64 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" @@ -8585,6 +8586,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) { /* @@ -9251,6 +9270,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 @@ -9267,6 +9287,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 @@ -9278,6 +9299,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 @@ -9303,6 +9325,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 f5a1e75db3..369ec2912b 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 28307b5615..31d9a59ed6 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 Sat Sep 6 14:53:25 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=1757019268; cv=none; d=zohomail.com; s=zohoarc; b=NBw9bpoEBj2ZQu6fP8mWd2tKT+WDCsFQa/IM2ZiQuVl5FRFy1bfEvRfkrJK3CiqfzrUt6uolsHewweCVWVasIZ/zZitbL3/qyF0XSOCVVKF5gXn2jsTXFd9VlULqoACSCJNUH5nb63fb0Gguht/fk4uz54Y+dp5jcDwTUXmpRJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019268; 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=fx+iXzlaWlK7ZFzrj34UmcB0e1+9WaZybPBMyNeFbmU=; b=Vc6diEd2lupsFtAnjSMTcC4PDXLRfYwqTXr0fst3jsvHmVKiHcCezYopHD/7Qg3Z8au7FTUGIQSl3YcdBJ7Hc5/C+3+5js7xOg5XJ/phl9FQf0j7H3DZw0BzTLp3xNbC3tMSWNzggbvTUSP8FgWDVPDcwIKmXWPIiZicb2sFbPg= 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 1757019268536622.2538081683865; Thu, 4 Sep 2025 13:54:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGs4-0003UQ-LO; Thu, 04 Sep 2025 16:47:52 -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 1uuGrw-0003SC-8e for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47: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 1uuGrp-0000id-Jd for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:43 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 6FB2360BF8 for ; Thu, 4 Sep 2025 22:47:21 +0200 (CEST) Received: (qmail 32607 invoked by uid 990); 4 Sep 2025 20:47:21 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:21 +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 v6 07/25] target/avr: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:44 +0200 Message-ID: <20cc1b234a31dd02dfb36702ebe2fc68e18ceb75.1757018626.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.997689) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597689 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=aiXM/t745WPvpZ4qvo3agcHEz8akJ3QnkTB+iJHf8wQ=; b=KI4lCuOI3w4zzugOoGzG6e3YaCMrfbDo37yfm/9bkigeUKhN5waQRp+xLLsFc4N5mgOLcMFsVW 5+1qNfi/hOI4rPJK8k3iH5dtnpyUV1Oo0zhwbfYtvTSFa+axoKenC9Jz+V4dFEhBh2pXtAo8Z1se msNCXbWJmpd4O7szg/qbMH6M3u2NsMkR+L3gH9xJpgPFDnCUUjoHurl6IaSLEfil3Lj8kGvpDEPh lN6PaCVbofYhtIEopD8p7oj0iyFnN2voe89LVNcyhZxijI8dWNIF/v4sqX0mgZMgqfHbbRXYRZTd RMU+sG9Jv+w/L+W1E+VwAFNN+kSTq3H2I11rLehQz5hPxYsCjJkIJqhgIThY2S0yshCvVJxDxneC lvQ5GAPf3Y9rC9SlwhGHfisOGf9ai1vUScppoREsO7Qw3FcONiWepwSuiyHPUAyWOVW+y/b+g8XP hHH9uimPjgwLJAexqUpjgu2iwFcjncZ3JPcQt85fWi4/L0Ql97h1UNWGq+onsUK+SGuDWPmNnI9A hO1GbO+cGP3vGbN6vjDfA2rt6sBTYzMmuUcni7TVZxv1PWTNWy5HYd4zvPB2728iTrIb8Rh/EemN nDdIx6nYwDDEpGHQrLol/3mhtuFbNO/Zg2faCiZ9MkE7K69xdN15ywKgiTcSv1OCrzPf4udfktT+ I= 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: 1757019271943124100 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 b9cd6d5ef2..f28cc08637 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 Sat Sep 6 14:53:25 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=1757018962; cv=none; d=zohomail.com; s=zohoarc; b=I3GSiwbSLNe6TNy5Yl8UftRc+pACAr3oJ/9YD1KsMd/LBwWtW/5xH/8DDOGnSl2bVfnzlhuJRAw7T7jejti+GcwsbcFOOM5gRSIAAM3EI/rxwCY8/VkltbyU/iNNNau5O/7JCY1Qu/1ngnXmMPI6dd++qW55ihuExIpF1uTj/bA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018962; 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=9PZqyylhjvqbHL1tknjlB5+zI7E0IYxDw4BwQMldWjc=; b=fhaE4sBYPCuNhczIzaWtvBVvOOq6wExxVBzOUDvuIKd3exOAB4pxTIGdGh0lpj+mTtNk2sdQWVpFHoJlzK4PcoFji3Gm7cwB1twkdI+m1xQe8F8kaWR83kAnGJHkib1ZeBBQAb1JhPtKKILA8U9kek+CBpV4XHKwcWHDxbaeWtY= 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 1757018962107428.50522325494046; Thu, 4 Sep 2025 13:49:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGs0-0003T9-Sp; Thu, 04 Sep 2025 16:47:49 -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 1uuGrv-0003Ri-Kh for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:43 -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 1uuGrq-0000it-Nc for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:43 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B3CF360C14 for ; Thu, 4 Sep 2025 22:47:21 +0200 (CEST) Received: (qmail 32623 invoked by uid 990); 4 Sep 2025 20:47:21 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:21 +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 v6 08/25] target/hppa: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:45 +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.942677) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.542677 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=sTu+NMoTbOksZJEmBQJW6DU8Eg+Z5TECEVwydqga6rE=; b=otk4MYqMYOYQ1pPsLBAMAPH98pfC+A932VBCKbs8xAdyqjuss1ZMs0rhXRtaP/57envnqdQ8BG C7zSiSYORm6sm84N91R1wRy26+xQrHlX3wZG3mlwThXon4F/I2BQamz0RXUfaMbR58H+sN/9nbzd dX+7q8rcX6A1NB8tnN4lu8WkbGBzDVJs6QMfPzJE4vjXkw/Q1nwFAZxCHFbvBeUv6bPKrsw8NzYb G/zre+j46c0jsSC8sMmbvYWuLhfFleTAYuztu1bbR7zehN32EfE8eEX6BwmzEICD11a7bBewbKuD a/AGPJnwNkQz05f0SDAjvquy7g4lESDgqHxpSNtSx43ACcdd5qeNVLUGD+nk1pEDcccxWKGUcfZJ 9FnpXSkh7I2vjPOwaQPgU2v7BwMhmFtlp4ajC9zizMnWADatcg4b48QSzMZzhSnFb6RbiK06jWFa AuSgo9knh3nEe0QUNrWQxyVYeEdZSGr1lGXe5kbpSG5hie/BNURmmrvyo27NkR8K8ojc/3WitI9X CYpzx0qXiw3fDmzFHppEHofO6OnU+hrBAuCT+ZgjUiTVQmmRY48KHZZ/xG5QO4soPLNoQffcb3PD E6aff33uwGwD7RtUloKt6T7m6I+vM4qrY6zL2XXbYyAgMwca9enfXXvxFY83gpOrtd6FYpqjHw6A 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757018964135124100 Content-Type: text/plain; charset="utf-8" We identified a number of exceptions as interrupts, and we assume any unknown exception is also an interrupt. HPPA 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 Sat Sep 6 14:53:25 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=1757019143; cv=none; d=zohomail.com; s=zohoarc; b=Wm8hIOOaYVoQ+yWq3zjlgwmsndJ6wvIapI0sV38eMtk+yXz8Q6AYtrMmoCkOw89xvUTBliKTypgD/Mnwi+e2sayjGo11Nxr5mSrZO3P8+ZTcxgIT4hOfUlJD3/Jl+BhSCK9d7O0/8ni9XnYzGGJfV9IldKsVkylNMDEJJCYEWjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019143; 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=kIJu+hXttaSrGlLlwULyZbV9vE3oSZZFayrE1cUE2iibzWkwGgl49fCb7Dc9PBzW3r50Fr6jxK6r1bA5tPBfOgt6+hZ0Tighi79NNILI09e5udBE645xorGTOXwBDXyjFY16P8LQpCtltIqlLMc7aZ4ee9jzd1h8mCD5/txUS1Q= 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 1757019143113863.2298421223156; Thu, 4 Sep 2025 13:52:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGs7-0003VJ-QU; Thu, 04 Sep 2025 16:47:55 -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 1uuGs2-0003U9-OL for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47: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 1uuGrs-0000jA-NX for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:50 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0B49360C0E for ; Thu, 4 Sep 2025 22:47:22 +0200 (CEST) Received: (qmail 32639 invoked by uid 990); 4 Sep 2025 20:47:21 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:21 +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 v6 09/25] target/i386: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:46 +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.999953) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599953 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=bvA/QUl7Tu2r5XKDlQ4PbUbx88gu0jteGou7bxHH1lweutUra3WoaJuhByepqlsRMLDsRfd12E nMDydLFXsKH0qtd3KZoGpaJJnMDjRTjmOyK1KYUEtxmhxpMOfDsgjzuFNzPuB6frwdGJqGtKuG/V XclODK0J0pzGWaq92VOTj68pzIzU+cGVs4TPEuculuVPoXU/AeMDSTtsH9fvz4QDYXinFNsjoOEy yQovzYPMg7r6X44joHJx1uOESW6ZNTPWMRfFwlXJpPpHMmy/mgJuQGQAzUlUxoxaB6k8iU1dozOT Kxe6H7Mhl3JVCz/JbnQq9gBqMHR6rgC9/8xdIys3CspzbHPHJv2hfq9QhnnP1diQPUTv6eBO39EO dAmSfePjPU6uWrjxQhywwUM7CV1QyMjgri5yXfB5coaqa+ZKzfI117dVLosNFsf6HlhbH/6w4ogP ZEdw2nFY3WHJUPTQhGfJOPg68taNLtHYRfzCnOiY38oofJacZedcrTmJn36IriCVwcRR9FrnX+81 FW36n7ZioH2FoiOboIc1ZoO2VeUhqyGUREuQHycfjs2nrKBH4XUPfUJ50wsl86pF6ZciHM1h21PF gRICrZerJ35BMzQ9gKGoLSfpgjZ4QYsPmhb5tMdLbpGRIkE+XnvwQ6T7+v+EK1ep3wFBuE8GvS+Y 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1757019144228116600 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 Sat Sep 6 14:53:25 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=1757018960; cv=none; d=zohomail.com; s=zohoarc; b=ZOtbN8kj8YFuF707W2I7nRw2FMixlZde2ovkDrNM0vtCoRFwV8z6zVAO4ZSjCRB2ZaEI52KMu7qIMaXYsM4Bd00RgIXVL1UqEfKiZLXMROLHB9WtpejMX93PCEHai0LNX9yuIeMKWcuEu8QFC6vXlU7v+uzruu49QVtV58PX8lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018960; 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=YgnqMNlWsl4mct0ZUHnm16M1BApP9S5e8hz29g2UgPA=; b=imtPFYU3UxsLY34woIj133Kr+p7VYCm8nsn5TzuygUgRrGH8AAaq8VDv+VMH1ldpoZM6GdA1Jfntbgh52G3kGBz2p+G9X6ePlJmHJPgz3lJm6gpNMb5edmtaMjgmpnOFTeO8yk3zUhpc2zEOYmMfj3fQPa3Hc/QXDEEkQEGfUDE= 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 1757018960514141.10080463384725; Thu, 4 Sep 2025 13:49:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsA-0003Wi-Fl; Thu, 04 Sep 2025 16:47: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 1uuGs7-0003VG-Kr for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47: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 1uuGru-0000jV-7B for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:54 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 43C6F60C18 for ; Thu, 4 Sep 2025 22:47:22 +0200 (CEST) Received: (qmail 32657 invoked by uid 990); 4 Sep 2025 20:47:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:22 +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 v6 10/25] target/loongarch: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:47 +0200 Message-ID: <4e0ce5ddc88260c9cd68b2db7e4fb8bf6ba32dda.1757018626.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.998182) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.598182 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=KeckTkY1RcWwX5r8maaZuE9pCKpR4aTRCsXtQinRs+U=; b=qcgJU1Ro9nGq5DVwSFDznmPOWtr0ijPpnqyW2KPDXFHbR9/sf0hlc03mz81I0fa3TV6dShKX9X Zc2mNmb0wtqL7pzwjUS3BL2QM2SAS249/GFFUBn9Dw5l0XU8fzB6tPc46h4BMe9rdOinh9WNujv8 KJgFFgXuASECRGkzOQwB7AYyJlwzeEFxtsJZnEDqyQP0MDpk6YoSuS7Gg15RiEcKYCm4+hQJdkoM M71Sd9O5TGSYGFlKQbjOnJcPaPahJh7h1L9YPCZYp2GRu4l9FEP9HMy+Jmm+WFWsdtbAoDjKzTyh XuYpUveQ1vjkAl5IN2FRriLfVYOyYNT1k4ncWBybDVr7nPj62K3pfGugKmwJsN9X8VLqxdDu16DK pYRmbcr46P0ElHYtHZQgCB6PZ52faz3OxtI5nlLSwRWQyuZ7S5xObputneL0rtU6lcK1y0Zdbgfa J/HqP87Sqo/5LERnlA7x4RohEJMeTlbPx1UWWkd/+1bhuMMks4bxAg+8WN0Q14wUc6wi/DvL8juc k32Vp1jzg4ddawpDNOEeP083aHirohNvA3Fri+XB73Tmnyly88VlzP9G5L/l6rFERk7RH8SPM+MZ dEN7gVmKhxE8CAuSj7bpGvbS+/uhzGkOo5GTDDYovLrMr103td6MyOpSJcNMWWb+y85/1M5KEvfx 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=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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 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: 1757018962573116600 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 55ee317bf2..8a8b6d8eaf 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 Sat Sep 6 14:53:25 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=1757018982; cv=none; d=zohomail.com; s=zohoarc; b=Q8XxNvqdTQe9K3w9wlZsFoB01nykqLWunEZSNd2j04DQw0MPQdv3DJTa0cwxNrIeIbfA6gjXaTbo5Jf/bV42rsGS/G3fzr36htWnehkqe3lPttBCiEvQLGre7PHoIJnlHIjmR0XSjWgDFAhRdex+go9X10WXltnPtslezZ92zE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018982; 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=CUOP0py4tO407/FppLRR/D4qnA/YldFFqdL928vSiOxxa98zs4z+vy60u+uoxry2mx4KGvJbik5Uz3WzsEF0+Wa7ay5SU0KgCcNb5Epq0fjfvV/dlTB8/HKfJJ5/Ew6DgoIEZB3xe4ZNs+3iBLNEDQT7or1NUSH5AJ7E6bzFJSQ= 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 1757018981994756.5317457932232; Thu, 4 Sep 2025 13:49:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsB-0003Xi-JH; Thu, 04 Sep 2025 16:47: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 1uuGs7-0003VI-NW for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:55 -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 1uuGru-0000jU-HZ for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:55 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7D60460BBE for ; Thu, 4 Sep 2025 22:47:22 +0200 (CEST) Received: (qmail 32669 invoked by uid 990); 4 Sep 2025 20:47:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:22 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Laurent Vivier Subject: [PATCH v6 11/25] target/m68k: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:48 +0200 Message-ID: <63385a775e6c00d4fb9c726631ec808a700b266c.1757018626.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.99705) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59705 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=qg4E9Hoe0jmVFqFBSoMJ9eXwEdTUy5mbO6Rh/keYChNjMgp8gBcLOaIJbnTy3TFAjcQCqdLtmV Z8I5QVHhS+35BWhYyQzazNApUjkBUlyGVhwEQtaLoEhBx8/xjPb3jzjcp71YkHMuhKsAEQ8Qh5TI MtDSnGERzrRwwoJWvfnPIQaPoNpk6ztDUANKRNHwQdRlIU1/sBNglgCBZdNtOCkgzAoYjR6b6wsU 70q6bNkMBhvmsuDtmf6uhgdi4uVSOdDut9R8rP2TZdFzC6ej8PlTIKDY6QViAbbVCDRAo0UCB/1V oCPDAMfMrKbx6C9qgLIr4gx+l1ZGuBbZWZKLZZkN/T/FMjkXdxuzyvaqXpogkxPxwLkLuEc35QHH o0Nv5yIq0Baa8q4RBngQQH2frp30u3kRP+b2NrEm4If6ZdDTeygeSH7L2oj9Ia1QgRRD6tIeq5we fkKAvj/k6BmwX0XRcTFgmaWu0DkNckoH3wEVC0VyKCEtg03Xubre7SN0Ks6R2gOmETBHbE9rkpJt DmBl1JqDGnTpId9Q7yZDkIa//++H0Zve54uazplfTmQWMVn7HyjaN8AVWR3hFw1bXp0lxQLxXjqY +9Sg/NmcV3qEkMcERMUH3pYXIfyYxL4eDchZPTGktlZ8lon3yjuzNrD3bKmT80CeCxTQMTMyC5lh 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: 1757018984296124100 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 Sat Sep 6 14:53:25 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=1757019058; cv=none; d=zohomail.com; s=zohoarc; b=T78DtvM0/LcJiwuJx4mrCAf0raiFeQS4RBTOOivC+QF9nUcJO1IrDFTDN69cxTJyKJN7xeUcUF3Jxfb4XQsf/n9nlqLM2RZWRowk3tFK3ncPQIs+f4sOZlM3LRkoVd9Iug/2Nd0mr2n7de8x+eYPA7jh4xuyM60CDZNnnL2yJyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019058; 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=hZP8MIZC1F7n4Rlz66tDEJ2l5LQ2MGwFGr/Zh/mXUZiOMhmR5/m+lGt9m9QFQ38nP0F7VXuuai4t11gc4ZMfze14w5E8O0G1C1dqjYIsiQOAFL6yweSr2jlWoJixq/pjvB41tHYbTmx/j9anHACV4ugkwVPf6vPpHHzta5mCL8U= 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 1757019058103674.4517062360576; Thu, 4 Sep 2025 13:50:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsM-0003c7-Kq; Thu, 04 Sep 2025 16:48:10 -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 1uuGsI-0003b2-Tx for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48: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 1uuGs9-0000jm-56 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:06 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B963F60C21 for ; Thu, 4 Sep 2025 22:47:22 +0200 (CEST) Received: (qmail 32681 invoked by uid 990); 4 Sep 2025 20:47:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:22 +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 v6 12/25] target/microblaze: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:49 +0200 Message-ID: <829dc282fcf037d44681ba88be4dd9e17c644376.1757018626.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.998444) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.598444 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=msxdpSIb4Yu+2qhO55qz2NfIUnZ3CxlanAcRPoz7BPA/tG1uuW1lyYmU98KwDj6hnB0UZzz1x3 fQV4lG416C0zaq/anFAtfODdbca5+0d8xvsAf4l2n8ya5Z/5SJ/u7dJ4K1pf3PT6L8s0XY++x6Gd rrcph09Sm5/avtWShMAd3CEeUiQaWpz15qCfn8GKBUP3EdiGSWkJZQb9co7SvgKtzI65fV/4vPkv Hol1ZXdKhczd5Srp9jx5LgFdPKq9huUVHp6aX7WK2fgSQLlgtbtBM8H32oyvAd6ocMX9q//yWbsa MZpkT2YFPy76EcBiuiVZZw3gBIcWjE+4X4kRBXaW/rk3zFB8KBcWOuxwyDn4fWB6gVYpAwVplyUh e3aN1fqpC7h3gHcbDJqb31Z94n65xVoElqdfYpMfQH8kfSv7eKGdvHzRu01caUVzg3fEqPyGGzoC a454d531gJaGaew0IlSJwbytjxuG2Y4bcvn64oEZLawNNr+uOs5vM1blZvssAk7yRqO471vnbTUE Hj9gMVGF4li3gW//MPKNyxdBvbf0rh7BD2ti1Xw1/801XrRntMina+O75rnshlWXu2uPXnYEeIUw h+3cPlAdhXgHpJ2UuVOQUD8Bft/TPnaztSHLsVk0SwI8Fv4VInZdJaOVy8CZxMX6/i+gJ9EkgL+s 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019059303124100 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 Sat Sep 6 14:53:25 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=1757019217; cv=none; d=zohomail.com; s=zohoarc; b=Kv7Nbv3s2TPmKI6hiwjCWcvb96airpjP0ayH1Jdt43Mal5huRxgowEgeI+0Vq+ngHATX6+8qslOXhXmkqQNBL5XXLbgmzW3KDs71/epxJEvZQESRGBi9K/gGqECuKCQkDUfpwgiL+0ZZgQtOomngCZIpxs2f47NIFsTUlHL0QRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019217; 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=ymSaTcEsabNSYC5IUB1P76r2Yrf39jwptb1WMJFa5qU=; b=RWKeJJQwrfn3pcm6iPA0SY+OQNOTQEYnogiH4ZY0V52+SolYivhY63F01cKm4ETMzethm9FG5clWWoFH9xpGdm7FWaDH/fAgbetf7S2qtRz6kuWwEXOdS522MmR6cG5FjvlK2ZWfvuZYEEOU46mWyyMrtWu+ULTgYe/4WCw06DE= 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 1757019217470334.5345336585166; Thu, 4 Sep 2025 13:53:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsA-0003X0-7F; Thu, 04 Sep 2025 16:47: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 1uuGs5-0003Up-ON for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47: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 1uuGru-0000jl-Fu for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0EDFF60C25 for ; Thu, 4 Sep 2025 22:47:23 +0200 (CEST) Received: (qmail 32695 invoked by uid 990); 4 Sep 2025 20:47:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:22 +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 v6 13/25] target/mips: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:50 +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.999457) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=OlzwuS+WIxAXgxczYmiujNr+qRwzPT++tEanqWOCdss=; b=ZD8NYTi7AtXcoScJ9i8MdXgh/bbe2TJuvLnwA0JZxTf7WRsOKZgMsq/4NmqPh90QD7iBea74Gj NN1NZyGL5rXXzWyvjNFj8ngTCq+/ANPn/deYt4io3HJyXwmhCAEmutzcO65STpszUsyTSHUdSBVb IyGZxnvOkE16xHgXKUkhvaVHxH1vH3kFtoxbA5+/uXFijG8/mceRqCJo7hmbWbT4Galcz2tCg+5n lTCZ9U/LZygWCp6azZsIduwnhXt1d0k2dfggLQzAlSlHE8PQI4CCBrOAhEJyknCGKi3ycaqn7TzG zEjP/TKl/BPrGrYw3defH765ylh4OnhJWzXagCxCJOMEi5Fa0+83OaMxcZb6/tRTJ6iDqH7XbPGP aU7t+NfNB6z4+3WPdD8CKHeem4NOyO8vxruh9b2Odm0KFdPVPa8WfrLiGUFm6npOcvQR9MewUoHY h1HxBbn2eHVioPqukiTlIX3dowofY5kC8/wW30EEXwZVwaUUuo1+H8lu+eWdCp081hNnkifoNd0a fjQFVNkpH39hOZhaldiSP/u9ZrUsLmQiGX4xgfgo813XPX3lWOu5Wa0sogN9ggbtDtZwRt/vwCHF ypCf1D5246WlZUaYhyt1feDiEx/RZYbZzcDupPUaxi1i+AszntZz4+D8bKF+HXjEwQV3hf/v7hcJ 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019219210124100 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 MIPS targets. We consider the exceptions NMI and EXT_INTERRUPT to be asynchronous interrupts rather than exceptions. Reviewed-by: Richard Henderson 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 Sat Sep 6 14:53:25 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=1757018958; cv=none; d=zohomail.com; s=zohoarc; b=ObiKqbxf1F42kdfSzxbHEnTiGRgX+7VIUzl4G5tFE0QLlzIzc66t1wCyrOlXcj1ineISilMP1rmlXXuqFmiYoH69GgwiDdYqfiPYDHqvKoI+Aup6+xXw0EYiQh+sX4gg1YeJ2BEcwkcU6fhfrmRj71diiBwVUG7gBDSwpWOet+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018958; 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=j3YTFVxvTWlMlXjegBdbEBgCbU+xZRvLLZb1WlGp4l9nXJ3eqfcJuyFFG5JuQXp5V4T6VFLyV7/H4RnVR2FiYrWkKVaJSfVI0t7M7AOi8xsDd5Qp+B0kgcZ0Tmndi+PmzyLQgINSq8tn8JsEmz1vLahxS/HflGPYCaJbd+60gME= 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 175701895898740.293061439247936; Thu, 4 Sep 2025 13:49:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsB-0003XM-8n; Thu, 04 Sep 2025 16:47: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 1uuGs6-0003V5-Qh for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47: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 1uuGrv-0000jw-2H for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:54 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 4A8F960C35 for ; Thu, 4 Sep 2025 22:47:23 +0200 (CEST) Received: (qmail 32710 invoked by uid 990); 4 Sep 2025 20:47:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:23 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Stafford Horne Subject: [PATCH v6 14/25] target/openrisc: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:51 +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.990486) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.590486 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6By6W6p63fDAcZVupcavoMH8cQUKrNcCRvR5J3edyUo=; b=rBBYsB3eGh7DnQnVBzg45QkevES8TeWdPcAXgHQ960/tKcX3V/zjHM/YGBjiyL5bA9hNrgSRMi tHnumaVMwBjQLgGwWaMu0YGYyuebDrHuba/Cs6qpZ3n6owlHGfgmPPlqc+zOKCcygfFzWII8//cM AmmKY5NM66L2YjO3ohnTFZGfUaU+mieC/EHo/97pw6Df5w7OEsmwHAZi+kqjK7PIQ/+v8oYxgQGt zNNliqmRqA+ReBTFo7AsF8ZiAKtHTqDj2ohOsPNfiHwiFMCAsz6X9IH1UZHrpxmgwUIQkg2yg4vV nzYDE0p/6m+HwPpDcC8a/PQCFKxdxzenlKnwgpdPGmYNPbPu0yYxO/XlUKzJ1R1HG54I2w5uQ9F+ IUk0GinqjkhFuMzF8rJ2Pj61QXRaY1Xme1acs4AsBEZv2tEBuFaWa7K4VFBnFMledMywRkbJY4v7 Ioxm0jtEr3DZCQ1qPzrjqO86rZJunf4kdq8uSwbANovmpYOfTlazvMeaRVjDFHKQ9nJO5Noqe7mk 7j2aEEW6QarqXCcDZjRf75/BO2WdWdzCchx2PRzGw75UtAlqIKG/URPoFyo7/K2xZjXIdcQx6W2T foHOgBPt1tZxAlF1yYkiZRIN+gHcsqCR6sIQyFZvENYE312GnllcZhwcWGO9qFy5Dbnf3v2ivQ7G 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=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: 1757018962691124100 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 Sat Sep 6 14:53:25 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=1757018966; cv=none; d=zohomail.com; s=zohoarc; b=h7D4V9VZzNCIUvAYC97/e4D6i+NZjKgu3hnr1PIfRWq0z9y+rvVVbIGChY+/h9v7DuK7m3UKQAiB5k8l5+OI5FIdvTGmseHrj2eT6OdTm1dLuWkZnOQYSXN+OMzs1Ux6qOCKTi2G7EcsTSr2eq5nveSGEyebjgmMAyVG5I2wXrg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018966; 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=DioiBHTaNn+ZB9p1Co3CD09+PScVY2DaTU/qSlf90E0=; b=KQUDWp3qWhtRSEJP99v9V2x/wNvzaHvFpr0/QdvaAgT2QhsPDmGn+tOVJANg8c1SbC/DygLRFvGpYnzsMjtKqAVfKiIm16Z9jevMBLB59Pi0w2mEtyUnc7JtzsLvgbjPvVbUuHn+jGToPJ4j+R3BAZx9JQAScnH85eRloVVBBVA= 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 1757018966665929.4766031370481; Thu, 4 Sep 2025 13:49:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsE-0003ZJ-PL; Thu, 04 Sep 2025 16:48: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 1uuGs9-0003Wg-6q for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:57 -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 1uuGrw-0000jx-Av for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:56 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 9171160C47 for ; Thu, 4 Sep 2025 22:47:23 +0200 (CEST) Received: (qmail 32722 invoked by uid 990); 4 Sep 2025 20:47:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:23 +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 v6 15/25] target/ppc: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:52 +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.977098) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.577098 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=+efXVEn6Kpl8Wn7M2xzQJVplE4/bu10ngQOhPPoIccs=; b=hig84k4iHrylo42qZ+BXG9x9mA/3GGWtksw6OCCs9AcwDQUJVAwruIBqbFrbUKx+8jBNosYAjp 88oVYdIr8idMqEBNiIfr+xQDsqwa8Mw4rXC8YL7Qp3yaeWoG0sJeTZF/gUnxL7+8YWJMnRI1NvAu p1Mriaz4darFbpSb6rvpA6VdqzFmA8TIfD10RS8ZgILS+G+JCBd/mSRWoiv3yz5qZw9jxA/D7FT0 uf+GGnW16m9AfMZM8Hc3dq8CnXqQOLibyaXhbfpCErtfvFgSH3swl0oMEVe9idDrZ16eyuLjFMjv Td9d6JcVfl0XwojSLzSUZY4778XzxWMm4Muyl9RRXYLglojRy1j41EyaJaf0ef65UyR71x83HD/C 3JUCSQ95APiRHewjOyYfFDdfKp952e5Is5hqKlV3KAou44I9tQMwoLwFgZnmEbQ/H56qFMTDHfQd Sh6bI/QZQG7ub6sX+30jat3mdADfarszARyOqXfw4Xedz7oHqFXfJUh57sP5R3TNSK385+oC3UnQ ajWs0/ebRQxvm4REgug1FKr1rmPrmXsav49QSJ8NHklnEbufr8LIWU1oZ/GkUfzgpt6yxBIqWEfB GEbyvya4NPpbxHkF1+MPNmScVoRWHkPytZy1B4x4R2FmTfvfPiytk0r0N7wKKWkjvFf7ug8fKD6K 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757018968065124100 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 1efdc4066e..be0596e41b 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_booke(PowerPCCPU *cpu, int excp) @@ -954,6 +988,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int exc= p) 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 @@ -1025,6 +1060,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; } /* @@ -1133,6 +1169,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 /* @@ -1254,6 +1291,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; @@ -1353,6 +1391,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; } /* @@ -1397,6 +1436,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) { @@ -1543,6 +1583,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 Sat Sep 6 14:53:25 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=1757018959; cv=none; d=zohomail.com; s=zohoarc; b=Br1CxRotLKK+KhjZlDofJOmNmXtukAu1LxDYPVMl81/XyzoXK3meKWphlxws61nVSf2bnibXNvHOdPgiIOpS0wYRLHFt5LmFau9uHkg4E0hMDrS76JorKvUqlzFfDvkU88bchFWR17EznOlvRihxNz+VEWp/5v4nJ0OLCZh4kDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757018959; 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=aCFcidZaHw6mGpoR5oMTYsflsOLY3Fshz+OXGdBAIAhqbBWARRcUI5ipfnE8YWcRqBdAErHiPv0g/8CaMsaz60YBSKsfadcXM6YHiec7je5DsZZ4o8fW210M5bnbLwCc0xWd2JeIjV4IQf5kiF5X/kmxSIawm0LSMHsvLECnzvU= 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 1757018959081915.3165304943586; Thu, 4 Sep 2025 13:49:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsB-0003Y3-RU; Thu, 04 Sep 2025 16:47: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 1uuGs8-0003W3-FE for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:56 -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 1uuGrx-0000kk-ED for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:56 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id E0C2660BB4 for ; Thu, 4 Sep 2025 22:47:23 +0200 (CEST) Received: (qmail 32736 invoked by uid 990); 4 Sep 2025 20:47:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:23 +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 v6 16/25] target/riscv: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:53 +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.990391) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.590391 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=oLgOyCO7C9M1gkLL/S0CJ9o/yrdfe7/Vd9aQR769jL0B18VeZ6F+L+DET46QiMoUAAJRXQwg8l nv4m8LrHM3NICRZm8FsDzHpWgEADZP1EEERwNshRQt8BgngvNhoIE8Wc+ix5N8HVgJIevx+/sjxf oxyPdLAS83YSuUqND3+lLkYngBdOQztzHGdCIO74oem1ARexkuL0v9m7Qk+xReT73IRX921Tz/IP iJt8/5Jt980qy8GwKkODA6diT2PmZmlAVbU4ucOOF+a+KrG0le3ZHpjOctXCltptsRJ1JynrNmVQ vHIV/Gxcf1edCEVC8OwlAn+UMYIbPD4DISxsT+1Sutb0geoc8MM8i2ZlMRz3EsyTJLONaaQsBNxx VhE/WCEiVJFh+ByhIoH1OUR5rRDcmf85ACgb6LjgIQyHExvhKc+SLU36+VxT/gxmwZb2CEJAijQC h/ixUij9dsak6x+pFK/bLfYHIIv03B41iigGgoHXiMqrUGEHzb7HlEh41zBlJN+Pe5GjfkyhBLiM sdnulqtYv/eNE/nWKqJCbk6LS+CDFJzDYo/C0/hsElLnYv3uJVs3z9P/KCEVzCdb/z/6rZkmwyag JFauhsu9sAjUF2GY3o+UN+lY5kj7DzFlTd9Mg/fpTKmHm8swwawQJhdl9h0tZdMyZ+NZfzNlfxa4 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: 1757018962697124100 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 Sat Sep 6 14:53:25 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=1757019273; cv=none; d=zohomail.com; s=zohoarc; b=cLkOSeppmh066bJj8bMw/EtVK45Gd9em/OpIIW8nQ+IrpT3MdA0MbpkCpaRIQshT2nvt/Ux9IkXx/0l92fKMg5ZKDNwRYgTISUH2/jaK1XPVcVZkyZ3h1ZoCRBQ2BUFEUBot/3hZX5w+zbjvvxs6oQHqrna1w9J1gKICfDptEiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019273; 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=4jyOeyTiiwSHsjXv4AoM9jGT1DfS70YuVzWnnrYikCA=; b=nnrc4de6AVJwIQdJJNhmX7DjMcHKBQ+oZ+iQS5p1KA4WiFuHIAzEIC5FScuN+WiUZvCwqJr69yBXtzkcqoxO6NiEMn5DGZmdUhbo08Yl+5tMvhqAwJERoPC2eOcsiKL6nc5vhcQ4+G+bczUfhvuwsBPdaHMlIespGZ1px6Ydjbw= 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 175701927390343.90628701971707; Thu, 4 Sep 2025 13:54:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsD-0003Yy-Mz; Thu, 04 Sep 2025 16:48:01 -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 1uuGs8-0003Vu-Be for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:57 -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 1uuGrx-0000ki-Qj for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:47:56 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 2DC2560C55 for ; Thu, 4 Sep 2025 22:47:24 +0200 (CEST) Received: (qmail 32755 invoked by uid 990); 4 Sep 2025 20:47:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:24 +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 v6 17/25] target/rx: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:54 +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.995166) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.595166 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=O2XE4lw8lRTZO91tPzs5hLNcmDOO/lAMqHonY1qYSvs=; b=dLUk+7bquaq6c/x9RvBJ8aMGAblc1xmRBg00+54bdP8TY++k7Xcl+P6hmD8A0RH9cGcITfjBGR qJNcR4kz4oQlBC55OG1uqP05EjBlK2mmweF274ruK/vS2vxMcorFDnkf6N8AyJMelLsurZzKf2Qq aUZrhuT+wWNETSIkr6F+R1V+TpFlgD0TrvuEf0Fwd7XKNABMBw6loHXTOFdtfAJaNdGCPjqKlS42 dn+uCkl/O1FO1TtsWXgDZlBUkjVksj6VgPVbMNYg2X+K8yGSmgU/8/3xQA8YwR4KFXN7SJ2Pe5pv jrJZU+8H2ptHhvJiqfLeKnzatmZ1P2l/KLwwZQZI2FlToFSJiopw7e+s1ATITbYczW+c3UtV37Ne 2Hu7KXMP6yX0trgP5fiNK+KbCajSzzSbsTeVyGt8iOjs5EaLFmFNtxxe17YH7tGpS5SsJ1xaPsQ+ WxSYYo84Crtipa8UtmrlyGu6iWero1iu5yGpUeD//nUA/u4ruoS6mAVFDZCjgbV/pOzjy7JU9Mue lpKKEDYO7QruohUF0PwJPeSXyRbuQi14lO/Hbi7RNmJH/GhOTY3iVWmB0elu6U1TZJu5fvPaM7CB PYxH2p+X2XtTyGhaxkmEDjJ8MbZn/8OGkT59co3npZGVKaXaaNbY/dqqqVVN1Zjqt8sDfqmpomar 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: 1757019275815124100 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 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 ce003af421..054bfdff57 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; cs->interrupt_request &=3D ~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; cs->interrupt_request &=3D ~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 Sat Sep 6 14:53:25 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=1757019286; cv=none; d=zohomail.com; s=zohoarc; b=HIh4MA47ic7dTXHAsrPJcS1bp4UOel5F4yPG06eaB4JqdV8pjqX1G9ur/h0wRRGkuvVTp0aPvNgMf/z9lPr+Jp7ohrNkfzgGV6DlfKxlxEoY+BkZ0Uf1vrPkP3hF5BbGrG3cVWC1dPOLutnrOOc+yzgDCORc149swJGRJjWUd18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019286; 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=aD8ebEu7tgrM0BFSE+Wo+UTpWTtHjMKJez+xNbNDT0c=; b=g+y7Ju5A15uuG2iszqBOk6XH5HsCQgdCDRVd/y8/xr9TlCHOJWmeJEVAG/UHpXMLF6hcSRjYwZJvWle/OZfEmFzlmzIj4LdQpdSSh9whoYbJjG1ljIqNOAY6D82qlh6MT4NhIVRZNfrZqRnis+heBKR71/kYTHjZaJF9aMwYhJU= 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 1757019286418717.6608051738555; Thu, 4 Sep 2025 13:54:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsK-0003bA-Gq; Thu, 04 Sep 2025 16:48: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 1uuGsH-0003ae-DU for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:05 -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 1uuGsA-0000l6-En for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:05 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 8074F60C1D for ; Thu, 4 Sep 2025 22:47:24 +0200 (CEST) Received: (qmail 306 invoked by uid 990); 4 Sep 2025 20:47:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:24 +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 v6 18/25] target/s390x: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:55 +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.988624) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.588624 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=1hZaVZ2wXGmnvpC0qbaET9P8RsuJHC7UzYbRbJo3OJU=; b=ce4KNFJpWfQiC6c9EqRrT1qlxqxnZ0NyHSIVf5S/BwZzetN7vncfmwU57jo20SbAMo6pCy4rjd QSRVeNZH6NecRtcH5ZW/DTTpugZHFRIaIYdrA3kKyybJG8u5nO3mqxP8sW7tDyAzkIpb5c+13Mmd X42V1TM441UKXGqsIysjYCwuJj7jdC6p/irSPPxuDrA0UIKP7G27VMvqWRtMA0GK6LcCXY7UuJqT Oa/nZw0z3Z7XllC+TbrWIiQvC/dKS/PDdLLAB9nFVbHlszkvegUXVPM7yCydDr4Q+wSjq/lo6KHO Mr/CNLACIpYOVcqmDZn5p3tGCUJGpVUu+70ouV9U7VaIOGeD8Mw6m+ZnG7U2xHU4f2SCdi8hiiQ3 KA9GvSZ9ZywLAp4zGQ2G/Fjc59EnUhhSIVIL4XMnSu7npQZN6YzUswNX6dIoG96FRcYe5FmJ0xPu 9SxOytwbTLG8xQbay/eFbk6mJVMY3Htf9UQn+SSX10utCksbmtjbod6lF6JVgmE1Y9jSStKDaBRs zwGbCxDH+YZwnO06iSprOK1N2bwphMCce/Ldsx6+7dAT0MjXhbQCxpNsPeSWqogm3Wg0cAypiDxz afUX1sK5L7Z7xFp4nZ0f702kSTh8unxAhwzuKziQOmh07lnchpl5d8z4+OlR0/U9kf+cFzPYOqKf 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019288172116600 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 e4c75d0ce0..b7e7a4deff 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 Sat Sep 6 14:53:25 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=1757019049; cv=none; d=zohomail.com; s=zohoarc; b=MqHEB+u6VLfm4D/zDGEe4Ap6xtBxOcLAK41QDeKctii3f5Erj1EY1RdsCm2RjqAyiUnrWM0PwB/gdfW4WZniVXHbPh9p/bFz+dMLpkKL56WJWC3h8UXcc+e6BpHiYHxZGTsPe9U02bVBacy4F86XyU9RAqgi/KkgfW2GG4RqzIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019049; 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=ZvuBgbFcuF9gzx+K4y6qn+rXkXm8g2zVnrNssWJSRec=; b=dW0fbEAcLp8Oa2F+DfNJLFIRNstcxI0P+9nfnY7TJvt0xS9L22y80eZPK5oWHYIA5BDSE7rWGnkE1cXA3nGWEEjutHh4LMp0yz4pjPmPI8kZ/bJp03+oiehXlYVfIwvS1ipYdt/SDYXX+svQck4n06k477rDdfvIcybyPe2Ad0A= 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 1757019049829484.1906615852454; Thu, 4 Sep 2025 13:50:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsJ-0003bB-Do; Thu, 04 Sep 2025 16:48: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 1uuGsH-0003ak-Vu for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:06 -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 1uuGs0-0000m3-UI for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:05 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id CAFD960C52 for ; Thu, 4 Sep 2025 22:47:24 +0200 (CEST) Received: (qmail 332 invoked by uid 990); 4 Sep 2025 20:47:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:24 +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 v6 19/25] target/sh4: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:56 +0200 Message-ID: <177329512e608b42c573385ca610b5a87fb2dc15.1757018626.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.999051) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599051 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=khvnEL825xCEwA5sKX0oGexdGtTcGOWpbw7whztwzWY=; b=gAdFaWDVTfZD5bt5SeFS09S9fuvit99WCg8fnLq57t+n7mqy7iNVEreVDAGc1cbYEiT9nEHqoh EUz6+7sR0u2NeVgVsgCucbCiwvUBvoZ74YoHn07eK5e9Tglx++FksdATMN7Io/XPifPUfRvYYfie T/J35VU9GKxlMIz3P0f+P4eU+Nlsx0ye56zXpvNZG8ayYiyU/kngCA5sgAVo81B8CjsOtuQWw1Wr ciZrtcNt+cnuLDgwfa9UF1vOPXv51TBd59oYW51fXWH9iV0aaDfjc8nUnsp/obiXdToNStIQnIMQ Dt6papzIQS3siXV0lAlTdzge+3fu5hUo4K2Ljm3/3Wk8KCbZ5/zoYOJqULweQU6L5NGzKk2ETdYi krohJ67SnNv4TihfteYriS3SwKH/UfaSrx6ApVvESeXLLMvboQASzErpCJ4dixKVRHRnbxy4xQSz Q9AaVlPi7BWOyuneqE4rNPolqc4WXVUhlzWVK7bhnX/rQ8bIjUVQg+WnuFGeuEK5iidPUV3H0Vnx BOje1Bwa0Doq0kNZA085Ph/z4Ca70zCbPkU6+SLlNiiDEqjQCCukisj3oTaz6Vugdpb8Q+OZjlBk CpABTcrksC/sSFkrEpZH6Qha4ZVb5jStjPyFeT9nJWfCUSVmXdkav4Rl1WJ5FJWybK2gZxXXq9Iw 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=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: 1757019051014124100 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 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 Sat Sep 6 14:53:25 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=1757019125; cv=none; d=zohomail.com; s=zohoarc; b=MlJbVvRN4bEcBwmpzHvD+eKiFeuTCz2yk1UXsRmdtVnaR+wgnD3ns2xdErngscKduHQyW/4EqbPUkF1ses0NOcINhpX/g4RqXjkzci1p0DOonM1PZmwr5ga7KvCpPGk6V/tD4Z/V2JQR1siekuGGkXCWCgi86SblZVgaZW67zk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019125; 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=AeE9NoxIVek1ZOUD3aAB7pY8oIq3McXOMulkbmBpkT8=; b=QOyuTfQGrcs1ofRY7YjOW0pH1rZqapnPYSGGXhbUbSElB/Qv2rkD1+nMCID5kDLnBbHuEFBGlwn9uy5nKqIAw1x4fHT70h7xa14+NJg7qpqO96Dc5tqNUbxFZFeXdUSpsHepxfl+aexE8qCvcsspiis5aZPUP1PK3lzlR5wy5LU= 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 1757019125646574.2326943881546; Thu, 4 Sep 2025 13:52:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGsN-0003ct-8Z; Thu, 04 Sep 2025 16:48:11 -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 1uuGsL-0003cD-Ce for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:09 -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 1uuGsC-0000m6-6D for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:48:07 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 1B71E60C5C for ; Thu, 4 Sep 2025 22:47:25 +0200 (CEST) Received: (qmail 346 invoked by uid 990); 4 Sep 2025 20:47:25 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:47:24 +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 v6 20/25] target/sparc: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:46:57 +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.999829) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=sUcYG7ruyA+9QHxAzSD9HdeHOhM3xRfzfStnbhoeH60=; b=kQ6EQ44QRV0p254UZmu+Cj/1T5/wp7VRimKsqGZ/ayVaF3gKLcdoF/hEaWwPRkfF67y78RVD3t TNfTZAvsJ3mgTj/lIxzLHyLGu33N5F5FjDnWfIkQKCFYqIe5efE3ZGyRgt91QaKM6BxqlJk8tjBt qz9wyMaqXZu/dvndb9XsuDTxyu0mLnXV9EqAu1OvMccD4+yTv1Kwi8N74o6rOeroW7Puso60DtQB LzdztEJ4u9tiUm5msY32p0iLKlJV4rResbnP3U1MWFf2kJT9nn8r+8XUKpypy6RpwYOy7C/UQ5nU a4PsEMNE6XNz+WgltldPv0XEIJXkVA/vEVNCFWFSvT8zhyoX2gpNTwMjw2f2AJIc4a9eAb/NGRp4 fFotEA9YlpWQEmcFLLcEIpJaFihEb55StH6IiGZFwzOWfMRuSAUSPwSJHJWWRdiKrLCZv3RkbXvQ 7HvphoWpALu1tqYTeEOGNLgVg7FjIo+V4ciN8i7fRCJtl7mCoSJiVfyYvhJDe2xWzsZThhPS/2DW pPJJkjyhA0TYP11IFLSMRhUDO5gy2GbOlbL7fw3EE++Z+AOxCYqj44liiohUAj3cyFqZDwkkFzj2 LpzQ22Fo6TRsMSFfigIN8pLMxClJfPsGGANHZJWdxBQx6a09vhvPV+YajBfJi06iPCRZs48mL9MJ 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019126009116600 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 39db4ffa70..634439ab2a 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", @@ -172,4 +173,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 49e4e51c6d..1de9de0961 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 @@ -253,6 +254,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 Sat Sep 6 14:53:25 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=1757019293; cv=none; d=zohomail.com; s=zohoarc; b=ULyH+qX/CW6ahi7MU7/QXZtBWDnnjRSiPGt40c8ohVy9xJKzA0l+NW58YUqZzxhF3E7UoL7CsFShQuLa4QWLGVEORp8OzmBwjhS0lj+EvNAlQesFIvk8YTNVRlQJZJui5WTPcdQTPwbn4JWH6u/WAi3fbmPwdkYOqWR12ldm8Lk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019293; 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=GLBcd1We2+JMNajtTGX7HrYkfvAWzVo6VXZqDBpCnm02TQw2wECleoHlnrigFwep1w6UKxsJj+W2zipKupiItR+DCiJHf9VeVEA3jFRHrU3t1z5IYo6rDPDIQejF3faSNQGcpEXD+Yqjn9b1gXxuNSf4lwm0Am1ONA9Qjy2PoKw= 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 1757019293991466.8432597670376; Thu, 4 Sep 2025 13:54:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGu0-0006Xg-Pn; Thu, 04 Sep 2025 16:49: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 1uuGtl-0005wi-Ay for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:41 -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 1uuGta-0000zm-Ae for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:37 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B376560C05 for ; Thu, 4 Sep 2025 22:49:17 +0200 (CEST) Received: (qmail 2379 invoked by uid 990); 4 Sep 2025 20:49:17 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:49:17 +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 v6 21/25] target/tricore: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:48:56 +0200 Message-ID: <69d6bef3b97f71e6caa2de246d300912c037698e.1757018626.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.993729) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.593729 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=HbwJ1KlyH0jessT85JTQ8RyjUFprsOgDzDvKQq/zmlStOf9jHZ8dwhssZfcQD5AYZnQXxA+QcB os/BqjW5XiYsAeJ0R/udZGK8rAwH8wpdCOjmccv6u8UTnQHajlvOAtzkH/rrhZ7/qM2EetYDFJEC 5mP7G+KU4SfqudEyENHvhK/c4hAPsOFATAX+G7NTr9IftKTvjGBUnV+SFsmrBASD7Mr3O7TP9KUE x1RQM0i3QnuKV2fEPr19vW7WHirwt0u2Gv7+J7DJcRfQzsbzp25FZGM9CY1QjwAxdMm2lsi954Jf OlM5Rxmk/4Uo2tjAij19BYkDBeSpYyH4w1DN958DYfxiKVviCXyr1d6xF/FM265WdSY8KMyFE77o MDu/6vMhsbS19AD6Qujg2h3CE7hijym7x+USeN1Tqttj2i3b5hD0LN/PpoaAguSVZmrqdY/yYBKJ ZI4wrIVArzNep7Q8onBv0z8nbBUdnlPpKKfXnVHLECuvU8nwnc+O1OmmwnJ4au1PpHv4ERnzInsU aal2E4HD3HUoFPYLEJpr9TCjjleTtXzuHRln+bHX+HYcCNnII3pQJhlsunW8tq3uuduW0gRQmLvF k5PJBDG//wleUYLtQZAji9ImLl5r+BTMdb1uq3OWVmOJK3P1vmneLapjntgIrjNqfelSoPuqW0qH 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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1757019296244124100 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 Sat Sep 6 14:53:25 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=1757019198; cv=none; d=zohomail.com; s=zohoarc; b=XpoabjLVhxMSzuCnDGVNS3O/TSv3DJfFxD0Ug3xuTZnEuGg16G/lpNNUO0eR321fP0YVv1280fC13MUwWkKL+9/THPP3oFyvM69fXocLTfESPvCI5sEYLRsICGHKLWHcb1SoI6eINjodCPSaqtYqTWOQYqKkZXmzu7EKhfK8o7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019198; 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=+xSjbR7EcJ5Ey9edcbD4gJeC4mn0H3wQlKBcxivDjQU=; b=dW3zgzyJL6Qynh8Ljnw/gBgW4YgjYbd8gakwcjjiMGiO59LiekdfhYlmRt3FuxDncxVsdrjSDPmnj47ALXmvdYgLq12qQI0rv/ZpKRnzZ4QtObJAu09rAR0foT/AVV6Bpyq/TCEGBW3iJqD7NPidCXwTCda8eHiaeZ2yPlZfinw= 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 1757019198133754.5212803528891; Thu, 4 Sep 2025 13:53:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGtz-0006F3-94; Thu, 04 Sep 2025 16:49: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 1uuGtg-0005q1-Lt for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:33 -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 1uuGtY-0000zq-AT for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:32 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id F3D8260BF4 for ; Thu, 4 Sep 2025 22:49:17 +0200 (CEST) Received: (qmail 2401 invoked by uid 990); 4 Sep 2025 20:49:17 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:49:17 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Max Filippov Subject: [PATCH v6 22/25] target/xtensa: call plugin trap callbacks Date: Thu, 4 Sep 2025 22:48:57 +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.999869) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599869 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=TvAisglz35MKJSZs9p85pseD3eQknxSupu+M7mUEgdw=; b=T0wiw7j3szSMbJbhka3DFbKrkLrc37aHRt1bA15B7bbr5VcFF4mSCFZ00R5rck5UwUy097oJWB ByQ/QgRpfhcSxLs3QN4tgGIq7ob0OepO4ArNHlafz5WuMyzQmVz+YTPvNT59+Bh5XyZuNuTrF6lf 3UNdEHnFmMKChLF9QchIUwb/KJOYTlS7C8/TDzvKQh9EpjxDSRb1nyWJx+HSeVJCCiNItINdv+Ut 7v+VtZNLy9+7aHz6aEuS9dflPxy5c/2c5ob4I9a0OFmdH+QQx5BFOW0XKDxySro1nG26DBEZiJ2l iDUYh9xBTIdgJjL+7B1kUO2EPYXG+Nv1231UdPVCcavxvKLHKegZHWY00TsDjq1nrZn9E5GAHTHG s9E0aku0CkNnQN4IKK4A3mRahF9yRr40yHHT2V5IHkV1RVwcjdHjAj4f1qdWh/CmO3+lPSrkB2I0 pC19eFuxoBmGUZKWwtpbjefVm5NPqHfi5aMcbzSUQe+IoJDqjuvmt2ehNXDC1CEdv9gTad9LV+lc HlqeDmc7ZIsyWdp6t5MTyfj+xJ6y90CIRNGYUdx5pXGtfEKUJzwcB8BYG75pPGdAiBYB4WJyUMeQ M0g+0FtKZX2Xp3srWAjmgVF/7qy78YKL1mnwcvxiaCmAfPZyPQ3YHvn6FwSciRtDOWjMzqv4vcuQ 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=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, T_SPF_TEMPERROR=0.01 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: 1757019198918116600 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 --- target/xtensa/exc_helper.c | 6 ++++++ 1 file changed, 6 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", --=20 2.49.1 From nobody Sat Sep 6 14:53:25 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=1757019134; cv=none; d=zohomail.com; s=zohoarc; b=OZ4ViDwB4P5TlnlU3ehFUED6RNI27GFqjpu8JPS0FCKy5aWDy2AMZAnMfL3xYZSJnO9zgOVJvFJaPIYre8oUFxzmig9V4hpd2pxjoKVGJqUwCQ7A7hxTZtgJ+9yrEceKKCqmx6f8uaTzjDPKDjme1e1ZKoUzTCgt13a/t8Ox2Io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019134; 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=D+NUJw7/ipgVmbuCF9DZaj1ptx17pcYNXQ4ea1Er9zc=; b=Sbx8KaowWYSw48J+h3EydGSY06G/qkjtZ/1ek+guCtsxrM9D+ctEN7uC5/Voq301Aqp22IiibTvh1vEWbe5ICwxgjxhOc1/3NrMyEUnHj9l79L1ydv/5Bl4aUKtVMdQ581X6UtgvQ8YQ4fd4madrSH0JN7rLabXy234HJsk0gIs= 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 1757019134313528.6699270460269; Thu, 4 Sep 2025 13:52:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGu1-0006bX-I0; Thu, 04 Sep 2025 16:49: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 1uuGti-0005ss-S0 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:36 -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 1uuGtX-0000zw-VF for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:34 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 4C3FA60C14 for ; Thu, 4 Sep 2025 22:49:18 +0200 (CEST) Received: (qmail 2422 invoked by uid 990); 4 Sep 2025 20:49:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:49:18 +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 v6 23/25] tests: add plugin asserting correctness of discon event's to_pc Date: Thu, 4 Sep 2025 22:48:58 +0200 Message-ID: <073cad7dd8ae509ff64a2835fd146833b60c1f60.1757018626.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.999961) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6bA+cSQ7uPfSE8TI1kgQE3TU/Q1amvHJS4CJP6CUHhY=; b=WTZ7xm88MIV6WY40wFQVcP2XxGLacJlQ1Lvbkkx6xGI5l19aN7bBBmr/GRtzrO1TldpadAAb4P uF+uF9hjwodDbs3G2WX9PQIFEgGVfhBxzT+MdfZs56qElQTMbdcB3GQABIoJT110x4Bkz1K34Mjj klFZVZGYG8EULKE1XpWDZ86dKGMydnFgrnXHwqi11xgTKMEFR2eWY1ksoNCWykvGvVf4zCLdFaO8 4fojI9yEu29/P5XgQBtzBYruubyQaXw3ZKKM1sdN9xCQJPjoAUP402/OBV1xy2zdj9c7sN2HevmN ZJWA8yNkh7QdeDEnRCh/1kTkzGdAr2/A4IdpHTFcAnPiZOo0aKuPalSF9hPtVOsmsK7Np45yIM2X Du8qKrcMTHZiQM2UveiKTaiwYgq3wo47UldGyLF/Op5aXAzH/QMoX2/HLwrVk45Q6kSeSphSnUWj HWvV3C7hT8FLepuT7z18nlrNDdwpAePt9ufbLeRG30rb8kAsP3scLMemq/a4UI7eBDEu6jnnLjiJ wSIIGf8K/VIXCyobNDWm5BCTh6Rc3I3uPdtWDyQl+dHX5EULc6kNNLrta18RKcHVjHyuU2hot4bu DcAb1gyP4n/1NcvUXDquxoatHSKbcIVhM0E/cKxt18vblvKhHqvBRXLFA4CgRSteTWoXpfzRCtfs 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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1757019138023124100 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 | 210 ++++++++++++++++++++++++++++++++++ tests/tcg/plugins/meson.build | 2 +- 2 files changed, 211 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..f185e3948b --- /dev/null +++ b/tests/tcg/plugins/discons.c @@ -0,0 +1,210 @@ +/* + * 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) +{ + GString *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_string_new(NULL); + g_string_append_printf(report, + "Discon %s PC mismatch on VCPU %d\nExpected: = %" + PRIx64"\nEncountered: %"PRIx64"\nExecuted Las= t: %" + PRIx64"\nEvent type: %s\n", + pc_name, vcpu_index, expected, encountered, las= t, + discon_type_name); + qemu_plugin_outs(report->str); + if (abort_on_mismatch) { + g_abort(); + } + g_string_free(report, true); +} + +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) +{ + /* 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 Sat Sep 6 14:53:25 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=1757019286; cv=none; d=zohomail.com; s=zohoarc; b=NkS/t66Hl3JnzD97sIf3BWG8NLXK7fyxY0RuF2ujXA/hmjKiDep0d9qrPNcEVfkF9Qt5jn8valIWtBg7TE5RbwzGtDvAo+GV/rKWcE8pcWzjz2xViVAzCWyC69Ktb65Z3HSRuazBzO/PA3TNAkNde2AeZXQ1Z+56fc99/vz2uss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019286; 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=M6k55L7g3h/9/zWdGyuMUhwUBYXuoHn+WDiEzAH5sVtmHvLWQN22uR2VvW+saBic29KhWJx7qz/pQYtHilGiABC9ayai6e5bUUEljg+HzdhVcvqpn7hWLGi2wcdCce0vaGCrWqY/HEq80wU+Sscn/dkpQlkSkBSq+8AtAD9Oqx4= 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 1757019286807314.85255698667083; Thu, 4 Sep 2025 13:54:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGu0-0006Y6-Q8; Thu, 04 Sep 2025 16:49: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 1uuGtp-00068M-Np for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49: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 1uuGtd-00011f-VF for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:39 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id A482B60BF1 for ; Thu, 4 Sep 2025 22:49:18 +0200 (CEST) Received: (qmail 2444 invoked by uid 990); 4 Sep 2025 20:49:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:49:18 +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 v6 24/25] tests: add test for double-traps on rv64 Date: Thu, 4 Sep 2025 22:48:59 +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.999521) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599521 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=GtnvqD95XKsk2LdqvkQzffGuhlZZQtbBeHpDMgDGiM+uCpcHX7/jBI9z8e6NUjQSi2Rur7dFQh HiWaFJqVp7EnkZ+vdxR1v2FGcytVq/zFjfLSIjCb4Hu7ptxcVVOVMEUHNa8ALP0oIx/xlGVlp15/ F9rVzlg7iZmAFBqrHqw4iKKMRJGXipQy4dEoxutAg52JYhKZegtkMesoGcyG3ytuC/+P8GDZMyxu 891XXosLMFAPJyyuCfR4HiKW1czOjAs+O8CIQfYrIi0G8k8gFX3U5kKFwRYSAfyJo+2lpkuK30DJ pnPcFF+Enqu7GCx4rOXz/0/4W0lu3KXVul3w/COo8A4+SlF09lUApA05EA0ddaqlH3dzmTfCUTCS NdWjPg6pC9PtREeqGjmG5nqUlqY6a3m+0HJLiWNa3gSQ5O0mu2ke7nKVEPB500YYzaOKcFc3iuBt UNPojxPC1FOQgDuzo1tHjWEwvNhUjDD9NZ/sv+ECaDcfAkpIepLykTMiIK+64blB0PAvjzWdfqmU h6B+NqKwkNhviYD5H5v7Rs7fzL/k21556UJRzijjBndChUBXYhoyURXB+DXwJDAygxyOA/Q6mBST c58oONwC5R+kD+YyUUCG/qa8mQ9WnyY6qj5TYe3vp3deVpjRpSL2HnlhCrX1oJ5HscU+aWdJGstb 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: 1757019288336116600 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 --- 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 Sat Sep 6 14:53:25 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=1757019192; cv=none; d=zohomail.com; s=zohoarc; b=UdSnCwaJy/K4MvMiKS5HUdJaBq8Nq14LQ+fgpqf9Y30Lu4kpwky6jYExT9QgcKyxYLD87UiMkjLxgY7A4EwHcAXPzR7G7NRS2UK8p7NRAexjIyG+SC6Yzps/YUpawLYpCpxMMkhBrDkRrB24Stp7pmJ4enHvFwb+ZmrbPAXnhFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1757019192; 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=henBUgWRUncGI7KwlBw8X9HnIYjhachXNNNeFcjE8Cn6fD9WPMohGkpHLuROs5cGGNgK3FNH1Ml4GsFi3cAbOLJQvSW9IjOrKScUmaGc2odk0UypSnrHfutKLpB8YQiiq4XEQEBA59mxzTWW8+Kkrqzvh984TeNUYCk/HjUyjno= 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 1757019192743372.7385895032804; Thu, 4 Sep 2025 13:53:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uuGu3-0006un-Va; Thu, 04 Sep 2025 16:49: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 1uuGtt-0006Ex-D0 for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49: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 1uuGti-00011m-2l for qemu-devel@nongnu.org; Thu, 04 Sep 2025 16:49:45 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 006CC60C3E for ; Thu, 4 Sep 2025 22:49:18 +0200 (CEST) Received: (qmail 2471 invoked by uid 990); 4 Sep 2025 20:49:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Thu, 04 Sep 2025 22:49:18 +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 v6 25/25] tests: add test with interrupted memory accesses on rv64 Date: Thu, 4 Sep 2025 22:49:00 +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.796651) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.396651 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=TY0pT536o+ZHiEnQhsgtRx4ZNUf6S2pZiLT1gb/yjcik9RKdUnmUjTkyG5NGEd9mQkc1Jb0afI vo/L5CAqROcyN2s9IpYFsHlQ8u07uhcHrvdqTow9sauWmKKigBjRwy4zUxns5VS8rhmOEnpyCr+Y nbsF6kqSU+x71OIr++/1EddorRfWcpJxv8PdjYqMD05obdoL5IYygKi7mtSL1eJ8d9xMJmOWp2mr /yqYNs9L3qRTUl0frDIGOjcgGt57P8cP3tMCOX+PelVwjHt1vOb0UfRbpwfKvKYMOZtzTquBVzqG 43IuC/yM1kO0+LFt0qaFURxwxaOf8i7evaF+Uz2HTvr4ahejBf6tECerYTQGGpQkDHvZJP5mwdSi k/NfcqdQPaiJkGD4yn+/N0/J/N+SZZFMkN9uHmXuiYCx8QUsH5M+WaySrKxMPcPu/jcgfrxzbnN5 WOoryyWzZ/VLWiEHv7m8rb+5B0d07X794jJFihbn5cF893Qptl5cdbOXKEDA9GYL9FHd2dTpwaMN 5y0v5x/w2lftroUJvxGn84a11+0HW/I0UKgA9jzSEhZqFBnOlk1/cZBD5OJjCP+TrktkVJ0bJWs1 e1nTAIWJkmxuJ216aicRogsNkC7EwZqXkGNgPhzIYg0K2jYo5bwjWHl5CvQqrI4SWNeKsHR+Y4ja 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=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: 1757019195024116600 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