From patchwork Tue May 24 09:39:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 811272 Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4O9f1D4022100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 24 May 2011 09:41:28 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QOo5E-0005mN-Sf; Tue, 24 May 2011 09:39:25 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QOo5D-0006ey-78; Tue, 24 May 2011 09:39:23 +0000 Received: from service87.mimecast.com ([94.185.240.25]) by canuck.infradead.org with smtp (Exim 4.76 #1 (Red Hat Linux)) id 1QOo5A-0006ef-IH for linux-arm-kernel@lists.infradead.org; Tue, 24 May 2011 09:39:21 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 24 May 2011 10:39:18 +0100 Received: from [10.1.77.45] ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 24 May 2011 10:39:28 +0100 Subject: Re: [PATCH] ARM: Do not allow unaligned accesses when CONFIG_ALIGNMENT_TRAP From: Catalin Marinas To: Russell King - ARM Linux In-Reply-To: <20110523132124.GI17672@n2100.arm.linux.org.uk> References: <20110523111648.10474.78396.stgit@e102109-lin.cambridge.arm.com> <20110523132124.GI17672@n2100.arm.linux.org.uk> Organization: ARM Limited Date: Tue, 24 May 2011 10:39:13 +0100 Message-ID: <1306229953.19557.14.camel@e102109-lin.cambridge.arm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 X-OriginalArrivalTime: 24 May 2011 09:39:28.0304 (UTC) FILETIME=[79CD2B00:01CC19F6] X-MC-Unique: 111052410391801001 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110524_053920_827666_93B62A7E X-CRM114-Status: GOOD ( 20.35 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [94.185.240.25 listed in list.dnswl.org] Cc: linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 24 May 2011 09:41:29 +0000 (UTC) On Mon, 2011-05-23 at 14:21 +0100, Russell King - ARM Linux wrote: > On Mon, May 23, 2011 at 12:16:48PM +0100, Catalin Marinas wrote: > > Newer versions of gcc generate unaligned accesses by default, causing > > kernel panics when CONFIG_ALIGNMENT_TRAP is enabled. This patch adds the > > -mno-unaligned-access option to gcc. > > This description doesn't make sense. If we have alignment traps enabled, > then we _expect_ to fix up unaligned loads and stores. > > Therefore there should be no panic if CONFIG_ALIGNMENT_TRAP is enabled. > > So what's the _actual_ problem that this is trying to address? What's > the panic/oops look like? And that information should be in the commit > description _anyway_. Does the patch below look better? We cannot move alignment_init() earlier as we don't know how early the compiler would generate unaligned accesses. An alternative is some #ifdef's in head.S. Please let me know which variant you prefer. ARM: Do not allow unaligned accesses when CONFIG_ALIGNMENT_TRAP From: Catalin Marinas Newer versions of gcc generate unaligned accesses by default. For ARMv6 and newer architecture versions, Linux disables the alignment trapping (SCTLR.A) in the alignment_init() function. However, unaligned accesses may still happen before this function is called (currently pcpu_dump_alloc_info causes a kernel panic). This patch adds the -mno-unaligned-access option to gcc when CONFIG_ALIGNMENT_TRAP is enabled. Reported-by: Ali Saidi Signed-off-by: Catalin Marinas --- arch/arm/Makefile | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index c7d321a..1c383d0 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -101,6 +101,10 @@ ifeq ($(CONFIG_ARM_UNWIND),y) CFLAGS_ABI +=-funwind-tables endif +ifeq ($(CONFIG_ALIGNMENT_TRAP),y) +CFLAGS_ABI +=$(call cc-option,-mno-unaligned-access,) +endif + ifeq ($(CONFIG_THUMB2_KERNEL),y) AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it) AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)