aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2014-07-24arm64: efi: only attempt efi map setup if booting via EFIv3.10/topic/arm64-efiLeif Lindholm
Booting a kernel with CONFIG_EFI enabled on a non-EFI system caused an oops with the current UEFI support code. Add the required test to prevent this. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 74bcc2499291d38b6253f9dbd6af33a195222208) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24arm64: add EFI runtime servicesMark Salter
This patch adds EFI runtime support for arm64. This runtime support allows the kernel to access various EFI runtime services provided by EFI firmware. Things like reboot, real time clock, EFI boot variables, and others. This functionality is supported for little endian kernels only. The UEFI firmware standard specifies that the firmware be little endian. A future patch is expected to add support for big endian kernels running with little endian firmware. Signed-off-by: Mark Salter <msalter@redhat.com> [ Remove unnecessary cache/tlb maintenance. ] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit f84d02755f5a9f3b88e8d15d6384da25ad6dcf5e) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/arm64/Kconfig arch/arm64/kernel/Makefile
2014-07-24efi: fdt: Do not report an error during boot if UEFI is not availableCatalin Marinas
Currently, fdt_find_uefi_params() reports an error if no EFI parameters are found in the DT. This is however a valid case for non-UEFI kernel booting. This patch checks changes the error reporting to a pr_info("UEFI not found") when no EFI parameters are found in the DT. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Acked-by: Leif Lindholm <leif.lindholm@linaro.org> Tested-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 29e2435fd6d71e0136e2c2ff0433b7dbeeaaccfd) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24efi/arm64: efistub: remove local copy of linux_bannerArd Biesheuvel
The shared efistub code for ARM and arm64 contains a local copy of linux_banner, allowing it to be referenced from separate executables such as the ARM decompressor. However, this introduces a dependency on generated header files, causing unnecessary rebuilds of the stub itself and, in case of arm64, vmlinux which contains it. On arm64, the copy is not actually needed since we can reference the original symbol directly, and as it turns out, there may be better ways to deal with this for ARM as well, so let's remove it from the shared code. If it still needs to be reintroduced for ARM later, it should live under arch/arm anyway and not in shared code. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Acked-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit a55c072dfe520f8fa03cf11b07b9268a8a17820a) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24efi: Fix compiler warnings (unused, const, type)Catalin Marinas
This patch fixes a few compiler warning in the efi code for unused variable, discarding const qualifier and wrong pointer type: drivers/firmware/efi/fdt.c|66 col 22| warning: unused variable ‘name’ [-Wunused-variable] drivers/firmware/efi/efi.c|368 col 3| warning: passing argument 3 of ‘of_get_flat_dt_prop’ from incompatible pointer type [enabled by default] drivers/firmware/efi/efi.c|368 col 8| warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 6fb8cc82c096fd5ccf277678639193cae07125a0) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24efi/arm64: ignore dtb= when UEFI SecureBoot is enabledArd Biesheuvel
Loading unauthenticated FDT blobs directly from storage is a security hazard, so this should only be allowed when running with UEFI Secure Boot disabled. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 345c736edd07b657a8c48190baed2719b85d0938) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24arm64: efi: add EFI stubMark Salter
This patch adds PE/COFF header fields to the start of the kernel Image so that it appears as an EFI application to UEFI firmware. An EFI stub is included to allow direct booting of the kernel Image. Signed-off-by: Mark Salter <msalter@redhat.com> [Add support in PE/COFF header for signed images] Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 3c7f255039a2ad6ee1e3890505caf0d029b22e29) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/arm64/Kconfig arch/arm64/kernel/Makefile
2014-07-24arm64: Expand arm64 image headerRoy Franz
Expand the arm64 image header to allow for co-existance with PE/COFF header required by the EFI stub. The PE/COFF format requires the "MZ" header to be at offset 0, and the offset to the PE/COFF header to be at offset 0x3c. The image header is expanded to allow 2 instructions at the beginning to accommodate a benign intruction at offset 0 that includes the "MZ" header, a magic number, and the offset to the PE/COFF header. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> (cherry picked from commit 4370eec05a887b0cd4392cd5dc5b2713174745c0) Signed-off-by: Mark Brown <broonie@linaro.org> (cherry picked from commit 3033aae67ae55a86e2a0b73199984ff060effa7b) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24efi: Move facility flags to struct efiMatt Fleming
As we grow support for more EFI architectures they're going to want the ability to query which EFI features are available on the running system. Instead of storing this information in an architecture-specific place, stick it in the global 'struct efi', which is already the central location for EFI state. While we're at it, let's change the return value of efi_enabled() to be bool and replace all references to 'facility' with 'feature', which is the usual word used to describe the attributes of the running system. Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 3e909599215456928e6b42a04f11c2517881570b) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/platform/efi/efi.c
2014-07-24ia64/efi: Implement efi_enabled()v3.10/topic/efiMatt Fleming
There's no good reason to keep efi_enabled() under CONFIG_X86 anymore, since nothing about the implementation is specific to x86. Set EFI feature flags in the ia64 boot path instead of claiming to support all features. The old behaviour was actually buggy since efi.memmap never points to a valid memory map, so we shouldn't be claiming to support EFI_MEMMAP. Fortunately, this bug was never triggered because EFI_MEMMAP isn't used outside of arch/x86 currently, but that may not always be the case. Reviewed-and-tested-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 092063808c498eccac8e891973bf143e7b60d723) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-24efi: Add separate 32-bit/64-bit definitionsMatt 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: Borislav Petkov <bp@suse.de> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 677703cef0a148ba07d37ced649ad25b1cda2f78) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: include/linux/efi.h
2014-07-23efivars: Add compatibility code for compat tasksMatt Fleming
It seems people are using 32-bit efibootmgr on top of 64-bit kernels, which will currently fail horribly when using the efivars interface, which is the traditional efibootmgr backend (the other being efivarfs). Since there is no versioning info in the data structure, figure out when we need to munge the structure data via judicious use of is_compat_task(). Cc: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit e33655a386ed3b26ad36fb97a47ebb1c2ca1e928) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars: Refactor sanity checking code into separate functionMatt Fleming
Move a large chunk of code that checks the validity of efi_variable into a new function, because we'll also need to use it for the compat code. Cc: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 54d2fbfb0c9d341c891926100ed0e5d4c4b0c987) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars: Stop passing a struct argument to efivar_validate()Matt Fleming
In preparation for compat support, we can't assume that user variable object is represented by a 'struct efi_variable'. Convert the validation functions to take the variable name as an argument, which is the only piece of the struct that was ever used anyway. Cc: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit a5d92ad32dad94fd8f3f61778561d532bb3a2f77) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars: Check size of user objectMatt Fleming
Unbelieavably there are no checks to see whether the data structure passed to 'new_var' and 'del_var' is the size that we expect. Let's add some for better robustness. Cc: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit e003bbee2a6a19a4c733335989284caf1b179e0d) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars: Use local variables instead of a pointer dereferenceMatt Fleming
In order to support a compat interface we need to stop passing pointers to structures around, since the type of structure is going to depend on whether the current task is a compat task. Cc: Mike Waychison <mikew@google.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit bafc84d539c0ffa916037840df54428623abc3e6) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efi: Use NULL instead of 0 for pointerDaeseok Youn
Fix following sparse warnings: drivers/firmware/efi/efivars.c:230:66: warning: Using plain integer as NULL pointer drivers/firmware/efi/efi.c:236:27: warning: Using plain integer as NULL pointer Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 69e608411473ac56358ef35277563982d0565381) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars, efi-pstore: Hold off deletion of sysfs entry until the scan is ↵Seiji Aguchi
completed Currently, when mounting pstore file system, a read callback of efi_pstore driver runs mutiple times as below. - In the first read callback, scan efivar_sysfs_list from head and pass a kmsg buffer of a entry to an upper pstore layer. - In the second read callback, rescan efivar_sysfs_list from the entry and pass another kmsg buffer to it. - Repeat the scan and pass until the end of efivar_sysfs_list. In this process, an entry is read across the multiple read function calls. To avoid race between the read and erasion, the whole process above is protected by a spinlock, holding in open() and releasing in close(). At the same time, kmemdup() is called to pass the buffer to pstore filesystem during it. And then, it causes a following lockdep warning. To make the dynamic memory allocation runnable without taking spinlock, holding off a deletion of sysfs entry if it happens while scanning it via efi_pstore, and deleting it after the scan is completed. To implement it, this patch introduces two flags, scanning and deleting, to efivar_entry. On the code basis, it seems that all the scanning and deleting logic is not needed because __efivars->lock are not dropped when reading from the EFI variable store. But, the scanning and deleting logic is still needed because an efi-pstore and a pstore filesystem works as follows. In case an entry(A) is found, the pointer is saved to psi->data. And efi_pstore_read() passes the entry(A) to a pstore filesystem by releasing __efivars->lock. And then, the pstore filesystem calls efi_pstore_read() again and the same entry(A), which is saved to psi->data, is used for resuming to scan a sysfs-list. So, to protect the entry(A), the logic is needed. [ 1.143710] ------------[ cut here ]------------ [ 1.144058] WARNING: CPU: 1 PID: 1 at kernel/lockdep.c:2740 lockdep_trace_alloc+0x104/0x110() [ 1.144058] DEBUG_LOCKS_WARN_ON(irqs_disabled_flags(flags)) [ 1.144058] Modules linked in: [ 1.144058] CPU: 1 PID: 1 Comm: systemd Not tainted 3.11.0-rc5 #2 [ 1.144058] 0000000000000009 ffff8800797e9ae0 ffffffff816614a5 ffff8800797e9b28 [ 1.144058] ffff8800797e9b18 ffffffff8105510d 0000000000000080 0000000000000046 [ 1.144058] 00000000000000d0 00000000000003af ffffffff81ccd0c0 ffff8800797e9b78 [ 1.144058] Call Trace: [ 1.144058] [<ffffffff816614a5>] dump_stack+0x54/0x74 [ 1.144058] [<ffffffff8105510d>] warn_slowpath_common+0x7d/0xa0 [ 1.144058] [<ffffffff8105517c>] warn_slowpath_fmt+0x4c/0x50 [ 1.144058] [<ffffffff8131290f>] ? vsscanf+0x57f/0x7b0 [ 1.144058] [<ffffffff810bbd74>] lockdep_trace_alloc+0x104/0x110 [ 1.144058] [<ffffffff81192da0>] __kmalloc_track_caller+0x50/0x280 [ 1.144058] [<ffffffff815147bb>] ? efi_pstore_read_func.part.1+0x12b/0x170 [ 1.144058] [<ffffffff8115b260>] kmemdup+0x20/0x50 [ 1.144058] [<ffffffff815147bb>] efi_pstore_read_func.part.1+0x12b/0x170 [ 1.144058] [<ffffffff81514800>] ? efi_pstore_read_func.part.1+0x170/0x170 [ 1.144058] [<ffffffff815148b4>] efi_pstore_read_func+0xb4/0xe0 [ 1.144058] [<ffffffff81512b7b>] __efivar_entry_iter+0xfb/0x120 [ 1.144058] [<ffffffff8151428f>] efi_pstore_read+0x3f/0x50 [ 1.144058] [<ffffffff8128d7ba>] pstore_get_records+0x9a/0x150 [ 1.158207] [<ffffffff812af25c>] ? selinux_d_instantiate+0x1c/0x20 [ 1.158207] [<ffffffff8128ce30>] ? parse_options+0x80/0x80 [ 1.158207] [<ffffffff8128ced5>] pstore_fill_super+0xa5/0xc0 [ 1.158207] [<ffffffff811ae7d2>] mount_single+0xa2/0xd0 [ 1.158207] [<ffffffff8128ccf8>] pstore_mount+0x18/0x20 [ 1.158207] [<ffffffff811ae8b9>] mount_fs+0x39/0x1b0 [ 1.158207] [<ffffffff81160550>] ? __alloc_percpu+0x10/0x20 [ 1.158207] [<ffffffff811c9493>] vfs_kern_mount+0x63/0xf0 [ 1.158207] [<ffffffff811cbb0e>] do_mount+0x23e/0xa20 [ 1.158207] [<ffffffff8115b51b>] ? strndup_user+0x4b/0xf0 [ 1.158207] [<ffffffff811cc373>] SyS_mount+0x83/0xc0 [ 1.158207] [<ffffffff81673cc2>] system_call_fastpath+0x16/0x1b [ 1.158207] ---[ end trace 61981bc62de9f6f4 ]--- Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com> Tested-by: Madper Xie <cxie@redhat.com> Cc: stable@kernel.org Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit e0d59733f6b1796b8d6692642c87d7dd862c3e3a) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efivars: Mark local function as staticBojan Prtvar
This fixes the following sparse warning drivers/firmware/efi/efivars.c:567:6: warning: symbol 'efivars_sysfs_exit' was not declared. Should it be static? Signed-off-by: Bojan Prtvar <prtvar.b@gmail.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 6f9dd30c22da4e48c4b7b837e9641f072e673161) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efi: Move facility flags to struct efiMatt Fleming
As we grow support for more EFI architectures they're going to want the ability to query which EFI features are available on the running system. Instead of storing this information in an architecture-specific place, stick it in the global 'struct efi', which is already the central location for EFI state. While we're at it, let's change the return value of efi_enabled() to be bool and replace all references to 'facility' with 'feature', which is the usual word used to describe the attributes of the running system. Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 3e909599215456928e6b42a04f11c2517881570b) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/include/asm/efi.h arch/x86/platform/efi/efi.c
2014-07-23efi: Add proper definitions for some EFI function pointers.Roy Franz
The x86/AMD64 EFI stubs must use a call wrapper to convert between the Linux and EFI ABIs, so void pointers are sufficient. For ARM, the ABIs are compatible, so we can directly invoke the function pointers. The functions that are used by the ARM stub are updated to match the EFI definitions. Also add some EFI types used by EFI functions. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit ed37ddffe201bfad7be3c45bc08bd65b5298adca) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-07-23efi: create memory map iteration helperMark Salter
There are a lot of places in the kernel which iterate through an EFI memory map. Most of these places use essentially the same for-loop code. This patch adds a for_each_efi_memory_desc() helper to clean up all of the existing duplicate code and avoid more in the future. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit e885cd805fc6e65ef5150a211c7bac02f925af04) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Add shared FDT related functions for ARM/ARM64Roy Franz
Both ARM and ARM64 stubs will update the device tree that they pass to the kernel. In both cases they primarily need to add the same UEFI related information, so the function can be shared. Create a new FDT related file for this to avoid use of architecture #ifdefs in efi-stub-helper.c. Signed-off-by: Roy Franz <roy.franz@linaro.org> [ Fixed memory node deletion code. ] Signed-off-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Grant Likely <grant.likely@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 263b4a30bfdb0d756ae9c70c6ff2eef1eb951770) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: add helper function to get UEFI params from FDTMark Salter
ARM and ARM64 architectures use the device tree to pass UEFI parameters from stub to kernel. These parameters are things known to the stub but not discoverable by the kernel after the stub calls ExitBootSerives(). There is a helper function in: drivers/firmware/efi/fdt.c which the stub uses to add the UEFI parameters to the device tree. This patch adds a complimentary helper function which UEFI runtime support may use to retrieve the parameters from the device tree. If an architecture wants to use this helper, it should select CONFIG_EFI_PARAMS_FROM_FDT. Signed-off-by: Mark Salter <msalter@redhat.com> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 0302f71c0aa59571ac306f93068fbbfe65ea349b) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: drivers/firmware/efi/Kconfig
2014-06-16efi: x86: Handle arbitrary Unicode charactersH. Peter Anvin
Instead of truncating UTF-16 assuming all characters is ASCII, properly convert it to UTF-8. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> [ Bug and style fixes. ] Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit c625d1c203941fad755eb4eb729db1f65d6e9836) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Add get_dram_base() helper functionRoy Franz
Add the get_dram_base() function, shared by arm/arm64. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 9bb40191e88d23563fd0467ac195debf5f6daaf9) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Add shared printk wrapper for consistent prefixingRoy Franz
Add a wrapper for printk to standardize the prefix for informational and error messages from the EFI stub. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit f966ea021f947b20c22b31194d7e3042375c7f24) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: efi-stub-helper cleanupLeif Lindholm
An #ifdef CONFIG_ARM clause in efi-stub-helper.c got included with some of the generic stub rework by Roy Franz. Drop it here to make subsequent patches less confusing. Also, In handle_cmdline_files(), fh is not initialized, and while the overall logic around this handling appears safe, gcc does not always pick this up. Initialize to NULL to remove the resulting warning. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 9403e462fb5ffa9eeaa9663cb23ded02b7e603a3) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Pass correct file handle to efi_file_{read,close}Matt Fleming
We're currently passing the file handle for the root file system to efi_file_read() and efi_file_close(), instead of the file handle for the file we wish to read/close. While this has worked up until now, it seems that it has only been by pure luck. Olivier explains, "The issue is the UEFI Fat driver might return the same function for 'fh->read()' and 'h->read()'. While in our case it does not work with a different implementation of EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. In our case, we return a different pointer when reading a directory and reading a file." Fixing this actually clears up the two functions because we can drop one of the arguments, and instead only pass a file 'handle' argument. Reported-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Olivier Martin <olivier.martin@arm.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 47514c996fac5e6f13ef3a4c5e23f1c5cffabb7b) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/boot/compressed/eboot.c
2014-06-16x86, efi: Abstract x86 efi_early callsMatt Fleming
The ARM EFI boot stub doesn't need to care about the efi_early infrastructure that x86 requires in order to do mixed mode thunking. So wrap everything up in an efi_call_early() macro. This allows x86 to do the necessary indirection jumps to call whatever firmware interface is necessary (native or mixed mode), but also allows the ARM folks to mask the fact that they don't support relocation in the boot stub and need to pass 'sys_table_arg' to every function. [ hpa: there are no object code changes from this patch ] Signed-off-by: Matt Fleming <matt.fleming@intel.com> Link: http://lkml.kernel.org/r/20140326091011.GB2958@console-pimps.org Cc: Roy Franz <roy.franz@linaro.org> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> (cherry picked from commit 204b0a1a4b92612c957a042df1a3be0e9cc79391) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/boot/compressed/eboot.c
2014-06-16efi: Move common EFI stub code from x86 arch code to common locationMark Brown
No code changes made, just moving functions and #define from x86 arch directory to common location. Code is shared using #include, similar to how decompression code is shared among architectures. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 7721da4c1ebf96ff815987011c1a0edef596b50a) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/boot/compressed/eboot.c arch/x86/boot/compressed/eboot.h
2014-06-16boot, efi: Remove redundant memset()Roy Franz
Remove a redundant memset() call from efi_relocate_kernel() that was clearing memory that would be used by BSS in non-compressed images loaded with this function. This clear was redundant with the clearing done in the image itself, and also implemented incorrectly with a 0 length. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit c158c3bf59951bbb44bd7ccca9e6665dfd1617c5) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: resolve warnings found on ARM compileRoy Franz
warnings from gcc: warning: label 'free_pool' defined but not used [-Wunused-label] warning: value computed is not used [-Wunused-value] Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 4e283088bd9af0ff119d6e15bca81a83d6e8e30c) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Fix types in EFI calls to match EFI function definitions.Roy Franz
EFI calls can made directly on ARM, so the function pointers are directly invoked. This allows types to be checked at compile time, so here we ensure that the parameters match the function signature. The wrappers used by x86 prevent any type checking. Correct the type of chunksize to be based on native width as specified by the EFI_FILE_PROTOCOL read() function. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 6a5fe770d32811ffacefaa2a430cc067ecc7336c) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Renames in handle_cmdline_files() to complete generalization.Roy Franz
Rename variables to be not initrd specific, as now the function loads arbitrary files. This change is exclusively renames and comment changes to reflect the generalization. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 36f8961c963683ac12282e422dfc3db806ee0c7e) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Generalize handle_ramdisks() and rename to handle_cmdline_files().Roy Franz
The handle_cmdline_files now takes the option to handle as a string, and returns the loaded data through parameters, rather than taking an x86 specific setup_header structure. For ARM, this will be used to load a device tree blob in addition to initrd images. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 46f4582e7cbc5f30127183812d4da875782518f5) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Allow efi_free() to be called with size of 0Roy Franz
Make efi_free() safely callable with size of 0, similar to free() being callable with NULL pointers, and do nothing in that case. Remove size checks that this makes redundant. This also avoids some size checks in the ARM EFI stub code that will be added as well. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 0e1cadb05bba2293b4575c8cab275313d181d94f) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: generalize efi_get_memory_map()Roy Franz
Add arguments for returning the descriptor version and also the memory map key. The key is required for calling exit_boot_services(). Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 1c089c65f54b70261fdcb4c238986a979c11fad7) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Rename __get_map() to efi_get_memory_map()Roy Franz
Rename function in preparation for making it more flexible and sharing it. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 86cc653b1955c0a47681d16457f9ee9009f2561a) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Move unicode to ASCII conversion to shared function.Roy Franz
Move the open-coded conversion to a shared function for use by all architectures. Change the allocation to prefer a high address for ARM, as this is required to avoid conflicts with reserved regions in low memory. We don't know the specifics of these regions until after we process the command line and device tree. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 5fef3870c572a30f9def07c4ded69dc37a9cf5d9) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Generalize relocate_kernel() for use by other architectures.Roy Franz
Rename relocate_kernel() to efi_relocate_kernel(), and take parameters rather than x86 specific structure. Add max_addr argument as for ARM we have some address constraints that we need to enforce when relocating the kernel. Add alloc_size parameter for use by ARM64 which uses an uncompressed kernel, and needs to allocate space for BSS. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 4a9f3a7c336a6b0ffeef2523bef93e67b0921163) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Move relocate_kernel() to shared file.Roy Franz
The relocate_kernel() function will be generalized and used by all architectures, as they all have similar requirements. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit c6866d7238d4f26055de8db9c1d5a700e554b2d4) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Enforce minimum alignment of 1 page on allocations.Roy Franz
The efi_high_alloc() and efi_low_alloc() functions use the EFI_ALLOCATE_ADDRESS option to the EFI function allocate_pages(), which requires a minimum of page alignment, and rejects all other requests. The existing code could fail to allocate depending on allocation size, as although repeated allocation attempts were made, none were guaranteed to be page aligned. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 38dd9c02c3f2ed461165db22b93fae7f3ddde9ac) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Rename memory allocation/free functionsRoy Franz
Rename them to be more similar, as low_free() could be used to free memory allocated by both high_alloc() and low_alloc(). high_alloc() -> efi_high_alloc() low_alloc() -> efi_low_alloc() low_free() -> efi_free() Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 40e4530a00b7d52332fe9a1361388fda8e5260da) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Add system table pointer argument to shared functions.Roy Franz
Add system table pointer argument to shared EFI stub related functions so they no longer use a global system table pointer as they did when part of eboot.c. For the ARM EFI stub this allows us to avoid global variables completely and thereby not have to deal with GOT fixups. Not having the EFI stub fixup its GOT, which is shared with the decompressor, simplifies the relocating of the zImage to a bootable address. Signed-off-by: Roy Franz <roy.franz@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 876dc36aceb1682cb01426f507f369aec4f68c76) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: Move common EFI stub code from x86 arch code to common locationRoy Franz
No code changes made, just moving functions and #define from x86 arch directory to common location. Code is shared using #include, similar to how decompression code is shared among architectures. Signed-off-by: Roy Franz <roy.franz@linaro.org> Acked-by: Mark Salter <msalter@redhat.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 7721da4c1ebf96ff815987011c1a0edef596b50a) Signed-off-by: Mark Brown <broonie@linaro.org> Conflicts: arch/x86/boot/compressed/eboot.c arch/x86/boot/compressed/eboot.h
2014-06-16efi: x86: make efi_lookup_mapped_addr() a common functionLeif Lindholm
efi_lookup_mapped_addr() is a handy utility for other platforms than x86. Move it from arch/x86 to drivers/firmware. Add memmap pointer to global efi structure, and initialise it on x86. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 258f6fd738221766b512cd8c7120563b78d62829) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efi: x86: ia64: provide a generic efi_config_init()Leif Lindholm
Common to (U)EFI support on all platforms is the global "efi" data structure, and the code that parses the System Table to locate addresses to populate that structure with. This patch adds both of these to the global EFI driver code and removes the local definition of the global "efi" data structure from the x86 and ia64 code. Squashed into one big patch to avoid breaking bisection. Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Tony Luck <tony.luck@intel.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit 272686bf46a34f86d270cf192f68769667792026) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efivars: check for EFI_RUNTIME_SERVICESMatt Fleming
The efivars code requires EFI runtime services to function, so check that they are enabled. This fixes a crash when booting with the "noefi" kernel parameter, and also when mixing kernel and firmware "bitness", e.g. 32-bit kernel with 64-bit firmware. Tested-by: Dave Young <dyoung@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com> (cherry picked from commit d320c079efd46db1be0640d00bd6723d9e738f9f) Signed-off-by: Mark Brown <broonie@linaro.org>
2014-06-16efivars: If pstore_register fails, free unneeded pstore bufferLenny Szubowicz
This is patch 3/3 of a patch set that cleans up pstore_register failure paths. If efivars fails to register with pstore, there is no point to keeping the 4 KB buffer around. It's only used by the pstore read/write routines. Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com> Reported-by: Naotaka Hamaguchi <n.hamaguchi@jp.fujitsu.com> Signed-off-by: Tony Luck <tony.luck@intel.com> (cherry picked from commit 0d838347f1325cebfe8b9341a4b4c1f407022231) Signed-off-by: Mark Brown <broonie@linaro.org>