From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78817C43381 for ; Sat, 23 Mar 2019 15:44:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4788321902 for ; Sat, 23 Mar 2019 15:44:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727625AbfCWPo5 (ORCPT ); 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.