From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668090; cv=none; d=zohomail.com; s=zohoarc; b=gUfeLSmVD0Vc4zNYe9+PWsVqf8g58xOHRyF9sG/jGHahly0E4mzhc8avQVUJloOlrj07ui1SO3FJpWdCL48O/mmFyDieKVSu2Gx4Rbchwoc3agv+lvoTAFEyDj7qSzYcTYdK0ryMwHgt6wsH2wHTdYZfyqEKJsAtD76xgHS1i+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668090; 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=s86eGEzjubjg3UWHHKpDrfte8TXUgun6xm1mqHOBBRc=; b=i6U2GwRemVCr3RneobwgOkeG4n1vJmAPiljG8937cK13mZUoW/fKHKjZt2PCxDvr1eZ0/UFtWUAd7pQcb+uIHULUG2t6UuwPCsvge/L08wvkdO8F93NmTBnCEUyLbAE5VkXr/SuXVpe3lqnXFiFfftSTY/QcuY5sVFQHrWkXGy8= 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 1747668090497649.4720260220333; Mon, 19 May 2025 08:21:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2I9-0006rn-2Z; Mon, 19 May 2025 11:20:37 -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 1uH2I6-0006r8-0C for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:34 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I3-0005S5-Nl for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:33 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 3EDB9180DF7 for ; Mon, 19 May 2025 17:20:22 +0200 (CEST) Received: (qmail 1343 invoked by uid 990); 19 May 2025 15:20:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:21 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier Subject: [PATCH v5 01/25] plugins: add types for callbacks related to certain discontinuities Date: Mon, 19 May 2025 17:19:41 +0200 Message-ID: <08cd73b30ee74d4b264890e193ef56d2270c04c0.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-3) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=/arU7/EJ2As6MS+N1KAvg7D4U6fSqd8rZJUYyNsrlFc=; b=An8HopdpwPwo5HnhimKCtfeVD7HbM4PfVJjLBQegGpEn4y3nwidC2pY08UrK8KOmkM9FOIvR4F NWIpIjZ8Jmt1SjY0y3c3cOUdDgVsRS0V7JRYjySU8v9Mm9UT+ELHO0rKdUqp5GCWDc3+JwzxyxNG VetzaPArwVeSAJ3BAYNpJFUSssaOPRdNmj1XvRqLCzn4QjcwLfwzklDYJivktKUPLw0jnrNAT037 NAgSQc4ssw2t3/gZnq2I5IUENpTJldK6QxMk89A5Rhv8YPR3wtugE7pxgz1MqgkOaomkwcX+785Q nFtVzMNLfgho4zmreWLw7YJJIqgv+F+6QoeQgVYVI2NVOzq5Yq+jEj6VqrPTkf1WHwZ5GSq9DD0K HmTu3Y2PPmgyG/IQ0d1QCfiYcvpr4DNfKkG+7R5BYmSJjp/cua3/yu7bb2dLqdMcBCQ5EaeaoHTC 5unG+sva9x6jEkKDzg+KGd0ugqb23IjIlcFboNX9EX1hAay6oWwgGUedxwZHip2nT0CAEbnh5/Di jqHWeZN/nyxs8BJ2qex1KSR+slZuz+Tjzwnplz17loqkhbtSE2s+I3t74oPyE5RgQaCh0BJLU8Cy XjpPmMpP8lCn9vTEK9bJH+w0MNerzqLclnzdLg7q2F6nLJCOcZpidquWXpzYoehecOo5RoGqhMT7 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668091645116600 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. However, traps of any kind, i.e. interrupts or exceptions, were previously not covered. These kinds of events are arguably quite significant and usually go hand in hand with a PC discontinuity. On most platforms, the discontinuity also includes a transition from some "mode" to another. Thus, plugins for the analysis of (virtualized) embedded systems may benefit from or even require the possiblity to perform work on the occurance of an interrupt or exception. This change introduces the concept of such a discontinuity event in the form of an enumeration. Currently only traps are covered. Specifically we (loosely) define interrupts, exceptions and host calls across all platforms. In addition, this change introduces a type to use for callback functions related to such events. Since possible modes and the enumeration of interupts and exceptions vary greatly between different architectures, the callback type only receives the VCPU id, the type of event as well as the old and new PC. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- 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 9726a9ebf3..27a176b631 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 3a850aa216..2e849bff0b 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -154,6 +154,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668063; cv=none; d=zohomail.com; s=zohoarc; b=XUFBM/y9JA/ngoLs4TUnB8KcKDweQk3Cuc9GcmmtQm0epmkldEMlMUT0SpPcnIwPmRF9Z/HKIt9a9gAdkIK5Xbjz8qzZssTDshZZsxE/4RVde/o/ZMHgrKuWm7VjB69BOXnFG2+jWH0bMDdOOaAp+emcwCPyP2AzCWjOL7qGPfA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668063; 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=fV47MxsXseeIbRReiWdzTjQggMaMNaaMv8Amw8XE/Ho=; b=Ry/IYsAp3zbZYJfiDuBBhxjtlMEQuutQu5//fIR8zJPcjHQAhh1I4YeBG+uO1Cz5SyxLbKgjnz3ljeOnLLffWXHj8U2sxFfmxAqqNT21eDIxl/Jc47lTfEBTNPmAyf4EWZpIKGdyNpI2UvAcBf8SQHoMG/rkXujBskDanZezHvY= 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 17476680632436.21091237290068; Mon, 19 May 2025 08:21:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2I7-0006re-GD; Mon, 19 May 2025 11:20: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 1uH2I5-0006r7-QU for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:33 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I3-0005S7-Lb for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:33 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 989AB180E87 for ; Mon, 19 May 2025 17:20:22 +0200 (CEST) Received: (qmail 1359 invoked by uid 990); 19 May 2025 15:20:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:22 +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 v5 02/25] plugins: add API for registering discontinuity callbacks Date: Mon, 19 May 2025 17:19:42 +0200 Message-ID: <3b5ee8f787cf2ebf17962b172eaf2bd46343235f.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 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=tqOkdn7H0/+7oThE54seK3nN0I07qvxmlZ9TGuAmoAc=; b=LLoHtiVB4UxDvxJeB6wkVg7BMJQtnaRzP1eFZVSFUX7krbYJHYiwA0eTJgXPHvdUyVcM3AxYMY 3EYmS6SbyEIJ47fVm/kHPDETtMx6Gdshn3XJTS/A9vmocA5v0H7pc+Ia+HvroMMTpWx+OKDqBR5n MX7/tGM/fEFB9Jv23FrCv5D0NqUhQtqTwE/gxwXFi48mRix7P8fC34CkTi8GLCXsFkrk69sdRPLn YvETSDKCFSH8LdrnX3dIA0N/V8Xq7mtHhUUrpt2nmDoiUaPZe5DXja1PeJTuLUJzIXTfJXLdDeiz eJ13ZGmQu7UXl5BYnMq7WtFnXgIutmxwsSYHIypphK4Si52DH+bOE1UvS8MK/Rg4edORTqHeniTL FMLHZX97e6jAjrr8XkW+IS/eW7FeZWJAlLsS/Czw7Vy1gA+4jufoLKKaNWoMMdwGM0vJ5WHkoL// +qBYHneCindKDwt8XP/1W5vUe6xGBlvXTjwVFMSpVcVhuXzbGZ5xmrjt2Igy6lHRZOI/fll4gLTd Cy2qsnFwAZFVz/iP2xYoWgTtwxoe3k6ZQYJNL8p6R947fGYFYItAdmX5Jwac86wZBJG7dus8gQJ7 zbqJXMLY7Dve3NxZUxrnYcBXu8BuMzfxI8ADKIzw/ZMeX8O8VGG5uXRMEDKTChsOO7ub9MuLJjbw 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668065076116600 Content-Type: text/plain; charset="utf-8" The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition to those events, we recently defined discontinuity events, which include traps. This change introduces a function to register callbacks for these events. We define one distinct plugin event type for each type of discontinuity, granting fine control to plugins in term of which events they receive. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- 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 2e849bff0b..6d46d15e27 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -274,6 +274,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 eb9281fe54..dc1f5cb4d8 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -551,6 +551,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668147; cv=none; d=zohomail.com; s=zohoarc; b=LBeO/+teLUAQDypW82zUHXlEACKZjkji7u7dRYKRtMvly6Ev61/bzi1YFP7uDAfOdLjrpWF/6DALHUL3fDlFYkbRXMhVjvMb4FH01jiHZDn3rOJwRfELKv/Hph/j7A/IObJEvACvK8tR9Rxy7lbTC6cGCXgDKavMh6Y4md0Sc0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668147; 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=a8KJY4C72yyRrpJeoJwPEBBW6YYSx5mDAV9Nv9nu91s=; b=F7BEFsrF2pO6Wn9DBuL4JcNt2/v3GfWys8qjotinmJbEO3KZkD+VGwSYsWM1dLzvhX5J5d1ANcp11mDDz7qHz9jgRN4CgfKONkdtiAFghqnBf2S4Ajkfdj+TjhEl6NgzTmt2avF8vW2gzSCz2RD1a0ltlYnxFcczXHP2N2UQ3y0= 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 1747668147706859.3087561458294; Mon, 19 May 2025 08:22:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IC-0006t3-0A; Mon, 19 May 2025 11:20: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 1uH2I7-0006ro-Ur for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:36 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I3-0005SB-Q2 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:35 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 01D60180E94 for ; Mon, 19 May 2025 17:20:22 +0200 (CEST) Received: (qmail 1376 invoked by uid 990); 19 May 2025 15:20:22 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:22 +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 v5 03/25] plugins: add hooks for new discontinuity related callbacks Date: Mon, 19 May 2025 17:19:43 +0200 Message-ID: <70c5a0d487731b08e803240061a97bfc110bfbcb.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 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=y56x5vaNn3bjC5DmfdvFI/BZ+uBnd2zhekOk6kbdbLE=; b=s7+oEmy+StxJ7kENJhrFdx9uVfSFTsYAz35p9Rq+UyENN3sn+dGx2SePAtPlbwtlhsjzhebsge r5BTbpxjZ0G4j3w3audgFPTFQ2JPr0HPoB7IusAPvVtCVfi0pdWfRXkShB2om+CIANaIIs/Zu3ya 0OFTHINxByCrWZWqGIEpZRWthXa5t6+C49Rb7EkgwNR/nLEtHGpk4ecf24ivCvac31OUTsj645u9 2YwexC0BnZnXed0XszPGZnwRuIxLZCGCZUlg2fLDOEVQrwwu3Udu9ec7K3uMefQ/tIjBt7FIs7YR fnn6rw11RmuFSBCmJIO9+m26tUH5zm+uXl+Kww/Sv2NdxBIbOKoBx5REwc/y5U7jF3qnw1C9BzZe 175C06ZCNMxvE1agaQCgbQ6lpfMtQYKn32D90zrv5MiLZpjX2UfGhVz+fkFQXmoUl4I48OclH6vm A2VziGPYpokItDM6C5BrCNSpOQkp3Qle+lyE9muKZXBT6BKuCyiJObt2QI0pkm32/PYctTpjxRc7 fE6mNSaw/1fZYElFLYpwKiTDU94zLPDMIgzAdV5YWwxN/JadifTN3gKS5Lm6EqBLKZaOsXDWZ4Cg 5RrmC/VnEmWoPoA+6VSk7XSTgHuLBQEtKgUlH4Q+gdLV1X2+0s/eRI265fpCZiI4Awx1n7r9MwXD 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668150025116600 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. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz --- include/qemu/plugin.h | 12 ++++++++++ plugins/core.c | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 27a176b631..3494325039 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, @@ -243,6 +246,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 dc1f5cb4d8..f07813d588 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -104,6 +104,44 @@ 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_discon_type type, + uint64_t from) +{ + struct qemu_plugin_cb *cb, *next; + enum qemu_plugin_event ev; + uint64_t to =3D cpu->cc->get_pc(cpu); + + if (cpu->cpu_index < plugin.num_vcpus) { + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + ev =3D QEMU_PLUGIN_EV_VCPU_INTERRUPT; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + ev =3D QEMU_PLUGIN_EV_VCPU_EXCEPTION; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + ev =3D QEMU_PLUGIN_EV_VCPU_HOSTCALL; + break; + default: + g_assert_not_reached(); + } + + /* 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 @@ -539,6 +577,21 @@ 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_DISCON_INTERRUPT, from); +} + +void qemu_plugin_vcpu_exception_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, QEMU_PLUGIN_DISCON_EXCEPTION, from); +} + +void qemu_plugin_vcpu_hostcall_cb(CPUState *cpu, uint64_t from) +{ + plugin_vcpu_cb__discon(cpu, 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668071; cv=none; d=zohomail.com; s=zohoarc; b=Ux9LV8zS9p8+2X/Xkmrmz+6QHFh3TaKBRFtLafXD1WzbR6el/cYONkKfNE8uZiaq4wSqwi3Sbdl0kQDTUhRnRSSmq/+3BBlQwYy9Vk8ekxYeoEcBMWtLbzIscIFMV8SNPNZTN9oKdqpnVaPshYN4K14SDYTsawwRiyye5Z/TGik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668071; 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=rdnA5ScTPKZsXZMjI2/s6BiiPsbvhk9a6ob8NfttgXU=; b=WXPLxXWrN1NG0sNTwpF1QjgAsEEtcc9b7FhrtOX2/F/YRHnU5Deg0mHnMyIHCKWdxWHZ2Mjm/MAWN35cCdjHznv5nusDQ+G73Zh8kmidXYF3b+UQh70mV29Kd5d1ktfDNP86po7ScRMTnSZQ4ncS3r70BLPnuOZ0fgPJQuDSJXo= 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 1747668071750269.37772607589125; Mon, 19 May 2025 08:21:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IE-0006uC-6n; Mon, 19 May 2025 11:20:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2I7-0006rm-Jq for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:35 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I4-0005SD-Lh for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:35 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 57375180E84 for ; Mon, 19 May 2025 17:20:23 +0200 (CEST) Received: (qmail 1392 invoked by uid 990); 19 May 2025 15:20:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:23 +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 v5 04/25] contrib/plugins: add plugin showcasing new dicontinuity related API Date: Mon, 19 May 2025 17:19:44 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 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=TYaMsFXC8guUhD1ey2oV3KHMxsxlgexmROBcFzbXiFs=; b=iNvVt6J4ekkwMyZ4K/qZhhAEQDP7jsjDdo4XwibHl9zO7IyU4c2yKR5pSeJuLSUv3FWKwkQoE9 /frvH9XcuGY8jscWtWdPV6K8Bxbw8/HU1viFsPRksttzEBx0JGFoPPPDB9eT//voGquQgytLDwTB sy/ZBrhF4nI/LQTSSfw16NT88Vwz4fEpUONJaCo7P7D6/7LFVptC3QOP6Ewv5RR8e+20xdOpK5H8 38fFjc9fv1YZRoxVizT1L27/3JzQCLFtt5lNSeTyr+z0dExzj33tP0trRaIvDncEdaqURFzwL/I3 pyobCxSLkRZuTh0I/rilxFy8U+/dEYIW7j9miU50JfsPDFtH/FOGU4/oF/1lrRKj4+OKr1bqvxxJ mtsUs2WYPK+WbF7E+nBt1orkjYo7yLK+hesg5UMj58jRqUBjoGWO+yC9F5HlBaNPGNKGafNbYZCn /alXQh0Jjs6mBpV5loRnVzkkVsO6mjhpcONgmp1GMOPiIl+C5k4pV4zb+Q+cXe03n0oc3jytp+uK r7bsVZIukVsEwdvo0kP8YNdhTU4k1uujus/ue45ekIsgP3lIHsvsziDPiWlWfhb8wqBx+JvAl/KN ARs+tlBZhilku5/4vkXl2rzXwHQbY/Eurw/CiCRJR7emaZovdlQyw0X255CsZVW/I4/miLSNSlHT 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NEW_PRODUCTS=1.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668073209116600 Content-Type: text/plain; charset="utf-8" We recently introduced new plugin API for registration of discontinuity related callbacks. This change introduces a minimal plugin showcasing the new API. It simply counts the occurances of interrupts, exceptions and host calls per CPU and reports the counts when exitting. Reviewed-by: Pierrick Bouvier Signed-off-by: Julian Ganz --- contrib/plugins/meson.build | 3 +- contrib/plugins/traps.c | 86 +++++++++++++++++++++++++++++++++++++ docs/about/emulation.rst | 8 ++++ 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 contrib/plugins/traps.c diff --git a/contrib/plugins/meson.build b/contrib/plugins/meson.build index fa8a426c8b..327b48c888 100644 --- a/contrib/plugins/meson.build +++ b/contrib/plugins/meson.build @@ -1,5 +1,6 @@ contrib_plugins =3D ['bbv', 'cache', 'cflow', 'drcov', 'execlog', 'hotbloc= ks', - 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger'] + 'hotpages', 'howvec', 'hwprofile', 'ips', 'stoptrigger', + 'traps'] if host_os !=3D 'windows' # lockstep uses socket.h contrib_plugins +=3D 'lockstep' diff --git a/contrib/plugins/traps.c b/contrib/plugins/traps.c new file mode 100644 index 0000000000..aa943fb55c --- /dev/null +++ b/contrib/plugins/traps.c @@ -0,0 +1,86 @@ +/* + * 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. + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include + +#include + +QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; + +typedef struct { + uint64_t interrupts; + uint64_t exceptions; + uint64_t hostcalls; +} TrapCounters; + +static struct qemu_plugin_scoreboard *traps; + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu_index); + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + rec->interrupts++; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + rec->exceptions++; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + rec->hostcalls++; + break; + default: + g_assert_not_reached(); + break; + } +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report; + report =3D g_string_new("VCPU, interrupts, exceptions, hostcalls\n"); + int max_vcpus =3D qemu_plugin_num_vcpus(); + int vcpu; + + for (vcpu =3D 0; vcpu < max_vcpus; vcpu++) { + TrapCounters *rec =3D qemu_plugin_scoreboard_find(traps, vcpu); + g_string_append_printf(report, + "% 4d, % 10"PRId64", % 10"PRId64", % 10"PRI= d64 + "\n", vcpu, rec->interrupts, rec->exception= s, + rec->hostcalls); + } + + qemu_plugin_outs(report->str); + qemu_plugin_scoreboard_free(traps); +} + +QEMU_PLUGIN_EXPORT +int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info, + int argc, char **argv) +{ + if (!info->system_emulation) { + fputs("trap plugin can only be used in system emulation mode.\n", + stderr); + return -1; + } + + traps =3D qemu_plugin_scoreboard_new(sizeof(TrapCounters)); + + qemu_plugin_register_vcpu_discon_cb(id, QEMU_PLUGIN_DISCON_ALL, + vcpu_discon); + + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} diff --git a/docs/about/emulation.rst b/docs/about/emulation.rst index a72591ee4d..f985fce8ec 100644 --- a/docs/about/emulation.rst +++ b/docs/about/emulation.rst @@ -812,6 +812,14 @@ This plugin can limit the number of Instructions Per S= econd that are executed:: - Maximum number of instructions per cpu that can be executed in one s= econd. The plugin will sleep when the given number of instructions is reach= ed. =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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668096; cv=none; d=zohomail.com; s=zohoarc; b=mogqXi/0W4MQM2r7+z/AudojR9r2te26wqf7CKjHqFPYqidvg9yv2JXBw4fz8V9pT8aoh69R32oKTSF9l0jeBOoZjmeii6xv/uu/j2IN9wyk9I5zijtBJJsqdyzxK88g7q3WBL/7D3FCTqyEUGiRpIx/ifginLz7oHQwjJxrAbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668096; 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=x71G6zHRD8Pk0N6q0OrnaeQCyccobCOy3VGI3s3Hwyo=; b=grqVugaZyRGwv0FqfW4K0SaPLd4XgkzOW4mjzzTo9l+CI6dHFYfqIifdd67mdRFWTs910dMXy0n1VT2o6H3aHntM5/jU1MabNegstZ1ObLzDcty2RxreZ5pSMugNM23kPR6WKltIG670iVzIiu45Lm2Hj5FJLLRDlPgNbB6DafE= 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 1747668096126443.0523764488786; Mon, 19 May 2025 08:21:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IE-0006uM-Fi; Mon, 19 May 2025 11:20:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2I9-0006s0-4d for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:37 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I6-0005T6-Rh for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:36 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id A4A1E180E8B for ; Mon, 19 May 2025 17:20:23 +0200 (CEST) Received: (qmail 1409 invoked by uid 990); 19 May 2025 15:20:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:23 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Richard Henderson Subject: [PATCH v5 05/25] target/alpha: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:45 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.998822) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.598822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=5JCAPKLe/6ZLVixYexxl1bNlbmlq04Bh5tEHZjqm5Ms=; b=q2F0vpNOVoas/SXNKcp+R+ac2mKmLox5fC2bqTltBjFkgu1Qs4ZZNmDcrmoFNVGyT1iOIUUWev uO8ZYHQ5tbnvLVq+0uUdyu2bJBVDrV/Z38oDTMps4Gn+3/eQ5E/vGer0x3JO6fSPP0C2kKJqKOSc Nfu4gVUwaKFlJm9IIyUyvBB9FJAUoyPh4Br7rypIgjRVnHCH82PSzBfIRILY3ZuJr+rWVUNPF1ef VY1UWjFJmRhTzrW2Cm/ujj52MzBCjESJx15smWQzw+zBYqHu6JcipbvJEJweLXUuiuOE3uSN/I1b YDNMRcrQb3m6ANyKUlQ7aA8wFAZaScwQi6BNQ4Awce2nrRMIVJvAd6JkYn9X8GSW0nDs/XCJhcUV dHKIrcrjEdCSLX9+EqLjv4tuH9hNYXahWy5Hl5VY5iC/HIXla+hCjPCt4Rv/xSjAYaO5aNPh5ow0 Tqmjc7W15+oNTGIu8I3NPg9gl+dA8HGEEzCRT2zOwbYjJYPSeX4K2hcA+hIqw73wxAmVqnSXlxXP KwyHDicwHBxaj953/Xpw+s/D/l3qJZVgjFjNoTwcFp84J4i/W9w8zduNDoWE63RgSLW8f8oGVRZt 4oxCYiw6FcjH7x4NxQbVXzmWbXWEtsHvYRR1Pmr8QQH0J5vPksVPGM81hhshvkmiwMnaxO/WPkTE 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668097081116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668345; cv=none; d=zohomail.com; s=zohoarc; b=blvIdKm5rN3EA9l7GpoXCSByqoQcSS+KIISKQQ6lAvrhmQEMKdBbOK4tkLz2SmO17ZrHyw4wDCfzsxBvPBbGbcHWwPoCX2Ks8BW/65iRXFpBClGXYSfVC1hWhBfGkou5hgGZ3q2Xs9c0O7mWYovLMFVyix52fOf6T35w0CV7Igg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668345; 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=QLgLE0ZA/brDzSvdMKYG6n/wKEqkydhjkG9vOFhWNP0=; b=c6Rh8NgAhbDDBLo4FoLfR7cch3ZpPP54e0bklOInRnXTQrKLLHc0DNq+XC/m+TtmPQoO28rvW4EEgonLOz8VywhycDVXkUKv9hfCXT6rzKYUcvB4KpFxgIfmYvTvGu8P5orufr2Y9J7vWUeK4GOYgREXsKhvyK2a7uLzJiF9fQo= 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 1747668345519751.7659656156933; Mon, 19 May 2025 08:25:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IH-0006vY-2J; Mon, 19 May 2025 11:20:45 -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 1uH2I9-0006sV-Bp for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:37 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I6-0005TF-Si for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:36 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id ED2EC180E95 for ; Mon, 19 May 2025 17:20:23 +0200 (CEST) Received: (qmail 1422 invoked by uid 990); 19 May 2025 15:20:23 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:23 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Peter Maydell , qemu-arm@nongnu.org (open list:ARM TCG CPUs) Subject: [PATCH v5 06/25] target/arm: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:46 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999635) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599635 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=6EPHJrxC3MYFqp3FW+kc56Uyv/wE7rHT4/YdFGMzvNc=; b=SDHW1W4XgHTidjjC4jAYj6gMV5VckHVrtoMWVn9aGgoSi0KxYUcoQbZ2KBDPbHIbOhvTaxcZr3 odEIJYwpZ4nCLJQ0SqPeUlOJLdSYkVk1Yl+uv/86V8R4uuV/Rqul/yXXRPhoQ5ag+HNELC4jARZM aqHHRZTcC5PBEmVWhf+2pNp7E/EGxA9hETo/szXz25buCKPJKtw7ppgUVzYvmFwqRdDytNFPc5ct jK/vbyWfOujqUUGLa+odrn4v56Glzfg87jPZrz3v89ZpQoOYqCeOPN9dVImtzf8Dii9idrrZoDj7 Ekx30gZB50nqDNBpayqAw25zZ9lD7h1uJv3UYGWlyeEeXk4ONCnWI3hp2lFQKd+d3ynuNyAYDpO3 O3DxLtzy6BFW0U6zZF/hZCOGFKtacKAxBtodCEvEW8SUM38VzVJWmteJnOVv0jT3rBgpZDp4GxYy 9wBtUv+21nyc695668SpW5VtPbFHBW2pHOrxG5MfBUhZwPTWNWqYFTv5gP3juQU+pS8303KdUQAX pjHUS4952vPEXBe+KvuKNEGPEQHTKS9c94OyQeUwEIF3outtR4WHttOtPTHB1+AB5kPAOd7eQIsU kM7zd6Gli4a7vC42eb2mZIDcQhELRvY36Ns1Dq90GRBGF7aRBzDnDwmEg/vyPI31i3JtlXDZabbY 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668346844116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for ARM (and Aarch64) targets. We decided to treat the (V)IRQ, (VI/VF)NMI, (V)FIQ and VSERR exceptions as interrupts since they are, presumably, async in nature. Signed-off-by: Julian Ganz --- target/arm/helper.c | 24 ++++++++++++++++++++++++ target/arm/tcg/m_helper.c | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7631210287..06070441a6 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" @@ -10214,6 +10215,24 @@ static void take_aarch32_exception(CPUARMState *en= v, int new_mode, } } =20 +static void arm_do_plugin_vcpu_interrupt_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) { /* @@ -10880,6 +10899,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 env->pc; =20 assert(!arm_feature(env, ARM_FEATURE_M)); =20 @@ -10896,6 +10916,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 @@ -10907,6 +10928,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 @@ -10932,6 +10954,8 @@ void arm_cpu_do_interrupt(CPUState *cs) if (!kvm_enabled()) { cs->interrupt_request |=3D CPU_INTERRUPT_EXITTB; } + + arm_do_plugin_vcpu_interrupt_cb(cs, last_pc); } #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/arm/tcg/m_helper.c b/target/arm/tcg/m_helper.c index 6614719832..bcb4aae0d5 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) @@ -2185,6 +2186,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->pc; =20 arm_log_exception(cs); =20 @@ -2352,6 +2354,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); @@ -2418,6 +2421,21 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) =20 ignore_stackfaults =3D v7m_push_stack(cpu); v7m_exception_taken(cpu, lr, false, ignore_stackfaults); + + 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, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } } =20 uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668188; cv=none; d=zohomail.com; s=zohoarc; b=Qrr3LFbqZYIWWTYBwjc9Ys1z32RoJvadaB6trBnSDXy1VgXzEmkqn2HaiAx06s8JwUKX+ZjYWD0iS0SE7KGA12HWfM7wr/SW7R9k5k0paKi5wCskkpWA1D4X7H/QGjOTk19b+vZ2I0zTLeEGJlZ1oOsmPsxvzQW+A3GLUBorIPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668188; 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=W0shR2uw/L6hJUAGIjdxI2AUyKVkqB0VPLlN+WzPmXQ=; b=k/rB40K/rcA28Mr5voma/qKgpfctDb4NqLNcaa6y8gvhVC9SVBEcD+//xIvSyxIKOsMtES6TfGMRaHkiWY54AhSHKZuj5PV8wnjXVlkKsRR6fleoPL6+XGvBf2i8wL3wb2qWYjIX5zStvvxKYLdz5fGl+P/HXgA0a1RHfOkXfTI= 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 1747668188133723.7133988689895; Mon, 19 May 2025 08:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IL-0006yI-T0; Mon, 19 May 2025 11:20:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IC-0006tn-4Q for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:40 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I7-0005TG-4H for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:39 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 59F64180E82 for ; Mon, 19 May 2025 17:20:24 +0200 (CEST) Received: (qmail 1438 invoked by uid 990); 19 May 2025 15:20:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:24 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Michael Rolnik Subject: [PATCH v5 07/25] target/avr: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:47 +0200 Message-ID: <57905b1779684c65f526b7554df14483aff58494.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.994489) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.594489 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=uFv4wgxu+WxZG2jJrkSSQ5VTa7ZJ5m7C8K8D/fGnRDA=; b=ElLA07NcYYX7uV6KEdizJSq2d3e54CorP5nDiGEfi0b9xJjRpyjzVrL4T/thpJK1ks7OriGkvG QKifj16vIWYRzOgNjONZXqpWlQLZq+VquATkXcVU5kKFZ3P3NmV0dJFICDpmYjqoC+z4hYXBqcM1 JiPj/gJtfPAHF8VgK5qjwQOxHRIWDulX+fmWZ58FMdcw2j7+MSzIL2PpZgwsekRxmXw8yR02R9D+ XQnJ/iwtboMt4nbnAJFxxK7MNEpqCnXRePc9A18+kZ8b6daWIY2HGgXbVRYHU4iPnFj3M+d8pnT8 du2ZVJX5DAbUemhhZvumYSKEOHcXl/AJNjCwtm8emyWPBwyf/xyK9cLsH59vUGmhBCa2u0AEiDuw Z561CNf5AbiRIri8bGWNxPiDXHmXgmlv4mWtkmcU8Ox6Ez7tPKmEXGcdb543AmW4Gw26eBTkpfcm FntuCrlLQXzMQmc7eL5nh8FIt6yxbFUd3uZGKy8mhGDjm4o+dHorqMDpITMch7nUvvg9yt9LLjml rP9WDe51qWwhdurI+qg9ti/EiLwnQfxdZJuSUHoFOU3tns57ReTVCMdULVTntuZUy7rRvQKdQxEc SYC7XzHAGtkPU2D6FRptWTIfs8VxajkfaANtEr9j6jMatg5iOEyhf/MVqPUipRI3t+QlmV0uIbDu 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668188662116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/avr/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/avr/helper.c b/target/avr/helper.c index b9cd6d5ef2..f28cc08637 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -28,6 +28,7 @@ #include "exec/target_page.h" #include "accel/tcg/cpu-ldst.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { @@ -102,6 +103,8 @@ void avr_cpu_do_interrupt(CPUState *cs) env->sregI =3D 0; /* clear Global Interrupt Flag */ =20 cs->exception_index =3D -1; + + qemu_plugin_vcpu_interrupt_cb(cs, ret); } =20 hwaddr avr_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668289; cv=none; d=zohomail.com; s=zohoarc; b=GrIiGJDuBREknfsOoVmB//wgsIqwpr4EjWxnbdujvgL6IIXE53ZI5h3GR/te3fey1ZKtNzvXpU23Pzjda1zD83MNaCMBbX6v6ZfJeoK5dphv4aE/eVl39A0hpcyZnSqY+tRt3lsOoKYmS38yg56KWJ+o/pbfbhr0c0NPkN9TpGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668289; 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=5+Zz+YCh78wuooyTqzCCwJ9xFgR8yhdWyN2Ku2cGGY4=; b=e3f3Y4eGJcU1zddBpdLrMrks7GBVCLr4l1rmCM2A3tGYauPvMtmQMtRfVzGB9g4wjmYNWbUR6WXwPpCb4vUoOztrNprwDXnOCv56UHVWPQHgA3A28UdhGGizJ80hf051rn4yO7B35XdF/sJNLUZkN29LffjGvxIDaBV2ugFFhWU= 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 174766828997278.6887609335256; Mon, 19 May 2025 08:24:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2II-0006wT-S9; Mon, 19 May 2025 11:20: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 1uH2IA-0006sw-Vi for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:39 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I8-0005Ti-FC for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:38 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 9B7E6180E2F for ; Mon, 19 May 2025 17:20:24 +0200 (CEST) Received: (qmail 1452 invoked by uid 990); 19 May 2025 15:20:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:24 +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 v5 08/25] target/hppa: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:48 +0200 Message-ID: <62a954b31818763a2f3e0806fb9c912f6dd44972.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.99889) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59889 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=W6dAuA1iLdBCbnZJz/uIyyL1KNX/P3H4QkX0p21d6Ks=; b=r2Aa7LVNXn+uSUNTSoDCTi1qltU1LnxiYTIWHICqObVWZZ9ghOS/PD5JrCVepCP8FMylbh14q8 5knKx1iXMGRpnbJiIBksdDuwHJsDMrEoIr6U+sO4pJjvces8auLKya5fEL+tu6UBmvTFRRudFGnp BCcaCDcyRVCg+hXcTIPBMv8VXxYhz9CUDAbTfMOQ6ipuL7TMLCh+tQSaoLM6hUMq38gYs3b7ThOG f37fguNvS2NXPGbTbnJ8ofNKrVFMUmybD1zqkIZLf1WFDY/g3b4oKxVN73m1rdaZKpavmdXbuh52 UcrYDLCEonuVcMG/2zAgpCRb7XDXVOeLnmLPhYwuhaa/aUbeqvBGwWBxXr5U2YoZMOK0WwPI/oLR Ahjt+bCLPUWheSNIsxBwMlWDygos7nEViFejxpoozaT+FL5lQ4xV4wSmOsImwH3dFclU55fDDbse 56FFVTtUSNLhQM5kH1eKOERNisWI7R3K83+4kK5rOBAPXMM3hlqJvAO8t20YHOZGGRIIt8vC8wU+ v767jW3feRbyvBZnNNOs2KrCjcb3HWYhAoy6fh9Fs1iJqq81aKN1h7S/76IgG88PtAByLjRIJXGT NgtHwR4JEyMNcZKUN8D3aoDd5FfVfRhVIH3NeEAaF8/XczckW1WUDRx1nHIP5jyEbaPwXivgV7F/ 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668292091116600 Content-Type: text/plain; charset="utf-8" We identified a number of exceptions as interrupts, and we assume any unknown exception is also an interrupt. HPPA appears to not have any form of host-call. This change places the hook for PA-RISC targets. Signed-off-by: Julian Ganz --- target/hppa/int_helper.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c index 7d48643bb6..e9325319a7 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 */ @@ -208,6 +210,48 @@ void hppa_cpu_do_interrupt(CPUState *cs) env->iasq_f =3D 0; env->iasq_b =3D 0; =20 + switch (i) { + case EXCP_HPMC: + case EXCP_POWER_FAIL: + case EXCP_RC: + case EXCP_EXT_INTERRUPT: + case EXCP_LPMC: + case EXCP_PER_INTERRUPT: + case EXCP_TOC: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + case EXCP_ITLB_MISS: + case EXCP_IMP: + case EXCP_ILL: + case EXCP_BREAK: + case EXCP_PRIV_OPR: + case EXCP_PRIV_REG: + case EXCP_OVERFLOW: + case EXCP_COND: + case EXCP_ASSIST: + case EXCP_DTLB_MISS: + case EXCP_NA_ITLB_MISS: + case EXCP_NA_DTLB_MISS: + case EXCP_DMP: + case EXCP_DMB: + case EXCP_TLB_DIRTY: + case EXCP_PAGE_REF: + case EXCP_ASSIST_EMU: + case EXCP_HPT: + case EXCP_LPT: + case EXCP_TB: + case EXCP_DMAR: + case EXCP_DMPI: + case EXCP_UNALIGN: + case EXCP_SYSCALL: + case EXCP_SYSCALL_LWS: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + } + if (qemu_loglevel_mask(CPU_LOG_INT)) { static const char * const names[] =3D { [EXCP_HPMC] =3D "high priority machine check", --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668063; cv=none; d=zohomail.com; s=zohoarc; b=dzXhGEioyAq4d6MZ+qYF9emKBZASxujOSacnLO41daczAK6kfnCj1vh8OyFu0iXerb/sTlHdbw8kN8IeL0+yQ8O6g8ROaUqSBUCeolwUISw4Uz+/X388/E7GPvgkbUmjdkGYhxd+mqM/OHvgrrRp0aitfcNBQA1xAVzAWTLE8Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668063; 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=WeSRDtNzeYxkRLmZ4zlu1EOKxSMU/lwBjZE9tIzYWz8=; b=SM72Y3l3opUSC0cnFyiyR+CjAKETBuezr7Kiqln7mte2tCpGTUakeY4io7Bx0VgT8mLd6Y2H76jCYwP++fTOqaLsCZxQRvDcCxEcX72LIb8F4DUTZcMI9NOS7XNOZmRIGLmuk0O47iNWLxwyUSYpQTaZirECvsidDXgcAGeIhEw= 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 1747668063147496.5394494585572; Mon, 19 May 2025 08:21:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IF-0006uc-RD; Mon, 19 May 2025 11:20: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 1uH2IB-0006t0-Bm for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:39 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I8-0005Tk-Th for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:38 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id F1838180E9D for ; Mon, 19 May 2025 17:20:24 +0200 (CEST) Received: (qmail 1468 invoked by uid 990); 19 May 2025 15:20:24 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:24 +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 v5 09/25] target/i386: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:49 +0200 Message-ID: <67873385ae5ca07542184ba2d5b21bf3fed34825.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999679) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599679 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=BDtEUGOiJ460yQyTgMpYkGu26mgEgDHjVtdwN+y0NTs=; b=rmal3Pd5UHv9qEF9cfZY99scVSD6zB4K6xHQmtgFGUAzJp9fU0sD5xV1wCq5S7Od5fJ4q2gmMr Kd+RAwTfjwVFTd2JVwilVBVGQ4HUagMi2oDl0MaW0PUZBqErdT17KzhIWDQjJHqpU1GYrTcTYf0k xqzzaLnTLgjg1dEyzCrGmcT7WYTfdRkNjHvWOK31U5iVc+pH55Qqec3JxKYcbt809GDtdYgS7Afh OBIE5f0065RxVNJslmB8+EBZvyA9rd4rdsKQBU/iUO3FIENRiEQn5M5tJMnSaeInoFTzo1n9QGOc nfhpFZtQhjWQfWxDBcVm/UYUiW02ajRBT2rl/Z4s/CNNKk5bJ6ZiHqHPidsGPQ48q4Qd9buhq8sG 5LyuAE/WY0cofEy2zxY7isgzj5jqCy1VEEBYWwHiqriltrkBIuJnUrObe2r4KhrC/jI/WfPRRxW8 hJUBkrLdZCO7fU6wRMmxuKz1+X7kiQGSmy3WiGYVJ9UJT1LPgyiCPB7nP3+4jkozAKPR77cUl/NI TwYcgoIDGQlRkik4K2pV6+yefi2y5GvxCwtqKHLlXxpGI71EwVQ4XkF5kB2uok6yoNWRHqnFkYQR HDJ1acLx6x62hSkqj68LH7s3JetDmFv3nnA7TGGUw+y0a1cJRkPzMmn2S5cTFClBnc1bhR0PWO/v 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668065225116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places the hook for x86 targets. Signed-off-by: Julian Ganz --- target/i386/tcg/excp_helper.c | 3 +++ target/i386/tcg/seg_helper.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/target/i386/tcg/excp_helper.c b/target/i386/tcg/excp_helper.c index 6fb8036d98..32f2784e92 100644 --- a/target/i386/tcg/excp_helper.c +++ b/target/i386/tcg/excp_helper.c @@ -23,6 +23,7 @@ #include "system/runstate.h" #include "exec/helper-proto.h" #include "helper-tcg.h" +#include "qemu/plugin.h" =20 G_NORETURN void helper_raise_interrupt(CPUX86State *env, int intno, int next_eip_addend) @@ -93,6 +94,7 @@ void raise_interrupt2(CPUX86State *env, int intno, uintptr_t retaddr) { CPUState *cs =3D env_cpu(env); + uint64_t last_pc =3D env->eip + env->segs[R_CS].base; =20 if (!is_int) { cpu_svm_check_intercept_param(env, SVM_EXIT_EXCP_BASE + intno, @@ -106,6 +108,7 @@ void raise_interrupt2(CPUX86State *env, int intno, env->error_code =3D error_code; env->exception_is_int =3D is_int; env->exception_next_eip =3D env->eip + next_eip_addend; + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit_restore(cs, retaddr); } =20 diff --git a/target/i386/tcg/seg_helper.c b/target/i386/tcg/seg_helper.c index 071f3fbd83..db635aceee 100644 --- a/target/i386/tcg/seg_helper.c +++ b/target/i386/tcg/seg_helper.c @@ -29,6 +29,7 @@ #include "seg_helper.h" #include "access.h" #include "tcg-cpu.h" +#include "qemu/plugin.h" =20 #ifdef TARGET_X86_64 #define SET_ESP(val, sp_mask) \ @@ -1192,6 +1193,7 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, int error_code, target_ulong next_eip, int is_hw) { CPUX86State *env =3D &cpu->env; + uint64_t last_pc =3D env->eip + env->segs[R_CS].base; =20 if (qemu_loglevel_mask(CPU_LOG_INT)) { if ((env->cr[0] & CR0_PE_MASK)) { @@ -1263,6 +1265,8 @@ void do_interrupt_all(X86CPU *cpu, int intno, int is_= int, event_inj & ~SVM_EVTINJ_VALID); } #endif + + qemu_plugin_vcpu_interrupt_cb(CPU(cpu), last_pc); } =20 void do_interrupt_x86_hardirq(CPUX86State *env, int intno, int is_hw) --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668162; cv=none; d=zohomail.com; s=zohoarc; b=X9/XRqrTqcISnVzllpe8b1CNFwljveVT7azgEeqH9q88i+rZ+kBHaX/5E4qSvAjDcOhcqLyfHIINJH5CE9J0U6DcpISaJ8QJDCdq5+Q30Ry42QVNT/9wh8UJ+soxdOS6eKnlvZZOO0PFg9I0ofx2i0tWC7JBlfNimWflqFfPRzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668162; 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=79JDRIWKbal4jbWseauBpzoFQ2MxJ1yaugb6gGt4vIs=; b=fKPvVxRCKCchZoyl5MfwZ3ZMOaxruNK2Yqh9bZ41qrQIMomVh7voGEtrh5jVeC2M0cT/pjCr7tOwP9SrQajXiV5DY7swTVVnvzXfiK4cuEaBxZSoSvI8PJP6V/23Q49pb6t95fXPSQwWSUQ+ImdKvKoRbZ66SFy+OOst9ycZjTA= 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 1747668162941472.0621727163988; Mon, 19 May 2025 08:22:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IM-0006yb-IA; Mon, 19 May 2025 11:20:50 -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 1uH2ID-0006u1-1T for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:41 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I9-0005Tr-8I for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:40 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 4D89F180E9A for ; Mon, 19 May 2025 17:20:25 +0200 (CEST) Received: (qmail 1482 invoked by uid 990); 19 May 2025 15:20:25 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:25 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Song Gao Subject: [PATCH v5 10/25] target/loongarch: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:50 +0200 Message-ID: <3f021f55b98787ad5aac1532b18bb3fa05ea2741.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.996607) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.596607 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=yldsQFmqI/dBr3jxFE+4gAW3CyvhrG6GnBZ0Wg++zfk=; b=IjXh9jsPVpT1czpYqD/+CsZx0aj/4wGyQZZFwpuvjAYhhJ0tS7fNWG1w5vNAgbDl7Ez5CpOmV/ VLAD8mZ0Q3BRRiYowHq2pNlmBxMVKn08j48H+ckt/SzGyYK06N8gRSE1f3Gry8nsw7BfiGWMeYF1 NnGjQ8LoZLqj/nOWsrHp2EcW342NXxVFOiRJPJBAqaqlRw+qWqhVR7TxmB7HF1YogfpFIjyaI4iV KYyP3GcmA5OIN/VSrnFOgNhJKgJuBSwtBmvr+gyQTGplcXfdszYrUGUMNbdEE4uXtdd9gFSzji1i 6RtLo3O1b99tAweWcqbA+9ymIt6tn8nST70axrSdfE+/cI4CbYBLEWsL3YQATcc/gimn8EKoQYz3 GmetegTaR3I5xyIxAXFia/5PqO7ECr+WZwxyGHKJJu3T4EeBbdWSkheMdIdmsRYNUO0ZKviZeBMs DKINdM5TnF38/vI8Kn+rMUTJKvQEOy/gbQ6wl1epE3XWE2jE31AwGcr9PkzRuXGytJNwX8MUJbjp sRkjiCijwdotTSgEMTe4h1dFUquYqVxOo50pK9Y9CzZoePUagvtq5aNpC5ArZFWmaMa8oSpz1tnF 8E2LY9hE2RR2LBapQ0vGVaUjoiiCPtlYbx0SYCy0UfTUvBtQk2ayApXtXowfiPmlCcvtkeDkqtAG 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668164469116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/loongarch/cpu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index f7535d1be7..d1ed56d15e 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -31,6 +31,7 @@ #include "accel/tcg/cpu-ldst.h" #include "accel/tcg/cpu-ops.h" #include "tcg/tcg.h" +#include "qemu/plugin.h" #endif #include "tcg/tcg_loongarch.h" =20 @@ -171,6 +172,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, @@ -281,6 +283,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); @@ -299,6 +302,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668222; cv=none; d=zohomail.com; s=zohoarc; b=cnXPKBd5Di8yh5ontHIAu/HIAAEnptfH49oiq817ClTRi77NWd5e1vYOpFj+P3Qw4xylArmfRiJwnPkLbiPhcEJmDiTWhh5DL9z9XTl0IdmK8PSLylMkdUxrQ2gbwo+VEOKFcYI+KVYZkNMBj+2hfifd8Nr4ayhlz6ztL7zj1hQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668222; 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=2Aqjzw7zYTd3NTad9VHCrUBRt2G43DzswN/PL4/HPYw=; b=ZEoHytVJVOG/Gl2CPEdMGgKylY5bscQ1JeXRA9iMmOF6JkXweGWRyok92igBsqq6mfArxn2jZma+nWBs53DlZIn1cXzueq71+zrAADHAFz+VpZS236iFwB4Q9aguwqRaHfeZIFP0Zmq/hQftVxiKVu2tYRckcait+Yrersx6tDI= 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 1747668222382302.7929558969952; Mon, 19 May 2025 08:23:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IM-0006ya-Gw; Mon, 19 May 2025 11:20:50 -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 1uH2IC-0006tt-Lm for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:40 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I9-0005Tq-85 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:40 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 7324C180E98 for ; Mon, 19 May 2025 17:20:25 +0200 (CEST) Received: (qmail 1494 invoked by uid 990); 19 May 2025 15:20:25 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:25 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Laurent Vivier Subject: [PATCH v5 11/25] target/m68k: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:51 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.997165) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597165 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=vccpnbPofMUn5GEYXIKmJ3iPq2zw2c87xl+AJcXAZSs=; b=S2IrBwbD5yd2OYlXrigLyp1gqUQMhXnopn3WiwDCoZhjG9guiLEJNluZb/ALjWXNpGt0qr/QF4 M8TSbsZd4QMmutGWOgL15KM643oUluVVo2TuIMqE81dAfxWD5KsANn0XQ9IkzYmvMYZNniGk0W9Q cQCdUUVGmy752vvdhg32tAnpEZrDytjjqenWjZiByEOatXT6iy7MbkzR2onfIM1hwLFckUCebGcE KEhuQCD6qh79HuGx7iKhGFSkPdjJ0SQdjEqt9F9tBDeLIcVBFz4QdQ2bcMIFmSO2XpBQCgcy7JSe +NME/S0+4N4seYKSkikV+JFY72G8AVDGUzF026WRalDt4Da74zqcv4IBkzVSsqB+abqnwPNbZYLs u+NFjVahRDtsASlL0iS4MQ4RcFp7cMfsqaJ62GP4QVqOtjSoGkbjAYXDX3UtR/i3OOWXbBrbgLfa eZq+EvsNc+UrdSZxKjHPeViKccnNFRZhIhqAREDJSpzeBG0ZO3xIGyey/YiLw1hRl8TCZ6Jz7Pdk FiNLPk3r24uhpjTEPYZBZ1Q45Bhaxw76un6uYAjpeD8U6gu9NvPvAgHLzvH0QbpPPAAJwff5Imrz jO8+doKHBBP4l3cnyJg+J+Xxw/bVVcFOClvMiOdgQ/HQabiK7kjqUnaQJyOQTwyO0UX66fhVAxgS 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668223101116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for Motorola 68000 targets. Signed-off-by: Julian Ganz --- target/m68k/op_helper.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/target/m68k/op_helper.c b/target/m68k/op_helper.c index f29ae12af8..ca15af5765 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); @@ -200,9 +216,11 @@ static void cf_interrupt_all(CPUM68KState *env, int is= _hw) case EXCP_RTE: /* Return from an exception. */ cf_rte(env); + qemu_plugin_vcpu_exception_cb(cs, retaddr); return; case EXCP_SEMIHOSTING: do_m68k_semihosting(env, env->dregs[0]); + qemu_plugin_vcpu_hostcall_cb(cs, retaddr); return; } } @@ -239,6 +257,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,12 +297,14 @@ static void m68k_interrupt_all(CPUM68KState *env, int= is_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) { case EXCP_RTE: /* Return from an exception. */ m68k_rte(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); return; } } @@ -417,6 +439,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668244; cv=none; d=zohomail.com; s=zohoarc; b=iL53IPxAiL8jpbtY1EauNidb1JPtxAwCPVLx1VAkE30EaHZ+EA/2dr6UNgnDahm9LVrABLTFayR3lYXlcVRRwRBAC7B15ux3bHA5HVdmOXHCEsHpC4sfq00k2rG1LTakqHJ04H5m8cXYuMpDrsWH6jWlPQ33bHjhSn5yOqF3sFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668244; 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=4mdpQLOfws4K9Mu0Z9gtHWnbj/rosgJKmWKLZcshwH4=; b=j7HrqPPZbNnnFcuYBGB/mI8fMMHT7IJ/Ptd2cVtl0KwgLCCxNIGe4dxIbxfiexxAitS7T1twHc4g/pt8/KA/cLLb7eQ+VXcUmmFj/mZEHJVS78lpMABohSM7Ere6zLOp1TFjxmsMxfjVmUTkhy+FaK0JTFxIOf/NO/PDyExE/G4= 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 1747668244101362.76135150165146; Mon, 19 May 2025 08:24:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2II-0006vs-Lw; Mon, 19 May 2025 11:20: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 1uH2IB-0006t2-NS for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:39 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I9-0005Tx-88 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:39 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id AD57B180EA3 for ; Mon, 19 May 2025 17:20:25 +0200 (CEST) Received: (qmail 1509 invoked by uid 990); 19 May 2025 15:20:25 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:25 +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 v5 12/25] target/microblaze: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:52 +0200 Message-ID: <06617de4780ef33abf7a04b108ed8aff70a96eea.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.99814) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59814 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=mYTOuQ7uLH2zInBP9Ap2kCAJ9tif03ZHga/PRE+sxLo=; b=k7x8eLsnWw175rZ0XfGvpiIB3e+O6nrNQsFpt7FMbQYJrnpkxTcOZSjBk5xQ66zscRSb2+xeKy LoYlIxCFEZ9BsPgV9OHz7+fisljGF0yL4aTTPTayR/RI3meQmHoiZiu3su2a/49wY5KkgW7ROSs9 MdkNazio3241IXyyXnbqeVNAu+Ak2vC2nYRUTbQUb6drV7lD4BLWEv5FkdobmI/K+wuiu5ZYCLJm F6BOy4796CVyubhqkUE1cuZ1xmg6lJOzohpXS34KVUq+1OZ5WGHGAD7eYYW08ETu5fqBw9AIvQkU HoelB9UI1WjR/qStDkW2Kf9HJiyJC9//xKkJCm+z626+QKN6qkio5SdinrAXeEMn85JPUZaN7FuP LGUSQZl9e0QmC3F2jFZvxAn7ejLyYujfuZOSCTAcfobVWEdewpLHdefJOXzO8QtpH8hJJDzH6V0P BCQi2bBliiLEBA1XIWG95ksRVL2v27FbXyt5e8w74zoJpe94XXXo1nBEJfg7SvMSpRGfYHgq5FUE RRW9MNy8B+5tcWhdJ1WKNUoxnjPa06MgSb9lR4NzoaPEDKLrd3ccjfCu7BAyVjUeh8tdEGbDkx6L UY17bhndtYKKqZ8V8+fUXDZlpz5VkjZ8XUTZMRLf6XMlrOUMBHglQKgliBgNebJBLjtsEktmI3kr 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668245496116600 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: Richard Henderson --- target/microblaze/helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/microblaze/helper.c b/target/microblaze/helper.c index 9203192483..27283c5dc4 100644 --- a/target/microblaze/helper.c +++ b/target/microblaze/helper.c @@ -26,6 +26,7 @@ #include "exec/target_page.h" #include "qemu/host-utils.h" #include "exec/log.h" +#include "qemu/plugin.h" =20 #ifndef CONFIG_USER_ONLY static bool mb_cpu_access_is_secure(MicroBlazeCPU *cpu, @@ -109,6 +110,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)); @@ -213,6 +215,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668248; cv=none; d=zohomail.com; s=zohoarc; b=Ruy4VvGwEseEZWtcdRB+8NHHdE0riUH93WgEiC2cIrIG57jE/rjAyPOhov5CwDnUjm3J0WoV6BtS7TfYoPnqRtfm2l/b2agxcJFIVkZgITnEOM+uC8FlnF0HR7+guVHuP6IXmGmFpGAcgERtJMAnWo1k69IIjKBDW2o8j1R+qm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668248; 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=tyCb1+SD2NI0YZyg0FeGqWpvF4xoeWsHj2m+1ig+468=; b=SOVD/BK2cOY5u3HRq0HeTQBusqjCFC7X8XLWRWe/IhnwbhdwAgnEPQquXvRnxCwnjFulHJn/E0/f/duya9LoSAbkG8rTmL7UfB+Pf+5lyr/horZDSbF5H1Oygdypx3+MKVklc7wxFZ2dGSFd0AZvKsdUR6USHFoyRc1cbtNm0ok= 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 1747668248714749.8272729352084; Mon, 19 May 2025 08:24:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2II-0006vg-0Y; Mon, 19 May 2025 11:20: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 1uH2IF-0006ur-8F for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:43 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2I9-0005Ty-8C for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:42 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 02663180EA5 for ; Mon, 19 May 2025 17:20:26 +0200 (CEST) Received: (qmail 1522 invoked by uid 990); 19 May 2025 15:20:25 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:25 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno , Jiaxun Yang , Aleksandar Rikalo Subject: [PATCH v5 13/25] target/mips: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:53 +0200 Message-ID: <7e602c496a873fd55713eab740543683b69c98eb.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999338) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599338 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=gF8ZpJS8y9Bbk8U6lfy6v84ed6luIVNRS7iWh3mugkA=; b=hCLggOgeqbceKTwet6LKHJpsaY+ahwjZgqG61Z/jzZXnq39ycvAoNpIiDGXg+3fVhPEDqlvYO6 F/Es5gee1Ntb0HVLrZbaScFM7CSPhxHDUhn5f4WKCrs7gUMOQDf2fWrGOZXcd+mBTz3fGCt3K+MG WncSHD0WQdlS2vK3F9YGqKVsutR3UypXWxlX260L8e2ShfPCBXO6dSjOlSf4LyYftwYCtW2Ew5ln k6L+SQ/powH8x6P2mdaHaJWNTDUm1ESvYP7ih9p78hmawz7iKQHNZ77zoqU03jJeskNf0l6cjMZY dbjfOdrmk6itaxFU4Dbp/3cUzi4bQNpLMFqrvejYitSKoxEIP0Q857kLMhkjcdH1L6eZ8ehyM9f0 03d4qYuljZsuQHaQqP805Ba6OY2P82oFpp/02rXQLmBZXDgqYewQQABMsKeCy6l3bUXjv2kFg+X2 7S4CedCaJfGgs9D6syPsLICUE1E68CTR0LkjBji7pVqGlnNR8bvBZHMT1SJbYt0PUrQExyVQqop/ WNqSL+c96a5YCg0+KrUrEYcC3i9Y5idn8EKV1rXSeuiCfNVFY0DhLofWP5DNewru0TF8QOVbi0iC 1ll7foVAS+dpUp+U/JzQifGDloTk4PZ7SpWZD2/whTJFOlwpXLK/edbpBpgjdkYcQRSbQ2Hvi1Ty 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668251652116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for MIPS targets. We consider the exceptions NMI and EXT_INTERRUPT to be asynchronous interrupts rather than exceptions. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- 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 eccaf3624c..abc4d9fef0 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668144; cv=none; d=zohomail.com; s=zohoarc; b=dgaXgKDV140dBcp6NMqb+fmCkt0r9R9NdTscxGQigniqIzBTIMkQQoNHFsYo+olFK31HV5VLx4akRCHUOWiqvz9hcQiSQBnuyBAuBRL4ZAkMI1V4D6gZqUz89HzygbF09yIoHDJFYVPgWE/gu8P8Ah3/q+l0NLnkWZO/8QA5N/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668144; 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=SWVSrmcUkWb9U+X+Uf/obWISvWZ2d5D5+cg32GYCX/A=; b=lCYC+0eTnc0v1mJa2BAG/7ji/kvW0ZWwFGzzSjvvY96Dn7jkJdCGWj2JepJEBisvv8U6VZ0K8//YY8yp3TtqvXYOo/Lh898oMhbKJvq+34xBl7SOUJAbV1I+ufxIgMIO5nyncz5yALcWmaVxaKBHPBiZRHN28coU0xsRlp6vYYA= 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 1747668144187673.582074786108; Mon, 19 May 2025 08:22:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IS-00070D-5r; Mon, 19 May 2025 11:20:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2II-0006vz-8f for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:46 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IA-0005UO-Mr for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:45 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 4384C180EA7 for ; Mon, 19 May 2025 17:20:26 +0200 (CEST) Received: (qmail 1537 invoked by uid 990); 19 May 2025 15:20:26 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:26 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Stafford Horne Subject: [PATCH v5 14/25] target/openrisc: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:54 +0200 Message-ID: <37da15321ffd8f3aa41ad2dadd591cc1f179feb1.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.998926) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.598926 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=92gsDAb/F7BMOSszWmofaaZf2P8bUL8jYBMcs0mlQQY=; b=EtZe+BQNAi3YZyMhuzHVn1omoOpi2DAR1/ht3xdBTz5MIM4wfgkzdtVoDnDPy7kWYEjgrRoE/F B00pRXU1QKGjG3JOJ2rzHhWAeLyyYE1IAyZKE4pwfBHu8HUMlyUOeKy/8ePCFvGxvCPT4yer5uc0 3pDTSBrGkJ+QdWvzy7KIIwJkLolo+2AkZY+pqNonVW/6Gg2TE0j4XZQu7/Yn92mNos38jbYxb1KP DAN6JEiVQCQtdzwGNy+dO3j71dSm8o4w64lHdZLvKbPkl8FAp6kR9Ue7AdE8/CbpFJSNdeX9XaDr k6WZFh9WY5cDKLk7goK0mXilKelMV7FC8LkmR7CyiSl1Jsa2u/0wKHqq9pNOuvf4ryJQkq9JyjVx gTuRt18mXZz22c+r5aey39Kbnv2FdkCGRLRmpVLpSVeEv5nP1QQGbfALfcKNO2Gz+8/9OVJOgWJG 8trmWhKJyEsr+9pScM6fmE8j90lNC7U4Ch23Eho5n0m00e7nozOLBnwBcHyrGbzMmjreNGCIAZg3 7C8XE83kRGlaoH1SbdvrfkmEdy2bLbjPZIHt0bYW733azTNdyYh/UHO/x9DHdmtE3LJv1FnS25Zd BKYr9Uo1pn56Q51YwSDuNh/W6h82j4J5xzqQpVmjqmo5vhh2Ip6acLwUMluOxPIvdde1qutA25Nd 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668145860116600 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: Richard Henderson --- target/openrisc/interrupt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 486823094c..08f0ed9b89 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,17 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } =20 + switch (exception) { + case EXCP_RESET: + 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668093; cv=none; d=zohomail.com; s=zohoarc; b=UbylMN+Qp0aGjuH2YFu+tH7z218mVJ0ux27RAmzlSHvs+3gMYrJ3UR4gXs4zq+lorqM55XtMSmOuONbaYBZy72lbCBx5/IduSVgox6H2dlArSN+hYMR9JeY5/b3y8Ezr6ty70DQdXaunZXs/0bntesUG9MuAjZgm5YLjP8s9n2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668093; 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=j+ESb0vh+K0ap5UXgBV5K7rMkF2wMVqR3Z3ntdb1w0o=; b=GZjc8eyo/7ddvzcQUdtLotnZxSHik8GJjHFetXZm/A0H/jvwAW1onnKuzBX8JewdpoQWkBf9a0qCZ6tJPskFkyYq13DMMXHQrXe/8Vbkjn4Gc0nZH59mueFWHmS7ocgLJY9pCvZBE8Pb/PeV4lxwOwf0FNIpzJjVI/K1Pd45G90= 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 1747668093632572.1766856746204; Mon, 19 May 2025 08:21:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IQ-0006za-5Q; Mon, 19 May 2025 11:20: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 1uH2IE-0006uN-3R for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:43 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IA-0005UN-M2 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:41 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 8E527180EAA for ; Mon, 19 May 2025 17:20:26 +0200 (CEST) Received: (qmail 1549 invoked by uid 990); 19 May 2025 15:20:26 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:26 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Nicholas Piggin , Daniel Henrique Barboza , qemu-ppc@nongnu.org (open list:PowerPC TCG CPUs) Subject: [PATCH v5 15/25] target/ppc: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:55 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.98085) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.58085 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=+MotbJIQe9rsBhnC1Fo8zZ/hxx6wRlQ/dXH41OFrpnU=; b=O5zPRQ3QOpBymIe5NSG5KzWrRZ5MI21gye53zJGbQMf7klSSLGt+WSSsXZFe4LxpgQzlU3Rf7j Z9+KdVqM9JNu3c8xnMcfXgOdA4Mi3ZHVj2zkqXRhlGZchBiTWLM92M4mPoLgTDaI84MGLKvTUDhe xSq8L+nqV72AkH7nH11/TzIt4kPBWXt1yx17tcvcCY3kg+AMNUnY0I23ox3QjUdEfojr3JamsLyR phcBDEIBJz79nD3m7kbz/EHeLv3oyMooehODkXzpzUdsTdQG3iTrsQ/fud88Y+KyhGCwcvbcjOFf Hv9sUN9MkZ0exQw+qcwg0/OCl9/MqXo3u+PVwguoMcZl6KRkx3er+4MfKjLtNgadUQtsrJIzjHJY GEyHcmWUs3LcdvKz9c+MMSx8KIuZtPjeqydg7IQ7NMmot+ViGRYjVI/bP7ExP/DGN5T8ZoofKB7K mbszaIJHOrWhuGMXeE5sN2LgSchrtU4ntAFxyLvBC/Oury+XX5WRmD2Oz1ToCYu+Nj9qr3cYWpQJ 9Jgwbq9E683y7B1yz0GHlNRqzTT4vbJwpJ5Buep+AwWeovZ1rmeDh3xnnfnlJTilXjZDWNtrhcDI kHSnm7OpSAIJtSvOJvPtHxz2XrowZvNhgrWcfeahS2QL8fVNiYPR6QeewwN8beLvNC6X7XkhOmvY 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668095508116600 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 | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 1efdc4066e..24740a000b 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,32 @@ 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_DEBUG: + 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 +478,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 +533,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 +592,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 +679,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 +736,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 +787,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 +833,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 +890,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 +941,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 +981,7 @@ static void powerpc_excp_74xx(PowerPCCPU *cpu, int excp) env->spr[SPR_SRR0] =3D env->nip; env->spr[SPR_SRR1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 static void powerpc_excp_booke(PowerPCCPU *cpu, int excp) @@ -954,6 +989,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int exc= p) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1; + uint64_t last_pc =3D env->nip; =20 /* * Book E does not play games with certain bits of xSRR1 being MSR save @@ -1025,6 +1061,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1133,6 +1170,7 @@ static void powerpc_excp_booke(PowerPCCPU *cpu, int e= xcp) env->spr[srr0] =3D env->nip; env->spr[srr1] =3D msr; powerpc_set_excp_state(cpu, vector, new_msr); + powerpc_do_plugin_vcpu_interrupt_cb(env_cpu(env), excp, last_pc); } =20 /* @@ -1254,6 +1292,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) CPUPPCState *env =3D &cpu->env; target_ulong msr, new_msr, vector; int srr0 =3D SPR_SRR0, srr1 =3D SPR_SRR1, lev =3D -1; + uint64_t last_pc =3D env->nip; =20 /* new srr1 value excluding must-be-zero bits */ msr =3D env->msr & ~0x783f0000ULL; @@ -1353,6 +1392,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (!FIELD_EX64_FE(env->msr) || !FIELD_EX64(env->msr, MSR, FP)= ) { trace_ppc_excp_fp_ignore(); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_exception_cb(env_cpu(env), last_pc); return; } /* @@ -1397,6 +1437,7 @@ static void powerpc_excp_books(PowerPCCPU *cpu, int e= xcp) if (lev =3D=3D 1 && books_vhyp_handles_hcall(cpu)) { cpu->vhyp_class->hypercall(cpu->vhyp, cpu); powerpc_reset_excp_state(cpu); + qemu_plugin_vcpu_hostcall_cb(env_cpu(env), last_pc); return; } if (env->insns_flags2 & PPC2_ISA310) { @@ -1543,6 +1584,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668250; cv=none; d=zohomail.com; s=zohoarc; b=QIGuj+9FEEdZzYKR5mgeRMZSJMP4NDNvPxpMlCwAWQ75KRhO0x1hV9HHVTsJP88omS46v7yBy1wfRscd8Va4ENbOuHdrMhjOxcv2iv0KCHsQ7fCADWWogVrf8gWqOwOk0ygghgdjnmumj/AgydU05YQorVRn2r2UhESHfkZah44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668250; 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=suSftCsInaLkWuAghLeHFqxq6VNT5iYTUxrN9S+Lp6k=; b=JbouOT0G0OxzxngyIFNTewUCTG4ZVZOs4QbvDLAzb2kmrfnVTzsyzTJ5D/+V1RZc44I7XneACyV28/NIAjG3KjaCu9SxjoWy+PxNELeeLmc99CJs0HItMTB4w1HfunOVgfzkAMLTEnwChHgP+Xaar7aD984wuqovM7zu+OY3rGE= 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 1747668250188786.013284257624; Mon, 19 May 2025 08:24:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IN-0006z5-Fm; Mon, 19 May 2025 11:20: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 1uH2ID-0006u8-Fw for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:41 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IA-0005Ub-MG for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:41 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id E8378180E9B for ; Mon, 19 May 2025 17:20:26 +0200 (CEST) Received: (qmail 1569 invoked by uid 990); 19 May 2025 15:20:26 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:26 +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 v5 16/25] target/riscv: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:56 +0200 Message-ID: <02ab1cf229f664a055429ec9bbc540fdb9819b29.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.980215) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.580215 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=5VBH82GNW1vOApkXmMOwSwXJ+E1YvBxJomZkJGAc60c=; b=LqxbjRyGQgRhdf8SZTVnAHjildpfrWDG9Tl9AgWfNx0GiHM/G52paCtz6rVgZhC9Zn147Z/51L OnFqjASRwtTdyN/AtqRFvsBg0xhAqcJQ0i2dgMYBgNaFPWv98y1yhc12oV6yHUqknpLNVHK/Apu4 qNqSYBuqObnTAWg3d/IZYGWU4El2eHJFEDJ9plD8YowKntM0FNmU4P+w9esVqvKbxAvBZBiGvYJX QQ9LKcKZ4b67nGhMeWMAm8H8zyCcw+vcT59C5PbIOz7ROCxNTERWFqt0TmQtag7+B9JTNYbx67oR uYjz/tq9msb8CUB17W7Qw3a0Yn0ri+DV9gq21E/X/oot54dKQFasbkfF+UjgGTeAqjSRf2P5an62 o/lRSwvJg1KcoOqe0mo1HcLQDResoLBljitH8MTpjmamX6jOEv3Fa2dBi2teAmfCsuEnrv023OMU uJxFkHbe3wSvaZ2IA5++Ho6k9VyaZ2tqWr+eQQ1uRDhopnFXMq2vz8SxYW13mkvnxdDHHehfJWFQ Sqk55O85GAUlUJy9ofOlszbB4k+D3hHQMdkHsnnT9Vppb9rIQxH+4fVHls6Khww6CpXKq4Q1KUXh vpnNVx93XJVowovkrA8DFtT71lwXuDOO3njdoRapqs2vcWo7yh/p4BwCiSJiEqeBdJfh1sJuyCL0 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668251527116600 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 d5039f69a9..dce7e34cba 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) { @@ -2173,6 +2174,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; @@ -2195,6 +2197,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: @@ -2464,6 +2467,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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668302; cv=none; d=zohomail.com; s=zohoarc; b=kuEB0sdBi6YC8zkizDPoMs8kB8O46Tj2TtWkWh+0pHVRfoZRISkKZeBbwAFfYNq7FLMyj9DCcXKhzm7YgkrArbDO09tOfo8js9EnPlum+IAlGjQ9LDReESGWiLe9qwCWm4tSGmlpZORuewu+NtvV6ngb+bJ2tgn1jJQYikWC2rg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668302; 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=16dEiaiY5Skr0TPfvMcLOVK53qm28WmbMchpp9G8ABI=; b=mIhRxCR8xiskBsHRGuPRS7opFxpW9c1NKRFB6Iaejkf29hThUEIPZL8OfIJSuIAQ3W63xHScAlO9T22ZHtmHoTzUoc0C4BCtAg81bHKdtBaH353qtmVDrmWDAELc9DQmlUX9MNk0nlWT+Ri2ykDwW+Xp8BAeC9paO5qhQWA+1BU= 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 1747668302699400.76568208832896; Mon, 19 May 2025 08:25:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IP-0006zG-9n; Mon, 19 May 2025 11:20:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IE-0006uZ-Mg for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:42 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IA-0005Ue-Mo for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:42 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 398ED180EA8 for ; Mon, 19 May 2025 17:20:27 +0200 (CEST) Received: (qmail 1586 invoked by uid 990); 19 May 2025 15:20:27 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:27 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Yoshinori Sato Subject: [PATCH v5 17/25] target/rx: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:57 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.997787) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.597787 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=hQkRJhsCAoh/1qVrrVBmBN8T3iX5LzPpXKtF61AGsE0=; b=UOtF0/e117zvdg9jI+GvWBAb1qTKLlw+2AsEFfXaUrJp4WvW0Ia31XPtBvvbRwvOUiDSa7U7kQ eO1PpLUfwYEuVquiscKrEW3Srchr8CN0OTz9LRXVqvMiZjJFMZLe9r9cJKVLFIe9X8SFj6UekTVS qV/Wy948I/vfszrwQ5rgHmc1yGw3ArGnUNIT/haA2TQCA7xYVhMwuOIXiwCFPO6Ol67oIHvQhvA3 VvUHp6Sg5Nvve7FB/FPlb0Iwf7HPfFwrcSAs8pepO7XU6Yfx9CohSriVVsqs2WRpq7wE6JAGqC3y FoaCQ+gvRnoRas1oI41oRifYFYo3Tr6Y3kPRyJOCVqpTsbCT8pe4yr4VsfAMI5w1cC8KTypfZnFJ M8NihCo1MzZv8w250P4QTssU9Mhc4aAPxwWQC1bK7Va0Xj9OoM3R0olh+3H6gdhzLP1oQ4C1IA/T eD46t3nGjFzrpuptQsOkPjYiBb7uSU5z3rw22+ePm+HbfIgKqr88okqnZokTn3wsfSRarhntUHrN 5DjT+kMP+QUfjwFWtf3+7u3uWCoapPB0yA6/zVXt16lBEf7qC9/U7vAwh9wrq+DuBTKS/ShpCDWc 5yYVAr8xll8eQXpkci2JLcsiYEt6qOjDu0rCHXqIlCT9MqQ8/wC5UR2LvUOyoQ9+d+Tsuaqam5J5 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668304312116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/rx/helper.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/rx/helper.c b/target/rx/helper.c index 0640ab322b..09f1c25be2 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 cs->interrupt_request & INT_FLAGS; uint32_t save_psw; + uint64_t last_pc =3D env->pc; =20 env->in_sleep =3D 0; =20 @@ -65,6 +67,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D 15; cs->interrupt_request &=3D ~CPU_INTERRUPT_FIR; qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "fast interrupt raised\n"); } else if (do_irq & CPU_INTERRUPT_HARD) { env->isp -=3D 4; @@ -75,6 +78,7 @@ void rx_cpu_do_interrupt(CPUState *cs) env->psw_ipl =3D env->ack_ipl; cs->interrupt_request &=3D ~CPU_INTERRUPT_HARD; qemu_set_irq(env->ack, env->ack_irq); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); qemu_log_mask(CPU_LOG_INT, "interrupt 0x%02x raised\n", env->ack_irq); } @@ -92,6 +96,14 @@ void rx_cpu_do_interrupt(CPUState *cs) } else { env->pc =3D cpu_ldl_data(env, env->intb + (vec & 0xff) * 4); } + + if (vec =3D=3D 30) { + /* Non-maskable interrupt */ + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + } else { + qemu_plugin_vcpu_exception_cb(cs, last_pc); + } + switch (vec) { case 20: expname =3D "privilege violation"; --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668240; cv=none; d=zohomail.com; s=zohoarc; b=B06K/gMa5QUbgwq89DdK4kUC7gcGQ1CiZRY9bqdhoR8iQjw4ChgUzma0pDXO78DfQu8KXQ2T2O34rHWuuN6E2/wTAOVsKEB86o+PBQbCGiBYdsRFcL/qqrONzZzIilqxxqPkgRUAuMX9296mspLbCQj1935mHe7RJorowuKfQ1Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668240; 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=u0YYc+z2EMH01w1J4eH6zoPxzMCds735jIpzCftFfKA=; b=S8v7+dGSFFMECyX1XfJVFHxWc7q2u9szW8s2Prtuc2wyDQvy0HA1uzXopMwFD7XQP24YtUo2s6bdSPqYFqAIumz8S/XHfP94Bid+zCsDMFfjIoxlAnc5NVu0JSQcofV+Oh7fmJmNOyN0Vud8OH4BIUpBJf25rcmgnui3O/dOgvM= 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 1747668240698193.46151071591294; Mon, 19 May 2025 08:24:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IX-00070W-HS; Mon, 19 May 2025 11:21:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IP-0006zW-Cp for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:53 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IM-0005VD-Px for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:52 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 835DB180E9E for ; Mon, 19 May 2025 17:20:27 +0200 (CEST) Received: (qmail 1602 invoked by uid 990); 19 May 2025 15:20:27 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:27 +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 v5 18/25] target/s390x: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:58 +0200 Message-ID: <71507814db65ebc5bbf8e5944728a106f51e3808.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.996855) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.596855 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=xX6ychV8ZQnfsmmBU699XHy/DI6ddqD8g0NA6IFVV98=; b=NWXiTaPDEUcy2U/RUKb8ptKnNvYFZl4wucXjg/xzl4/kl4SkQkUCNefVSQO+ZCbrWr26C/w8hN gQm1V3UAgLZ2KuYHiUXHx4VfsiEwGVTYEDu1zC+08roz202+CJYaP/S2TX5kfj3Ho9krt3HWgxHG 4oV4MHfJBvMsawCqT3QB8ekv+ef6x4m3hZE4PeO610GIieF9eqEhmfQ2i7Y4mBL+ptQ0pZ5KRD6z LXU+6+0QoQdd+H1x+p45/m7gp3z/JHilhbarpMY/U4Rdx5/qnD+ubHsGJqZFBJJ/xND8BLfrUvu5 vMj7mhHghIY9SS5T8f0AEZiOM3OwcxOBLPdoAOHH6k4busiHyFUEHLkEPQHw3brEd9ervL535Qp6 JwwQBqCX6U9uPlP5C9ry+GBD+fygbsooY1evgXyXXKQzjMOZJoP1loAlaobpS/57Lca27WYB6t1J jFLS0pItglLzRDR+RC97CqSSZVT9fYOPC/QngvPi8NjDJEY6NS5H3968c5WyZZlOmss2urfMnA+e QZN3fpyYOC+e7s7Tp9Qdy11ktnudZmVxD+wOxFmMfISXhJonXGePdPvlOJvAx6xitGSIJGVdUmuo gC8WBdie48Eypo47wbwGVSuXIBxsWAopqkxnSk00XdPfMDjpq15c53kJg3IeYL6dBKQBzjrQpaVO c= Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668241412116600 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 Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/s390x/tcg/excp_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c index e4c75d0ce0..b7e7a4deff 100644 --- a/target/s390x/tcg/excp_helper.c +++ b/target/s390x/tcg/excp_helper.c @@ -34,6 +34,7 @@ #include "hw/s390x/s390_flic.h" #include "hw/boards.h" #endif +#include "qemu/plugin.h" =20 G_NORETURN void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, uintptr_t ra) @@ -499,6 +500,7 @@ void s390_cpu_do_interrupt(CPUState *cs) S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; bool stopped =3D false; + uint64_t last_pc =3D cpu->env.psw.addr; =20 qemu_log_mask(CPU_LOG_INT, "%s: %d at psw=3D%" PRIx64 ":%" PRIx64 "\n", __func__, cs->exception_index, env->psw.mask, env->psw.a= ddr); @@ -528,21 +530,27 @@ try_deliver: switch (cs->exception_index) { case EXCP_PGM: do_program_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_SVC: do_svc_interrupt(env); + qemu_plugin_vcpu_exception_cb(cs, last_pc); break; case EXCP_EXT: do_ext_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_IO: do_io_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_MCHK: do_mchk_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_RESTART: do_restart_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); break; case EXCP_STOP: do_stop_interrupt(env); --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668108; cv=none; d=zohomail.com; s=zohoarc; b=jYykp0+5kdsMrUd7oD3crKn1VZdNq8Fb4zULzYPwzsSAvA8rW41vwm6sUFwGVkPwu1MDzmlwHMbsngFBxVrMP5tgYS8J5XVybV36nG9nAfd4KbK3CKT1Es53mS/4Uwv1vJ47INxrDgclv1KsNpc4XBGXoNzzUyJ62K2X98/++/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668108; 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=iYV1tV2YxmQMbpwN5zYPfl7jSM5ER3kB8fvHsz8eD8c=; b=eSydWRDRvp9VKIGw49oHG1ZgYrqKfCU9R3+cpVkHSlqFiTt6QKxEtBBg8zn9hFIzTAhoW89FtNmu0xzrpDI8rukkAEIcF1JjtvBk/G7yJZsAzPsZwAAwDm/i+12hqlpCuqzuI7s72m/Vl6/WS8OVLtYyobFTMR4vlyaiWw4TJM8= 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 1747668108870696.6194019029582; Mon, 19 May 2025 08:21:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2Ih-0007EL-GT; Mon, 19 May 2025 11:21:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IR-00070C-Oc for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:55 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IO-0005VM-0z for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:55 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id BAACB180EB4 for ; Mon, 19 May 2025 17:20:27 +0200 (CEST) Received: (qmail 1617 invoked by uid 990); 19 May 2025 15:20:27 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:27 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Yoshinori Sato Subject: [PATCH v5 19/25] target/sh4: call plugin trap callbacks Date: Mon, 19 May 2025 17:19:59 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.99762) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59762 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=KlyMN/5qzgjLb+9aIafnthxsp3s3tteWGEJqz7YyfMg=; b=YYPLXajsqDkBGf/TQY571opD/Z4uYw5XtcUstWKb4/zk9yKz7WBXFIeyTOKH/MnJPXsGVEjj+Z s7jIq69h9y83XiCrm1sowg/GtL6eOT2PYThOvGEQsSqNMYHe21XzRO83MkA79Fl+U7A/OB0H+b4r i7WJkURV4RoccNfCHsC7mUWn2S9TlVyvrn45prsyjGaIU/4dSsEt0olos5mw8MrGetDslIPvGk31 B9qGpMBOk5AvEC/+thger7Hk8DZNLfdOp97/Qo6lbBKRyH1viRKwHDTf6jE+X3DVHZiFqSYXz61r 4PDi6PQ+4CkyZADm3zHV3tCdvfXwC3m41XDJLTRFEtZbcmxKf3WtZN5Zbk9W/DBsSwaBfiUkujPb B8nvR4DkeAiybq7AondQgykaW8HsDNcK+kyw+qg96601bk7uM4QQ9FvwNFKV8dl0KVYN97AFWI09 DIHIne9YbTE2+SlpDRlFEgbukdcYL8aJwjXgZkwAjJXwaJMs0WGU50kCM4PKChrHyP95H7XpTSz/ Oa68Gx5DiMFcEEocuUr/3pKzUIX1uMHcMcUakbcQRP4w5RWzebbrljDbpqBnq7Te2nVhdK5OTpXp 7X2tF7TJaStDWEDNSyQqyHZ/0+0gYqfa77aOZsQL2poraU0KqoxPOcCyAlbdRFNwr1H8e8MSQJjN 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668109352116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/sh4/helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/sh4/helper.c b/target/sh4/helper.c index fb7642bda1..ef8760111d 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 cs->interrupt_request & 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668232; cv=none; d=zohomail.com; s=zohoarc; b=glIYxZHOiYL9OIrHtnwjW1dBQ363MpZmaHRNQbeN9Hln4oaegH6nnyaLFBe5anQsk311ku/cFWjlsKxRtXJtBJOghWJYdBWo2XeBDYuUzQ9GNQHuk2U0USjcEOcs38aPLa+hgyxXSCUcukd+F0Z/JR7C1Y0wd/95Yter4k0o14Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668232; 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=dY09v3R5xKlb4nuYH6r18fcqAqgPmNhtLOmqW+qD9FI=; b=hL21ZrzhQP0uXi+N7WghM9eStYieh4scViQcmFz8di9Hd4Ulchru8FF4FmA+7ifuNrsg2qCueO2JTbNcrIFJsNhawbgceazOcLOnTv1nXUt0lEXNsC9EsFBINHiS2H2hAAoOmTXI4ZERdr6bV3x9jkwhcBHvMhjWnvpjKOU1Je0= 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 1747668232982200.01241319626047; Mon, 19 May 2025 08:23:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IX-00070c-Ny; Mon, 19 May 2025 11:21:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IP-0006zT-9U for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:53 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IM-0005VJ-Py for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:52 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 07E2B180EB6 for ; Mon, 19 May 2025 17:20:28 +0200 (CEST) Received: (qmail 1638 invoked by uid 990); 19 May 2025 15:20:27 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:27 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Mark Cave-Ayland , Artyom Tarasenko Subject: [PATCH v5 20/25] target/sparc: call plugin trap callbacks Date: Mon, 19 May 2025 17:20:00 +0200 Message-ID: <74a9841af043f785757ad9c6cb585b51752b15f8.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999515) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599515 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=IdC88N99+YM4YmCWx53I/KZhBjRliJfCHy+BVZ5q4+g=; b=xJ8vZj92AAEZR8I+SczftdCmXasYa/qC6se6EF+YHNPJc1vjyUG1AH9vckvKgFgEYzQYphgX6C hqBoBK8h81hC/n/4sNZuGzKqWflxgfDwWCuP7+v1IlK3jcPno3r4ZKMtWi3G4AEIFhu0IBNcuPwo QfhGVZf7qg0UauhntuBfHbn1HzQ0C7qh4IeaNOlKaYszkwK9YQt1gSQMu9/8Gx6IQyEGpb/slivE mHT5IoC4RUhFoS/i6uEye8Tl+ZT1mCX375kZfGgeXA1cJcXv86C6ZTjAqZC7TRzfFihfEm/UL/XJ UX9ltY1UEpiXEVn5yZtwWFPEu3wmci3eicPB9doURhjTk/UmWdx6QdZbZee7PvUPpAjHccGd1o7u 2uZOjDA0iSeoHuXO1b5rDGuUcoY06WlW1TuE4WKa6Us2sXYWvuMcHOcGQxT3660Loi4hVEE2Tm6M /cfg3XIzHlfSUA8TkwY4UTsSOiB8ByegBMQgflPHw7p4+gZebB811/IRv6YRhKKrbi2EL/4ihCnV LQyG14vJwC1XgKXhVh2oyLvUrk9A48IoqVWoIWQSRzpoHqe/D/fMmFZxUqnpWdn+pULYp5GIqJFV O+Gass+v10Cz9WzBgoKLjDvAp3GZkmFZBIMp9AupbLZK9PB3C63EDD0r4MQUmFj59ndmShYdZQI+ 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668233254116600 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. Signed-off-by: Julian Ganz Reviewed-by: Richard Henderson --- target/sparc/int32_helper.c | 7 +++++++ target/sparc/int64_helper.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 39db4ffa70..634439ab2a 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -24,6 +24,7 @@ #include "accel/tcg/cpu-ldst.h" #include "exec/log.h" #include "system/runstate.h" +#include "qemu/plugin.h" =20 static const char * const excp_names[0x80] =3D { [TT_TFAULT] =3D "Instruction Access Fault", @@ -172,4 +173,10 @@ void sparc_cpu_do_interrupt(CPUState *cs) env->qemu_irq_ack(env, intno); } #endif + + if (intno =3D=3D TT_EXTINT) { + qemu_plugin_vcpu_interrupt_cb(cs, env->regwptr[9]); + } else { + qemu_plugin_vcpu_exception_cb(cs, env->regwptr[9]); + } } diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index bd14c7a0db..9868a80669 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -23,6 +23,7 @@ #include "exec/helper-proto.h" #include "exec/log.h" #include "trace.h" +#include "qemu/plugin.h" =20 #define DEBUG_PCALL =20 @@ -253,6 +254,15 @@ void sparc_cpu_do_interrupt(CPUState *cs) } env->npc =3D env->pc + 4; cs->exception_index =3D -1; + + switch (intno) { + case TT_EXTINT: + case TT_IVEC: + qemu_plugin_vcpu_interrupt_cb(cs, tsptr->tpc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, tsptr->tpc); + } } =20 trap_state *cpu_tsptr(CPUSPARCState* env) --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668144; cv=none; d=zohomail.com; s=zohoarc; b=Rb36pPal765Gr4G/tJ1kMVpr13gZRq/alc64I0ysni/kRiJcN3Q3KcMVmliu2ML4lt0kLRcOEho3TwHf8rVN9CwBqRGLNMeuco8cTi5N7fl7h4/i9h1tJnurfd/cbMEhVSpyppxkr477D0CstFK+4qn1f1uvpX+FTV/Hiy96sdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668144; 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=JinEFQRX0LBXnJQX5lfNJ07p5sYGCNKA6W41bF0G92Y=; b=lRsOryCYWaCgjpaMxJAtf86+NtvpFzHTP2kuvjiy6HQxvxw3nJXedmJzqihZjlWQYLDgW5qRVXnyMlbq08vU82C2Pl8y1q73nfFauzb/jc5RlU8eWVpROTm3NKBlpU0QwoYzyAw0jzjKkkhpKtQ11G1ru3FRZlbFtfH1Se6/dqE= 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 1747668143942547.0532101413853; Mon, 19 May 2025 08:22:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2Ie-00076M-9M; Mon, 19 May 2025 11:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IQ-0006zl-9y for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:54 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IN-0005VS-5M for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 47194180EA6 for ; Mon, 19 May 2025 17:20:28 +0200 (CEST) Received: (qmail 1656 invoked by uid 990); 19 May 2025 15:20:28 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:28 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Bastian Koppelmann Subject: [PATCH v5 21/25] target/tricore: call plugin trap callbacks Date: Mon, 19 May 2025 17:20:01 +0200 Message-ID: <8bd3931ba67e8beb420cb198e2eb16b7b1270084.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.99107) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.59107 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=YXMZB8MgiqIetDkdLVgfF/7lrJrc0D6JsYkbzthKZd4=; b=QhayD4sfEx0RJmDvE8AzmfQiD1m8pNR2wj2f+xXGwmzP/0NBJcgz3wjap+9ceUKXY80hU0orI7 8aGngnPLH4pX5u5LjkIm59RlCtvb/e3ULqExdwWT0kBwz//WzY41XOSEi5mQ6ZkVgGEMq+Yeg1fI 71ugoPU13VzkKnc0thGvIvMFPBLej1snFbjwHHxXTASpa0cXS4C+njmyAWfsQinu92r5QiuttBFx R7vCcSXR5LguqOFLYfIGqPMilrSlUHyZfTdyQY96p8u/Hq5xCg0mWNbqSBbns99bdkmbRXNlb6lD mY1wd2RULIU+MvgnpQFP7UIHaykXGMKAzejsOuwnOMa+W03XWX9WoPJY+p1XSBIDnr+B/T/P+cd4 1g7NR6T9vLaUuw61TGEcHmxovLRXxcFOsRo3b9LcrWTlnbyy28d6UQM385R00UOOUDAVe18G6cHx 86DxRynwb6rMIcXks0vvJUqep1+wg+a5gZPR4ey6FrSTwt+d9S6OmPHe8niMhRZuLXxcp84hRcF5 /LZCy9BAqthezP4y3q6Uq5S/b5F/UHALdeCj7bYtVCvtNmJ+JxvLJc+J+EN7nLpQKQS+I7P+rUD2 wyJT8cWzb3UV8yPicRozVA33DsQxxOhEgjB1ZcmzzVSVIdh6KiEaG4uRiD1+hGYXGHRltH9hQZxG 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668145974116600 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. Signed-off-by: Julian Ganz Reviewed-by: Bastian Koppelmann Reviewed-by: Richard Henderson --- target/tricore/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index 9910c13f4b..9bd6ce55d1 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -19,6 +19,7 @@ #include "qemu/host-utils.h" #include "exec/helper-proto.h" #include "accel/tcg/cpu-ldst.h" +#include "qemu/plugin.h" #include /* for crc32 */ =20 =20 @@ -29,8 +30,11 @@ void raise_exception_sync_internal(CPUTriCoreState *env,= uint32_t class, int tin uintptr_t pc, uint32_t fcd_pc) { CPUState *cs =3D env_cpu(env); + uint64_t last_pc; + /* in case we come from a helper-call we need to restore the PC */ cpu_restore_state(cs, pc); + last_pc =3D env->PC; =20 /* Tin is loaded into d[15] */ env->gpr_d[15] =3D tin; @@ -90,6 +94,7 @@ void raise_exception_sync_internal(CPUTriCoreState *env, = uint32_t class, int tin /* Update PC using the trap vector table */ env->PC =3D env->BTV | (class << 5); =20 + qemu_plugin_vcpu_exception_cb(cs, last_pc); cpu_loop_exit(cs); } =20 --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668209; cv=none; d=zohomail.com; s=zohoarc; b=cxomncpfalNh61dxLnr9QskIZOXli2SK0a4WN4XkB9h465Fe+6tjYaOtufTS05IvNUxATUJITVPYKnwXoeRX8noFAQKeHxv833QYpMlHvVfjY6mYtXoaFXoyF83m0JZyuRLgjAbPl90zmif5ctV629COmG/L0lgBHY39+32kWUM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668209; 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=Cee1KqNJxQEupzsvRdrh7eYnPR+MiKvhvoye6a7AVR8=; b=GoDlvPhKVW70l2osNFaexwSjHSmTMGtcDcBlNAXlFM9ydhXH2BZPBQ5YhOcJqgNXkwGSQQkTzUG8vHYViK+fVTbDoCFcJ9qdb0p4ikl1tNYSRGBZIZdx50pEIdtw4raqC7LHH/GvcNe3sa/uzpGKpC5pRnnTYfF9h7UICDlkOO4= 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 1747668209829610.6755068554681; Mon, 19 May 2025 08:23:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2IS-00070M-CR; Mon, 19 May 2025 11:20:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2IQ-0006zk-9Q for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:54 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2IN-0005VR-6M for qemu-devel@nongnu.org; Mon, 19 May 2025 11:20:53 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 82A53180EB0 for ; Mon, 19 May 2025 17:20:28 +0200 (CEST) Received: (qmail 1668 invoked by uid 990); 19 May 2025 15:20:28 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:20:28 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Max Filippov Subject: [PATCH v5 22/25] target/xtensa: call plugin trap callbacks Date: Mon, 19 May 2025 17:20:02 +0200 Message-ID: <27ecbe19c5e2c39166f050754a30249de573d635.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.999597) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.599597 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=pn68r0uYyRci5PiYa0KzEBE+m3ljCBB7beZPQsIx0i0=; b=ERg8TJe9nvxmUtb8eEihO5XkBTRiEbsrRZ00Z1JmqEYeEbIrRdlnW1wMnIeVhWhOms66jNr/bV 21aMNJk6n/Wd5HT6RTCYBZxYwLF2Pf0S3tGyJKHM2LZinCUr5yG8nK2NFB0qBumQSvo0AZliw/h5 7NROapPWov64AnRb1jk0R+U82qJwvwV1SZL28QNEBv0IjP7R+ONDtgW/mUQYDSXcRqCdj8SsXu6W iW0X0mPN5bbvOhDSGUyKmeu/u5QKecjXDnaAJapxRMoUqUtoP4ddAmnvtf0ymASicoUApX/rV0Pw czzevzTqYNrSaGLqa0QgHuEpT5qok2F2yAFuKAoKq3sC/Exgors/vNMkVqMwNYn7/qaorTvR3PIA m0oqn4zpv2Zz9yHf4x3DLF0nDOK24df4Zt9xWAeaz0kifr8wHeG1APk5lRMg2s6QqO1LGWOcl0wr RljBVCcSAmEVSJ+zZvLulL2XhEwg0Q1v9A4oO+kWcbBS5WdjeIgF2X/q1CO6vVt5Hp0toyX0SWA/ BUvGWHNE+OUCnTGJM+rrzt8XQO+c6IQ6INdqTrNc3bZSbkRuDnVtJJRVTvU2XgR3nau8xUnjomWM hzWXbJXCuFcovyvsRdsTbwIZAH7t0dquCRmrdzmCPxE7KwVrIqV8cfi5QBk2Jh21LPtO5RATDNFO 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668210961116600 Content-Type: text/plain; charset="utf-8" We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for xtensa targets. Reviewed-by: Max Filippov Signed-off-by: Julian Ganz --- target/xtensa/exc_helper.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/target/xtensa/exc_helper.c b/target/xtensa/exc_helper.c index b611c9bf97..fdc522698d 100644 --- a/target/xtensa/exc_helper.c +++ b/target/xtensa/exc_helper.c @@ -32,6 +32,7 @@ #include "exec/helper-proto.h" #include "qemu/host-utils.h" #include "qemu/atomic.h" +#include "qemu/plugin.h" =20 void HELPER(exception)(CPUXtensaState *env, uint32_t excp) { @@ -207,6 +208,8 @@ void xtensa_cpu_do_interrupt(CPUState *cs) CPUXtensaState *env =3D cpu_env(cs); =20 if (cs->exception_index =3D=3D EXC_IRQ) { + uint64_t last_pc =3D env->pc; + qemu_log_mask(CPU_LOG_INT, "%s(EXC_IRQ) level =3D %d, cintlevel =3D %d, " "pc =3D %08x, a0 =3D %08x, ps =3D %08x, " @@ -218,6 +221,7 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[INTSET], env->sregs[INTENABLE], env->sregs[CCOUNT]); handle_interrupt(env); + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); } =20 switch (cs->exception_index) { @@ -238,9 +242,11 @@ void xtensa_cpu_do_interrupt(CPUState *cs) env->sregs[CCOUNT]); if (env->config->exception_vector[cs->exception_index]) { uint32_t vector; + uint64_t last_pc =3D env->pc; =20 vector =3D env->config->exception_vector[cs->exception_index]; env->pc =3D relocated_vector(env, vector); + qemu_plugin_vcpu_exception_cb(cs, last_pc); } else { qemu_log_mask(CPU_LOG_INT, "%s(pc =3D %08x) bad exception_index: %d\n", --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668349; cv=none; d=zohomail.com; s=zohoarc; b=SIRm4ISQTad9hV2p3xphjuLkmKPUEoaJlJMpNP2McRBElYn8loLPLc8PZrFzbiYH29iXJivnRcb8E++VliAdizZxTyH2p2WN26wG4ITzOymOc3pPMVl/gjHV7OhhzEZp/5Sfrnh5nb86W7EEz/mnpyBM/pw2c908LCdI7HBY6Uk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668349; 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=o4VgPQZXrvAeF6AGxobAdYopEjt48Von5FwZ410EzEw=; b=Hew43wXQNrQ6piHWrpLwe4e9rSFDPpd/P7w9on+1JzYCpvl/zkYZHCwpoA5hkYpjh3B3Y0Okt/yGDFriCdZOyV67sUbOmCDOGmIEE/Faj5H4Ylfz13E52od1uiOkV5ADcKf1vi0/nA+tGDSgGn5EcG0hWk80MBIDqssjDrGKYmo= 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 1747668349484525.8295654365322; Mon, 19 May 2025 08:25:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2MG-0008W8-Ps; Mon, 19 May 2025 11:24:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2Ln-0007xN-Co for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:26 -0400 Received: from mailgate02.uberspace.is ([2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2Li-0005oU-J0 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:23 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 6514B180EAE for ; Mon, 19 May 2025 17:24:17 +0200 (CEST) Received: (qmail 5944 invoked by uid 990); 19 May 2025 15:24:17 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:24:17 +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 v5 23/25] tests: add plugin asserting correctness of discon event's to_pc Date: Mon, 19 May 2025 17:24:07 +0200 Message-ID: <2a30a629012f39f8495415f87568fe9b3a0eb32b.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 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=4SF0Y+dqaHinO+9T1gaTFBgtUGDULaBri30lZLDat5o=; b=yrUSM+YHt2JynGD2aMAUSUqnpQnnqNEhP2xBL30LOzj+/hH2iYZkV1850kR2n5nHBjfOFc1sEL 8EoURQ2P9Njxf/o3pDqyCrye/1eh5JJHzNnLWrHk7nXx0/G75TNdZt0ZUwgsIaR3BnaIF9uyqZDI jJFHt1ibt0PCbXrcoTaLOxek7wAKijWQMED3X8Or5U882788r4xJt2wBxmJPfSGnL1Yu7wwqqLrP MuKS/Pl56a151MCd9AMw21Hu9z+KXB3yL3C6AnAU4g1QoWwmI0GE0VTX6vOAw/IbOneRVIgpbPez ikRYbx0SDxry9D+zuRPCW2aFh1johH+w4C8lAlEp47b33iNcHACItoqWDbDsZKVR36esPXBCxbCW XlPlBMWmGmp/xEVuqcCQeyF8Cro9Y+2IIGA+OL7l/X2SvUAVehHXUPAgsl9n70Fb6xEyZBcL5pkf +PX2jCwbXK73I09px+EBC8RgxQrRm4v8SNtD+5XKAmCSKw08NYP0jrkl6oA5S+vmX7/AW5QfksMD MZ5FgFhdhBnq3FqmtJnLmzswVEL8Y55oRO/OiJF8BM1VEnG9UIyPmNXdFTK9rqXtyjEjG6C4VKlu silQANTVurzV4npxGu9KTG5oILWcQWMbMcF413kpZMu9iztjJmztrUx8qONmkLKFbi5FVF0jlweQ 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=2a00:d0c0:200:0:1c7b:a6ff:fee0:8ea4; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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: 1747668351074116600 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. Since instruction PCs are recorded at translation blocks translation time and a TB may be used in multiple processes running in distinct virtual memory, the plugin allows comparing not full addresses but a subset of address bits via the `compare-addr-bits` option. Signed-off-by: Julian Ganz Reviewed-by: Pierrick Bouvier --- Pierrick: I did implement the changes you requested, but I did not add your Reviewed-By because I felt the changes were not trivial enough to not require a new, coarse review. tests/tcg/plugins/discons.c | 216 ++++++++++++++++++++++++++++++++++ tests/tcg/plugins/meson.build | 2 +- 2 files changed, 217 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..afbd1b400d --- /dev/null +++ b/tests/tcg/plugins/discons.c @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2025, Julian Ganz + * + * License: GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + * + * 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 uint64_t compare_addr_mask; + +static bool addr_eq(uint64_t a, uint64_t b) +{ + return ((a ^ b) & compare_addr_mask) =3D=3D 0; +} + +static void report_mismatch(const char *pc_name, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t la= st, + uint64_t expected, uint64_t encountered) +{ + GString *report; + const char *discon_type_name =3D "unknown"; + + if (addr_eq(expected, encountered)) { + return; + } + + switch (type) { + case QEMU_PLUGIN_DISCON_INTERRUPT: + discon_type_name =3D "interrupt"; + break; + case QEMU_PLUGIN_DISCON_EXCEPTION: + discon_type_name =3D "exception"; + break; + case QEMU_PLUGIN_DISCON_HOSTCALL: + discon_type_name =3D "hostcall"; + break; + default: + break; + } + + report =3D g_string_new(NULL); + g_string_append_printf(report, + "Discon %s PC mismatch on VCPU %d\nExpected: = %" + PRIx64"\nEncountered: %"PRIx64"\nExecuted Las= t: %" + PRIx64"\nEvent type: %s\n", + pc_name, vcpu_index, expected, encountered, las= t, + discon_type_name); + qemu_plugin_outs(report->str); + if (abort_on_mismatch) { + g_abort(); + } + g_string_free(report, true); +} + +static void vcpu_discon(qemu_plugin_id_t id, unsigned int vcpu_index, + enum qemu_plugin_discon_type type, uint64_t from_p= c, + uint64_t to_pc) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (type =3D=3D QEMU_PLUGIN_DISCON_EXCEPTION && + addr_eq(state->last_pc, from_pc)) + { + /* + * For some types of exceptions, insn_exec will be called for the + * instruction that caused the exception. This is valid behaviour = and + * does not need to be reported. + */ + } else if (state->has_next) { + /* + * We may encounter discontinuity chains without any instructions + * being executed in between. + */ + report_mismatch("source", vcpu_index, type, state->last_pc, + state->next_pc, from_pc); + } else if (state->has_from) { + report_mismatch("source", vcpu_index, type, state->last_pc, + state->from_pc, from_pc); + } + + state->has_from =3D false; + + state->next_pc =3D to_pc; + state->next_type =3D type; + state->has_next =3D true; +} + +static void insn_exec(unsigned int vcpu_index, void *userdata) +{ + struct cpu_state *state =3D qemu_plugin_scoreboard_find(states, vcpu_i= ndex); + + if (state->has_next) { + report_mismatch("target", vcpu_index, state->next_type, state->las= t_pc, + state->next_pc, state->last_pc); + state->has_next =3D false; + } + + if (trace_all_insns) { + g_autoptr(GString) report =3D g_string_new(NULL); + g_string_append_printf(report, "Exec insn at %"PRIx64" on VCPU %d\= n", + state->last_pc, vcpu_index); + qemu_plugin_outs(report->str); + } +} + +static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) +{ + size_t n_insns =3D qemu_plugin_tb_n_insns(tb); + for (size_t i =3D 0; i < n_insns; i++) { + struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, i); + uint64_t pc =3D qemu_plugin_insn_vaddr(insn); + uint64_t next_pc =3D pc + qemu_plugin_insn_size(insn); + uint64_t has_next =3D (i + 1) < n_insns; + + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + last_pc, pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + from_pc, next_= pc); + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu(insn, + QEMU_PLUGIN_IN= LINE_STORE_U64, + has_from, has_= next); + qemu_plugin_register_vcpu_insn_exec_cb(insn, insn_exec, + QEMU_PLUGIN_CB_NO_REGS, NUL= L); + } +} + +QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, + const qemu_info_t *info, + int argc, char **argv) +{ + /* Set defaults */ + abort_on_mismatch =3D true; + trace_all_insns =3D false; + compare_addr_mask =3D -1; + + 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 if (g_strcmp0(tokens[0], "compare-addr-bits") =3D=3D 0) { + if (g_strcmp0(tokens[1], "full") =3D=3D 0) { + compare_addr_mask =3D -1; + } else { + char *end =3D tokens[1]; + guint64 bits =3D g_ascii_strtoull(tokens[1], &end, 10); + if (bits =3D=3D 0 || bits > 64 || *end) { + fprintf(stderr, + "integer parsing failed or out of range: %s\n", + opt); + return -1; + } + compare_addr_mask =3D ~(((uint64_t) -1) << bits); + } + } 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 41f02f2c7f..1b13d6e614 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'] + foreach i : ['bb', 'discons', 'empty', 'inline', 'insn', 'mem', 'reset',= 'syscall'] 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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668433; cv=none; d=zohomail.com; s=zohoarc; b=GyPbiz+9FuKGCslJyNvmpQor4oPGzoa4w6zxkOj3Lfh4PklobCEZvW9Kq0Mf8st4RyS1aPbqD/PcRG+7T8f87+BE9PtdNJwxLm0DwgDCr0h9NvTWDYe7o9vkwj290jHX52/DROKU9cJbNIytkmXYSKhtLvcSgMHJr2JGFLZ8vFI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668433; 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=hGFk7ymJHKHAG9m2P76drx1S0Y9MKSjZKlQ+env9ZHw=; b=StaGSu2D1PUzVA0PTLZo5LdLtgRwYxYgrkDrnalbgz0DNR4XtQqIIzl22fUkLPeWZUHUA+LCibyCbzdygGthgtwji3Heippf6WKLTxLYXU5NNfxxSCFxqCASg4pbx4tPB0RLWQYxb9NJDESRnN9RNvY53zPtfczgkbMufYbxIXY= 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 1747668433314870.5085578685575; Mon, 19 May 2025 08:27:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2MB-0008HM-OH; Mon, 19 May 2025 11:24:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uH2Lm-0007xJ-PU for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:25 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2Lj-0005ob-8B for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:22 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id E87A9180EAB for ; Mon, 19 May 2025 17:24:17 +0200 (CEST) Received: (qmail 5968 invoked by uid 990); 19 May 2025 15:24:17 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:24:17 +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 v5 24/25] tests: add test for double-traps on rv64 Date: Mon, 19 May 2025 17:24:08 +0200 Message-ID: <83fc9462a895d5c0d9edb9e8bcce980c27d8fc81.1747666625.git.neither@nut.email> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.951293) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.551293 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=oVnnQOlaHDcgULY7mP8Q+DwiS6v0Cp7ANlJ4mQwWq6E=; b=BZ0+ABjWajvIgKu6PBcdFdjhGksEzA1PUheRsyIz4rcgCkX/vqZ4lmuPEdW1qathmqDKHT5IPr gRZ3rKwC5UOoGxUw6gDWDbY7RzvXaDR/e5H51LjITYemhlZt2vYBNcxJqFgfMS5pLNlt+IXigZtS W56UqMWCnYCUqzkVrG1pwjWJEKe0QZTsafONbQlGhxNqLCoweIqmybyGja0f8RK6+1NkX7tNu0jg drtRx9jEcjf4qQqNPMAgg82TudbtwaiT3sCtZh9UIJvHjW8GEbaACqLipx1WsOnR1ikS6MXjIX0H jMcSK6AjxQUP7ICxbDycZKdJVbRaYKllQ6uUvx3oejkLGX94lUD0i0KXfkP5GSoj+ycjpX9vdsdf 23L76IddwiDBU9yYw/mjNMJ5Tsc+ljjFdgfwxFCE1dpIGapN5tZY2vn4Yp8Jl16M3YLMcS8MAqMc VGslOmiv//n0WiuwbBjuhpXdWuU4Sai2O6Nk+EkdHGuVU5TYycJdKIInW9u5s6a3x415WcIYovBz yEW2ssxckRWKp7eWqlFhjlFmPDXChOcA7/LBItz342fz82VgthJj39kiTOugLZcviWuBiXghk6uX ZYUnbfEeGRDFYMllyAvy93/G71HwqQ+OmqITROneDr9uWmkBFsftEqK1UYVsVJ22NHnlJ3Vygngv 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1747668434250116600 Content-Type: text/plain; charset="utf-8" We do have a number of test-case for various architectures exercising their interrupt/exception logic. However, for the recently introduced trap API we also want to exercise the logic for double traps on at least one architecture. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Julian Ganz --- tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ tests/tcg/riscv64/doubletrap.S | 73 +++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/tcg/riscv64/doubletrap.S diff --git a/tests/tcg/riscv64/Makefile.softmmu-target b/tests/tcg/riscv64/= Makefile.softmmu-target index 7c1d44d3f4..5fba973e18 100644 --- a/tests/tcg/riscv64/Makefile.softmmu-target +++ b/tests/tcg/riscv64/Makefile.softmmu-target @@ -20,5 +20,11 @@ EXTRA_RUNS +=3D run-issue1060 run-issue1060: issue1060 $(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.0 From nobody Sat Nov 15 20:47:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1747668341; cv=none; d=zohomail.com; s=zohoarc; b=F2dsttbEckFeDGqljF67dqqx9jzNv92YgUVb0esnb4QIMnYvTHKJifWHwhBPCH680ql71pEFORkqJgbW7kBzaR6Ypj4kq9fFop76UNJrTySwzZ/VNK69BqUTiTLZwn6+ncU7ZDXAAAFN4o6xuhf/wTWPRZrca6ChsWliWP3dGZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747668341; 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=xeRtQAeWYMCo8/En6ifb+PxiRYL6rP7G9H9Ehl0eYW0=; b=VyKwH+qZvMYA1LY53jhlDi5V8GONZhFRz9k0ScUXa2smKiZ/Lxs1FhSxiPSGXeh/VjZdZFxmT9JqGVbKcKC1PM4JfLAPuOCZgZSDl0/7dxOqnjleceJ3BR639dkAslJrZs3Sv9HwHBqTASND5bSLMSiGJWdXAohtJ1dFYfb29NA= 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 1747668341308570.865569571793; Mon, 19 May 2025 08:25:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uH2Mb-0000dg-JO; Mon, 19 May 2025 11:25:19 -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 1uH2Lm-0007xM-V9 for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:26 -0400 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uH2Lj-0005oj-JU for qemu-devel@nongnu.org; Mon, 19 May 2025 11:24:22 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 4BF20180EB6 for ; Mon, 19 May 2025 17:24:18 +0200 (CEST) Received: (qmail 5993 invoked by uid 990); 19 May 2025 15:24:18 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 19 May 2025 17:24:18 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Daniel Henrique Barboza , Palmer Dabbelt , Alistair Francis , Weiwei Li , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [PATCH v5 25/25] tests: add test with interrupted memory accesses on rv64 Date: Mon, 19 May 2025 17:24:09 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.776343) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.376343 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=HE7sfSzhKX2oFLAmIERtf6GP8LdpE8qiGbOolHCRMo0=; b=E1zj/b59fiKKOk/syU18Z8rHMwqFa0FCOd85IeLc0yv9IkskTATyUOQk/L0OGB4fyUFl0+guHz sJ/LuExk/glw4nn5OYklBJiyW/1KpQQcyeYGso8or1YqwvMdE5sMzjMiAfcxJ5lvywC44AbpfuOU GhQSbXagYjggE8Fnp9TvUmF1ml1RpHF538NvEmY/ZZTQ7Kpx8RgSXFdHE3ghzynliVeYp2eaTVX1 gDe8rOI4iXgFtTwCN/hFAuMwEDUwMXt61Bv4Q/2sjkhDcXAfs5gZru0r/n2oMZCQoJtiXp2rHEi1 r9fP758i17Qsdp/y2g/Q4fV51+MmM4JMgTUJSBfoECdxLEeIfLLtCw1W0hqktk7zpRxIWNZijI5p qZ5dHL+4PYljSwrL7WttxgZgx9Kaz43uOKDTtXYUi2qlYMV+A8cGXR03WSgynv8On0JiBFB/Rc3z hrv2tYMC2yXzoPTVGge91S08SdcS9zjP7D3CLTZTJj6iMK7iXyLLL/F+oakMboOFegVpZjtr1wgU g3CB7S7tSZM3hOUXsPlrd53iU2gfsfsp48SOGoBzAXIo9HuILHCAQ08z5ZVNo7klnHipjCciKk46 p2ReNXA5HfQimWf/FrG14GaNWYGCrXEF+39z9+djLgeoGxCoP4a/4G5VH4iF2uWZ9v1umeEs6buZ 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1747668342766116600 Content-Type: text/plain; charset="utf-8" This test aims at catching API misbehaviour w.r.t. the interaction between interrupts and memory accesses, such as the bug fixed in 27f347e6a1d269c533633c812321cabb249eada8 Because the condition for triggering misbehaviour may not be deterministic and the cross-section between memory accesses and interrupt handlers may be small, we have to place our trust in large numbers. Instead of guessing/trying an arbitrary, fixed loop-bound, we decided to loop for a fixed amount of real-time. This avoids the test running into a time-out on slower machines while enabling a high number of possible interactions on faster machines. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Julian Ganz --- tests/tcg/riscv64/Makefile.softmmu-target | 6 ++ tests/tcg/riscv64/interruptedmemory.S | 67 +++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/tcg/riscv64/interruptedmemory.S diff --git a/tests/tcg/riscv64/Makefile.softmmu-target b/tests/tcg/riscv64/= Makefile.softmmu-target index 5fba973e18..5d07755964 100644 --- a/tests/tcg/riscv64/Makefile.softmmu-target +++ b/tests/tcg/riscv64/Makefile.softmmu-target @@ -26,5 +26,11 @@ run-plugin-doubletrap: doubletrap $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ $(QEMU_OPTS)$<) =20 +EXTRA_RUNS +=3D run-plugin-interruptedmemory +run-plugin-interruptedmemory: interruptedmemory + $(call run-test, $<, \ + $(QEMU) -plugin ../plugins/libdiscons.so -d plugin -D $*.pout \ + $(QEMU_OPTS)$<) + # We don't currently support the multiarch system tests undefine MULTIARCH_TESTS diff --git a/tests/tcg/riscv64/interruptedmemory.S b/tests/tcg/riscv64/inte= rruptedmemory.S new file mode 100644 index 0000000000..a32d672849 --- /dev/null +++ b/tests/tcg/riscv64/interruptedmemory.S @@ -0,0 +1,67 @@ + .option norvc + + .text + .global _start +_start: + # Set up trap vector + lla t0, trap + csrw mtvec, t0 + + # Set up timer + lui t1, 0x02004 + sd zero, 0(t1) # MTIMECMP0 + + # Enable timer interrupts + li t0, 0x80 + csrrs zero, mie, t0 + csrrsi zero, mstatus, 0x8 + + # Find out when to stop + call rtc_get + li t0, 60 + slli t0, t0, 30 # Approx. 10e9 ns + add t0, t0, a0 + + # Loop with memory accesses + la t1, semiargs +0: + ld t2, 0(t1) + sd t2, 0(t1) + call rtc_get + bltu a0, t0, 0b + + li a0, 0 + lla a1, semiargs + li t0, 0x20026 # ADP_Stopped_ApplicationExit + sd t0, 0(a1) + sd a0, 8(a1) + li a0, 0x20 # TARGET_SYS_EXIT_EXTENDED + + # Semihosting call sequence + .balign 16 + slli zero, zero, 0x1f + ebreak + srai zero, zero, 0x7 + j . + +rtc_get: + # Get current time from the goldfish RTC + lui t3, 0x0101 + lw a0, 0(t3) + lw t3, 4(t3) + slli t3, t3, 32 + add a0, a0, t3 + ret + +trap: + lui t5, 0x0200c + ld t6, -0x8(t5) # MTIME + addi t6, t6, 100 + lui t5, 0x02004 + sd t6, 0(t5) # MTIMECMP + mret + + .data + .balign 16 +semiargs: + .space 16 --=20 2.49.0