]> Git Repo - J-linux.git/commitdiff
Merge tag 'efi-next-for-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
authorLinus Torvalds <[email protected]>
Sun, 9 Oct 2022 15:56:54 +0000 (08:56 -0700)
committerLinus Torvalds <[email protected]>
Sun, 9 Oct 2022 15:56:54 +0000 (08:56 -0700)
Pull EFI updates from Ard Biesheuvel:
 "A bit more going on than usual in the EFI subsystem. The main driver
  for this has been the introduction of the LoonArch architecture last
  cycle, which inspired some cleanup and refactoring of the EFI code.
  Another driver for EFI changes this cycle and in the future is
  confidential compute.

  The LoongArch architecture does not use either struct bootparams or DT
  natively [yet], and so passing information between the EFI stub and
  the core kernel using either of those is undesirable. And in general,
  overloading DT has been a source of issues on arm64, so using DT for
  this on new architectures is a to avoid for the time being (even if we
  might converge on something DT based for non-x86 architectures in the
  future). For this reason, in addition to the patch that enables EFI
  boot for LoongArch, there are a number of refactoring patches applied
  on top of which separate the DT bits from the generic EFI stub bits.
  These changes are on a separate topich branch that has been shared
  with the LoongArch maintainers, who will include it in their pull
  request as well. This is not ideal, but the best way to manage the
  conflicts without stalling LoongArch for another cycle.

  Another development inspired by LoongArch is the newly added support
  for EFI based decompressors. Instead of adding yet another
  arch-specific incarnation of this pattern for LoongArch, we are
  introducing an EFI app based on the existing EFI libstub
  infrastructure that encapulates the decompression code we use on other
  architectures, but in a way that is fully generic. This has been
  developed and tested in collaboration with distro and systemd folks,
  who are eager to start using this for systemd-boot and also for arm64
  secure boot on Fedora. Note that the EFI zimage files this introduces
  can also be decompressed by non-EFI bootloaders if needed, as the
  image header describes the location of the payload inside the image,
  and the type of compression that was used. (Note that Fedora's arm64
  GRUB is buggy [0] so you'll need a recent version or switch to
  systemd-boot in order to use this.)

  Finally, we are adding TPM measurement of the kernel command line
  provided by EFI. There is an oversight in the TCG spec which results
  in a blind spot for command line arguments passed to loaded images,
  which means that either the loader or the stub needs to take the
  measurement. Given the combinatorial explosion I am anticipating when
  it comes to firmware/bootloader stacks and firmware based attestation
  protocols (SEV-SNP, TDX, DICE, DRTM), it is good to set a baseline now
  when it comes to EFI measured boot, which is that the kernel measures
  the initrd and command line. Intermediate loaders can measure
  additional assets if needed, but with the baseline in place, we can
  deploy measured boot in a meaningful way even if you boot into Linux
  straight from the EFI firmware.

  Summary:

   - implement EFI boot support for LoongArch

   - implement generic EFI compressed boot support for arm64, RISC-V and
     LoongArch, none of which implement a decompressor today

   - measure the kernel command line into the TPM if measured boot is in
     effect

   - refactor the EFI stub code in order to isolate DT dependencies for
     architectures other than x86

   - avoid calling SetVirtualAddressMap() on arm64 if the configured
     size of the VA space guarantees that doing so is unnecessary

   - move some ARM specific code out of the generic EFI source files

   - unmap kernel code from the x86 mixed mode 1:1 page tables"

