Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2545604imu; Sun, 23 Dec 2018 02:09:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mgZHMhPvhIh/CzHDlBT/z1rklXqpfOJdz5H8fBA1UrzC1aV1DjZUxA0Hl+2aGGV/Usngw X-Received: by 2002:a17:902:bf44:: with SMTP id u4mr9221040pls.5.1545559751659; Sun, 23 Dec 2018 02:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545559751; cv=none; d=google.com; s=arc-20160816; b=IPf0WAkNw9yQtxPlA7djA7L/B7ecGCjJegRFxd/l3MTjcIYvAee+mwMcOl9kXPJiDk r0lrz6sdu8Dk9Njy/RQhO+bwyKsSUgDWr8TxsgEsDweFLiIUC0CCv+g/bQ+ytV2u4319 FJWWmC8n+TZfG3dlHIaTWv3rYbBs5Ogqt6nEcXD7DVGCwErls/Kusp3Gt5AEfYK6lPw4 TC1eigMzN4rf3kAYeOQPpXXw3q0/FdAqNCqwQX3G1BiRFXXz2sUO0igUIFpYrCFA6/iz D2bx+fcWE2s9Nk/+NubkeOnvwU/2LPEvrFIusYSEJgr1T8mJwIxEbr/VjlAv98qRPCgd jORA== 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=nC66WFBt2UA/oQmVErlW1SJnvVObcYp24ZyY6ukSH9o=; b=0zPbymKXVTTZAD9BRDB3LP4u1YpyIxWv1v0qflPWST7QROc8Bjq39+23W0zfl5C136 YjOyX1mlr5fd/lc08hLGSB55OhcsY9exFwBkeOekzv+GVZn2Kc8syS4l6NlIxDABFX01 4NN1XrMKcmLjx6UcqCTzZVq9F9Onv3IOWhtYXYI97OMHdtNZTspjIVsSW+8pPymMmHaz 2jrxI9TuIaEnqn5+8bk31PZ10vWV8iYZH2FoLTaHzVRsd/Y2THzAwa0WRiJ7+zQKwFsy cLeEbVy4q1wHbl6NZRlAqEmMUzBNyXKaePEfRDKkcmf8WYrm9HN87AKfQs1LZz7tHRtW 89tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NuON10re; 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 k19si22705748pgn.20.2018.12.23.02.08.56; Sun, 23 Dec 2018 02:09:11 -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=NuON10re; 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 S2387953AbeLVQvJ (ORCPT + 99 others); Sat, 22 Dec 2018 11:51:09 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:50374 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbeLVQvJ (ORCPT ); Sat, 22 Dec 2018 11:51:09 -0500 Received: by mail-it1-f196.google.com with SMTP id z7so11302158iti.0 for ; Sat, 22 Dec 2018 08:51:08 -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=nC66WFBt2UA/oQmVErlW1SJnvVObcYp24ZyY6ukSH9o=; b=NuON10re+9DbPQheYmgLRGo6CLC1oGuEAZTxovj4V8CSWAOLZqKRLTIM5bVWl2MYrL HI9HOKmjzC0LRjjoGQfYjavXHRUr+620BYiFjd/w7wH5yLB8lhoLmIgdxhcf5M2hAEOv 21yjwcjpEFg5KqMGZyfHYNmRjHooi3URwCdZE= 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=nC66WFBt2UA/oQmVErlW1SJnvVObcYp24ZyY6ukSH9o=; b=GV9RsMVyXsxEiv8gZPXA4S4XC54X5bx4NTPyxXE0ojy5F9k1rCtMF/bUIMsheRmzqh D76e/RTw6ayKYtJ9Lizlu5iuOjm5GEvuo93Not2VrjB8lajImhFcHA4RD4tFOmSxSu4g uto3NPZnMECUfyFLlyHFHKcpX/N4/apYx3ZDhZW0gZ8OBM06j1SYwqSrtZxq5pZPt97F RgS3J9RZYGlEQoYaeSrHh7BUbMmKWxazWUIYabp4hG0X8R1UC9+W4McbMIja/l3P3rAO sSHWB7+0fsOHUS2a6G3JZV7XOSXtOxgGJkiEaa27b9dfXfDAaRSDS1HoPidKhCbn+fe2 G1lA== X-Gm-Message-State: AA+aEWaATV/NUyULcnFmvg4tNLOirsvoVsz/858oVLbikaFiaiPpisaU yza1ZX7kkgcDCLd+AMlTZ7CMiF758IDnVURkT65ZEQ== X-Received: by 2002:a24:edc4:: with SMTP id r187mr4701604ith.158.1545476699638; Sat, 22 Dec 2018 03:04:59 -0800 (PST) MIME-Version: 1.0 References: <20181222022234.7573-1-sai.praneeth.prakhya@intel.com> <20181222105410.GA130780@gmail.com> In-Reply-To: <20181222105410.GA130780@gmail.com> From: Ard Biesheuvel Date: Sat, 22 Dec 2018 12:04:49 +0100 Message-ID: Subject: Re: [PATCH] x86/efi: Don't unmap EFI boot services code/data regions for EFI_OLD_MEMMAP and EFI_MIXED_MODE To: Ingo Molnar Cc: Sai Praneeth Prakhya , linux-efi , Linux Kernel Mailing List , "the arch/x86 maintainers" , Borislav Petkov , Andy Lutomirski , Dave Hansen , Bhupesh Sharma , Peter Zijlstra , 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 Sat, 22 Dec 2018 at 11:54, Ingo Molnar wrote: > > > * Sai Praneeth Prakhya wrote: > > > Commit d5052a7130a6 ("x86/efi: Unmap EFI boot services code/data regions > > from efi_pgd") forgets to take two EFI modes into consideration namely > > EFI_OLD_MEMMAP and EFI_MIXED_MODE. > > So the commit sha1 ended up being this one in tip:efi/core: > > 08cfb38f3ef4: x86/efi: Unmap EFI boot services code/data regions from efi_pgd > > > EFI_OLD_MEMMAP is a legacy way of mapping EFI regions into swapper_pg_dir > > using ioremap() and init_memory_mapping(). This feature can be enabled by > > passing "efi=old_map" as kernel command line argument. But, > > efi_unmap_pages() unmaps EFI boot services code/data regions *only* from > > efi_pgd and hence cannot be used for unmapping EFI boot services code/data > > regions from swapper_pg_dir. > > > > Introduce a temporary fix to not unmap EFI boot services code/data regions > > when EFI_OLD_MEMMAP is enabled while working on a real fix. > > > > EFI_MIXED_MODE is another feature where a 64-bit kernel runs on a > > 64-bit platform crippled by a 32-bit firmware. To support EFI_MIXED_MODE, > > all RAM (i.e. namely EFI regions like EFI_CONVENTIONAL_MEMORY, > > EFI_LOADER_, EFI_BOOT_SERVICES_ and > > EFI_RUNTIME_CODE/DATA regions) is mapped into efi_pgd all the time to > > facilitate EFI runtime calls access it's arguments in 1:1 mode. Hence, > > don't unmap EFI boot services code/data regions when booted in mixed mode. > > > > Signed-off-by: Sai Praneeth Prakhya > > Cc: Borislav Petkov > > Cc: Ingo Molnar > > Cc: Andy Lutomirski > > Cc: Dave Hansen > > Cc: Bhupesh Sharma > > Cc: Peter Zijlstra > > Cc: Thomas Gleixner > > Cc: Ard Biesheuvel > > --- > > arch/x86/platform/efi/quirks.c | 16 ++++++++++++++++ > > 1 file changed, 16 insertions(+) > > > > diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c > > index 09e811b9da26..9c34230aaeae 100644 > > --- a/arch/x86/platform/efi/quirks.c > > +++ b/arch/x86/platform/efi/quirks.c > > @@ -380,6 +380,22 @@ static void __init efi_unmap_pages(efi_memory_desc_t *md) > > u64 pa = md->phys_addr; > > u64 va = md->virt_addr; > > > > + /* > > + * To Do: Remove this check after adding functionality to unmap EFI boot > > + * services code/data regions from direct mapping area because > > + * "efi=old_map" maps EFI regions in swapper_pg_dir. > > + */ > > + if (efi_enabled(EFI_OLD_MEMMAP)) > > + return; > > + > > + /* > > + * EFI mixed mode has all RAM mapped to access arguments while making > > + * EFI runtime calls, hence don't unmap EFI boot services code/data > > + * regions. > > + */ > > + if (!efi_is_native() && IS_ENABLED(CONFIG_EFI_MIXED)) AFAIK efi_is_native() can only return false is CONFIG_EFI_MIXED is set, so this expression can be simplified. > > + return; > > I suppose old_mmap and mixed mode stopped working altogether after the > unmapping changes? What are the symptoms, instant reboots, crasher, or > some more benign behavior like non-working runtime EFI functionality? > > If Ard acks this I'll apply it immediately, as these bugs look like > show-stoppers for merging the EFI tree into v4.21. > Acked-by: Ard Biesheuvel with the sidenote that I won't be able to test this myself until monday at the earliest.