Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f92e3da1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull EFI updates from Ingo Molnar:
 "The main changes in this cycle were:

   - Transparently fall back to other poweroff method(s) if EFI poweroff
     fails (and returns)

   - Use separate PE/COFF section headers for the RX and RW parts of the
     ARM stub loader so that the firmware can use strict mapping
     permissions

   - Add support for requesting the firmware to wipe RAM at warm reboot

   - Increase the size of the random seed obtained from UEFI so CRNG
     fast init can complete earlier

   - Update the EFI framebuffer address if it points to a BAR that gets
     moved by the PCI resource allocation code

   - Enable "reset attack mitigation" of TPM environments: this is
     enabled if the kernel is configured with
     CONFIG_RESET_ATTACK_MITIGATION=y.

   - Clang related fixes

   - Misc cleanups, constification, refactoring, etc"

* 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  efi/bgrt: Use efi_mem_type()
  efi: Move efi_mem_type() to common code
  efi/reboot: Make function pointer orig_pm_power_off static
  efi/random: Increase size of firmware supplied randomness
  efi/libstub: Enable reset attack mitigation
  firmware/efi/esrt: Constify attribute_group structures
  firmware/efi: Constify attribute_group structures
  firmware/dcdbas: Constify attribute_group structures
  arm/efi: Split zImage code and data into separate PE/COFF sections
  arm/efi: Replace open coded constants with symbolic ones
  arm/efi: Remove pointless dummy .reloc section
  arm/efi: Remove forbidden values from the PE/COFF header
  drivers/fbdev/efifb: Allow BAR to be moved instead of claiming it
  efi/reboot: Fall back to original power-off method if EFI_RESET_SHUTDOWN returns
  efi/arm/arm64: Add missing assignment of efi.config_table
  efi/libstub/arm64: Set -fpie when building the EFI stub
  efi/libstub/arm64: Force 'hidden' visibility for section markers
  efi/libstub/arm64: Use hidden attribute for struct screen_info reference
  efi/arm: Don't mark ACPI reclaim memory as MEMBLOCK_NOMAP
parents 57e88b43 6de47a5e
Loading
Loading
Loading
Loading
+82 −78
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013-2015 Linaro Ltd
 * Copyright (C) 2013-2017 Linaro Ltd
 * Authors: Roy Franz <roy.franz@linaro.org>
 *          Ard Biesheuvel <ard.biesheuvel@linaro.org>
 *
@@ -8,6 +8,9 @@
 * published by the Free Software Foundation.
 */

#include <linux/pe.h>
#include <linux/sizes.h>

		.macro	__nop
#ifdef CONFIG_EFI_STUB
		@ This is almost but not quite a NOP, since it does clobber the
@@ -15,7 +18,7 @@
		@ PE/COFF expects the magic string "MZ" at offset 0, while the
		@ ARM/Linux boot protocol expects an executable instruction
		@ there.
		.inst	'M' | ('Z' << 8) | (0x1310 << 16)   @ tstne r0, #0x4d000
		.inst	MZ_MAGIC | (0x1310 << 16)	@ tstne r0, #0x4d000
#else
 AR_CLASS(	mov	r0, r0		)
  M_CLASS(	nop.w			)
@@ -37,56 +40,56 @@
		.long	pe_header - start		@ Offset to the PE header.

pe_header:
		.ascii	"PE\0\0"
		.long	PE_MAGIC

coff_header:
		.short	0x01c2			@ ARM or Thumb
		.short	2			@ nr_sections
		.short	IMAGE_FILE_MACHINE_THUMB	@ Machine
		.short	section_count			@ NumberOfSections
		.long	0 				@ TimeDateStamp
		.long	0				@ PointerToSymbolTable
		.long	1			@ NumberOfSymbols
		.short	section_table - optional_header
						@ SizeOfOptionalHeader
		.short	0x306			@ Characteristics.
						@ IMAGE_FILE_32BIT_MACHINE |
						@ IMAGE_FILE_DEBUG_STRIPPED |
						@ IMAGE_FILE_EXECUTABLE_IMAGE |
						@ IMAGE_FILE_LINE_NUMS_STRIPPED
		.long	0				@ NumberOfSymbols
		.short	section_table - optional_header	@ SizeOfOptionalHeader
		.short	IMAGE_FILE_32BIT_MACHINE | \
			IMAGE_FILE_DEBUG_STRIPPED | \
			IMAGE_FILE_EXECUTABLE_IMAGE | \
			IMAGE_FILE_LINE_NUMS_STRIPPED	@ Characteristics

