[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-riscv] [RFC v3 22/24] tcg: Add RISC-V cpu signal handler
From: |
Alistair Francis |
Subject: |
[Qemu-riscv] [RFC v3 22/24] tcg: Add RISC-V cpu signal handler |
Date: |
Sat, 8 Dec 2018 00:49:39 +0000 |
Signed-off-by: Alistair Francis <address@hidden>
Signed-off-by: Michael Clark <address@hidden>
---
accel/tcg/user-exec.c | 75 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index cd75829cf2..941295ea49 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -571,6 +571,81 @@ int cpu_signal_handler(int host_signum, void *pinfo,
return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask);
}
+#elif defined(__riscv)
+
+int cpu_signal_handler(int host_signum, void *pinfo,
+ void *puc)
+{
+ siginfo_t *info = pinfo;
+ ucontext_t *uc = puc;
+ greg_t pc = uc->uc_mcontext.__gregs[REG_PC];
+ uint32_t insn = *(uint32_t *)pc;
+ int is_write = 0;
+
+ /* Detect store by reading the instruction at the program
+ counter. Note: we currently only generate 32-bit
+ instructions so we thus only detect 32-bit stores */
+ switch (((insn >> 0) & 0b11)) {
+ case 3:
+ switch (((insn >> 2) & 0b11111)) {
+ case 8:
+ switch (((insn >> 12) & 0b111)) {
+ case 0: /* sb */
+ case 1: /* sh */
+ case 2: /* sw */
+ case 3: /* sd */
+ case 4: /* sq */
+ is_write = 1;
+ break;
+ default:
+ break;
+ }
+ break;
+ case 9:
+ switch (((insn >> 12) & 0b111)) {
+ case 2: /* fsw */
+ case 3: /* fsd */
+ case 4: /* fsq */
+ is_write = 1;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Check for compressed instructions */
+ switch (((insn >> 13) & 0b111)) {
+ case 7:
+ switch (insn & 0b11) {
+ case 0: /*c.sd */
+ case 2: /* c.sdsp */
+ is_write = 1;
+ break;
+ default:
+ break;
+ }
+ break;
+ case 6:
+ switch (insn & 0b11) {
+ case 0: /* c.sw */
+ case 3: /* c.swsp */
+ is_write = 1;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask);
+}
+
#else
#error host CPU specific signal handler needed
--
2.19.1
- [Qemu-riscv] [RFC v3 17/24] riscv: tcg-target: Add slowpath load and store instructions, (continued)
- [Qemu-riscv] [RFC v3 20/24] riscv: tcg-target: Add the prologue generation and register the JIT, Alistair Francis, 2018/12/07
- [Qemu-riscv] [RFC v3 21/24] riscv: tcg-target: Add the target init code, Alistair Francis, 2018/12/07
- [Qemu-riscv] [RFC v3 22/24] tcg: Add RISC-V cpu signal handler,
Alistair Francis <=
- [Qemu-riscv] [RFC v3 23/24] dias: Add RISC-V support, Alistair Francis, 2018/12/07
- [Qemu-riscv] [RFC v3 24/24] configure: Add support for building RISC-V host, Alistair Francis, 2018/12/07
- Re: [Qemu-riscv] [Qemu-devel] [RFC v3 00/24] Add RISC-V TCG backend support, no-reply, 2018/12/07