From nobody Tue Oct 22 23:28:37 2024 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=1729356076; cv=none; d=zohomail.com; s=zohoarc; b=FieTJuWBuBD3Rcj6Hddv/3KEEJ0P4nnZHEUHqKHaP8Aj3DPwDxJ8yEZzsCSKoJk9HtP1MGwKz/mZKh9pBmotCrMi8e99JaH1bbagENlB+xpPSwMBh4NiuB2WHEzknm22hPiNyEvMaheoW+esR9SI5iyQ2d1chwMZBPnOuxMxeVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356076; 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=OkYDGLpfiH06kdfiWWI0KSzrINILPdJbFLbloxIaabw=; b=G/8gO7bfhlpMCfuggdPBdIT48f0uKNyK1Aq+JYeRcrlR7OL0vul0+CKH/feg6zW/Cfwz5cyvvkTQPWlgMrvGJYUtfasyFQnFEf+4Ly0Oydbm30jdgicIb4bBUw1kMllzlomD578m8J+zktzn4NiTtC0rzdQ6Kx1qpCynshS9SZA= 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 172935607652089.39233864726873; Sat, 19 Oct 2024 09:41:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUw-0001zV-KZ; Sat, 19 Oct 2024 12:40:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2CUs-0001vZ-V0 for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:10 -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 1t2CUp-0003gn-QT for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:10 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id DCBB917F958 for ; Sat, 19 Oct 2024 18:39:57 +0200 (CEST) Received: (qmail 9712 invoked by uid 990); 19 Oct 2024 16:39:57 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:57 +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: [RFC PATCH v2 1/7] plugins: add API for registering trap related callbacks Date: Sat, 19 Oct 2024 18:39:34 +0200 Message-ID: <6ea9b0df866ca507e478df7df06899e69766503a.1729355735.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> 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) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -1.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=fToHVCbrDVMfJHC3vsVfVl6MiANqzWoRCaSP8NGsL2o=; b=eM41ZrHU44PVfOUc3E7AqL8oiAkix+Z3NURtJ2/2INCktvl1FsQmxvoFYouk6KJH1QasVfFSsc Dac+r7WAne/jPQ2p6RvzMUy3BM+IeKJEJATfWCguGzDwu05rPoSiDkrE93vwZn4/ZfNNcZ8py9U5 RD7pn/iwBQh1+e9JAu+xCsLpXFKStAXr7/eY5Vm5tLDQZYNBFVHSFsU0GLUBSj4J5+aQ6LdAz0fr dsulecS0jsJbtU3T5ZGJvy2fuQjTIJa2zqT97CeU/9EuR6ctHpRNFChJoYiPdUzN/adMg53YPNbX YGpaUHB/a6STU2cNgykhmlEx171VBT38ijmlNf4vlorTHYHsKnqdTxNJobnk0A2RwixiAGrVu749 6zh4cnDUWELmzpjrS4Bm0XtZ70GzE2h13nwquLq10LYm02mRiE7bI0ZqkTqrcVBlVJTfGaCWWX/h i8SEBHYsLk3Z67K+/TxBEhhJQJ7SeONaXy+l2DMH/ZADgk8GJkiGCDkc7hL8b+I97kKSl0hcEQ44 QfXaVm1Lj42ZOaSzWpyxfA5FNwt6MhBHWdBK9HzsYYD0QaHW/KVRYxEZvOl27HCKVvck9y03yye6 Vu4kXYO7gxf2wUdye9PWJQvXamJcpjEC4chlxWEMzdWX7LQdmoE3VlnKBsAv6I6jBkrlpR7fK39b 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: 1729356077591116600 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 and, on most platforms, 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 an interface for the registration of trap related callbacks. Specifically we (loosely) define interrupts, exceptions and semihosting events across all platforms and introduce one callback for each type of event. Because possible modes and concepts for enumeration of traps vary greatly between different architectures the callbacks are `qemu_plugin_vcpu_simple_cb_t`. That is, they only receive the VCPU id and may need to call other API functions for retrieving additional information. Signed-off-by: Julian Ganz --- include/qemu/plugin-event.h | 3 +++ include/qemu/qemu-plugin.h | 45 ++++++++++++++++++++++++++++++++++++ plugins/core.c | 18 +++++++++++++++ plugins/qemu-plugins.symbols | 3 +++ 4 files changed, 69 insertions(+) diff --git a/include/qemu/plugin-event.h b/include/qemu/plugin-event.h index 7056d8427b..2b69a3821b 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_SEMIHOSTING, 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 622c9a0232..94c3ccd496 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -230,6 +230,51 @@ 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_interrupt_cb() - register a vCPU interrupt ca= llback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU receives an interrupt, aft= er the + * vCPU was prepared to handle the interrupt. An interrupt, in this contex= t and + * across all architectures, is defined as an asynchronous event, usually + * originating from outside the CPU. Preparation usually entails updating = the PC + * to some interrupt handler or trap vector entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_interrupt_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t c= b); + +/** + * qemu_plugin_register_vcpu_exception_cb() - register a vCPU exception ca= llback + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU receives an exception (exc= luding + * semihosting events), after the vCPU was prepared to handle the expectio= n. An + * exception, in this context and across all architectures, is defined as a + * synchronous event in response to a specific instruction being executed. + * Preparation usually entails updating the PC to some exception handler o= r trap + * vector entry. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_exception_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t c= b); + +/** + * qemu_plugin_register_vcpu_semihosting_cb() - register a vCPU semihostin= g cb + * @id: plugin ID + * @cb: callback function + * + * The @cb function is called every time a vCPU encounters a semihosting e= vent, + * after the event was handled. A semihosting event can be thought of as a + * special kind of exception that is not handled by code run by the vCPU b= ut + * machinery outside the vCPU. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_semihosting_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_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..9de997069c 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -559,6 +559,24 @@ 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_interrupt_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t c= b) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_INTERRUPT, cb); +} + +void qemu_plugin_register_vcpu_exception_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t c= b) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_EXCEPTION, cb); +} + +void qemu_plugin_register_vcpu_semihosting_cb(qemu_plugin_id_t id, + qemu_plugin_vcpu_simple_cb_t= cb) +{ + plugin_register_cb(id, QEMU_PLUGIN_EV_VCPU_SEMIHOSTING, cb); +} + void qemu_plugin_register_flush_cb(qemu_plugin_id_t id, qemu_plugin_simple_cb_t cb) { diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index 032661f9ea..449a47af22 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -34,6 +34,9 @@ qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline_per_vcpu; qemu_plugin_register_vcpu_resume_cb; + qemu_plugin_register_vcpu_interrupt_cb; + qemu_plugin_register_vcpu_exception_cb; + qemu_plugin_register_vcpu_semihosting_cb; qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356059; cv=none; d=zohomail.com; s=zohoarc; b=bF2g02KELJkj6RNyB3ZUc+rq8ipFtXzOlf7pf32MTlu/kYDyOTWXixJU9SOgFQZCzMZCNIFXSOOx/ITPE13OQElEbxPVDTWScab5yZze0U92MTFYoYc6/Xj4Z7+jhIRmasU4E7Cb9MBrGYF89+awXO1BtPN5W6awuGDZJPs76KI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356059; 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=TmWItrrXsPtD3dT8yjoH+RGfNQubfNkAl0aLKH3Hc3c=; b=BHSCYQQoDaH83vt8HCNtaIseRPcBPwyhFMCfXjgdRPaGlXVrWaDcY9DLRG6J7UVlX52TZASzKeHz3dCkD5njMnZSlwpfxHdT0dDJTM1lGP/nOF6BZfC86zjOpFHBBWQor/CFjKEWNebakRlTcZ9B1QuywOu1xmIQ5HwnqonqDYo= 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 1729356059606413.32441682222304; Sat, 19 Oct 2024 09:40:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUy-00021w-Vz; Sat, 19 Oct 2024 12:40:17 -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 1t2CUs-0001vX-Ts for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:10 -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 1t2CUq-0003gr-2F for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:10 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 3B4681802EC for ; Sat, 19 Oct 2024 18:39:58 +0200 (CEST) Received: (qmail 9732 invoked by uid 990); 19 Oct 2024 16:39:58 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:57 +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: [RFC PATCH v2 2/7] plugins: add hooks for new trap related callbacks Date: Sat, 19 Oct 2024 18:39:35 +0200 Message-ID: <7ac6b4373e393e99070470818f6197fa34f9e3a9.1729355735.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.999999) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=2PREUqFIHRAtdmmzZJyaj9MVcqZad6TdGsxcSG5umK0=; b=PMi/3/uaxWjE6nzJF/yJC5e+P9c+r3VFvQcRZ+1Gx/D2sw31UPrBhhCPYHxz4H0t9lk95IARPd jARxKLEk+vnOFtVICZKH1gB1wugBdISWL0d2FACRpCbiXh2+JTBvppZcpXrooDe/QCfGKVLFDrtn asbRMeqDUxFqHnQ7LO72hrQMSwGe4c0SUQ8eQ5eINjL90GzD3kwzpIUafvpMUzlLmsh6zPpRzMq8 e2GIdzw1eYuDw8cMdFxMx7rEoup0CMGqclsco2N7w36tZyi0G4TwuW4xLdgDoJCAwoZrd9iLh2No 9ZX/DKRcoYkeKEtFO/tzEaMAJnGTxalgcHQlAbHVnLkNu1qaseZ2Cyw85JZS+6cL+oU+u6B2+tDV BjbT8lOG7QUvwV1SSjrB81Q0ka4MQpESZjH34VsNGJXs8F+3sT7fpc/EAg5au2oWgrPMAJtjy/j9 /oTdCasD+Fhq3ulvXSqGJ7Rx1w3N04295pFxeb7IJ9scrEkFLrv09noQu3GfCKuocxJD+Mvo777Y 7niwnl+cOUlBlatrlsgUW6RVRGeMTyOZj7Os+6UxSII+1NmdieT74IVWGrW9e+VxCsi/DORBE6Ju T321xahybeJZvBRwE0w0lgzlcyu1I3k7+vVidVy5r9bVfCsh/UqiBbQ9Zkk9hsfBXlpJ8mNuoZUw 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=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: 1729356061620116600 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 trap events, specifically for interrupts, exceptions and semihosting events. This change introduces the corresponding hooks called from target specific code inside qemu. Signed-off-by: Julian Ganz --- include/qemu/plugin.h | 12 ++++++++++++ plugins/core.c | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 9726a9ebf3..71f03b83f4 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -160,6 +160,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); +void qemu_plugin_vcpu_exception_cb(CPUState *cpu); +void qemu_plugin_vcpu_semihosting_cb(CPUState *cpu); 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, @@ -242,6 +245,15 @@ static inline void qemu_plugin_vcpu_idle_cb(CPUState *= cpu) static inline void qemu_plugin_vcpu_resume_cb(CPUState *cpu) { } =20 +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu) +{ } + +void qemu_plugin_vcpu_exception_cb(CPUState *cpu) +{ } + +void qemu_plugin_vcpu_semihosting_cb(CPUState *cpu) +{ } + 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 9de997069c..4f80f1cb72 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -100,6 +100,9 @@ static void plugin_vcpu_cb__simple(CPUState *cpu, enum = qemu_plugin_event ev) case QEMU_PLUGIN_EV_VCPU_EXIT: case QEMU_PLUGIN_EV_VCPU_IDLE: case QEMU_PLUGIN_EV_VCPU_RESUME: + case QEMU_PLUGIN_EV_VCPU_INTERRUPT: + case QEMU_PLUGIN_EV_VCPU_EXCEPTION: + case QEMU_PLUGIN_EV_VCPU_SEMIHOSTING: /* iterate safely; plugins might uninstall themselves at any time = */ QLIST_FOREACH_SAFE_RCU(cb, &plugin.cb_lists[ev], entry, next) { qemu_plugin_vcpu_simple_cb_t func =3D cb->f.vcpu_simple; @@ -547,6 +550,27 @@ void qemu_plugin_vcpu_resume_cb(CPUState *cpu) } } =20 +void qemu_plugin_vcpu_interrupt_cb(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_INTERRUPT); + } +} + +void qemu_plugin_vcpu_exception_cb(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_EXCEPTION); + } +} + +void qemu_plugin_vcpu_semihosting_cb(CPUState *cpu) +{ + if (cpu->cpu_index < plugin.num_vcpus) { + plugin_vcpu_cb__simple(cpu, QEMU_PLUGIN_EV_VCPU_SEMIHOSTING); + } +} + void qemu_plugin_register_vcpu_idle_cb(qemu_plugin_id_t id, qemu_plugin_vcpu_simple_cb_t cb) { --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356051; cv=none; d=zohomail.com; s=zohoarc; b=LBZoQ4g76lJM6gBBT72CI+w4DcG5g1hVMSBPHSZAdii3MawP6p3/NISID+Oakr/65BIgVn1FG1vWYTl6Sy9aoxc4fn4+J8fenktJybvZ1ymEoeDwyjBNTzLblm33J6KdOGVCblz9Ipmosaie9GaE+iNBRcyO7rYc/N5BCuKpYz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356051; 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=Ur8L81I1H0e4vzzh5VrT7k+TDuhANP/KCZKThZCd3Jw=; b=gE17POW/8eei4YWPA6vRB4X7RtU+3xlKecwg9OjshpH8n1CB9krOt0joFn+3N5d+B/C1pAIwSTh9e5dmV0aWjGWLf6M3zChDh5+UrMld7hJ3ggN2EIZt+5xhsOgqZa1Y2rvLep5hw/P2ILjOEosIuL9TpcTHY69bo29XK+IwYs0= 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 1729356051303135.1057249822005; Sat, 19 Oct 2024 09:40:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUu-0001xr-TW; Sat, 19 Oct 2024 12:40:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t2CUr-0001v6-6L for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:09 -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 1t2CUp-0003h0-Az for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:08 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id BAF9E180363 for ; Sat, 19 Oct 2024 18:39:58 +0200 (CEST) Received: (qmail 9755 invoked by uid 990); 19 Oct 2024 16:39:58 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:58 +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: [RFC PATCH v2 3/7] contrib/plugins: add plugin showcasing new trap related API Date: Sat, 19 Oct 2024 18:39:36 +0200 Message-ID: <1a2a379011c3636cfc516a3d246566acf14dd44f.1729355735.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.999999) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.099999 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=bLp2Ya8EFnauSsMyOa8SMgEYE21yarlDHCE17UCplxA=; b=JheoeNHMF8IN71/x8thC36JxGDHBrOsrvGS/Db9bau+76mkcuTymlMZsX8YjVhL2ywIr6+Lh5X 73F4cE3M3C5p5ddlYzOb0jrQFOuUD7+eieN5f0uxzHRUjhvW9odyWFpyoTYT+ZcjGRSGRejGT/Vo ToBZiFe9Oo51MsqxJN+LG8HSdSZWzQRM5CXenuiTkNgeWDvc4hVK/3ZiHB1NUQI2rGPaLazoRWFA pI3cChuM427V38P7mO5MBUYFHHV/ny3Ty2IZJRtJLDvOzrnaMlAsyO4mQDixXyV/Vkgl4I8mhROR pL/xc5XTn8Gy++6g3yr5psvgEDJhJxWIi/VHWQFGv7gLThMhFNxwNPg9xkrgsNYlrze0OLaee/Jt +YOiVKYbNWnDvzzy+vqttTMZZEpL9y0j7r6ofzK4NjmJrCyF7tUnEUKb9Sww05Tz7fEnOuPbQEyk Aey+SMN6wPoKbqwo3IbtfCgGi+qHuAC6FRP7KdoIcJ58T2Piv96onY/y5UaZuSScwTjxnEAR/71G 1M70O4JPY4cURpwZyyqLpzten2EqlN39ImLlGPn99wCVhLSKl5BK/BwKNuolLpL/17rPYEauGbwd AGgLrk/Ik5p9+QfpGmOiUe/B5zBQjlLQyo1/9jZJAqDZUc4jetEk+lgBHanfcrjTpCBfMXOIIoy3 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=185.26.156.114; envelope-from=neither@nut.email; helo=mailgate02.uberspace.is X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, NEW_PRODUCTS=1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1729356054524116600 Content-Type: text/plain; charset="utf-8" We recently introduced new plugin API for registration of trap related callbacks. This change introduces a minimal plugin showcasing the new API. It simply counts the occurances of interrupts, exceptions and semihosting events per CPU and reports the counts when exitting. Signed-off-by: Julian Ganz --- contrib/plugins/Makefile | 1 + contrib/plugins/traps.c | 89 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 contrib/plugins/traps.c diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile index bbddd4800f..6085fd701f 100644 --- a/contrib/plugins/Makefile +++ b/contrib/plugins/Makefile @@ -31,6 +31,7 @@ NAMES +=3D drcov NAMES +=3D ips NAMES +=3D stoptrigger NAMES +=3D cflow +NAMES +=3D traps =20 ifeq ($(CONFIG_WIN32),y) SO_SUFFIX :=3D .dll diff --git a/contrib/plugins/traps.c b/contrib/plugins/traps.c new file mode 100644 index 0000000000..2a38dbb8b3 --- /dev/null +++ b/contrib/plugins/traps.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2024, Julian Ganz + * + * Traps - count traps + * + * 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 semihosting; + bool active; +} TrapCounters; + +static TrapCounters *traps; +size_t max_vcpus; + +static void vcpu_init(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + traps[vcpu_index].active =3D true; +} + +static void vcpu_interrupt(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + traps[vcpu_index].interrupts++; +} + +static void vcpu_exception(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + traps[vcpu_index].exceptions++; +} + +static void vcpu_semihosting(qemu_plugin_id_t id, unsigned int vcpu_index) +{ + traps[vcpu_index].semihosting++; +} + +static void plugin_exit(qemu_plugin_id_t id, void *p) +{ + g_autoptr(GString) report; + report =3D g_string_new("VCPU, interrupts, exceptions, semihosting\n"); + int vcpu; + + for (vcpu =3D 0; vcpu < max_vcpus; vcpu++) { + TrapCounters *rec =3D &traps[vcpu]; + if (rec->active) { + g_string_append_printf(report, + "% 4d, % 10"PRId64", % 10"PRId64", % 10" + PRId64"\n", + vcpu, + rec->interrupts, rec->exceptions, + rec->semihosting); + } + } + + qemu_plugin_outs(report->str); +} + +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; + } + + max_vcpus =3D info->system.max_vcpus; + traps =3D calloc(max_vcpus, sizeof(TrapCounters)); + qemu_plugin_register_vcpu_init_cb(id, vcpu_init); + qemu_plugin_vcpu_for_each(id, vcpu_init); + + qemu_plugin_register_vcpu_interrupt_cb(id, vcpu_interrupt); + qemu_plugin_register_vcpu_exception_cb(id, vcpu_exception); + qemu_plugin_register_vcpu_semihosting_cb(id, vcpu_semihosting); + + qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); + + return 0; +} --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356051; cv=none; d=zohomail.com; s=zohoarc; b=Qs2lFI/havnMTdgcUXk/dzt1f4zsD/tf69Nr3BrMlv7fWtkgYb7/0Wk/wLfYcfPhdmmBHEdJQVFuOh++44Afw/5e57d/HBqM83sNkBTnohCM1PhHLTiPVBVmL9cWQDCNxUlTqJGWhb5UJ+IzSXD0sT88R0XEFcPuz93w4u2Zh98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356051; 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=x42lIcmUVyZlGqvs687ZhBwZtsjWBlBgbePtmcDnasg=; b=IhadfFnlvPSM1N32orl3KMaEfAcc0I3am7yxOKX+aKxlJIhoD/lLMMbR558NJLcXwqf+LuU0VDyOjvCkjSgCV4V/cBKOThsw+em3tepV3iMlcnmbKnnOHgNtci9hOfgYtGqMUtWgFb7UgPOk5Dlr+XniqgYmuSgWuI27BmOWXKs= 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 1729356051835259.51579973122034; Sat, 19 Oct 2024 09:40:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUt-0001vT-AI; Sat, 19 Oct 2024 12:40: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 1t2CUr-0001v7-76 for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:09 -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 1t2CUo-0003h3-TD for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:08 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 02A3217F9F4 for ; Sat, 19 Oct 2024 18:39:59 +0200 (CEST) Received: (qmail 9771 invoked by uid 990); 19 Oct 2024 16:39:58 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:58 +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: [RFC PATCH v2 4/7] target/arm: call plugin trap callbacks Date: Sat, 19 Oct 2024 18:39:37 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.83479) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.43479 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=QW5b+c8GerXmJWDNBXe+kTqzYLQkqZ+V6ikpQTJsG78=; b=Dwzd9ejyKQW+iC6emONffpP14xKf6tH85Pp3LCf3wawqHFZHM/nrBRRrnN6hfpmuiG0hKnFrbS aG1W1P4Ng/k+3WOVGgNAt3JRZXw6nz1rIuhdLlJOvcdUxralJIuUsXx64Dle78VjR9ptrelCQcmn LmDZZW85shk1H1Aff2YA6d+aphCSSbLZeEPyyHU3btUfOl/drs/gwk+WEwQfRekg16p5xY3n80YR n7ODFibt+cbEiqIXAidJdKi0v0kB6VPAtBH6weFMhmnBMmb+nIwc/jVSPaSkh6khhELYYw7oZtLm MMk9JDzpl5FGJFSht3FqhYbiz5G/y+bUB2wolQxCr/PnSUWd+es1s3jlaCJ0kwkHT8hwa2Hld8vA lMGA25QrST6h39s4uABTlZYHCAk6/C8Wg+aIIKyYku+zyc7s7kOiq/R4vgjQOnz7NWxKbL7ZThQp I741x7rweD3RQn6YeMN3C3mKAWrEmEslDKMSBktaKbHpbAhQ54/ipb4FcnGq8PY6lDVPg3wunQHx 1XhMKbYTo6wcOgh/wVD9o8gcj+E9shLe6UaSPuAS74gAtlpsxENLaTpGKmcMwFh//FaFTwNMzP+v IDSBExGb7Yiz7Im9VCZ6/CdnCCzhRvJ5+MrwCYtKHh5InX4ftzuAiZR0zDyD4KDHuImo3srsdA6E 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1729356054550116600 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 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 0a731a38e8..f636e216c8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -31,6 +31,7 @@ #endif #include "cpregs.h" #include "target/arm/gtimer.h" +#include "qemu/plugin.h" =20 #define ARM_CPU_FREQ 1000000000 /* FIXME: 1 GHz, should be configurable */ =20 @@ -11147,6 +11148,24 @@ static void take_aarch32_exception(CPUARMState *en= v, int new_mode, } } =20 +static void arm_do_plugin_vcpu_interrupt_cb(CPUState *cs) +{ + 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); + break; + default: + qemu_plugin_vcpu_exception_cb(cs); + } +} + static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs) { /* @@ -11819,6 +11838,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"); + arm_do_plugin_vcpu_interrupt_cb(cs); return; } =20 @@ -11830,6 +11850,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_semihosting_cb(cs); return; } #endif @@ -11855,6 +11876,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); } #endif /* !CONFIG_USER_ONLY */ =20 --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356060; cv=none; d=zohomail.com; s=zohoarc; b=Fxwky3A4BKmMGk2nTe0LCC2oodPAFR6j+PELvAsu7UPDfnFtiYGbiLYQHqfyVc/GxyhzjGn12Js9sb0VBnlQMLOxmKfCIZvYpl+Cw5GYpCEFby+QqzBzzUlk4J6eNGWp7dB7S7FQEc2P6KIgrnUJ2eg/oKF6UR9L5bu2k/jEnvw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356060; 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=p1U79YdT0PylnjVG2LczPbrGQf0BQ1W2G0WtcJ4foSk=; b=GomJ4JDLufl2x8DPrUoC7rGsWTxQyXodcCMDgTj9LLO2cctJwhEPCOcz/fKmfhdQwtwXHFlSgQBejDzpeYF4Yt3+65eEwvnxq1AMFj4KEzF82P/dOVmg+WPZBdhNeVISWf0eRt7WUPhvWDVJx1Ly1chHQroGFuPx3A9k38Gu/78= 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 1729356060758988.1957903040847; Sat, 19 Oct 2024 09:41:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUx-0001zm-6H; Sat, 19 Oct 2024 12:40:15 -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 1t2CUt-0001wV-JJ for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:11 -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 1t2CUs-0003xC-3q for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:11 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 904C917F838 for ; Sat, 19 Oct 2024 18:39:59 +0200 (CEST) Received: (qmail 9787 invoked by uid 990); 19 Oct 2024 16:39:59 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:59 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Michael Rolnik Subject: [RFC PATCH v2 5/7] target/avr: call plugin trap callbacks Date: Sat, 19 Oct 2024 18:39:38 +0200 Message-ID: <5807fbae77440ce091c1480a173e371a72142952.1729355735.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.955061) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.555061 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=3kEDEfs2NK+O76NkQpJ9J9wdE/Guadg1wnJP/wNvu24=; b=oL2YfM2sk5MpdnW86mImRU62igmM9MjOSYjboKOGIu1YkkUy7wFrnxDLp7m9lpwf3pclQ/wpE7 wtrnF4hWQkb5y5HTD4NMxxrdx3LoAU7MXIvU9SWXsDjQEbJDK0GppXrnyFb2i6oVfNcWXWEU5Dlg MdzR3ho/AaU9BnwTNKz7vMyTjCFdxcQDkUtq4Lo+ZZNX0yMLZcN4Jmrc9XwBQnyHPA5HpjjQm7OO P1pKedCoI/Rr0XEUaX/KspdT4EwEvosqizSUwfupWiJB1Ai3+W6EH6CXVjHnO6jyrLv9aQTANqHS OV8Ob2MReoHawOJg5fQmkx18EKzfwZzpqEfC2b2mZoyP6qmBdLVlk+ftesPyLNDZ6kBrTQCezO19 zGO8GQfFZVIHI7pX1CndzZ2AUgUrTUNnDz/0FbOCS2wSkqPXK55zdTrEoV35xQtfXqPQVqkpcEPe ThXSz9i0QecFaIe/c4BJHCOxY765f4/uMZrCe5FaLC+FL2YnITG+mMInQXdrecEgJCtE6i3lxnMy z+kRKN6xSuRdDbBOyauCozvR8m8yI6bb8cBlGOe/xu5UOrvdlwTxSLnmXWPJlR7jAlWJmoPCLFT+ zD3jZa+wgIjRA5Fdf2mdPsurVvt/5AOgwL9/Q6VegPh4U6AtX6H5WrxzILzCGkua/PJKgjdpFue6 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1729356061467116600 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: Michael Rolnik --- target/avr/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/avr/helper.c b/target/avr/helper.c index 345708a1b3..be94552674 100644 --- a/target/avr/helper.c +++ b/target/avr/helper.c @@ -28,6 +28,7 @@ #include "exec/cpu_ldst.h" #include "exec/address-spaces.h" #include "exec/helper-proto.h" +#include "qemu/plugin.h" =20 bool avr_cpu_exec_interrupt(CPUState *cs, int interrupt_request) { @@ -97,6 +98,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); } =20 hwaddr avr_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356066; cv=none; d=zohomail.com; s=zohoarc; b=LWj9hO2bkZv3vIt0JUReP/RyfNB82+eKGREAYXFOAMNOtRB4NoBO2FvgiCgc3nIAmeHV2e8Y1pANNPgr3Y2GUSfJN9Q1n8fc8DfAXkpH12RuubAJqzXvZofhe6Kuth2kj5Bk19uq4NF/6zGb2CTUqzECe3YIgLnMcybutDuWuE0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356066; 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=eCvB3BnTk+aifu9P3XC9Yt3yczeIe1tQEse7tNhXoE8=; b=Nd2HTO7xSZMvTacNtvMRi/kDObQU7qxDMLqIuVTQXEDBDR5JUNMDjRQQH9clMvngCDvH4z2Vww6fL3KknONTpRaXBchMLD/z2KDDMrgzAYXc6wOhdU0mjFjBMS+kDp5JVu0g80Xd6ACG9GR9zChH3HtKLlE0yCe0/n4w2jk/8bQ= 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 1729356066154225.26360502263321; Sat, 19 Oct 2024 09:41:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUz-00022u-L6; Sat, 19 Oct 2024 12:40:17 -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 1t2CUt-0001wf-QH for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:11 -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 1t2CUs-0003xH-4E for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:11 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id E1C79180379 for ; Sat, 19 Oct 2024 18:39:59 +0200 (CEST) Received: (qmail 9805 invoked by uid 990); 19 Oct 2024 16:39:59 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:39:59 +0200 Authentication-Results: skiff.uberspace.de; auth=pass (plain) From: Julian Ganz To: qemu-devel@nongnu.org Cc: Julian Ganz , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs) Subject: [RFC PATCH v2 6/7] target/riscv: call plugin trap callbacks Date: Sat, 19 Oct 2024 18:39:39 +0200 Message-ID: <4a0a1da117dcb66eb3050570869bedcfefb86100.1729355735.git.neither@nut.email> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ---- X-Rspamd-Report: REPLY(-4) SUSPICIOUS_RECIPS(1.5) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) BAYES_HAM(-2.969764) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -4.069764 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=Wfx4XlJFAqOqDm2oM4VSKIM/3Bzy+eWnXxIR053cDbE=; b=GGpDg7Q2r5mudjMMjpc6s18O8YwbcCOPWTpTIc1spDDuSmgxYjTTZuoarql1YV+7Z/mFjM4k8S UL9re4W2/bDt4I4Vlbl8a/SKj0d0aRJySqIc+E85g6MI3/HhwP1FqOAoLgs4yWe4zRWlk1GU3XCg nphtdwZiloeeIQ3xtCjjtAwik6jueAOFgT+Q1TUrm8Oi3hG+xMUPALthdq5DjOkWReVvqqq/a99C bQAMXV3NrO/FRuRz7zrEWvDz8e4NnTxMZp8BoVlL8LmyUW9RFjYijaIEx5aWGIVbvcraIxYfr9Ip LQzpiydyOLb7x+cTdYtaW4xXIIn4AqZfguMe5wTQUZlyR1EL4ltxOrog04lax/SU6MIGwYISIyyg 0lJIVa0vVKl2wZBsRWcSRKvnpv//U0l0htoo5/BxXA1l+9xuDI+mdWPw7+hTepob/ewsTBEP78uG z2K2D06E1OcrHIwqsyVNScsWCfxkdCggzSXyIxNPY6/WbWwF5XwJ8qnRyDcfBqdBAuPsJc0NFdtJ ntnZpFxZad14+f/w92ud5WB9TmDLz5G9MV5WBBikUljRwTqhpvXAB52eBU7jJOhdwXsKSyTNeYIb oKPMNGvEBrkdmplswB1gDi2x6VVxbxclmkV5nNxrLY6IzVs7cRdJIUq41oDDqW5owBPaBKae75ne 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=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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1729356067688116600 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. Signed-off-by: Julian Ganz --- target/riscv/cpu_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c index a935377b4a..2a95869339 100644 --- a/target/riscv/cpu_helper.c +++ b/target/riscv/cpu_helper.c @@ -33,6 +33,7 @@ #include "cpu_bits.h" #include "debug.h" #include "tcg/oversized-guest.h" +#include "qemu/plugin.h" =20 int riscv_env_mmu_index(CPURISCVState *env, bool ifetch) { @@ -1678,6 +1679,7 @@ void riscv_cpu_do_interrupt(CPUState *cs) case RISCV_EXCP_SEMIHOST: do_common_semihosting(cs); env->pc +=3D 4; + qemu_plugin_vcpu_semihosting_cb(cs); return; #endif case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT: @@ -1839,6 +1841,12 @@ void riscv_cpu_do_interrupt(CPUState *cs) riscv_cpu_set_mode(env, PRV_M, virt); } =20 + if (async) { + qemu_plugin_vcpu_interrupt_cb(cs); + } else { + qemu_plugin_vcpu_exception_cb(cs); + } + /* * NOTE: it is not necessary to yield load reservations here. It is on= ly * necessary for an SC from "another hart" to cause a load reservation --=20 2.45.2 From nobody Tue Oct 22 23:28:37 2024 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=1729356122; cv=none; d=zohomail.com; s=zohoarc; b=FfrVrW8rpxZijICQO/1bXiDLnmZsxyusOYWGMykoBy5HFcilQ+4YwPxGW3a2XufS0je79AjtaQDV5E8Z5ncUMi0rP2s1f9TAzpJPryb++68sfLN1L5JCnKRueOmQ5S2STuowUU01ui/ZEonAogyXIjfPHUewPv42bThBt5+CuwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1729356122; 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=K8LwL4AwsmRC5ZhKV0z0+73sn+zkdmH711mLNzoMSEU=; b=n/LpvuAA13icCfh8CduWXkqCmXQTwo5UidP6plqxCV3DQkvYziGksydzrXmeImMD8zyE45a9c2i/6nUf+lfds1Z34xOpkmNZC0t2q2it/Npj0sHlQ4XKg8WeTPYy2MJz8e8KK6se9jk1H3+/Lbi76cmqagps8WeXyoSwEKUltMk= 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 1729356122180796.2643275761047; Sat, 19 Oct 2024 09:42:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t2CUx-0001zp-EB; Sat, 19 Oct 2024 12:40:15 -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 1t2CUv-0001yu-Dp for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:13 -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 1t2CUt-0003zY-Qr for qemu-devel@nongnu.org; Sat, 19 Oct 2024 12:40:13 -0400 Received: from skiff.uberspace.de (skiff.uberspace.de [185.26.156.131]) by mailgate02.uberspace.is (Postfix) with ESMTPS id 31DDF17F810 for ; Sat, 19 Oct 2024 18:40:00 +0200 (CEST) Received: (qmail 9824 invoked by uid 990); 19 Oct 2024 16:40:00 -0000 Received: from unknown (HELO unkown) (::1) by skiff.uberspace.de (Haraka/3.0.1) with ESMTPSA; Sat, 19 Oct 2024 18:40:00 +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: [RFC PATCH v2 7/7] target/sparc: call plugin trap callbacks Date: Sat, 19 Oct 2024 18:39:40 +0200 Message-ID: X-Mailer: git-send-email 2.45.2 In-Reply-To: References: <20231021122502.26746-1-neither@nut.email> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Bar: ----- X-Rspamd-Report: REPLY(-4) BAYES_HAM(-2.994807) MID_CONTAINS_FROM(1) MIME_GOOD(-0.1) R_MISSING_CHARSET(0.5) X-Rspamd-Score: -5.594807 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nut.email; s=uberspace; h=from:to:cc:subject:date; bh=0DIXz22ZQVybjpDzj+NirHJXZfr6QSriqPOofdXhjlE=; b=lzCnfXIllGcULlYAEBS9aQbHYKtUBBQmsR6BkMlfr208O3+okvULCTX8gFPY1OawgtFs5EGfAQ XHsHCAMXkDrbe9OTL4IiCQL4Tbd9/apwL048msbHroiHHzlxr3997HSsgirZo1TXoXtqJbFU9SoB 3M2vxSoqDwTGmql4NyGwY5i1EdgGWpOnRHnYO8/cV6QQ0qXRyQO529FbsKEFZFsY1eo0Ai1eJMcf bPmJHoMjagBYqOMVxOrBYrA5iR6lv3kxBMIbKPb4hd3SPt7kQzPZPKFpgwxgQFTsHIBFrr/mFDQw HcM8gS84jLvja9Tx1+sY5DfB9d0UBR3fA9wh/HYUXAtgVhE0WtfiWWpwD6ehNa8HsjVhRWVcALuf 6RXboiSasx4t7pQqadXFzpEb7cKcDOP289QzWp9xzX12iThtTyspC0B+hQsoj4IXqURPWvI7pGzq 4vYF/QiczlD0gaLNIGFvTHB3Gyq2fP5gfF0pTqgzr0mS26oynbsQbSUx1m2cU9YmBkRRdPXHw5+X Zdl4CMIDQC3H1Hf9z1aJiLILsEgDfQOxdVc6YGiyNHAqT+LX9ZbNwD1Dd0j7JJbBy+pZIb3dVvqJ DgIQy5hcXkV4JM79PjAx31IvaSf18AcA2E9ObNu4ZZ3WCSt7dgMV4MAxx3JvPnQd12GxgyYBE+Kp 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @nut.email) X-ZM-MESSAGEID: 1729356123789116600 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. Also note that SPARC targets do not have semihosting events. Signed-off-by: Julian Ganz --- target/sparc/int32_helper.c | 7 +++++++ target/sparc/int64_helper.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index f2dd8bcb2e..4eb41694f7 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -24,6 +24,7 @@ #include "exec/cpu_ldst.h" #include "exec/log.h" #include "sysemu/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); + } else { + qemu_plugin_vcpu_exception_cb(cs); + } } diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index bd14c7a0db..f4175ef912 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); + break; + default: + qemu_plugin_vcpu_exception_cb(cs); + } } =20 trap_state *cpu_tsptr(CPUSPARCState* env) --=20 2.45.2