Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3388769img; Mon, 25 Mar 2019 09:16:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMTcPC7fB8G4xK6r4Qvb2CRLMyp6NuwuWV+7Nb0v1ySBCrv6+5fWCCowkdACbQPa9gvMrC X-Received: by 2002:aa7:83cb:: with SMTP id j11mr24714341pfn.117.1553530601868; Mon, 25 Mar 2019 09:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553530601; cv=none; d=google.com; s=arc-20160816; b=N9PYqJpsGJxyel0t7Qcj2p1gME7oxA5M4oYYlUXf+eDUvyv7lZVn6DD8yMLH5tlEJ/ cmIGlDAQwKzUt1ZZd7DYhfwPheCdZm4qe3kvOcyBMIH2UrbtTPtpqKZENIYtaveMparb QXg7i36JL8RwHII/P27uoZtAKn93Y+ScHSU52mQ7WkyfjRwSQMOSGCtMwdvQ3a25wiL2 QZWA4y9nBP02QhhY34k8omtMAvsokhs69qLQDqKHKJBQh11EKnCRD28tQL9krNgDw78M 1M4GLxgiJ6VihI6XXGBgTt2cwxWLcwFOBx7usj3CEwuqm4spPTII+5NpmFSIdFTqGbIu 3nlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=A8I4jzg8rROjCqZhM8xYzA35RRuWgTmyIl/tCfY1MZ0=; b=rF/A04oqsr5CZwkEQZL3XGewDHJgFFROvHCo6VcNDC332EQWU6rPWP4X83bl3KbPu2 zV+i/nEKf3emrYGaHLN5U4NwmdHjA9JDifxyaIhmjitm7ZSn9GsjD1Tb/VPARuDyNHcc 4JVUz6YvWfLsRI0eQyX81WrI1HtPKJE/LM8LZMyiKBpi8XSQnnjUs2QKx/Iq+eRBxSJ3 g13pNDra9cvdMryh7kiLoFDkOBHpiGlDA52K+kR+SXA7edbeNQttg0/xddy66VVB+Gnk 1bMURpopzba8+UsWJJUcAACEGisjkmhi8aB4J+8zlM1hCvOBeJhLdxfzUE/bEkRQCy7Y xo6Q== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 127si6546438pgf.595.2019.03.25.09.16.20; Mon, 25 Mar 2019 09:16:41 -0700 (PDT) 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729297AbfCYQOJ (ORCPT + 99 others); Mon, 25 Mar 2019 12:14:09 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34032 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfCYQOJ (ORCPT ); Mon, 25 Mar 2019 12:14:09 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2PGE5ls107453 for ; Mon, 25 Mar 2019 12:14:08 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rf1duu2s6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Mar 2019 12:14:08 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Mar 2019 16:14:05 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 25 Mar 2019 16:14:02 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2PGE1FV46596148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Mar 2019 16:14:02 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D478CA405B; Mon, 25 Mar 2019 16:14:01 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 03454A4054; Mon, 25 Mar 2019 16:14:01 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.207.192]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 25 Mar 2019 16:14:00 +0000 (GMT) Date: Mon, 25 Mar 2019 18:13:59 +0200 From: Mike Rapoport To: Anup Patel Cc: Palmer Dabbelt , Albert Ou , Atish Patra , Christoph Hellwig , Paul Walmsley , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v3 2/4] RISC-V: Fix memory reservation in setup_bootmem() References: <20190325092234.5451-1-anup.patel@wdc.com> <20190325092234.5451-3-anup.patel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325092234.5451-3-anup.patel@wdc.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19032516-0012-0000-0000-00000306EFF6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19032516-0013-0000-0000-0000213E14EF Message-Id: <20190325161358.GA4783@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-25_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903250120 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 25, 2019 at 09:23:09AM +0000, Anup Patel wrote: > Currently, the setup_bootmem() reserves memory from RAM start to the > kernel end. This prevents us from exploring ways to use the RAM below > (or before) the kernel start hence this patch updates setup_bootmem() > to only reserve memory from the kernel start to the kernel end. > > Signed-off-by: Mike Rapoport Suggested-by: please :) > Signed-off-by: Anup Patel > Reviewed-by: Christoph Hellwig Reviewed-by: Mike Rapoport > --- > arch/riscv/mm/init.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 8cf9ff1f9058..3e66b7cb3a61 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -29,6 +29,8 @@ unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)] > __page_aligned_bss; > EXPORT_SYMBOL(empty_zero_page); > > +extern char _start[]; > + > static void __init zone_sizes_init(void) > { > unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; > @@ -108,23 +110,21 @@ void __init setup_bootmem(void) > { > struct memblock_region *reg; > phys_addr_t mem_size = 0; > + phys_addr_t vmlinux_end = __pa(&_end); > + phys_addr_t vmlinux_start = __pa(&_start); > > /* Find the memory region containing the kernel */ > for_each_memblock(memory, reg) { > - phys_addr_t vmlinux_end = __pa(_end); > phys_addr_t end = reg->base + reg->size; > > - if (reg->base <= vmlinux_end && vmlinux_end <= end) { > - /* > - * Reserve from the start of the region to the end of > - * the kernel > - */ > - memblock_reserve(reg->base, vmlinux_end - reg->base); > + if (reg->base <= vmlinux_end && vmlinux_end <= end) > mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); > - } > } > BUG_ON(mem_size == 0); > > + /* Reserve from the start of the kernel to the end of the kernel */ > + memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start); > + > set_max_mapnr(PFN_DOWN(mem_size)); > max_low_pfn = PFN_DOWN(memblock_end_of_DRAM()); > > @@ -196,7 +196,6 @@ void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t prot) > */ > asmlinkage void __init setup_vm(void) > { > - extern char _start; > uintptr_t i; > uintptr_t pa = (uintptr_t) &_start; > pgprot_t prot = __pgprot(pgprot_val(PAGE_KERNEL) | _PAGE_EXEC); > -- > 2.17.1 > -- Sincerely yours, Mike.