From: Julian Ganz <neither@nut.email>
To: qemu-devel@nongnu.org
Cc: Julian Ganz <neither@nut.email>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Bin Meng <bmeng.cn@gmail.com>, Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
qemu-riscv@nongnu.org (open list:RISC-V TCG CPUs)
Subject: [RFC PATCH v3 09/11] target/riscv: call plugin trap callbacks
Date: Mon, 2 Dec 2024 20:26:50 +0100 [thread overview]
Message-ID: <1f9b7a8c8bca228529957a5ca62ad778870215ff.1733063076.git.neither@nut.email> (raw)
In-Reply-To: <cover.1733063076.git.neither@nut.email>
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
next prev parent reply other threads:[~2024-12-02 19:28 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 19:26 [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 01/11] plugins: add types for callbacks related to certain discontinuities Julian Ganz
2024-12-03 8:45 ` Julian Ganz
2024-12-04 22:41 ` Pierrick Bouvier
2024-12-05 12:40 ` Julian Ganz
2024-12-05 17:56 ` Pierrick Bouvier
2024-12-05 21:50 ` Julian Ganz
2024-12-05 22:14 ` Julian Ganz
2024-12-05 23:03 ` Pierrick Bouvier
2024-12-06 8:58 ` Julian Ganz
2024-12-06 18:59 ` Pierrick Bouvier
2024-12-07 13:38 ` Julian Ganz
2024-12-09 18:52 ` Pierrick Bouvier
2024-12-04 22:45 ` Pierrick Bouvier
2024-12-05 12:44 ` Julian Ganz
2024-12-05 17:35 ` Pierrick Bouvier
2024-12-05 21:25 ` Julian Ganz
2025-01-09 13:52 ` Alex Bennée
2025-01-09 22:28 ` Pierrick Bouvier
2025-01-10 11:43 ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 02/11] plugins: add API for registering discontinuity callbacks Julian Ganz
2024-12-04 22:45 ` Pierrick Bouvier
2025-01-09 13:57 ` Alex Bennée
2025-01-10 11:40 ` Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 03/11] plugins: add hooks for new discontinuity related callbacks Julian Ganz
2024-12-04 22:47 ` Pierrick Bouvier
2025-01-09 13:58 ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 04/11] contrib/plugins: add plugin showcasing new dicontinuity related API Julian Ganz
2024-12-04 23:14 ` Pierrick Bouvier
2024-12-05 13:00 ` Julian Ganz
2024-12-05 17:23 ` Pierrick Bouvier
2025-01-09 14:04 ` Alex Bennée
2025-01-09 22:10 ` Pierrick Bouvier
2025-01-10 11:49 ` Julian Ganz
2025-01-10 15:15 ` Alex Bennée
2025-01-10 21:02 ` Pierrick Bouvier
2025-01-11 12:15 ` Alex Bennée
2024-12-02 19:26 ` [RFC PATCH v3 05/11] target/alpha: call plugin trap callbacks Julian Ganz
2024-12-04 22:48 ` Pierrick Bouvier
2024-12-02 19:26 ` [RFC PATCH v3 06/11] target/arm: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 07/11] target/avr: " Julian Ganz
2024-12-02 19:26 ` [RFC PATCH v3 08/11] target/mips: " Julian Ganz
2025-01-09 13:43 ` Alex Bennée
2024-12-02 19:26 ` Julian Ganz [this message]
2024-12-03 4:39 ` [RFC PATCH v3 09/11] target/riscv: " Alistair Francis
2024-12-02 19:41 ` [RFC PATCH v3 10/11] target/sparc: " Julian Ganz
2025-01-09 13:46 ` Alex Bennée
2024-12-02 19:41 ` [RFC PATCH v3 11/11] tests: add plugin asserting correctness of discon event's to_pc Julian Ganz
2024-12-04 23:33 ` Pierrick Bouvier
2024-12-05 13:10 ` Julian Ganz
2024-12-05 17:30 ` Pierrick Bouvier
2024-12-05 21:22 ` Julian Ganz
2024-12-05 22:28 ` Pierrick Bouvier
2024-12-06 8:42 ` Julian Ganz
2024-12-06 19:02 ` Pierrick Bouvier
2024-12-06 19:42 ` Richard Henderson
2024-12-06 20:40 ` Pierrick Bouvier
2024-12-06 22:56 ` Richard Henderson
2024-12-07 13:47 ` Julian Ganz
2024-12-07 13:41 ` Julian Ganz
2024-12-20 11:47 ` Julian Ganz
2024-12-20 21:17 ` Pierrick Bouvier
2024-12-20 21:46 ` Pierrick Bouvier
2025-01-09 16:35 ` Alex Bennée
2025-01-09 16:33 ` Alex Bennée
2025-01-09 22:27 ` Pierrick Bouvier
2025-01-10 11:58 ` Julian Ganz
2024-12-03 8:36 ` [RFC PATCH v3 00/11] tcg-plugins: add hooks for discontinuities Julian Ganz
2024-12-04 22:51 ` Pierrick Bouvier
2025-01-09 16:43 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1f9b7a8c8bca228529957a5ca62ad778870215ff.1733063076.git.neither@nut.email \
--to=neither@nut.email \
--cc=alistair.francis@wdc.com \
--cc=bmeng.cn@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).