1. 05 6月, 2019 1 次提交
  2. 25 5月, 2019 1 次提交
  3. 16 2月, 2019 1 次提交
  4. 30 11月, 2018 2 次提交
    • A
      efi: Reduce the amount of memblock reservations for persistent allocations · 80424b02
      Ard Biesheuvel 提交于
      The current implementation of efi_mem_reserve_persistent() is rather
      naive, in the sense that for each invocation, it creates a separate
      linked list entry to describe the reservation. Since the linked list
      entries themselves need to persist across subsequent kexec reboots,
      every reservation created this way results in two memblock_reserve()
      calls at the next boot.
      
      On arm64 systems with 100s of CPUs, this may result in a excessive
      number of memblock reservations, and needless fragmentation.
      
      So instead, make use of the newly updated struct linux_efi_memreserve
      layout to put multiple reservations into a single linked list entry.
      This should get rid of the numerous tiny memblock reservations, and
      effectively cut the total number of reservations in half on arm64
      systems with many CPUs.
      
       [ mingo: build warning fix. ]
      Tested-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
      Cc: Bhupesh Sharma <bhsharma@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Eric Snowberg <eric.snowberg@oracle.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Jon Hunter <jonathanh@nvidia.com>
      Cc: Julien Thierry <julien.thierry@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Nathan Chancellor <natechancellor@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Cc: Sedat Dilek <sedat.dilek@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: YiFei Zhu <zhuyifei1999@gmail.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20181129171230.18699-11-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      80424b02
    • A
      efi: Permit multiple entries in persistent memreserve data structure · 5f0b0ecf
      Ard Biesheuvel 提交于
      In preparation of updating efi_mem_reserve_persistent() to cause less
      fragmentation when dealing with many persistent reservations, update
      the struct definition and the code that handles it currently so it
      can describe an arbitrary number of reservations using a single linked
      list entry. The actual optimization will be implemented in a subsequent
      patch.
      Tested-by: NMarc Zyngier <marc.zyngier@arm.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
      Cc: Bhupesh Sharma <bhsharma@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Eric Snowberg <eric.snowberg@oracle.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Jon Hunter <jonathanh@nvidia.com>
      Cc: Julien Thierry <julien.thierry@arm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Cc: Nathan Chancellor <natechancellor@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      Cc: Sedat Dilek <sedat.dilek@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: YiFei Zhu <zhuyifei1999@gmail.com>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20181129171230.18699-10-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      5f0b0ecf
  5. 27 11月, 2018 1 次提交
  6. 15 11月, 2018 2 次提交
  7. 26 9月, 2018 2 次提交
  8. 17 7月, 2018 1 次提交
  9. 16 7月, 2018 2 次提交
    • A
      efi: Drop type and attribute checks in efi_mem_desc_lookup() · 7e1550b8
      Ard Biesheuvel 提交于
      The current implementation of efi_mem_desc_lookup() includes the
      following check on the memory descriptor it returns:
      
          if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
              md->type != EFI_BOOT_SERVICES_DATA &&
              md->type != EFI_RUNTIME_SERVICES_DATA) {
                  continue;
          }
      
      This means that only EfiBootServicesData or EfiRuntimeServicesData
      regions are considered, or any other region type provided that it
      has the EFI_MEMORY_RUNTIME attribute set.
      
      Given what the name of the function implies, and the fact that any
      physical address can be described in the UEFI memory map only a single
      time, it does not make sense to impose this condition in the body of the
      loop, but instead, should be imposed by the caller depending on the value
      that is returned to it.
      
      Two such callers exist at the moment:
      
      - The BGRT code when running on x86, via efi_mem_reserve() and
        efi_arch_mem_reserve(). In this case, the region is already known to
        be EfiBootServicesData, and so the check is redundant.
      
      - The ESRT handling code which introduced this function, which calls it
        both directly from efi_esrt_init() and again via efi_mem_reserve() and
        efi_arch_mem_reserve() [on x86].
      
      So let's move this check into the callers instead. This preserves the
      current behavior both for BGRT and ESRT handling, and allows the lookup
      routine to be reused by other [upcoming] users that don't have this
      limitation.
      
      In the ESRT case, keep the entire condition, so that platforms that
      deviate from the UEFI spec and use something other than
      EfiBootServicesData for the ESRT table will keep working as before.
      
      For x86's efi_arch_mem_reserve() implementation, limit the type to
      EfiBootServicesData, since it is the only type the reservation code
      expects to operate on in the first place.
      
      While we're at it, drop the __init annotation so that drivers can use it
      as well.
      Tested-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180711094040.12506-8-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      7e1550b8
    • S
      efi: Use a work queue to invoke EFI Runtime Services · 3eb420e7
      Sai Praneeth 提交于
      Presently, when a user process requests the kernel to execute any
      UEFI runtime service, the kernel temporarily switches to a separate
      set of page tables that describe the virtual mapping of the UEFI
      runtime services regions in memory. Since UEFI runtime services are
      typically invoked with interrupts enabled, any code that may be called
      during this time, will have an incorrect view of the process's address
      space. Although it is unusual for code running in interrupt context to
      make assumptions about the process context it runs in, there are cases
      (such as the perf subsystem taking samples) where this causes problems.
      
      So let's set up a work queue for calling UEFI runtime services, so that
      the actual calls are made when the work queue items are dispatched by a
      work queue worker running in a separate kernel thread. Such threads are
      not expected to have userland mappings in the first place, and so the
      additional mappings created for the UEFI runtime services can never
      clash with any.
      
      The ResetSystem() runtime service is not covered by the work queue
      handling, since it is not expected to return, and may be called at a
      time when the kernel is torn down to the point where we cannot expect
      work queues to still be operational.
      
      The non-blocking variants of SetVariable() and QueryVariableInfo()
      are also excluded: these are intended to be used from atomic context,
      which obviously rules out waiting for a completion to be signalled by
      another thread. Note that these variants are currently only used for
      UEFI runtime services calls that occur very early in the boot, and
      for ones that occur in critical conditions, e.g., to flush kernel logs
      to UEFI variables via efi-pstore.
      Suggested-by: NAndy Lutomirski <luto@kernel.org>
      Signed-off-by: NSai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
      [ardb: exclude ResetSystem() from the workqueue treatment
             merge from 2 separate patches and rewrite commit log]
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-efi@vger.kernel.org
      Link: http://lkml.kernel.org/r/20180711094040.12506-4-ard.biesheuvel@linaro.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      3eb420e7
  10. 12 3月, 2018 1 次提交
  11. 09 3月, 2018 1 次提交
  12. 08 1月, 2018 1 次提交
  13. 03 1月, 2018 1 次提交
  14. 07 12月, 2017 2 次提交
  15. 26 8月, 2017 2 次提交
  16. 21 8月, 2017 1 次提交
  17. 18 7月, 2017 1 次提交
  18. 23 6月, 2017 1 次提交
  19. 18 3月, 2017 1 次提交
    • D
      efi/esrt: Cleanup bad memory map log messages · 822f5845
      Daniel Drake 提交于
      The Intel Compute Stick STCK1A8LFC and Weibu F3C platforms both
      log 2 error messages during boot:
      
         efi: requested map not found.
         esrt: ESRT header is not in the memory map.
      
      Searching the web, this seems to affect many other platforms too.
      Since these messages are logged as errors, they appear on-screen during
      the boot process even when using the "quiet" boot parameter used by
      distros.
      
      Demote the ESRT error to a warning so that it does not appear on-screen,
      and delete the error logging from efi_mem_desc_lookup; both callsites
      of that function log more specific messages upon failure.
      
      Out of curiosity I looked closer at the Weibu F3C. There is no entry in
      the UEFI-provided memory map which corresponds to the ESRT pointer, but
      hacking the code to map it anyway, the ESRT does appear to be valid with
      2 entries.
      Signed-off-by: NDaniel Drake <drake@endlessm.com>
      Cc: Matt Fleming <matt@codeblueprint.co.uk>
      Acked-by: NPeter Jones <pjones@redhat.com>
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      822f5845
  20. 01 2月, 2017 1 次提交
  21. 13 11月, 2016 1 次提交
  22. 18 10月, 2016 1 次提交
  23. 09 9月, 2016 5 次提交
    • A
      efi: Replace runtime services spinlock with semaphore · dce48e35
      Ard Biesheuvel 提交于
      The purpose of the efi_runtime_lock is to prevent concurrent calls into
      the firmware. There is no need to use spinlocks here, as long as we ensure
      that runtime service invocations from an atomic context (i.e., EFI pstore)
      cannot block.
      
      So use a semaphore instead, and use down_trylock() in the nonblocking case.
      We don't use a mutex here because the mutex_trylock() function must not
      be called from interrupt context, whereas the down_trylock() can.
      Signed-off-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Sylvain Chouleur <sylvain.chouleur@gmail.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      dce48e35
    • M
      efi: Allow drivers to reserve boot services forever · 816e7612
      Matt Fleming 提交于
      Today, it is not possible for drivers to reserve EFI boot services for
      access after efi_free_boot_services() has been called on x86. For
      ARM/arm64 it can be done simply by calling memblock_reserve().
      
      Having this ability for all three architectures is desirable for a
      couple of reasons,
      
        1) It saves drivers copying data out of those regions
        2) kexec reboot can now make use of things like ESRT
      
      Instead of using the standard memblock_reserve() which is insufficient
      to reserve the region on x86 (see efi_reserve_boot_services()), a new
      API is introduced in this patch; efi_mem_reserve().
      
      efi.memmap now always represents which EFI memory regions are
      available. On x86 the EFI boot services regions that have not been
      reserved via efi_mem_reserve() will be removed from efi.memmap during
      efi_free_boot_services().
      
      This has implications for kexec, since it is not possible for a newly
      kexec'd kernel to access the same boot services regions that the
      initial boot kernel had access to unless they are reserved by every
      kexec kernel in the chain.
      
      Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
      Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      816e7612
    • M
      efi: Split out EFI memory map functions into new file · 60863c0d
      Matt Fleming 提交于
      Also move the functions from the EFI fake mem driver since future
      patches will require access to the memmap insertion code even if
      CONFIG_EFI_FAKE_MEM isn't enabled.
      
      This will be useful when we need to build custom EFI memory maps to
      allow drivers to mark regions as reserved.
      
      Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
      Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Taku Izumi <izumi.taku@jp.fujitsu.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      60863c0d
    • M
      efi: Add efi_memmap_init_late() for permanent EFI memmap · dca0f971
      Matt Fleming 提交于
      Drivers need a way to access the EFI memory map at runtime. ARM and
      arm64 currently provide this by remapping the EFI memory map into the
      vmalloc space before setting up the EFI virtual mappings.
      
      x86 does not provide this functionality which has resulted in the code
      in efi_mem_desc_lookup() where it will manually map individual EFI
      memmap entries if the memmap has already been torn down on x86,
      
        /*
         * If a driver calls this after efi_free_boot_services,
         * ->map will be NULL, and the target may also not be mapped.
         * So just always get our own virtual map on the CPU.
         *
         */
        md = early_memremap(p, sizeof (*md));
      
      There isn't a good reason for not providing a permanent EFI memory map
      for runtime queries, especially since the EFI regions are not mapped
      into the standard kernel page tables.
      
      Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
      Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      dca0f971
    • M
      efi: Refactor efi_memmap_init_early() into arch-neutral code · 9479c7ce
      Matt Fleming 提交于
      Every EFI architecture apart from ia64 needs to setup the EFI memory
      map at efi.memmap, and the code for doing that is essentially the same
      across all implementations. Therefore, it makes sense to factor this
      out into the common code under drivers/firmware/efi/.
      
      The only slight variation is the data structure out of which we pull
      the initial memory map information, such as physical address, memory
      descriptor size and version, etc. We can address this by passing a
      generic data structure (struct efi_memory_map_data) as the argument to
      efi_memmap_init_early() which contains the minimum info required for
      initialising the memory map.
      
      In the process, this patch also fixes a few undesirable implementation
      differences:
      
       - ARM and arm64 were failing to clear the EFI_MEMMAP bit when
         unmapping the early EFI memory map. EFI_MEMMAP indicates whether
         the EFI memory map is mapped (not the regions contained within) and
         can be traversed.  It's more correct to set the bit as soon as we
         memremap() the passed in EFI memmap.
      
       - Rename efi_unmmap_memmap() to efi_memmap_unmap() to adhere to the
         regular naming scheme.
      
      This patch also uses a read-write mapping for the memory map instead
      of the read-only mapping currently used on ARM and arm64. x86 needs
      the ability to update the memory map in-place when assigning virtual
      addresses to regions (efi_map_region()) and tagging regions when
      reserving boot services (efi_reserve_boot_services()).
      
      There's no way for the generic fake_mem code to know which mapping to
      use without introducing some arch-specific constant/hook, so just use
      read-write since read-only is of dubious value for the EFI memory map.
      
      Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
      Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      9479c7ce
  24. 05 9月, 2016 1 次提交
    • A
      efi: Fix handling error value in fdt_find_uefi_params · 4af9ed57
      Andrzej Hajda 提交于
      of_get_flat_dt_subnode_by_name can return negative value in case of error.
      Assigning the result to unsigned variable and checking if the variable
      is lesser than zero is incorrect and always false.
      The patch fixes it by using signed variable to check the result.
      
      The problem has been detected using semantic patch
      scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
      Signed-off-by: NAndrzej Hajda <a.hajda@samsung.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Marek Szyprowski <m.szyprowski@samsung.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Shawn Lin <shawn.lin@rock-chips.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      4af9ed57
  25. 09 7月, 2016 1 次提交
  26. 06 7月, 2016 1 次提交
    • S
      Xen: EFI: Parse DT parameters for Xen specific UEFI · 0cac5c30
      Shannon Zhao 提交于
      The EFI DT parameters for bare metal are located under /chosen node,
      while for Xen Dom0 they are located under /hyperviosr/uefi node. These
      parameters under /chosen and /hyperviosr/uefi are not expected to appear
      at the same time.
      
      Parse these EFI parameters and initialize EFI like the way for bare
      metal except the runtime services because the runtime services for Xen
      Dom0 are available through hypercalls and they are always enabled. So it
      sets the EFI_RUNTIME_SERVICES flag if it finds /hyperviosr/uefi node and
      bails out in arm_enable_runtime_services() when EFI_RUNTIME_SERVICES
      flag is set already.
      Signed-off-by: NShannon Zhao <shannon.zhao@linaro.org>
      Cc: Stefano Stabellini <sstabellini@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Signed-off-by: NMatt Fleming <matt@codeblueprint.co.uk>
      0cac5c30
  27. 28 4月, 2016 4 次提交