1. 05 3月, 2014 6 次提交
    • 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: 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
  2. 15 1月, 2014 1 次提交
  3. 10 12月, 2013 1 次提交
    • H
      x86, build: Pass in additional -mno-mmx, -mno-sse options · 8b3b005d
      H. Peter Anvin 提交于
      In checkin
      
          5551a34e x86-64, build: Always pass in -mno-sse
      
      we unconditionally added -mno-sse to the main build, to keep newer
      compilers from generating SSE instructions from autovectorization.
      However, this did not extend to the special environments
      (arch/x86/boot, arch/x86/boot/compressed, and arch/x86/realmode/rm).
      Add -mno-sse to the compiler command line for these environments, and
      add -mno-mmx to all the environments as well, as we don't want a
      compiler to generate MMX code either.
      
      This patch also removes a $(cc-option) call for -m32, since we have
      long since stopped supporting compilers too old for the -m32 option,
      and in fact hardcode it in other places in the Makefiles.
      Reported-by: NKevin B. Smith <kevin.b.smith@intel.com>
      Cc: Sunil K. Pandey <sunil.k.pandey@intel.com>
      Signed-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      Cc: H. J. Lu <hjl.tools@gmail.com>
      Link: http://lkml.kernel.org/n/tip-j21wzqv790q834n7yc6g80j1@git.kernel.org
      Cc: <stable@vger.kernel.org> # build fix only
      8b3b005d
  4. 13 11月, 2013 1 次提交
  5. 12 11月, 2013 2 次提交
  6. 13 10月, 2013 5 次提交
  7. 09 10月, 2013 1 次提交
  8. 30 9月, 2013 2 次提交
    • B
      x86 efi: bugfix interrupt disabling sequence · 0ce6cda2
      Bart Kuivenhoven 提交于
      The problem in efi_main was that the idt was cleared before the
      interrupts were disabled.
      
      The UEFI spec states that interrupts aren't used so this shouldn't be
      too much of a problem. Peripherals however don't necessarily know about
      this and thus might cause interrupts to happen anyway. Even if
      ExitBootServices() has been called.
      
      This means there is a risk of an interrupt being triggered while the IDT
      register is nullified and the interrupt bit hasn't been cleared,
      allowing for a triple fault.
      
      This patch disables the interrupt flag, while leaving the existing IDT
      in place. The CPU won't care about the IDT at all as long as the
      interrupt bit is off, so it's safe to leave it in place as nothing will
      ever happen to it.
      
      [ Removed the now unused 'idt' variable - Matt ]
      Signed-off-by: NBart Kuivenhoven <bemk@redhat.com>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      0ce6cda2
    • L
      x86: EFI stub support for large memory maps · d2078d5a
      Linn Crosetto 提交于
      This patch fixes a problem with EFI memory maps larger than 128 entries
      when booting using the EFI stub, which results in overflowing e820_map
      in boot_params and an eventual halt when checking the map size in
      sanitize_e820_map().
      
      If the number of map entries is greater than what can fit in e820_map,
      add the extra entries to the setup_data list using type SETUP_E820_EXT.
      These extra entries are then picked up when the setup_data list is
      parsed in parse_e820_ext().
      Signed-off-by: NLinn Crosetto <linn@hp.com>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      d2078d5a
  9. 25 9月, 2013 10 次提交
  10. 08 8月, 2013 1 次提交
  11. 26 7月, 2013 1 次提交
  12. 10 7月, 2013 1 次提交
  13. 11 6月, 2013 2 次提交
    • Z
      x86, efi: retry ExitBootServices() on failure · d3768d88
      Zach Bobroff 提交于
      ExitBootServices is absolutely supposed to return a failure if any
      ExitBootServices event handler changes the memory map.  Basically the
      get_map loop should run again if ExitBootServices returns an error the
      first time.  I would say it would be fair that if ExitBootServices gives
      an error the second time then Linux would be fine in returning control
      back to BIOS.
      
      The second change is the following line:
      
      again:
              size += sizeof(*mem_map) * 2;
      
      Originally you were incrementing it by the size of one memory map entry.
      The issue here is all related to the low_alloc routine you are using.
      In this routine you are making allocations to get the memory map itself.
      Doing this allocation or allocations can affect the memory map by more
      than one record.
      
      [ mfleming - changelog, code style ]
      Signed-off-by: NZach Bobroff <zacharyb@ami.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      d3768d88
    • M
      Modify UEFI anti-bricking code · f8b84043
      Matthew Garrett 提交于
      This patch reworks the UEFI anti-bricking code, including an effective
      reversion of cc5a080c and 31ff2f20. It turns out that calling
      QueryVariableInfo() from boot services results in some firmware
      implementations jumping to physical addresses even after entering virtual
      mode, so until we have 1:1 mappings for UEFI runtime space this isn't
      going to work so well.
      
      Reverting these gets us back to the situation where we'd refuse to create
      variables on some systems because they classify deleted variables as "used"
      until the firmware triggers a garbage collection run, which they won't do
      until they reach a lower threshold. This results in it being impossible to
      install a bootloader, which is unhelpful.
      
      Feedback from Samsung indicates that the firmware doesn't need more than
      5KB of storage space for its own purposes, so that seems like a reasonable
      threshold. However, there's still no guarantee that a platform will attempt
      garbage collection merely because it drops below this threshold. It seems
      that this is often only triggered if an attempt to write generates a
      genuine EFI_OUT_OF_RESOURCES error. We can force that by attempting to
      create a variable larger than the remaining space. This should fail, but if
      it somehow succeeds we can then immediately delete it.
      
      I've tested this on the UEFI machines I have available, but I don't have
      a Samsung and so can't verify that it avoids the bricking problem.
      Signed-off-by: NMatthew Garrett <matthew.garrett@nebula.com>
      Signed-off-by: Lee, Chun-Y <jlee@suse.com> [ dummy variable cleanup ]
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      f8b84043
  14. 28 5月, 2013 1 次提交
  15. 24 4月, 2013 2 次提交
    • J
      efi: Check EFI revision in setup_efi_vars · f697036b
      Josh Boyer 提交于
      We need to check the runtime sys_table for the EFI version the firmware
      specifies instead of just checking for a NULL QueryVariableInfo.  Older
      implementations of EFI don't have QueryVariableInfo but the runtime is
      a smaller structure, so the pointer to it may be pointing off into garbage.
      
      This is apparently the case with several Apple firmwares that support EFI
      1.10, and the current check causes them to no longer boot.  Fix based on
      a suggestion from Matthew Garrett.
      Signed-off-by: NJosh Boyer <jwboyer@redhat.com>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      f697036b
    • B
      x86, efi: Fix a build warning · 51f8fbba
      Borislav Petkov 提交于
      Fix this:
      
      arch/x86/boot/compressed/eboot.c: In function ‘setup_efi_vars’:
      arch/x86/boot/compressed/eboot.c:269:2: warning: passing argument 1 of ‘efi_call_phys’ makes pointer from integer without a cast [enabled by default]
      In file included from arch/x86/boot/compressed/eboot.c:12:0:
      /w/kernel/linux/arch/x86/include/asm/efi.h:8:33: note: expected ‘void *’ but argument is of type ‘long unsigned int’
      
      after cc5a080c ("efi: Pass boot services variable info to runtime
      code").
      Reported-by: NPaul Bolle <pebolle@tiscali.nl>
      Cc: Matthew Garrett <matthew.garrett@nebula.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      51f8fbba
  16. 17 4月, 2013 2 次提交
  17. 16 4月, 2013 1 次提交
    • M
      efi: Pass boot services variable info to runtime code · cc5a080c
      Matthew Garrett 提交于
      EFI variables can be flagged as being accessible only within boot services.
      This makes it awkward for us to figure out how much space they use at
      runtime. In theory we could figure this out by simply comparing the results
      from QueryVariableInfo() to the space used by all of our variables, but
      that fails if the platform doesn't garbage collect on every boot. Thankfully,
      calling QueryVariableInfo() while still inside boot services gives a more
      reliable answer. This patch passes that information from the EFI boot stub
      up to the efi platform code.
      Signed-off-by: NMatthew Garrett <matthew.garrett@nebula.com>
      Signed-off-by: NMatt Fleming <matt.fleming@intel.com>
      cc5a080c