From 13ef37237eec7d4bea053746e262773c3e4a7c13 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Mon, 8 Oct 2018 15:57:54 +0000 Subject: Generate SIGBUS when we see a data abort exception because of unaligned access instead of spinning forever. Fix a weird cast in related code while I'm there. ok visa@ deraadt@ --- sys/arch/arm64/arm64/trap.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sys/arch/arm64') diff --git a/sys/arch/arm64/arm64/trap.c b/sys/arch/arm64/arm64/trap.c index 56000bcaec6..d36e91b049c 100644 --- a/sys/arch/arm64/arm64/trap.c +++ b/sys/arch/arm64/arm64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.20 2018/08/03 18:36:01 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.21 2018/10/08 15:57:53 kettenis Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * All rights reserved. @@ -90,6 +90,19 @@ data_abort(struct trapframe *frame, uint64_t esr, uint64_t far, if (va >= VM_MAXUSER_ADDRESS) curcpu()->ci_flush_bp(); + if (lower) { + switch (esr & ISS_DATA_DFSC_MASK) { + case ISS_DATA_DFSC_ALIGN: + sv.sival_ptr = (void *)far; + KERNEL_LOCK(); + trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + KERNEL_UNLOCK(); + return; + default: + break; + } + } + if (lower) map = &p->p_vmspace->vm_map; else { @@ -141,7 +154,7 @@ data_abort(struct trapframe *frame, uint64_t esr, uint64_t far, sig = SIGSEGV; code = SEGV_MAPERR; } - sv.sival_ptr = (u_int64_t *)far; + sv.sival_ptr = (void *)far; KERNEL_LOCK(); trapsignal(p, sig, 0, code, sv); -- cgit v1.2.3