stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <matt@codeblueprint.co.uk>
To: tglx@linutronix.de, hpa@zytor.com, leif.lindholm@linaro.org,
	ard.biesheuvel@linaro.org, jlee@suse.com, stable@vger.kernel.org,
	mjg59@srcf.ucam.org, linux-kernel@vger.kernel.org,
	mingo@kernel.org, torvalds@linux-foundation.org, bp@suse.de,
	dyoung@redhat.com, matt.fleming@intel.com, pjones@redhat.com,
	JBottomley@Odin.com, peterz@infradead.org, efault@gmx.de
Cc: linux-tip-commits@vger.kernel.org
Subject: Re: [tip:core/urgent] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down
Date: Fri, 2 Oct 2015 10:44:05 +0100	[thread overview]
Message-ID: <20151002094405.GA2846@codeblueprint.co.uk> (raw)
In-Reply-To: <tip-a5caa209ba9c29c6421292e7879d2387a2ef39c9@git.kernel.org>

On Thu, 01 Oct, at 05:48:43AM, tip-bot for Matt Fleming wrote:
> Commit-ID:  a5caa209ba9c29c6421292e7879d2387a2ef39c9
> Gitweb:     http://git.kernel.org/tip/a5caa209ba9c29c6421292e7879d2387a2ef39c9
> Author:     Matt Fleming <matt.fleming@intel.com>
> AuthorDate: Fri, 25 Sep 2015 23:02:18 +0100
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Thu, 1 Oct 2015 12:51:28 +0200
> 
> x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down
> 
> Beginning with UEFI v2.5 EFI_PROPERTIES_TABLE was introduced
> that signals that the firmware PE/COFF loader supports splitting
> code and data sections of PE/COFF images into separate EFI
> memory map entries. This allows the kernel to map those regions
> with strict memory protections, e.g. EFI_MEMORY_RO for code,
> EFI_MEMORY_XP for data, etc.
> 
> Unfortunately, an unwritten requirement of this new feature is
> that the regions need to be mapped with the same offsets
> relative to each other as observed in the EFI memory map. If
> this is not done crashes like this may occur,
> 
>   BUG: unable to handle kernel paging request at fffffffefe6086dd
>   IP: [<fffffffefe6086dd>] 0xfffffffefe6086dd
>   Call Trace:
>    [<ffffffff8104c90e>] efi_call+0x7e/0x100
>    [<ffffffff81602091>] ? virt_efi_set_variable+0x61/0x90
>    [<ffffffff8104c583>] efi_delete_dummy_variable+0x63/0x70
>    [<ffffffff81f4e4aa>] efi_enter_virtual_mode+0x383/0x392
>    [<ffffffff81f37e1b>] start_kernel+0x38a/0x417
>    [<ffffffff81f37495>] x86_64_start_reservations+0x2a/0x2c
>    [<ffffffff81f37582>] x86_64_start_kernel+0xeb/0xef
> 
> Here 0xfffffffefe6086dd refers to an address the firmware
> expects to be mapped but which the OS never claimed was mapped.
> The issue is that included in these regions are relative
> addresses to other regions which were emitted by the firmware
> toolchain before the "splitting" of sections occurred at
> runtime.
> 
> Needless to say, we don't satisfy this unwritten requirement on
> x86_64 and instead map the EFI memory map entries in reverse
> order. The above crash is almost certainly triggerable with any
> kernel newer than v3.13 because that's when we rewrote the EFI
> runtime region mapping code, in commit d2f7cbe7b26a ("x86/efi:
> Runtime services virtual mapping"). For kernel versions before
> v3.13 things may work by pure luck depending on the
> fragmentation of the kernel virtual address space at the time we
> map the EFI regions.
> 
> Instead of mapping the EFI memory map entries in reverse order,
> where entry N has a higher virtual address than entry N+1, map
> them in the same order as they appear in the EFI memory map to
> preserve this relative offset between regions.
> 
> This patch has been kept as small as possible with the intention
> that it should be applied aggressively to stable and
> distribution kernels. It is very much a bugfix rather than
> support for a new feature, since when EFI_PROPERTIES_TABLE is
> enabled we must map things as outlined above to even boot - we
> have no way of asking the firmware not to split the code/data
> regions.
> 
> In fact, this patch doesn't even make use of the more strict
> memory protections available in UEFI v2.5. That will come later.
> 
> Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
> Cc: <stable@vger.kernel.org>
> Cc: Borislav Petkov <bp@suse.de>
> Cc: Chun-Yi <jlee@suse.com>
> Cc: Dave Young <dyoung@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: James Bottomley <JBottomley@Odin.com>
> Cc: Lee, Chun-Yi <jlee@suse.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Matthew Garrett <mjg59@srcf.ucam.org>
> Cc: Mike Galbraith <efault@gmx.de>
> Cc: Peter Jones <pjones@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Link: http://lkml.kernel.org/r/1443218539-7610-2-git-send-email-matt@codeblueprint.co.uk
> Signed-off-by: Ingo Molnar <mingo@kernel.org>

It's probably a little late to change this now, but I just realised
that I dropped Joey's Tested-by tags from this patch. Sorry Joey!

-- 
Matt Fleming, Intel Open Source Technology Center

  reply	other threads:[~2015-10-02  9:44 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 22:02 [GIT PULL 0/2] EFI urgent fixes Matt Fleming
2015-09-25 22:02 ` [PATCH 1/2] x86/efi: Map EFI memmap entries in-order at runtime Matt Fleming
2015-09-26  5:56   ` Ingo Molnar
2015-09-26  6:44     ` Ard Biesheuvel
2015-09-26 13:43     ` Matt Fleming
2015-09-27  7:03       ` Ingo Molnar
2015-09-28  6:49         ` Ard Biesheuvel
2015-09-28  8:22           ` Ingo Molnar
2015-09-28  9:51             ` Ard Biesheuvel
2015-09-29  9:12               ` Ingo Molnar
2015-09-29 10:41                 ` Ard Biesheuvel
2015-09-29 14:18                   ` Matt Fleming
2015-09-29 13:52                 ` Matt Fleming
2015-09-26 17:01     ` Andy Lutomirski
2015-09-26 17:20       ` H. Peter Anvin
2015-09-26 18:15         ` Ard Biesheuvel
2015-09-26 19:49           ` H. Peter Anvin
2015-09-26 19:57             ` Matt Fleming
2015-09-26 20:09               ` Ard Biesheuvel
2015-09-26 20:19                 ` H. Peter Anvin
2015-09-27 16:30                   ` Andy Lutomirski
2015-09-27 18:06                     ` Matthew Garrett
2015-09-28  6:16                       ` Ingo Molnar
2015-09-28  6:41                         ` Matthew Garrett
2015-09-29 21:58                           ` Laszlo Ersek
2015-09-30  9:30                             ` Ard Biesheuvel
2015-09-30 16:43                               ` Andy Lutomirski
2015-09-30 17:24                                 ` James Bottomley
2015-09-30  0:54                         ` H. Peter Anvin
2015-09-26 19:55         ` Matt Fleming
2015-09-27  6:50       ` Ingo Molnar
2015-10-01 12:48   ` [tip:core/urgent] x86/efi: Fix boot crash by mapping EFI memmap entries bottom-up at runtime, instead of top-down tip-bot for Matt Fleming
2015-10-02  9:44     ` Matt Fleming [this message]
2015-09-25 22:02 ` [PATCH 2/2] arm64/efi: Don't pad between EFI_MEMORY_RUNTIME regions Matt Fleming
2015-09-26  6:01   ` Ingo Molnar
2015-09-26  7:08     ` Ard Biesheuvel
2015-09-27  7:06       ` Ingo Molnar
2015-09-27 10:40         ` Borislav Petkov
2015-09-28  6:20           ` Ingo Molnar
2015-09-29  9:31           ` Dave Young
2015-09-29 10:24             ` Borislav Petkov
2015-09-29 14:36           ` Matt Fleming
2015-09-30  0:56             ` H. Peter Anvin
2015-09-30  8:33               ` Borislav Petkov
2015-09-30  1:03         ` H. Peter Anvin
2015-09-30  1:16           ` Andy Lutomirski
2015-09-30  1:19             ` H. Peter Anvin
2015-09-30  4:24             ` Ard Biesheuvel
2015-10-01 10:44           ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151002094405.GA2846@codeblueprint.co.uk \
    --to=matt@codeblueprint.co.uk \
    --cc=JBottomley@Odin.com \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bp@suse.de \
    --cc=dyoung@redhat.com \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=jlee@suse.com \
    --cc=leif.lindholm@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=mingo@kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=peterz@infradead.org \
    --cc=pjones@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).