• Ard Biesheuvel's avatar
    efi/capsule-loader: Reinstate virtual capsule mapping · f24c4d47
    Ard Biesheuvel authored
    Commit:
    
      82c3768b ("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:
    
      2a457fb3 ("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.
    Reported-by: default avatarGe Song <ge.song@hxt-semitech.com>
    Tested-by: default avatarBryan O'Donoghue <pure.logic@nexus-software.ie>
    Tested-by: default avatarGe Song <ge.song@hxt-semitech.com>
    Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: <stable@vger.kernel.org>
    Cc: Dave Young <dyoung@redhat.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Matt Fleming <matt@codeblueprint.co.uk>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-efi@vger.kernel.org
    Fixes: 82c3768b ("efi/capsule-loader: Use a cached copy of the capsule header")
    Link: http://lkml.kernel.org/r/20180102172110.17018-3-ard.biesheuvel@linaro.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    f24c4d47
capsule-loader.c 8.99 KB