From patchwork Tue Jul 26 14:14:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 3152 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2F2A323F3F for ; Tue, 26 Jul 2011 14:14:59 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id EC8A1A185FA for ; Tue, 26 Jul 2011 14:14:58 +0000 (UTC) Received: by qyk10 with SMTP id 10so1790792qyk.11 for ; Tue, 26 Jul 2011 07:14:58 -0700 (PDT) Received: by 10.229.1.217 with SMTP id 25mr2068904qcg.38.1311689698423; Tue, 26 Jul 2011 07:14:58 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs113671qcb; Tue, 26 Jul 2011 07:14:58 -0700 (PDT) Received: by 10.216.169.19 with SMTP id m19mr1665546wel.31.1311689697054; Tue, 26 Jul 2011 07:14:57 -0700 (PDT) Received: from mail-wy0-f178.google.com (mail-wy0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id l37si985217weq.34.2011.07.26.07.14.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jul 2011 07:14:57 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by wyf19 with SMTP id 19so49868wyf.37 for ; Tue, 26 Jul 2011 07:14:56 -0700 (PDT) Received: by 10.227.55.15 with SMTP id s15mr5215457wbg.20.1311689695959; Tue, 26 Jul 2011 07:14:55 -0700 (PDT) Received: from e200948.peterhouse.linaro.org (fw-lnat.cambridge.arm.com [217.140.96.63]) by mx.google.com with ESMTPS id 20sm467461wbw.36.2011.07.26.07.14.53 (version=SSLv3 cipher=OTHER); Tue, 26 Jul 2011 07:14:54 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, Nicolas Pitre , "Kirill A. Shutemov" Subject: [PATCH 1/2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Date: Tue, 26 Jul 2011 15:14:46 +0100 Message-Id: <1311689686-7451-1-git-send-email-dave.martin@linaro.org> X-Mailer: git-send-email 1.7.4.1 With the UM_SIGNAL alignment fault mode, no siginfo structure is passed to userspace. POSIX specifies how siginfo_t should be populated for alignment faults, so this patch does just that: * si_signo = SIGBUS * si_code = BUS_ADRALN * si_addr = address of the faulted instruction Signed-off-by: Dave Martin Reviewed-by: Kirill A. Shutemov Acked-by: Nicolas Pitre --- arch/arm/mm/alignment.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c index 724ba3b..9a65aaf 100644 --- a/arch/arm/mm/alignment.c +++ b/arch/arm/mm/alignment.c @@ -22,6 +22,7 @@ #include #include +#include #include #include "fault.h" @@ -883,9 +884,16 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs) if (ai_usermode & UM_FIXUP) goto fixup; - if (ai_usermode & UM_SIGNAL) - force_sig(SIGBUS, current); - else { + if (ai_usermode & UM_SIGNAL) { + siginfo_t si; + + si.si_signo = SIGBUS; + si.si_errno = 0; + si.si_code = BUS_ADRALN; + si.si_addr = (void __user *)instruction_pointer(regs); + + force_sig_info(si.si_signo, &si, current); + } else { /* * We're about to disable the alignment trap and return to * user space. But if an interrupt occurs before actually