From patchwork Wed Jun 5 10:44:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2668621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id CAC99DF264 for ; Wed, 5 Jun 2013 10:39:03 +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 1UkB6O-0005jo-HE; Wed, 05 Jun 2013 10:38:02 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UkB66-0006XM-WE; Wed, 05 Jun 2013 10:37:43 +0000 Received: from mail-pd0-f170.google.com ([209.85.192.170]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UkB60-0006V2-6G for linux-arm-kernel@lists.infradead.org; Wed, 05 Jun 2013 10:37:37 +0000 Received: by mail-pd0-f170.google.com with SMTP id x10so1638919pdj.15 for ; Wed, 05 Jun 2013 03:37:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=f4ncMadBA6GzM3xyqGbapxkQJozqYnxYRQt+xTYZkE0=; b=mxWhtqSIgTiYJZRuZxoMxPQgLlomhotRGcSuSsbRni47WNgQLhV3qpMFeRKaJlJWAL pT7HL1hgMeQDwvvGpAFmN2HsO0KKBbadmistBLqr14OqkbRk/IvtSP+XVGvljt2q7Mv+ tm+WS8QaTZrYaUX7Emd2nOH0d6XBIP8CmXqOMmce5NCZYTtogPxd7uhEDVBcX21049y+ QpxDOtfGSHFVuXWipnQU3zcJnP0Oh7GIpUI5AgheLyO4DB6s5NONB1ml8/UbgCXHNnVW WEb15ZrqPlJVwUzmnHvvvMsnVyxQE2wQRwMDs1qbcehwSe8fnlRZclWmAxz+dQl6130F CL4g== X-Received: by 10.68.130.167 with SMTP id of7mr33505400pbb.169.1370428639609; Wed, 05 Jun 2013 03:37:19 -0700 (PDT) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net. [202.32.14.49]) by mx.google.com with ESMTPSA id vv6sm72093187pab.6.2013.06.05.03.37.16 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 05 Jun 2013 03:37:18 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Wed, 05 Jun 2013 19:44:46 +0900 Message-Id: <20130605104446.1720.12461.sendpatchset@w520> In-Reply-To: <20130605104427.1720.68752.sendpatchset@w520> References: <20130605104427.1720.68752.sendpatchset@w520> Subject: [PATCH 02/03] ARM: Handle 64-bit memory in case of 32-bit phys_addr_t X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130605_063736_436544_547E270F X-CRM114-Status: GOOD ( 11.58 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.170 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (magnus.damm[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: arnd@arndb.de, catalin.marinas@arm.com, Magnus Damm , horms@verge.net.au, laurent.pinchart@ideasonboard.com, olof@lixom.net, 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Magnus Damm Use CONFIG_ARCH_PHYS_ADDR_T_64BIT to determine if ignoring or truncating of memory banks is neccessary. This may be needed in the case of 64-bit memory bank addresses but when phys_addr_t is kept 32-bit. Signed-off-by: Magnus Damm --- Ignoring case tested on APE6EVM in cases when HIGHMEM=y/n and LPAE=y/n. Truncating not tested. arch/arm/kernel/setup.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) --- 0003/arch/arm/kernel/setup.c +++ work/arch/arm/kernel/setup.c 2013-06-05 19:08:17.000000000 +0900 @@ -530,6 +530,7 @@ void __init dump_machine_table(void) int __init arm_add_memory(u64 start, u64 size) { struct membank *bank = &meminfo.bank[meminfo.nr_banks]; + u64 aligned_start; if (meminfo.nr_banks >= NR_BANKS) { printk(KERN_CRIT "NR_BANKS too low, " @@ -542,10 +543,16 @@ int __init arm_add_memory(u64 start, u64 * Size is appropriately rounded down, start is rounded up. */ size -= start & ~PAGE_MASK; - bank->start = PAGE_ALIGN(start); + aligned_start = PAGE_ALIGN(start); -#ifndef CONFIG_ARM_LPAE - if (bank->start + size < bank->start) { +#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT + if (aligned_start > ULONG_MAX) { + printk(KERN_CRIT "Ignoring memory at 0x%08llx outside " + "32-bit physical address space\n", (long long)start); + return -EINVAL; + } + + if (aligned_start + size > ULONG_MAX) { printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in " "32-bit physical address space\n", (long long)start); /* @@ -553,10 +560,11 @@ int __init arm_add_memory(u64 start, u64 * 32 bits, we use ULONG_MAX as the upper limit rather than 4GB. * This means we lose a page after masking. */ - size = ULONG_MAX - bank->start; + size = ULONG_MAX - aligned_start; } #endif + bank->start = aligned_start; bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1); /*