From nobody Mon Feb 9 07:52:09 2026 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1761753175; cv=none; d=zohomail.com; s=zohoarc; b=SOBk777JX/TITITb93ZTf/fD83mLnGya35MrVlK9vfOmRAecSrCO9Dv+5Gc8Pu0aSGdWXKphhMNHIwp6SGyOSCzfFZoOvqbtgaTo+YTEF6B197Dw3/UxErNySPMsdSBI6/+1GDh29v7Kd4D/e43TNI4gLNXcGcdwXH3OeTZ1gLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761753175; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fhb+7Qy/aaY0P5BrwBDb6iFOKoQxT9GF6cclukqj4aw=; b=khvsh0JHtq3d30F3HWJUEQCpwwNhbSQDWovDghzzhmD9sITn5EYkg/Gn1N3d1AmoTmEikXv3ZY4vm9D3kLgSYDxxfMuwlqIVk4JUkTbyiWu7u479mi9cWD4fn8/wqc7RtcYV9Yb9+4wG9giilatEMGx5DltV4dEApNxQTEjD4vQ= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761753175920481.998796500509; Wed, 29 Oct 2025 08:52:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vE8S6-00043L-J1; Wed, 29 Oct 2025 11:51:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vE8S4-00042I-C0 for qemu-devel@nongnu.org; Wed, 29 Oct 2025 11:51:08 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vE8Ru-0002sb-3c for qemu-devel@nongnu.org; Wed, 29 Oct 2025 11:51:08 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b6d5e04e0d3so2730366b.2 for ; Wed, 29 Oct 2025 08:50:54 -0700 (PDT) Received: from draig.lan ([185.126.160.19]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b6d85353ff7sm1475768666b.22.2025.10.29.08.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 08:50:50 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 9F4415FAE6; Wed, 29 Oct 2025 15:50:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1761753052; x=1762357852; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fhb+7Qy/aaY0P5BrwBDb6iFOKoQxT9GF6cclukqj4aw=; b=aX64Nmrj1glK0I9Fa0Q1mcgCnblV0uy0Tdw1iuZGf5N9ct+U8WP/3H0tWEUb0QN5Lp YMf2Gr55YBMJb571GU7ntdpnoy9cf3cwQvsOgHx16Ya1ifv60wH0CUz2C5EAkgGO+E7I ao7CsYwwQMoxpFT1cCrDzZRDZvxaPv70audRLJSUDb7VJBgN/DUPG1YF1lnAhy89vmhs Mi5tzcWsvw34NYJaSHqbpSFHFnrTt7r8Eb9Mew5W6oRHASI7QTkFasDQmMk+qQs4mOPw dFTWC2GafrKKBOBqycTcnsVR/asT78CEytjoXDrHt8Odf5d8KrY5+u56HsZ0AVdjUX5p HLKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761753052; x=1762357852; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fhb+7Qy/aaY0P5BrwBDb6iFOKoQxT9GF6cclukqj4aw=; b=HpLKsf9+Mr0kQbOZrsUqW6z6PKXwe3fSxw0vk44hnJORxUsT29Y4yd/5K5Zxqdod9l IqUrzI8HJKkzu6FcipD5CqyjDMB7mTE0Oo+2USgtJOEqzrO5J7KpYKnZ0c7otlk/Mvn5 FcRi4gyLQ7b/y316Xi0lk5eK6FmC+IRQalR7Zg0wxUvmsxgo3f1XBj8+CuRmbooFeppC q72yfpo2ek37AcMlKdyDiNwwQgyQXllnQQZpzd2+qpcDPXb6F23q//WXbcFCXUzyq50A /Xos/i/I61/Smz4ojfHl/pPFtPq1/PqPVDgYh9Dpm3wXTCWxVbZMwx5Qt1YDOhsLgX7a XWvw== X-Gm-Message-State: AOJu0Yw03dyixEjMNBVABBi/Fbw4qq1UpeMVgl+R4Ja5YsNdtQPLEjm4 VBctQTPdcfcEFlXCoFEyFVAYxy4mhejZbkpw8m8JobS+qPri812Dn+SRotpLTLsW8Uc= X-Gm-Gg: ASbGnctr5hygbsLl+bfc0SeClbEMSVxBlZaM1bVolIjJ8JrnQn/cPFabi46t2poFDtD tQ0dHWDao4y/yxfe/8M96GDIlwsro8UKWyJqWvXjixyHJOWSG5T4uJP7xLgnCKJpLnZE76ujJht vx+9a4ufllojwCEUwhp6/NanY6qT2ijjBbggXMh6c3rcgmcu8mecMVp3t554MncQ3LY0WjVdXeS 3j2OFK1IdG6YBnWO4peDi6pzRdknnbHly+aR3W5kEzbCE9o8Fo+ZEfqfD1c4efDEFFExtH24XHv 978n4dLToqghXS+W4V217AE+0Th0K9XCIoYgyaZy10t++dpoMPutiok3iYoeUocznIQvoGqQ1ki NgTYcgrDHZeLnNz5ChTUEUpbY5/pshPe2JgjrlRBBAKaWvp3DPJjkqhmuOALeuoOhQuKdKZCijX jr X-Google-Smtp-Source: AGHT+IFCzOgsW8c3t/UdEfGN6N5tXpvg6NmQmmAsgRwrUV2tDyctQC8FL+k4YZRcDWTRKOsG3DVv4g== X-Received: by 2002:a17:906:4fca:b0:b1d:285c:e0ef with SMTP id a640c23a62f3a-b703d36dd21mr334808466b.26.1761753051773; Wed, 29 Oct 2025 08:50:51 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Julian Ganz , Pierrick Bouvier , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Alexandre Iooss , Mahmoud Mandour Subject: [PULL 08/35] plugins: add API for registering discontinuity callbacks Date: Wed, 29 Oct 2025 15:50:17 +0000 Message-ID: <20251029155045.257802-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251029155045.257802-1-alex.bennee@linaro.org> References: <20251029155045.257802-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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:1450:4864:20::634; envelope-from=alex.bennee@linaro.org; helo=mail-ej1-x634.google.com 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_DNSWL_NONE=-0.0001, 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 @linaro.org) X-ZM-MESSAGEID: 1761753177000158500 From: Julian Ganz The plugin API allows registration of callbacks for a variety of VCPU related events, such as VCPU reset, idle and resume. In addition to those events, we recently defined discontinuity events, which include traps. This change introduces a function to register callbacks for these events. We define one distinct plugin event type for each type of discontinuity, granting fine control to plugins in term of which events they receive. Reviewed-by: Pierrick Bouvier Reviewed-by: Richard Henderson Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Julian Ganz Message-ID: <20251027110344.2289945-9-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h index 7056d8427b7..1100dae2123 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 08bf366e363..60de4fdd3fa 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -281,6 +281,22 @@ QEMU_PLUGIN_API void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb); =20 +/** + * qemu_plugin_register_vcpu_discon_cb() - register a discontinuity callba= ck + * @id: plugin ID + * @type: types of discontinuities for which to call the callback + * @cb: callback function + * + * The @cb function is called every time a vCPU receives a discontinuity e= vent + * of the specified type(s), after the vCPU was prepared to handle the eve= nt. + * Preparation entails updating the PC, usually to some interrupt handler = or + * trap vector entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id, + enum qemu_plugin_discon_type type, + qemu_plugin_vcpu_discon_cb_t cb); + /** struct qemu_plugin_tb - Opaque handle for a translation block */ struct qemu_plugin_tb; /** struct qemu_plugin_insn - Opaque handle for a translated instruction */ diff --git a/plugins/core.c b/plugins/core.c index ead09fd2f1e..40d001d39ad 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -569,6 +569,21 @@ void qemu_plugin_register_vcpu_resume_cb(qemu_plugin_i= d_t id, plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_RESUME, cb); } =20 +void qemu_plugin_register_vcpu_discon_cb(qemu_plugin_id_t id, + enum qemu_plugin_discon_type type, + qemu_plugin_vcpu_discon_cb_t cb) +{ + if (type & QEMU_PLUGIN_DISCON_INTERRUPT) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb); + } + if (type & QEMU_PLUGIN_DISCON_EXCEPTION) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb); + } + if (type & QEMU_PLUGIN_DISCON_HOSTCALL) { + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_HOSTCALL, cb); + } +} + void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { --=20 2.47.3