From cbf0e6e3dc8ece2f3eb05c1840d95440eab4ae8c Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Mon, 27 Oct 2025 11:03:27 +0000 Subject: [PATCH] target/openrisc: call plugin trap callbacks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We recently introduced API for registering callbacks for trap related events as well as the corresponding hook functions. Due to differences between architectures, the latter need to be called from target specific code. This change places hooks for OpenRISC targets. We treat anything other than resets, timer and device interrupts as exceptions. Signed-off-by: Julian Ganz Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20251027110344.2289945-21-alex.bennee@linaro.org> Signed-off-by: Alex Bennée --- target/openrisc/interrupt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/target/openrisc/interrupt.c b/target/openrisc/interrupt.c index 486823094c8..d357aaa7da1 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" void openrisc_cpu_do_interrupt(CPUState *cs) { CPUOpenRISCState *env = cpu_env(cs); int exception = cs->exception_index; + uint64_t last_pc = env->pc; env->epcr = env->pc; @@ -98,6 +100,19 @@ void openrisc_cpu_do_interrupt(CPUState *cs) cpu_abort(cs, "Unhandled exception 0x%x\n", exception); } + switch (exception) { + case EXCP_RESET: + /* Resets are already exposed to plugins through a dedicated callback */ + break; + case EXCP_TICK: + case EXCP_INT: + qemu_plugin_vcpu_interrupt_cb(cs, last_pc); + break; + default: + qemu_plugin_vcpu_exception_cb(cs, last_pc); + break; + } + cs->exception_index = -1; } -- 2.47.3