From patchwork Tue Mar 2 10:04:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 12111335 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,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 5F009C433E0 for ; Tue, 2 Mar 2021 10:04:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E791C64F0F for ; Tue, 2 Mar 2021 10:04:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E791C64F0F 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 7BE308D00F8; Tue, 2 Mar 2021 05:04:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7202A8D0063; Tue, 2 Mar 2021 05:04:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E7EC8D00F8; Tue, 2 Mar 2021 05:04:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0021.hostedemail.com [216.40.44.21]) by kanga.kvack.org (Postfix) with ESMTP id 4332F8D0063 for ; Tue, 2 Mar 2021 05:04:33 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 0FADD52C1 for ; Tue, 2 Mar 2021 10:04:33 +0000 (UTC) X-FDA: 77874499626.30.6D975F8 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf20.hostedemail.com (Postfix) with ESMTP id B5DE6F8 for ; Tue, 2 Mar 2021 10:04:31 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 031E164F1B; Tue, 2 Mar 2021 10:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614679471; bh=pACDq5dh9SnWHeToI15lAiv7Zc9+44fWIB6RMHF0BEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oFZA3+CfC+xOMR2lWPr7on7rEzOVojEsEaxFZgnroqRvY/QhbYpKja31vbfao/GJk WGP8F0Si5Hc7JLt9UEQFGXi18MZvPWJz5us7WBglcI8Ev4eJmo5H3F7WxtNrESNiVx +kJVAWKpUOiXAlmie414eLbuDHDF1tYHtQSeWg2mJRSEObt+tXTd0xj4Gptsstsm5H qklhTAn6uuNmVk6A6sYV7kXF3Su/kjHE9ROUGUgv16/RTVON3ulgull8dX6yH6Vyp2 9g2HqqqVK7LFWIkZDeU/n/coy8Iqagxp3YsBv93SPrBpmMkNzgfYB+XIK7czAhaqFR b2+Gevc5FCo9g== From: Mike Rapoport To: x86@kernel.org Cc: Andrew Morton , 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, Borislav Petkov Subject: [PATCH v3 2/2] x86/setup: merge several reservations of start of the memory Date: Tue, 2 Mar 2021 12:04:06 +0200 Message-Id: <20210302100406.22059-3-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210302100406.22059-1-rppt@kernel.org> References: <20210302100406.22059-1-rppt@kernel.org> MIME-Version: 1.0 X-Stat-Signature: kisk4fdhh9ykgpsqrpqaq368uoxk6n6h X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: B5DE6F8 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614679471-723124 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 Currently the first several pages are reserved both to avoid leaking their contents on systems with L1TF and to avoid corrupting BIOS memory. Merge the two memory reservations. Signed-off-by: Mike Rapoport Reviewed-by: David Hildenbrand Acked-by: Borislav Petkov --- arch/x86/kernel/setup.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 3e3c6036b023..776fc9b3fafe 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -713,11 +713,6 @@ static int __init parse_reservelow(char *p) early_param("reservelow", parse_reservelow); -static void __init trim_low_memory_range(void) -{ - memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); -} - static void __init early_reserve_memory(void) { /* @@ -730,10 +725,17 @@ static void __init early_reserve_memory(void) (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); /* - * Make sure page 0 is always reserved because on systems with - * L1TF its contents can be leaked to user processes. + * The first 4Kb of memory is a BIOS owned area, but generally it is + * not listed as such in the E820 table. + * + * Reserve the first memory page and typically some additional + * memory (64KiB by default) since some BIOSes are known to corrupt + * low memory. See the Kconfig help text for X86_RESERVE_LOW. + * + * In addition, make sure page 0 is always reserved because on + * systems with L1TF its contents can be leaked to user processes. */ - memblock_reserve(0, PAGE_SIZE); + memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); early_reserve_initrd(); @@ -746,7 +748,6 @@ static void __init early_reserve_memory(void) reserve_bios_regions(); trim_snb_memory(); - trim_low_memory_range(); } /*