From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Date: Tue, 02 Mar 2021 11:55:08 +0000 Subject: [PATCH AUTOSEL 5.11 27/52] sparc32: Limit memblock allocation to low memory Message-Id: <20210302115534.61800-27-sashal@kernel.org> List-Id: References: <20210302115534.61800-1-sashal@kernel.org> In-Reply-To: <20210302115534.61800-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andreas Larsson , Mike Rapoport , "David S . Miller" , Sasha Levin , sparclinux@vger.kernel.org From: Andreas Larsson [ Upstream commit bda166930c37604ffa93f2425426af6921ec575a ] Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 changed sparc32 to use memblocks instead of bootmem, but also made high memory available via memblock allocation which does not work together with e.g. phys_to_virt and can lead to kernel panic. This changes back to only low memory being allocatable in the early stages, now using memblock allocation. Signed-off-by: Andreas Larsson Acked-by: Mike Rapoport Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- arch/sparc/mm/init_32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index eb2946b1df8a..6139c5700ccc 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -197,6 +197,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) size = memblock_phys_mem_size() - memblock_reserved_size(); *pages_avail = (size >> PAGE_SHIFT) - high_pages; + /* Only allow low memory to be allocated via memblock allocation */ + memblock_set_current_limit(max_low_pfn << PAGE_SHIFT); + return max_pfn; } -- 2.30.1 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=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 C8894C43381 for ; Tue, 2 Mar 2021 12:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8509C64EF0 for ; Tue, 2 Mar 2021 12:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443716AbhCBMde (ORCPT ); Tue, 2 Mar 2021 07:33:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:40278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350057AbhCBMCz (ORCPT ); Tue, 2 Mar 2021 07:02:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D03A664F2B; Tue, 2 Mar 2021 11:56:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614686170; bh=MMMI+OuLDA3u1PKEN0sdy1klVPC1+9eo7l7J3WcUstE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QRBRthq/Qmg9mpeizqFfuueVIQqpyVP6fkyzbyShgo2gw6hgfVebeVrl9RCSgioqa mOTMajgM5njJtR/RgHuiKVIlvuMu9VdIAnFZ8NYFebEn9++H7UMduGXj4gxfbjZp2K Wxq95cBVrOJUOYOtfObUqSA2tfuLkpu9GrE/fVuqWW4l0GzJIqmds1d1R11HrJ52X/ HwVq65b8obMHaYp7hj/Z9wQdqZDUis7Oc2w4/0TBB4C5gQBMD8/VMIuusYnO/JRdCe tO1yI6lLxOp9FfxafmMHb883OfHnZg+tdK4siNb4PkT9kSiA8V1dpcXUZLKvWMzFW2 9ETB1lJoxeXfQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andreas Larsson , Mike Rapoport , "David S . Miller" , Sasha Levin , sparclinux@vger.kernel.org Subject: [PATCH AUTOSEL 5.11 27/52] sparc32: Limit memblock allocation to low memory Date: Tue, 2 Mar 2021 06:55:08 -0500 Message-Id: <20210302115534.61800-27-sashal@kernel.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210302115534.61800-1-sashal@kernel.org> References: <20210302115534.61800-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Larsson [ Upstream commit bda166930c37604ffa93f2425426af6921ec575a ] Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 changed sparc32 to use memblocks instead of bootmem, but also made high memory available via memblock allocation which does not work together with e.g. phys_to_virt and can lead to kernel panic. This changes back to only low memory being allocatable in the early stages, now using memblock allocation. Signed-off-by: Andreas Larsson Acked-by: Mike Rapoport Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- arch/sparc/mm/init_32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index eb2946b1df8a..6139c5700ccc 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -197,6 +197,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) size = memblock_phys_mem_size() - memblock_reserved_size(); *pages_avail = (size >> PAGE_SHIFT) - high_pages; + /* Only allow low memory to be allocated via memblock allocation */ + memblock_set_current_limit(max_low_pfn << PAGE_SHIFT); + return max_pfn; } -- 2.30.1