1. 04 10月, 2014 2 次提交
    • A
      x86/efi: Adding efi_printks on memory allocationa and pci.reads · 77e21e87
      Andre Müller 提交于
      All other calls to allocate memory seem to make some noise already, with the
      exception of two calls (for gop, uga) in the setup_graphics path.
      
      The purpose is to be noisy on worrysome errors immediately.
      
      commit fb86b244 ("x86/efi: Add better error logging to EFI boot
      stub") introduces printing false alarms for lots of hardware. Rather
      than playing Whack a Mole with non-fatal exit conditions, try the other
      way round.
      
      This is per Matt Fleming's suggestion:
      
      > Where I think we could improve things
      > is by adding efi_printk() message in certain error paths. Clearly, not
      > all error paths need such messages, e.g. the EFI_INVALID_PARAMETER path
      > you highlighted above, but it makes sense for memory allocation and PCI
      > read failures.
      
      Link: http://article.gmane.org/gmane.linux.kernel.efi/4628Signed-off-by: NAndre Müller <andre.muller@web.de>
      Cc: Ulf Winkelvos <ulf@winkelvos.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      77e21e87
    • M
      efi: Add efi= parameter parsing to the EFI boot stub · 5a17dae4
      Matt Fleming 提交于
      We need a way to customize the behaviour of the EFI boot stub, in
      particular, we need a way to disable the "chunking" workaround, used
      when reading files from the EFI System Partition.
      
      One of my machines doesn't cope well when reading files in 1MB chunks to
      a buffer above the 4GB mark - it appears that the "chunking" bug
      workaround triggers another firmware bug. This was only discovered with
      commit 4bf7111f ("x86/efi: Support initrd loaded above 4G"), and
      that commit is perfectly valid. The symptom I observed was a corrupt
      initrd rather than any kind of crash.
      
      efi= is now used to specify EFI parameters in two very different
      execution environments, the EFI boot stub and during kernel boot.
      
      There is also a slight performance optimization by enabling efi=nochunk,
      but that's offset by the fact that you're more likely to run into
      firmware issues, at least on x86. This is the rationale behind leaving
      the workaround enabled by default.
      
      Also provide some documentation for EFI_READ_CHUNK_SIZE and why we're
      using the current value of 1MB.
      Tested-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Cc: Roy Franz <roy.franz@linaro.org>
      Cc: Maarten Lankhorst <m.b.lankhorst@gmail.com>
      Cc: Leif Lindholm <leif.lindholm@linaro.org>
      Cc: Borislav Petkov <bp@suse.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      5a17dae4
  2. 19 7月, 2014 3 次提交
  3. 10 7月, 2014 1 次提交
    • M
      x86/efi: Include a .bss section within the PE/COFF headers · c7fb93ec
      Michael Brown 提交于
      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: NMichael 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: NMatt Fleming <matt.fleming@intel.com>
      c7fb93ec
  4. 08 7月, 2014 2 次提交
    • A
      efi: efistub: Refactor stub components · bd669475
      Ard Biesheuvel 提交于
      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: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      bd669475
    • A
      efi/x86: efistub: Move shared dependencies to <asm/efi.h> · f23cf8bd
      Ard Biesheuvel 提交于
      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: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      f23cf8bd
  5. 19 6月, 2014 1 次提交
  6. 17 6月, 2014 1 次提交
  7. 08 6月, 2014 1 次提交
    • M
      x86/boot: EFI_MIXED should not prohibit loading above 4G · 745c5167
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      Link: http://lkml.kernel.org/r/1402140380-15377-1-git-send-email-matt@console-pimps.orgSigned-off-by: NH. Peter Anvin <hpa@zytor.com>
      745c5167
  8. 05 6月, 2014 1 次提交
  9. 08 5月, 2014 2 次提交
  10. 06 5月, 2014 2 次提交
  11. 17 4月, 2014 2 次提交
  12. 11 4月, 2014 3 次提交
  13. 27 3月, 2014 1 次提交
  14. 21 3月, 2014 1 次提交
  15. 20 3月, 2014 5 次提交
  16. 14 3月, 2014 1 次提交
  17. 05 3月, 2014 11 次提交
    • M
      x86/boot: Fix non-EFI build · 3db4cafd
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      3db4cafd
    • M
      x86, tools: Fix up compiler warnings · b663a685
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      b663a685
    • M
      x86/boot: Don't overwrite cr4 when enabling PAE · 108d3f44
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      108d3f44
    • M
      x86/efi: Wire up CONFIG_EFI_MIXED · 7d453eee
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      7d453eee
    • M
      x86/efi: Firmware agnostic handover entry points · b8ff87a6
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      b8ff87a6
    • M
      x86/efi: Split the boot stub into 32/64 code paths · c116e8d6
      Matt Fleming 提交于
      Make the decision which code path to take at runtime based on
      efi_early->is64.
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      c116e8d6
    • M
      x86/efi: Add early thunk code to go from 64-bit to 32-bit · 0154416a
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      0154416a
    • M
      x86/efi: Build our own EFI services pointer table · 54b52d87
      Matt Fleming 提交于
      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: NMatt Fleming <matt.fleming@intel.com>
      54b52d87
    • M
      efi: Add separate 32-bit/64-bit definitions · 677703ce
      Matt Fleming 提交于
      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: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      677703ce
    • M
      x86, tools: Consolidate #ifdef code · 993c30a0
      Matt Fleming 提交于
      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: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      993c30a0
    • M
      x86/boot: Cleanup header.S by removing some #ifdefs · 86134a1b
      Matt Fleming 提交于
      handover_offset is now filled out by build.c. Don't set a default value
      as it will be overwritten anyway.
      Acked-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      86134a1b