Skip to content

Commit

Permalink
target/riscv: call plugin trap callbacks
Browse files Browse the repository at this point in the history
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.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
neithernut authored and pbo-linaro committed Dec 4, 2024
1 parent fe640d6 commit 180ecba
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions target/riscv/cpu_helper.c
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
#include "debug.h"
#include "tcg/oversized-guest.h"
#include "pmp.h"
#include "qemu/plugin.h"

int riscv_env_mmu_index(CPURISCVState *env, bool ifetch)
{
@@ -1806,6 +1807,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
!(env->mip & (1 << cause));
bool vs_injected = env->hvip & (1 << cause) & env->hvien &&
!(env->mip & (1 << cause));
uint64_t last_pc = env-> pc;
target_ulong tval = 0;
target_ulong tinst = 0;
target_ulong htval = 0;
@@ -1820,6 +1822,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
case RISCV_EXCP_SEMIHOST:
do_common_semihosting(cs);
env->pc += 4;
qemu_plugin_vcpu_hostcall_cb(cs, last_pc, env->pc);
return;
#endif
case RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT:
@@ -1999,6 +2002,12 @@ void riscv_cpu_do_interrupt(CPUState *cs)
riscv_cpu_set_mode(env, PRV_M, virt);
}

if (async) {
qemu_plugin_vcpu_interrupt_cb(cs, last_pc, env->pc);
} else {
qemu_plugin_vcpu_exception_cb(cs, last_pc, env->pc);
}

/*
* Interrupt/exception/trap delivery is asynchronous event and as per
* zicfilp spec CPU should clear up the ELP state. No harm in clearing

0 comments on commit 180ecba

Please sign in to comment.