Skip to content
  1. Sep 08, 2014
    • Matt Fleming's avatar
      x86/efi: Fixup GOT in all boot code paths · 9cb0e394
      Matt Fleming authored
      
      
      Maarten reported that his Macbook pro 8.2 stopped booting after commit
      f23cf8bd ("efi/x86: efistub: Move shared dependencies to
      <asm/efi.h>"), the main feature of which is changing the visibility of
      symbol 'efi_early' from local to global.
      
      By making 'efi_early' global we end up requiring an entry in the Global
      Offset Table. Unfortunately, while we do include code to fixup GOT
      entries in the early boot code, it's only called after we've executed
      the EFI boot stub.
      
      What this amounts to is that references to 'efi_early' in the EFI boot
      stub don't point to the correct place.
      
      Since we've got multiple boot entry points we need to be prepared to
      fixup the GOT in multiple places, while ensuring that we never do it
      more than once, otherwise the GOT entries will still point to the wrong
      place.
      
      Reported-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
      Tested-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
      Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      9cb0e394
    • Yinghai Lu's avatar
      x86/efi: Only load initrd above 4g on second try · 47226ad4
      Yinghai Lu authored
      
      
      Mantas found that after commit 4bf7111f ("x86/efi: Support initrd
      loaded above 4G"), the kernel freezes at the earliest possible moment
      when trying to boot via UEFI on Asus laptop.
      
      Revert to old way to load initrd under 4G on first try, second try will
      use above 4G buffer when initrd is too big and does not fit under 4G.
      
      [ The cause of the freeze appears to be a firmware bug when reading
        file data into buffers above 4GB, though the exact reason is unknown.
        Mantas reports that the hang can be avoid if the file size is a
        multiple of 512 bytes, but I've seen some ASUS firmware simply
        corrupting the file data rather than freezing.
      
        Laszlo fixed an issue in the upstream EDK2 DiskIO code in Aug 2013
        which may possibly be related, commit 4e39b75e ("MdeModulePkg/DiskIoDxe:
        fix source/destination pointer of overrun transfer").
      
        Whatever the cause, it's unlikely that a fix will be forthcoming
        from the vendor, hence the workaround - Matt ]
      
      Cc: Laszlo Ersek <lersek@redhat.com>
      Reported-by: default avatarMantas Mikulėnas <grawity@gmail.com>
      Reported-by: default avatarHarald Hoyer <harald@redhat.com>
      Tested-by: default avatarAnders Darander <anders@chargestorm.se>
      Tested-by: default avatarCalvin Walton <calvin.walton@kepstin.ca>
      Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      47226ad4
  2. Jul 18, 2014
  3. Jul 10, 2014
    • Michael Brown's avatar
      x86/efi: Include a .bss section within the PE/COFF headers · c7fb93ec
      Michael Brown authored
      
      
      The PE/COFF headers currently describe only the initialised-data
      portions of the image, and result in no space being allocated for the
      uninitialised-data portions.  Consequently, the EFI boot stub will end
      up overwriting unexpected areas of memory, with unpredictable results.
      
      Fix by including a .bss section in the PE/COFF headers (functionally
      equivalent to the init_size field in the bzImage header).
      
      Signed-off-by: default avatarMichael Brown <mbrown@fensystems.co.uk>
      Cc: Thomas Bächler <thomas@archlinux.org>
      Cc: Josh Boyer <jwboyer@fedoraproject.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      c7fb93ec
  4. Jul 07, 2014
    • Ard Biesheuvel's avatar
      efi: efistub: Refactor stub components · bd669475
      Ard Biesheuvel authored
      
      
      In order to move from the #include "../../../xxxxx.c" anti-pattern used
      by both the x86 and arm64 versions of the stub to a static library
      linked into either the kernel proper (arm64) or a separate boot
      executable (x86), there is some prepatory work required.
      
      This patch does the following:
      - move forward declarations of functions shared between the arch
        specific and the generic parts of the stub to include/linux/efi.h
      - move forward declarations of functions shared between various .c files
        of the generic stub code to a new local header file called "efistub.h"
      - add #includes to all .c files which were formerly relying on the
        #includor to include the correct header files
      - remove all static modifiers from functions which will need to be
        externally visible once we move to a static library
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      bd669475
    • Ard Biesheuvel's avatar
      efi/x86: efistub: Move shared dependencies to <asm/efi.h> · f23cf8bd
      Ard Biesheuvel authored
      
      
      This moves definitions depended upon both by code under arch/x86/boot
      and under drivers/firmware/efi to <asm/efi.h>. This is in preparation of
      turning the stub code under drivers/firmware/efi into a static library.
      
      Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      f23cf8bd
  5. Jun 19, 2014
  6. Jun 16, 2014
  7. Jun 07, 2014
    • Matt Fleming's avatar
      x86/boot: EFI_MIXED should not prohibit loading above 4G · 745c5167
      Matt Fleming authored
      
      
      commit 7d453eee ("x86/efi: Wire up CONFIG_EFI_MIXED") introduced a
      regression for the functionality to load kernels above 4G. The relevant
      (incorrect) reasoning behind this change can be seen in the commit
      message,
      
        "The xloadflags field in the bzImage header is also updated to reflect
        that the kernel supports both entry points by setting both of
        XLF_EFI_HANDOVER_32 and XLF_EFI_HANDOVER_64 when CONFIG_EFI_MIXED=y.
        XLF_CAN_BE_LOADED_ABOVE_4G is disabled so that the kernel text is
        guaranteed to be addressable with 32-bits."
      
      This is obviously bogus since 32-bit EFI loaders will never place the
      kernel above the 4G mark. So this restriction is entirely unnecessary.
      
      But things are worse than that - since we want to encourage people to
      always compile with CONFIG_EFI_MIXED=y so that their kernels work out of
      the box for both 32-bit and 64-bit firmware, commit 7d453eee
      effectively disables XLF_CAN_BE_LOADED_ABOVE_4G completely.
      
      Remove the overzealous and superfluous restriction and restore the
      XLF_CAN_BE_LOADED_ABOVE_4G functionality.
      
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Dave Young <dyoung@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      Link: http://lkml.kernel.org/r/1402140380-15377-1-git-send-email-matt@console-pimps.org
      
      
      Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
      745c5167
  8. Jun 04, 2014
  9. May 08, 2014
  10. May 05, 2014
  11. Apr 17, 2014
  12. Apr 10, 2014
  13. Mar 26, 2014
  14. Mar 20, 2014
  15. Mar 19, 2014
  16. Mar 13, 2014
  17. Mar 05, 2014
    • Matt Fleming's avatar
      x86/boot: Fix non-EFI build · 3db4cafd
      Matt Fleming authored
      
      
      The kbuild test robot reported the following errors, introduced with
      commit 54b52d87 ("x86/efi: Build our own EFI services pointer
      table"),
      
       arch/x86/boot/compressed/head_32.o: In function `efi32_config':
      >> (.data+0x58): undefined reference to `efi_call_phys'
      
       arch/x86/boot/compressed/head_64.o: In function `efi64_config':
      >> (.data+0x90): undefined reference to `efi_call6'
      
      Wrap the efi*_config structures in #ifdef CONFIG_EFI_STUB so that we
      don't make references to EFI functions if they're not compiled in.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      3db4cafd
    • Matt Fleming's avatar
      x86, tools: Fix up compiler warnings · b663a685
      Matt Fleming authored
      
      
      The kbuild test robot reported the following errors that were introduced
      with commit 993c30a0 ("x86, tools: Consolidate #ifdef code"),
      
        arch/x86/boot/tools/build.c: In function 'update_pecoff_setup_and_reloc':
      >> arch/x86/boot/tools/build.c:252:1: error: parameter name omitted
          static inline void update_pecoff_setup_and_reloc(unsigned int) {}
          ^
        arch/x86/boot/tools/build.c: In function 'update_pecoff_text':
      >> arch/x86/boot/tools/build.c:253:1: error: parameter name omitted
          static inline void update_pecoff_text(unsigned int, unsigned int) {}
          ^
      >> arch/x86/boot/tools/build.c:253:1: error: parameter name omitted
      
         arch/x86/boot/tools/build.c: In function 'main':
      >> arch/x86/boot/tools/build.c:372:2: warning: implicit declaration of function 'efi_stub_entry_update' [-Wimplicit-function-declaration]
          efi_stub_entry_update();
          ^
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      b663a685
  18. Mar 04, 2014
    • Matt Fleming's avatar
      x86/boot: Don't overwrite cr4 when enabling PAE · 108d3f44
      Matt Fleming authored
      
      
      Some EFI firmware makes use of the FPU during boottime services and
      clearing X86_CR4_OSFXSR by overwriting %cr4 causes the firmware to
      crash.
      
      Add the PAE bit explicitly instead of trashing the existing contents,
      leaving the rest of the bits as the firmware set them.
      
      Cc: H. Peter Anvin <hpa@zytor.com>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      108d3f44
    • Matt Fleming's avatar
      x86/efi: Wire up CONFIG_EFI_MIXED · 7d453eee
      Matt Fleming authored
      
      
      Add the Kconfig option and bump the kernel header version so that boot
      loaders can check whether the handover code is available if they want.
      
      The xloadflags field in the bzImage header is also updated to reflect
      that the kernel supports both entry points by setting both of
      XLF_EFI_HANDOVER_32 and XLF_EFI_HANDOVER_64 when CONFIG_EFI_MIXED=y.
      XLF_CAN_BE_LOADED_ABOVE_4G is disabled so that the kernel text is
      guaranteed to be addressable with 32-bits.
      
      Note that no boot loaders should be using the bits set in xloadflags to
      decide which entry point to jump to. The entire scheme is based on the
      concept that 32-bit bootloaders always jump to ->handover_offset and
      64-bit loaders always jump to ->handover_offset + 512. We set both bits
      merely to inform the boot loader that it's safe to use the native
      handover offset even if the machine type in the PE/COFF header claims
      otherwise.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      7d453eee
    • Matt Fleming's avatar
      x86/efi: Firmware agnostic handover entry points · b8ff87a6
      Matt Fleming authored
      
      
      The EFI handover code only works if the "bitness" of the firmware and
      the kernel match, i.e. 64-bit firmware and 64-bit kernel - it is not
      possible to mix the two. This goes against the tradition that a 32-bit
      kernel can be loaded on a 64-bit BIOS platform without having to do
      anything special in the boot loader. Linux distributions, for one thing,
      regularly run only 32-bit kernels on their live media.
      
      Despite having only one 'handover_offset' field in the kernel header,
      EFI boot loaders use two separate entry points to enter the kernel based
      on the architecture the boot loader was compiled for,
      
          (1) 32-bit loader: handover_offset
          (2) 64-bit loader: handover_offset + 512
      
      Since we already have two entry points, we can leverage them to infer
      the bitness of the firmware we're running on, without requiring any boot
      loader modifications, by making (1) and (2) valid entry points for both
      CONFIG_X86_32 and CONFIG_X86_64 kernels.
      
      To be clear, a 32-bit boot loader will always use (1) and a 64-bit boot
      loader will always use (2). It's just that, if a single kernel image
      supports (1) and (2) that image can be used with both 32-bit and 64-bit
      boot loaders, and hence both 32-bit and 64-bit EFI.
      
      (1) and (2) must be 512 bytes apart at all times, but that is already
      part of the boot ABI and we could never change that delta without
      breaking existing boot loaders anyhow.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      b8ff87a6
    • Matt Fleming's avatar
      x86/efi: Split the boot stub into 32/64 code paths · c116e8d6
      Matt Fleming authored
      
      
      Make the decision which code path to take at runtime based on
      efi_early->is64.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      c116e8d6
    • Matt Fleming's avatar
      x86/efi: Add early thunk code to go from 64-bit to 32-bit · 0154416a
      Matt Fleming authored
      
      
      Implement the transition code to go from IA32e mode to protected mode in
      the EFI boot stub. This is required to use 32-bit EFI services from a
      64-bit kernel.
      
      Since EFI boot stub is executed in an identity-mapped region, there's
      not much we need to do before invoking the 32-bit EFI boot services.
      However, we do reload the firmware's global descriptor table
      (efi32_boot_gdt) in case things like timer events are still running in
      the firmware.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      0154416a
    • Matt Fleming's avatar
      x86/efi: Build our own EFI services pointer table · 54b52d87
      Matt Fleming authored
      
      
      It's not possible to dereference the EFI System table directly when
      booting a 64-bit kernel on a 32-bit EFI firmware because the size of
      pointers don't match.
      
      In preparation for supporting the above use case, build a list of
      function pointers on boot so that callers don't have to worry about
      converting pointer sizes through multiple levels of indirection.
      
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      54b52d87
    • Matt Fleming's avatar
      efi: Add separate 32-bit/64-bit definitions · 677703ce
      Matt Fleming authored
      
      
      The traditional approach of using machine-specific types such as
      'unsigned long' does not allow the kernel to interact with firmware
      running in a different CPU mode, e.g. 64-bit kernel with 32-bit EFI.
      
      Add distinct EFI structure definitions for both 32-bit and 64-bit so
      that we can use them in the 32-bit and 64-bit code paths.
      
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      677703ce
    • Matt Fleming's avatar
      x86, tools: Consolidate #ifdef code · 993c30a0
      Matt Fleming authored
      
      
      Instead of littering main() with #ifdef CONFIG_EFI_STUB, move the logic
      into separate functions that do nothing if the config option isn't set.
      This makes main() much easier to read.
      
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      993c30a0
    • Matt Fleming's avatar
      x86/boot: Cleanup header.S by removing some #ifdefs · 86134a1b
      Matt Fleming authored
      
      
      handover_offset is now filled out by build.c. Don't set a default value
      as it will be overwritten anyway.
      
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
      86134a1b
Loading