Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1880391ybv; Fri, 14 Feb 2020 07:35:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyYHtsEV4r9s/ZB8hTNEt9L5rAq3pIA9KCRT0y1SlmSa6aoscBs1CQFplZCXJx3A/q/+l/R X-Received: by 2002:aca:4ace:: with SMTP id x197mr2320896oia.23.1581694533385; Fri, 14 Feb 2020 07:35:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581694533; cv=none; d=google.com; s=arc-20160816; b=r9dN04+47moGWQkj+j9Asnvrb1W00pVqq6SkOH/2mzXOkdhohdqU8aFniG02GFnjsq imZBCQ/jPk0qkMm29l5BljShbRFj1KSwgp3z/tpidf+plq0GrfKLG6rcxWnCKU6nflHQ dzbU3py6BdMP1ajsj1Y/Ujnivxhj2M7+Hg7dLZowXuHVDfE0Qta0r2C4/yt5OpzNcIgx jpwvDbDVNKpyp8hm8CovNC4hIV79BWj0ZuOE7gSu0fJxsOHljJloZuaVwxt6EOOUxtqB eBpblfBWNOA0rnH4ALyf0sFmAqocSn2s7yg37gsOjTc+edx7+942VSLEDKrEswHfCpe4 rw0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:cc:to :subject:from; bh=Sk8qulBB48VBCjAV9WtWjZkN0tUyfJAz8rQUcFJ/wWE=; b=lm/8gO7t9h0Bx7hJtVCQgkjy4eSifxlzucTSNBQH5UszpTWEZFfkPIy3fW2i3GEYnJ LU2x81cu/VugSX8W4nkL+lP1C4IMxlmgP0kRIdVcwPLh0JIvPjjyYkwdnwUC7j2xSQOh tN8u8s/gD31kaCh30E+7cJUyQqVVaz1FsHhTUZoJN+heKPKRiPMMdO/yF5Doa9WCVGtt M+BClwYGbieR/LGMIJRQeWq+PSkjpo3Jbfn5REJzlLjE3EOSVQv7xoJCDUAZeBwx18iB uul2dbPEFP6otiInBYw2enBMonUIbLjFISZEL50NYoLq8mGyWQqg+Z+TLw0UDLW+Gkf7 aJ5Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w135si3037718oiw.44.2020.02.14.07.35.21; Fri, 14 Feb 2020 07:35:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387534AbgBNPeD (ORCPT + 99 others); Fri, 14 Feb 2020 10:34:03 -0500 Received: from david.siemens.de ([192.35.17.14]:45136 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387398AbgBNPeD (ORCPT ); Fri, 14 Feb 2020 10:34:03 -0500 Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id 01EFXoue022931 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Feb 2020 16:33:50 +0100 Received: from [139.25.68.37] ([139.25.68.37]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 01EFXnI9026125; Fri, 14 Feb 2020 16:33:49 +0100 From: Jan Kiszka Subject: [PATCH] riscv: Add support for mem= To: Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org Cc: Linux Kernel Mailing List Message-ID: <899dc26e-aca5-0a81-ccb5-c0fda59503f0@siemens.com> Date: Fri, 14 Feb 2020 16:33:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka This sets a memory limit provided via mem= on the command line, analogously to many other architectures. Signed-off-by: Jan Kiszka --- arch/riscv/mm/init.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 965a8cf4829c..09948e43741b 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -488,8 +488,26 @@ static inline void setup_vm_final(void) } #endif /* CONFIG_MMU */ +static phys_addr_t memory_limit = PHYS_ADDR_MAX; + +/* + * Limit the memory size that was specified via FDT. + */ +static int __init early_mem(char *p) +{ + if (!p) + return 1; + + memory_limit = memparse(p, &p) & PAGE_MASK; + pr_notice("Memory limited to %lldMB\n", memory_limit >> 20); + + return 0; +} +early_param("mem", early_mem); + void __init paging_init(void) { + memblock_enforce_memory_limit(memory_limit); setup_vm_final(); memblocks_present(); sparse_init(); -- 2.16.4 -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux