Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp207891pxb; Fri, 15 Jan 2021 00:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoVcfEayhajDCMf7XFFdYwDWF76PXHAuJa41NrpFvepCoIlBnsyijaJvYGS1AKl3NAZtxf X-Received: by 2002:a05:6402:1d3b:: with SMTP id dh27mr8990901edb.238.1610700545661; Fri, 15 Jan 2021 00:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610700545; cv=none; d=google.com; s=arc-20160816; b=aSwlaIV0/1rOIvemwJSv8n9Idd1ykCTTFdZJnC80MxehCZt2S/LNJBHr+v4GJTTdH4 mBIbbAVIg8YHCTQRy6U8JBrJnYO20MGfq+a9F8FDvVrAOkcsjbWajuuGN0EMsAgY7wZ8 8g8x+Dz2M001CdI11zveCgxJX/ddO4Bejce1KjKHRF1bTYlITHMX1szURr+5UFcWFuZj +LtzTUimuvc3n4coiSIAGcoSI5+jGM2/vjc6tKkBNOvAkuO24ylNcP4dgw/gMtZS9Ey9 tuOzeSGRRePI5hHBXil/zrjJPH60kg4gZH/8IdcigttpnNztDppJ72adjMfuU7vkt9oX Dt2g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LFcGWv9Y0BqQ6I242fva4vmS+1J/Kb8ubGDwLL+ijKI=; b=0wF37oWaQbOwNc7+4SBSXksv39zFrnWIexe+3T+MrFxcjKIcqOZqvDcTdf3zPB7wYi qK+wH6cwIkhif/QDRu5qOjKMvQjg1hcmWa04y8nOEpxHCpf3FpSNsowwRleI7qZC/LGt hr4XxqRy3ngWTdsFw7zQbKcZpltpel7HUoqTP80xUuiOzLSt2zKiXJUl4ZU+XpQVCXQ4 /7mzvsqjDUikbae7c87/9tCdzQWQjTsEKGCZl3kuUKyp9F8LDJ8/Ts04llOxlnYs+P0t y9MTgvfuS7GE5QuGal+DN7eeWHnsBhYwXatrEWWH1gP5dl1KCWWv17ttBiVyzvT1YOHD kUPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AZMzuYEa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si1715412ejm.29.2021.01.15.00.48.41; Fri, 15 Jan 2021 00:49:05 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AZMzuYEa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730538AbhAOIeL (ORCPT + 99 others); Fri, 15 Jan 2021 03:34:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:57396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730201AbhAOIeK (ORCPT ); Fri, 15 Jan 2021 03:34:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B4B6E23436; Fri, 15 Jan 2021 08:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610699610; bh=StoT2zp79sznIPfcRkkmD1yMT7cGVvKLETHGz0Lwr3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AZMzuYEacN0wqIbOJ5wTWm5r6t/pKWqQzWZKUM6+sW2j61F1dxN1ZSm2o0RtLNwty ZhBXIqRNtG4Cy346zt8KEHMhL3WhQ7m21aoEcmpmNLv2IET4NRUsqjZx0GnTih8CoT 5mWAzUGd9KbCX/Xs/uTpu+/EfpZEuz0lYaeZBhBti6lGoRlmCkbNUqukoaYZBviMGT +P4ENiB2ZHA86/GJVUzzcIMePKKm7rME+Lv5T8sUsqW3NcLs+r8I5MBNxA6jzDb1kQ G4C9+GRZxRqDMw60BeBUQXjnn+eT17lK8qB5cR91eTBnqQOa5BDaK3whZ7zu4rGa+C 1w75MLZUsFE1g== 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 2/2] x86/setup: merge several reservations of start of the memory Date: Fri, 15 Jan 2021 10:32:55 +0200 Message-Id: <20210115083255.12744-3-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210115083255.12744-1-rppt@kernel.org> References: <20210115083255.12744-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/kernel/setup.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 32cd2e790a0a..3f2fd67240f8 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -715,20 +715,6 @@ static int __init parse_reservelow(char *p) early_param("reservelow", parse_reservelow); -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)); -} - static void __init early_reserve_memory(void) { /* @@ -741,10 +727,18 @@ 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, we must 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(); @@ -757,7 +751,6 @@ static void __init early_reserve_memory(void) reserve_bios_regions(); trim_platform_memory_ranges(); - trim_low_memory_range(); } /* -- 2.28.0