Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp267557ybl; Wed, 4 Dec 2019 02:24:49 -0800 (PST) X-Google-Smtp-Source: APXvYqzjynb809wIqDdICqGBzZy1+ocVFP8V1Itq01xfPd6EJ9rAD5PdGvt8nN2C+Nk3a/al+QFT X-Received: by 2002:a9d:4e97:: with SMTP id v23mr1790316otk.201.1575455089466; Wed, 04 Dec 2019 02:24:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575455089; cv=none; d=google.com; s=arc-20160816; b=PWd5icUSYEYNEryT0q6jVgVAsyqBuPERoyjg5BbhYB44zBrtgN2X39BripxbvbuxQF JlUuBEYzQPnuFdiFQNwQAx+SAn1rMznlnfnVyb3/vv8Ix2uPiYMsoHNCVsCYiRSHzwt7 QB77gZJUKvK0f4bOa3/EbO+RsjVSw0CKiQJzd/b2VAIOSo+3HLC6rajVjawBsCmygP6G WMqIsoKwAawXWIocZF9kBw6HS4/xLsFgYdywdd5Ri+ZOq24WghZMy8Qqmsp6zCP1G4Ij jNMw9pxTEZy5rlbXbMgvfbLYLmRU3qR1zmbWmxLej6dIBYt6lFBtVx14UGe8mfilRxOu JKSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GuqJKgxzORWixv+ONGuRvuIb4W1dExSeU86nj2DCsb0=; b=E/v0iJYjTKJDo94W3FwPqrBonHX4RAtbzoZ5V2pQBJiwVqQ42HcQT7sXBmCm5MNjkB 7eHo0E2uS3Z8vGAIcTtZgbMVKjOqvlHA7vdx2E8LIjxgMuix78bSeyKrcxNUnJiuzecI ormYpOc4eVMwK5krxf/PS1wyu2zjQ9kpPKk1OW067eR7w0Tf9PswyHa37P+c1MKSTs/t vr9qX/X7W/jVnbOvnBFsJ71u9YELv9eqwaIJkGqN4eTfUdtNtQDPYA6Kd89iVEWlDfa0 nUHoOYQMOqYXpCCkkub0MwVUOqU5SLH5sh4f4AuUnvX8PEhuW/2bnBHWKDB/548BkhxU zn/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MYMcpF0N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si2885855oia.165.2019.12.04.02.24.36; Wed, 04 Dec 2019 02:24:49 -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=@linaro.org header.s=google header.b=MYMcpF0N; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727429AbfLDKYH (ORCPT + 99 others); Wed, 4 Dec 2019 05:24:07 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45665 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbfLDKYH (ORCPT ); Wed, 4 Dec 2019 05:24:07 -0500 Received: by mail-wr1-f67.google.com with SMTP id j42so7805681wrj.12 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=WFsh6d+rXgd5Q0ROwPU9XMfvlGwLzPYK6aIG6ND9DRijXiIjJgt5ABsyzcFhusJtt/ /SM3cJRsA7OSl9Fgkr0N7cDETHdjnuIsB3v45mmvcStV9iTWx1laejd4tDTj5DteOLe/ OEtg9bi68D7H6KG4d3GHqHhF0bLj14DaREeI+qxta6lNkVvl5nRyLJF/4xLJWFVzmLTs 36EbsvJZv9cdP1nJitftNhw9cJDwbQqGa/TdRTJ20mF6gJV5N5GWvjFlWvCilCSaOK1g RM6SUgGUb4IGWSqQl6VrTT1cnGqjNccx7xlecOnLMIKeFPQWviAz8psSyctDHKnBgMmz hqfg== X-Gm-Message-State: APjAAAXGHL6CiNzh0nuxvFKw0cvqaXFJv7yuC1M14q59fUJi5ohSDwQl LExer5pqr8M3wojLazzJ3Qk7tDpp5OZR4bCXcAlwSw== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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