1. 11 11月, 2022 1 次提交
    • A
      arm64: efi: Force the use of SetVirtualAddressMap() on Altra machines · 550b33cf
      Ard Biesheuvel 提交于
      Ampere Altra machines are reported to misbehave when the SetTime() EFI
      runtime service is called after ExitBootServices() but before calling
      SetVirtualAddressMap(). Given that the latter is horrid, pointless and
      explicitly documented as optional by the EFI spec, we no longer invoke
      it at boot if the configured size of the VA space guarantees that the
      EFI runtime memory regions can remain mapped 1:1 like they are at boot
      time.
      
      On Ampere Altra machines, this results in SetTime() calls issued by the
      rtc-efi driver triggering synchronous exceptions during boot.  We can
      now recover from those without bringing down the system entirely, due to
      commit 23715a26 ("arm64: efi: Recover from synchronous
      exceptions occurring in firmware"). However, it would be better to avoid
      the issue entirely, given that the firmware appears to remain in a funny
      state after this.
      
      So attempt to identify these machines based on the 'family' field in the
      type #1 SMBIOS record, and call SetVirtualAddressMap() unconditionally
      in that case.
      Tested-by: NAlexandru Elisei <alexandru.elisei@gmail.com>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      550b33cf
  2. 01 11月, 2022 6 次提交
  3. 29 10月, 2022 1 次提交
    • A
      efi: efivars: Fix variable writes with unsupported query_variable_store() · f11a74b4
      Ard Biesheuvel 提交于
      Commit 8a254d90 ("efi: efivars: Fix variable writes without
      query_variable_store()") addressed an issue that was introduced during
      the EFI variable store refactor, where alternative implementations of
      the efivars layer that lacked query_variable_store() would no longer
      work.
      
      Unfortunately, there is another case to consider here, which was missed:
      if the efivars layer is backed by the EFI runtime services as usual, but
      the EFI implementation predates the introduction of QueryVariableInfo(),
      we will return EFI_UNSUPPORTED, and this is no longer being dealt with
      correctly.
      
      So let's fix this, and while at it, clean up the code a bit, by merging
      the check_var_size() routines as well as their callers.
      
      Cc: <stable@vger.kernel.org> # v6.0
      Fixes: bbc6d2c6 ("efi: vars: Switch to new wrapper layer")
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Tested-by: NAditya Garg <gargaditya08@live.com>
      f11a74b4
  4. 24 10月, 2022 3 次提交
    • A
      efi: random: Use 'ACPI reclaim' memory for random seed · 7d866e38
      Ard Biesheuvel 提交于
      EFI runtime services data is guaranteed to be preserved by the OS,
      making it a suitable candidate for the EFI random seed table, which may
      be passed to kexec kernels as well (after refreshing the seed), and so
      we need to ensure that the memory is preserved without support from the
      OS itself.
      
      However, runtime services data is intended for allocations that are
      relevant to the implementations of the runtime services themselves, and
      so they are unmapped from the kernel linear map, and mapped into the EFI
      page tables that are active while runtime service invocations are in
      progress. None of this is needed for the RNG seed.
      
      So let's switch to EFI 'ACPI reclaim' memory: in spite of the name,
      there is nothing exclusively ACPI about it, it is simply a type of
      allocation that carries firmware provided data which may or may not be
      relevant to the OS, and it is left up to the OS to decide whether to
      reclaim it after having consumed its contents.
      
      Given that in Linux, we never reclaim these allocations, it is a good
      choice for the EFI RNG seed, as the allocation is guaranteed to survive
      kexec reboots.
      
      One additional reason for changing this now is to align it with the
      upcoming recommendation for EFI bootloader provided RNG seeds, which
      must not use EFI runtime services code/data allocations.
      
      Cc: <stable@vger.kernel.org> # v4.14+
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      7d866e38
    • A
      efi: random: reduce seed size to 32 bytes · 161a438d
      Ard Biesheuvel 提交于
      We no longer need at least 64 bytes of random seed to permit the early
      crng init to complete. The RNG is now based on Blake2s, so reduce the
      EFI seed size to the Blake2s hash size, which is sufficient for our
      purposes.
      
      While at it, drop the READ_ONCE(), which was supposed to prevent size
      from being evaluated after seed was unmapped. However, this cannot
      actually happen, so READ_ONCE() is unnecessary here.
      
      Cc: <stable@vger.kernel.org> # v4.14+
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Reviewed-by: NJason A. Donenfeld <Jason@zx2c4.com>
      Acked-by: NIlias Apalodimas <ilias.apalodimas@linaro.org>
      161a438d
    • J
      efi/tpm: Pass correct address to memblock_reserve · f4cd18c5
      Jerry Snitselaar 提交于
      memblock_reserve() expects a physical address, but the address being
      passed for the TPM final events log is what was returned from
      early_memremap(). This results in something like the following:
      
      [    0.000000] memblock_reserve: [0xffffffffff2c0000-0xffffffffff2c00e4] efi_tpm_eventlog_init+0x324/0x370
      
      Pass the address from efi like what is done for the TPM events log.
      
      Fixes: c46f3405 ("tpm: Reserve the TPM final events table")
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: Jarkko Sakkinen <jarkko@kernel.org>
      Cc: Bartosz Szczepanek <bsz@semihalf.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Signed-off-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Acked-by: NJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      f4cd18c5
  5. 21 10月, 2022 6 次提交
    • A
      efi: runtime: Don't assume virtual mappings are missing if VA == PA == 0 · 37926f96
      Ard Biesheuvel 提交于
      The generic EFI stub can be instructed to avoid SetVirtualAddressMap(),
      and simply run with the firmware's 1:1 mapping. In this case, it
      populates the virtual address fields of the runtime regions in the
      memory map with the physical address of each region, so that the mapping
      code has to be none the wiser. Only if SetVirtualAddressMap() fails, the
      virtual addresses are wiped and the kernel code knows that the regions
      cannot be mapped.
      
      However, wiping amounts to setting it to zero, and if a runtime region
      happens to live at physical address 0, its valid 1:1 mapped virtual
      address could be mistaken for a wiped field, resulting on loss of access
      to the EFI services at runtime.
      
      So let's only assume that VA == 0 means 'no runtime services' if the
      region in question does not live at PA 0x0.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      37926f96
    • A
      efi: libstub: Fix incorrect payload size in zboot header · 53a7ea28
      Ard Biesheuvel 提交于
      The linker script symbol definition that captures the size of the
      compressed payload inside the zboot decompressor (which is exposed via
      the image header) refers to '.' for the end of the region, which does
      not give the correct result as the expression is not placed at the end
      of the payload. So use the symbol name explicitly.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      53a7ea28
    • A
      efi: libstub: Give efi_main() asmlinkage qualification · db14655a
      Ard Biesheuvel 提交于
      To stop the bots from sending sparse warnings to me and the list about
      efi_main() not having a prototype, decorate it with asmlinkage so that
      it is clear that it is called from assembly, and therefore needs to
      remain external, even if it is never declared in a header file.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      db14655a
    • A
      efi: efivars: Fix variable writes without query_variable_store() · 8a254d90
      Ard Biesheuvel 提交于
      Commit bbc6d2c6 ("efi: vars: Switch to new wrapper layer")
      refactored the efivars layer so that the 'business logic' related to
      which UEFI variables affect the boot flow in which way could be moved
      out of it, and into the efivarfs driver.
      
      This inadvertently broke setting variables on firmware implementations
      that lack the QueryVariableInfo() boot service, because we no longer
      tolerate a EFI_UNSUPPORTED result from check_var_size() when calling
      efivar_entry_set_get_size(), which now ends up calling check_var_size()
      a second time inadvertently.
      
      If QueryVariableInfo() is missing, we support writes of up to 64k -
      let's move that logic into check_var_size(), and drop the redundant
      call.
      
      Cc: <stable@vger.kernel.org> # v6.0
      Fixes: bbc6d2c6 ("efi: vars: Switch to new wrapper layer")
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      8a254d90
    • A
      efi: ssdt: Don't free memory if ACPI table was loaded successfully · 4b017e59
      Ard Biesheuvel 提交于
      Amadeusz reports KASAN use-after-free errors introduced by commit
      3881ee0b ("efi: avoid efivars layer when loading SSDTs from
      variables"). The problem appears to be that the memory that holds the
      new ACPI table is now freed unconditionally, instead of only when the
      ACPI core reported a failure to load the table.
      
      So let's fix this, by omitting the kfree() on success.
      
      Cc: <stable@vger.kernel.org> # v6.0
      Link: https://lore.kernel.org/all/a101a10a-4fbb-5fae-2e3c-76cf96ed8fbd@linux.intel.com/
      Fixes: 3881ee0b ("efi: avoid efivars layer when loading SSDTs from variables")
      Reported-by: NAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4b017e59
    • A
      efi: libstub: Remove zboot signing from build options · f57fb375
      Ard Biesheuvel 提交于
      The zboot decompressor series introduced a feature to sign the PE/COFF
      kernel image for secure boot as part of the kernel build. This was
      necessary because there are actually two images that need to be signed:
      the kernel with the EFI stub attached, and the decompressor application.
      
      This is a bit of a burden, because it means that the images must be
      signed on the the same system that performs the build, and this is not
      realistic for distros.
      
      During the next cycle, we will introduce changes to the zboot code so
      that the inner image no longer needs to be signed. This means that the
      outer PE/COFF image can be handled as usual, and be signed later in the
      release process.
      
      Let's remove the associated Kconfig options now so that they don't end
      up in a LTS release while already being deprecated.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      f57fb375
  6. 04 10月, 2022 2 次提交
    • G
      firmware: google: test spinlock on panic path to avoid lockups · 1179083f
      Guilherme G. Piccoli 提交于
      Currently the gsmi driver registers a panic notifier as well as reboot and
      die notifiers.  The callbacks registered are called in atomic and very
      limited context - for instance, panic disables preemption and local IRQs,
      also all secondary CPUs (not executing the panic path) are shutdown.
      
      With that said, taking a spinlock in this scenario is a dangerous
      invitation for lockup scenarios.  So, fix that by checking if the spinlock
      is free to acquire in the panic notifier callback - if not, bail-out and
      avoid a potential hang.
      
      Link: https://lkml.kernel.org/r/20220909200755.189679-1-gpiccoli@igalia.com
      Fixes: 74c5b31c ("driver: Google EFI SMI")
      Signed-off-by: NGuilherme G. Piccoli <gpiccoli@igalia.com>
      Reviewed-by: NEvan Green <evgreen@chromium.org>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: David Gow <davidgow@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Julius Werner <jwerner@chromium.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      1179083f
    • A
      kmsan: disable instrumentation of unsupported common kernel code · 79dbd006
      Alexander Potapenko 提交于
      EFI stub cannot be linked with KMSAN runtime, so we disable
      instrumentation for it.
      
      Instrumenting kcov, stackdepot or lockdep leads to infinite recursion
      caused by instrumentation hooks calling instrumented code again.
      
      Link: https://lkml.kernel.org/r/20220915150417.722975-13-glider@google.comSigned-off-by: NAlexander Potapenko <glider@google.com>
      Reviewed-by: NMarco Elver <elver@google.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Eric Biggers <ebiggers@kernel.org>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      79dbd006
  7. 29 9月, 2022 2 次提交
  8. 27 9月, 2022 18 次提交
  9. 24 9月, 2022 1 次提交