Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 21 Mar 2016 01:58:18 +0000 (18:58 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 21 Mar 2016 01:58:18 +0000 (18:58 -0700)
Pull EFI updates from Ingo Molnar:
 "The main changes are:

   - Use separate EFI page tables when executing EFI firmware code.
     This isolates the EFI context from the rest of the kernel, which
     has security and general robustness advantages.  (Matt Fleming)

   - Run regular UEFI firmware with interrupts enabled.  This is already
     the status quo under other OSs.  (Ard Biesheuvel)

   - Various x86 EFI enhancements, such as the use of non-executable
     attributes for EFI memory mappings.  (Sai Praneeth Prakhya)

   - Various arm64 UEFI enhancements.  (Ard Biesheuvel)

   - ... various fixes and cleanups.

  The separate EFI page tables feature got delayed twice already,
  because it's an intrusive change and we didn't feel confident about
  it - third time's the charm we hope!"

* 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (37 commits)
  x86/mm/pat: Fix boot crash when 1GB pages are not supported by the CPU
  x86/efi: Only map kernel text for EFI mixed mode
  x86/efi: Map EFI_MEMORY_{XP,RO} memory region bits to EFI page tables
  x86/mm/pat: Don't implicitly allow _PAGE_RW in kernel_map_pages_in_pgd()
  efi/arm*: Perform hardware compatibility check
  efi/arm64: Check for h/w support before booting a >4 KB granular kernel
  efi/arm: Check for LPAE support before booting a LPAE kernel
  efi/arm-init: Use read-only early mappings
  efi/efistub: Prevent __init annotations from being used
  arm64/vmlinux.lds.S: Handle .init.rodata.xxx and .init.bss sections
  efi/arm64: Drop __init annotation from handle_kernel_image()
  x86/mm/pat: Use _PAGE_GLOBAL bit for EFI page table mappings
  efi/runtime-wrappers: Run UEFI Runtime Services with interrupts enabled
  efi: Reformat GUID tables to follow the format in UEFI spec
  efi: Add Persistent Memory type name
  efi: Add NV memory attribute
  x86/efi: Show actual ending addresses in efi_print_memmap
  x86/efi/bgrt: Don't ignore the BGRT if the 'valid' bit is 0
  efivars: Use to_efivar_entry
  efi: Runtime-wrapper: Get rid of the rtc_lock spinlock
  ...

1  2 
arch/arm64/kernel/vmlinux.lds.S
arch/x86/include/asm/efi.h
arch/x86/kernel/vmlinux.lds.S
arch/x86/mm/pageattr.c
arch/x86/platform/efi/efi_stub_64.S
arch/x86/platform/efi/quirks.c
drivers/firmware/efi/libstub/arm-stub.c
drivers/firmware/efi/libstub/arm64-stub.c
drivers/firmware/efi/libstub/efistub.h
include/linux/efi.h

Simple merge
Simple merge
Simple merge
Simple merge
index 0df2dcc18404315661ef68517d5b3ca78cbd06bf,32020cb8bb08ce0e12ca0fbf6428cf81344e9054..92723aeae0f96d2d5def8aac111765d9683f4d7f
        mov %rsi, %cr0;                 \
        mov (%rsp), %rsp
  
-       /* stolen from gcc */
-       .macro FLUSH_TLB_ALL
-       movq %r15, efi_scratch(%rip)
-       movq %r14, efi_scratch+8(%rip)
-       movq %cr4, %r15
-       movq %r15, %r14
-       andb $0x7f, %r14b
-       movq %r14, %cr4
-       movq %r15, %cr4
-       movq efi_scratch+8(%rip), %r14
-       movq efi_scratch(%rip), %r15
-       .endm
-       .macro SWITCH_PGT
-       cmpb $0, efi_scratch+24(%rip)
-       je 1f
-       movq %r15, efi_scratch(%rip)            # r15
-       # save previous CR3
-       movq %cr3, %r15
-       movq %r15, efi_scratch+8(%rip)          # prev_cr3
-       movq efi_scratch+16(%rip), %r15         # EFI pgt
-       movq %r15, %cr3
-       1:
-       .endm
-       .macro RESTORE_PGT
-       cmpb $0, efi_scratch+24(%rip)
-       je 2f
-       movq efi_scratch+8(%rip), %r15
-       movq %r15, %cr3
-       movq efi_scratch(%rip), %r15
-       FLUSH_TLB_ALL
-       2:
-       .endm
  ENTRY(efi_call)
 +      FRAME_BEGIN
        SAVE_XMM
        mov (%rsp), %rax
        mov 8(%rax), %rax
        mov %r8, %r9
        mov %rcx, %r8
        mov %rsi, %rcx
-       SWITCH_PGT
        call *%rdi
-       RESTORE_PGT
        addq $48, %rsp
        RESTORE_XMM
 +      FRAME_END
        ret
  ENDPROC(efi_call)
-       .data
- ENTRY(efi_scratch)
-       .fill 3,8,0
-       .byte 0
-       .quad 0
Simple merge
index e0e6b74fef8f7becdef4c0481919ead298023250,047fc343665a64375d0e2ec292ac0f43419c8317..a90f6459f5c6d16535f026d1fcf54719b0a96878
  #include <linux/efi.h>
  #include <asm/efi.h>
  #include <asm/sections.h>
+ #include <asm/sysreg.h>
  
- efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg,
-                                       unsigned long *image_addr,
-                                       unsigned long *image_size,
-                                       unsigned long *reserve_addr,
-                                       unsigned long *reserve_size,
-                                       unsigned long dram_base,
-                                       efi_loaded_image_t *image)
 +#include "efistub.h"
 +
 +extern bool __nokaslr;
 +
+ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg)
+ {
+       u64 tg;
+       /* UEFI mandates support for 4 KB granularity, no need to check */
+       if (IS_ENABLED(CONFIG_ARM64_4K_PAGES))
+               return EFI_SUCCESS;
+       tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_TGRAN_SHIFT) & 0xf;
+       if (tg != ID_AA64MMFR0_TGRAN_SUPPORTED) {
+               if (IS_ENABLED(CONFIG_ARM64_64K_PAGES))
+                       pr_efi_err(sys_table_arg, "This 64 KB granular kernel is not supported by your CPU\n");
+               else
+                       pr_efi_err(sys_table_arg, "This 16 KB granular kernel is not supported by your CPU\n");
+               return EFI_UNSUPPORTED;
+       }
+       return EFI_SUCCESS;
+ }
+ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg,
+                                unsigned long *image_addr,
+                                unsigned long *image_size,
+                                unsigned long *reserve_addr,
+                                unsigned long *reserve_size,
+                                unsigned long dram_base,
+                                efi_loaded_image_t *image)
  {
        efi_status_t status;
        unsigned long kernel_size, kernel_memsize = 0;
index 5ed3d3f3816637cd10d007f381797320f0567305,981c6035ce09d88d6c22c01e3ccef72493335c5e..ee49cd23ee636d96b7d340ee74577ff8aef50822
@@@ -43,11 -53,6 +53,13 @@@ void efi_get_virtmap(efi_memory_desc_t 
                     unsigned long desc_size, efi_memory_desc_t *runtime_map,
                     int *count);
  
 +efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table,
 +                                unsigned long size, u8 *out);
 +
 +efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
 +                            unsigned long size, unsigned long align,
 +                            unsigned long *addr, unsigned long random_seed);
 +
+ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
  #endif
index 333d0ca6940f0214f37b69377716d58852240a3c,42be9c92fdf000d4a2a4c754b9e25b82a06ef80b..1626474567ac503d26802fcefbd9f147605e4449
@@@ -537,72 -536,89 +536,93 @@@ void efi_native_runtime_setup(void)
   *  EFI Configuration Table and GUID definitions
   */
  #define NULL_GUID \
