[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH v3 09/11] target/riscv: call plugin trap callbacks
From: |
Julian Ganz |
Subject: |
[RFC PATCH v3 09/11] target/riscv: call plugin trap callbacks |
Date: |
Mon, 2 Dec 2024 20:26:50 +0100 |
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.
---
target/riscv/cpu_helper.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 0a3ead69ea..6da9bd4629 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -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
--
2.45.2
- Re: [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities, (continued)
- [RFC PATCH v3 06/11] target/arm: call plugin trap callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 03/11] plugins: add hooks for new discontinuity related callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 05/11] target/alpha: call plugin trap callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 07/11] target/avr: call plugin trap callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 08/11] target/mips: call plugin trap callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 09/11] target/riscv: call plugin trap callbacks,
Julian Ganz <=
- [RFC PATCH v3 10/11] target/sparc: call plugin trap callbacks, Julian Ganz, 2024/12/02
- [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Julian Ganz, 2024/12/02
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Pierrick Bouvier, 2024/12/04
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Julian Ganz, 2024/12/05
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Pierrick Bouvier, 2024/12/05
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Julian Ganz, 2024/12/05
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Pierrick Bouvier, 2024/12/05
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Julian Ganz, 2024/12/06
- Re: [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc, Pierrick Bouvier, 2024/12/06