1. 23 2月, 2022 2 次提交
  2. 16 9月, 2020 1 次提交
    • L
      efi: Support for MOK variable config table · 58c90902
      Lenny Szubowicz 提交于
      Because of system-specific EFI firmware limitations, EFI volatile
      variables may not be capable of holding the required contents of
      the Machine Owner Key (MOK) certificate store when the certificate
      list grows above some size. Therefore, an EFI boot loader may pass
      the MOK certs via a EFI configuration table created specifically for
      this purpose to avoid this firmware limitation.
      
      An EFI configuration table is a much more primitive mechanism
      compared to EFI variables and is well suited for one-way passage
      of static information from a pre-OS environment to the kernel.
      
      This patch adds initial kernel support to recognize, parse,
      and validate the EFI MOK configuration table, where named
      entries contain the same data that would otherwise be provided
      in similarly named EFI variables.
      
      Additionally, this patch creates a sysfs binary file for each
      EFI MOK configuration table entry found. These files are read-only
      to root and are provided for use by user space utilities such as
      mokutil.
      
      A subsequent patch will load MOK certs into the trusted platform
      key ring using this infrastructure.
      Signed-off-by: NLenny Szubowicz <lszubowi@redhat.com>
      Link: https://lore.kernel.org/r/20200905013107.10457-2-lszubowi@redhat.comSigned-off-by: NArd Biesheuvel <ardb@kernel.org>
      58c90902
  3. 20 8月, 2020 1 次提交
  4. 17 7月, 2020 2 次提交
  5. 24 4月, 2020 1 次提交
    • A
      efi: Clean up config table description arrays · 4e9a0f73
      Ard Biesheuvel 提交于
      Increase legibility by adding whitespace to the efi_config_table_type_t
      arrays that describe which EFI config tables we look for when going over
      the firmware provided list. While at it, replace the 'name' char pointer
      with a char array, which is more space efficient on relocatable 64-bit
      kernels, as it avoids a 8 byte pointer and the associated relocation
      data (24 bytes when using RELA format)
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      4e9a0f73
  6. 03 3月, 2020 2 次提交
    • H
      efi: Add embedded peripheral firmware support · f0df68d5
      Hans de Goede 提交于
      Just like with PCI options ROMs, which we save in the setup_efi_pci*
      functions from arch/x86/boot/compressed/eboot.c, the EFI code / ROM itself
      sometimes may contain data which is useful/necessary for peripheral drivers
      to have access to.
      
      Specifically the EFI code may contain an embedded copy of firmware which
      needs to be (re)loaded into the peripheral. Normally such firmware would be
      part of linux-firmware, but in some cases this is not feasible, for 2
      reasons:
      
      1) The firmware is customized for a specific use-case of the chipset / use
      with a specific hardware model, so we cannot have a single firmware file
      for the chipset. E.g. touchscreen controller firmwares are compiled
      specifically for the hardware model they are used with, as they are
      calibrated for a specific model digitizer.
      
      2) Despite repeated attempts we have failed to get permission to
      redistribute the firmware. This is especially a problem with customized
      firmwares, these get created by the chip vendor for a specific ODM and the
      copyright may partially belong with the ODM, so the chip vendor cannot
      give a blanket permission to distribute these.
      
      This commit adds support for finding peripheral firmware embedded in the
      EFI code and makes the found firmware available through the new
      efi_get_embedded_fw() function.
      
      Support for loading these firmwares through the standard firmware loading
      mechanism is added in a follow-up commit in this patch-series.
      
      Note we check the EFI_BOOT_SERVICES_CODE for embedded firmware near the end
      of start_kernel(), just before calling rest_init(), this is on purpose
      because the typical EFI_BOOT_SERVICES_CODE memory-segment is too large for
      early_memremap(), so the check must be done after mm_init(). This relies
      on EFI_BOOT_SERVICES_CODE not being free-ed until efi_free_boot_services()
      is called, which means that this will only work on x86 for now.
      Reported-by: NDave Olsthoorn <dave@bewaar.me>
      Suggested-by: NPeter Jones <pjones@redhat.com>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20200115163554.101315-3-hdegoede@redhat.comSigned-off-by: NArd Biesheuvel <ardb@kernel.org>
      f0df68d5
    • H
      efi: Export boot-services code and data as debugfs-blobs · 0e72a6a3
      Hans de Goede 提交于
      Sometimes it is useful to be able to dump the efi boot-services code and
      data. This commit adds these as debugfs-blobs to /sys/kernel/debug/efi,
      but only if efi=debug is passed on the kernel-commandline as this requires
      not freeing those memory-regions, which costs 20+ MB of RAM.
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20200115163554.101315-2-hdegoede@redhat.comSigned-off-by: NArd Biesheuvel <ardb@kernel.org>
      0e72a6a3
  7. 29 2月, 2020 2 次提交
  8. 24 2月, 2020 14 次提交
    • A
      efi/x86: Drop 'systab' member from struct efi · fd268304
      Ard Biesheuvel 提交于
      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: NArd Biesheuvel <ardb@kernel.org>
      fd268304
    • A
      efi: Add 'runtime' pointer to struct efi · 59f2a619
      Ard Biesheuvel 提交于
      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: NArd Biesheuvel <ardb@kernel.org>
      59f2a619
    • A
      efi/x86: Merge assignments of efi.runtime_version · 09308012
      Ard Biesheuvel 提交于
      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: NArd Biesheuvel <ardb@kernel.org>
      09308012
    • A
      efi/x86: Make fw_vendor, config_table and runtime sysfs nodes x86 specific · 9cd437ac
      Ard Biesheuvel 提交于
      There is some code that exposes physical addresses of certain parts of
      the EFI firmware implementation via sysfs nodes. These nodes are only
      used on x86, and are of dubious value to begin with, so let's move
      their handling into the x86 arch code.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      9cd437ac
    • A
      efi/x86: Remove runtime table address from kexec EFI setup data · 0a67361d
      Ard Biesheuvel 提交于
      Since commit 33b85447 ("efi/x86: Drop two near identical versions
      of efi_runtime_init()"), we no longer map the EFI runtime services table
      before calling SetVirtualAddressMap(), which means we don't need the 1:1
      mapped physical address of this table, and so there is no point in passing
      the address via EFI setup data on kexec boot.
      
      Note that the kexec tools will still look for this address in sysfs, so
      we still need to provide it.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      0a67361d
    • A
      efi: Clean up config_parse_tables() · 06c0bd93
      Ard Biesheuvel 提交于
      config_parse_tables() is a jumble of pointer arithmetic, due to the
      fact that on x86, we may be dealing with firmware whose native word
      size differs from the kernel's.
      
      This is not a concern on other architectures, and doesn't quite
      justify the state of the code, so let's clean it up by adding a
      non-x86 code path, constifying statically allocated tables and
      replacing preprocessor conditionals with IS_ENABLED() checks.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      06c0bd93
    • A
      efi: Make efi_config_init() x86 only · 3a0701dc
      Ard Biesheuvel 提交于
      The efi_config_init() routine is no longer shared with ia64 so let's
      move it into the x86 arch code before making further x86 specific
      changes to it.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      3a0701dc
    • A
      efi: Merge EFI system table revision and vendor checks · 14fb4209
      Ard Biesheuvel 提交于
      We have three different versions of the code that checks the EFI system
      table revision and copies the firmware vendor string, and they are
      mostly equivalent, with the exception of the use of early_memremap_ro
      vs. __va() and the lowest major revision to warn about. Let's move this
      into common code and factor out the commonalities.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      14fb4209
    • A
      efi: Move mem_attr_table out of struct efi · a17e809e
      Ard Biesheuvel 提交于
      The memory attributes table is only used at init time by the core EFI
      code, so there is no need to carry its address in struct efi that is
      shared with the world. So move it out, and make it __ro_after_init as
      well, considering that the value is set during early boot.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      a17e809e
    • A
      efi: Move UGA and PROP table handling to x86 code · fd506e0c
      Ard Biesheuvel 提交于
      The UGA table is x86 specific (its handling was introduced when the
      EFI support code was modified to accommodate IA32), so there is no
      need to handle it in generic code.
      
      The EFI properties table is not strictly x86 specific, but it was
      deprecated almost immediately after having been introduced, due to
      implementation difficulties. Only x86 takes it into account today,
      and this is not going to change, so make this table x86 only as well.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      fd506e0c
    • A
      efi/ia64: Move HCDP and MPS table handling into IA64 arch code · 120540f2
      Ard Biesheuvel 提交于
      The HCDP and MPS tables are Itanium specific EFI config tables, so
      move their handling to ia64 arch code.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      120540f2
    • A
      efi: Drop handling of 'boot_info' configuration table · 50d53c58
      Ard Biesheuvel 提交于
      Some plumbing exists to handle a UEFI configuration table of type
      BOOT_INFO but since we never match it to a GUID anywhere, we never
      actually register such a table, or access it, for that matter. So
      simply drop all mentions of it.
      
      Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      50d53c58
    • A
      efi/x86: Replace #ifdefs with IS_ENABLED() checks · a570b062
      Ard Biesheuvel 提交于
      When possible, IS_ENABLED() conditionals are preferred over #ifdefs,
      given that the latter hide the code from the compiler entirely, which
      reduces build test coverage when the option is not enabled.
      
      So replace an instance in the x86 efi startup code.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      a570b062
    • A
      efi/x86: Reindent struct initializer for legibility · 14b60cc8
      Ard Biesheuvel 提交于
      Reindent the efi_memory_map_data initializer so that all the = signs
      are aligned vertically, making the resulting code much easier to read.
      Suggested-by: NIngo Molnar <mingo@kernel.org>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      14b60cc8
  9. 02 2月, 2020 1 次提交
  10. 20 1月, 2020 2 次提交
    • D
      efi: Add tracking for dynamically allocated memmaps · 1db91035
      Dan Williams 提交于
      In preparation for fixing efi_memmap_alloc() leaks, add support for
      recording whether the memmap was dynamically allocated from slab,
      memblock, or is the original physical memmap provided by the platform.
      
      Given this tracking is established in efi_memmap_alloc() and needs to be
      carried to efi_memmap_install(), use 'struct efi_memory_map_data' to
      convey the flags.
      
      Some small cleanups result from this reorganization, specifically the
      removal of local variables for 'phys' and 'size' that are already
      tracked in @data.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200113172245.27925-12-ardb@kernel.org
      1db91035
    • A
      efi/x86: Limit EFI old memory map to SGI UV machines · 1f299fad
      Ard Biesheuvel 提交于
      We carry a quirk in the x86 EFI code to switch back to an older
      method of mapping the EFI runtime services memory regions, because
      it was deemed risky at the time to implement a new method without
      providing a fallback to the old method in case problems arose.
      
      Such problems did arise, but they appear to be limited to SGI UV1
      machines, and so these are the only ones for which the fallback gets
      enabled automatically (via a DMI quirk). The fallback can be enabled
      manually as well, by passing efi=old_map, but there is very little
      evidence that suggests that this is something that is being relied
      upon in the field.
      
      Given that UV1 support is not enabled by default by the distros
      (Ubuntu, Fedora), there is no point in carrying this fallback code
      all the time if there are no other users. So let's move it into the
      UV support code, and document that efi=old_map now requires this
      support code to be enabled.
      
      Note that efi=old_map has been used in the past on other SGI UV
      machines to work around kernel regressions in production, so we
      keep the option to enable it by hand, but only if the kernel was
      built with UV support.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      Link: https://lore.kernel.org/r/20200113172245.27925-8-ardb@kernel.org
      1f299fad
  11. 11 1月, 2020 7 次提交
    • A
      efi/x86: Remove unreachable code in kexec_enter_virtual_mode() · 4684abe3
      Ard Biesheuvel 提交于
      Remove some code that is guaranteed to be unreachable, given
      that we have already bailed by this time if EFI_OLD_MEMMAP is
      set.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-15-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      4684abe3
    • A
      efi/x86: Don't panic or BUG() on non-critical error conditions · e2d68a95
      Ard Biesheuvel 提交于
      The logic in __efi_enter_virtual_mode() does a number of steps in
      sequence, all of which may fail in one way or the other. In most
      cases, we simply print an error and disable EFI runtime services
      support, but in some cases, we BUG() or panic() and bring down the
      system when encountering conditions that we could easily handle in
      the same way.
      
      While at it, replace a pointless page-to-virt-phys conversion with
      one that goes straight from struct page to physical.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-14-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      e2d68a95
    • A
      efi/x86: Clean up efi_systab_init() routine for legibility · 5b279a26
      Ard Biesheuvel 提交于
      Clean up the efi_systab_init() routine which maps the EFI system
      table and copies the relevant pieces of data out of it.
      
      The current routine is very difficult to read, so let's clean that
      up. Also, switch to a R/O mapping of the system table since that is
      all we need.
      
      Finally, use a plain u64 variable to record the physical address of
      the system table instead of pointlessly stashing it in a struct efi
      that is never used for anything else.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-13-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      5b279a26
    • A
      efi/x86: Drop two near identical versions of efi_runtime_init() · 33b85447
      Ard Biesheuvel 提交于
      The routines efi_runtime_init32() and efi_runtime_init64() are
      almost indistinguishable, and the only relevant difference is
      the offset in the runtime struct from where to obtain the physical
      address of the SetVirtualAddressMap() routine.
      
      However, this address is only used once, when installing the virtual
      address map that the OS will use to invoke EFI runtime services, and
      at the time of the call, we will necessarily be running with a 1:1
      mapping, and so there is no need to do the map/unmap dance here to
      retrieve the address. In fact, in the preceding changes to these users,
      we stopped using the address recorded here entirely.
      
      So let's just get rid of all this code since it no longer serves a
      purpose. While at it, tweak the logic so that we handle unsupported
      and disable EFI runtime services in the same way, and unmap the EFI
      memory map in both cases.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-12-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      33b85447
    • A
      efi/x86: Simplify mixed mode call wrapper · ea5e1919
      Ard Biesheuvel 提交于
      Calling 32-bit EFI runtime services from a 64-bit OS involves
      switching back to the flat mapping with a stack carved out of
      memory that is 32-bit addressable.
      
      There is no need to actually execute the 64-bit part of this
      routine from the flat mapping as well, as long as the entry
      and return address fit in 32 bits. There is also no need to
      preserve part of the calling context in global variables: we
      can simply push the old stack pointer value to the new stack,
      and keep the return address from the code32 section in EBX.
      
      While at it, move the conditional check whether to invoke
      the mixed mode version of SetVirtualAddressMap() into the
      64-bit implementation of the wrapper routine.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-11-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ea5e1919
    • A
      efi/x86: Split SetVirtualAddresMap() wrappers into 32 and 64 bit versions · 69829470
      Ard Biesheuvel 提交于
      Split the phys_efi_set_virtual_address_map() routine into 32 and 64 bit
      versions, so we can simplify them individually in subsequent patches.
      
      There is very little overlap between the logic anyway, and this has
      already been factored out in prolog/epilog routines which are completely
      different between 32 bit and 64 bit. So let's take it one step further,
      and get rid of the overlap completely.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Link: https://lkml.kernel.org/r/20200103113953.9571-8-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      69829470
    • A
      efi/x86: Map the entire EFI vendor string before copying it · ffc2760b
      Ard Biesheuvel 提交于
      Fix a couple of issues with the way we map and copy the vendor string:
      - we map only 2 bytes, which usually works since you get at least a
        page, but if the vendor string happens to cross a page boundary,
        a crash will result
      - only call early_memunmap() if early_memremap() succeeded, or we will
        call it with a NULL address which it doesn't like,
      - while at it, switch to early_memremap_ro(), and array indexing rather
        than pointer dereferencing to read the CHAR16 characters.
      Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Arvind Sankar <nivedita@alum.mit.edu>
      Cc: Matthew Garrett <mjg59@google.com>
      Cc: linux-efi@vger.kernel.org
      Fixes: 5b83683f ("x86: EFI runtime service support")
      Link: https://lkml.kernel.org/r/20200103113953.9571-5-ardb@kernel.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      ffc2760b
  12. 25 12月, 2019 2 次提交
  13. 07 11月, 2019 3 次提交
    • D
      x86/efi: Add efi_fake_mem support for EFI_MEMORY_SP · 199c8471
      Dan Williams 提交于
      Given that EFI_MEMORY_SP is platform BIOS policy decision for marking
      memory ranges as "reserved for a specific purpose" there will inevitably
      be scenarios where the BIOS omits the attribute in situations where it
      is desired. Unlike other attributes if the OS wants to reserve this
      memory from the kernel the reservation needs to happen early in init. So
      early, in fact, that it needs to happen before e820__memblock_setup()
      which is a pre-requisite for efi_fake_memmap() that wants to allocate
      memory for the updated table.
      
      Introduce an x86 specific efi_fake_memmap_early() that can search for
      attempts to set EFI_MEMORY_SP via efi_fake_mem and update the e820 table
      accordingly.
      
      The KASLR code that scans the command line looking for user-directed
      memory reservations also needs to be updated to consider
      "efi_fake_mem=nn@ss:0x40000" requests.
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      199c8471
    • D
      x86/efi: EFI soft reservation to E820 enumeration · 262b45ae
      Dan Williams 提交于
      UEFI 2.8 defines an EFI_MEMORY_SP attribute bit to augment the
      interpretation of the EFI Memory Types as "reserved for a specific
      purpose".
      
      The proposed Linux behavior for specific purpose memory is that it is
      reserved for direct-access (device-dax) by default and not available for
      any kernel usage, not even as an OOM fallback.  Later, through udev
      scripts or another init mechanism, these device-dax claimed ranges can
      be reconfigured and hot-added to the available System-RAM with a unique
      node identifier. This device-dax management scheme implements "soft" in
      the "soft reserved" designation by allowing some or all of the
      reservation to be recovered as typical memory. This policy can be
      disabled at compile-time with CONFIG_EFI_SOFT_RESERVE=n, or runtime with
      efi=nosoftreserve.
      
      This patch introduces 2 new concepts at once given the entanglement
      between early boot enumeration relative to memory that can optionally be
      reserved from the kernel page allocator by default. The new concepts
      are:
      
      - E820_TYPE_SOFT_RESERVED: Upon detecting the EFI_MEMORY_SP
        attribute on EFI_CONVENTIONAL memory, update the E820 map with this
        new type. Only perform this classification if the
        CONFIG_EFI_SOFT_RESERVE=y policy is enabled, otherwise treat it as
        typical ram.
      
      - IORES_DESC_SOFT_RESERVED: Add a new I/O resource descriptor for
        a device driver to search iomem resources for application specific
        memory. Teach the iomem code to identify such ranges as "Soft Reserved".
      
      Note that the comment for do_add_efi_memmap() needed refreshing since it
      seemed to imply that the efi map might overflow the e820 table, but that
      is not an issue as of commit 7b6e4ba3 "x86/boot/e820: Clean up the
      E820_X_MAX definition" that removed the 128 entry limit for
      e820__range_add().
      
      A follow-on change integrates parsing of the ACPI HMAT to identify the
      node and sub-range boundaries of EFI_MEMORY_SP designated memory. For
      now, just identify and reserve memory of this type.
      Acked-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      262b45ae
    • D
      x86/efi: Push EFI_MEMMAP check into leaf routines · 6950e31b
      Dan Williams 提交于
      In preparation for adding another EFI_MEMMAP dependent call that needs
      to occur before e820__memblock_setup() fixup the existing efi calls to
      check for EFI_MEMMAP internally. This ends up being cleaner than the
      alternative of checking EFI_MEMMAP multiple times in setup_arch().
      Reviewed-by: NDave Hansen <dave.hansen@linux.intel.com>
      Reviewed-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      6950e31b