From patchwork Fri Jan 15 08:32:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12021863 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=-11.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, 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 A4F2EC433DB for ; Fri, 15 Jan 2021 08:33:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0721F23118 for ; Fri, 15 Jan 2021 08:33:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0721F23118 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0BA5D8D013A; Fri, 15 Jan 2021 03:33:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06BB98D0023; Fri, 15 Jan 2021 03:33:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC2618D013A; Fri, 15 Jan 2021 03:33:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id D88ED8D0023 for ; Fri, 15 Jan 2021 03:33:21 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A3B1C180AD806 for ; Fri, 15 Jan 2021 08:33:21 +0000 (UTC) X-FDA: 77707345002.07.bee39_261745c2752d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin07.hostedemail.com (Postfix) with ESMTP id 89B201803F9AC for ; Fri, 15 Jan 2021 08:33:21 +0000 (UTC) X-HE-Tag: bee39_261745c2752d X-Filterd-Recvd-Size: 3140 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 08:33:20 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8017522597; Fri, 15 Jan 2021 08:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610699600; bh=KpXmcXL6FYc320RhBuERzath9qSEZFkBf2bJF4H4cmc=; h=From:To:Cc:Subject:Date:From; b=SW/g2dTWKGHibp7GcZoc7RanuaeEfvCGzUkMd2N28NQnlLJpd21DXiKc+XHf8fh8I xo3OBIE5Vdj31zcF/CR2c2TE2vijLaJb0ipZGQMTgENBPS79Hh3J/W4eX41XpWh1Q7 MFTK5UQvdchPjerlzxb5j+EtLXFpulrVGXTYtlfTEkleyvB+x1BHxUEgt6g9PgPO5P 4YchAEcLGJamFPM4LH6yfLPxCGMDVR6+ep8jsTXJWiztRpiFJOLEIntGHZIOP+hHaO LriShka04lSjY7Ny1aZ8GmGlyNI2eTUMMFFkvURjmf8D2gWY/36k5FDT5A4iYejy7x MqaCavw9ej1hg== From: Mike Rapoport To: Andrew Morton Cc: Andrea Arcangeli , Baoquan He , Borislav Petkov , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , Mel Gorman , Michal Hocko , Mike Rapoport , Mike Rapoport , Qian Cai , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 0/2] x86/setup: consolidate early memory reservations Date: Fri, 15 Jan 2021 10:32:53 +0200 Message-Id: <20210115083255.12744-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Mike Rapoport Hi, David noticed that we do some of memblock_reserve() calls after allocations are possible: https://lore.kernel.org/lkml/6ba6bde3-1520-5cd0-f987-32d543f0b79f@redhat.com For now there is no actual problem because in top-down mode we allocate from the end of the memory and in bottom-up mode we allocate above the kernel image. But there is a patch in the mm tree that allow bottom-up allocations below the kernel: https://lore.kernel.org/lkml/20201217201214.3414100-2-guro@fb.com and with this change we may get a memory corruption if an allocation steps on some of the firmware areas that are yet to be reserved. The below patches consolidate early memory reservations done during setup_arch() so that memory used by firmware, bootloader, kernel text/data and the memory that should be excluded from the available memory for whatever other reason is reserved before memblock allocations are possible. The patches are vs v5.11-rc3-mmots-2021-01-12-02-00 as I think they are prerequisite for the memblock bottom-up changes, but if needed I can rebase then on another tree. Mike Rapoport (2): x86/setup: consolidate early memory reservations x86/setup: merge several reservations of start of the memory arch/x86/kernel/setup.c | 85 +++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 42 deletions(-)