From patchwork Wed Nov 27 19:50:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 3249691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 28DD79F3A0 for ; Wed, 27 Nov 2013 19:54:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7790C205E6 for ; Wed, 27 Nov 2013 19:54:37 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9F864205BA for ; Wed, 27 Nov 2013 19:54:35 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VllBe-0006Nv-4w; Wed, 27 Nov 2013 19:54:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VllBU-0000Ik-Lg; Wed, 27 Nov 2013 19:54:04 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VllBR-0000H1-7y for linux-arm-kernel@lists.infradead.org; Wed, 27 Nov 2013 19:54:02 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 27 Nov 2013 19:50:32 +0000 Received: from e104324-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 27 Nov 2013 19:50:29 +0000 From: Robin Murphy To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] arm: SIGBUS on unsupported ARMv6 unaligned accesses Date: Wed, 27 Nov 2013 19:50:16 +0000 Message-Id: <1385581816-23379-1-git-send-email-robin.murphy@arm.com> X-Mailer: git-send-email 1.7.9.5 X-OriginalArrivalTime: 27 Nov 2013 19:50:29.0532 (UTC) FILETIME=[ECCF1DC0:01CEEBA9] X-MC-Unique: 113112719503202501 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131127_145401_458351_B678BF03 X-CRM114-Status: GOOD ( 13.27 ) X-Spam-Score: -2.6 (--) Cc: Robin Murphy , dave.martin@arm.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch changes the default behaviour for userspace alignment faults on v6 from silent fixup to SIGBUS. This only affects code that violates the v6 unaligned access model - bad assembly/JIT code or high-level language code in violation of the relevant language spec - which should be corrected rather than unwittingly relying on performance-degrading fixups. Fixup behaviour can still be controlled from boot parameters or at runtime for compatibility with existing incorrect software. There will be no impact for v5 and earlier. Signed-off-by: Robin Murphy --- This is very much the hard-line approach to the issue, but userspace really shouldn't be depending on the ability to execute architecturally invalid code; ultimately this is an ABI that deserves to be broken. The only trouble with going in softly and just turning on the warning alone is that it should already be rare enough to be easily missed. "Break everything AND scream about it" as the default isn't going to make any friends, but does make bad code as visible as possible. Anyone is of course free to turn warnings off, and/or fixups back on - defaulting to UM_SIGNAL on UM_IGNORE is to ensure fixup has to be explicitly requested, by which point they should be well aware of what they're doing and why. It would be useful to know if people are actually running v6+ userspaces that would be non-trivially impacted by this before considering progressing beyond RFC. arch/arm/mm/alignment.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c index 9240364..9a93315 100644 --- a/arch/arm/mm/alignment.c +++ b/arch/arm/mm/alignment.c @@ -106,10 +106,10 @@ static int safe_usermode(int new_usermode, bool warn) * making any progress. */ if (cpu_is_v6_unaligned() && !(new_usermode & (UM_FIXUP | UM_SIGNAL))) { - new_usermode |= UM_FIXUP; + new_usermode |= UM_SIGNAL; if (warn) - printk(KERN_WARNING "alignment: ignoring faults is unsafe on this CPU. Defaulting to fixup mode.\n"); + printk(KERN_WARNING "alignment: ignoring faults is unsafe on this CPU. Defaulting to signal mode.\n"); } return new_usermode; @@ -971,7 +971,7 @@ static int __init alignment_init(void) cr_alignment &= ~CR_A; cr_no_alignment &= ~CR_A; set_cr(cr_alignment); - ai_usermode = safe_usermode(ai_usermode, false); + ai_usermode = safe_usermode(ai_usermode | UM_WARN, false); } #endif