Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp527245pxv; Thu, 1 Jul 2021 03:47:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9D8sUmNDzoNQMMZ+flElsmIreEldTfaBRvSJA55QOdLPXr8j+kU0/8/yhSPBQXNiAj6lZ X-Received: by 2002:a92:c78d:: with SMTP id c13mr30400671ilk.11.1625136427556; Thu, 01 Jul 2021 03:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625136427; cv=none; d=google.com; s=arc-20160816; b=KMeO+mIHdWI60Cam94J0xGCAXEbSndIHHB1br0PJh2pCmkKFwSILeOl27LqsmEvWB2 M/XfkXFIAP+GapCakQMu1+hJ94Lqr9cdKiIGjvXNAKutA2XOEMe4rHlxqLDdOZxc4Vw8 GTEYfYsR966nsxL4kU4Vo8SWHih8CzrmWkFuV/zhTQOuCrSeJWL8GYZqAIYgd+qxIcKZ dzOJMYklousxTqB3SVuk3XVUUoR5igI5WfQ8qzRwQUJthKtkLB6mWJzYb5nuz4l4nATF p2zQS+46dn9MWQWY44yEik78cwaIyHkMHQ+N5xdvkr57jbObZPQvtPq3YXmoCi48l9Jb vDlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject; bh=ccPiCOTnWTV8VAIIlwca+Ac5Wa1a7Fj6TjRKuiZd+UI=; b=ke1X8OtCwpEhgdEdDq4TL7FlC3bq1YWlGnbWloNpUtrk9E9y8o+2U2xmoW0kPHZM0D /+2P+eE1SHDQAlKRNA+TByBn/35gvSQiY1cwTQKKVW6HC36m/q2cZopyllkZ2OmSmcKY lTCA6Rr4UaRImb7z3J1s8IXt3yM1mtC3d0F5L45Z2LTHge5AtwVHUv2RITu3RWoks4Bf 5QClc6WYdafNdn8uE8r+sxIUjrfSw9GouaDR+1w9+DZAP83kAs8vapJl1OddE/Wzlyjj VJ01/Nh9D3BoCllj6w+v4+GlhROZ36euT1X2dWXajBQZ/1O4PU7/xW7xTtI8a9ivUGsw VQWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si20905230ill.90.2021.07.01.03.46.55; Thu, 01 Jul 2021 03:47:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235947AbhGAKrL (ORCPT + 99 others); Thu, 1 Jul 2021 06:47:11 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6031 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235526AbhGAKrL (ORCPT ); Thu, 1 Jul 2021 06:47:11 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GFvpY5TdlzXmNC; Thu, 1 Jul 2021 18:39:17 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 1 Jul 2021 18:44:38 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 1 Jul 2021 18:44:38 +0800 Subject: Re: [PATCH 1/3] riscv: Fix memory_limit for 64-bit kernel To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , , References: <20210629091349.3802690-1-alex@ghiti.fr> From: Kefeng Wang Message-ID: <6a38fb9a-d658-836b-4ff4-7c47cadb7db0@huawei.com> Date: Thu, 1 Jul 2021 18:44:37 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20210629091349.3802690-1-alex@ghiti.fr> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/6/29 17:13, Alexandre Ghiti wrote: > As described in Documentation/riscv/vm-layout.rst, the end of the > virtual address space for 64-bit kernel is occupied by the modules/BPF/ > kernel mappings so this actually reduces the amount of memory we are able > to map and then use in the linear mapping. So make sure this limit is > correctly set. > > Fixes: c9811e379b21 ("riscv: Add mem kernel parameter support") Should the Fixes tag be de043da0b9e7 (“RISC-V: Fix usage of memblock_enforce_memory_limit“), The -PAGE_OFFSET is set to the maximal physical memory from this point :) > Signed-off-by: Alexandre Ghiti > --- > arch/riscv/mm/init.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c > index 12f956b3a674..04a5db3a9788 100644 > --- a/arch/riscv/mm/init.c > +++ b/arch/riscv/mm/init.c > @@ -124,10 +124,17 @@ void __init mem_init(void) > } > > /* > - * The default maximal physical memory size is -PAGE_OFFSET, > - * limit the memory size via mem. > + * The default maximal physical memory size is -PAGE_OFFSET for 32-bit kernel, > + * whereas for 64-bit kernel, the end of the virtual address space is occupied > + * by the modules/BPF/kernel mappings which reduces the available size of the > + * linear mapping. > + * Limit the memory size via mem. > */ > +#ifdef CONFIG_64BIT > +static phys_addr_t memory_limit = -PAGE_OFFSET - SZ_4G; > +#else > static phys_addr_t memory_limit = -PAGE_OFFSET; > +#endif > > static int __init early_mem(char *p) > {