From nobody Fri Nov 14 16:52:19 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=1760887106; cv=none; d=zohomail.com; s=zohoarc; b=Gh7DEozRwBgEB9olerGYi1C99AJ1EwEL0BCJK/O8iVQtU/7GAymCXFwB5QVINJkbezMpM8spt3jgUAZ3sZNRuTv61BhhoPXXZkXUecoUNLxhS7NjVrRrZJif5l9O/EL3Y4KJSpAydkxaUvyztRF8ELbU+H54g8e+VJiZGXKwklE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887106; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ss1yy1T2q0zVf9CnRQlbojFXOsx70VKbdsGuIey0YsA=; b=I0eSqzyTTRAoN7zEwhTTeVxwiwI6DP7fJE6QsxdgtYWbpP89LRGF1Otv1o/ekXC2fOjnuKL8fxS2pZ1pyu65S+9pYRHR+CludLtDfcix06THZGGhAjJ0Va+tOphZND6UhGXtaiJLxJIfXMj0t0gW1vk/8qyIisqt5a7OdObjy5E= 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 1760887106703656.9782422797388; Sun, 19 Oct 2025 08:18:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV8m-0001nG-Ni; Sun, 19 Oct 2025 11:16:12 -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 1vAV8l-0001mm-Dl for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:11 -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 1vAV8i-00038s-Tx for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:10 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C572960A7D for ; Sun, 19 Oct 2025 17:16:05 +0200 (CEST) Received: (qmail 22549 invoked by uid 990); 19 Oct 2025 15:16:05 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:01 +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?= Subject: [PATCH v8 01/25] plugins: add types for callbacks related to certain discontinuities Date: Sun, 19 Oct 2025 17:14:50 +0200 Message-ID: <1bff3f2e662e94d8415d7b81bf4433deff3e62bd.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ------ X-Rspamd-Report: REPLY(-4) BAYES_HAM(-3) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) X-Rspamd-Score: -6.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=yVd7nR05hHdMlfOA7uD6MWQvH0T4W6yPyJICUYUL/Wk=; b=wSu/prkIAbGGyg7jKp80R9cncPmhuZQuX0S/jdvvC5MGNBeYbEW4gTM8hhNxqwVEPIig2fHckQ otzLPwAxWMDQAUQ70tFG6R7+DLTmC1hDDdMV4ijHBgfLxvbfJXX0M4b6hV+GYUQgjJGG64HG+14K W0itpbEzaK/ZrAODq78oPkBN553eHZmPv+iyJQj5YH1Fm1w2de9eQb1aEpvV0t0owCmLLdiMTyt2 8eQMIOHZi1yTnQeOV8LxIapLZe1YLT2hsMfIyU+/yNbamX+hcDbGHzfM2zL6/LEfNKbTTkcYeGN+ Y3rS/AMNPk/pZy30N2bYfebGC804HnUoQs/0JOpOuyBxLEEN0gJxU+hEOX7Kydg7834pF/kYgP8Y FuOuJmT6A9otrdOwdDzyRFB7K1M56wTPTEiP8QVDg58Rf1/z78xMMjjiG/5K1WfSf591o59dNcSm 1BwSFS+FNPf0Bw5RDJFiqE+Zq0N9S7vvav1nOpZ8CdojNyvCi5i5RbV0gnwuTZuFmqMiKt8xhOV4 r4apE29jkhPc0EnUMtQ9b69YGxMag3WmFwXqypSlPEMyD1NRlTduJOjV9s/jMuLuKIIbFG7ONweo edBgG1ukdZI4z8cYZCneVPsJfAFvDKhapjQw/nr+gq/xQz0ya7HFpQlauXX58iZ0FjbnFJrke8eu 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: 1760887109245154100 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 Reviewed-by: Alex Benn=C3=A9e 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 Fri Nov 14 16:52:19 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=1760887024; cv=none; d=zohomail.com; s=zohoarc; b=dlH7Y+HKdd1YrGEhurZ/n6ggSMT2QslGp/HYfsJFSCzfyGuFn0+JsJY1REHG9looV+QZrZhurrom0bdxCB4FuXS+sDOasUv6r4o7gu+pbd/+Soxr4h2txcT/+GHhpCIiTYlU9rVnRnP0ZmoeLEikAYCJI9mDEbs29yLNh124sRE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887024; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=I3o5Ur994CWayXaCzItTnCk2LQPA3Yo+/+6P/iE20PM=; b=MTPNDWH4eCYtUxPyH8AdAgTCP4ZU10HOkAcRwSfiOeIeCRnVM7/8SavdXK3Z8xvKdcjdFCCVRt2SRZreYLSrKtZXCUhcxQEYMVpRfcw8tYgVeDNdIca1zzePI2LGZhizOpaog2Q8ASwYQYp+EcK93Ex+W4V+L50nec1Zo1Bhypk= 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 1760887024268121.18119549548226; Sun, 19 Oct 2025 08:17:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV8o-0001nP-QD; Sun, 19 Oct 2025 11:16:14 -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 1vAV8n-0001nH-5G for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:13 -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 1vAV8l-00039G-6s for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:12 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 04CE360A83 for ; Sun, 19 Oct 2025 17:16:10 +0200 (CEST) Received: (qmail 22621 invoked by uid 990); 19 Oct 2025 15:16:09 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:07 +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 v8 02/25] plugins: add API for registering discontinuity callbacks Date: Sun, 19 Oct 2025 17:14:51 +0200 Message-ID: <3a521f7982dfe1a2a71b4237f6a71c7b10da6598.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-3) X-Rspamd-Score: -4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=QtKA19sfR0JfExEgWblMeLRIoK6HCqGXkcD3ErSDWR8=; b=HU67ZTj2qFYuZJpjRr8hvZkQmjjzjarAe/nSm5BIAxQt/+wLofq14VELlAO31U51k+V/blA9Oi 7G5YJGfm4hX83doSoO5el/ejz2fLl0mTI1WnoxrW+3JsXVSTmkjaewzVDRcpPahWk+y8DPqfXXaE 4pWUWOj6IXNXfVsnIOqCVIGkVVmPIC/v/r2PKh09hfAMVyLZc5ZHpku96OkEMdsdw8UG6O3xsYBr NLlgf+EAkOe5r1iXGa9f9oqoAfp1E2lwObr2+G0o4P6mV7KbfhayOgdvL+7lv+2JaaWjHRYT3pEH J0V8+xGgmNcXfFGPR9KdPk+7yHwhKxV+XQPE/ywF9ZFZbf8K5Wsp+iYHXougRCBrvpwKvHafV3Id qZEce6BHSxM4X+zabiLQrkcICqiCTecM41gr0V8Rt7/p4vGrFbfqxF7GkbYel/B97DvUjqMilknG oZiC79HxrQLs21yUsgXF9ZpN83BxMdIGft2a1pVN9tlwSgAzpRHN2GzUOk2FnRwgrvmMbai0hh5W zqXOy5gzwiawxE8lgu3QgKE+5nbEMbSPr2UMJOPc+DOYiCQ4sBp1yWqk+D75zkaIsSXVE9IXk7g+ C5oESBvloGVq8EjegHDnN3maEBTcgvQmJK51Y6ZQAdXNrE2dKo9GntQjClWBF3MWVVvT49oZepzv 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: 1760887029275158500 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 Reviewed-by: Alex Benn=C3=A9e 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 ead09fd2f1..40d001d39a 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -569,6 +569,21 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_i= d_t id, plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); } =20 +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id, + enum qemu_plugin_discon_type type, + qemu_plugin_vcpu_discon_cb_t cb) +{ + if (type & QEMU_PLUGIN_DISCON_INTERRUPT) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb); + } + if (type & QEMU_PLUGIN_DISCON_EXCEPTION) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb); + } + if (type & QEMU_PLUGIN_DISCON_HOSTCALL) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb); + } +} + void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887162; cv=none; d=zohomail.com; s=zohoarc; b=FPEqSgqNOpqPB6WQ/13Cyx42ogwWiP5fPHN3WQLeFclOp9fWzqgjcTKpiS7iWOydoTkj7kz1UTDLdJT+8wg0os9jIy1G3c3jiOe3Nnz7WaZXbvk0fiXIgXErjQRUSHdLdtpamuJhYiKv2VGd2b8FaEemIkCrQm3CqxqA+JQV5qI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887162; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3Zvbc+Klv904SNe9upTP7tPPH545R74vCPSDsWPMGiE=; b=XHZop76IBkru0qHFi/f8/VtMyftbkz6t8WYeLJMVNWMdSlaWx6jbdTDJiIW9E/MnuyIb+Sq8nnTkVvBW9kmmVng0gHYtrUHadvYfBf/4AEMzKYr+hhhaev4sqRTyDGwpOmHW+tABdwwLFtwE2bkj6FwtuMZdMxlFdDgFkw3D3vA= 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 1760887162537248.7928223519391; Sun, 19 Oct 2025 08:19:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV92-0001sJ-Kb; Sun, 19 Oct 2025 11:16:28 -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 1vAV8s-0001p5-Di for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:18 -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 1vAV8q-00039c-NS for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:18 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 324BA60A7D for ; Sun, 19 Oct 2025 17:16:14 +0200 (CEST) Received: (qmail 22695 invoked by uid 990); 19 Oct 2025 15:16:14 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:10 +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 v8 03/25] plugins: add hooks for new discontinuity related callbacks Date: Sun, 19 Oct 2025 17:14:52 +0200 Message-ID: <8beeef05cf137ca25320930c5f35291ad1a92275.1760884672.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=ZSHCzgddnSxTNbITRzGkKXj5uD5IHXB/jqzWZ1YJNrs=; b=tD+23aVY+8Rtg7ZIbcBhMvuUXyLYMHkLvFdjrH9gITpDCj+EwpA9CkbbRGsGbjdk2D5vll9Va1 A2Z5R4OerqMSTZUrHie5vsdigVAViWXPIBmm06eByrP7G+3tx3GFiJFWkESCpLD4QTu49To/07Mp 5ZPnvKmkIoj0XlcDaNZnQivh0WKGL6slbIzWK2GYdcPfGsr3zd3T+69yazGqsflBcWzxXH4kHJpW dXyBpRm4smBcviN3J7R6SqOPqzZ+2z6+1ar1TM06RlCyciRjVAZ+zaML7490yS6ueJa/gmQf7LPD /64q6eng6iJbU0ZYNbGroEpjdKAoAgjdRNH92xjO9ZcqyGc6gKcBEyM5IcLRzdS5nLf6lVyNFtrc lFvACASxerzalH49iJYeuJfd4fXjx+9KnBGvvh/4Q7fd+MXJplj0mAsQJBfRW+EktlvA4/yI8a7Y Am3+mkTE7BfGQPPISY9xkNXcQw36+sHMIjAc9hbChQMkqL9AmD/FJTHJrRL5+FnYWOUxVxkfl9Fq JFQ/dbu+xff6a7dTkxB88CD+9VTtpziRnMJ/1b44YbGCeh3ux5J8FbdcgQ9lshgHOZDuu0DG4QvA dEKcBfQsvnbI5sWAt16YBcqBsn0L+KWyDIcZ9c0CwsV2qjEE0/Pgy0L2uV2XEz0PN/pPhtny1Spq s= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887163737154100 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition, we recently introduced API for registering callbacks for discontinuity events, specifically for interrupts, exceptions and host calls. This change introduces the corresponding hooks called from target specific code inside qemu. Signed-off-by: Julian Ganz --- include/qemu/plugin.h | 12 ++++++++++++ plugins/core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 8cf20cd96f..cea0a68858 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -161,6 +161,9 @@ void qemu_plugin_vcpu_exit_hook(CPUState *cpu); void qemu_plugin_tb_trans_cb(CPUState *cpu, struct qemu_plugin_tb *tb); void qemu_plugin_vcpu_idle_cb(CPUState *cpu); void qemu_plugin_vcpu_resume_cb(CPUState *cpu); +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t from); +void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from); +void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from); void qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a= 5, @@ -258,6 +261,15 @@ static inline void qemu_plugin_vcpu_idle_cb(CPUState *= cpu) static inline void qemu_plugin_vcpu_resume_cb(CPUState *cpu) { } =20 +static inline void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t f= rom) +{ } + +static inline void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t f= rom) +{ } + +static inline void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t fr= om) +{ } + static inline void qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t= a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a= 6, diff --git a/plugins/core.c b/plugins/core.c index 40d001d39a..35a252d272 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -105,6 +105,30 @@ static void plugin_vcpu_cb__simple(CPUState *cpu, enum= qemu_plugin_event ev) } } =20 +/* + * Disable CFI checks. + * The callback function has been loaded from an external library so we do= not + * have type information + */ +QEMU_DISABLE_CFI +static void plugin_vcpu_cb__discon(CPUState *cpu, + enum qemu_plugin_event ev, + enum qemu_plugin_discon_type type, + uint64_t from) +{ + struct qemu_plugin_cb *cb, *next; + uint64_t to =3D cpu->cc->get_pc(cpu); + + if (cpu->cpu_index < plugin.num_vcpus) { + /* iterate safely; plugins might uninstall themselves at any time = */ + QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { + qemu_plugin_vcpu_discon_cb_t func =3D cb->f.vcpu_discon; + + func(cb->ctx->id, cpu->cpu_index, type, from, to); + } + } +} + /* * Disable CFI checks. * The callback function has been loaded from an external library so we do= not @@ -557,6 +581,24 @@ void qemu_plugin_vcpu_resume_cb(CPUState *cpu) } } =20 +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_INTERRUPT, + QEMU_PLUGIN_DISCON_INTERRUPT, from); +} + +void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_EXCEPTION, + QEMU_PLUGIN_DISCON_EXCEPTION, from); +} + +void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_EV_VCPU_HOSTCALL, + QEMU_PLUGIN_DISCON_HOSTCALL, from); +} + void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887083; cv=none; d=zohomail.com; s=zohoarc; b=nNnW/PX7NBNoFPCfGpdg28u5HwVszdMfUWHi6+2zTJZza/Ja4qBlToUO+Co9wHt/zKvvRW2vR5h4RVjxlPUXUHVlM3lUW0aBoODITbRgPS+ruPEcrS4zdMcv/ZQV2yDKJY+aHal2dcZ9V6jcb2cXdWxzxT6dRIOWcgR846b/WRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887083; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xPjECZXceD5cpGzOwVCv7gFrHfSoXxPGCbCGg9zUe7o=; b=M8sVYNdk0XW/fByDdZSxBD95WOo5ykdLoD/5CHStVMUsDSpIxnHb3LoUUAHcebSWAk7R/nZtn7V7dSoZxyNo2OzNdB97+9pJnj9McpZXLGHp7xocG5dXkdT5Ouvl4DRAaNzo4h61bkK7cxEpCoMnm4iaSbvaymwawLZ3LWv7rw8= 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 17608870838971006.4395269913592; Sun, 19 Oct 2025 08:18:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV99-0001vz-DX; Sun, 19 Oct 2025 11:16:35 -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 1vAV8w-0001sw-90 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:28 -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 1vAV8t-00039q-Ja for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:21 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 8184B60A9D for ; Sun, 19 Oct 2025 17:16:18 +0200 (CEST) Received: (qmail 22776 invoked by uid 990); 19 Oct 2025 15:16:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:14 +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 v8 04/25] contrib/plugins: add plugin showcasing new dicontinuity related API Date: Sun, 19 Oct 2025 17:14:53 +0200 Message-ID: <056b017b5524be30120f3b04eb9dc588d99e7968.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.999999) X-Rspamd-Score: -4.599999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=dqybkAOfRtXHelEez94qnN/FtC5ilBJlP25tPvkm2xI=; b=HsyJd9xDmUPdytO11zvB5jz8FHws2pM1kTgUkggUzZKQl1WUtC50NUrg0kxpzdKFq6vSbNV7mu T1eO+5pTzAPYVtXLyTitHpWxIeWcyYeWmWqHYUHyhsFgOhiRhjkkJDTQ6txtQYdG/udzDdT/iIKc +GK1SbOSQlhlqJrZyCFL97TTzfa/5TA7nemOuYsT+sKwkEZJWbe3OviNollNtuFHTESHc1r4aXt/ eYBW7pE4EbHHg6C3d+A5LuA2cDJxFPLNUwN0hd3MCP9dCM0VoU4jJql9iKA3hARISccmCzxWL4f+ nnSqVPoZt1IMg2pLS+I1OPPebbRzXvIQQLUHSMutMfNZFFTuJ9q1IR1fO3f77q7CMjsBVtJK0e50 zRGY0Ithn6z0OG1JiYK1xfN4pARBiYcjzDEW6KmpZeIOiAsiim9b6hiD8e90Cc4mEoyUPCjo2mp7 Jb8XtvIbSqTxPhjm3mz3RJL6vvE3kHrhWutRRCOCKR/73V3Wx9p0JWUBvDhmhKIzw7ypdZL4cVLt wc7Bv6qGKa4tuxbZESwfYf/FWRtRs30KVvve1wXWm7l/Gy1UIsx+/jpc2XgnDWCeAzIKYcBsZeL5 51quIPjm7cOV8GjeJJ86j6S9sc68vPT4Jvri4koJ33T/l8yt7xqZU+RYcd0UE3XZ/VU23PVkFlKj 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: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NEW_PRODUCTS=1.184, 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: 1760887085816158500 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 Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Julian Ganz --- contrib/plugins/meson.build | 2 +- contrib/plugins/traps.c | 83 +++++++++++++++++++++++++++++++++++++ docs/about/emulation.rst | 8 ++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/traps.c diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index 7eb3629c95..eb944b5159 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,6 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', - 'uftrace'] + 'traps', 'uftrace'] if host_os !=3D 'windows' # lockstep uses socket.h contrib_plugins +=3D 'lockstep' diff --git a/contrib/plugins/traps.c b/contrib/plugins/traps.c new file mode 100644 index 0000000000..d5ddc0f3dd --- /dev/null +++ b/contrib/plugins/traps.c @@ -0,0 +1,83 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2025, Julian Ganz + * + * Traps - count traps + * + * Count the number of interrupts (asyncronous events), exceptions (synchr= onous + * events) and host calls (e.g. semihosting) per cpu and report those coun= ts on + * exit. + */ + +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +typedef struct { + uint64_t interrupts; + uint64_t exceptions; + uint64_t hostcalls; +} TrapCounters; + +static struct qemu_plugin_scoreboard *traps; + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu_index); + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + rec->interrupts++; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + rec->exceptions++; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + rec->hostcalls++; + break; + default: + g_assert_not_reached(); + break; + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report; + report =3D g_string_new("VCPU, interrupts, exceptions, hostcalls\n"); + int max_vcpus =3D qemu_plugin_num_vcpus(); + int vcpu; + + for (vcpu =3D 0; vcpu < max_vcpus; vcpu++) { + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu); + g_string_append_printf(report, + "% 4d, % 10"PRId64", % 10"PRId64", % 10"PRI= d64 + "\n", vcpu, rec->interrupts, rec->exception= s, + rec->hostcalls); + } + + qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(traps); +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + if (!info->system_emulation) { + qemu_plugin_outs("Note: interrupts are only reported in system" + " emulation mode."); + } + + traps =3D qemu_plugin_scoreboard_new(sizeof(TrapCounters)); + + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, + vcpu_discon); + + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index 8a5e128f67..92c219119e 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -1015,6 +1015,14 @@ interesting to generate them around a particular poi= nt of execution:: # generate trace around init execution (2 seconds): $ uftrace dump --chrome --time-range=3D1753122320~1753122322 > init.js= on =20 +Count traps +........... + +``contrib/plugins/traps.c`` + +This plugin counts the number of interrupts (asyncronous events), exceptio= ns +(synchronous events) and host calls (e.g. semihosting) per cpu. + Other emulation features ------------------------ =20 --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887053; cv=none; d=zohomail.com; s=zohoarc; b=MevgXwNsFSMW87EGWjYn+e6414+JZtiP+T9xzVpF4HGP/JGMIcz0GMwjpi6onZlqxFamgX5JAt6D4lpNEGfGPVBOKqKVYmb1fBMwQIQJ+QqJkmhjsvCqp0YphLyrZXQXWsYSmEIi1Q+Pl6Z7ruounw5Wt0DRic1R2QqqAZvDGSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887053; 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=IW8N9LNDR6V/wcGVALcFwmBDYz3CoWdguSTwlZlJUfMgxE90Vq8JfczgrjxtIqf8B6iQHsmTR6HuXWI4qWsmdaWTGHu+k4S9h2AU8pobRpoyQCvHyCxSZ3NLJk8K+grInb+RAbMeeODpEIsWJyF9DXz0ziFJv9+rTLo5cj3oT/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1760887053868861.4949802790709; Sun, 19 Oct 2025 08:17:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV99-0001vm-1F; Sun, 19 Oct 2025 11:16:35 -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 1vAV8x-0001uM-OC for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:28 -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 1vAV8w-0003A1-1R for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:23 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id BFEBA60A8A for ; Sun, 19 Oct 2025 17:16:20 +0200 (CEST) Received: (qmail 22822 invoked by uid 990); 19 Oct 2025 15:16:20 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:18 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson Subject: [PATCH v8 05/25] target/alpha: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14:54 +0200 Message-ID: <78ba254c812a91105bf52f6f0ce73774ee2be265.1760884672.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.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599999 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=fXwtBveyFvq0AI6PHHuv98HGkRO/VFi1/YIrcGquxP3qvGKJFxhn9LEqWREm1WCXFEi7x+F2dX cghulsD6f9CsGzxSy6H8moihkLuvgwKpoSNrd7k4cpju85tQCl7s8c2ish2kFHATrDdqSMsQO72s qf16l+eaA0EaOOzerl2ZKAFyel3d3cz/vzM2k8RCUOjUai2Pv9pvJv+TjC5C4B6dRV4gaeqk8FaR jWW15fbxvTrUb8C5ti1Nff0rQiotM46EAV6jC2lGnu3op4XgqVxN7fT3rPxqHBUVoo7ToQ34SYXl YjS/IYkgwB2OVtJF5edhKyBvIeixBC50SRuNB7FXGHPGcscdwXjbxw91pMTEvAJfXly63k4LXdzr sT0qI2HLKMQeUI3O8UOMhZ8nJFpL6c16uQiS6/zgyA5FU8/N6AJCuZ9iAP4Kf5/jtUv3UA7a0DnS 5MA+jCvHkWYf5GvcSyV4mv68v3MhQPT1XWg9rUcIfvz8V+ZLMokRXs5KL4dnj1dsubqhxPDuocLz iADYgc7Dh16E0kygOaqduRENhFP6+1P/BigFHRqCPbsMTgWsQH328UTXGcVKIfSylzW5V+7kG4cU 4Ky+RuodrPbrzWXt7OWXgyqN9rhJ5zCwkDhBIAjTqywlANf4yKNuiav0WRu2YemIuFyQNz4fmvIg 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=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: 1760887056794154100 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for Alpha targets. Reviewed-by: Richard Henderson Signed-off-by: Julian Ganz --- target/alpha/helper.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 096eac3445..a9af52a928 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -27,6 +27,7 @@ #include "exec/helper-proto.h" #include "qemu/qemu-print.h" #include "system/memory.h" +#include "qemu/plugin.h" =20 =20 #define CONVERT_BIT(X, SRC, DST) \ @@ -328,6 +329,7 @@ void alpha_cpu_do_interrupt(CPUState *cs) { CPUAlphaState *env =3D cpu_env(cs); int i =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { static int count; @@ -431,6 +433,17 @@ void alpha_cpu_do_interrupt(CPUState *cs) =20 /* Switch to PALmode. */ env->flags |=3D ENV_FLAG_PAL_MODE; + + switch (i) { + case EXCP_SMP_INTERRUPT: + case EXCP_CLK_INTERRUPT: + case EXCP_DEV_INTERRUPT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } } =20 bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887167; cv=none; d=zohomail.com; s=zohoarc; b=McShkrBo4f4cpPPYwz3ZzN0jBXRXd5ybCbGsyLJgEzBuaGbRRWFRZYFTo7AX6LkDkZJoHhYkZtb9NQlXdG6FT7uE+6jLC4vzvCFjAXkVLIkTWDMB6cKj1fXM/dzkInveox56vgWP7WsDdHVxkaezlI6KXQY/duSmNxqtWlBD8lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887167; 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=3r/h24j7fACCaPNAa08+kDEwHsYpHCdS9CjEfzr/uxU=; b=hymmIwRDSXSiqeIqtSpHd2iYOkG5SgZift9yFVNJKcpJ2FFuR9/v/EURd5jHqSDzuWBfGM6m62KR8mP0D9SIeh42VrNWIgOY0xGgYd/bRJHv3lj4Oqxh8kktP1OYXX+geoiP592xPrucEJcVNuh+Vn9aUchOmVJAMT1DJwfct0g= 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 176088716790086.37172785566952; Sun, 19 Oct 2025 08:19:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV97-0001vU-Ae; Sun, 19 Oct 2025 11:16:33 -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 1vAV91-0001uY-Oc for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:28 -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 1vAV90-0003Aa-32 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:27 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0AE1F60A6C for ; Sun, 19 Oct 2025 17:16:25 +0200 (CEST) Received: (qmail 22893 invoked by uid 990); 19 Oct 2025 15:16:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:20 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v8 06/25] target/arm: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14:55 +0200 Message-ID: <57010cfd617c50a0d539d7d69b2ef5c891f2f360.1760884672.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.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=eTrUncCA6C2WPlUgxKZyYZpPBpx50vqDZF2D9sdp358=; b=pdsX6meunpR1mlv3GZWlKkcnPiZVp00qMihKqdzhYftImRoJ9MKoGLYnWZkst8RN9Y5lvmZ+Sk WFqO43NpafuKD9JGAD0WUO9N80qbu6dns90F+fVzOOVLwbRDZe8k5lMxoOM73nkkqVybfvLjl/6V s/oafSILhXAcyzFJq5BzNqGSrtyfht7AwvbrltV714Z40ZIkaqIXd9NrKeT/H0AWJ9QutAJwIRj7 AW98oS9nHjZZlxyymXrH/LHgEkwDgDW2ywcvzi5Xey6+4037cDggtTWVCm3x8Q3jXKRHym5MpDVi sVl0ABWC9Yym84Wdr0M/Qi4+Dj6pnjutTI5RkrRxBikbUbh4VaLht/dJPoWvsutzhGZEmXdS1oWk RNWOX1wjhvyuQnzzHUGhOgDd+W7YLwtYPUvZZh0vMGa+pQWOZe7gx7jKl+n/DiBV5ityOBfIGjiq T/LGF6le1M8WEvlbrJTiK0eN/oRZdFOIQxY67f/yG7YStoUa/Vr2E9r1Bu5tPMaskbIM1x4rC/ZE IIEsmFWQtNLFPMuQ4TDE2H2mRtixVOGbnLKl7G/SmzgqObnTMJGI99Z9lVUJkWmFJipmFq+NpBDM yYiKTA/vh9YAkgA7fw/MvHOmAO90e4aoGidU2gPfXeePDUoCD1psukMqt5Z577jNS6DuoSk0pAgd 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887169873154100 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. Reviewed-by: Richard Henderson 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 167f2909b3..c30d77bee9 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" @@ -8715,6 +8716,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) { /* @@ -9405,6 +9424,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 @@ -9421,6 +9441,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 @@ -9432,6 +9453,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 @@ -9457,6 +9479,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 f539bbe58e..6be044b29d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -375,6 +375,7 @@ static inline int r14_bank_number(int mode) =20 void arm_cpu_register(const ARMCPUInfo *info); =20 +void arm_do_plugin_vcpu_discon_cb(CPUState *cs, uint64_t from); void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu); =20 diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index d856e3bc8e..3fb24c7790 100644 --- a/target/arm/tcg/m_helper.c +++ b/target/arm/tcg/m_helper.c @@ -23,6 +23,7 @@ #if !defined(CONFIG_USER_ONLY) #include "hw/intc/armv7m_nvic.h" #endif +#include "qemu/plugin.h" =20 static void v7m_msr_xpsr(CPUARMState *env, uint32_t mask, uint32_t reg, uint32_t val) @@ -2194,6 +2195,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) CPUARMState *env =3D &cpu->env; uint32_t lr; bool ignore_stackfaults; + uint64_t last_pc =3D env->regs[15]; =20 arm_log_exception(cs); =20 @@ -2361,6 +2363,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) g_assert_not_reached(); #endif env->regs[15] +=3D env->thumb ? 2 : 4; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; case EXCP_BKPT: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); @@ -2427,6 +2430,8 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) =20 ignore_stackfaults =3D v7m_push_stack(cpu); v7m_exception_taken(cpu, lr, false, ignore_stackfaults); + + arm_do_plugin_vcpu_discon_cb(cs, last_pc); } =20 uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887155; cv=none; d=zohomail.com; s=zohoarc; b=LGgFsvMBJrLmu4k+7ruHkuBzxtnE9MuuZWaRMd2oXiZB+n+9HBzw5YOapftajf+MX9Yrm3mbaqk0CnxaNP5JypF4ftZN/uZYrrayv1ZUefOWd9PJTHneTcMdDKBiC49rsVikL6Tr1P8uXZ+2fc8kdbFhZJisu1zgwr2g0DotC+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887155; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2Ft/NUCkLxO2eY49vMtxcP5GmPhCIswNUkgiv+pX6c4=; b=O/a3vJL7llUOPJc9kl8ArRUQDIU08aNh9X0eSkI/Tt/Ry45WY2MBplk25g1MVacz9qaBrX6pLGa/80D7ikPaF9KmR8u3RwdZOzE0gpDQgPXmGGO7j0yBmz8ddrdU2dXCciL2YYDbBHbt2pBQE/IMttYomuuofAf1xBA9vzPqUr8= 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 1760887155450131.11557635069425; Sun, 19 Oct 2025 08:19:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV98-0001vi-1M; Sun, 19 Oct 2025 11:16:34 -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 1vAV96-0001vJ-8K for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:32 -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 1vAV94-0003BA-F5 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:32 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 66FAD60A6C for ; Sun, 19 Oct 2025 17:16:29 +0200 (CEST) Received: (qmail 22990 invoked by uid 990); 19 Oct 2025 15:16:29 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:25 +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 v8 07/25] target/avr: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14:56 +0200 Message-ID: <81eae4d94240303cebbbc8638841249bd7536ede.1760884672.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.999884) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599884 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=2UlKhbKoOoVQGSJ3KTG/q+t+0tUNYOPi6CGni73Tih0=; b=PAP+mvK0AYON9rydNo5drzp7BYiNMLR0B1aa2hhv56xrmR0yw2V1OAUVC6loZmJQNtcVG8tlQD HcxLExFZCq5rFpl/zRvvi6wp9v61mLWFuFXai6KP3c3NLKpKdW951rNEow1vivZBFZD8MmYTdMR9 yY7a1jvpX85jr4BwDcOkYRoyWLIsrgjAqdlpvEkn00wQ+W1xxOxAINvajGlFYKEFwRTznePyB8El FIWayMw6EOl/APpAm+8xCoqAqiBwm8bRdUz/ubW8NGTwjXOLw/TCCg/dCXeMq8EW4SQclh8OfrLr 5/HRqqF2n77cZcILcH4z3pUZSLeNKupnnBYaXPanSXY0aqS6c6HmG8o8A53qTmGq+fXfhhqvTZRz Dpc69eGMCrHxmAQV/gtpptt28QD3jYYDS/LVjQw8c08pgmaTh1EU29RSn8/tFHxb4JOsuuthla24 LLYZkKbhZiC+gTIYZQMc3ELSklOC+sV1sea/jxlUhArq30cRUSf7eHmHwGAGCLsehXFCOdjFurPy TlEqZ8LMpbcjvRGrsrRNJu4Z3cIzZY/mcIvqVnPnyDHagL9i6WLejUPLPIDmAXpUUcf0xvuCdlE1 gW5agQIpPXc7iOdWV3LyGEo8v8KXhaT8m0agm3nPQ5wv1nlc1b0Yee9RVIOx3+evw+shesxQ5u34 Q= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:1a50:11:0:c83f:a8ff:fea6:c8da; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887157827154100 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/avr/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/avr/helper.c b/target/avr/helper.c index 4b29ab3526..365c8c60e1 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -28,6 +28,7 @@ #include "exec/target_page.h" #include "accel/tcg/cpu-ldst.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { @@ -102,6 +103,8 @@ void avr_cpu_do_interrupt(CPUState *cs) env->sregI =3D 0; /* clear Global Interrupt Flag */ =20 cs->exception_index =3D -1; + + qemu_plugin_vcpu_interrupt_cb(cs, ret); } =20 hwaddr avr_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887136; cv=none; d=zohomail.com; s=zohoarc; b=JkeSyp/kPP8/VW92QB3ssZ6MBLdXPnh6/GczO84uYSjiXJ/XJ3HUUTdlKxOX4/lhzL852q2F+C3Stw0Rw5v/SvHhxK1f/1p7e+m8hnxZq1NUzLf+Am2SVQ+xFg+H6lRGcJribvHdcmYgo9oJoXfmHHp+lEsxPL4NkbAgJb27wC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887136; 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=QP+x9q5SyUQ3FFAX+oMc++fFiFTP4Q/2GUQalA8uxG4=; b=dnfS15n8PftBvJCZ6Px06Rmq17CYS0Rw54+ADl5Ru3NJNpawzSTYYfuSExgSWaekR7JiyINEh8q53Il1gODzdGBEwnuwEaZMHPJMkggkKVv2t6VIs5y8DB0gHVq0W7p3gSp2IPQE67Rt3SASRWw8J37CUCkmYRO3Cg199xsdYG4= 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 1760887136462938.7971375259035; Sun, 19 Oct 2025 08:18:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9C-0001xx-M6; Sun, 19 Oct 2025 11:16: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 1vAV9A-0001wG-8c for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16: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 1vAV98-0003BW-OT for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:36 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id AB24A60A75 for ; Sun, 19 Oct 2025 17:16:33 +0200 (CEST) Received: (qmail 23117 invoked by uid 990); 19 Oct 2025 15:16:33 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:29 +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 v8 08/25] target/hppa: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14: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.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=PrAAKrvTEoAw77iOkjbdm6WPBb80G5xPz9yg7zljNC4=; b=FOjxn2xUeclito7V4p3KW1c0UZ8GZ6gnvSw7Z/RF1BmlD6PNGSbMP8o4UQYFci2I+oK+17GUMv s/SzAcFA02f66gSpyvietB4PMgyR0XviI6vhbovvgRal5BE3WX+lLc/HUmx7XtR1WCPDjrQgHQ6V /pOJWld+DDxJrw2/E3pCun2JWoOTKySfZjIVXvWCGzSkM7U7tv7lUob2EzRu5s/RUTHuH3X75cyy 7H930fgcsK89vpPrqdRi3iNdjwQspel2lHz239Lq0sCQEl2WhoCzGLZvzcI6yY1dfw+pfCHDlfjr VMz1U7zE2waxrV2HYE54p667sbvZzbCLMc+GP8224qsvJQf4g/wvoZBrRqse1B7/kTEmEjD8xbGN 8XOs0XE2z3C8Zloypo8nPYlmVPjHZVlPla9qJS7f6TSkFnXITwwFonH/vwfzduI8R/RA4oM2LWal F+3YE0wGKH8gGpx8DyEhy2kxfXscFl1RsSSBBmwxmSoG3PfdSO8EyYEkGCXcMoSVakvV/A5HQ8+w e7mHGgIP5DOD8+Cp03ufW3RicekKBJbyl5p22Dw1BW1E0qhV2F6Ppf55HoNouSBK5FvQwncVscUf WenvyIMypyyy5C4xBWAcMR3sQ8l/OI81jho9TUzAbwnvbfJM2cZqaW/UQCyqO95f9+86N4bAHk68 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=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: 1760887144772158500 Content-Type: text/plain; charset="utf-8" We identified a number of exceptions as interrupts, and we assume every other exception is a (syncroneous) exceptions. PA-RISC appears to not have any form of host-call. This change places the hook for PA-RISC targets. Signed-off-by: Julian Ganz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/hppa/int_helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 191ae19404..4e4869285b 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,21 @@ 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; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } + if (qemu_loglevel_mask(CPU_LOG_INT)) { static const char * const names[] =3D { [EXCP_HPMC] =3D "high priority machine check", --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887040; cv=none; d=zohomail.com; s=zohoarc; b=VVR4anhs4/YfOgUcOKs4RDckl9y4zTkkU9J0txiZ/+5FIg+URfTu4/DvXP6olcL+udZNc6hPy+uAO36R7xd2YSt6oDN36kYidvGn0h8pK68IaJwz9xZMBw66N3LKqnrM0ZUTv8/brv/psi7V9by9pLAvYyxMrUpd0Ijw46S7G0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887040; 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=sc5uheGlvDe71sMUdhs9jRIJnXn+lApevkwQ2tIJQe4=; b=OFxcMNLgbFcFNcPQtyZnzFyztcoB3GXete+rqtBh0HyGQDgvV3Yxt7QXiD2/vexuJhGqusfNSRB42YfD+KnVcLGNurBn7dEnRLe+pnuTlO24itCx7ksu5EizjyQru6c/PWQhxXqZrbFgDKsJKO4JckdASn6NVwg5GweDC0n9Wcg= 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 1760887040210746.3871648323352; Sun, 19 Oct 2025 08:17:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9C-0001yB-Od; Sun, 19 Oct 2025 11:16: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 1vAV9B-0001wR-5m for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:37 -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 1vAV99-0003Ba-7a for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:36 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 1777560A6C for ; Sun, 19 Oct 2025 17:16:34 +0200 (CEST) Received: (qmail 23134 invoked by uid 990); 19 Oct 2025 15:16:34 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:33 +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 v8 09/25] target/i386: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14:58 +0200 Message-ID: <5fb50dd708c97604112c95fcf33045cfe215901a.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999997) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=4wIyJdUT0Wq/HXsJOsBJPGZgllzvhv7UsSxinsdLJ6s=; b=PbfI4ZPKQRz4TJLXwGDwL+8wZ8cSZIYv666sDlb4D6SbxeXOF94owcdb1mZtv5iLdDRvBI4EpD h6kXWtRKuS5c9OqFq552nA+Epm+t61zbnfzrke9195Q/YKaPJUNy7n70gzuG7TokPdpFqiGjc+kq 2xHUV41noLSdHjrpZFXbP+Cj6O5zI6w+927XjuZVqGfq3moB4iQOY6kfN92npWvycOSo+Pr8nlRA 2bMxDBvMVZQc/uus7bkkCsLizHD2HQBcqCV9HBALhjVIvXYw8k+u1g0nRYGEBTCQNL9L/SHQL+T5 1DtKIiq0G7MtMEW9UCOVDDpGhle1DA+8KTOVdAjk6oNy3DiKVI2UgB0fqzBzaWhI5lCgFIusbVld OOFTo+/9LsgJfKLwckq2kyjYsvGw0cH/Y+eNkNjaSp/Odx43wLCTi0yav7aBMnA3s0BVQH7mplG5 rnXLnOts7Py1tYN9NxK6ZhnvkEUcA4W/BSqfGGr1GO7NIITDQ33mNbZT8iy5TmPmwl743IUwK6Mi zBvKHFnkOHtz+dHSCinXp+oqsECtM0PdcRDUa0eSf7XYFtU3riFAjh1p5t6SiTX9LrA6TPxntXh1 Tw8P3iXNOwHNQaNKcY1nLqLtQ6kmy+EIs+5kYJ9y1bgFxQfyWKScF1AfpDuQVxFuNWwYh8x1il7M 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=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887043824158500 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 f49fe851cd..667b1c3869 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -29,6 +29,7 @@ #include "seg_helper.h" #include "access.h" #include "tcg-cpu.h" +#include "qemu/plugin.h" =20 #ifdef TARGET_X86_64 #define SET_ESP(val, sp_mask) \ @@ -1192,6 +1193,7 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, int error_code, target_ulong next_eip, int is_hw) { CPUX86State *env =3D &cpu->env; + uint64_t last_pc =3D env->eip + env->segs[R_CS].base; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { if ((env->cr[0] & CR0_PE_MASK)) { @@ -1263,6 +1265,8 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, event_inj & ~SVM_EVTINJ_VALID); } #endif + + qemu_plugin_vcpu_interrupt_cb(CPU(cpu), last_pc); } =20 void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887037; cv=none; d=zohomail.com; s=zohoarc; b=Z1t1/b1c7OgZt8iQK5YAC2IFuRLhSV9xzR/0ZVYNZp4L4AOBv+2vC5H74in2Gx1EcTd3Z/JT4VbvIYGq7SR3LsM0hI29Pz90RDxJjW+H1j/XTLE4xfTb80RMXEws/EitikI11+2arthCkbgarQAS1p+xL6WJJx4eSjpOMw/afeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887037; 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=TFM48GrDb6bPiuw/tcAxvakvIuBWepg3+Lp8xlRDCSQ=; b=T+2Fi/jD5/TOcr8yDWcJY2GpXa3DXoWSrWRMYkA3xmKn3ZWDI8trI6VdBEqJgQ++w1bd6ZYiDayoJuD3W965n1cc8Q5D2CYIEAhDQBMMFbXMWl3nk9eL55kvzH8q5E0OEU8F0gg/FNJe+Fjh0biR9YVpah+AfMQwYKFEB4Icp+A= 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 1760887037421911.7620172218834; Sun, 19 Oct 2025 08:17:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9E-0001ys-D9; Sun, 19 Oct 2025 11:16: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 1vAV9B-0001xf-JQ for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:37 -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 1vAV99-0003Be-O9 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:37 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 5FFC860A96 for ; Sun, 19 Oct 2025 17:16:34 +0200 (CEST) Received: (qmail 23152 invoked by uid 990); 19 Oct 2025 15:16:34 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:34 +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 v8 10/25] target/loongarch: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:14: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.999998) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599998 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=P6g3y4aF4gqxYoKAfyzuZc16pIeVypfgEAD1P9uwUBU=; b=ogmjiaiycJx60KUmURrYKjChKSVhhe8pRnK6qTeMmkiN7Absi8TRXhH/PZScohWgmrdFvQtIdi n0y5BRb3ggSAUhn8uZ9qbd9icvvJ8qBvbDpLzlq+YAhLT4NJAImoGWrQS72RTAPeBeBPKimvvS5f SApo+nTKqyK4Vm1ByQRNbtxxiXkRjmpKvN0gCWg5O3Mpnyh4xdfnS+BP48i3zwZD6Jq7ITX7oQg9 Hdh5fnnRK24n52b6To/smUawJA9ZvpyvGzNhV9iPlSd0eBBnsxURuu/kuaK35RgFNsiUqy5TWMSI 1MgX+HUO8A7aB/kxFrLXapQBkNAH0Q1+uYZksby41SvLLIipmFkvunL+sCsi0fyBGKlBwrdhL2/5 DyudyNvI9ZSZ/JD3+FkJ4nT1xBGklM4IBBYfItPiB3Q2LdDSn8v2nXj15V39PuVOmFGzdm+n0O9t 9AVUw8NU1Ra9pk+y2uBab5McBrngwxUytllsjU/AOGidjvbu+jFbJBMo5YFeiR7xGz4LpTtJS/k/ oAfY44JpffOpLU/092n8X8Wy1xz09HSHb4cVd4U6hsX9vNUpmIfsrKkFRj9NCoZlwXSV2EdcJ2/i JhbQOcblhnoGPJhx9uBDJhFSHMU2tWC7dDpRy1bd9R/grlrtV7P88QMPrYw5jls/jPZuC+gvq5ik E= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887043166154100 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 Reviewed-by: Song Gao --- target/loongarch/tcg/tcg_cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/loongarch/tcg/tcg_cpu.c b/target/loongarch/tcg/tcg_cpu.c index 82b54e6dc3..9d077c56d9 100644 --- a/target/loongarch/tcg/tcg_cpu.c +++ b/target/loongarch/tcg/tcg_cpu.c @@ -8,6 +8,7 @@ #include "qemu/accel.h" #include "qemu/error-report.h" #include "qemu/log.h" +#include "qemu/plugin.h" #include "accel/accel-cpu-target.h" #include "accel/tcg/cpu-ldst.h" #include "accel/tcg/cpu-ops.h" @@ -80,6 +81,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, @@ -190,6 +192,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); @@ -208,6 +211,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs) tlbfill ? env->CSR_TLBRBADV : env->CSR_BADV, env->CSR_BADI, env->gpr[11], cs->cpu_index, env->CSR_ASID); + qemu_plugin_vcpu_exception_cb(cs, last_pc); } cs->exception_index =3D -1; } --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887145; cv=none; d=zohomail.com; s=zohoarc; b=JZGqa93o/kYMwWf3BjXW3mllGG6r2xdtMmPEgagpebU9nZI7ZRorbhJj3ObshhvluHlIOaCakLvqlokPwp+B1ZCVlkpxks5XPM8AtAeki+8QTvSBCUBS3twJQwwMG4JRfm41CFEvA02Qp/tviiWAgnDiBoiRgZqOZj3Tk1RgWEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887145; 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=Ma4o8EzcvDBdxulVMDQNh64mWy04svEyQeoaeJpBfjF08HyyUI/yBBtQpB5nOK5lusBSuNnuYJi8wrBkaufPn9xdX5V+eMSBv5WEZi9N+C/uTZLySoCZjwKdKeZi5ZdQkb2B7GwpGx0nst+xz7n7dNafKKWIrk2VNgAq+n6cszI= 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 1760887145094570.1276909578451; Sun, 19 Oct 2025 08:19:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9H-0001zZ-Bd; Sun, 19 Oct 2025 11:16:43 -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 1vAV9F-0001z2-D6 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:41 -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 1vAV9D-0003CP-QF for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:41 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id AB3CA60A75 for ; Sun, 19 Oct 2025 17:16:38 +0200 (CEST) Received: (qmail 23227 invoked by uid 990); 19 Oct 2025 15:16:38 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:34 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Laurent Vivier Subject: [PATCH v8 11/25] target/m68k: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:00 +0200 Message-ID: <5443bb9ab89d96f0f8670060734226f04d40a668.1760884672.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.999873) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599873 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=qg2jRGMaQxgS4v8H3+1EeJkm+IB50WNekO6ukmyHdGuRdxcYUvG6S3dhKxTC9OqBVWsQth7iJ9 UfPDX6kKpHEoJ0uDqc/7CUntmXTx3DJbxd/IjESRYggl+/Iwifbre8p64reXv4kWEIDuKOqZoQ7J 7c27lSkc2V0h/OZkszQpBiJkeOBWv0/TlPvmvux12+QVVgTnCOY343uSOqjqqWOGWGUs/vDao03N KyIOzlWUieSX4QewVwjwennp95XeO+Sw9VMHJ38ETxih1OATZ42U6sFniqWz9w10SlJreJoRT8Hl 747XehRdjohIsmZeGRM9HsNf4K3LtqG3EgwGJxM5wi/DKubl7TLkoijL+Rdq0j/4QsTfqQBMqbn7 6JtWOYnBy/sxmWVjfHbJ6/Giqxftab8lpb8d9dPozhldtadX6NhqNOMdlz/2fZt1B+Sch8O97vtW 0rC4qtMnsfNWK5ON9BsygmmS/LJNHncr7gqZHeMzU3m2/oP7W9R1eg1hFQCPsQKQ/9ZPiKv+I5GO sic6N64GfMjo/ySKijaiMOUoF3OrWbh9E9NVOWEch7mHyFQDZ/yOCSmvjBAhLkp982SQ0/aZot8l wcS10EXc+ErGkKMTB/VRbwku0lAU/mnj344gnCtKLTlWZM87dg+U1n2Z09si91ufW9AqhKmHYs/x 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: 1760887146813158500 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/m68k/op_helper.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index f29ae12af8..e9c20a8e03 100644 --- a/target/m68k/op_helper.c +++ b/target/m68k/op_helper.c @@ -22,6 +22,7 @@ #include "exec/helper-proto.h" #include "accel/tcg/cpu-ldst.h" #include "semihosting/semihost.h" +#include "qemu/plugin.h" =20 #if !defined(CONFIG_USER_ONLY) =20 @@ -183,6 +184,21 @@ static const char *m68k_exception_name(int index) return "Unassigned"; } =20 +static void do_plugin_vcpu_interrupt_cb(CPUState *cs, uint64_t from) +{ + switch (cs->exception_index) { + case EXCP_SPURIOUS ... EXCP_INT_LEVEL_7: + qemu_plugin_vcpu_interrupt_cb(cs, from); + break; + case EXCP_SEMIHOSTING: + qemu_plugin_vcpu_hostcall_cb(cs, from); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, from); + break; + } +} + static void cf_interrupt_all(CPUM68KState *env, int is_hw) { CPUState *cs =3D env_cpu(env); @@ -203,6 +219,7 @@ static void cf_interrupt_all(CPUM68KState *env, int is_= hw) return; case EXCP_SEMIHOSTING: do_m68k_semihosting(env, env->dregs[0]); + qemu_plugin_vcpu_hostcall_cb(cs, retaddr); return; } } @@ -239,6 +256,8 @@ static void cf_interrupt_all(CPUM68KState *env, int is_= hw) env->aregs[7] =3D sp; /* Jump to vector. */ env->pc =3D cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, = 0); + + do_plugin_vcpu_interrupt_cb(cs, retaddr); } =20 static inline void do_stack_frame(CPUM68KState *env, uint32_t *sp, @@ -277,6 +296,7 @@ static void m68k_interrupt_all(CPUM68KState *env, int i= s_hw) uint32_t sp; uint32_t vector; uint16_t sr, oldsr; + uint64_t last_pc =3D env->pc; =20 if (!is_hw) { switch (cs->exception_index) { @@ -417,6 +437,8 @@ static void m68k_interrupt_all(CPUM68KState *env, int i= s_hw) env->aregs[7] =3D sp; /* Jump to vector. */ env->pc =3D cpu_ldl_mmuidx_ra(env, env->vbr + vector, MMU_KERNEL_IDX, = 0); + + do_plugin_vcpu_interrupt_cb(cs, last_pc); } =20 static void do_interrupt_all(CPUM68KState *env, int is_hw) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887072; cv=none; d=zohomail.com; s=zohoarc; b=Zfqd4Wo+s+3O3mibwgVgclgg/dTZGIrvrA6pLuRPXHwdhOVb4XAHjDSGsh+DIwq9bqA0MIKQdMAPoYmxwUIzXYRJwEXOVRKsE28hWLJLwBUdwDz14AFv5z8j0IPGqZYTre/gJM5UmKJWXJukHoRu7Nvj2tVCBTFnWUfzAnqILTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887072; 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=MdX4/q2U7jR2ZTXKlAX920Uyz3pkiNfzBlqq8ZZlLbs=; b=i0IgWZuZ0WPzNpomy96ba1y0/UtqbFawAOMDSy7Cc81sLQI9bHmqtcpsjJLf7gjVh9uZ+LK/XGW5XoFOVAKdwSf/bn7o3auYZ7P95V2UaRD0dL1pl4WG8PkaboEMVFp47QDPakHBr95wQu0ki5REIPNYgJF9t3GEliEoixhdeKc= 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 1760887072874142.91896284781592; Sun, 19 Oct 2025 08:17:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9K-0001zq-4h; Sun, 19 Oct 2025 11:16: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 1vAV9I-0001zg-QC for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:45 -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 1vAV9G-0003Cg-0w for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:44 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id E1BD060A6C for ; Sun, 19 Oct 2025 17:16:40 +0200 (CEST) Received: (qmail 23263 invoked by uid 990); 19 Oct 2025 15:16:40 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:38 +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 v8 12/25] target/microblaze: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:01 +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.999978) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599978 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=qFu9MLqW24ZlXSD3Zd1xUyLRQOBol5YAEs1kPkA8RhI=; b=ZshoWq5yrMWVn12vhJxruBbNP01KdAaZPhcVE2qHXcKQ/pwqItXNSJYh4pDi6bfs2EhYcVGhtq apXqgSE7l1OAjnD51bjJsixnsu11dMfbs0O5zFgtW7sYQXRqpHxwtAomfk1CXORWUpRR5L2RekRg mwbvu3w9UtG1nTGNiR4tpX12YB/+QPorePAUw+ba5ilhgRX1bq9buFIiEra+8g1nOBJ4G3HhC9Qq JIEi0QN7CuK7CeV+CLxNz1LOnd5PnW+1bTwozpppzfa4ex9f7KNnyZa8p1kpAhqYuVr178iqX8fG 7WvAonch/wF91/hEPvamr8j32EAs+ZoXy04wLCGmMOdr2ut7tLZLVCJMDxOulwHxQzDAHLwL49X+ j3F0FQikVfshp00Se03gp4jGb9BSg6o/aVUCJ30NgPomYzyR1quqkzr7EChKFPfLnOqHI+fe1+jz mHYefJDAGwfStzb3cmTXrUnyV7ZY5VqMwafl4osPFI3JbzeVfPj/6hzS5I3E60j3zwzjK/8Phdgo SihlyO8DxGH0w0MIHtfseBaLil2qtnYz0UXRalKdJDuvEg+CuogL7Q55jyxpjXkhwS02wu1XOmdl 0e/rLwT6URZ7a+fWYw2JrqsGf4LppZWihEfx39WYkcN8UI9GVIcPsvNDh+kMivs4KGObphij/+Ki U= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887074549154100 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/microblaze/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index cf577a7226..a1857b7217 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -27,6 +27,7 @@ #include "qemu/host-utils.h" #include "exec/log.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 =20 G_NORETURN @@ -35,6 +36,7 @@ static void mb_unaligned_access_internal(CPUState *cs, ui= nt64_t addr, { CPUMBState *env =3D cpu_env(cs); uint32_t esr, iflags; + uint64_t last_pc =3D env->pc; =20 /* Recover the pc and iflags from the corresponding insn_start. */ cpu_restore_state(cs, retaddr); @@ -54,6 +56,7 @@ static void mb_unaligned_access_internal(CPUState *cs, ui= nt64_t addr, env->ear =3D addr; env->esr =3D esr; cs->exception_index =3D EXCP_HW_EXCP; + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit(cs); } =20 @@ -152,6 +155,7 @@ void mb_cpu_do_interrupt(CPUState *cs) CPUMBState *env =3D &cpu->env; uint32_t t, msr =3D mb_cpu_read_msr(env); bool set_esr; + uint64_t last_pc =3D env->pc; =20 /* IMM flag cannot propagate across a branch and into the dslot. */ assert((env->iflags & (D_FLAG | IMM_FLAG)) !=3D (D_FLAG | IMM_FLAG)); @@ -256,6 +260,12 @@ void mb_cpu_do_interrupt(CPUState *cs) env->res_addr =3D RES_ADDR_NONE; env->iflags =3D 0; =20 + if (cs->exception_index =3D=3D EXCP_IRQ) { + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + if (!set_esr) { qemu_log_mask(CPU_LOG_INT, " to pc=3D%08x msr=3D%08x\n", env->pc, msr); --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887190; cv=none; d=zohomail.com; s=zohoarc; b=I+NexK19QVng3b+DKmc/zUWzrPYvPimesjC8ysIw5D3QwzVxMhDvGh/xISn3bLEPpB4BwomIrLuY7pPBkwiANS9im4ztvR6Q1y25wjW+rg5SHhYmPQIWqQoVh1PDX7Dx0Fy/IPgx7/LQVi1EUcxqPJTbCSoL0sZ83wxmVW2gtPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887190; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4sWrccxdT+7/T6NQf9ZfnVL5gRC/gfSxiheMo483FI4=; b=SArfy9I2UAhkA/b5IfoU/zeqtWS2Z51HAbQpMBAfbE654H76rPMdH/ktAFH9Qx9Lbts0/DLR/BaYBtuevbKnnyh3euehUchNzN7Y9o2iSqqmcQEKQqjI84VZI6EJh0meqfqBqw+lDlPqxGd/yA/EMEVEQpB+WOK0CoOAGVfUHew= 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 1760887190131382.248993605823; Sun, 19 Oct 2025 08:19:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9M-00020p-Cw; Sun, 19 Oct 2025 11:16:48 -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 1vAV9K-00020B-AS for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16: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 1vAV9I-0003Cv-8p for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:45 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 35A0060A8A for ; Sun, 19 Oct 2025 17:16:43 +0200 (CEST) Received: (qmail 23310 invoked by uid 990); 19 Oct 2025 15:16:43 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:41 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH v8 13/25] target/mips: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:02 +0200 Message-ID: <90f894e51477495903fc0594e6957c6b2b5c8bc4.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ------ X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999991) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) X-Rspamd-Score: -6.099991 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=4QCLeRlIzG5ENUNvx1SoYVdpQIbTNKVldgdxK9RZn7c=; b=PI5oKy+VVVtUVXV9gjnjBNypei+5MFhWt7OpSvoZxjOA3OjnmdJDI4kD0xjNhX6kzUlyTX95Ag 4X2SZpe9W1VaiYOUBUSLNmoaKTpyGIYg16kHyR5+Uh6axmKSQ2bcG20zgHe/xUzrSLsKbOXqh46E Zng4Db1J1tgKumD9XqDvgUa9Dw+kwc35O/s8vUOmoENolSZcTJSupWCcT116oute6n8YX2jFpe09 OoifMq57GNa/vX8w3Pvf3uhSDD0pbatyvxbR5ZLzdb3lmkRpoOI8s5Kq0yXoNtAlmWAF2FtaKPwc Pxpzx3/9pdJUQmPhhTU8xqQFYhy1dL3SzsDg5SQub0bpDFIEIqPgMrOmX0QHcGlCtFMu/D5brIf3 KHM0/AUkyVXW/Fn59n99pXCmfhuBYjlFjP3o4GgRGsP58Y7jNtXwwxsAFclRMR5mn2+v28nGtM8O GwUUk7K+bHATr7fTtg5DPhj8VODfrs3y/lHwPLJ1HfGXf+4eI9GzGMXGCHQlTkYqQkmSSNoQonER JU6C6iVezgr28jd6B3lVdWrZ882D9TWzeCTSC7rpq47RftRpULRVvnJFFFYjCYgFukBvjkEMBXq2 I6dBdqlnqCp4BIs8xwqtrxZ81V7WHK/DJsDs+v15dSF7mB+dyrO5XZlwIcTGlWIsnYwWkr04kruH 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=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: 1760887192266154100 We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for MIPS targets. We consider the exceptions NMI and EXT_INTERRUPT to be asynchronous interrupts rather than exceptions. Reviewed-by: Richard Henderson Acked-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Julian Ganz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/tcg/system/tlb_helper.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/target/mips/tcg/system/tlb_helper.c b/target/mips/tcg/system/t= lb_helper.c index 1e8901556d..566924b079 100644 --- a/target/mips/tcg/system/tlb_helper.c +++ b/target/mips/tcg/system/tlb_helper.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" #include "qemu/bitops.h" +#include "qemu/plugin.h" =20 #include "cpu.h" #include "internal.h" @@ -1034,6 +1035,7 @@ void mips_cpu_do_interrupt(CPUState *cs) bool update_badinstr =3D 0; target_ulong offset; int cause =3D -1; + uint64_t last_pc =3D env->active_tc.PC; =20 if (qemu_loglevel_mask(CPU_LOG_INT) && cs->exception_index !=3D EXCP_EXT_INTERRUPT) { @@ -1052,6 +1054,7 @@ void mips_cpu_do_interrupt(CPUState *cs) cs->exception_index =3D EXCP_NONE; mips_semihosting(env); env->active_tc.PC +=3D env->error_code; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; case EXCP_DSS: env->CP0_Debug |=3D 1 << CP0DB_DSS; @@ -1336,6 +1339,14 @@ void mips_cpu_do_interrupt(CPUState *cs) env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, env->CP0_DEPC); } + switch (cs->exception_index) { + case EXCP_NMI: + case EXCP_EXT_INTERRUPT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } cs->exception_index =3D EXCP_NONE; } =20 --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887103; cv=none; d=zohomail.com; s=zohoarc; b=OJFzl2iwkuMEQHCf8OstlKyQNYs5X+etHmmjjpnmPt+Pojp87zPl9bZbsIgtfi96U+OwWztWu8ckMVgi6Ny7QcPcAN+pscU2b53fUmDKgHe8pJWqzVuFN3SKq8NqgXBWPB7fBUjtndNHxKDLEVI52rkIhLbaRzVPvCoA237jThU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887103; 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=a9MjyYgoNWGcMwa2ZPSfYYuHlER3nwMfR6vBFaK8QE91NaD0+fX/bw2GDg5RTggyo1Ut/OU29BAuVGXvkAZ/71nHWhBPRKpD/7WLJwHUjALRjv2VHwjniYTNY/rrliCY+k0MwRQ0HmuLhZ3r175J3BGtqcW8rtKr2Il3V8eOgUc= 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 1760887103715833.4473133464477; Sun, 19 Oct 2025 08:18:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9L-00020a-Qy; Sun, 19 Oct 2025 11:16:47 -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 1vAV9K-00020C-D1 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16: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 1vAV9I-0003D1-PZ for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:46 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B8AB760AA8 for ; Sun, 19 Oct 2025 17:16:43 +0200 (CEST) Received: (qmail 23331 invoked by uid 990); 19 Oct 2025 15:16:43 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:43 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Stafford Horne Subject: [PATCH v8 14/25] target/openrisc: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:03 +0200 Message-ID: <7525e266c45664ce58a2c6c7f92318cad8e6caf7.1760884672.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.999965) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599965 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6By6W6p63fDAcZVupcavoMH8cQUKrNcCRvR5J3edyUo=; b=cKQImoW6i5GZkGR4Foqe/35EEAb7uprl7y/77gqlo3U7jSIS1IfAMpAE/3TdWqAEixBmUM0xn/ homBxCmjtVxTyKPVQAU7gZuCE26Zviga4RfVjGGiajaXlBwZIvGG3VHreF7z2Jmm7azYBjXQWr5F kYKL4Qow2e0qMaCLnochYWX4Wpf6tJnFUR1DSAH/9J/qB56K5mO1r8oBWoN67cZn6fqRdnGa0cgK gFsy7BYloGYXiHMfSN8G5dFd7tGIzjrn/0nw1utx2cBrkOmxPD3kCUjqPyP9q6T4kw/oXoyx/LHi OImX+7KgZzJh8dEQLeL9N4pKDkoN9YSGPNBTT4cugd6MknhBZlnbB5IJup9tqSawixeOUGSFdxgR 6AN0WPZV6wMfKRRdFezwVRX8gocvyPlN6L4uzPdVJvpbMAdpJpzR53QZqWnjeE5DwDLzQWUas/A8 KtXIHHFXaS+TiMircbcCdVDzZDIAko764MNgjhJM8s8K7KUT+XVKDKZgGO3j6Nezzo8hLZML5XFp IA4V24BPg9rbBikl5VwbLgJr/cGjWpVU+UziaGQP0Y/N5TjFVCHoY+rabn+d6r7myaLUbmvsms3X loFjYbjHJTKjI+zuyIxv01xLylZEQ70qMonc50Cbp0YryTGw+j9KM1dTKcLPoomeW3nJUbOYMLUU 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=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: 1760887103981158500 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/openrisc/interrupt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 486823094c..d357aaa7da 100644 --- a/target/openrisc/interrupt.c +++ b/target/openrisc/interrupt.c @@ -25,11 +25,13 @@ #ifndef CONFIG_USER_ONLY #include "hw/loader.h" #endif +#include "qemu/plugin.h" =20 void openrisc_cpu_do_interrupt(CPUState *cs) { CPUOpenRISCState *env =3D cpu_env(cs); int exception =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 env->epcr =3D env->pc; =20 @@ -98,6 +100,19 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } =20 + switch (exception) { + case EXCP_RESET: + /* Resets are already exposed to plugins through a dedicated callb= ack */ + break; + case EXCP_TICK: + case EXCP_INT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } + cs->exception_index =3D -1; } =20 --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887125; cv=none; d=zohomail.com; s=zohoarc; b=DjicnDWZ//qQ9ruen/wfTVvaW5z7TMUM13qbh4Re+ecVwVN55rGyVAGTc4QFNzRR5yiGEB2HWOVkVHtPxSqnxIkDExpw0dfj3J8LtjQRjzNyDOFoDgEe3JEcvWEqgRaaBwAnEdr8o2eGBku0neCyuez5or9lXQycnI2z5PjbOc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887125; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=v237/wWyU+kci5xAafOdud1umgh97l5cwck6V2Y5IW0=; b=VUnyd7KJ4s+Dh6lFRDjnBC2PyLJtbWDbWdvhVkieb50tUlKlxAgiZ1wWW2MDe59vxCbksVYw+jvRWpuiYhn+nriyt/OmE60iyiiVQTfMdRFoBMqree2hqppZUGBF1WVt7dTlM7EDcc9G0q444nWucD+Du8DvKM40Qffnga5YMpo= 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 1760887125603527.6730950169261; Sun, 19 Oct 2025 08:18:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9P-00021x-5n; Sun, 19 Oct 2025 11:16: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 1vAV9N-000215-5m for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:49 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vAV9L-0003DV-7n for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:48 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id F21FC60A7D for ; Sun, 19 Oct 2025 17:16:45 +0200 (CEST) Received: (qmail 23376 invoked by uid 990); 19 Oct 2025 15:16:45 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:43 +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 v8 15/25] target/ppc: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:04 +0200 Message-ID: X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=uQChR51oj+aG0zkY+/JvsLAbv/s6w2MfYyQgGOhbbLc=; b=L1LjJmsox3esecHVmowN0TRX3j/v1cDsMOeE4pBWRa5OmyoOXvwK+f0ikIFNrlchAgRYYFGE4j 8dEpxiej6xITtGxssQfwqY3hiMJKfc3bGWZ1byopZ34uy3NC083W99JKbXEHJRhk5HNenfhgTEOv PzjcXrQwoChohXHC5BQtE5/6pN6W9CkwFB3UHOY4+UWJ3b7SRkY1nSZ8yejv0hT7U4CGmI4bfeKS h08H7msEhzshnOrJ/JH9Coin2IzrY1OFEnGreFoVM0IHc86tfOZnN3pWO6GfYMfdeu3vgVWRyw5e k709V4u3/vccnAYmIkzzySqAgpSIqmNUm6M4IcuerkjDv9+Ognp55gq6GPZ0f2ol4o5SKN0CULkq dwlC0nL+gKKoojHffZmom6hEkXwt7g+4YhuIqcVwyVjYp+lANWOKOYa9KRFBuULrPjl6z9TU8uPk p2t45HTqgVbrwKk88/06TSBn+nPHf1AEUFixBln++/MgluQZBldO9RQqPxLUpY3q1+saqjjG+y8p /4LcWV8P8oLTkxb3Ytw1PgPbqQsKxiLjRX9whgUd3KQu+fzb8ezgPYzODN3DGo4+9aqIj3HqLoIp T+snFuGhzRf0CGMtB5EooUH1oQMAiLum7DWev/ls+jYe7g43COb1JVPLitvOIL3MkyJY4IZOjDTe o= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887127470154100 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for Power PC targets. Signed-off-by: Julian Ganz --- target/ppc/excp_helper.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index d8bca19fff..6d05b86505 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -27,6 +27,7 @@ #include "internal.h" #include "helper_regs.h" #include "hw/ppc/ppc.h" +#include "qemu/plugin.h" =20 #include "trace.h" =20 @@ -404,11 +405,31 @@ static void powerpc_mcheck_checkstop(CPUPPCState *env) powerpc_checkstop(env, "machine check with MSR[ME]=3D0"); } =20 +static void powerpc_do_plugin_vcpu_interrupt_cb(CPUState *cs, int excp, + uint64_t from) +{ + switch (excp) { + case POWERPC_EXCP_NONE: + break; + case POWERPC_EXCP_FIT: + case POWERPC_EXCP_WDT: + case POWERPC_EXCP_PIT: + case POWERPC_EXCP_SMI: + case POWERPC_EXCP_PERFM: + case POWERPC_EXCP_THERM: + qemu_plugin_vcpu_interrupt_cb(cs, from); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, from); + } +} + static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -456,6 +477,7 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } env->spr[SPR_40x_ESR] =3D ESR_FP; @@ -510,12 +532,14 @@ static void powerpc_excp_40x(PowerPCCPU *cpu, int exc= p) env->spr[srr0] =3D env->nip; env->spr[srr1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -567,6 +591,7 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -653,12 +678,14 @@ static void powerpc_excp_6xx(PowerPCCPU *cpu, int exc= p) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -708,6 +735,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -758,6 +786,7 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int excp) if (lev =3D=3D 1 && cpu->vhyp) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } =20 @@ -803,12 +832,14 @@ static void powerpc_excp_7xx(PowerPCCPU *cpu, int exc= p) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) { CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -858,6 +889,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -908,6 +940,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) if (lev =3D=3D 1 && cpu->vhyp) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } =20 @@ -947,6 +980,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_ppe42(PowerPCCPU *cpu, int excp) @@ -1073,6 +1107,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1; + uint64_t last_pc =3D env->nip; =20 /* * Book E does not play games with certain bits of xSRR1 being MSR save @@ -1144,6 +1179,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1252,6 +1288,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) env->spr[srr0] =3D env->nip; env->spr[srr1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 /* @@ -1373,6 +1410,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1, lev =3D -1; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -1472,6 +1510,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1516,6 +1555,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (lev =3D=3D 1 && books_vhyp_handles_hcall(cpu)) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } if (env->insns_flags2 & PPC2_ISA310) { @@ -1662,6 +1702,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) ppc_excp_apply_ail(cpu, excp, msr, &new_msr, &vector); powerpc_set_excp_state(cpu, vector, new_msr); } + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } #else static inline void powerpc_excp_books(PowerPCCPU *cpu, int excp) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887037; cv=none; d=zohomail.com; s=zohoarc; b=Tgh5o5574UV+LtJyRJ8UkMPxoO7ONb7Lb/Il9B2OodMOiR2M7E1Mn0I1qSYfZCAI5lftXT9zQxV8f74psdIycB8Ygkr6hqhcakxO7XM9DpFsLm6GRHaM486y9OBivWbB5KIj1fFVswhaw1iiTNMlsUC3LW540YeA8GCLntHmfEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887037; 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=Nd9j3UAsX2LIcgNOP6HaFrHtPXwkhfvP/TSn+nokQiumJc2jOJOYHVqMq/oSbswVhsm/VxwWQf4ilH7pf1orbAq6ibHeTUyq+OpUjuE4ah5xrp1o+ya77ZJiBQI0SaOljKH+je4ZBjWVsavAsZ2ePfeB1xGgPGq+TTC2Y4zoENk= 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 1760887037421538.9205280423464; Sun, 19 Oct 2025 08:17:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9S-00022O-Br; Sun, 19 Oct 2025 11:16:54 -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 1vAV9R-000227-1m for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:53 -0400 Received: from mailgate01.uberspace.is ([95.143.172.20]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vAV9P-0003Dw-Ka for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:52 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 84C7960A75 for ; Sun, 19 Oct 2025 17:16:50 +0200 (CEST) Received: (qmail 23451 invoked by uid 990); 19 Oct 2025 15:16:50 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:46 +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 v8 16/25] target/riscv: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:05 +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.999754) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599754 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=szwEy84c3FUEIJkSNjqg9PDfgXn7Vh/sKNgXYx6w63CqTgyEoGIiBKGAKWmF56iY9L/Sxg9yCv iDQhye0kBizrq0rugog+Rb3ks+K8PPijsYCRGNmuG21uuLdD3erPT+OqQllcHRAw+Rr55XLF57T4 UlpohLXenk3w9fUkCbgJiN6Wgp8oF8fjJ8rwYfDyOU9hD1nCCzi/2rqRf9qxtlGd9XpP3VZB9IBS QWfwr9/5JuPl2LD7WQxo4U1HVDNYCPKJMQ2ajKYVEKlHva6bAgJQ6wsfqrZ0VSe4hiqarVNaf65d Qb1tQDj7ptEDGDUUXtK8ygCmqeLKb6w9kvz4PLf3pEjc19xSrUk/OiTvCGABsjwCBRsE6o4DhaGq lls4DirGBWVe2ClHFdKZ4S0PWPTJpDTyIQNhZXoaoS6q/g7Blnpt6VWYkN6DCH1PelFdLzCqLSqm Usulzl+dl6XPq87uvS0yohWQWO2ToEWEALWSpJesLoKnhHtly5khDr8yLvc5ypuirRRVdOtKbww2 tBObHxOfSRCZkVfb69xHT7RyCeH2MLSVwzASvEKsGFRhqMQN/R9SybffL2y76LWwxe/8Q7io61qk Rjnb0tYovQBi95RfZmI/RvaToVgQvbpzX1eXe9EMGwIWuYAHxwbKZYqQf6BsyL1ML8i8D+U5XuT6 M= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1760887042979154100 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for RISC-V targets. Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Signed-off-by: Julian Ganz --- target/riscv/cpu_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index 3479a62cc7..10a10dcd90 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -36,6 +36,7 @@ #include "cpu_bits.h" #include "debug.h" #include "pmp.h" +#include "qemu/plugin.h" =20 int riscv_env_mmu_index(CPURISCVState *env, bool ifetch) { @@ -2176,6 +2177,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) uint64_t hdeleg =3D async ? env->hideleg : env->hedeleg; const bool prev_virt =3D env->virt_enabled; const target_ulong prev_priv =3D env->priv; + uint64_t last_pc =3D env->pc; target_ulong tval =3D 0; target_ulong tinst =3D 0; target_ulong htval =3D 0; @@ -2198,6 +2200,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) case RISCV_EXCP_SEMIHOST: do_common_semihosting(cs); env->pc +=3D 4; + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); return; #endif case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT: @@ -2467,6 +2470,12 @@ void riscv_cpu_do_interrupt(CPUState *cs) prev_priv, prev_virt); } =20 + if (async) { + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + /* * Interrupt/exception/trap delivery is asynchronous event and as per * zicfilp spec CPU should clear up the ELP state. No harm in clearing --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887125; cv=none; d=zohomail.com; s=zohoarc; b=B90t+TkXE/urIBZ7o8IhxaT5bVbInHSdiyGTW31R3IH+xE0LGiyep2914+FKZAt1M8jDKX0zBD+RQktSvGJNs8k64HNB1aVW5HD2deGoSrkRnparQcNzCetC2sKi6/WW1jzT/gqN9MPx6cg3FC7uPWoCGCKr7SiRJ0gdNfCuAZo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887125; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bmqjE8ooXkFoPszGK8BczmMSyivRP35VpUeb6TNvd4M=; b=l35EgXU2CX3+hBf4jnPQYEBlHFnLvaOxu0kDFlgibR4GZhKDMUhUBvrRuM6oILIQ7jDTyScVq6YFK7/SRqY3Y3i0xdNNaPZry5+oilEAUwslcVi1REp2xZ17Q0QnN9I7xRe8k9R35lwL4y+YImVKKguyhwGnASbSK2FIFc0rqow= 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 176088712552444.15405363849811; Sun, 19 Oct 2025 08:18:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9W-00023Q-S0; Sun, 19 Oct 2025 11:16: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 1vAV9V-000239-CA for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16: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 1vAV9T-0003ES-RA for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:16:57 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id BC7F260A7F for ; Sun, 19 Oct 2025 17:16:54 +0200 (CEST) Received: (qmail 23595 invoked by uid 990); 19 Oct 2025 15:16:54 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:50 +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 v8 17/25] target/rx: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:06 +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.999977) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599977 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=uI/BjTYdC7z/7F5A6PPEG9j6lzk7xU/k4iG6aZX+MLQ=; b=VIH2n6lFopsUPggJtOA7KLPXmNmXnbq3OvKyu3JN13U3jWpYMZKf8EOVy6ktvwVDp/L63e/Pvl iDrczrz7QUtIIOQlvUtNI/4LpS7F0ExjQVS6jCOynZzSfeUL7N4usv6lgmRAg27XFG6/VowOLpog 38fHZgoDSfPU3+mO5fu86e4NbwMylcKWRLYlsgIIdrDFSQyOB91qu41CdEzw46jUcU4GoMusVpj0 R7EOEwttU5fIGj3JY0Fk4WJ66QACZR7+sCcxfrAlIevyhEnoiEED4bNruPkJwANtqWrmQYy2MhGv F6VcNMX5YAfYvyvgHCbecktJlFGVCnZiQvccKW+XyHrIHoArT8Sdm6NlSPO4cI7eAkDR58k4QMRM JOOUu0CF4JUmTVFUKxthm6Uk1uc/NpcJfxr34LVCws3BBasD/aGVNiLzHTXArLMa+e+0WMv3KfDY 19+Uko7r1h3thJ7Q1FdTjmyxW2vw3EaZOJVAt2B6E+/24WMh8r9cUfW9m0sZghdMCLa73432lICN 38eAhpqWVGTL0C2GBJ6IXnlc9gWfD4g/fjQWvwgOzkEZMlf/7Mil3E6Dr9ip6aIhIp7XFYVOrFwL ry4wshvF0dPoEg0sIsxMmMrSFAVXuofaE4g/OhyVAIoPVE1ytffx0REpHIEPLqQu1PIh/z02PsW9 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: 1760887128590158500 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for Renesas Xtreme targets. Reviewed-by: Richard Henderson Reviewed-by: Yoshinori Sato Signed-off-by: Julian Ganz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/rx/helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/rx/helper.c b/target/rx/helper.c index 41c9606fd1..ef47e32add 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -22,6 +22,7 @@ #include "exec/log.h" #include "accel/tcg/cpu-ldst.h" #include "hw/irq.h" +#include "qemu/plugin.h" =20 void rx_cpu_unpack_psw(CPURXState *env, uint32_t psw, int rte) { @@ -46,6 +47,7 @@ void rx_cpu_do_interrupt(CPUState *cs) CPURXState *env =3D cpu_env(cs); int do_irq =3D cpu_test_interrupt(cs, INT_FLAGS); uint32_t save_psw; + uint64_t last_pc =3D env->pc; =20 env->in_sleep =3D 0; =20 @@ -65,6 +67,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D 15; cpu_reset_interrupt(cs, CPU_INTERRUPT_FIR); qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); } else if (do_irq & CPU_INTERRUPT_HARD) { env->isp -=3D 4; @@ -75,6 +78,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D env->ack_ipl; cpu_reset_interrupt(cs, CPU_INTERRUPT_HARD); qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "interrupt 0x%02x raised\n", env->ack_irq); } @@ -92,6 +96,14 @@ void rx_cpu_do_interrupt(CPUState *cs) } else { env->pc =3D cpu_ldl_data(env, env->intb + (vec & 0xff) * 4); } + + if (vec =3D=3D 30) { + /* Non-maskable interrupt */ + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + switch (vec) { case 20: expname =3D "privilege violation"; --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887134; cv=none; d=zohomail.com; s=zohoarc; b=cIr8GyLZrb3G1ojUYtUWKTZfPJ+CYwxMHJkleYQx40yydcwrZ0Iq/veuGgpfpi7ebJ1qYnO1M9EnWtbSRLomYm2Dx/UxJ4GvKuQ3bqMDPuf96sE7wlR0hqTZprkztY9XPd0MneNUdPtFWYIc+2sQ2RgcwcZVlo96lCXc/nwl7ec= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887134; 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=xLMJY7SrqqUVdd/ZywuWmOTrzIXlfjaKjmyZPxvdPY8=; b=XHx6op1I/WP3i9SiuicgWuip33TYIZz4kn6ptXnDXqzfGlUn6a9n+YTlO+jPrih7WtHIJHC5eyK3j+yUPR0/7JhOH4pM/dGiXdF1JBz040uV4Xo8qhldBVcQaWUsXrC6/IG0ivUjPiu4MfPTjtNqxt9D9b5vfPYN5wEXCl0gfNM= 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 1760887134194428.96451736602; Sun, 19 Oct 2025 08:18:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9b-0002Bu-Q5; Sun, 19 Oct 2025 11:17:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vAV9a-00028o-Bs for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:02 -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 1vAV9Y-0003Eq-Io for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:02 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7BF9060A7F for ; Sun, 19 Oct 2025 17:16:59 +0200 (CEST) Received: (qmail 23740 invoked by uid 990); 19 Oct 2025 15:16:59 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:54 +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 v8 18/25] target/s390x: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:07 +0200 Message-ID: <50a092042a41f7d679df2b6577edcba1d9316829.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999997) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=MB5bvnHFgmS+fBJ+/9N5X6Ag5ih3ShqfcmYaYHxgf6k=; b=WKGxSwP5lmDVTVv+oDe62cZpTtbrxBYLeMlg2QqhaeBk9llk3//uOfhxpqI/Uee1ovidGXoce5 l6S2i/GQLNcibbInkREuxz8RI7I0AVUHqA/V+NCZtohcegYrGqZtxAKRFQxpZ7tJsDSENJzqLnII Gs3z3Z77sxXfV6olvAnyTEspHbjeEobsmKLy2XQFlfFj9P3H7oSk4uRucl5ad/gSPyyCDE20Cpuu JPb1ROlhS3rTLhycbnflglPYMZmK4cz0xUik3/VMYp+bQOedpzq4EAyD1DL5JYIM595RmiuBEjQE wbzIGeJpMq5lm6aLkUpb/4DQn055Wi64oTXP4K63bVOijisvmKvE4HHdlvxnk1uetc99cruQcnC1 iWNCpb+pISensAk3E6f+XFW8kTTqpWEx84N1llC+HHAwdZIEVedkjkpyAhlyzL/SzkeyK4Dpvj0q HHBugGNxUC2VAIOZlYLxb+lc9/qSvSQvmRsRhl8JKhhRsumwCaH8/frq4z6hAE6HW7bIMGih5xlS C7Vz0OtpEVdrvn31V4OHwTYak+0MB4U7NsiOMAi+TLURZNepI1xHqcN3b5qbU1LuLJktCl6j1Qp5 RVUKQGOTgy4dyELZUrWqXYdqcFLxQijzypXGxqo2f7WkTxlzpTgFcooSXNvtiDWBzN5XkFCk2nkN 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=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: 1760887138810158500 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 0ae4e26606..c6641280bc 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -35,6 +35,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) @@ -502,6 +503,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); @@ -531,21 +533,27 @@ try_deliver: switch (cs->exception_index) { case EXCP_PGM: do_program_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_SVC: do_svc_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_EXT: do_ext_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_IO: do_io_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_MCHK: do_mchk_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_RESTART: do_restart_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_STOP: do_stop_interrupt(env); --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887062; cv=none; d=zohomail.com; s=zohoarc; b=OjnBJAG9W+i1qvy0yeoXj5mkkyeYmmdMsBGNySMSuZCIpnYWqmdVtAT5rQYSxMIn1UFuygER+EREVgerI3fPwjOnrzIxBcZaAz0RjAfiavbuc2Acap6KQA5e8Tyv3QD30F3cNaY+tmWR15EMc0YUq1WuOgeaRyPaOv/t9JoJzTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887062; 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=W5EYviYkGQViulV98HurcfKEyl/tD3XHc2ZcK2EGDp4=; b=RTxbtQujVme9LVdeUwWXFxWU2fiiur97iUp9IgJJL9+rZzmA+hyK0yW4q+Dc6fKPDUF6zNwj8Dcty80EykTSDPdeEFoqWuJwCOvMdlFF5LABgZxygDnPed5gx+NXTYwvKf3QGjGfXpPvsEGRsCaazrvN/PFSTM988oUtJYAiurA= 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 1760887062575590.1035134799205; Sun, 19 Oct 2025 08:17:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9e-0002EH-OG; Sun, 19 Oct 2025 11:17:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vAV9b-0002Bh-Ka for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:03 -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 1vAV9Y-0003Eu-T3 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:03 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id C07D760AA0 for ; Sun, 19 Oct 2025 17:16:59 +0200 (CEST) Received: (qmail 23758 invoked by uid 990); 19 Oct 2025 15:16:59 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:59 +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 v8 19/25] target/sh4: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:08 +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.99997) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59997 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=henyk1pn+Y7JL09xIai+moS5k8bo4s/ntXusmsrLMEM=; b=ICcGmOSmeYzG63LRRfIlDVCnIBCkhK/f+rmSmydLBxX6i+WX7wFMXukJ5XCpE9HGWjt6t5YZ6n KT4W+YYJOj5TzLHm2PCfwc0Jp4Rl3hor9iuqC+513IY51cQ+o50x5olPSbhBrLZVhUllP9lqSiyN XAMT0MfWWbJewNKmO8L8k6XYtpfaOkyXO6Kg3L5Ra3khBUXk77x8mz334uwsfcwcfGpvsAZUo48I Lp/xKRUinB9F5OyES0Y8K4njtcnAqMZ5+e20RaEge5YIx1fKfAqnb+qcWWwop2C6PlMar0fEkXPh oIq4Q1qcsOCEGSV8ZqU68bRqQJ/bCh0NfAM7/M8yiPssVaoDGUcTCpN0Op0PPPDLByrKT/6WkDYO 49zZqcvp1bmP5V27H6/Qwgvb2buP7xF87kUVzS5K5noruFvBqFLN5eJvo8TzQpQ09PAAK0Iv92ya rLkhd/vzULPc4cQ5S/cKKYahByNRDOZqkN82nFQUInb+Vgm8+sOfaWrIO2LXvDbQ0i/Jl8BhD24u aD6SVWdSHboHHpZdMP5dNWkBiOddiCRgpwHOAlxDiU8BvHkeHQlUZi4A4aL7GHIKGhlwxzINs5Mw NbKRfnfojDYMFIUq1ln2E8T5nakJo8+1RKZ265PYoJU8dfsyKLIRnllJzLHX/Gl2tuDGf3nlO+OZ g= 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: 1760887067765158500 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for SuperH targets. Reviewed-by: Richard Henderson Reviewed-by: Yoshinori Sato Signed-off-by: Julian Ganz --- target/sh4/helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/sh4/helper.c b/target/sh4/helper.c index 3b18a320b8..5d6295618f 100644 --- a/target/sh4/helper.c +++ b/target/sh4/helper.c @@ -24,6 +24,7 @@ #include "exec/page-protection.h" #include "exec/target_page.h" #include "exec/log.h" +#include "qemu/plugin.h" =20 #if !defined(CONFIG_USER_ONLY) #include "hw/sh4/sh_intc.h" @@ -60,6 +61,7 @@ void superh_cpu_do_interrupt(CPUState *cs) CPUSH4State *env =3D cpu_env(cs); int do_irq =3D cpu_test_interrupt(cs, CPU_INTERRUPT_HARD); int do_exp, irq_vector =3D cs->exception_index; + uint64_t last_pc =3D env->pc; =20 /* prioritize exceptions over interrupts */ =20 @@ -176,12 +178,14 @@ void superh_cpu_do_interrupt(CPUState *cs) env->pc =3D env->vbr + 0x100; break; } + qemu_plugin_vcpu_exception_cb(cs, last_pc); return; } =20 if (do_irq) { env->intevt =3D irq_vector; env->pc =3D env->vbr + 0x600; + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); return; } } --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887043; cv=none; d=zohomail.com; s=zohoarc; b=T03lJlR82LPpbcPMb2Tmv75QEtjVLFjYAlC3jWiZW2g8tum4jJjLbTa3O91keaRW5wYHF4QOQ3oIjcitKsRC+W1f2xewxqSnyeGLT/CW1bOWDiN4J6CoFB5ygysXOIZnbthq3nAPguxZKoazbvyKUitq0HA34hN1Blg70SkOel8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887043; 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=xAo90Z+5BG4Cj4PVsRpYPfxlqExHsNwLL/jSk7+1yF0=; b=MLPVDEIOW6E03XSo7MsYeKzbeOdWgsoK9o1dsWOm/Oh8Y0mSyAD8Bv4RJQNI4c9ZRA2pXvFZXYd/hvFmQXrEb59U1O0CQOoW9rH5nyGoXbZBDjP7bjgKw66ccUUuhU3LrFX1oOaHBOZApTT6CRF4pT/8OgKlpAEONio+8stCwbs= 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 1760887043350387.7403381892026; Sun, 19 Oct 2025 08:17:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAV9i-0002FY-Ov; Sun, 19 Oct 2025 11:17: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 1vAV9f-0002F4-Jp for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:07 -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 1vAV9d-0003Fb-7E for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:17:07 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0B41460A7F for ; Sun, 19 Oct 2025 17:17:04 +0200 (CEST) Received: (qmail 23926 invoked by uid 990); 19 Oct 2025 15:17:03 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:16:59 +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 v8 20/25] target/sparc: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:15:09 +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.999996) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599996 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=bDx+90yCB776gfOKaTfPut3XrCuPFgmm569DSUJF6Ic=; b=annyLzFpt/EjnY415ouuO+OA6+B3kAVpGSovGw+mcLhnM60fCsgGX/heHvJTCnOk+xFI+A28li RzNu49PljCPIRdE4MfVAskumUIQFKsdgpDsBbRfaIwVecmafw/AYJSU4tG2AtviRoDWdnZ7ynVZU lIVRID5JeltqTB4VAXz667htbsm6UXwqFIFSv+ljiINX+b6fTaUISfYfXKnbpJS8ltaOSPBRYNF/ ffwF3QZ96zDEkcoyRQVJ8f0frv2zCRTwbqrp503ARKqgDOQJsN+p2V0xGHId8jxtDg6cXwwgSiTU V0G+kqXyA6tTymqqi95B+u8gDj8YcdvbshlRzT+BC9SEJiZjPN/r0WZtdtwmIbcOGB1XhTVjR7dN fvdyq4BwstoLnkjwm6ty3Bp8IxQgMlBwnZKt4VpPQvuYitHmbIYLMJ112VQK6f1KpF0A8QHUAfyd icsL8uaUW/JWmubBM9AL2DZPfcsfGMOIRX0XPU6NRCtlFUZwMoTr+H/Dlvk4Nv7MnhhzmjPeji+B McIYDqjMhvIHdcOGPpIrFSOZTba708b0bJV9WKyUcC77NQpFJjO+e5fq6tTY4+I2btpAkChw6hdk qVYjoWeLhxwN0WHDWlwtOnbdNDf3yzYJLU5e9i4FfDZiL1IQUBnCNgboOb4dGefwAO9GKxWptZnH 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: 1760887049624158500 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/sparc/int32_helper.c | 7 +++++++ target/sparc/int64_helper.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index fdcaa0a578..b29f693a6b 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -24,6 +24,7 @@ #include "accel/tcg/cpu-ldst.h" #include "exec/log.h" #include "system/runstate.h" +#include "qemu/plugin.h" =20 static const char * const excp_names[0x80] =3D { [TT_TFAULT] =3D "Instruction Access Fault", @@ -174,4 +175,10 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->qemu_irq_ack(env, intno); } #endif + + if (intno =3D=3D TT_EXTINT) { + qemu_plugin_vcpu_interrupt_cb(cs, env->regwptr[9]); + } else { + qemu_plugin_vcpu_exception_cb(cs, env->regwptr[9]); + } } diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index 96ef81c26c..60ab0478fc 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -24,6 +24,7 @@ #include "exec/helper-proto.h" #include "exec/log.h" #include "trace.h" +#include "qemu/plugin.h" =20 #define DEBUG_PCALL =20 @@ -256,6 +257,15 @@ void sparc_cpu_do_interrupt(CPUState *cs) } env->npc =3D env->pc + 4; cs->exception_index =3D -1; + + switch (intno) { + case TT_EXTINT: + case TT_IVEC: + qemu_plugin_vcpu_interrupt_cb(cs, tsptr->tpc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, tsptr->tpc); + } } =20 trap_state *cpu_tsptr(CPUSPARCState* env) --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887160; cv=none; d=zohomail.com; s=zohoarc; b=CpSUihj+T2S7n2q+BqzK03IwLvf5poKM/WOY4ySd8wsFKsp1Yzngb025cPbu6u7hXVdUxGPJiwYPeHR3wYltGQrvUsAXPwSd+hI7b5S9qXB+K2F2ZLzUMuBkq5/w1khqVqfz0y2lz6tGVH36XQ6/asja8bRB27ISuYi4K4h4W/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887160; 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=sFnY5UjuZX5PTXNJKQw7RUxdfHQa4BBxmxq37+2oG8M=; b=Q6NRzg2EP46AjMJR2g+9ZV2kSviBm3UQAaAxc84MtXZXcEgEBEn3G3WQPr7ByPWnBNd2tgFfPXaJFSkbx7OOUiQOhXpKU79S8rE1PXEL3MEwsuSWID72zyg4imSusgF6bQ1lCTQ1NCUhZt/pFXKNge0vYNUqTfUkANUOSCNPXm0= 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 176088716079680.97622979098799; Sun, 19 Oct 2025 08:19:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAVBc-00089G-1l; Sun, 19 Oct 2025 11:19: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 1vAVBZ-0007uN-V9 for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19: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 1vAVBW-0003TZ-Nn for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:05 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 2B72A60AB3 for ; Sun, 19 Oct 2025 17:19:01 +0200 (CEST) Received: (qmail 25988 invoked by uid 990); 19 Oct 2025 15:19:01 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:18:56 +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 v8 21/25] target/tricore: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:18:40 +0200 Message-ID: <430884d68ff519df486959d78cfceed860400a08.1760884672.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.999616) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599616 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=T0TAjJK7IefmZyG4PU/2dpjSPNBiWLvd8mA6hXvwDOo=; b=Kvr1KW6WLjZNUoo6DZpVUD7iC5bs8JPowFuMrLsvx6B+/TXR/6E0/pGh7993sjspSJ1StiJAPa bte/RmV438vvgQtlinpq3F7hlU1uhWtqTScIKyq1JHTBBv7two9uZKNNHeAUUeMwG61rsIk8vB3K PccZHrcpM3NEK2wXvcvCWYLlv3ESTQFBeDjgLRLPJgIFrkSEXQjOwtIgxzvQCdh/UQUo4yWZOTZU cM+oO4ealp7Nt9Ix9vU3DKmKp81ijj7rjiPtWjrqGMuS6Zo+lwtvGr+IHNZQho0hObu6J1A4fazY ZnSRud6B4tzpCj+kzOywjrNlBQ4lEORCcnE951KqpRtv/pNlbL0ugxsy2ONfV98D9avamvZuNX33 2d41J/d0Y1l58JBN5SZZmdLOZAIxjfqEiS2KwUfauz/ryPuKgJ6sjb/vt5KFvToUe7C2ZE3phr/o 9TJBA8HzHIjbxWdxL6p55tjtfuzoZDvllJOvBinr1b90AZ+8JdhM8EcyTPklaCxmqcKhZlHCzrbx J7Rh4NybNJUk4w0lW4Oc0QMtX/QwmTKcXqHXgOGW4bztZkHPKAFlHOkFk1Siu4qbd9QM4hF2qCAj +NkIX9tlAkcPxoCg8TGxaQnuhRE/VZ7fVTwRDATEkh3qgQOu4Po/dzZP7SNy2CmtZHGtIPuIF6MQ 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=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: 1760887165194158500 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 610f148a23..2c8281a67e 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -19,6 +19,7 @@ #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "accel/tcg/cpu-ldst.h" +#include "qemu/plugin.h" #include /* for crc32 */ =20 =20 @@ -29,8 +30,11 @@ void raise_exception_sync_internal(CPUTriCoreState *env,= uint32_t class, int tin uintptr_t pc, uint32_t fcd_pc) { CPUState *cs =3D env_cpu(env); + uint64_t last_pc; + /* in case we come from a helper-call we need to restore the PC */ cpu_restore_state(cs, pc); + last_pc =3D env->PC; =20 /* Tin is loaded into d[15] */ env->gpr_d[15] =3D tin; @@ -90,6 +94,7 @@ void raise_exception_sync_internal(CPUTriCoreState *env, = uint32_t class, int tin /* Update PC using the trap vector table */ env->PC =3D env->BTV | (class << 5); =20 + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit(cs); } =20 --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887160; cv=none; d=zohomail.com; s=zohoarc; b=Mg0UUWG8J8MVHHvoI89Ccis3L9vpx5mCM+EvJ02M2+adux2TrmtaaY8Wg2veRHsMa10UK64DUf/PgEM72gUA7nYPJ41rHsM9sprLMduIz85i2+E/eFUgIQ85rvGeK9ww5mvEanltjW1M6LauT1yb6rWq7F7st2crudaXkxiQSBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887160; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+pctLtG2c8avkS6w2WBBM9dDWsGZI0l0fXOtefZe8jw=; b=OuCjJNKPrEqJolzcAzgelqQeLpi11R2vpycua/jKrSG5Hk34Z06lH85W5nHhoQ/AX9hG+2g5wv1jAImDFcewLO2sK4xba+PiY0kONFnbu48olc+4v43HmpC6kxbhU/r7sEmZUsLQmebQEz99CFnm6X6ROwFMYiVT0mWWGxSAnUE= 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 1760887160024146.72276490358854; Sun, 19 Oct 2025 08:19:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAVBf-0000G9-Rs; Sun, 19 Oct 2025 11:19:12 -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 1vAVBd-0008PB-CV for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:09 -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 1vAVBa-0003UM-Uh for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:09 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 7E87960ACD for ; Sun, 19 Oct 2025 17:19:05 +0200 (CEST) Received: (qmail 26144 invoked by uid 990); 19 Oct 2025 15:19:05 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:19:01 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Max Filippov , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v8 22/25] target/xtensa: call plugin trap callbacks Date: Sun, 19 Oct 2025 17:18:41 +0200 Message-ID: <5edba4fa416c9904a874ff5bee604735c3436f65.1760884672.git.neither@nut.email> X-Mailer: git-send-email 2.49.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ------ X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999999) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) X-Rspamd-Score: -6.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=E+G7Ee9WEmlRuvyZYhqKemGENWoKiIcB983rZ31V8I8=; b=sTG8ltaEsyA5Ht8tAFzMzDr1aJQuqkehAahN8Knapqe8v+L402fogDQShufNtAOq6kmRCiM4VJ vfzm4oG7RNBZ5j31Glj2zHZCHo6X17y0PywcEn1BWE9vIzuRKN0JsdpLDddgZJfnew8uICBpG0NT YfIVgFSKmyqVUYkI3z9oHXaXMoCgat4xvvjTC46oEG7OplgrNe6tPKHudhxXZmCiKM5a4m3LRrgv 9dvau3KG1xbqbSLMFbEstwsmb02CGYEYfonYYSPQ8yEVk5JjtFh8OHTnLQGrCXPei9AW/GY8kj2S Rfv2l4uA3rdckhbBn7do/Tr3E0X07oKxkvKWYnpb31EJMBgkceuCBpIqTPBaGrxX6ol+XiVvkKLo Ip+EsW9oOG0ZqcKxooqFrcuH4R+YhsdZMA+sZZGjqfdLUXmgXx0QZ+MkV9+YhHLjaIvl6PrgbFN/ D4oJCWglABsGqxf5LWTx3vR/Gm8lTwx8n2BAa7ImHOqsXRD6tZuiuW0IzZ+AAQ36BWMFqBbe6Ild 33NJfwm7gq6/ptZtsnYISmEKJKsq6JkAtfuumRBmFnWu96LMtZBer+JGNismMaCBNnBRk1GYy0sC IrtPLg5P9l6NA5yEMm/va+e25QJbkZ/Rge3hMHA/sy2L0s5qZxNaU6xXyMABBbIPnJZhlqWS5jPH 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: 1760887160960158500 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Julian Ganz --- target/xtensa/exc_helper.c | 6 ++++++ target/xtensa/xtensa-semi.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index b611c9bf97..fdc522698d 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -32,6 +32,7 @@ #include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "qemu/atomic.h" +#include "qemu/plugin.h" =20 void HELPER(exception)(CPUXtensaState *env, uint32_t excp) { @@ -207,6 +208,8 @@ void xtensa_cpu_do_interrupt(CPUState *cs) CPUXtensaState *env =3D cpu_env(cs); =20 if (cs->exception_index =3D=3D EXC_IRQ) { + uint64_t last_pc =3D env->pc; + qemu_log_mask(CPU_LOG_INT, "%s(EXC_IRQ) level =3D %d, cintlevel =3D %d, " "pc =3D %08x, a0 =3D %08x, ps =3D %08x, " @@ -218,6 +221,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[INTSET], env->sregs[INTENABLE], env->sregs[CCOUNT]); handle_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); } =20 switch (cs->exception_index) { @@ -238,9 +242,11 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[CCOUNT]); if (env->config->exception_vector[cs->exception_index]) { uint32_t vector; + uint64_t last_pc =3D env->pc; =20 vector =3D env->config->exception_vector[cs->exception_index]; env->pc =3D relocated_vector(env, vector); + qemu_plugin_vcpu_exception_cb(cs, last_pc); } else { qemu_log_mask(CPU_LOG_INT, "%s(pc =3D %08x) bad exception_index: %d\n", diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index 431c263dc5..9d9c6254a3 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -35,6 +35,7 @@ #include "system/memory.h" #include "qapi/error.h" #include "qemu/log.h" +#include "qemu/plugin.h" =20 enum { TARGET_SYS_exit =3D 1, @@ -197,6 +198,7 @@ void HELPER(simcall)(CPUXtensaState *env) CPUState *cs =3D env_cpu(env); AddressSpace *as =3D cs->as; uint32_t *regs =3D env->regs; + uint64_t last_pc =3D env->pc; =20 switch (regs[2]) { case TARGET_SYS_exit: @@ -433,4 +435,5 @@ void HELPER(simcall)(CPUXtensaState *env) regs[3] =3D TARGET_ENOSYS; break; } + qemu_plugin_vcpu_hostcall_cb(cs, last_pc); } --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887231; cv=none; d=zohomail.com; s=zohoarc; b=ZKTMfv0xUfozVtDxMIg5WnIAdzVYCt/p6u7sM8r3F85VZbwR3NsIdNv4SZhp64QgDWZy7wEqaBSLS+O0P7tK62uMRfNzVvP4TmOyJwRzfne5rkX9I0L9bMSoRgcUmKO6tBIlsuupv1o2A4gYbRIXthYw9XXfA8D3Q4nCxBPn0lw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887231; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BbiMI+KevS8E8Z0Bg03krlmr/m/lZTIuZKXVkR/IJb8=; b=FfmUnOWXDFfQzPXJLMn18FdVn8E1Uel8fQufwkIcx2gvpkmCpxG1S5vM5u1aOeCUmcVDDdqPSoel3G/9iD3nn62QEhUrDw1StkZ/F5+KuXrUbplJ5so3CzTakALp5F1wPN675f9BmO/spn2bZC/9rYiG4YOWjhoW9XHgDVYYaHM= 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 1760887231477251.08690390151128; Sun, 19 Oct 2025 08:20:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAVBx-0001rn-T3; Sun, 19 Oct 2025 11:19:29 -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 1vAVBu-0001i2-UT for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:27 -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 1vAVBj-0003Uf-8j for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:26 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 0216460ACD for ; Sun, 19 Oct 2025 17:19:10 +0200 (CEST) Received: (qmail 26253 invoked by uid 990); 19 Oct 2025 15:19:09 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:19:05 +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 v8 23/25] tests: add plugin asserting correctness of discon event's to_pc Date: Sun, 19 Oct 2025 17:18:42 +0200 Message-ID: <0330814a4a154e20d3625feb91c32a6a0d7571c6.1760884672.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) MIME_GOOD(-0.1) MID_CONTAINS_FROM(1) BAYES_HAM(-2.999996) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099996 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=M66cb9o00ka1yDebj+//xx3Us6bJo1VzJeW7Zn7c/As=; b=QoYnoSu6gwv+kADG1xj8EWLYbOHcrmKjCsPyaGkugJYR5qssUa3A+rHfMzAlRSJoyXQjY488ZG LRfct+loPbJ/kF2QDr4b8cvbbrMupl2/LH2FtLcW9tmKii8gt7qMJRk3JJAMAAQHaTqTAhSCVfq/ 2Fd+kw6PzZDi8CspMjSGpyoz/ARHimSKLs1JIjJTmN7rqlDFdPjswoP6urjFOL69MjM2+2j5+Nr2 SmKofMV5PTKhr6pLrz9sCm9fMvSEEFto5C7zdDmviKQvbVSeXP7SG1s8K16maFAhEmR4LyaM9OgT ddMd8vPqTdrbvZYTb/91cBy5v0KOrbNRsfG5U1AomgZbUUve0l6uimA4fOvlvmojqARtiP6x+2dz 9wd8A9a9Sp6xZ+WdeUWE3OROC17MH5COevqGTHxDMOzqOtnLsn+wNddSrV2UPhvVGhRckiH54YB0 hAukbO4DXdBtV4aI7cg/Em/0x8j3HcDVXZ57BRInA9RryEZa9DKV/uEWGp5Z8lzJzaG1GU/m+CPQ FC6+nsf2DwdQfnYVQZRf/S3AwSilRie9HOYz4+MdBtd0N+r+xwBlLhiQsiGmL/gGY4ORrLtxSBO2 pC6tboCSfzDdgNpK3nngfQzy7IxuftN46X1dor7UJSC5vcAdGJtuMZczDk9BRK8zdIF1i+a83Eg8 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: 1760887232633154100 Content-Type: text/plain; charset="utf-8" We recently introduced plugin API for the registration of callbacks for discontinuity events, specifically for interrupts, exceptions and host call events. The callback receives various bits of information, including the VCPU index and PCs. This change introduces a test plugin asserting the correctness of that behaviour in cases where this is possible with reasonable effort. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz --- tests/tcg/plugins/discons.c | 221 ++++++++++++++++++++++++++++++++++ tests/tcg/plugins/meson.build | 2 +- 2 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/plugins/discons.c diff --git a/tests/tcg/plugins/discons.c b/tests/tcg/plugins/discons.c new file mode 100644 index 0000000000..2e0e664e82 --- /dev/null +++ b/tests/tcg/plugins/discons.c @@ -0,0 +1,221 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * Copyright (C) 2025, Julian Ganz + * + * This plugin exercises the discontinuity plugin API and asserts some + * of its behaviour regarding reported program counters. + */ +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +struct cpu_state { + uint64_t last_pc; + uint64_t from_pc; + uint64_t next_pc; + uint64_t has_from; + bool has_next; + enum qemu_plugin_discon_type next_type; +}; + +struct insn_data { + uint64_t addr; + uint64_t next_pc; + bool next_valid; +}; + +static struct qemu_plugin_scoreboard *states; + +static qemu_plugin_u64 last_pc; +static qemu_plugin_u64 from_pc; +static qemu_plugin_u64 has_from; + +static bool abort_on_mismatch; +static bool trace_all_insns; + +static bool addr_eq(uint64_t a, uint64_t b) +{ + if (a =3D=3D b) { + return true; + } + + uint64_t a_hw; + uint64_t b_hw; + if (!qemu_plugin_translate_vaddr(a, &a_hw) || + !qemu_plugin_translate_vaddr(b, &b_hw)) + { + return false; + } + + return a_hw =3D=3D b_hw; +} + +static void report_mismatch(const char *pc_name, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t la= st, + uint64_t expected, uint64_t encountered) +{ + gchar *report; + const char *discon_type_name =3D "unknown"; + + if (addr_eq(expected, encountered)) { + return; + } + + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + discon_type_name =3D "interrupt"; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + discon_type_name =3D "exception"; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + discon_type_name =3D "hostcall"; + break; + default: + break; + } + + report =3D g_strdup_printf("Discon %s PC mismatch on VCPU %d\n" + "Expected: %"PRIx64"\nEncountered: %" + PRIx64"\nExecuted Last: %"PRIx64 + "\nEvent type: %s\n", + pc_name, vcpu_index, expected, encountered, l= ast, + discon_type_name); + if (abort_on_mismatch) { + /* + * The qemu log infrastructure may lose messages when aborting. Us= ing + * fputs directly ensures the final report is visible to developer= s. + */ + fputs(report, stderr); + g_abort(); + } else { + qemu_plugin_outs(report); + } + g_free(report); +} + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (type =3D=3D QEMU_PLUGIN_DISCON_EXCEPTION && + addr_eq(state->last_pc, from_pc)) + { + /* + * For some types of exceptions, insn_exec will be called for the + * instruction that caused the exception. This is valid behaviour = and + * does not need to be reported. + */ + } else if (state->has_next) { + /* + * We may encounter discontinuity chains without any instructions + * being executed in between. + */ + report_mismatch("source", vcpu_index, type, state->last_pc, + state->next_pc, from_pc); + } else if (state->has_from) { + report_mismatch("source", vcpu_index, type, state->last_pc, + state->from_pc, from_pc); + } + + state->has_from =3D false; + + state->next_pc =3D to_pc; + state->next_type =3D type; + state->has_next =3D true; +} + +static void insn_exec(unsigned int vcpu_index, void *userdata) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (state->has_next) { + report_mismatch("target", vcpu_index, state->next_type, state->las= t_pc, + state->next_pc, state->last_pc); + state->has_next =3D false; + } + + if (trace_all_insns) { + g_autoptr(GString) report =3D g_string_new(NULL); + g_string_append_printf(report, "Exec insn at %"PRIx64" on VCPU %d\= n", + state->last_pc, vcpu_index); + qemu_plugin_outs(report->str); + } +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + for (size_t i =3D 0; i < n_insns; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + uint64_t pc =3D qemu_plugin_insn_vaddr(insn); + uint64_t next_pc =3D pc + qemu_plugin_insn_size(insn); + uint64_t has_next =3D (i + 1) < n_insns; + + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + last_pc, pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + from_pc, next_= pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + has_from, has_= next); + qemu_plugin_register_vcpu_insn_exec_cb(insn, insn_exec, + QEMU_PLUGIN_CB_NO_REGS, NUL= L); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + if (!info->system_emulation) { + qemu_plugin_outs("Testing of the disontinuity plugin API is only" + " possible in system emulation mode."); + return 0; + } + + /* Set defaults */ + abort_on_mismatch =3D true; + trace_all_insns =3D false; + + for (int i =3D 0; i < argc; i++) { + char *opt =3D argv[i]; + g_auto(GStrv) tokens =3D g_strsplit(opt, "=3D", 2); + if (g_strcmp0(tokens[0], "abort") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &abort_on_mismatch)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else if (g_strcmp0(tokens[0], "trace-all") =3D=3D 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &trace_all_insns)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", o= pt); + return -1; + } + } else { + fprintf(stderr, "option parsing failed: %s\n", opt); + return -1; + } + } + + states =3D qemu_plugin_scoreboard_new(sizeof(struct cpu_state)); + last_pc =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_st= ate, + last_pc); + from_pc =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_st= ate, + from_pc); + has_from =3D qemu_plugin_scoreboard_u64_in_struct(states, struct cpu_s= tate, + has_from); + + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, + vcpu_discon); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); + + return 0; +} diff --git a/tests/tcg/plugins/meson.build b/tests/tcg/plugins/meson.build index 61a007d9e7..561584159e 100644 --- a/tests/tcg/plugins/meson.build +++ b/tests/tcg/plugins/meson.build @@ -1,6 +1,6 @@ t =3D [] if get_option('plugins') - foreach i : ['bb', 'empty', 'inline', 'insn', 'mem', 'reset', 'syscall',= 'patch'] + foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset',= 'syscall', 'patch'] if host_os =3D=3D 'windows' t +=3D shared_module(i, files(i + '.c') + '../../../contrib/plugins/= win32_linker.c', include_directories: '../../../include/qemu', --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887207; cv=none; d=zohomail.com; s=zohoarc; b=Ortn1A+G115C0i0sc+FtR5lEnvWXHflzGMrWutb8+sOMOmJ9OFDt63WPVG9y5zG6nnRC+P1Wj/8LDdNlub2PQ830OAYpPNtvtl+hGulwdlz7rYYYdYxA5tGRW1ym1RC0EbI9jB3RnF5+545D2vOOl6S3+wNeJJgyAciSE3rqdb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887207; 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=kZ60c4JQxIecxNsw3bOsE+IdNJUHK1wqX2CDXhHsKHk=; b=a2/c4LWuO8qfeibsqlpWVU2vHdS+LUW8r0BM5YDD+k07eB1vJNgoJtSEiQwqcboQZfjIxpqqXI1TPfliAsexyNlhQkjad9fXL6m8aSUobCa2hySwT2vL6wKfFODO4Xr0dTrWI3lZc827bXMiVUg5EOLClfgncPdPADhWxkccWiA= 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 1760887207911336.3949482519371; Sun, 19 Oct 2025 08:20:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAVBs-0001VV-BB; Sun, 19 Oct 2025 11:19:24 -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 1vAVBq-0001Oy-7K for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:22 -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 1vAVBk-0003Ui-4l for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:21 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id 4E30060AE2 for ; Sun, 19 Oct 2025 17:19:14 +0200 (CEST) Received: (qmail 26319 invoked by uid 990); 19 Oct 2025 15:19:14 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:19:10 +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 v8 24/25] tests: add test for double-traps on rv64 Date: Sun, 19 Oct 2025 17:18:43 +0200 Message-ID: <311375778957ac6527109ab83ab8c6ba28502fc8.1760884672.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.948666) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.548666 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=Z2wOkmJ8TIPZXX3AHPBRN/csViKXwOsK/S8NlkWxpjM=; b=ECkthoac17ixOQqXC92K7zDj0SgIY+WZr5WkKrWXSOMse8iM9Yhtu54/jHAcmcsSQv3aVxrHV+ pW+l1Aqev6ju/+mK1iQaoyg+Lq7Bx85P1C7HeUkubQLm0JrotnVXezQHamKs+yeCf+zTVWsTcu6F iqUYbd0EWJg7+4zW4AFQHbZto8iepjRbxjaUv43P7AT8HgkROATYhssvfzZElatbsoH4q5q8A5Wr k7ELfQgAT0yS6trAdawnulp+kSVxMc/B359EfzxvlPKOh1AVeIdzZsusplrdr4CsF6kIwwToruV5 5xpxUpbCQe+AzlCSJzI69OhxYPC3pb5zkalvB5fSBjGKgRUFeE4+vqaLWqWcNJLuVKU5572EDREh fKmJ74I5gtme0o2zDMwvj8XSpQcY+peHYdXP+BveQDKeqVmXliDXv9zLee9f363EjwWez257l+Mt /g9fpV1GoBp/alTTpdOreTnhUdryVJJVWeb9yHrILT7Ft1wyA0dB+gYIQ5xiQoFOW4s08OU49Vst EpmSRBer/aCanP/vI2Mnf9e5G8H6L0x7PVMm61sLA8qBcWT0wgxCiIs9IBAbB2d8Tdqnsl4m0FZm eQtl1rP5tGUh84czbgU+rzgzOAJuTSxIKUlVf/MGN4Ok9fDG3kTf3EcfcbMRYzz4detg9d1YgvrV M= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1760887211525158500 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 Reviewed-by: Alistair Francis 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..d9c0036eb4 100644 --- a/tests/tcg/riscv64/Makefile.softmmu-target +++ b/tests/tcg/riscv64/Makefile.softmmu-target @@ -24,5 +24,11 @@ EXTRA_RUNS +=3D run-test-mepc-masking run-test-mepc-masking: test-mepc-masking $(call run-test, $<, $(QEMU) $(QEMU_OPTS)$<) =20 +EXTRA_RUNS +=3D run-plugin-doubletrap +run-plugin-doubletrap: doubletrap + $(call run-test, $<, \ + $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $<.pout \ + $(QEMU_OPTS)$<) + # We don't currently support the multiarch system tests undefine MULTIARCH_TESTS diff --git a/tests/tcg/riscv64/doubletrap.S b/tests/tcg/riscv64/doubletrap.S new file mode 100644 index 0000000000..b61089c9c1 --- /dev/null +++ b/tests/tcg/riscv64/doubletrap.S @@ -0,0 +1,73 @@ + .option norvc + + .text + .global _start +_start: + # Set up vectored interrupts + lla t0, trap + add t0, t0, 1 + csrw mtvec, t0 + + # Enable sw interrupts + csrrsi zero, mie, 0x8 + csrrsi zero, mstatus, 0x8 + + # Engage the double trap: we trigger an machine-level software + # interrupt, which will trap to an illegal instruction + lui t1, 0x02000 + li t0, 1 + sw t0, 0(t1) + + # If we still not went out via the software interrupt route after a + # short while, we failed the test. + lui t0, 0x1 +0: + addi t0, t0, -1 + bnez t0, 0b + j fail + +trap: + j illegal_insn # Exceptions + j fail # Supervisor software interrupt + j fail + .insn i CUSTOM_0, 0, x0, x0, 0 # Machine software interrupt + j fail + j fail # Supervisor timer interrupt + j fail + j fail # Machine timer interrupt + j fail + j fail # Supervisor external interrupt + j fail + j fail # Machine external interrupt + j fail + j fail # Counter overflow interrupt + j fail + j fail + +illegal_insn: + # Check whether we really got an illegal instruction + csrr t0, mcause + li t1, 2 + bne t0, t1, fail + li a0, 0 + j _exit +fail: + li a0, 1 +_exit: + lla a1, semiargs + li t0, 0x20026 # ADP_Stopped_ApplicationExit + sd t0, 0(a1) + sd a0, 8(a1) + li a0, 0x20 # TARGET_SYS_EXIT_EXTENDED + + # Semihosting call sequence + .balign 16 + slli zero, zero, 0x1f + ebreak + srai zero, zero, 0x7 + j . + + .data + .balign 16 +semiargs: + .space 16 --=20 2.49.1 From nobody Fri Nov 14 16:52:19 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=1760887231; cv=none; d=zohomail.com; s=zohoarc; b=L47wrHOVefXs/A42+cySluNaRG6b9+Zo0IfW3e4PFcjE0QC/L1ulBmZ6eRN2VleQ5Q3kUtJmcyWZ+Fa0j0QRIQEhARgP6eEaTnrk8eMF9wx9qkPK1m5KmH33XI3q3Oxiat6Ryl60zL/XHySEWUktmKJOXMShhDkmeBLwzAY9u5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760887231; 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=2Ywvg7jpKUw+yWYFPm+3TwYCrXB5h61XHunW29u95fc=; b=aKjPszBZGZU94+NjjPUBBBGGancD7JnadAC0a1t0gQroMY8aw8CcQ3vOUFpl7kjFFovVhdkP7K9KKZFcdCcU7jW2uCGEl2Nf07t2yP5GTX1rvMetpP1+KYiFb4kXvYUc7V0RSQuQ+P1N54aFqtPV5AVYnuJ5iVgXTHIo21wJkls= 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 1760887231052509.25268992540157; Sun, 19 Oct 2025 08:20:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vAVBv-0001i3-CX; Sun, 19 Oct 2025 11:19:27 -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 1vAVBs-0001Zc-WC for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:25 -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 1vAVBo-0003Uy-Em for qemu-devel@nongnu.org; Sun, 19 Oct 2025 11:19:24 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate01.uberspace.is (Postfix) with ESMTPS id B707F60AE3 for ; Sun, 19 Oct 2025 17:19:18 +0200 (CEST) Received: (qmail 26402 invoked by uid 990); 19 Oct 2025 15:19:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sun, 19 Oct 2025 17:19:14 +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 v8 25/25] tests: add test with interrupted memory accesses on rv64 Date: Sun, 19 Oct 2025 17:18:44 +0200 Message-ID: <5a95ff9e573a245ae5aba91ecc01c5e14579580b.1760884672.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(-0.127773) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -2.727773 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=JtHctVu4zzyt5rbO+qSrHWtDCImC8Y50wo+oZsOBoUM=; b=F+buPZMGtj24s5QGssO2bXwXfqfbAtnJNJos+Ftq8YAbOH1cqeQ/RJ1Q2zOIFQldMqjCgh6/lB ee8NmZNQovad/+noGqbpf1PJhUpxAMEQb8kQ1sJNRCXSgiI33t7JrjuHQ2XPm959i2h6jPV7Rieq NiIsz8TZcLATZIYWp7lNQTStys19kI9gEnPnAlC8a94D1p4iCoxajEuXTgFJEXwNI2OIBU1bMjo6 jibpOOSm+ent9FHWub3vkjahEFvfnn86RqmO7hZ2xIva/c3Rxf7+MD2CyFVJ9wNVQxgzz2MG95KC WA5z7ltbx6ZzG0wJHBEY3EACkolxiokdlZGU2XhCuIe0wvYgvTA7AjWJrMhIeuMjNELFG2dlqNWK 2eKMhVch2g7Xj6TdKopv8tSjy69T21tNQbT2sUy0iWgckQwRkYEESD0Tb1CRjIE4vAqCvv3o04mN D9/6B5EMR0zTWwO/Oxw6o4SHl8V5tyuW2gk7n973OefNIMsNEE7xZklxmwaki7o4lJmsvMZ4a7xu 8P7jEgIefvLODd0eYeTd3rbL5tXbkTXIE8p0Wk+PbUf/Q6/PCwNnBzCoW/ntmW6iFB5S8690ON7A y4z3jF5pzv/oRbIn0X5VrPjT6Rg0aQ0aq0gLMslght7YDwabqAUZAMd66Kd78rkTMkJYhzaKuBjt M= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=95.143.172.20; envelope-from=neither@nut.email; helo=mailgate01.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1760887233785158500 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 (accel/tcg: also suppress asynchronous IRQs for cpu_io_recompile) 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. The test program sends a single '.' per 1000000 loads/stores over the serial. This output is not captured, but may be used by developers to gauge the number of possible interactions. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Julian Ganz --- tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ tests/tcg/riscv64/interruptedmemory.S | 97 +++++++++++++++++++++++ 2 files changed, 103 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 d9c0036eb4..eb1ce6504a 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..cd9073ee31 --- /dev/null +++ b/tests/tcg/riscv64/interruptedmemory.S @@ -0,0 +1,97 @@ + .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 + + # Set up UART + lui t1, 0x10000 + li a0, 0x80 # DLAB=3D1 + sb a0, 3(t1) + li a0, 1 # Full speed + sw a0, 0(t1) + li a0, 0x03 # 8N1, DLAB=3D0 + sb a0, 3(t1) + + # Run test for around 60s + call rtc_get + li t0, 30 + slli t0, t0, 30 # Approx. 10e9 ns + add t0, t0, a0 +0: + # Tight loop with memory accesses + li a1, 1000000 + la a2, semiargs +1: + ld a0, 0(a2) + sd a0, 0(a2) + addi a1, a1, -1 + bnez a1, 1b + + li a0, '.' + call send_byte + call rtc_get + bltu a0, t0, 0b + + li a0, '\n' + call send_byte + + # Exit + 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 + +send_byte: + # Send a single byte over the serial + lui t3, 0x10000 + lb a1, 5(t3) + andi a1, a1, 0x20 + beqz a1, send_byte + sb a0, 0(t3) + ret + + .balign 4 +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