From patchwork Wed Aug 26 08:06:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 52711 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by patches.linaro.org (Postfix) with ESMTPS id 4D88222E8B for ; Wed, 26 Aug 2015 08:09:00 +0000 (UTC) Received: by lbcli1 with SMTP id li1sf59422025lbc.2 for ; Wed, 26 Aug 2015 01:08:59 -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: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=uVInwPg2Wf/2ewJq4zCzCYlqrLOaGofZtCOByQKqcH0=; b=Uxzan+gmmsqgPbi+guUj4akzn2uzXB2IjEw1v5fQtvNOpjRHBVsWkLoVEsbWa/EVTf DmYp/iloNA4Zjbf5E5zJ397yL0NJtFgCZM3B8ZTJOXqAwEZLHL2lI4Sn7JfwcVmvHGaG IvjMk2DuzN3EZYTnKn2Le2GhVVGKS/YaeL9ZUX69k5VUbhwnvU4GfrMEDWojw3awkx4C CUl7VfwDLLkbspWNRXhpI0cI2F4/rnk/mAIT/Uoy5UjfFv9v4EerIkxNCVZVTbrECCsf bfaCns5W1SD6vyVESHVabByDBiyPmALKPkwwlnV/iCUcHnxPyz+/ivyqwfl8oiBK63rY rh3w== X-Gm-Message-State: ALoCoQl8xd+cUdgXfa46Txt+gFJ1f8FmpPufzal52RwSmRM3/Zw+RvforWWV475a7GKt0LhXi/cz X-Received: by 10.112.199.5 with SMTP id jg5mr598103lbc.14.1440576539243; Wed, 26 Aug 2015 01:08:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.73 with SMTP id de9ls198823lac.68.gmail; Wed, 26 Aug 2015 01:08:59 -0700 (PDT) X-Received: by 10.112.146.106 with SMTP id tb10mr29208623lbb.22.1440576539081; Wed, 26 Aug 2015 01:08:59 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id nq2si18190111lbc.42.2015.08.26.01.08.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by lalv9 with SMTP id v9so113970488lal.0 for ; Wed, 26 Aug 2015 01:08:59 -0700 (PDT) X-Received: by 10.112.235.130 with SMTP id um2mr29465724lbc.72.1440576538985; Wed, 26 Aug 2015 01:08:58 -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.162.200 with SMTP id yc8csp3739913lbb; Wed, 26 Aug 2015 01:08:57 -0700 (PDT) X-Received: by 10.140.195.141 with SMTP id q135mr78719174qha.75.1440576537253; Wed, 26 Aug 2015 01:08:57 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id j135si37410901qhc.18.2015.08.26.01.08.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 01:08:57 -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 1ZUVjk-0007pf-W3; Wed, 26 Aug 2015 08:07:13 +0000 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZUVjb-0007h9-O4 for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2015 08:07:04 +0000 Received: by wijn1 with SMTP id n1so15616015wij.0 for ; Wed, 26 Aug 2015 01:06:42 -0700 (PDT) X-Received: by 10.194.192.99 with SMTP id hf3mr55009724wjc.78.1440576402337; Wed, 26 Aug 2015 01:06:42 -0700 (PDT) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id gm20sm2569597wjc.17.2015.08.26.01.06.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 01:06:41 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, msalter@redhat.com Subject: [PATCH v2 1/5] arm64: clone early_init_dt_add_memory_arch() to override default Date: Wed, 26 Aug 2015 10:06:27 +0200 Message-Id: <1440576391-25725-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> References: <1440576391-25725-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150826_010703_952301_F3B3B8E4 X-CRM114-Status: GOOD ( 13.01 ) 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.174 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.174 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 , haojian.zhuang@linaro.org, Ganapatrao.Kulkarni@caviumnetworks.com, leo.yan@linaro.org 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.47 as permitted sender) smtp.mailfrom=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. We need this in a subsequent patch to make the handling of the memory nodes conditional on whether we are booting via UEFI or not. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/init.c | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f5c0680d17d9..ab25fde7397c 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -374,3 +374,44 @@ static int __init keepinitrd_setup(char *__unused) __setup("keepinitrd", keepinitrd_setup); #endif + +void __init early_init_dt_add_memory_arch(u64 base, u64 size) +{ + const u64 phys_offset = __pa(PAGE_OFFSET); + + 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; + + if (base > MAX_MEMBLOCK_ADDR) { + pr_warning("Ignoring memory block 0x%llx - 0x%llx\n", + base, base + size); + return; + } + + if (base + size - 1 > MAX_MEMBLOCK_ADDR) { + pr_warning("Ignoring memory range 0x%llx - 0x%llx\n", + ((u64)MAX_MEMBLOCK_ADDR) + 1, base + size); + size = MAX_MEMBLOCK_ADDR - base + 1; + } + + if (base + size < phys_offset) { + pr_warning("Ignoring memory block 0x%llx - 0x%llx\n", + base, base + size); + return; + } + if (base < phys_offset) { + pr_warning("Ignoring memory range 0x%llx - 0x%llx\n", + base, phys_offset); + size -= phys_offset - base; + base = phys_offset; + } + memblock_add(base, size); +}