Patch "efi/capsule-loader: Reinstate virtual capsule mapping" has been added to the 4.14-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
efi/capsule-loader: Reinstate virtual capsule mapping
to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
efi-capsule-loader-reinstate-virtual-capsule-mapping.patch
and it can be found in the queue-4.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
f24c4d478013d82bd1b943df566fff3561d52864Mon Sep 17 00:00:00 2001
From: Ard Biesheuvel <[email protected]>
Date: Tue, 2 Jan 2018 17:21:10 +0000
Subject: efi/capsule-loader: Reinstate virtual capsule mapping
From: Ard Biesheuvel <[email protected]>
commit f24c4d478013d82bd1b943df566fff3561d52864 upstream.
Commit:
82c3768b8d68 ("efi/capsule-loader: Use a cached copy of the capsule header")
... refactored the capsule loading code that maps the capsule header, to avoid having to map it several times.
However, as it turns out, the vmap() call we ended up removing did not just map the header, but the entire capsule image, and dropping this virtual mapping breaks capsules that are processed by the firmware immediately (i.e., without a reboot).
Unfortunately, that change was part of a larger refactor that allowed a quirk to be implemented for Quark, which has a non-standard memory layout for capsules, and we have slightly painted ourselves into a corner by allowing quirk code to mangle the capsule header and memory layout.
So we need to fix this without breaking Quark. Fortunately, Quark does not appear to care about the virtual mapping, and so we can simply do a partial revert of commit:
2a457fb31df6 ("efi/capsule-loader: Use page addresses rather than struct page pointers")
... and create a vmap() mapping of the entire capsule (including header) based on the reinstated struct page array, unless running on Quark, in which case we pass the capsule header copy as before.
--- arch/x86/platform/efi/quirks.c | 13 +++++++++ drivers/firmware/efi/capsule-loader.c | 45 +++++++++++++++++++++++++++------- include/linux/efi.h | 4 ++- 3 files changed, 52 insertions(+), 10 deletions(-)
arch/x86/platform/efi/quirks.c +12 -1
@@ -592,7 +592,18 @@ static int qrk_capsule_setup_info(struct/* * Update the first page pointer to skip over the CSH header. */ - cap_info->pages[0 ] += csh->headersize; + cap_info->phys[0 ] += csh->headersize; + +/* +* cap_info->capsule should point at a virtual mapping of the entire +* capsule, starting at the capsule header. Our image has the Quark +* security header prepended, so we cannot rely on the default vmap() +* mapping created by the generic capsule code. +* Given that the Quark firmware does not appear to care about the +* virtual mapping, let's just point cap_info->capsule at our copy +* of the capsule header. +*/ + cap_info->capsule = &cap_info->header;return 1 ; }
drivers/firmware/efi/capsule-loader.c +37 -8
91 lines not on this page · raw message
include/linux/efi.h +3 -1
@@ -140,11 +140,13 @@ struct efi_boot_memmap {struct capsule_info {efi_capsule_header_t header; +efi_capsule_header_t *capsule;int reset_type;long index;size_t count;size_t total_size; -phys_addr_t *pages; +struct page **pages; +phys_addr_t *phys;size_t page_bytes_remain; };
Patches currently in stable-queue which might be from [email protected] are
queue-4.14/efi-capsule-loader-reinstate-virtual-capsule-mapping.patch