Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp947742pxb; Wed, 3 Mar 2021 22:08:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyP68SFMpX+6os9DqPy+w+Nq9oQVTGYVtEOt1+abCFkIbEEiG+mDVzaUhH6Q34QVIl9BCy1 X-Received: by 2002:a17:906:a44:: with SMTP id x4mr2439283ejf.101.1614838103026; Wed, 03 Mar 2021 22:08:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614838103; cv=none; d=google.com; s=arc-20160816; b=XjscQ4WAohTtNMo7MuEVaNXDzENZkN4rvFqMieso4X64K2lt5DwbNrhC+uplPeog9w de3urWWFJI7d32e/UHzbio2FUp+AyWbvNc2TUJcQ94jbQDt2YlfzHZpt7JZG+RU+9pKp MC9R5N7LTCJbV1G9kHy/By+kE7cByN+3bbogIjpZ+s1xc4ZQLNiRSnIrKkeStwCv8tas 1xnva34RxeoysUguckt/9FNyQJ0hc0E5Ki7Wd/jijniKwsvyBbeadVI5WHyy5TJSn4N5 MSkJwhh7yun8rIolYMe0CxXfzaV3qMSPHeR0Z8cJCri1virAHrLneRRf/r5aOhZzk8kQ BwOA== 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=YJgWWNgMIoZEoLJ7BFuWJzwPNVXyiX9CO75Mv99y9nM=; b=h5SayZLd/xgv7VIQaSeDjataDa8lmc11aQ0CuNEyOaYBDBDvZDMwKThof8AbSm35iO q4/0DcgyOno8ZENZx8TRejXlggR0dV3zNYlvjHhGfJQEYVBuwRQgdQSLTeiCByMPx193 dsCee+nZa8KfBxsBZ9jGd8HZhcQU3RixF4b+7tHSxdftfjUK2ZlFLqcfa5ugN841hTOT 1LF48pc0JqqYcOCYMBTJbq9UW3J9Hr4ifZP0AtXc58tirFEdZiVHuKUZ2XS8uv1ga9xT fZvhYz2uGQg5Jxb1OUfheQxSV3Uv49Q2lN2MCCYafadaGNcfwcFdgd9Ifo+xCQcFLx+A qqhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oFZA3+Cf; 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 jg13si17390338ejc.126.2021.03.03.22.08.00; Wed, 03 Mar 2021 22:08:23 -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=oFZA3+Cf; 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 S1380032AbhCBK0X (ORCPT + 99 others); Tue, 2 Mar 2021 05:26:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:55236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349563AbhCBKFO (ORCPT ); Tue, 2 Mar 2021 05:05:14 -0500 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 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 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(); } /* -- 2.28.0