Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1076669yba; Tue, 2 Apr 2019 01:37:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPp1iEDCi0fujDrPaeyfu4q47sSyXbWapQMIJmniUIkVLc9wBaL9ofcXzCyzvJcmDnPNn0 X-Received: by 2002:a62:1215:: with SMTP id a21mr7390928pfj.126.1554194224268; Tue, 02 Apr 2019 01:37:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554194224; cv=none; d=google.com; s=arc-20160816; b=wbHQonf7H70NuvEDyr0+Ff8BEaFoGifdWW0NNneWFge4qogXOMAquQKJcGusmWiMcL Kp15bofhJtcYtmZUanOgaUU+xPpoQFF+PYH+sXCYB1bAiKP2PfTlzqOMG6sQmXohlOpb Rr7FUbN4uoAw1zI0M3HefFxd96qwIyGjKmuZ7TnPeifXUZ5vMZ74+bkMCuzjSHl67Jar 92YZEwTi9LQbLtZFYDgC8p2ih3g3TxJiRr9WGgNfbnnp8acD2fa+Lba/CZA1vdob1ZTL 40nGHS9T18mbLizOCr0bKKlmlnEmqbq4L9T0dPw3TxSgfxva6MzK0TlMfaWkJpjfHp8x snhA== 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=4+7iA6VCMx3BBW1lMGfDQ8essshLAffMnJlh4CQxQBc=; b=n+2DDg7xMpVz+SPdLMzno/sJr95E42RYJlf7yp9Jgvg05sx4VMZFl5PgAG/BHCQXNK iPwkmoXUyE3xKgXyv9L33oinH9Jw24kcJGJslawgi3YOLyO2xDcRQOMt3mFTGVszoI0B zk+gR7mv+WHAIG0R5bYVO2yoMWI8J0dqZxLFI3Lp+s9fCHcgcX3HyZg9N6UUxXkE0AzU j9qkvPWxLQyLY9A0qmPnHREdD3FJvt4snEyvgCxs2fXs4gYxRl9rm8WUQjzSQon5lv05 u12IcRKIbEAPUNrEqVhLstemQLnqjnXUDUckL1ItlwB0NtjvFIJ+4NQdbzeKtswDinn5 icHg== 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 j35si11076789plb.61.2019.04.02.01.36.48; Tue, 02 Apr 2019 01:37:04 -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 S1729543AbfDBIfH (ORCPT + 99 others); Tue, 2 Apr 2019 04:35:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35284 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725884AbfDBIfH (ORCPT ); Tue, 2 Apr 2019 04:35:07 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x328T2U4026248 for ; Tue, 2 Apr 2019 04:35:05 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2rm1nd8qn9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 Apr 2019 04:35:05 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Apr 2019 09:35:03 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 2 Apr 2019 09:35:01 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x328Z0TP61669568 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Apr 2019 08:35:00 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E58054C040; Tue, 2 Apr 2019 08:34:59 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 364934C050; Tue, 2 Apr 2019 08:34:59 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.112]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Tue, 2 Apr 2019 08:34:59 +0000 (GMT) Date: Tue, 2 Apr 2019 11:34:57 +0300 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] RISC-V: Fix Maximum Physical Memory 2GiB option for 64bit systems References: <20190402055902.14017-1-anup.patel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190402055902.14017-1-anup.patel@wdc.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19040208-0028-0000-0000-0000035C41CB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19040208-0029-0000-0000-0000241B4508 Message-Id: <20190402083456.GA2153@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-02_04:,, 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-1904020062 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 02, 2019 at 06:02:38AM +0000, Anup Patel wrote: > The Maximum Physical Memory 2GiB option for 64bit systems is currently > broken because kernel hangs at boot-time when this option is enabled > and the underlying system has more than 2GiB memory. > > This issue can be easily reproduced on SiFive Unleashed board where > we have 8GiB of memory. > > This patch fixes above issue by reserving unusable memory region in > setup_bootmem(). > > Signed-off-by: Anup Patel > --- > arch/riscv/mm/init.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 5fd8c922e1c2..6b063f20a9d0 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -121,6 +121,14 @@ void __init setup_bootmem(void) > */ > memblock_reserve(reg->base, vmlinux_end - reg->base); > mem_size = min(reg->size, (phys_addr_t)-PAGE_OFFSET); > + > + /* > + * Reserve from the end of usable area to the end of > + * region > + */ > + if ((reg->base + mem_size) < end) > + memblock_reserve(reg->base + mem_size, > + end - reg->base - mem_size); The memory above MAXPHYSMEM should not be reserved. It should be either removed from memblock with memblock_remove or not added at the first place. Frankly, I fail to understand the logic behind setting PAGE_OFFSET to MAXPHYSMEM and then using PAGE_OFFSET as the limit for accessible physical memory. Still, as it is there, you can set MAX_MEMBLOCK_ADDR=PAGE_OFFSET in arch/riscv/include/page.h and then early_init_dt_add_memory_arch() will simply ignore the memory above PAGE_OFFSET. More sustainable fix for the long term, IMHO, would be to break PAGE_OFFSET and MAXPHYSMEM interdependency. > } > } > BUG_ON(mem_size == 0); > -- > 2.17.1 > -- Sincerely yours, Mike.