Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp265344ybl; Wed, 4 Dec 2019 02:22:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzjPl0IN6ZuxzzPkUzi3sEI1pfbb39B3PuhSIeO2fDIDjJZwAceHJvmTMrUAEWhWZtnzf4v X-Received: by 2002:aca:ac88:: with SMTP id v130mr1783738oie.123.1575454932045; Wed, 04 Dec 2019 02:22:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575454932; cv=none; d=google.com; s=arc-20160816; b=mNHYIXIM6IRJLD342A7Y2Bh8t8zESdOnFbINJukTQQpKmN9LSYvOO3ZUOE7/AZcG6h T8UjAJQfaEyCMnFE6aXa2ZU4OwO+bLZ7Kavdibp0h/WDeEpIEK5d6wxYIqFjxyRpPLcv auVVyFrX+oFPvV8S3tXG0D8WUUzvVdKSX5UkfBR+ftRMow4kNVZM1RA+tqJCCQJxf9w2 BBCJCKZYeBK6Lk6VpwOiRifb/9fzkoGOrPrOVQN99kC8hLzV9YsHfyhQ4ZjGR3VNECUV XC/QPU4CIDdah+SaNIVCufRrLuc/Ti+s6QaS6pJluUf3FCbmQqQNYopaBtISRD9XBmxo H7fA== 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=3R5d/kKbQyexjHG8H6JZOh4cUBVVOj1b0/MSbrKgPk0=; b=pCGJHgrH5tbgu8FVVZ4VDqLnfLbcOQNYtilQsOeH6DNjh3c2qjucK3ZTKqZ/03jlfN eZSvSpAxl7D0Zo4GJrZnUk5L0FWLsvvWiDitrATLaTPD4jaEPcQpFyQMTtAGwyQDsVlk 7+bsXQxX4wVYmEIQgY1uu758BNrHDCZNILtUlZlMlzbYqnvBdsbmrX12pDYEqaU+tiZo a57nvcoiPa0d0SVKN1YLU/7NkSYBCZuxuhwXVQzcDzeFx/TyX32VLEZe/Iwn1evu5RSM NIbMIK6pnihVsCN8BB7vrJMJAsT5+ARftpSWzRi+ImBl+QGx6rKG9q30qQ1XfSj3z3ma GDSw== 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 y3si2999825ote.235.2019.12.04.02.21.59; Wed, 04 Dec 2019 02:22:12 -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 S1727472AbfLDKV2 (ORCPT + 99 others); Wed, 4 Dec 2019 05:21:28 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:56697 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbfLDKV1 (ORCPT ); Wed, 4 Dec 2019 05:21:27 -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 1icRmU-0006v8-1R; Wed, 04 Dec 2019 11:21:14 +0100 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id A21A21C2667; Wed, 4 Dec 2019 11:21:13 +0100 (CET) Date: Wed, 04 Dec 2019 10:21:13 -0000 From: "tip-bot2 for Dave Young" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/efi: Update e820 with reserved EFI boot services data to fix kexec breakage Cc: Michael Weiser , Dave Young , Ard Biesheuvel , Borislav Petkov , "Eric W. Biederman" , "H. Peter Anvin" , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , kexec@lists.infradead.org, linux-efi@vger.kernel.org, Ingo Molnar , x86 , LKML In-Reply-To: <20191204075233.GA10520@dhcp-128-65.nay.redhat.com> References: <20191204075233.GA10520@dhcp-128-65.nay.redhat.com> MIME-Version: 1.0 Message-ID: <157545487347.21853.1786279419838113209.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/urgent branch of tip: Commit-ID: af164898482817a1d487964b68f3c21bae7a1beb Gitweb: https://git.kernel.org/tip/af164898482817a1d487964b68f3c21bae7a1beb Author: Dave Young AuthorDate: Wed, 04 Dec 2019 15:52:33 +08:00 Committer: Ingo Molnar CommitterDate: Wed, 04 Dec 2019 11:15:30 +01:00 x86/efi: Update e820 with reserved EFI boot services data to fix kexec breakage Michael Weiser reported that he got this error during a kexec rebooting: esrt: Unsupported ESRT version 2904149718861218184. The ESRT memory stays in EFI boot services data, and it was reserved in kernel via efi_mem_reserve(). The initial purpose of the reservation is to reuse the EFI boot services data across kexec reboot. For example the BGRT image data and some ESRT memory like Michael reported. But although the memory is reserved it is not updated in the X86 E820 table, and kexec_file_load() iterates system RAM in the IO resource list to find places for kernel, initramfs and other stuff. In Michael's case the kexec loaded initramfs overwrote the ESRT memory and then the failure happened. Since kexec_file_load() depends on the E820 table being updated, just fix this by updating the reserved EFI boot services memory as reserved type in E820. Originally any memory descriptors with EFI_MEMORY_RUNTIME attribute are bypassed in the reservation code path because they are assumed as reserved. But the reservation is still needed for multiple kexec reboots, and it is the only possible case we come here thus just drop the code chunk, then everything works without side effects. On my machine the ESRT memory sits in an EFI runtime data range, it does not trigger the problem, but I successfully tested with BGRT instead. both kexec_load() and kexec_file_load() work and kdump works as well. [ mingo: Edited the changelog. ] Reported-by: Michael Weiser Tested-by: Michael Weiser Signed-off-by: Dave Young Cc: Ard Biesheuvel Cc: Borislav Petkov Cc: Eric W. Biederman Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: kexec@lists.infradead.org Cc: linux-efi@vger.kernel.org Link: https://lkml.kernel.org/r/20191204075233.GA10520@dhcp-128-65.nay.redhat.com Signed-off-by: Ingo Molnar --- arch/x86/platform/efi/quirks.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 7675cf7..f8f0220 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -260,10 +260,6 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) return; } - /* No need to reserve regions that will never be freed. */ - if (md.attribute & EFI_MEMORY_RUNTIME) - return; - size += addr % EFI_PAGE_SIZE; size = round_up(size, EFI_PAGE_SIZE); addr = round_down(addr, EFI_PAGE_SIZE); @@ -293,6 +289,8 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) early_memunmap(new, new_size); efi_memmap_install(new_phys, num_entries); + e820__range_update(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED); + e820__update_table(e820_table); } /*