From patchwork Tue Nov 5 02:16:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 21325 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 593062096D for ; Tue, 5 Nov 2013 02:16:38 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp18sf25695504obc.1 for ; Mon, 04 Nov 2013 18:16:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=7a2XR6OYX12pU6/79Ea0HLAXU8T9FwhU1s35WX7VYb8=; b=ZoTAnMXmbBZyLejuG1NJMCqzgTKtThulJd60Kfd3LIz28jdqpoGLsujXDqui3KYRJc Ko8ZqcxkrOadSRgM2eSg+q56ZN3WuVoOCi0ywY0aH18rb+Hkjjhz7khWyXEZ7x4TOxuM yONq31EWJQ/rmdp/U0ZVVX+eYyIcMEWycwZRT3kuZErM1HxoPigekAMyjkWt6HgwAF1+ p5Rt1xz5cUENJNaAewBOkLdxlZiLFEOzpT50UbkHlG3KE7Ql3ycoECmXOn7Igd7/Zksh pktTcRkk8NsjWkZOiwdPcl/7c0/ZSUlEa6v5pkTqALnKQfxydW9c1G6mpH+LPgzNtFcC oZ8g== X-Gm-Message-State: ALoCoQkaKVpUeBUIf8YtL3cqwiV+wRr7X/1mxW1SBPO8p6rTc64H0TrOr43deiY95am31VI4Noeg X-Received: by 10.50.66.238 with SMTP id i14mr6780912igt.4.1383617797961; Mon, 04 Nov 2013 18:16:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.118.103 with SMTP id kl7ls45630qeb.32.gmail; Mon, 04 Nov 2013 18:16:37 -0800 (PST) X-Received: by 10.58.210.39 with SMTP id mr7mr13610764vec.18.1383617797820; Mon, 04 Nov 2013 18:16:37 -0800 (PST) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id s5si4395348vev.3.2013.11.04.18.16.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Nov 2013 18:16:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id m10so1941640vbh.20 for ; Mon, 04 Nov 2013 18:16:37 -0800 (PST) X-Received: by 10.52.98.194 with SMTP id ek2mr11421895vdb.11.1383617797696; Mon, 04 Nov 2013 18:16:37 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp174174vcz; Mon, 4 Nov 2013 18:16:37 -0800 (PST) X-Received: by 10.66.66.133 with SMTP id f5mr637933pat.176.1383617796888; Mon, 04 Nov 2013 18:16:36 -0800 (PST) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by mx.google.com with ESMTPS id dk5si11978005pbc.286.2013.11.04.18.16.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Nov 2013 18:16:36 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of victor.kamensky@linaro.org) client-ip=209.85.220.53; Received: by mail-pa0-f53.google.com with SMTP id kx10so7735275pab.40 for ; Mon, 04 Nov 2013 18:16:36 -0800 (PST) X-Received: by 10.68.189.133 with SMTP id gi5mr20806746pbc.57.1383617796205; Mon, 04 Nov 2013 18:16:36 -0800 (PST) Received: from kamensky-w530.cisco.com.com (128-107-239-234.cisco.com. [128.107.239.234]) by mx.google.com with ESMTPSA id ry4sm36533776pab.4.2013.11.04.18.16.34 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Mon, 04 Nov 2013 18:16:35 -0800 (PST) From: Victor Kamensky To: linux-arm-kernel@lists.infradead.org, ben.dooks@codethink.co.uk, rmk@arm.linux.org.uk Cc: santosh.shilimkar@ti.com, r.sricharan@ti.com, nicolas.pitre@linaro.org, patches@linaro.org, linaro-kernel@lists.linaro.org, linaro-networking@linaro.org, Victor Kamensky Subject: [PATCH 2/3] ARM: mm: fix __phys_to_virt to work with 64 bit phys_addr_t in BE case Date: Mon, 4 Nov 2013 18:16:04 -0800 Message-Id: <1383617765-28052-3-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1383617765-28052-1-git-send-email-victor.kamensky@linaro.org> References: <1383617765-28052-1-git-send-email-victor.kamensky@linaro.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: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Make sure that inline assembler that expects 'r' operand receives 32 bit value. Before this fix in case of CONFIG_ARCH_PHYS_ADDR_T_64BIT and CONFIG_ARM_PATCH_PHYS_VIRT __phys_to_virt function passed 64 bit value to __pv_stub inline assembler where 'r' operand is expected. Compiler behavior in such case is not well specified. It worked in little endian case, but in big endian case incorrect code was generated, where compiler confused which part of 64 bit value it needed to modify. For example BE snippet looked like this: N:0x80904E08 : MOV r2,#0 N:0x80904E0C : SUB r2,r2,#0x81000000 when LE similar code looked like this N:0x808FCE2C : MOV r2,r0 N:0x808FCE30 : SUB r2,r2,#0xc0, 8 ; #0xc0000000 Note 'r0' register is va that have to be translated into phys To avoid this situation use explicit cast to 'unsigned long', which explicitly discard upper part of phys address and convert value to 32 bit. Also add comment so such cast will not be removed in the future. Signed-off-by: Victor Kamensky Acked-by: Santosh Shilimkar --- arch/arm/include/asm/memory.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index 4dd2145..7a8599c 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -226,7 +226,13 @@ static inline phys_addr_t __virt_to_phys(unsigned long x) static inline unsigned long __phys_to_virt(phys_addr_t x) { unsigned long t; - __pv_stub(x, t, "sub", __PV_BITS_31_24); + /* + * 'unsigned long' cast discard upper word when + * phys_addr_t is 64 bit, and makes sure that inline + * assembler expression receives 32 bit argument + * in place where 'r' 32 bit operand is expected. + */ + __pv_stub((unsigned long) x, t, "sub", __PV_BITS_31_24); return t; }