From patchwork Wed Jul 29 16:14:55 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 51667 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 5523222DB5 for ; Wed, 29 Jul 2015 16:16:42 +0000 (UTC) Received: by wilm20 with SMTP id m20sf8824549wil.2 for ; Wed, 29 Jul 2015 09:16:41 -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:from:to:subject:date:message-id :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:cc:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=S6rSMlDE/QqTVK3xIQvZItRoUY85yfdeBgRG53w3l2s=; b=eyBeuEewa/mY0JnPFE4TzrQtTNyzQDL4RA7cWTuTgsIdpaXDAhRs6qBJCsZfEdPSIY lVaL9T9bh4EoouvoNniVlaefboxYH9IAMWjMbrU+7Ma5OQu37+CJaA3/v3zrMC9Ca/JQ Czu9HjkhKeYjcHhMmgm3M+Z0VAwHwZ+zX5DC7U/IFPl6oddebr+Cj7eVN4TNlp4YDYTp kr7TDUnSB8V9KVFkHCMATds96VJlxt+mRBtvEZYxA8FErv1QuiT4QP1HuyyxsrYSKHvV m25uoWk8mETYQgZ2hoLKUfjWqbN6qVH+AkAtRtYn7Opgb2DwhvNHWqSW3ZQbCDNyFMN+ mD8g== X-Gm-Message-State: ALoCoQlzud8jdhIdZrfB7nA730ooCpUJDie6Tul/0GHCiSqaxsclItXXWQSwNKrV1HMBXYwQrcHQ X-Received: by 10.180.186.36 with SMTP id fh4mr3426167wic.7.1438186601581; Wed, 29 Jul 2015 09:16:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.138 with SMTP id am10ls56594lac.67.gmail; Wed, 29 Jul 2015 09:16:40 -0700 (PDT) X-Received: by 10.112.63.169 with SMTP id h9mr39835764lbs.104.1438186600968; Wed, 29 Jul 2015 09:16:40 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id kj18si21879506lbb.126.2015.07.29.09.16.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2015 09:16:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by lahh5 with SMTP id h5so9376260lah.2 for ; Wed, 29 Jul 2015 09:16:40 -0700 (PDT) X-Received: by 10.112.145.169 with SMTP id sv9mr26248438lbb.73.1438186600536; Wed, 29 Jul 2015 09:16:40 -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.112.7.198 with SMTP id l6csp2844559lba; Wed, 29 Jul 2015 09:16:39 -0700 (PDT) X-Received: by 10.70.63.37 with SMTP id d5mr96132498pds.162.1438186598759; Wed, 29 Jul 2015 09:16:38 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id pu3si13041604pdb.177.2015.07.29.09.16.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Jul 2015 09:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) 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 1ZKU0s-0000uh-IR; Wed, 29 Jul 2015 16:15:26 +0000 Received: from mail-wi0-f170.google.com ([209.85.212.170]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZKU0p-00087s-D7 for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2015 16:15:24 +0000 Received: by wibud3 with SMTP id ud3so33365116wib.0 for ; Wed, 29 Jul 2015 09:15:01 -0700 (PDT) X-Received: by 10.180.38.34 with SMTP id d2mr17974699wik.48.1438186501454; Wed, 29 Jul 2015 09:15:01 -0700 (PDT) Received: from localhost.localdomain (ip16-2-212-87.adsl2.static.versatel.nl. [87.212.2.16]) by smtp.gmail.com with ESMTPSA id q19sm25079795wik.16.2015.07.29.09.14.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 29 Jul 2015 09:15:00 -0700 (PDT) From: Ard Biesheuvel To: mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, stuart.yoder@freescale.com, will.deacon@arm.com Subject: [PATCH] arm64: override early_init_dt_add_memory_arch() Date: Wed, 29 Jul 2015 18:14:55 +0200 Message-Id: <1438186495-18126-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150729_091523_599500_DAD0B978 X-CRM114-Status: GOOD ( 16.10 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.170 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.170 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 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: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) 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 Override the __weak early_init_dt_add_memory_arch() with our own version. This allows us to relax the imposed restrictions at memory discovery time, and clip the memory we will not able to address in a single go at mapping time. So copy the generic original, but only retain the check against regions whose sizes become zero when clipped to page alignment. The clipping against the maximum size of the linear region has been moved to arm64_memblock_init(). Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index ad87ce826cce..76a624611939 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -158,6 +158,25 @@ early_param("mem", early_mem); void __init arm64_memblock_init(void) { + /* + * Remove the memory that we will not be able to cover + * with the linear mapping. + */ + const s64 linear_region_size = -(s64)PAGE_OFFSET; + + if (memblock_start_of_DRAM() < memstart_addr) { + pr_warn("Ignoring memory below PHYS_OFFSET (0x%012llx - 0x%012llx)\n", + (u64)memblock_start_of_DRAM(), memstart_addr - 1); + memblock_remove(0, memstart_addr); + } + + if (memstart_addr + linear_region_size < memblock_end_of_DRAM()) { + pr_warn("Ignoring memory outside of linear range (0x%012llx - 0x%012llx)\n", + memstart_addr + linear_region_size, + (u64)memblock_end_of_DRAM() - 1); + memblock_remove(memstart_addr + linear_region_size, ULLONG_MAX); + } + memblock_enforce_memory_limit(memory_limit); /* @@ -374,3 +393,19 @@ static int __init keepinitrd_setup(char *__unused) __setup("keepinitrd", keepinitrd_setup); #endif + +void __init early_init_dt_add_memory_arch(u64 base, u64 size) +{ + if (!PAGE_ALIGNED(base)) { + if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { + pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", + base, base + size); + return; + } + size -= PAGE_SIZE - (base & ~PAGE_MASK); + base = PAGE_ALIGN(base); + } + size &= PAGE_MASK; + + memblock_add(base, size); +}