]> Pileus Git - ~andy/linux/commitdiff
Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 26 Jul 2012 20:13:25 +0000 (13:13 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 26 Jul 2012 20:13:25 +0000 (13:13 -0700)
Pul x86/efi changes from Ingo Molnar:
 "This tree adds an EFI bootloader handover protocol, which, once
  supported on the bootloader side, will make bootup faster and might
  result in simpler bootloaders.

  The other change activates the EFI wall clock time accessors on x86-64
  as well, instead of the legacy RTC readout."

* 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, efi: Handover Protocol
  x86-64/efi: Use EFI to deal with platform wall clock

1  2 
Documentation/x86/boot.txt
arch/x86/boot/header.S
arch/x86/mm/pageattr.c
init/main.c

index 473b32fd544e29a6bc1f3e9d357a4e13f3588597,c6539a4278b697978d3bc3c487c549167199fffb..9efceff51bfb1327a52e54af308a3077ccf7a02d
@@@ -54,6 -54,9 +54,9 @@@ Protocol 2.10:        (Kernel 2.6.31) Added a 
                beyond the kernel_alignment added, new init_size and
                pref_address fields.  Added extended boot loader IDs.
  
+ Protocol 2.11:        (Kernel 3.6) Added a field for offset of EFI handover
+               protocol entry point.
  **** MEMORY LAYOUT
  
  The traditional memory map for the kernel loader, used for Image or
@@@ -189,6 -192,7 +192,7 @@@ Offset     Proto   Name            Meanin
                                of struct setup_data
  0258/8        2.10+   pref_address    Preferred loading address
  0260/4        2.10+   init_size       Linear memory required during initialization
+ 0264/4        2.11+   handover_offset Offset of handover entry point
  
  (1) For backwards compatibility, if the setup_sects field contains 0, the
      real value is 4.
@@@ -363,8 -367,7 +367,8 @@@ Protocol:  2.00
    ext_loader_type <- 0x05
    ext_loader_ver  <- 0x23
  
 -  Assigned boot loader ids:
 +  Assigned boot loader ids (hexadecimal):
 +
        0  LILO                 (0x00 reserved for pre-2.00 bootloader)
        1  Loadlin
        2  bootsect-loader      (0x20, all other values reserved)
        C  Arcturus Networks uCbootloader
        E  Extended             (see ext_loader_type)
        F  Special              (0xFF = undefined)
 +       10  Reserved
 +       11  Minimal Linux Bootloader <http://sebastian-plotz.blogspot.de>
  
    Please contact <hpa@zytor.com> if you need a bootloader ID
    value assigned.
@@@ -693,6 -694,16 +697,16 @@@ Offset/size:     0x260/
    else
        runtime_start = pref_address
  
+ Field name:   handover_offset
+ Type:         read
+ Offset/size:  0x264/4
+   This field is the offset from the beginning of the kernel image to
+   the EFI handover protocol entry point. Boot loaders using the EFI
+   handover protocol to boot the kernel should jump to this offset.
+   See EFI HANDOVER PROTOCOL below for more details.
  
  **** THE IMAGE CHECKSUM
  
@@@ -1013,3 -1024,30 +1027,30 @@@ segment; __BOOS_CS must have execute/re
  must have read/write permission; CS must be __BOOT_CS and DS, ES, SS
  must be __BOOT_DS; interrupt must be disabled; %esi must hold the base
  address of the struct boot_params; %ebp, %edi and %ebx must be zero.
+ **** EFI HANDOVER PROTOCOL
+ This protocol allows boot loaders to defer initialisation to the EFI
+ boot stub. The boot loader is required to load the kernel/initrd(s)
+ from the boot media and jump to the EFI handover protocol entry point
+ which is hdr->handover_offset bytes from the beginning of
+ startup_{32,64}.
+ The function prototype for the handover entry point looks like this,
+     efi_main(void *handle, efi_system_table_t *table, struct boot_params *bp)
+ 'handle' is the EFI image handle passed to the boot loader by the EFI
+ firmware, 'table' is the EFI system table - these are the first two
+ arguments of the "handoff state" as described in section 2.3 of the
+ UEFI specification. 'bp' is the boot loader-allocated boot params.
+ The boot loader *must* fill out the following fields in bp,
+     o hdr.code32_start
+     o hdr.cmd_line_ptr
+     o hdr.cmdline_size
+     o hdr.ramdisk_image (if applicable)
+     o hdr.ramdisk_size  (if applicable)
+ All other fields should be zero.
diff --combined arch/x86/boot/header.S
index 9b9c6475b3614ccf976cbb5bb462ea9c6b3a52f0,097f4760faeae955ca12f06b50854058685d1883..b4e15dd6786a166b1fc16b0d24a1bb4f78a7295e
@@@ -94,10 -94,10 +94,10 @@@ bs_die
  
        .section ".bsdata", "a"
  bugger_off_msg:
 -      .ascii  "Direct booting from floppy is no longer supported.\r\n"
 -      .ascii  "Please use a boot loader program instead.\r\n"
 +      .ascii  "Direct floppy boot is not supported. "
 +      .ascii  "Use a boot loader program instead.\r\n"
        .ascii  "\n"
 -      .ascii  "Remove disk and press any key to reboot . . .\r\n"
 +      .ascii  "Remove disk and press any key to reboot ...\r\n"
        .byte   0
  
  #ifdef CONFIG_EFI_STUB
@@@ -111,7 -111,7 +111,7 @@@ coff_header
  #else
        .word   0x8664                          # x86-64
  #endif
 -      .word   2                               # nr_sections
 +      .word   3                               # nr_sections
        .long   0                               # TimeDateStamp
        .long   0                               # PointerToSymbolTable
        .long   1                               # NumberOfSymbols
@@@ -158,8 -158,8 +158,8 @@@ extra_header_fields
  #else
        .quad   0                               # ImageBase
  #endif
 -      .long   0x1000                          # SectionAlignment
 -      .long   0x200                           # FileAlignment
 +      .long   0x20                            # SectionAlignment
 +      .long   0x20                            # FileAlignment
        .word   0                               # MajorOperatingSystemVersion
        .word   0                               # MinorOperatingSystemVersion
        .word   0                               # MajorImageVersion
  
        # Section table
  section_table:
 -      .ascii  ".text"
 -      .byte   0
 +      #
 +      # The offset & size fields are filled in by build.c.
 +      #
 +      .ascii  ".setup"
        .byte   0
        .byte   0
        .long   0
  
        #
        # The EFI application loader requires a relocation section
 -      # because EFI applications must be relocatable. But since
 -      # we don't need the loader to fixup any relocs for us, we
 -      # just create an empty (zero-length) .reloc section header.
 +      # because EFI applications must be relocatable. The .reloc
 +      # offset & size fields are filled in by build.c.
        #
        .ascii  ".reloc"
        .byte   0
        .word   0                               # NumberOfRelocations
        .word   0                               # NumberOfLineNumbers
        .long   0x42100040                      # Characteristics (section flags)
 +
 +      #
 +      # The offset & size fields are filled in by build.c.
 +      #
 +      .ascii  ".text"
 +      .byte   0
 +      .byte   0
 +      .byte   0
 +      .long   0
 +      .long   0x0                             # startup_{32,64}
 +      .long   0                               # Size of initialized data
 +                                              # on disk
 +      .long   0x0                             # startup_{32,64}
 +      .long   0                               # PointerToRelocations
 +      .long   0                               # PointerToLineNumbers
 +      .word   0                               # NumberOfRelocations
 +      .word   0                               # NumberOfLineNumbers
 +      .long   0x60500020                      # Characteristics (section flags)
 +
  #endif /* CONFIG_EFI_STUB */
  
        # Kernel attributes; used by setup.  This is part 1 of the
@@@ -283,7 -263,7 +283,7 @@@ _start
        # Part 2 of the header, from the old setup.S
  
                .ascii  "HdrS"          # header signature
-               .word   0x020a          # header version number (>= 0x0105)
+               .word   0x020b          # header version number (>= 0x0105)
                                        # or else old loadlin-1.5 will fail)
                .globl realmode_swtch
  realmode_swtch:       .word   0, 0            # default_switch, SETUPSEG
@@@ -401,11 -381,20 +401,13 @@@ pref_address:           .quad LOAD_PHYSICAL_ADD
  #define INIT_SIZE VO_INIT_SIZE
  #endif
  init_size:            .long INIT_SIZE         # kernel initialization size
+ handover_offset:      .long 0x30              # offset to the handover
+                                               # protocol entry point
  
  # End of setup header #####################################################
  
        .section ".entrytext", "ax"
  start_of_setup:
 -#ifdef SAFE_RESET_DISK_CONTROLLER
 -# Reset the disk controller.
 -      movw    $0x0000, %ax            # Reset disk controller
 -      movb    $0x80, %dl              # All disks
 -      int     $0x13
 -#endif
 -
  # Force %es = %ds
        movw    %ds, %ax
        movw    %ax, %es
diff --combined arch/x86/mm/pageattr.c
index a718e0d23503fdc4bb3149d4ad5c7046458f2a57,ee09aca6399802aa1a66c28bca84dd4d46ae6d52..931930a96160b2de489b1dc9c955b676c7a250dd
@@@ -122,7 -122,7 +122,7 @@@ within(unsigned long addr, unsigned lon
  
  /**
   * clflush_cache_range - flush a cache range with clflush
 - * @addr:     virtual start address
 + * @vaddr:    virtual start address
   * @size:     number of bytes to flush
   *
   * clflush is an unordered instruction which needs fencing with mfence
@@@ -919,11 -919,13 +919,13 @@@ static int change_page_attr_set_clr(uns
  
        /*
         * On success we use clflush, when the CPU supports it to
-        * avoid the wbindv. If the CPU does not support it and in the
-        * error case we fall back to cpa_flush_all (which uses
-        * wbindv):
+        * avoid the wbindv. If the CPU does not support it, in the
+        * error case, and during early boot (for EFI) we fall back
+        * to cpa_flush_all (which uses wbinvd):
         */
-       if (!ret && cpu_has_clflush) {
+       if (early_boot_irqs_disabled)
+               __cpa_flush_all((void *)(long)cache);
+       else if (!ret && cpu_has_clflush) {
                if (cpa.flags & (CPA_PAGES_ARRAY | CPA_ARRAY)) {
                        cpa_flush_array(addr, numpages, cache,
                                        cpa.flags, pages);
diff --combined init/main.c
index 3f151f6c6da79cd2e28d55ba513aed39b2593923,eef30128321ab76d697121c1b74bf7d6ab32b52c..eb72a5c4c8443a39c661de690ec704db02728483
@@@ -68,7 -68,6 +68,7 @@@
  #include <linux/shmem_fs.h>
  #include <linux/slab.h>
  #include <linux/perf_event.h>
 +#include <linux/file.h>
  
  #include <asm/io.h>
  #include <asm/bugs.h>
@@@ -461,6 -460,10 +461,10 @@@ static void __init mm_init(void
        percpu_init_late();
        pgtable_cache_init();
        vmalloc_init();
+ #ifdef CONFIG_X86
+       if (efi_enabled)
+               efi_enter_virtual_mode();
+ #endif
  }
  
  asmlinkage void __init start_kernel(void)
        parse_early_param();
        parse_args("Booting kernel", static_command_line, __start___param,
                   __stop___param - __start___param,
 -                 0, 0, &unknown_bootoption);
 +                 -1, -1, &unknown_bootoption);
  
        jump_label_init();
  
        calibrate_delay();
        pidmap_init();
        anon_vma_init();
- #ifdef CONFIG_X86
-       if (efi_enabled)
-               efi_enter_virtual_mode();
- #endif
        thread_info_cache_init();
        cred_init();
        fork_init(totalram_pages);
@@@ -756,8 -755,13 +756,8 @@@ static void __init do_initcalls(void
  {
        int level;
  
 -      for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++) {
 -              pr_info("initlevel:%d=%s, %d registered initcalls\n",
 -                      level, initcall_level_names[level],
 -                      (int) (initcall_levels[level+1]
 -                              - initcall_levels[level]));
 +      for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
                do_initcall_level(level);
 -      }
  }
  
  /*
@@@ -805,8 -809,8 +805,8 @@@ static noinline int init_post(void
        system_state = SYSTEM_RUNNING;
        numa_default_policy();
  
 -
        current->signal->flags |= SIGNAL_UNKILLABLE;
 +      flush_delayed_fput();
  
        if (ramdisk_execute_command) {
                run_init_process(ramdisk_execute_command);