* tag 'efi-next-for-v6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: (24 commits)
  efi/arm64: libstub: avoid SetVirtualAddressMap() when possible
  efi: zboot: create MemoryMapped() device path for the parent if needed
  efi: libstub: fix up the last remaining open coded boot service call
  efi/arm: libstub: move ARM specific code out of generic routines
  efi/libstub: measure EFI LoadOptions
  efi/libstub: refactor the initrd measuring functions
  efi/loongarch: libstub: remove dependency on flattened DT
  efi: libstub: install boot-time memory map as config table
  efi: libstub: remove DT dependency from generic stub
  efi: libstub: unify initrd loading between architectures
  efi: libstub: remove pointless goto kludge
  efi: libstub: simplify efi_get_memory_map() and struct efi_boot_memmap
  efi: libstub: avoid efi_get_memory_map() for allocating the virt map
  efi: libstub: drop pointless get_memory_map() call
  efi: libstub: fix type confusion for load_options_size
  arm64: efi: enable generic EFI compressed boot
  loongarch: efi: enable generic EFI compressed boot
  riscv: efi: enable generic EFI compressed boot
  efi/libstub: implement generic EFI zboot
  efi/libstub: move efi_system_table global var into separate object
  ...

1  2 
arch/arm64/kernel/image-vars.h
arch/loongarch/Kconfig
arch/loongarch/kernel/head.S
arch/loongarch/kernel/setup.c
arch/loongarch/kernel/vmlinux.lds.S
drivers/firmware/efi/libstub/Makefile
drivers/firmware/efi/libstub/arm64-stub.c
drivers/firmware/efi/libstub/x86-stub.c

