From patchwork Sat Feb 25 06:47:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Yisheng X-Patchwork-Id: 9591499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECA266042C for ; Sat, 25 Feb 2017 06:55:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D808E28670 for ; Sat, 25 Feb 2017 06:55:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8BF32865F; Sat, 25 Feb 2017 06:55:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E98E2865F for ; Sat, 25 Feb 2017 06:55:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=da+u8nfrvki7i/8YPBDvvtvsrlsPMtIbHShng5JMTb8=; b=ObZejD1Is/rKJk 1GAkIjk6NARMqhFXg2QVovmSv2fAwNRxWwFgzyCEHukN9L7OgUNMIIYfOvY73Wq7I7IuMj5iwwbu5 T2Y8aGtRjv9NyJyenkeHQTj1nbUXq212/kY75ASaVnlTXtby3gDWPtDAzENp2qKpGwIrBtLykwgBU EJeeuwKlofn6RiAUg66BlBRDmbpT2ku2ynDCkx8GXKrIjYSbiJ/kv+Evv61AqJbcfRsnYS6cOQ2Wq d5DiyXJagUKvB9NwigS57MVANAmxgkz3OPpl+ea9QSH2Mqw0t74d0Tgdfe5VzzGTrQZZFqD26f7nz dsPNx6u+dF9Z0ut9tIPA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1chWFd-0002i7-Nr; Sat, 25 Feb 2017 06:54:41 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chWFF-0002hr-Kp for linux-arm-kernel@bombadil.infradead.org; Sat, 25 Feb 2017 06:54:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:Message-ID: Date:Subject:CC:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=WpGs8YcmeDx3n8NonT0Wti+C7QbSoGkCUyW32immWXk=; b=RsO5PR8eW+Vc1ytEG/NCMcbbLE VBdUX8XMogqkjnr4okfuNrRJV4YaCWoe1lPJCibKA8GJVjkyuTa3Y1RQ8SOTY+ecwZe2/bw5iVkFm 1M/Sn0u9zBqT8S0dn1fZUgwUV2gKxoMn3vNaWzkwj8jGNBFb5h2EXOkmElH79gB5nfcIof82H4zMy J0+z4ng3kq6QhKScU0D9Lt69KU8gEZZlQWrEw5NUqxVzgL+fi3vce0GIufOxooFlIWaHguZcNRN70 Jvhv8ozPih9mbQ3R7qNb/myI8olAAG/9Kd4cYabc5u914d2GZwWfsPLsuHUZaj2pOpJ20mN/bRclY 8QBfv5mA==; Received: from [45.249.212.188] (helo=dggrg02-dlp.huawei.com) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1chWFA-0006KB-RV for linux-arm-kernel@lists.infradead.org; Sat, 25 Feb 2017 06:54:15 +0000 Received: from 172.30.72.54 (EHLO DGGEMM404-HUB.china.huawei.com) ([172.30.72.54]) by dggrg02-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id AIZ40327; Sat, 25 Feb 2017 14:51:22 +0800 (CST) Received: from DGGEML401-HUB.china.huawei.com (10.3.17.32) by DGGEMM404-HUB.china.huawei.com (10.3.20.212) with Microsoft SMTP Server (TLS) id 14.3.301.0; Sat, 25 Feb 2017 14:51:19 +0800 Received: from linux-ibm.site (10.175.102.37) by DGGEML401-HUB.china.huawei.com (10.3.17.32) with Microsoft SMTP Server id 14.3.301.0; Sat, 25 Feb 2017 14:51:09 +0800 From: Yisheng Xie To: , Subject: [PATCH RFC] arm64/mm: handle memmap kernel option Date: Sat, 25 Feb 2017 14:47:25 +0800 Message-ID: <1488005245-54811-1-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.58B1296C.007B, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d67b3654b288cdeaaee13179ec9bc339 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170225_065413_696425_E656C56D X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, jszhang@marvell.com, wangkefeng.wang@huawei.com, labbott@redhat.com, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, dongbo4@huawei.com, guohanjun@huawei.com, gkulkarni@caviumnetworks.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When use device tree mode, user can reserve memory by changes the dts, however, when boot with ACPI, user cannot reserve memory except by changing the ACPI table in BIOS, which is not so convenient. To make user reserve memory for some specific use more convenient, this patch implement the following memmap variants: - memmap=nn[KMG]$ss[KMG]: mark specified memory as reserved; - memmap=nn[KMG]@ss[KMG]: force usage of a specific region of memory; Reported-by: Bob Dong Signed-off-by: Yisheng Xie --- arch/arm64/mm/init.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index e19e065..cf90c1d 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -188,6 +188,52 @@ static int __init early_mem(char *p) } early_param("mem", early_mem); +static void __init parse_memmap_one(char *p) +{ + char *oldp; + unsigned long start_at, mem_size; + + if (!p) + return; + + oldp = p; + mem_size = memparse(p, &p); + if (p == oldp) + return; + + switch (*p) { + case '@': + start_at = memparse(p + 1, &p); + memblock_add(start_at, mem_size); + break; + + case '$': + start_at = memparse(p + 1, &p); + memblock_reserve(start_at, mem_size); + break; + + default: + pr_warn("Unrecognized memmap syntax: %s\n", p); + break; + } +} + +static int __init parse_memmap_opt(char *str) +{ + while (str) { + char *k = strchr(str, ','); + + if (k) + *k++ = 0; + + parse_memmap_one(str); + str = k; + } + + return 0; +} +early_param("memmap", parse_memmap_opt); + void __init arm64_memblock_init(void) { const s64 linear_region_size = -(s64)PAGE_OFFSET;