-     EFI_GUID(  0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
+       EFI_GUID(0x00000000, 0x0000, 0x0000, \
+                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  
  #define MPS_TABLE_GUID    \
-     EFI_GUID(  0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
+       EFI_GUID(0xeb9d2d2f, 0x2d88, 0x11d3, \
+                0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  
  #define ACPI_TABLE_GUID    \
-     EFI_GUID(  0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
+       EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, \
+                0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  
  #define ACPI_20_TABLE_GUID    \
-     EFI_GUID(  0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
+       EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \
+                0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  
  #define SMBIOS_TABLE_GUID    \
-     EFI_GUID(  0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \
+                0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  
  #define SMBIOS3_TABLE_GUID    \
-     EFI_GUID(  0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 )
+       EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, \
+                0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94)
  
  #define SAL_SYSTEM_TABLE_GUID    \
-     EFI_GUID(  0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
+       EFI_GUID(0xeb9d2d32, 0x2d88, 0x11d3, \
+                0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
  
  #define HCDP_TABLE_GUID       \
-     EFI_GUID(  0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 )
+       EFI_GUID(0xf951938d, 0x620b, 0x42ef, \
+                0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98)
  
  #define UGA_IO_PROTOCOL_GUID \
-     EFI_GUID(  0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 )
+       EFI_GUID(0x61a4d49e, 0x6f68, 0x4f1b, \
+                0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2)
  
  #define EFI_GLOBAL_VARIABLE_GUID \
-     EFI_GUID(  0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c )
+       EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, \
+                0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c)
  
  #define UV_SYSTEM_TABLE_GUID \
-     EFI_GUID(  0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
+       EFI_GUID(0x3b13a7d4, 0x633e, 0x11dd, \
+                0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93)
  
  #define LINUX_EFI_CRASH_GUID \
-     EFI_GUID(  0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
+       EFI_GUID(0xcfc8fc79, 0xbe2e, 0x4ddc, \
+                0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0)
  
  #define LOADED_IMAGE_PROTOCOL_GUID \
-     EFI_GUID(  0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
+       EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
+                0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  
  #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
-     EFI_GUID(  0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a )
+       EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \
+                0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a)
  
  #define EFI_UGA_PROTOCOL_GUID \
-     EFI_GUID(  0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 )
+       EFI_GUID(0x982c298b, 0xf4fa, 0x41cb, \
+                0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39)
  
  #define EFI_PCI_IO_PROTOCOL_GUID \
-     EFI_GUID(  0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a )
+       EFI_GUID(0x4cf5b200, 0x68b8, 0x4ca5, \
+                0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a)
  
  #define EFI_FILE_INFO_ID \
-     EFI_GUID(  0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
+       EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \
+                0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  
  #define EFI_SYSTEM_RESOURCE_TABLE_GUID \
-     EFI_GUID(  0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 )
+       EFI_GUID(0xb122a263, 0x3661, 0x4f68, \
+                0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80)
  
  #define EFI_FILE_SYSTEM_GUID \
-     EFI_GUID(  0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
+       EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \
+                0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
  
  #define DEVICE_TREE_GUID \
-     EFI_GUID(  0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 )
+       EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \
+                0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0)
  
  #define EFI_PROPERTIES_TABLE_GUID \
-     EFI_GUID(  0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5 )
+       EFI_GUID(0x880aaca3, 0x4adc, 0x4a04, \
+                0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5)
  
 +#define EFI_RNG_PROTOCOL_GUID \
 +      EFI_GUID(0x3152bca5, 0xeade, 0x433d, \
 +               0x86, 0x2e, 0xc0, 0x1c, 0xdc, 0x29, 0x1f, 0x44)
 +
  typedef struct {
        efi_guid_t guid;
        u64 table;