Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4239620pxv; Tue, 29 Jun 2021 02:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqJ5yB3mdJMaDAT5SbkgzB7+GGJX5LY8BEL+19FRoL8BVvm3Qys3WXVsZg6kfj95rjYlUa X-Received: by 2002:aa7:c991:: with SMTP id c17mr38461951edt.195.1624958155502; Tue, 29 Jun 2021 02:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624958155; cv=none; d=google.com; s=arc-20160816; b=o9cF8Ns5t09zz2ySHXWTRtW1dvAohQRzErElxo4jWAol4AlWh0mEwUTN7rLbiTOQuk /Kx8cDPHiQQYXaAuFK/wMqGZUnyCeO+WXBrXV8o6vi815Em+tQ2Cs4Z17dxDSASxueLQ pzd/Y/kPPiqL8GvTtJEmFxloTG5bU4vWflnbVbn7Hm224Ok+mqP+qEnMYJiBZMqFw+XO KQTNA/kLLkoBWagheZYcd3coyfcRsCPlBkqexdMtDXuR8Nr/llC6x8dSPi5E6TqFRsK2 fUEYoKsFXXjQQGg8/VSu6kNboBq0kwBgl1TgWAmvJfDKc/MCCd2SyxLCwr+4hBsHJ9iK cx0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=1yQbUJJrqCQzZ+JT5/eMMvHMMcqrS4dVWOCqsUS4tIQ=; b=jCZIxY6P5fbtZ4acDSY3nHn5XIJM3e0lZ9rD3+iEGg6+9aD7Vg03ilurrziTGzKTrq 5M4yrikW897YJ/kG6bCGESMC2xpbFOxtfEq1AWMg/dGsuLHSfWfg/6fKb7oNw7W0daxQ +mv6uPUpQb2xtqn18nbAvJgBTNcqNKwFzZTXVfKh6JeBSCxyhfSClX1sTmNbQRdzmOsK lWHiBdp8K+toPV1/9/5EEHyRWmfWYPKx30UdDmnDtE49RZYc5KvgFBeXAc1qxP1OCREC fz+e1kt6hyP99rS98xZ4cyHfIe4JM/XlrpBsqHyBBt5UB8Dt2B51GEarXi3ID/UoOdsW SH5A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si16868909ejl.563.2021.06.29.02.15.32; Tue, 29 Jun 2021 02:15:55 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232691AbhF2JQ1 (ORCPT + 99 others); Tue, 29 Jun 2021 05:16:27 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:59491 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232680AbhF2JQ0 (ORCPT ); Tue, 29 Jun 2021 05:16:26 -0400 Received: (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id C57F724000F; Tue, 29 Jun 2021 09:13:56 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Kefeng Wang , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH 1/3] riscv: Fix memory_limit for 64-bit kernel Date: Tue, 29 Jun 2021 11:13:46 +0200 Message-Id: <20210629091349.3802690-1-alex@ghiti.fr> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") 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) { -- 2.30.2