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: Victor Kamensky X-Patchwork-Id: 3138961 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 24995BEEB2 for ; Tue, 5 Nov 2013 03:12:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58106205EC for ; Tue, 5 Nov 2013 03:12:09 +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 3B3C7205EA for ; Tue, 5 Nov 2013 03:12:08 +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 1VdWDh-0006MC-99; Tue, 05 Nov 2013 02:18:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdWCm-0004j3-5j; Tue, 05 Nov 2013 02:17:20 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VdWCQ-0004cs-81 for linux-arm-kernel@lists.infradead.org; Tue, 05 Nov 2013 02:16:59 +0000 Received: by mail-pa0-f41.google.com with SMTP id rd3so7779105pab.14 for ; Mon, 04 Nov 2013 18:16:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7a2XR6OYX12pU6/79Ea0HLAXU8T9FwhU1s35WX7VYb8=; b=fyz5NQj3RLibj34iW4DDR96zoj1oYSnwKYYA2KEMNLCLW7gNuxcPD3yGOch0qwBFZD UHx4k6fjlTBBmasm//OdOqwbDYwAZ/B5k3vaniXTymDiGyZaUiXDm1E3HITYuOsCvfGl z3INlcAQgDCLZhBDm7mx+wZTh/WD+/6UMVpRLNGKzbmT963W1UFr3ZjiTL6h3vG4UK4b zeJFOr64lfFTHU8Egeu7KwLpj4/kiGYXvGhhl80lG59hvcUiS31wJPXdGV1ZhY8I3CjB 22KTzxKZ934wscDRgI2Cld+6zxEYsW3vEnnQSNFL+aUa0xMZf24UkWt9AOC0RNCMJcYl RD0w== X-Gm-Message-State: ALoCoQkGXMSFoRjtIB9NR4jyL6e3UMMoSBbltPLQ4lp2UCDpUFdHsUrr9iv/WO2uxyccp5Z7YOhW 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131104_211658_401186_DB0D90DC X-CRM114-Status: GOOD ( 10.68 ) X-Spam-Score: -2.6 (--) Cc: nicolas.pitre@linaro.org, linaro-kernel@lists.linaro.org, patches@linaro.org, Victor Kamensky , r.sricharan@ti.com, santosh.shilimkar@ti.com, linaro-networking@linaro.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: , 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 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; }