#define __pecoff_code_size (__pecoff_data_start - __efi_start)

optional_header:
		.short	0x10b			@ PE32 format
		.short	PE_OPT_MAGIC_PE32		@ PE32 format
		.byte	0x02				@ MajorLinkerVersion
		.byte	0x14				@ MinorLinkerVersion
		.long	_end - __efi_start	@ SizeOfCode
		.long	0			@ SizeOfInitializedData
		.long	__pecoff_code_size		@ SizeOfCode
		.long	__pecoff_data_size		@ SizeOfInitializedData
		.long	0				@ SizeOfUninitializedData
		.long	efi_stub_entry - start		@ AddressOfEntryPoint
		.long	start_offset			@ BaseOfCode
		.long	0			@ data
		.long	__pecoff_data_start - start	@ BaseOfData

extra_header_fields:
		.long	0				@ ImageBase
		.long	0x200			@ SectionAlignment
		.long	0x200			@ FileAlignment
		.short	0			@ MajorOperatingSystemVersion
		.short	0			@ MinorOperatingSystemVersion
		.long	SZ_4K				@ SectionAlignment
		.long	SZ_512				@ FileAlignment
		.short	0				@ MajorOsVersion
		.short	0				@ MinorOsVersion
		.short	0				@ MajorImageVersion
		.short	0				@ MinorImageVersion
		.short	0				@ MajorSubsystemVersion
		.short	0				@ MinorSubsystemVersion
		.long	0				@ Win32VersionValue

		.long	_end - start		@ SizeOfImage
		.long	__pecoff_end - start		@ SizeOfImage
		.long	start_offset			@ SizeOfHeaders
		.long	0				@ CheckSum
		.short	0xa			@ Subsystem (EFI application)
		.short	IMAGE_SUBSYSTEM_EFI_APPLICATION	@ Subsystem
		.short	0				@ DllCharacteristics
		.long	0				@ SizeOfStackReserve
		.long	0				@ SizeOfStackCommit
		.long	0				@ SizeOfHeapReserve
		.long	0				@ SizeOfHeapCommit
		.long	0				@ LoaderFlags
		.long	0x6			@ NumberOfRvaAndSizes
		.long	(section_table - .) / 8		@ NumberOfRvaAndSizes

		.quad	0				@ ExportTable
		.quad	0				@ ImportTable
@@ -96,34 +99,35 @@ extra_header_fields:
		.quad	0				@ BaseRelocationTable

section_table:
		@
		@ The EFI application loader requires a relocation section
		@ because EFI applications must be relocatable. This is a
		@ dummy section as far as we are concerned.
		@
		.ascii	".reloc\0\0"
		.long	0			@ VirtualSize
		.long	0			@ VirtualAddress
		.long	0			@ SizeOfRawData
		.long	0			@ PointerToRawData
		.ascii	".text\0\0\0"
		.long	__pecoff_code_size		@ VirtualSize
		.long	__efi_start			@ VirtualAddress
		.long	__pecoff_code_size		@ SizeOfRawData
		.long	__efi_start			@ PointerToRawData
		.long	0				@ PointerToRelocations
		.long	0				@ PointerToLineNumbers
		.short	0				@ NumberOfRelocations
		.short	0				@ NumberOfLineNumbers
		.long	0x42100040		@ Characteristics
		.long	IMAGE_SCN_CNT_CODE | \
			IMAGE_SCN_MEM_READ | \
			IMAGE_SCN_MEM_EXECUTE		@ Characteristics

		.ascii	".text\0\0\0"
		.long	_end - __efi_start	@ VirtualSize
		.long	__efi_start		@ VirtualAddress
		.long	_edata - __efi_start	@ SizeOfRawData
		.long	__efi_start		@ PointerToRawData
		.ascii	".data\0\0\0"
		.long	__pecoff_data_size		@ VirtualSize
		.long	__pecoff_data_start - start	@ VirtualAddress
		.long	__pecoff_data_rawsize		@ SizeOfRawData
		.long	__pecoff_data_start - start	@ PointerToRawData
		.long	0				@ PointerToRelocations
		.long	0				@ PointerToLineNumbers
		.short	0				@ NumberOfRelocations
		.short	0				@ NumberOfLineNumbers
		.long	0xe0500020		@ Characteristics
		.long	IMAGE_SCN_CNT_INITIALIZED_DATA | \
			IMAGE_SCN_MEM_READ | \
			IMAGE_SCN_MEM_WRITE		@ Characteristics

		.set	section_count, (. - section_table) / 40

		.align	9
		.align	12
