From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B141BC43603 for ; Wed, 4 Dec 2019 10:24:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80864206DB for ; Wed, 4 Dec 2019 10:24:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MYMcpF0N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727351AbfLDKYH (ORCPT ); Wed, 4 Dec 2019 05:24:07 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46924 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726893AbfLDKYH (ORCPT ); Wed, 4 Dec 2019 05:24:07 -0500 Received: by mail-wr1-f68.google.com with SMTP id z7so7790134wrl.13 for ; Wed, 04 Dec 2019 02:24:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GuqJKgxzORWixv+ONGuRvuIb4W1dExSeU86nj2DCsb0=; b=MYMcpF0NBpya3Dp0QUs8IhS2XLN5hBn3Y74n2Fpg/00W933ktGY5gQuF5wGqC7dYf/ 09qiEy92KfIgQgS+Zmo0DpX7rURPfWDBgRkP3d/r9p6HsYExqQAgaV/iRhlwDbZGw98L uPjFZBSTofPNVxyjqtBh6MdbKRYzbm8MSmaMbsCVuthOUDjBMC7fGMTpxrA33vLEM/Ir 4cFfh+nlygb67h7WLQ083u+1eogyQ1SvUA71LYknaaooRX/9P/7kQU54UYf1oMm1qMi6 PE25lcUp+E2amWLAZt0AbC10mzYJ6McnJbJKCA3Ann6D5MibCmobitoldmtdRSxAcjvV y9KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GuqJKgxzORWixv+ONGuRvuIb4W1dExSeU86nj2DCsb0=; b=bRzWw2/G3I2ftg9bj2+xv+1LPY4oHxtbL1cTAEjs4D1iCPlYR7TkA7UZpF/0i+UmTE R8okWOlo113XcNvygWDcP10mx59CPXw9TZ+y1J+Z9qfThKHXN5cRYhPkS61lAwTTEJEv bSKGOCDBlGFstZ9oLnrxUtt79j+GlX0rV1G3xPlLZON7G9m59eKn/ut2kKzZxC1UDLjx ujzKaQfMt9fkeChh58aSxchuiu/Z6DMrMokHeqcKkrys3q7AzCjIsuU8V9RWcPjTVg+5 VQxvu7w6eZ7Ch6oJIdpzA/65DCMLM07I3NxvVDZ22Jq9tw400U9WB1CbJbcu9/8uBKs8 CtEw== X-Gm-Message-State: APjAAAWttVBRiXdFz+bCMa/p+KlCW3QQGrNvDpYf5NbBDYhY06t2xTBr 3UvcNHE+AvYoy1tmEVSizhbinkrBPnm3jcgRfkt5Ng== X-Google-Smtp-Source: APXvYqxWwFndRJgAqjBJu+iNimNvB0sXaYF2yRdMmBK9Aw4qj7i6zYf8yApxP+lwHCYRcybjgFLsPwfMKMGRGGwlg9Y= X-Received: by 2002:a5d:6652:: with SMTP id f18mr3249867wrw.246.1575455044775; Wed, 04 Dec 2019 02:24:04 -0800 (PST) MIME-Version: 1.0 References: <20191204075233.GA10520@dhcp-128-65.nay.redhat.com> <20191204075917.GA10587@dhcp-128-65.nay.redhat.com> <20191204101412.GD114697@gmail.com> In-Reply-To: <20191204101412.GD114697@gmail.com> From: Ard Biesheuvel Date: Wed, 4 Dec 2019 10:24:01 +0000 Message-ID: Subject: Re: [PATCH] x86/efi: update e820 about reserved EFI boot services data to fix kexec breakage To: Ingo Molnar Cc: Dave Young , linux-efi , "the arch/x86 maintainers" , Linux Kernel Mailing List , Michael Weiser , Kexec Mailing List , Ingo Molnar , Borislav Petkov , "Eric W. Biederman" , "H. Peter Anvin" , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org On Wed, 4 Dec 2019 at 10:14, Ingo Molnar wrote: > > > * Dave Young wrote: > > > On 12/04/19 at 03:52pm, Dave Young wrote: > > > Michael Weiser reported he got below 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 X86 e820 table. > > > And kexec_file_load iterate system ram in io resource list to find places > > > for kernel, initramfs and other stuff. In Michael's case the kexec loaded > > > initramfs overwritten the ESRT memory and then the failure happened. > > > > s/overwritten/overwrote :) If need a repost please let me know.. > > > > > > > > Since kexec_file_load depends on the e820 to be 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 reboot. > > > 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. > > > > > > Signed-off-by: Dave Young > > > So I edited this to: > > From: Dave Young > > Michael Weiser reported 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. > Acked-by: Ard Biesheuvel