On 5/19/25 16:19, Julian Ganz wrote:
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 <neither@nut.email>
---
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"
#if !defined(CONFIG_USER_ONLY)
@@ -183,6 +184,21 @@ static const char *m68k_exception_name(int index)
return "Unassigned";
}
+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 = 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;
EXCP_RTE is not an architectural exception, it's qemu implementation detail. Think
"subroutine return, and also pop cpu state". I don't think you should expose this.
Certainly you're not instrumenting "return from exception" for other targets.
@@ -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 = env->pc;
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;
}
}
Likewise.
r~