__efi_start:
#endif
		.endm
+23 −7
Original line number Diff line number Diff line
@@ -48,13 +48,6 @@ SECTIONS
    *(.rodata)
    *(.rodata.*)
  }
  .data : {
    /*
     * The EFI stub always executes from RAM, and runs strictly before the
     * decompressor, so we can make an exception for its r/w data, and keep it
     */
    *(.data.efistub)
  }
  .piggydata : {
    *(.piggydata)
  }
@@ -70,6 +63,26 @@ SECTIONS
  /* ensure the zImage file size is always a multiple of 64 bits */
  /* (without a dummy byte, ld just ignores the empty section) */
  .pad			: { BYTE(0); . = ALIGN(8); }

#ifdef CONFIG_EFI_STUB
  .data : ALIGN(4096) {
    __pecoff_data_start = .;
    /*
     * The EFI stub always executes from RAM, and runs strictly before the
     * decompressor, so we can make an exception for its r/w data, and keep it
     */
    *(.data.efistub)
    __pecoff_data_end = .;

    /*
     * PE/COFF mandates a file size which is a multiple of 512 bytes if the
     * section size equals or exceeds 4 KB
     */
    . = ALIGN(512);
  }
  __pecoff_data_rawsize = . - ADDR(.data);
#endif

  _edata = .;

  _magic_sig = ZIMAGE_MAGIC(0x016f2818);
@@ -84,6 +97,9 @@ SECTIONS
  . = ALIGN(8);		/* the stack must be 64-bit aligned */
  .stack		: { *(.stack) }

  PROVIDE(__pecoff_data_size = ALIGN(512) - ADDR(.data));
  PROVIDE(__pecoff_end = ALIGN(512));

  .stab 0		: { *(.stab) }
  .stabstr 0		: { *(.stabstr) }
  .stab.excl 0		: { *(.stab.excl) }
+3 −0
Original line number Diff line number Diff line
@@ -90,6 +90,9 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
#define alloc_screen_info(x...)		&screen_info
#define free_screen_info(x...)

/* redeclare as 'hidden' so the compiler will generate relative references */
extern struct screen_info screen_info __attribute__((__visibility__("hidden")));

static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
{
}
+3 −0
Original line number Diff line number Diff line
@@ -997,6 +997,9 @@ struct boot_params *efi_main(struct efi_config *c,
	if (boot_params->secure_boot == efi_secureboot_mode_unset)
		boot_params->secure_boot = efi_get_secureboot(sys_table);

	/* Ask the firmware to clear memory on unclean shutdown */
	efi_enable_reset_attack_mitigation(sys_table);

	setup_graphics(boot_params);

	setup_efi_pci(boot_params);
+0 −19
Original line number Diff line number Diff line
@@ -1032,25 +1032,6 @@ void __init efi_enter_virtual_mode(void)
	efi_dump_pagetable();
}

/*
 * Convenience functions to obtain memory types and attributes
 */
int efi_mem_type(unsigned long phys_addr)
{
	efi_memory_desc_t *md;

	if (!efi_enabled(EFI_MEMMAP))
		return -ENOTSUPP;

	for_each_efi_memory_desc(md) {
		if ((md->phys_addr <= phys_addr) &&
		    (phys_addr < (md->phys_addr +
				  (md->num_pages << EFI_PAGE_SHIFT))))
			return md->type;
	}
	return -EINVAL;
}

static int __init arch_parse_efi_cmdline(char *str)
{
	if (!str) {
Loading