From patchwork Wed Apr 23 06:37:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 28847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4283E20534 for ; Wed, 23 Apr 2014 06:40:40 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf3137084oac.11 for ; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=Bbcfnj5Tk0b04T0SQDrjMwDZ+CQ8VqEQjqCWcdvH+VI=; b=BMFixVhQIvgUjwFGYIPB8ecUQeJVEFMYmE25uyLVpLxc8UQiBoymZh4Vk3Pn7fKiIf kyPhVy6enKXUfIKISpOMURODa+7t1Ql6nOwD1ZgMOKDweL5wdEiMq7sva0vnQDPGu5+m QLqzhBkFtPvUmBu+YQ+TFIynsffd7IPGEiLY98YtDC2P+5y6i7usD5KBwnyjk5S0XNV3 bapWYT3VvJN1yCrLyFin1Pnp8b4LVMXF4pccW0P+uZqiKF3KH+iGpu3pRuZlWBMXqs3W yJbL0UmxOoIQKTNKe4OHOWBabE2i0OC7PWgJ/7YfInoc5NS8zMqI9EPCh1RN8P0IrdfP AHmQ== X-Gm-Message-State: ALoCoQk0v0mtAxGwtpmJugux4Pn0gmo4YD3ZD1HpyJihCI86paq3XixaCYuabiPSSyimBBwVfSWh X-Received: by 10.182.22.133 with SMTP id d5mr25497502obf.27.1398235239853; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.203 with SMTP id h69ls443237qgh.56.gmail; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr41218815vei.20.1398235239741; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id sw4si10137vdc.12.2014.04.22.23.40.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Apr 2014 23:40:39 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id ld13so592898vcb.19 for ; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-Received: by 10.58.126.4 with SMTP id mu4mr44813728veb.0.1398235239625; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp80649vcb; Tue, 22 Apr 2014 23:40:39 -0700 (PDT) X-Received: by 10.140.32.139 with SMTP id h11mr58171556qgh.49.1398235238932; Tue, 22 Apr 2014 23:40:38 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id k5si19497qgf.66.2014.04.22.23.40.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Apr 2014 23:40:38 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcqoK-00041U-R1; Wed, 23 Apr 2014 06:37:36 +0000 Received: from mail-qg0-f41.google.com ([209.85.192.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WcqoH-0003xU-Kx for linux-arm-kernel@lists.infradead.org; Wed, 23 Apr 2014 06:37:34 +0000 Received: by mail-qg0-f41.google.com with SMTP id z60so513230qgd.28 for ; Tue, 22 Apr 2014 23:37:11 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.140.27.70 with SMTP id 64mr1257051qgw.14.1398235031305; Tue, 22 Apr 2014 23:37:11 -0700 (PDT) Received: by 10.229.95.6 with HTTP; Tue, 22 Apr 2014 23:37:11 -0700 (PDT) In-Reply-To: <20140422094659.GB6979@arm.com> References: <1398119770-27817-1-git-send-email-victor.kamensky@linaro.org> <20140422094659.GB6979@arm.com> Date: Tue, 22 Apr 2014 23:37:11 -0700 Message-ID: Subject: Re: [PATCH] ARM64: disable DCACHE_WORD_ACCESS in big endian case From: Victor Kamensky To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140422_233733_757086_12A4808A X-CRM114-Status: GOOD ( 22.53 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Cc: Catalin Marinas , "linaro-kernel@lists.linaro.org" , "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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Hi Will, On 22 April 2014 02:46, Will Deacon wrote: > On Mon, Apr 21, 2014 at 11:36:10PM +0100, Victor Kamensky wrote: >> If DCACHE_WORD_ACCESS is enabled big endian image failed to >> boot. commit 7bc13fd33adb9536bd73965cd46bbf7377df097c >> "arm64: dcache: select DCACHE_WORD_ACCESS for little-endian CPUs" >> enabled this setting for both big endian and little endian >> cpus. And code in commit itself seems to be endian agnostic, >> however other, i.e C, code that sits under DCACHE_WORD_ACCESS >> seems to be not endian agnostic, I could not figure out where >> though. >> >> Solution is to enable DCACHE_WORD_ACCESS only if little >> endian mode is enabled (default). >> >> Signed-off-by: Victor Kamensky > > NAK, this really should work for big-endian machines. If it doesn't, we > should figure out why and fix the problem. Fair enough. Thanks for encouragement :) > As a start, can you share further details of the failure please? Failure was that kernel could not find init in case of initramfs image or could not do nfs mount in nfs boot case .. The issue turned out to be in another commit: "word-at-a-time: provide generic big-endian zero_bytemask implementation". Because of the issue in zero_bytemask function full_name_hash and hash_name were giving different hash results for the same path name (without slash). The issue is that (~0ul << 64) gives ~0ul not 0. I could not come up with more elegant solution other than use inline function that check shift value against type maximum width. Please take a look below. The patch below is not correctly formatted because of my gmail client line wrapping issue, and others. I will resend it with git send-mail later. For now could you please take a look and maybe suggest something more nicer other than inline function and explicit check. Also, if you can, could you please advise on what mailing list should I post it and who is appropriate maintainer. I could use get_maintainer.pl but would appreciate expert advice. With below patch aarch64 big-endian image with DCACHE_WORD_ACCESS enabled boots OK. >From 47293e5e020ee8ad6233474a1eb13a149378de9d Mon Sep 17 00:00:00 2001 From: Victor Kamensky Date: Tue, 22 Apr 2014 21:05:07 -0700 Subject: [PATCH] word-at-a-time: fix generic big-endian zero_bytemask in max width case Commit 11ec50caedb56e3a87715edeff6a1852e6ae5416 "word-at-a-time: provide generic big-endian zero_bytemask implementation" added generic zero_bytemask implementation for big-endian system. But it gives incorrect result in case where fls gives shift value that equals to the width of unsigned long. As per C standard left shifting for the full width of type is undefined: "If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined." For example in arrach64 big-endian (~0ul << 64) will produce ~0ul. As result aarch64 big-endian is broken when CONFIG_DCACHE_WORD_ACCESS is defined and zero_bytemask is used. Solution to check shift size and if it is equal to width of unsigned long return 0. Signed-off-by: Victor Kamensky --- include/asm-generic/word-at-a-time.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h index d3909ef..6c80ead 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h @@ -50,10 +50,20 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct } #ifndef zero_bytemask +static inline unsigned long __zero_bytemask(unsigned long shift) +{ + unsigned long ret; + if (shift != BITS_PER_LONG) + ret = (~0ul << shift); + else + ret = 0; + return ret; +} + #ifdef CONFIG_64BIT -#define zero_bytemask(mask) (~0ul << fls64(mask)) +#define zero_bytemask(mask) (__zero_bytemask(fls64(mask))) #else -#define zero_bytemask(mask) (~0ul << fls(mask)) +#define zero_bytemask(mask) (__zero_bytemask(fls(mask))) #endif /* CONFIG_64BIT */ #endif /* zero_bytemask */