index 4aaa5f3d1f65f6bf42d28d6a46ac9489f8216957,11643f4d864d796e05f9e3f72122c711d16fc2e2..8151412653de209cc9006881d2e496b132cbd72e
@@@ -24,9 -24,6 +24,6 @@@ PROVIDE(__efistub_primary_entry_offset        
   */
  PROVIDE(__efistub_memcmp              = __pi_memcmp);
  PROVIDE(__efistub_memchr              = __pi_memchr);
- PROVIDE(__efistub_memcpy              = __pi_memcpy);
- PROVIDE(__efistub_memmove             = __pi_memmove);
- PROVIDE(__efistub_memset              = __pi_memset);
  PROVIDE(__efistub_strlen              = __pi_strlen);
  PROVIDE(__efistub_strnlen             = __pi_strnlen);
  PROVIDE(__efistub_strcmp              = __pi_strcmp);
@@@ -40,16 -37,6 +37,6 @@@ PROVIDE(__efistub__edata             = _edata)
  PROVIDE(__efistub_screen_info         = screen_info);
  PROVIDE(__efistub__ctype              = _ctype);
  
- /*
-  * The __ prefixed memcpy/memset/memmove symbols are provided by KASAN, which
-  * instruments the conventional ones. Therefore, any references from the EFI
-  * stub or other position independent, low level C code should be redirected to
-  * the non-instrumented versions as well.
-  */
- PROVIDE(__efistub___memcpy            = __pi_memcpy);
- PROVIDE(__efistub___memmove           = __pi_memmove);
- PROVIDE(__efistub___memset            = __pi_memset);
  PROVIDE(__pi___memcpy                 = __pi_memcpy);
  PROVIDE(__pi___memmove                        = __pi_memmove);
  PROVIDE(__pi___memset                 = __pi_memset);
@@@ -73,7 -60,6 +60,7 @@@ KVM_NVHE_ALIAS(spectre_bhb_patch_loop_i
  KVM_NVHE_ALIAS(spectre_bhb_patch_loop_mitigation_enable);
  KVM_NVHE_ALIAS(spectre_bhb_patch_wa3);
  KVM_NVHE_ALIAS(spectre_bhb_patch_clearbhb);
 +KVM_NVHE_ALIAS(alt_cb_patch_nops);
  
  /* Global kernel state accessed by nVHE hyp code. */
  KVM_NVHE_ALIAS(kvm_vgic_global_state);
@@@ -90,6 -76,10 +77,6 @@@ KVM_NVHE_ALIAS(__icache_flags)
  /* VMID bits set by the KVM VMID allocator */
  KVM_NVHE_ALIAS(kvm_arm_vmid_bits);
  
 -/* Kernel symbols needed for cpus_have_final/const_caps checks. */
 -KVM_NVHE_ALIAS(arm64_const_caps_ready);
 -KVM_NVHE_ALIAS(cpu_hwcap_keys);
 -
  /* Static keys which are set if a vGIC trap should be handled in hyp. */
  KVM_NVHE_ALIAS(vgic_v2_cpuif_trap);
  KVM_NVHE_ALIAS(vgic_v3_cpuif_trap);
diff --combined arch/loongarch/Kconfig
index 551dd99e98b82ae8b0970bc325056f4d059eee08,14a2a1ec8561217d062762ac336c64641170771f..cfd976065a0da4c3f4a33c4f783ae38897598eb1
@@@ -10,6 -10,7 +10,6 @@@ config LOONGARC
        select ARCH_ENABLE_MEMORY_HOTPLUG
        select ARCH_ENABLE_MEMORY_HOTREMOVE
        select ARCH_HAS_ACPI_TABLE_UPGRADE      if ACPI
 -      select ARCH_HAS_PHYS_TO_DMA
        select ARCH_HAS_PTE_SPECIAL
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
        select ARCH_INLINE_READ_LOCK if !PREEMPTION
@@@ -38,7 -39,6 +38,7 @@@
        select ARCH_INLINE_SPIN_UNLOCK_BH if !PREEMPTION
        select ARCH_INLINE_SPIN_UNLOCK_IRQ if !PREEMPTION
        select ARCH_INLINE_SPIN_UNLOCK_IRQRESTORE if !PREEMPTION
 +      select ARCH_KEEP_MEMBLOCK
        select ARCH_MIGHT_HAVE_PC_PARPORT
        select ARCH_MIGHT_HAVE_PC_SERIO
        select ARCH_SPARSEMEM_ENABLE
@@@ -51,7 -51,6 +51,7 @@@
        select ARCH_USE_CMPXCHG_LOCKREF
        select ARCH_USE_QUEUED_RWLOCKS
        select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
 +      select ARCH_WANT_LD_ORPHAN_WARN
        select ARCH_WANTS_NO_INSTR
        select BUILDTIME_TABLE_SORT
        select COMMON_CLK
        select MODULES_USE_ELF_RELA if MODULES
        select NEED_PER_CPU_EMBED_FIRST_CHUNK
        select NEED_PER_CPU_PAGE_FIRST_CHUNK
-       select OF
-       select OF_EARLY_FLATTREE
        select PCI
        select PCI_DOMAINS_GENERIC
        select PCI_ECAM if ACPI
        select PCI_LOONGSON
        select PCI_MSI_ARCH_FALLBACKS
 +      select PCI_QUIRKS
        select PERF_USE_VMALLOC
        select RTC_LIB
        select SMP
@@@ -313,12 -309,20 +311,20 @@@ config DM
  config EFI
        bool "EFI runtime service support"
        select UCS2_STRING
-       select EFI_PARAMS_FROM_FDT
        select EFI_RUNTIME_WRAPPERS
        help
          This enables the kernel to use EFI runtime services that are
          available (such as the EFI variable services).
  
+ config EFI_STUB
+       bool "EFI boot stub support"
+       default y
+       depends on EFI
+       select EFI_GENERIC_STUB
+       help
+         This kernel feature allows the kernel to be loaded directly by
+         EFI firmware without the use of a bootloader.
  config SMP
        bool "Multi-Processing support"
        help
index 331864369e49ece9d5ff79e26aa0d3d75f5b0a9c,8f89f39fd31b0eb21ddfb86c1ad8591edffcc99d..7e57ae8741b1a07b16c56ac4a6a5ae8949fb6f1e
  #include <asm/loongarch.h>
  #include <asm/stackframe.h>
  
+ #ifdef CONFIG_EFI_STUB
+ #include "efi-header.S"
+       __HEAD
+ _head:
+       .word   MZ_MAGIC                /* "MZ", MS-DOS header */
+       .org    0x3c                    /* 0x04 ~ 0x3b reserved */
+       .long   pe_header - _head       /* Offset to the PE header */
+ pe_header:
+       __EFI_PE_HEADER
+ SYM_DATA(kernel_asize, .long _end - _text);
+ SYM_DATA(kernel_fsize, .long _edata - _text);
+ SYM_DATA(kernel_offset, .long kernel_offset - _text);
+ #endif
        __REF
  
 +      .align 12
 +
  SYM_CODE_START(kernel_entry)                  # kernel entry point
  
        /* Config direct window and set PG */
@@@ -49,6 -67,8 +69,8 @@@
        st.d            a0, t0, 0               # firmware arguments
        la              t0, fw_arg1
        st.d            a1, t0, 0
+       la              t0, fw_arg2
+       st.d            a2, t0, 0
  
        /* KSave3 used for percpu base, initialized as 0 */
        csrwr           zero, PERCPU_BASE_KS
index d97c69dbe553d228f6be515c244516676898a95c,7fabf2306e801ae80d9876af7aa89fa3f2939dfa..6ca5a0dcbb1c459e5a3b82d141dea2b4e77c1c13
  #define SMBIOS_CORE_PACKAGE_OFFSET    0x23
  #define LOONGSON_EFI_ENABLE           (1 << 3)
  
- #ifdef CONFIG_VT
- struct screen_info screen_info;
- #endif
+ struct screen_info screen_info __section(".data");
  
- unsigned long fw_arg0, fw_arg1;
+ unsigned long fw_arg0, fw_arg1, fw_arg2;
  DEFINE_PER_CPU(unsigned long, kernelsp);
  struct cpuinfo_loongarch cpu_data[NR_CPUS] __read_mostly;
  
@@@ -122,16 -120,9 +120,9 @@@ static void __init parse_cpu_table(cons
  
  static void __init parse_bios_table(const struct dmi_header *dm)
  {
-       int bios_extern;
        char *dmi_data = (char *)dm;
  
-       bios_extern = *(dmi_data + SMBIOS_BIOSEXTERN_OFFSET);
        b_info.bios_size = (*(dmi_data + SMBIOS_BIOSSIZE_OFFSET) + 1) << 6;
-       if (bios_extern & LOONGSON_EFI_ENABLE)
-               set_bit(EFI_BOOT, &efi.flags);
-       else
-               clear_bit(EFI_BOOT, &efi.flags);
  }
  
  static void __init find_tokens(const struct dmi_header *dm, void *dummy)
@@@ -196,7 -187,6 +187,6 @@@ early_param("mem", early_parse_mem)
  
  void __init platform_init(void)
  {
-       efi_init();
  #ifdef CONFIG_ACPI_TABLE_UPGRADE
        acpi_table_upgrade();
  #endif
@@@ -247,7 -237,7 +237,7 @@@ static void __init arch_mem_init(char *
        sparse_init();
        memblock_set_bottom_up(true);
  
 -      plat_swiotlb_setup();
 +      swiotlb_init(true, SWIOTLB_VERBOSE);
  
        dma_contiguous_reserve(PFN_PHYS(max_low_pfn));
  
@@@ -356,6 -346,7 +346,7 @@@ void __init setup_arch(char **cmdline_p
        *cmdline_p = boot_command_line;
  
        init_environ();
+       efi_init();
        memblock_init();
        parse_early_param();
  
index f4831df5d2f9a5d4001ee0ab1e8ef545bb036b87,36d042739f3c54dfdf1ea5461a3b3bafd59bb3ff..e5890bec2bf6b509bdb0c015e0ed35bde243f05c
@@@ -12,6 -12,7 +12,7 @@@
  #define BSS_FIRST_SECTIONS *(.bss..swapper_pg_dir)
  
  #include <asm-generic/vmlinux.lds.h>
+ #include "image-vars.h"
  
  /*
   * Max avaliable Page Size is 64K, so we set SectionAlignment
@@@ -77,8 -78,6 +78,8 @@@ SECTION
        PERCPU_SECTION(1 << CONFIG_L1_CACHE_SHIFT)
  #endif
  
 +      .rela.dyn : ALIGN(8) { *(.rela.dyn) *(.rela*) }
 +
        .init.bss : {
                *(.init.bss)
        }
index b43fdb319fd4fb9708e710b63e2b54570d69e3d8,a7cadf7b1471402f19548a2a58303f5e802a6ca0..01a01be4a2a0b449c5f2fb011e42b74556f8b754
@@@ -26,8 -26,10 +26,10 @@@ cflags-$(CONFIG_ARM)                := $(subst $(CC_F
                                   $(call cc-option,-mno-single-pic-base)
  cflags-$(CONFIG_RISCV)                := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
                                   -fpic
+ cflags-$(CONFIG_LOONGARCH)    := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
+                                  -fpie
  
- cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
+ cflags-$(CONFIG_EFI_PARAMS_FROM_FDT)  += -I$(srctree)/scripts/dtc/libfdt
  
  KBUILD_CFLAGS                 := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
                                   -include $(srctree)/include/linux/hidden.h \
                                   $(call cc-option,-fno-addrsig) \
                                   -D__DISABLE_EXPORTS
  
 +#
 +# struct randomization only makes sense for Linux internal types, which the EFI
 +# stub code never touches, so let's turn off struct randomization for the stub
 +# altogether
 +#
 +KBUILD_CFLAGS := $(filter-out $(RANDSTRUCT_CFLAGS), $(KBUILD_CFLAGS))
 +
  # remove SCS flags from all objects in this directory
  KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_SCS), $(KBUILD_CFLAGS))
 +# disable CFI
 +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_CFI), $(KBUILD_CFLAGS))
  # disable LTO
  KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
  
@@@ -66,21 -59,32 +68,32 @@@ lib-y                              := efi-stub-helper.o gop.o sec
                                   skip_spaces.o lib-cmdline.o lib-ctype.o \
                                   alignedmem.o relocate.o vsprintf.o
  
- # include the stub's generic dependencies from lib/ when building for ARM/arm64
- efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c
+ # include the stub's libfdt dependencies from lib/ when needed
+ libfdt-deps                   := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c \
+                                  fdt_empty_tree.c fdt_sw.c
+ lib-$(CONFIG_EFI_PARAMS_FROM_FDT) += fdt.o \
+                                    $(patsubst %.c,lib-%.o,$(libfdt-deps))
  
  $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
        $(call if_changed_rule,cc_o_c)
  
- lib-$(CONFIG_EFI_GENERIC_STUB)        += efi-stub.o fdt.o string.o \
-                                  $(patsubst %.c,lib-%.o,$(efi-deps-y))
+ lib-$(CONFIG_EFI_GENERIC_STUB)        += efi-stub.o string.o intrinsics.o systable.o
  
  lib-$(CONFIG_ARM)             += arm32-stub.o
  lib-$(CONFIG_ARM64)           += arm64-stub.o
  lib-$(CONFIG_X86)             += x86-stub.o
  lib-$(CONFIG_RISCV)           += riscv-stub.o
+ lib-$(CONFIG_LOONGARCH)               += loongarch-stub.o
  CFLAGS_arm32-stub.o           := -DTEXT_OFFSET=$(TEXT_OFFSET)
  
+ zboot-obj-$(CONFIG_RISCV)     := lib-clz_ctz.o lib-ashldi3.o
+ lib-$(CONFIG_EFI_ZBOOT)               += zboot.o $(zboot-obj-y)
+ extra-y                               := $(lib-y)
+ lib-y                         := $(patsubst %.o,%.stub.o,$(lib-y))
  # Even when -mbranch-protection=none is set, Clang will generate a
  # .note.gnu.property for code-less object files (like lib/ctype.c),
  # so work around this by explicitly removing the unwanted section.
@@@ -120,9 -124,6 +133,6 @@@ STUBCOPY_RELOC-$(CONFIG_ARM)       := R_ARM_A
  # a verification pass to see if any absolute relocations exist in any of the
  # object files.
  #
- extra-y                               := $(lib-y)
- lib-y                         := $(patsubst %.o,%.stub.o,$(lib-y))
  STUBCOPY_FLAGS-$(CONFIG_ARM64)        += --prefix-alloc-sections=.init \
                                   --prefix-symbols=__efistub_
  STUBCOPY_RELOC-$(CONFIG_ARM64)        := R_AARCH64_ABS
@@@ -134,6 -135,12 +144,12 @@@ STUBCOPY_FLAGS-$(CONFIG_RISCV)   += --pre
                                   --prefix-symbols=__efistub_
  STUBCOPY_RELOC-$(CONFIG_RISCV)        := R_RISCV_HI20
  
+ # For LoongArch, keep all the symbols in .init section and make sure that no
+ # absolute symbols references exist.
+ STUBCOPY_FLAGS-$(CONFIG_LOONGARCH)    += --prefix-alloc-sections=.init \
+                                          --prefix-symbols=__efistub_
+ STUBCOPY_RELOC-$(CONFIG_LOONGARCH)    := R_LARCH_MARK_LA
  $(obj)/%.stub.o: $(obj)/%.o FORCE
        $(call if_changed,stubcopy)
  
index 60973e84d7abe92f18b3d5d29cab30372f49646b,df05c53baa234451e3213069063f04c5fa7c620e..259e4b852d63276d7732f462c54984ad155ab84a
@@@ -19,12 -19,20 +19,20 @@@ efi_status_t check_platform_features(vo
  {
        u64 tg;
  
+       /*
+        * If we have 48 bits of VA space for TTBR0 mappings, we can map the
+        * UEFI runtime regions 1:1 and so calling SetVirtualAddressMap() is
+        * unnecessary.
+        */
+       if (VA_BITS_MIN >= 48)
+               efi_novamap = true;
        /* UEFI mandates support for 4 KB granularity, no need to check */
        if (IS_ENABLED(CONFIG_ARM64_4K_PAGES))
                return EFI_SUCCESS;
  
 -      tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_TGRAN_SHIFT) & 0xf;
 -      if (tg < ID_AA64MMFR0_TGRAN_SUPPORTED_MIN || tg > ID_AA64MMFR0_TGRAN_SUPPORTED_MAX) {
 +      tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_EL1_TGRAN_SHIFT) & 0xf;
 +      if (tg < ID_AA64MMFR0_EL1_TGRAN_SUPPORTED_MIN || tg > ID_AA64MMFR0_EL1_TGRAN_SUPPORTED_MAX) {
                if (IS_ENABLED(CONFIG_ARM64_64K_PAGES))
                        efi_err("This 64 KB granular kernel is not supported by your CPU\n");
                else
   */
  static bool check_image_region(u64 base, u64 size)
  {
-       unsigned long map_size, desc_size, buff_size;
-       efi_memory_desc_t *memory_map;
-       struct efi_boot_memmap map;
+       struct efi_boot_memmap *map;
        efi_status_t status;
        bool ret = false;
        int map_offset;
  
-       map.map =       &memory_map;
-       map.map_size =  &map_size;
-       map.desc_size = &desc_size;
-       map.desc_ver =  NULL;
-       map.key_ptr =   NULL;
-       map.buff_size = &buff_size;
-       status = efi_get_memory_map(&map);
+       status = efi_get_memory_map(&map, false);
        if (status != EFI_SUCCESS)
                return false;
  
-       for (map_offset = 0; map_offset < map_size; map_offset += desc_size) {
-               efi_memory_desc_t *md = (void *)memory_map + map_offset;
+       for (map_offset = 0; map_offset < map->map_size; map_offset += map->desc_size) {
+               efi_memory_desc_t *md = (void *)map->map + map_offset;
                u64 end = md->phys_addr + md->num_pages * EFI_PAGE_SIZE;
  
                /*
@@@ -74,7 -73,7 +73,7 @@@
                }
        }
  
-       efi_bs_call(free_pool, memory_map);
+       efi_bs_call(free_pool, map);
  
        return ret;
  }
index 7a7abc8959d2b0e3e44dcb06f15fa12432b93c18,8cb7ff5ecffca9a8e4817292fbe677b4b0064378..b9ce6393e35313c9d714c126b370010bc304610e
@@@ -220,6 -220,7 +220,6 @@@ adjust_memory_range_protection(unsigne
        unsigned long end, next;
        unsigned long rounded_start, rounded_end;
        unsigned long unprotect_start, unprotect_size;
 -      int has_system_memory = 0;
  
        if (efi_dxe_table == NULL)
                return;
@@@ -516,13 -517,6 +516,13 @@@ efi_status_t __efiapi efi_pe_entry(efi_
        hdr->ramdisk_image = 0;
        hdr->ramdisk_size = 0;
  
 +      /*
 +       * Disregard any setup data that was provided by the bootloader:
 +       * setup_data could be pointing anywhere, and we have no way of
 +       * authenticating or validating the payload.
 +       */
 +      hdr->setup_data = 0;
 +
        efi_stub_entry(handle, sys_table_arg, boot_params);
        /* not reached */
  
@@@ -722,32 -716,22 +722,22 @@@ static efi_status_t exit_boot_func(stru
  
        efi_set_u64_split((unsigned long)efi_system_table,
                          &p->efi->efi_systab, &p->efi->efi_systab_hi);
-       p->efi->efi_memdesc_size        = *map->desc_size;
-       p->efi->efi_memdesc_version     = *map->desc_ver;
-       efi_set_u64_split((unsigned long)*map->map,
+       p->efi->efi_memdesc_size        = map->desc_size;
+       p->efi->efi_memdesc_version     = map->desc_ver;
+       efi_set_u64_split((unsigned long)map->map,
                          &p->efi->efi_memmap, &p->efi->efi_memmap_hi);
-       p->efi->efi_memmap_size         = *map->map_size;
+       p->efi->efi_memmap_size         = map->map_size;
  
        return EFI_SUCCESS;
  }
  
  static efi_status_t exit_boot(struct boot_params *boot_params, void *handle)
  {
-       unsigned long map_sz, key, desc_size, buff_size;
-       efi_memory_desc_t *mem_map;
        struct setup_data *e820ext = NULL;
        __u32 e820ext_size = 0;
        efi_status_t status;
-       __u32 desc_version;
-       struct efi_boot_memmap map;
        struct exit_boot_struct priv;
  
-       map.map                 = &mem_map;
-       map.map_size            = &map_sz;
-       map.desc_size           = &desc_size;
-       map.desc_ver            = &desc_version;
-       map.key_ptr             = &key;
-       map.buff_size           = &buff_size;
        priv.boot_params        = boot_params;
        priv.efi                = &boot_params->efi_info;
  
                return status;
  
        /* Might as well exit boot services now */
-       status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func);
+       status = efi_exit_boot_services(handle, &priv, exit_boot_func);
        if (status != EFI_SUCCESS)
                return status;
  
@@@ -782,7 -766,7 +772,7 @@@ unsigned long efi_main(efi_handle_t han
        unsigned long bzimage_addr = (unsigned long)startup_32;
        unsigned long buffer_start, buffer_end;
        struct setup_header *hdr = &boot_params->hdr;
-       unsigned long addr, size;
+       const struct linux_efi_initrd *initrd = NULL;
        efi_status_t status;
  
        efi_system_table = sys_table_arg;
         * arguments will be processed only if image is not NULL, which will be
         * the case only if we were loaded via the PE entry point.
         */
-       status = efi_load_initrd(image, &addr, &size, hdr->initrd_addr_max,
-                                ULONG_MAX);
+       status = efi_load_initrd(image, hdr->initrd_addr_max, ULONG_MAX,
+                                &initrd);
        if (status != EFI_SUCCESS)
                goto fail;
-       if (size > 0) {
-               efi_set_u64_split(addr, &hdr->ramdisk_image,
+       if (initrd && initrd->size > 0) {
+               efi_set_u64_split(initrd->base, &hdr->ramdisk_image,
                                  &boot_params->ext_ramdisk_image);
-               efi_set_u64_split(size, &hdr->ramdisk_size,
+               efi_set_u64_split(initrd->size, &hdr->ramdisk_size,
                                  &boot_params->ext_ramdisk_size);
        }
  
        /*
         * If the boot loader gave us a value for secure_boot then we use that,
         * otherwise we ask the BIOS.
This page took 0.105928 seconds and 4 git commands to generate.