[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults
From: |
Warner Losh |
Subject: |
[PATCH v3 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults |
Date: |
Fri, 28 Jan 2022 16:27:40 -0700 |
Update for the richer set of data faults that are now possible. Copied
largely from linux-user/arm/cpu_loop.c, with minor typo fixes.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/arm/target_arch_cpu.h | 45 ++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/bsd-user/arm/target_arch_cpu.h b/bsd-user/arm/target_arch_cpu.h
index 9d790176420..2b395d5c97f 100644
--- a/bsd-user/arm/target_arch_cpu.h
+++ b/bsd-user/arm/target_arch_cpu.h
@@ -39,8 +39,7 @@ static inline void target_cpu_init(CPUARMState *env,
static inline void target_cpu_loop(CPUARMState *env)
{
- int trapnr;
- target_siginfo_t info;
+ int trapnr, si_signo, si_code;
unsigned int n;
CPUState *cs = env_cpu(env);
@@ -150,15 +149,41 @@ static inline void target_cpu_loop(CPUARMState *env)
/* just indicate that signals should be handled asap */
break;
case EXCP_PREFETCH_ABORT:
- /* See arm/arm/trap.c prefetch_abort_handler() */
case EXCP_DATA_ABORT:
- /* See arm/arm/trap.c data_abort_handler() */
- info.si_signo = TARGET_SIGSEGV;
- info.si_errno = 0;
- /* XXX: check env->error_code */
- info.si_code = 0;
- info.si_addr = env->exception.vaddress;
- queue_signal(env, info.si_signo, &info);
+ /*
+ * See arm/arm/trap-v6.c prefetch_abort_handler() and
+ * data_abort_handler()
+ *
+ * However, FreeBSD maps these to a generic value and then uses
that
+ * to maybe fault in pages in vm/vm_fault.c:vm_fault_trap(). I
+ * believe that the indirection maps the same as Linux, but haven't
+ * chased down every single possible indirection.
+ */
+
+ /* For user-only we don't set TTBCR_EAE, so look at the FSR. */
+ switch (env->exception.fsr & 0x1f) {
+ case 0x1: /* Alignment */
+ si_signo = TARGET_SIGBUS;
+ si_code = TARGET_BUS_ADRALN;
+ break;
+ case 0x3: /* Access flag fault, level 1 */
+ case 0x6: /* Access flag fault, level 2 */
+ case 0x9: /* Domain fault, level 1 */
+ case 0xb: /* Domain fault, level 2 */
+ case 0xd: /* Permission fault, level 1 */
+ case 0xf: /* Permission fault, level 2 */
+ si_signo = TARGET_SIGSEGV;
+ si_code = TARGET_SEGV_ACCERR;
+ break;
+ case 0x5: /* Translation fault, level 1 */
+ case 0x7: /* Translation fault, level 2 */
+ si_signo = TARGET_SIGSEGV;
+ si_code = TARGET_SEGV_MAPERR;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ force_sig_fault(si_signo, si_code, env->exception.vaddress);
break;
case EXCP_DEBUG:
case EXCP_BKPT:
--
2.33.1
- [PATCH v3 04/40] bsd-user/arm/signal.c: get_mcontext should zero vfp data, (continued)
- [PATCH v3 04/40] bsd-user/arm/signal.c: get_mcontext should zero vfp data, Warner Losh, 2022/01/28
- [PATCH v3 07/40] bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-user, Warner Losh, 2022/01/28
- [PATCH v3 05/40] bsd-user: Remove vestiges of signal queueing code, Warner Losh, 2022/01/28
- [PATCH v3 06/40] bsd-user: Bring in docs from linux-user for signal_pending, Warner Losh, 2022/01/28
- [PATCH v3 08/40] bsd-user/signal.c: implement force_sig_fault, Warner Losh, 2022/01/28
- [PATCH v3 09/40] bsd-user/signal-common.h: Move signal functions prototypes to here, Warner Losh, 2022/01/28
- [PATCH v3 10/40] bsd-user/signal.c: Implement cpu_loop_exit_sigsegv, Warner Losh, 2022/01/28
- [PATCH v3 12/40] bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT together, Warner Losh, 2022/01/28
- [PATCH v3 13/40] bsd-user/arm/target_arch_cpu.h: Correct code pointer, Warner Losh, 2022/01/28
- [PATCH v3 11/40] bsd-user/signal.c: implement cpu_loop_exit_sigbus, Warner Losh, 2022/01/28
- [PATCH v3 15/40] bsd-user/arm/target_arch_cpu.h: Implement data faults,
Warner Losh <=
- [PATCH v3 16/40] bsd-user/signal.c: implement abstract target / host signal translation, Warner Losh, 2022/01/28
- [PATCH v3 14/40] bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEF, Warner Losh, 2022/01/28
- [PATCH v3 21/40] bsd-user/host/x86_64/host-signal.h: Implement host_signal_*, Warner Losh, 2022/01/28
- [PATCH v3 20/40] bsd-user/host/i386/host-signal.h: Implement host_signal_*, Warner Losh, 2022/01/28
- [PATCH v3 18/40] bsd-user/signal.c: Add si_type argument to queue_signal, Warner Losh, 2022/01/28
- [PATCH v3 35/40] bsd-user/signal.c: implement do_sigreturn, Warner Losh, 2022/01/28
- [PATCH v3 36/40] bsd-user/signal.c: implement do_sigaction, Warner Losh, 2022/01/28