Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1661863img; Sat, 23 Mar 2019 08:45:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqv76dUI+AGX5RQqvd+i8t3wVi2Htp6Got2Gcsj/UbpbzyMKZ7/Fjx78h9t9gGsr3Apk5p X-Received: by 2002:a63:e151:: with SMTP id h17mr14509350pgk.413.1553355959142; Sat, 23 Mar 2019 08:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553355959; cv=none; d=google.com; s=arc-20160816; b=h49csPQC7fKzIHxHEelBPmMDC9QWSJQiRBizm4PGAmQFI4K4GDK2wxTkOWLD9kGwAk j6ki+xhMzuZCoSQsmPB539rhvZoOniMn0ExuR+DL3CTmuWpCihx2R9pCVgKR+mk9jLnA rNw9g8oh/ZpgXsSn1cPuXpd/bTjC73KgXxDwJKOS+waXP0yMgfNwD9axhvdx6Wa9deYE MUPIQxE6NTSIV+GIi/oZNBRNRXO1CqtczLsggZu4tDR+PIYpbT/WuyXqNlsK4NUAEyGx EJtmWaGYDVDFpZiQ0KswWfmio/X10LLopK9g88PwvLEp04NTAVftz/pXdNspdyuvH6Cz qsyg== 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=elrp9eb0Wbw+jIz5cqur24Hf0fgOBKi3IpUyuwcxJIg=; b=YMz4mBRb2dOorCQ0iAHlq+P3++znPR4eBcdxrOn+nUS7IkUnWECQuKcwv3gzZyTXkL 66sfe1nq3ffEdVu+7l5/u7pd2lD5NfAFZp0FVFKmn8LLAEOdz1HO0VjI/palUE6Dia+Y +u+exDplK6C+vmkIB9Tktc0+53HO3pC8utsXSoSvpNKnK92afuOrG4vxdQjbKR3xl2Kj RMz3/zNm/1XM8KwSEWh7H1pvNeNbCavPsdDtkYmWoezuSoxoP+DZKcbrz/AMsC7F4+Ry 9BahPEidR+r5SNms1HzJnMMsp3EHaCrf3p3hQHnwkLdJxcwcYBZ3AdJAckSoWOFZ1/kk m5MQ== 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 20si9317398pgr.200.2019.03.23.08.45.44; Sat, 23 Mar 2019 08:45:59 -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 S1727596AbfCWPo5 (ORCPT + 99 others); Sat, 23 Mar 2019 11:44:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47122 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726649AbfCWPo5 (ORCPT ); Sat, 23 Mar 2019 11:44:57 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2NFhvEs182225 for ; Sat, 23 Mar 2019 11:44:56 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2rdee5yrk1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sat, 23 Mar 2019 11:44:56 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 23 Mar 2019 15:44:49 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Sat, 23 Mar 2019 15:44:46 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2NFio5N56557766 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Mar 2019 15:44:50 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8178152050; Sat, 23 Mar 2019 15:44:50 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.207.22]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id A99975204F; Sat, 23 Mar 2019 15:44:49 +0000 (GMT) Date: Sat, 23 Mar 2019 17:44:47 +0200 From: Mike Rapoport To: Anup Patel Cc: Palmer Dabbelt , Albert Ou , Atish Patra , Paul Walmsley , Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 5/5] RISC-V: Fix memory reservation in setup_bootmem() References: <20190321094710.16552-1-anup.patel@wdc.com> <20190321094710.16552-6-anup.patel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190321094710.16552-6-anup.patel@wdc.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19032315-0012-0000-0000-000003064858 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19032315-0013-0000-0000-0000213D6798 Message-Id: <20190323154447.GB25149@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-23_08:,, 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-1903230121 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 09:47:58AM +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 > Signed-off-by: Anup Patel > --- > arch/riscv/mm/init.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 2e2f2567964c..99b42380d17d 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -18,6 +18,8 @@ > #include > #include > > +extern char _start[]; > + > static void __init zone_sizes_init(void) > { > unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; > @@ -93,15 +95,17 @@ void __init setup_bootmem(void) > > /* Find the memory region containing the kernel */ > for_each_memblock(memory, reg) { > - phys_addr_t vmlinux_end = __pa(_end); > + phys_addr_t vmlinux_end = __pa(&_end); > + phys_addr_t vmlinux_start = __pa(&_start); > 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 > + * Reserve from the start of the kernel to the end of > * the kernel > */ > - memblock_reserve(reg->base, vmlinux_end - reg->base); > + memblock_reserve(vmlinux_start, > + vmlinux_end - vmlinux_start); Sorry for misleading you here, but this can be done outside the loop as well as the calculation of vmlinux_{start,end}. > mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); > } > } > @@ -177,7 +181,6 @@ struct mapping_ops { > > static inline void *__load_addr(void *ptr, uintptr_t load_pa) > { > - extern char _start; > uintptr_t va = (uintptr_t)ptr; > uintptr_t sz = (uintptr_t)(&_end) - (uintptr_t)(&_start); > > -- > 2.17.1 > -- Sincerely yours, Mike.