From nobody Fri Dec 19 07:33:52 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=1733167744; cv=none; d=zohomail.com; s=zohoarc; b=SE70thYp4Vd5SbcL03GLQGJ2cFsJoNvAYOsbm4sjfoMssUnc/lA+alHREucTsnSoS02zeuU4dHO8H5duyUPix84qr94eIULrhcWduQhUPrsQKij+HWcR2xxrFA82/3dD/0mQNqwJ3sVeK090pYGPpeferj7fkyO1BCGXz9IlQCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1733167744; 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=ss8BmUM6arEHjSlwjiz9vdiUa4IohK408kzj/nzJJR8=; b=IiUXYXKlmw1BMQG6jb1seRnRl3FsITsYPTJTrD+/OUNvdHUeavqbrb9ZLWN03JMmoEwBpfhxhhF9FvKb1j74TkXTM5af1p5v+AXh8Z/sOOHJVe+G24BaKTFg6n92VTlbpZ0Tx0dJcKCVww+jPf0tH0hoJwL2uB0wem2LPf9+EKA= 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 1733167744872395.5191766691079; Mon, 2 Dec 2024 11:29:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tIC56-0005lG-D2; Mon, 02 Dec 2024 14:27:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tIC4r-0005ij-Cu for qemu-devel@nongnu.org; Mon, 02 Dec 2024 14:27:26 -0500 Received: from mailgate02.uberspace.is ([185.26.156.114]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIC4n-0001uj-LV for qemu-devel@nongnu.org; Mon, 02 Dec 2024 14:27:24 -0500 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id DA1A61809F3 for ; Mon, 2 Dec 2024 20:27:12 +0100 (CET) Received: (qmail 7114 invoked by uid 990); 2 Dec 2024 19:27:12 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Mon, 02 Dec 2024 20:27:12 +0100 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: [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks Date: Mon, 2 Dec 2024 20:26:43 +0100 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-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=aJDEWw/vgtoK+ozg8zQ+6xYZJOVjyXSFJiZhR8xeimY=; b=nt++v4fG3WGfL9Oqx4bXxjTCmhDqH7n3ZTr1bnxwLwwg2b8uRJggWoaE0kBsjyvlQjK//We6rl gcUODlu+KKlAIieKErXD3jccsnhMgW/eNX1fJTa3rI3u+TByNNIy2O/D9bJg6o/xgRSFl9rWUnev ar1ndsP02VWPf4Jk8MXmsHQKv/i34iQP4OXI2KNzYdrc8JMAkgsW/5yhWekIxkQ204vGFQvbNR3Y AX9Sqi55C3YTTpcKsxQ8DOTUaz0vyo1a3xq7ObjM3guf5bzSTC9uHF7V91++X4DHH+ABCRQ3z/TM shLMK3h8u2Ji8NNVY39+wJxATOZP/QKAPi/zw6nOyFZLH+vHJYd20rO8KOBdyiyv/SaQ8mdbY7X1 7M/JJwFjBI5ZEiUAWE2w+p4vtqIqDjWgl+ySe6B+dTEQ+dq1oWfRCIvbuWs5WW71xwJskV6+3WMw TdwftUW8JSwlgj6hIkdUUYISnBFxVpjR8N5aLRkQGfjiT0x33ZsbynQeS+On9gZqgc5PIWWxC94s osKOcd5Azexk9zWLjhj9Zl9qCu9XSB1hbaKuEYxfJxOE5TKpUfER+Q1+lxeHNZrLYTcOglOtNFKD hcw7ujvVc7D2ISJY8TV7e9gvZ3CXwgQ7IXQUIMcH/PjTObjv1yTJBmHpOArovJIyH6FDxDctOw8Q 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: 1733167746156116600 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 --- include/qemu/plugin-event.h | 3 +++ include/qemu/qemu-plugin.h | 15 +++++++++++++++ plugins/core.c | 15 +++++++++++++++ 3 files changed, 33 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 9c67374b7e..f998a465e5 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -273,6 +273,21 @@ 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 + * @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 usually entails updating the PC to some interrupt handler o= r 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 bb105e8e68..a89a4a0315 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -559,6 +559,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.45.2