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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,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 92E8FC433DB for ; Mon, 11 Jan 2021 19:40:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1609922BEF for ; Mon, 11 Jan 2021 19:40:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1609922BEF 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 6E4306B0286; Mon, 11 Jan 2021 14:40:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6887E6B02BE; Mon, 11 Jan 2021 14:40:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4DAE96B01F6; Mon, 11 Jan 2021 14:40:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id 5BC4F6B0286 for ; Mon, 11 Jan 2021 14:40:34 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 22F04824556B for ; Mon, 11 Jan 2021 19:40:34 +0000 (UTC) X-FDA: 77694511188.06.title87_2207e772750f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id E093410042630 for ; Mon, 11 Jan 2021 19:40:33 +0000 (UTC) X-HE-Tag: title87_2207e772750f X-Filterd-Recvd-Size: 4400 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 Jan 2021 19:40:33 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id F243022CA1; Mon, 11 Jan 2021 19:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610394032; bh=WE6SmDSLNbXYicMy6sA/x0SSQuVJJT63v1hLhctMFKg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMDXWWscG+8NNaI7+yGP/QMgY03rJlLXTX44ViO4vx+QanZ6ry+D443Vj/9A/8knb zvHTtHySdvgO3hoFj122f+QvthsfICBHF27jlhM/z/Rn0sQOzWFH3Wuh7Ehn9EwZY3 GH8s2uszGSYxNH5tU+9fXdLtviQZZZFxugeFqZxYtd917k0uzd71xdpEgkk/MOhgZm LoVxzUd73D+qKgKVuxacDajKRBLDvJq4Faspq3LDprCzmIWSkbngBCsiY8CaG6Ejxx xvRM1I+6BRHDLwW/ldnjE+3ufFx+DubYl+fuS7X3abgJ33cB8Ddftm8Wtj8Q7IjC0e 2zTXYV2ES0kzQ== 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 v3 1/2] x86/setup: don't remove E820_TYPE_RAM for pfn 0 Date: Mon, 11 Jan 2021 21:40:16 +0200 Message-Id: <20210111194017.22696-2-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210111194017.22696-1-rppt@kernel.org> References: <20210111194017.22696-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 The first 4Kb of memory is a BIOS owned area and to avoid its allocation for the kernel it was not listed in e820 tables as memory. As the result, pfn 0 was never recognised by the generic memory management and it is not= a part of neither node 0 nor ZONE_DMA. If set_pfnblock_flags_mask() would be ever called for the pageblock corresponding to the first 2Mbytes of memory, having pfn 0 outside of ZONE_DMA would trigger VM_BUG_ON_PAGE(!zone_spans_pfn(page_zone(page), pfn), page); Along with reserving the first 4Kb in e820 tables, several first pages ar= e reserved with memblock in several places during setup_arch(). These reservations are enough to ensure the kernel does not touch the BIOS area and it is not necessary to remove E820_TYPE_RAM for pfn 0. Remove the update of e820 table that changes the type of pfn 0 and move t= he comment describing why it was done to trim_low_memory_range() that reserv= es the beginning of the memory. Signed-off-by: Mike Rapoport --- arch/x86/kernel/setup.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 740f3bdb3f61..3412c4595efd 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -660,17 +660,6 @@ static void __init trim_platform_memory_ranges(void) =20 static void __init trim_bios_range(void) { - /* - * A special case is the first 4Kb of memory; - * This is a BIOS owned area, not kernel ram, but generally - * not listed as such in the E820 table. - * - * This typically reserves additional memory (64KiB by default) - * since some BIOSes are known to corrupt low memory. See the - * Kconfig help text for X86_RESERVE_LOW. - */ - e820__range_update(0, PAGE_SIZE, E820_TYPE_RAM, E820_TYPE_RESERVED); - /* * special case: Some BIOSes report the PC BIOS * area (640Kb -> 1Mb) as RAM even though it is not. @@ -728,6 +717,15 @@ early_param("reservelow", parse_reservelow); =20 static void __init trim_low_memory_range(void) { + /* + * A special case is the first 4Kb of memory; + * This is a BIOS owned area, not kernel ram, but generally + * not listed as such in the E820 table. + * + * This typically reserves additional memory (64KiB by default) + * since some BIOSes are known to corrupt low memory. See the + * Kconfig help text for X86_RESERVE_LOW. + */ memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); } =09 --=20 2.28.0