Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2298188ybv; Mon, 24 Feb 2020 02:51:42 -0800 (PST) X-Google-Smtp-Source: APXvYqw3yg/227clrdHQBsz3eP8tLb063U3Ly5ZWub1iaBV71R1qF1vwh8OncyXqcHvw5POK9h83 X-Received: by 2002:a05:6830:1643:: with SMTP id h3mr37731863otr.70.1582541502439; Mon, 24 Feb 2020 02:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582541502; cv=none; d=google.com; s=arc-20160816; b=KBa5YN/5ONCi0fXLrCEHvxRUDkttu18a4l4oyvPRidain4QjxxmcQZc8kIKvj0m0wg AekV073mY+E6DXwyYatLxXwTZJhxOdFPzGo5G7fdbopuBFJ1QTyde8bkEJUahPQs4CKG I1ZBeXWQ6K+lN5gmdsXEbCezoDRa2TqBFeK9Gb3GNVgqMRHuCusJLyzRSwxKLrwXMzKH oNdOH+aoABgL3zQ0I27Hr/FFcaDuLiLpU8mXGzNK7m3XmVvHml8E4v4TRNTjha4Ov/xZ W55e3aSWY7CrQI6B26mjWa/n2t5z5M8qbDcRo3FOP+geL7oVa3JWCyNjmgkbmgKQIMrA b++Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=mJJ5AiMKw8Z88lllEJWulcdY1bH8rY6Gj30+npagdsk=; b=zlw/lCDCWMBe8rG5IUKaZ9Lxas//jvwItGRaxHNdJCrWw9sL6A5iyObkU/QVLnTJ+9 Dck55l64mIfgoPvyk18QUeEKLji2Qqbq62aZrGWyRN0Vr7HKMEV0yNKmV/IxlmrMCvxN 96a3a/bTpy4zsS5TBBjzFpaLkg/Tzbl5ApbA8LjkMrT4+LAuAEzzKf5Ym3+p+1mzg9t6 XVqjmLh+9MWzGiJUKE16x/ziaLo2EzppQB0HVE75blwiug4yS+ECLqEeD16ODWPyp5nO q/lbTtQLUDAS4kNpZUbNwmMZtMZBGESD6d4I+0nrfYzwOVyPKDQJNrjbGSir2RKiTqZX NARA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23si6129469oti.34.2020.02.24.02.51.29; Mon, 24 Feb 2020 02:51:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727312AbgBXKvP (ORCPT + 99 others); Mon, 24 Feb 2020 05:51:15 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:49463 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbgBXKvP (ORCPT ); Mon, 24 Feb 2020 05:51:15 -0500 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j6BKP-0008RK-V6; Mon, 24 Feb 2020 11:51:10 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 6EF3D1C1A0F; Mon, 24 Feb 2020 11:51:09 +0100 (CET) Date: Mon, 24 Feb 2020 10:51:08 -0000 From: "tip-bot2 for Dave Young" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/kdump] x86/kexec: Do not reserve EFI setup_data in the kexec e820 table Cc: Dave Young , Borislav Petkov , x86 , LKML In-Reply-To: <20200212110424.GA2938@dhcp-128-65.nay.redhat.com> References: <20200212110424.GA2938@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Message-ID: <158254146897.28353.4247096498069522547.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/kdump branch of tip: Commit-ID: 8efbc518b884e1db2dd6a6fce62d0112ab871dcf Gitweb: https://git.kernel.org/tip/8efbc518b884e1db2dd6a6fce62d0112ab871dcf Author: Dave Young AuthorDate: Wed, 12 Feb 2020 19:04:24 +08:00 Committer: Borislav Petkov CommitterDate: Mon, 24 Feb 2020 11:41:57 +01:00 x86/kexec: Do not reserve EFI setup_data in the kexec e820 table The e820 table for the kexec kernel unconditionally marks setup_data as reserved because the second kernel can reuse setup_data passed by the 1st kernel's boot loader, for example SETUP_PCI marked regions like PCI BIOS, etc. SETUP_EFI types, however, are used by kexec itself to enable EFI in the 2nd kernel. Thus, it is pointless to add this type of setup_data to the kexec e820 table as reserved. IOW, what happens is this: - 1st physical boot: no SETUP_EFI. - kexec loads a new kernel and prepares a SETUP_EFI setup_data blob, then reboots the machine. - 2nd kernel sees SETUP_EFI, reserves it both in the e820 and in the kexec e820 table. - If another kexec load is executed, it prepares a new SETUP_EFI blob and then reboots the machine into the new kernel. 5. The 3rd kexec-ed kernel has two SETUP_EFI ranges reserved. And so on... Thus skip SETUP_EFI while reserving setup_data in the e820_table_kexec table because it is not needed. [ bp: Heavily massage commit message, shorten line and improve comment. ] Signed-off-by: Dave Young Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200212110424.GA2938@dhcp-128-65.nay.redhat.com --- arch/x86/kernel/e820.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index c5399e8..c920296 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -999,7 +999,15 @@ void __init e820__reserve_setup_data(void) while (pa_data) { data = early_memremap(pa_data, sizeof(*data)); e820__range_update(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); - e820__range_update_kexec(pa_data, sizeof(*data)+data->len, E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); + + /* + * SETUP_EFI is supplied by kexec and does not need to be + * reserved. + */ + if (data->type != SETUP_EFI) + e820__range_update_kexec(pa_data, + sizeof(*data) + data->len, + E820_TYPE_RAM, E820_TYPE_RESERVED_KERN); if (data->type == SETUP_INDIRECT && ((struct setup_indirect *)data->data)->type != SETUP_INDIRECT) {