1. 30 Jun, 2022 3 commits
  2. 28 Jun, 2022 2 commits
  3. 24 Jun, 2022 8 commits
    • Ard Biesheuvel's avatar
      efi: vars: Drop __efivar_entry_iter() helper which is no longer used · 5ac94136
      Ard Biesheuvel authored
      __efivar_entry_iter() uses a list iterator in a dubious way, i.e., it
      assumes that the iteration variable always points to an object of the
      appropriate type, even if the list traversal exhausts the list
      completely, in which case it will point somewhere in the vicinity of the
      list's anchor instead.
      
      Fortunately, we no longer use this function so we can just get rid of it
      entirely.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      5ac94136
    • Ard Biesheuvel's avatar
      efi: vars: Use locking version to iterate over efivars linked lists · 3a75f9f2
      Ard Biesheuvel authored
      Both efivars and efivarfs uses __efivar_entry_iter() to go over the
      linked list that shadows the list of EFI variables held by the firmware,
      but fail to call the begin/end helpers that are documented as a
      prerequisite.
      
      So switch to the proper version, which is efivar_entry_iter(). Given
      that in both cases, efivar_entry_remove() is invoked with the lock held
      already, don't take the lock there anymore.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      3a75f9f2
    • Ard Biesheuvel's avatar
      efi: pstore: Omit efivars caching EFI varstore access layer · 85974825
      Ard Biesheuvel authored
      Avoid the efivars layer and simply call the newly introduced EFI
      varstore helpers instead. This simplifies the code substantially, and
      also allows us to remove some hacks in the shared efivars layer that
      were added for efi-pstore specifically.
      
      In order to be able to delete the EFI variable associated with a record,
      store the UTF-16 name of the variable in the pstore record's priv field.
      That way, we don't have to make guesses regarding which variable the
      record may have been loaded from.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      85974825
    • Ard Biesheuvel's avatar
      efi: vars: Add thin wrapper around EFI get/set variable interface · 472831d4
      Ard Biesheuvel authored
      The current efivars layer is a jumble of list iterators, shadow data
      structures and safe variable manipulation helpers that really belong in
      the efivarfs pseudo file system once the obsolete sysfs access method to
      EFI variables is removed.
      
      So split off a minimal efivar get/set variable API that reuses the
      existing efivars_lock semaphore to mediate access to the various runtime
      services, primarily to ensure that performing a SetVariable() on one CPU
      while another is calling GetNextVariable() in a loop to enumerate the
      contents of the EFI variable store does not result in surprises.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      472831d4
    • Ard Biesheuvel's avatar
      efi: vars: Don't drop lock in the middle of efivar_init() · ec3507b2
      Ard Biesheuvel authored
      Even though the efivars_lock lock is documented as protecting the
      efivars->ops pointer (among other things), efivar_init() happily
      releases and reacquires the lock for every EFI variable that it
      enumerates. This used to be needed because the lock was originally a
      spinlock, which prevented the callback that is invoked for every
      variable from being able to sleep. However, releasing the lock could
      potentially invalidate the ops pointer, but more importantly, it might
      allow a SetVariable() runtime service call to take place concurrently,
      and the UEFI spec does not define how this affects an enumeration that
      is running in parallel using the GetNextVariable() runtime service,
      which is what efivar_init() uses.
      
      In the meantime, the lock has been converted into a semaphore, and the
      only reason we need to drop the lock is because the efivarfs pseudo
      filesystem driver will otherwise deadlock when it invokes the efivars
      API from the callback to create the efivar_entry items and insert them
      into the linked list. (EFI pstore is affected in a similar way)
      
      So let's switch to helpers that can be used while the lock is already
      taken. This way, we can hold on to the lock throughout the enumeration.
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      ec3507b2
    • Ard Biesheuvel's avatar
      pstore: Add priv field to pstore_record for backend specific use · 8ca869b2
      Ard Biesheuvel authored
      The EFI pstore backend will need to store per-record variable name data
      when we switch away from the efivars layer. Add a priv field to struct
      pstore_record, and document it as holding a backend specific pointer
      that is assumed to be a kmalloc()d buffer, and will be kfree()d when the
      entire record is freed.
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      8ca869b2
    • Ard Biesheuvel's avatar
      Input: applespi - avoid efivars API and invoke EFI services directly · f662092b
      Ard Biesheuvel authored
      This driver abuses the efivar API, by using a few of its helpers on
      entries that were not instantiated by the API itself. This is a problem
      as future cleanup work on efivars is complicated by this.
      
      So let's just switch to the get/set variable runtime wrappers directly.
      
      Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      f662092b
    • Ard Biesheuvel's avatar
      selftests/kexec: remove broken EFI_VARS secure boot fallback check · c07d2475
      Ard Biesheuvel authored
      Commit b433a52a ("selftests/kexec: update get_secureboot_mode")
      refactored the code that discovers the EFI secure boot mode so it only
      depends on either the efivars pseudo filesystem or the efivars sysfs
      interface, but never both.
      
      However, the latter version was not implemented correctly, given the
      fact that the local 'efi_vars' variable never assumes a value. This
      means the fallback has been dead code ever since it was introduced.
      
      So let's drop the fallback altogether. The sysfs interface has been
      deprecated for ~10 years now, and is only enabled on x86 to begin with,
      so it is time to get rid of it entirely.
      Reviewed-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      c07d2475
  4. 20 Jun, 2022 5 commits
  5. 15 Jun, 2022 6 commits
  6. 06 Jun, 2022 3 commits
  7. 05 Jun, 2022 13 commits