From patchwork Mon May 11 06:41: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: 48202 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9FF892121F for ; Mon, 11 May 2015 06:46:23 +0000 (UTC) Received: by wiz9 with SMTP id 9sf7308460wiz.3 for ; Sun, 10 May 2015 23:46:23 -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 :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=EPQdcUdHVwEA/Di5UgSN08CwrWOa4XTHtHvBWdZkUQo=; b=Wb8XsQTQbDaChwFjkwCI0JxMEAtFoNs+JoiWrAvAPqO0iYju7iycp/CfSNH3iyf3RU MfSIyvtvSbgqeIWMRfNYwD7/2WWau750AL8BGGY6D0Ordkj73Qyw1IrhiKKeyJXov89u NLshmJgopeCdmrTvT0imohGljGPn6YGrE9NRS2FDagPYvKdE2NT28mIhiLc2ZXie+YQU +DfMWuoC6CxmM3XATJC3D6Ux1MdPrY22a/fbp/2BvpjYtSH0lWw+Oki3cobpkShjJld0 JbRHDBKCFRhPlrlLNwEXVTZI071IjmPArWYV8It761qs35mYlTidlOerVfGeIyS7M5SH BdJQ== X-Gm-Message-State: ALoCoQlkDHokBMGVrVXF91Q0kNrcKzy67S8MnfRbrDnv8XTS3jF3zbjtnwUA3vSR66+qCs/nFdhu X-Received: by 10.112.53.102 with SMTP id a6mr6544120lbp.16.1431326782985; Sun, 10 May 2015 23:46:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.1.134 with SMTP id 6ls575195lam.36.gmail; Sun, 10 May 2015 23:46:22 -0700 (PDT) X-Received: by 10.152.30.100 with SMTP id r4mr6870821lah.107.1431326782840; Sun, 10 May 2015 23:46:22 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id ps10si7836611lbb.26.2015.05.10.23.46.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:46:22 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbuc2 with SMTP id uc2so87031846lbb.2 for ; Sun, 10 May 2015 23:46:22 -0700 (PDT) X-Received: by 10.152.4.72 with SMTP id i8mr7190179lai.32.1431326782737; Sun, 10 May 2015 23:46:22 -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.108.230 with SMTP id hn6csp1335128lbb; Sun, 10 May 2015 23:46:21 -0700 (PDT) X-Received: by 10.70.37.9 with SMTP id u9mr16558241pdj.50.1431326780792; Sun, 10 May 2015 23:46:20 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sy7si1733104pbc.208.2015.05.10.23.46.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 May 2015 23:46:20 -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 1YrhQm-0007Ux-BV; Mon, 11 May 2015 06:43:12 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YrhQC-0007Dj-Hj for linux-arm-kernel@lists.infradead.org; Mon, 11 May 2015 06:42:37 +0000 Received: by widdi4 with SMTP id di4so84338049wid.0 for ; Sun, 10 May 2015 23:42:13 -0700 (PDT) X-Received: by 10.180.97.164 with SMTP id eb4mr16921880wib.3.1431326533869; Sun, 10 May 2015 23:42:13 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id wr2sm21173009wjb.45.2015.05.10.23.42.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 May 2015 23:42:13 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, grant.likely@linaro.org, leif.lindholm@linaro.org, roy.franz@linaro.org, catalin.marinas@arm.com, mark.rutland@arm.com, matt.fleming@intel.com Subject: [PATCH 3/8] arm64: override early_init_dt_add_memory_arch() Date: Mon, 11 May 2015 08:41:55 +0200 Message-Id: <1431326520-17331-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> References: <1431326520-17331-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150510_234236_767628_68B1FD86 X-CRM114-Status: GOOD ( 12.42 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.177 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.177 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ganapatrao.Kulkarni@caviumnetworks.com, Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 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+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.217.179 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, which is needed if we want to defer the assignment of PHYS_OFFSET and make it independent of where the kernel Image is placed in physical memory. So copy the generic original, but only retain the check against regions whose sizes become zero when clipped to page alignment. For now, we will remove the range below PHYS_OFFSET explicitly until we rework that logic in a subsequent patch. Any memory that we will not be able to map due to insufficient size of the linear region is also removed. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 597831bdddf3..64480b65ef17 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -158,6 +158,15 @@ 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; + + memblock_remove(0, memstart_addr); + memblock_remove(memstart_addr + linear_region_size, ULLONG_MAX); + memblock_enforce_memory_limit(memory_limit); /* @@ -374,3 +383,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); +}