1. 29 Feb, 2020 3 commits
  2. 26 Feb, 2020 1 commit
    • Ingo Molnar's avatar
      Merge tag 'efi-next' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into efi/core · e9765680
      Ingo Molnar authored
      Pull EFI updates for v5.7 from Ard Biesheuvel:
      
      This time, the set of changes for the EFI subsystem is much larger than
      usual. The main reasons are:
      
       - Get things cleaned up before EFI support for RISC-V arrives, which will
         increase the size of the validation matrix, and therefore the threshold to
         making drastic changes,
      
       - After years of defunct maintainership, the GRUB project has finally started
         to consider changes from the distros regarding UEFI boot, some of which are
         highly specific to the way x86 does UEFI secure boot and measured boot,
         based on knowledge of both shim internals and the layout of bootparams and
         the x86 setup header. Having this maintenance burden on other architectures
         (which don't need shim in the first place) is hard to justify, so instead,
         we are introducing a generic Linux/UEFI boot protocol.
      
      Summary of changes:
      
       - Boot time GDT handling changes (Arvind)
      
       - Simplify handling of EFI properties table on arm64
      
       - Generic EFI stub cleanups, to improve command line handling, file I/O,
         memory allocation, etc.
      
       - Introduce a generic initrd loading method based on calling back into
         the firmware, instead of relying on the x86 EFI handover protocol or
         device tree.
      
       - Introduce a mixed mode boot method that does not rely on the x86 EFI
         handover protocol either, and could potentially be adopted by other
         architectures (if another one ever surfaces where one execution mode
         is a superset of another)
      
       - Clean up the contents of struct efi, and move out everything that
         doesn't need to be stored there.
      
       - Incorporate support for UEFI spec v2.8A changes that permit firmware
         implementations to return EFI_UNSUPPORTED from UEFI runtime services at
         OS runtime, and expose a mask of which ones are supported or unsupported
         via a configuration table.
      
       - Various documentation updates and minor code cleanups (Heinrich)
      
       - Partial fix for the lack of by-VA cache maintenance in the decompressor
         on 32-bit ARM. Note that these patches were deliberately put at the
         beginning so they can be used as a stable branch that will be shared with
         a PR containing the complete fix, which I will send to the ARM tree.
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      e9765680
  3. 25 Feb, 2020 3 commits
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linux-5.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · c5f86891
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
       "This contains a handful of RISC-V related fixes that I've collected
        and would like to target for 5.6-rc4:
      
         - A fix to set up the PMPs on boot, which allows the kernel to access
           memory on systems that don't set up permissive PMPs before getting
           to Linux. This only effects machine-mode kernels, which currently
           means only NOMMU kernels.
      
         - A fix to avoid enabling supervisor-mode interrupts when running in
           machine-mode, also only for NOMMU kernels.
      
         - A pair of fixes to our KASAN support to avoid corrupting memory.
      
         - A gitignore fix.
      
        This boots on QEMU's virt board for me"
      
      * tag 'riscv-for-linux-5.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: adjust the indent
        riscv: allocate a complete page size for each page table
        riscv: Fix gitignore
        RISC-V: Don't enable all interrupts in trap_init()
        riscv: set pmp configuration if kernel is running in M-mode
      c5f86891
    • Linus Torvalds's avatar
      Merge branch 'mips-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux · d67f250e
      Linus Torvalds authored
      Pull MIPS fixes from Paul Burton:
       "Here are a few MIPS fixes, and a MAINTAINERS update to hand over MIPS
        maintenance to Thomas Bogendoerfer - this will be my final pull
        request as MIPS maintainer.
      
        Thanks for your helpful comments, useful corrections & responsiveness
        during the time I've fulfilled the role, and I'm sure I'll pop up
        elsewhere in the tree somewhere down the line"
      
      * 'mips-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
        MAINTAINERS: Hand MIPS over to Thomas
        MIPS: ingenic: DTS: Fix watchdog nodes
        MIPS: X1000: Fix clock of watchdog node.
        MIPS: vdso: Wrap -mexplicit-relocs in cc-option
        MIPS: VPE: Fix a double free and a memory leak in 'release_vpe()'
        MIPS: cavium_octeon: Fix syncw generation.
        mips: vdso: add build time check that no 'jalr t9' calls left
        MIPS: Disable VDSO time functionality on microMIPS
        mips: vdso: fix 'jalr t9' crash in vdso code
      d67f250e
    • Paul Burton's avatar
      MAINTAINERS: Hand MIPS over to Thomas · 3234f4ed
      Paul Burton authored
      My time with MIPS the company has reached its end, and so at best I'll
      have little time spend on maintaining arch/mips/.
      
      Ralf last authored a patch over 2 years ago, the last time he committed
      one is even further back & activity was sporadic for a while before
      that. The reality is that he isn't active.
      
      Having a new maintainer with time to do things properly will be
      beneficial all round. Thomas Bogendoerfer has been involved in MIPS
      development for a long time & has offered to step up as maintainer, so
      add Thomas and remove myself & Ralf from the MIPS entry.
      
      Ralf already has an entry in CREDITS to honor his contributions, so this
      just adds one for me.
      Signed-off-by: default avatarPaul Burton <paulburton@kernel.org>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Acked-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-mips@vger.kernel.org
      3234f4ed
  4. 24 Feb, 2020 8 commits
  5. 23 Feb, 2020 25 commits
    • Ard Biesheuvel's avatar
      efi: Bump the Linux EFI stub major version number to #1 · dc235d62
      Ard Biesheuvel authored
      Now that we have introduced new, generic ways for the OS loader to
      interface with Linux kernels during boot, we need to record this
      fact in a way that allows loaders to discover this information, and
      fall back to the existing methods for older kernels.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      dc235d62
    • Ard Biesheuvel's avatar
      efi/libstub: Introduce symbolic constants for the stub major/minor version · 148d3f71
      Ard Biesheuvel authored
      Now that we have added new ways to load the initrd or the mixed mode
      kernel, we will also need a way to tell the loader about this. Add
      symbolic constants for the PE/COFF major/minor version numbers (which
      fortunately have always been 0x0 for all architectures), so that we
      can bump them later to document the capabilities of the stub.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      148d3f71
    • Ard Biesheuvel's avatar
      efi/x86: Use symbolic constants in PE header instead of bare numbers · a3326a0d
      Ard Biesheuvel authored
      Replace bare numbers in the PE/COFF header structure with symbolic
      constants so they become self documenting.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      a3326a0d
    • Ard Biesheuvel's avatar
      integrity: Check properly whether EFI GetVariable() is available · 6b75d54d
      Ard Biesheuvel authored
      Testing the value of the efi.get_variable function pointer is not
      the right way to establish whether the platform supports EFI
      variables at runtime. Instead, use the newly added granular check
      that can test for the presence of each EFI runtime service
      individually.
      Acked-by: default avatarSerge Hallyn <serge@hallyn.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      6b75d54d
    • Ard Biesheuvel's avatar
      x86/ima: Use EFI GetVariable only when available · 9a440391
      Ard Biesheuvel authored
      Replace the EFI runtime services check with one that tells us whether
      EFI GetVariable() is implemented by the firmware.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      9a440391
    • Ard Biesheuvel's avatar
      efi: Use EFI ResetSystem only when available · 9b42f76a
      Ard Biesheuvel authored
      Do not attempt to call EFI ResetSystem if the runtime supported mask tells
      us it is no longer functional at OS runtime.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      9b42f76a
    • Ard Biesheuvel's avatar
      scsi: iscsi: Use EFI GetVariable only when available · 69f4cab1
      Ard Biesheuvel authored
      Replace the EFI runtime services check with one that tells us whether
      EFI GetVariable() is implemented by the firmware.
      
      Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
      Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
      Cc: linux-scsi@vger.kernel.org
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      69f4cab1
    • Ard Biesheuvel's avatar
      infiniband: hfi1: Use EFI GetVariable only when available · d79b348c
      Ard Biesheuvel authored
      Replace the EFI runtime services check with one that tells us whether
      EFI GetVariable() is implemented by the firmware.
      
      Cc: Mike Marciniszyn <mike.marciniszyn@intel.com>
      Cc: Dennis Dalessandro <dennis.dalessandro@intel.com>
      Cc: Doug Ledford <dledford@redhat.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: linux-rdma@vger.kernel.org
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      d79b348c
    • Ard Biesheuvel's avatar
      efi: Register EFI rtc platform device only when available · e5c3b1cc
      Ard Biesheuvel authored
      Drop the separate driver that registers the EFI rtc on all EFI
      systems that have runtime services available, and instead, move
      the registration into the core EFI code, and make it conditional
      on whether the actual time related services are available.
      Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      e5c3b1cc
    • Ard Biesheuvel's avatar
      efi: Use more granular check for availability for variable services · bf67fad1
      Ard Biesheuvel authored
      The UEFI spec rev 2.8 permits firmware implementations to support only
      a subset of EFI runtime services at OS runtime (i.e., after the call to
      ExitBootServices()), so let's take this into account in the drivers that
      rely specifically on the availability of the EFI variable services.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      bf67fad1
    • Ard Biesheuvel's avatar
      efi: Add support for EFI_RT_PROPERTIES table · fe4db90a
      Ard Biesheuvel authored
      Take the newly introduced EFI_RT_PROPERTIES_TABLE configuration table
      into account, which carries a mask of which EFI runtime services are
      still functional after ExitBootServices() has been called by the OS.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      fe4db90a
    • Ard Biesheuvel's avatar
      efi: Store mask of supported runtime services in struct efi · 96a3dd3d
      Ard Biesheuvel authored
      Revision 2.8 of the UEFI spec introduces provisions for firmware to
      advertise lack of support for certain runtime services at OS runtime.
      Let's store this mask in struct efi for easy access.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      96a3dd3d
    • Ard Biesheuvel's avatar
      efi/arm: Rewrite FDT param discovery routines · e457ed51
      Ard Biesheuvel authored
      The efi_get_fdt_params() routine uses the early OF device tree
      traversal helpers, that iterate over each node in the DT and invoke
      a caller provided callback that can inspect the node's contents and
      look for the required data. This requires a special param struct to
      be passed around, with pointers into param enumeration structs that
      contain (and duplicate) property names and offsets into yet another
      struct that carries the collected data.
      
      Since we know the data we look for is either under /hypervisor/uefi
      or under /chosen, it is much simpler to use the libfdt routines, and
      just try to grab a reference to either node directly, and read each
      property in sequence.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      e457ed51
    • Ard Biesheuvel's avatar
      efi/arm: Move FDT specific definitions into fdtparams.c · 3b2e4b4c
      Ard Biesheuvel authored
      Push the FDT params specific types and definition into fdtparams.c,
      and instead, pass a reference to the memory map data structure and
      populate it directly, and return the system table address as the
      return value.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      3b2e4b4c
    • Ard Biesheuvel's avatar
      efi/arm: Move FDT param discovery code out of efi.c · ac5abc70
      Ard Biesheuvel authored
      On ARM systems, we discover the UEFI system table address and memory
      map address from the /chosen node in the device tree, or in the Xen
      case, from a similar node under /hypervisor.
      
      Before making some functional changes to that code, move it into its
      own file that only gets built if CONFIG_EFI_PARAMS_FROM_FDT=y.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      ac5abc70
    • Ard Biesheuvel's avatar
      efi/x86: Add true mixed mode entry point into .compat section · 97aa2765
      Ard Biesheuvel authored
      Currently, mixed mode is closely tied to the EFI handover protocol
      and relies on intimate knowledge of the bootparams structure, setup
      header etc, all of which are rather byzantine and entirely specific
      to x86.
      
      Even though no other EFI supported architectures are currently known
      that could support something like mixed mode, it still makes sense to
      abstract a bit from this, and make it part of a generic Linux on EFI
      boot protocol.
      
      To that end, add a .compat section to the mixed mode binary, and populate
      it with the PE machine type and entry point address, allowing firmware
      implementations to match it to their native machine type, and invoke
      non-native binaries using a secondary entry point.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      97aa2765
    • Ard Biesheuvel's avatar
      efi/x86: Implement mixed mode boot without the handover protocol · 17054f49
      Ard Biesheuvel authored
      Add support for booting 64-bit x86 kernels from 32-bit firmware running
      on 64-bit capable CPUs without requiring the bootloader to implement
      the EFI handover protocol or allocate the setup block, etc etc, all of
      which can be done by the stub itself, using code that already exists.
      
      Instead, create an ordinary EFI application entrypoint but implemented
      in 32-bit code [so that it can be invoked by 32-bit firmware], and stash
      the address of this 32-bit entrypoint in the .compat section where the
      bootloader can find it.
      
      Note that we use the setup block embedded in the binary to go through
      startup_32(), but it gets reallocated and copied in efi_pe_entry(),
      using the same code that runs when the x86 kernel is booted in EFI
      mode from native firmware. This requires the loaded image protocol to
      be installed on the kernel image's EFI handle, and point to the kernel
      image itself and not to its loader. This, in turn, requires the
      bootloader to use the LoadImage() boot service to load the 64-bit
      image from 32-bit firmware, which is in fact supported by firmware
      based on EDK2. (Only StartImage() will fail, and instead, the newly
      added entrypoint needs to be invoked)
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      17054f49
    • Ard Biesheuvel's avatar
      efi/libstub/x86: Use Exit() boot service to exit the stub on errors · 3b8f44fc
      Ard Biesheuvel authored
      Currently, we either return with an error [from efi_pe_entry()] or
      enter a deadloop [in efi_main()] if any fatal errors occur during
      execution of the EFI stub. Let's switch to calling the Exit() EFI boot
      service instead in both cases, so that we
      a) can get rid of the deadloop, and simply return to the boot manager
         if any errors occur during execution of the stub, including during
         the call to ExitBootServices(),
      b) can also return cleanly from efi_pe_entry() or efi_main() in mixed
         mode, once we introduce support for LoadImage/StartImage based mixed
         mode in the next patch.
      
      Note that on systems running downstream GRUBs [which do not use LoadImage
      or StartImage to boot the kernel, and instead, pass their own image
      handle as the loaded image handle], calling Exit() will exit from GRUB
      rather than from the kernel, but this is a tolerable side effect.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      3b8f44fc
    • Ard Biesheuvel's avatar
      efi/libstub/x86: Make loaded_image protocol handling mixed mode safe · f7b85b33
      Ard Biesheuvel authored
      Add the definitions and use the special wrapper so that the loaded_image
      UEFI protocol can be safely used from mixed mode.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      f7b85b33
    • Ard Biesheuvel's avatar
      efi/x86: Drop redundant .bss section · 832187f0
      Ard Biesheuvel authored
      In commit
      
        c7fb93ec ("x86/efi: Include a .bss section within the PE/COFF headers")
      
      we added a separate .bss section to the PE/COFF header of the compressed
      kernel describing the static memory footprint of the decompressor, to
      ensure that it has enough headroom to decompress itself.
      
      We can achieve the exact same result by increasing the virtual size of
      the .text section, without changing the raw size, which, as per the
      PE/COFF specification, requires the loader to zero initialize the delta.
      
      Doing so frees up a slot in the section table, which we will use later
      to describe the mixed mode entrypoint.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      832187f0
    • Ard Biesheuvel's avatar
      efi/x86: add headroom to decompressor BSS to account for setup block · 223e3ee5
      Ard Biesheuvel authored
      In the bootparams struct, init_size defines the static footprint of the
      bzImage, counted from the start of the kernel image, i.e., startup_32().
      
      The PE/COFF metadata declares the same size for the entire image, but this
      time, the image includes the setup block as well, and so the space reserved
      by UEFI is a bit too small. This usually doesn't matter, since we normally
      relocate the kernel into a memory allocation of the correct size.
      But in the unlikely case that the image happens to be loaded at exactly
      the preferred offset, we skip this relocation, and execute the image in
      place, stepping on memory beyond the provided allocation, which may be
      in use for other purposes.
      
      Let's fix this by adding the size of the setup block to the image size as
      declared in the PE/COFF header.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      223e3ee5
    • Ard Biesheuvel's avatar
      efi/x86: Drop 'systab' member from struct efi · fd268304
      Ard Biesheuvel authored
      The systab member in struct efi has outlived its usefulness, now that
      we have better ways to access the only piece of information we are
      interested in after init, which is the EFI runtime services table
      address. So instead of instantiating a doctored copy at early boot
      with lots of mangled values, and switching the pointer when switching
      into virtual mode, let's grab the values we need directly, and get
      rid of the systab pointer entirely.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      fd268304
    • Ard Biesheuvel's avatar
      efi/arm: Drop unnecessary references to efi.systab · 8819ba39
      Ard Biesheuvel authored
      Instead of populating efi.systab very early during efi_init() with
      a mapping that is released again before the function exits, use a
      local variable here. Now that we use efi.runtime to access the runtime
      services table, this removes the only reference efi.systab, so there is
      no need to populate it anymore, or discover its virtually remapped
      address. So drop the references entirely.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      8819ba39
    • Ard Biesheuvel's avatar
      efi: Add 'runtime' pointer to struct efi · 59f2a619
      Ard Biesheuvel authored
      Instead of going through the EFI system table each time, just copy the
      runtime services table pointer into struct efi directly. This is the
      last use of the system table pointer in struct efi, allowing us to
      drop it in a future patch, along with a fair amount of quirky handling
      of the translated address.
      
      Note that usually, the runtime services pointer changes value during
      the call to SetVirtualAddressMap(), so grab the updated value as soon
      as that call returns. (Mixed mode uses a 1:1 mapping, and kexec boot
      enters with the updated address in the system table, so in those cases,
      we don't need to do anything here)
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      59f2a619
    • Ard Biesheuvel's avatar
      efi/x86: Merge assignments of efi.runtime_version · 09308012
      Ard Biesheuvel authored
      efi.runtime_version is always set to the same value on both
      existing code paths, so just set it earlier from a shared one.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      09308012