From patchwork Fri Jul 19 12:15:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Dooks X-Patchwork-Id: 2830463 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 872269F4D5 for ; Fri, 19 Jul 2013 12:16:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57FFF20271 for ; Fri, 19 Jul 2013 12:16:26 +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 CCEAE2026D for ; Fri, 19 Jul 2013 12:16:24 +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 1V09bc-0007uN-Lv; Fri, 19 Jul 2013 12:16:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V09ba-0006Hd-4X; Fri, 19 Jul 2013 12:16:14 +0000 Received: from ducie-dc1.codethink.co.uk ([37.128.190.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V09bW-0006Fv-UH for linux-arm-kernel@lists.infradead.org; Fri, 19 Jul 2013 12:16:12 +0000 Received: from localhost (localhost [127.0.0.1]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTP id 73F6546B022; Fri, 19 Jul 2013 13:15:48 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at ducie-dc1.codethink.co.uk Received: from ducie-dc1.codethink.co.uk ([127.0.0.1]) by localhost (ducie-dc1.codethink.co.uk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rIHhq3jCmyIR; Fri, 19 Jul 2013 13:15:39 +0100 (BST) Received: from [192.168.24.134] (rainbowdash.dyn.ducie.codethink.co.uk [192.168.24.134]) by ducie-dc1.codethink.co.uk (Postfix) with ESMTPSA id 3753646DDB4; Fri, 19 Jul 2013 13:15:39 +0100 (BST) Message-ID: <51E92DE5.6090404@codethink.co.uk> Date: Fri, 19 Jul 2013 13:15:33 +0100 From: Ben Dooks Organization: Codethink Limited. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Russell King - ARM Linux Subject: Re: alignment handler instruction endian-ness References: <51E91BE5.8070809@codethink.co.uk> <20130719110947.GD24642@n2100.arm.linux.org.uk> In-Reply-To: <20130719110947.GD24642@n2100.arm.linux.org.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130719_081611_090631_23BF0921 X-CRM114-Status: GOOD ( 18.59 ) X-Spam-Score: -2.3 (--) Cc: "linux-arm-kernel@lists.infradead.org" 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: , 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.6 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 On 19/07/13 12:09, Russell King - ARM Linux wrote: > On Fri, Jul 19, 2013 at 11:58:45AM +0100, Ben Dooks wrote: >> I ran in to an issue with the alignment handler when running BE8 where >> it loads instructions and fails to swap. >> >> Is there a better way of swapping instructions for ARM when loading >> from arbitrary places? Have I missed any other places this could happen? > > Maybe we need a macro which deals with this automatically? > > arm_instr_to_cpu(x) > thumb_instr_to_cpu(x) > > These should probably make use of the swab*() macros when an endian swap > is needed. > >> The following patch is my first attempt at solving the problem for the >> alignment handler: > > I'd suggest checking this with sparse too - you have some type errors here. How about: Senior Engineer Codethink - Providing Genius diff --git a/arch/arm/include/uapi/asm/byteorder.h b/arch/arm/include/uapi/asm/b index 7737974..9e63a00 100644 --- a/arch/arm/include/uapi/asm/byteorder.h +++ b/arch/arm/include/uapi/asm/byteorder.h @@ -21,5 +21,13 @@ #include #endif +#ifdef CONFIG_CPU_ENDIAN_BE8 +#define cpu_to_arm_instr(__instr) swab32(__instr) +#define cpu_to_thum_instr(__instr) swab16(__instr) +#else +#define cpu_to_arm_instr(__instr) (__instr) +#define cpu_to_thum_instr(__instr) (__instr) +#endif -- Ben Dooks http://www.codethink.co.uk/