From patchwork Thu Jul 28 13:29:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 3186 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 4F7FD23F4D for ; Thu, 28 Jul 2011 13:30:05 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 21551A184FF for ; Thu, 28 Jul 2011 13:30:05 +0000 (UTC) Received: by qwb8 with SMTP id 8so1930410qwb.11 for ; Thu, 28 Jul 2011 06:30:04 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr13133qci.114.1311859804570; Thu, 28 Jul 2011 06:30:04 -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 hl14cs178350qcb; Thu, 28 Jul 2011 06:30:04 -0700 (PDT) Received: by 10.14.28.142 with SMTP id g14mr7850eea.110.1311859803637; Thu, 28 Jul 2011 06:30:03 -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 z2si1882047wec.144.2011.07.28.06.30.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 28 Jul 2011 06:30:03 -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 6so2390290wwe.31 for ; Thu, 28 Jul 2011 06:30:02 -0700 (PDT) Received: by 10.227.207.210 with SMTP id fz18mr19307wbb.59.1311859797555; Thu, 28 Jul 2011 06:29:57 -0700 (PDT) Received: from e200948.peterhouse.linaro.org (fw-lnat.cambridge.arm.com [217.140.96.63]) by mx.google.com with ESMTPS id fn12sm850866wbb.21.2011.07.28.06.29.51 (version=SSLv3 cipher=OTHER); Thu, 28 Jul 2011 06:29:51 -0700 (PDT) From: Dave Martin To: patches@arm.linux.org.uk Cc: patches@linaro.org, Dave Martin Subject: [PATCH] ARM: alignment: Make SIGBUS sent to userspace POSIXly correct Date: Thu, 28 Jul 2011 14:29:40 +0100 Message-Id: <1311859780-18121-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: Nicolas Pitre Acked-by: Kirill A. Shutemov Reviewed-by: Will Deacon --- KernelVersion: v3.0 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