[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 43/66] linux-user: Add cpu_loop_exit_sigbus
From: |
Richard Henderson |
Subject: |
[PATCH v6 43/66] linux-user: Add cpu_loop_exit_sigbus |
Date: |
Sat, 30 Oct 2021 10:16:12 -0700 |
This is a new interface to be provided by the os emulator for
raising SIGBUS on fault. Use the new record_sigbus target hook.
Reviewed-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/exec-all.h | 14 ++++++++++++++
linux-user/signal.c | 14 ++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index f74578500c..6bb2a0f7ec 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -700,6 +700,20 @@ void QEMU_NORETURN cpu_loop_exit_sigsegv(CPUState *cpu,
target_ulong addr,
MMUAccessType access_type,
bool maperr, uintptr_t ra);
+/**
+ * cpu_loop_exit_sigbus:
+ * @cpu: the cpu context
+ * @addr: the guest address of the alignment fault
+ * @access_type: access was read/write/execute
+ * @ra: host pc for unwinding
+ *
+ * Use the TCGCPUOps hook to record cpu state, do guest operating system
+ * specific things to raise SIGBUS, and jump to the main cpu loop.
+ */
+void QEMU_NORETURN cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
+ MMUAccessType access_type,
+ uintptr_t ra);
+
#else
static inline void mmap_lock(void) {}
static inline void mmap_unlock(void) {}
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 9d60abc038..df2c8678d0 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -706,6 +706,20 @@ void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong
addr,
cpu_loop_exit_restore(cpu, ra);
}
+void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
+ MMUAccessType access_type, uintptr_t ra)
+{
+ const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops;
+
+ if (tcg_ops->record_sigbus) {
+ tcg_ops->record_sigbus(cpu, addr, access_type, ra);
+ }
+
+ force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, addr);
+ cpu->exception_index = EXCP_INTERRUPT;
+ cpu_loop_exit_restore(cpu, ra);
+}
+
/* abort execution with signal */
static void QEMU_NORETURN dump_core_and_abort(int target_sig)
{
--
2.25.1
- [PATCH v6 33/66] target/openrisc: Make openrisc_cpu_tlb_fill sysemu only, (continued)
- [PATCH v6 33/66] target/openrisc: Make openrisc_cpu_tlb_fill sysemu only, Richard Henderson, 2021/10/30
- [PATCH v6 36/66] target/s390x: Use probe_access_flags in s390_probe_access, Richard Henderson, 2021/10/30
- [PATCH v6 41/66] accel/tcg: Restrict TCGCPUOps::tlb_fill() to sysemu, Richard Henderson, 2021/10/30
- [PATCH v6 45/66] target/arm: Implement arm_cpu_record_sigbus, Richard Henderson, 2021/10/30
- [PATCH v6 40/66] target/xtensa: Make xtensa_cpu_tlb_fill sysemu only, Richard Henderson, 2021/10/30
- [PATCH v6 52/66] target/s390x: Implement s390x_cpu_record_sigbus, Richard Henderson, 2021/10/30
- [PATCH v6 44/66] target/alpha: Implement alpha_cpu_record_sigbus, Richard Henderson, 2021/10/30
- [PATCH v6 46/66] linux-user/hppa: Remove EXCP_UNALIGN handling, Richard Henderson, 2021/10/30
- [PATCH v6 51/66] linux-user/ppc: Remove POWERPC_EXCP_ALIGN handling, Richard Henderson, 2021/10/30
- [PATCH v6 42/66] hw/core: Add TCGCPUOps.record_sigbus, Richard Henderson, 2021/10/30
- [PATCH v6 43/66] linux-user: Add cpu_loop_exit_sigbus,
Richard Henderson <=
- [PATCH v6 50/66] target/ppc: Restrict ppc_cpu_do_unaligned_access to sysemu, Richard Henderson, 2021/10/30
- [PATCH v6 49/66] target/ppc: Set fault address in ppc_cpu_do_unaligned_access, Richard Henderson, 2021/10/30
- [PATCH v6 59/66] tcg: Add helper_unaligned_{ld, st} for user-only sigbus, Richard Henderson, 2021/10/30
- [PATCH v6 57/66] accel/tcg: Report unaligned atomics for user-only, Richard Henderson, 2021/10/30
- [PATCH v6 60/66] linux-user: Handle BUS_ADRALN in host_signal_handler, Richard Henderson, 2021/10/30
- [PATCH v6 56/66] target/sparc: Set fault address in sparc_cpu_do_unaligned_access, Richard Henderson, 2021/10/30
- [PATCH v6 62/66] linux-user: Disable more prctl subcodes, Richard Henderson, 2021/10/30
- [PATCH v6 54/66] target/sparc: Remove DEBUG_UNALIGNED, Richard Henderson, 2021/10/30
- [PATCH v6 53/66] target/sh4: Set fault address in superh_cpu_do_unaligned_access, Richard Henderson, 2021/10/30
- [PATCH v6 65/66] target/hppa: Implement prctl_unalign_sigbus, Richard Henderson, 2021/10/30