Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1766273ybl; Sat, 11 Jan 2020 02:23:07 -0800 (PST) X-Google-Smtp-Source: APXvYqwxYzCNokh2W0A7Rr0LjM1dJK9lyU8iXxDpq9Sa78bAqnrm8+QIbbe0iksPri4ZUS2MEjL8 X-Received: by 2002:a9d:7999:: with SMTP id h25mr6310183otm.347.1578738187817; Sat, 11 Jan 2020 02:23:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578738187; cv=none; d=google.com; s=arc-20160816; b=oA8PkH2joEEfv73iZrvBaOlBw7McyrLvmt3JuY82QAFqY55CIAa925AQH1BvRXTebd EIkBZqYiUxl1F8FzJ/w87vGwDY/dGNDqr3IYFxKoOh5gFPfmO+CJkLN9eeHEz2ACzAze kk6d38zlx6fOZ3/4jhIEmUj9MK9eaD88BoUyRK8Pf1slsCPzIwOL6erYOQ4QN3e/S1VF 6dOU08qOvnBh8Wpo3WzFrK6WS+PCjYv7TlaBaTXq0JCRzmbeWT5I6uBffRV8lLZ4jVLH Akf/0JM9fGKQ+QAyJQZPnrQal33/aTuEuE7QPSLBDyBC+wVo2y4E4aCJbjEDlmJ9Hmp0 4Nbg== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=37moGv9mY4T3LfIjGwmHsOx9K3Ml8O3nf6jyIMn9WFM=; b=eA4b49GNdXQMmw+xDp5/AvcklKa2VbC36W6+bzY9PhkI0opheDaKjbqZfPtakVduCu GJC2cQHgqrOHGv0v09R+YlP4BhCna4jRHpeH0rfyHKeCsXOG4tZVaXrlluJ78DjyKsw8 Mm7gRfBtIlMWhnJ5K15RrUW+qnXKJ+j1HxuHiZRI2OKkLV9O7FV2S5+f/wqNnEBsvmjr AyqgBnEnzBzxZfMnQ/6QC8+z964/Deqcx4Na5X0JGh6cRH1ojsz+8x07xUr3p5dFIrQS m2vrrU5OkRwUAoDos1FKZlGgg0iKaBRPvBAjno6Mev7HMjlXZRv2oqc/U0h8sa5XQgJy dD+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fROb1PGb; 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 c11si3532197otf.91.2020.01.11.02.22.56; Sat, 11 Jan 2020 02:23:07 -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; dkim=pass header.i=@kernel.org header.s=default header.b=fROb1PGb; 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 S1729245AbgAKKVH (ORCPT + 99 others); Sat, 11 Jan 2020 05:21:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:43744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729336AbgAKKVF (ORCPT ); Sat, 11 Jan 2020 05:21:05 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 527EB2084D; Sat, 11 Jan 2020 10:21:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578738064; bh=PAOUSNAxojEzCiLlv75nNZS799ylz9MjHsY1qAlDUQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fROb1PGbvTmr1tBLiCxYG+v51DDSQtCf6HJcnQb6C5EMaDI580G+z13uWs2lGfs3r HkJyz6J/4z8ExYVbPYHkUXDlqss8bOdHk2p0jpwzs8Tj1CsHbZGluVn6RgemM+DgCk FN8ncTRcW7rBlPW1wdeQAy/1xloTTTLJeCiQvAjs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, 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 , Sasha Levin Subject: [PATCH 5.4 018/165] x86/efi: Update e820 with reserved EFI boot services data to fix kexec breakage Date: Sat, 11 Jan 2020 10:48:57 +0100 Message-Id: <20200111094922.468903342@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200111094921.347491861@linuxfoundation.org> References: <20200111094921.347491861@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Young [ Upstream commit af164898482817a1d487964b68f3c21bae7a1beb ] 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 Signed-off-by: Sasha Levin --- 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 3b9fd679cea9..aefe845dff59 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); } /* -- 2.20.1