From patchwork Wed Jul 27 12:10:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 3175 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 8FC7E23F3F for ; Wed, 27 Jul 2011 12:10:50 +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 5A654A1809A for ; Wed, 27 Jul 2011 12:10:50 +0000 (UTC) Received: by qyk10 with SMTP id 10so2549807qyk.11 for ; Wed, 27 Jul 2011 05:10:49 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr1664075qci.114.1311768649731; Wed, 27 Jul 2011 05:10:49 -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 hl14cs143277qcb; Wed, 27 Jul 2011 05:10:49 -0700 (PDT) Received: by 10.227.160.78 with SMTP id m14mr2432175wbx.80.1311768647598; Wed, 27 Jul 2011 05:10:47 -0700 (PDT) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id n5si84532wbh.121.2011.07.27.05.10.44 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Jul 2011 05:10:46 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of dave.martin@linaro.org) smtp.mail=dave.martin@linaro.org Received: by wwe6 with SMTP id 6so1271505wwe.31 for ; Wed, 27 Jul 2011 05:10:44 -0700 (PDT) Received: by 10.227.137.208 with SMTP id x16mr6188503wbt.81.1311768644614; Wed, 27 Jul 2011 05:10:44 -0700 (PDT) Received: from e200948.peterhouse.linaro.org (fw-lnat.cambridge.arm.com [217.140.96.63]) by mx.google.com with ESMTPS id fe4sm47629wbb.28.2011.07.27.05.10.42 (version=SSLv3 cipher=OTHER); Wed, 27 Jul 2011 05:10:43 -0700 (PDT) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, Nicolas Pitre , "Kirill A. Shutemov" Subject: [PATCH v2] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Date: Wed, 27 Jul 2011 13:10:36 +0100 Message-Id: <1311768636-29582-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 = misaligned data address at which access was attempted Signed-off-by: Dave Martin Acked-by: Kirill A. Shutemov --- v2: si_addr in siginfo_t changed to contain the faulting data access address, not the address of the faulting instruction. This behaviour is consistent with the way other fault signals such as SIGSEGV are already reported, as well as matching the apparent intent of the POSIX sigaction interface. 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..65ed9c6 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 *)addr; + + 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