diff options
| -rw-r--r-- | Documentation/x86/zero-page.txt | 2 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/Makefile | 1 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/aslr.c | 34 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/efi_stub_64.S | 25 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/efi_thunk_64.S | 196 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/misc.c | 3 | ||||
| -rw-r--r-- | arch/x86/boot/compressed/misc.h | 6 | ||||
| -rw-r--r-- | arch/x86/include/asm/apic.h | 8 | ||||
| -rw-r--r-- | arch/x86/include/asm/page_types.h | 2 | ||||
| -rw-r--r-- | arch/x86/include/uapi/asm/bootparam.h | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel.c | 5 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel_early.c | 6 | ||||
| -rw-r--r-- | arch/x86/kernel/module.c | 10 | ||||
| -rw-r--r-- | arch/x86/kernel/setup.c | 22 | ||||
| -rw-r--r-- | arch/x86/mm/init.c | 28 | ||||
| -rw-r--r-- | arch/x86/mm/mmap.c | 6 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_stub_64.S | 161 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi_thunk_64.S | 121 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-helper.c | 16 | ||||
| -rw-r--r-- | fs/binfmt_elf.c | 5 |
20 files changed, 419 insertions, 239 deletions
diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt index 199f453cb4de..82fbdbc1e0b0 100644 --- a/Documentation/x86/zero-page.txt +++ b/Documentation/x86/zero-page.txt | |||
| @@ -3,7 +3,7 @@ protocol of kernel. These should be filled by bootloader or 16-bit | |||
| 3 | real-mode setup code of the kernel. References/settings to it mainly | 3 | real-mode setup code of the kernel. References/settings to it mainly |
| 4 | are in: | 4 | are in: |
| 5 | 5 | ||
| 6 | arch/x86/include/asm/bootparam.h | 6 | arch/x86/include/uapi/asm/bootparam.h |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | Offset Proto Name Meaning | 9 | Offset Proto Name Meaning |
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 843feb3eb20b..0a291cdfaf77 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile | |||
| @@ -51,6 +51,7 @@ $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone | |||
| 51 | 51 | ||
| 52 | vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ | 52 | vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \ |
| 53 | $(objtree)/drivers/firmware/efi/libstub/lib.a | 53 | $(objtree)/drivers/firmware/efi/libstub/lib.a |
| 54 | vmlinux-objs-$(CONFIG_EFI_MIXED) += $(obj)/efi_thunk_$(BITS).o | ||
| 54 | 55 | ||
| 55 | $(obj)/vmlinux: $(vmlinux-objs-y) FORCE | 56 | $(obj)/vmlinux: $(vmlinux-objs-y) FORCE |
| 56 | $(call if_changed,ld) | 57 | $(call if_changed,ld) |
diff --git a/arch/x86/boot/compressed/aslr.c b/arch/x86/boot/compressed/aslr.c index bb1376381985..7083c16cccba 100644 --- a/arch/x86/boot/compressed/aslr.c +++ b/arch/x86/boot/compressed/aslr.c | |||
| @@ -14,6 +14,13 @@ | |||
| 14 | static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@" | 14 | static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@" |
| 15 | LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION; | 15 | LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION; |
| 16 | 16 | ||
| 17 | struct kaslr_setup_data { | ||
| 18 | __u64 next; | ||
| 19 | __u32 type; | ||
| 20 | __u32 len; | ||
| 21 | __u8 data[1]; | ||
| 22 | } kaslr_setup_data; | ||
| 23 | |||
| 17 | #define I8254_PORT_CONTROL 0x43 | 24 | #define I8254_PORT_CONTROL 0x43 |
| 18 | #define I8254_PORT_COUNTER0 0x40 | 25 | #define I8254_PORT_COUNTER0 0x40 |
| 19 | #define I8254_CMD_READBACK 0xC0 | 26 | #define I8254_CMD_READBACK 0xC0 |
| @@ -295,7 +302,29 @@ static unsigned long find_random_addr(unsigned long minimum, | |||
| 295 | return slots_fetch_random(); | 302 | return slots_fetch_random(); |
| 296 | } | 303 | } |
| 297 | 304 | ||
| 298 | unsigned char *choose_kernel_location(unsigned char *input, | 305 | static void add_kaslr_setup_data(struct boot_params *params, __u8 enabled) |
| 306 | { | ||
| 307 | struct setup_data *data; | ||
| 308 | |||
| 309 | kaslr_setup_data.type = SETUP_KASLR; | ||
| 310 | kaslr_setup_data.len = 1; | ||
| 311 | kaslr_setup_data.next = 0; | ||
| 312 | kaslr_setup_data.data[0] = enabled; | ||
| 313 | |||
| 314 | data = (struct setup_data *)(unsigned long)params->hdr.setup_data; | ||
| 315 | |||
| 316 | while (data && data->next) | ||
| 317 | data = (struct setup_data *)(unsigned long)data->next; | ||
| 318 | |||
| 319 | if (data) | ||
| 320 | data->next = (unsigned long)&kaslr_setup_data; | ||
| 321 | else | ||
| 322 | params->hdr.setup_data = (unsigned long)&kaslr_setup_data; | ||
| 323 | |||
| 324 | } | ||
| 325 | |||
| 326 | unsigned char *choose_kernel_location(struct boot_params *params, | ||
| 327 | unsigned char *input, | ||
| 299 | unsigned long input_size, | 328 | unsigned long input_size, |
| 300 | unsigned char *output, | 329 | unsigned char *output, |
| 301 | unsigned long output_size) | 330 | unsigned long output_size) |
| @@ -306,14 +335,17 @@ unsigned char *choose_kernel_location(unsigned char *input, | |||
| 306 | #ifdef CONFIG_HIBERNATION | 335 | #ifdef CONFIG_HIBERNATION |
| 307 | if (!cmdline_find_option_bool("kaslr")) { | 336 | if (!cmdline_find_option_bool("kaslr")) { |
| 308 | debug_putstr("KASLR disabled by default...\n"); | 337 | debug_putstr("KASLR disabled by default...\n"); |
| 338 | add_kaslr_setup_data(params, 0); | ||
| 309 | goto out; | 339 | goto out; |
| 310 | } | 340 | } |
| 311 | #else | 341 | #else |
| 312 | if (cmdline_find_option_bool("nokaslr")) { | 342 | if (cmdline_find_option_bool("nokaslr")) { |
| 313 | debug_putstr("KASLR disabled by cmdline...\n"); | 343 | debug_putstr("KASLR disabled by cmdline...\n"); |
| 344 | add_kaslr_setup_data(params, 0); | ||
| 314 | goto out; | 345 | goto out; |
| 315 | } | 346 | } |
| 316 | #endif | 347 | #endif |
| 348 | add_kaslr_setup_data(params, 1); | ||
| 317 | 349 | ||
| 318 | /* Record the various known unsafe memory ranges. */ | 350 | /* Record the various known unsafe memory ranges. */ |
| 319 | mem_avoid_init((unsigned long)input, input_size, | 351 | mem_avoid_init((unsigned long)input, input_size, |
diff --git a/arch/x86/boot/compressed/efi_stub_64.S b/arch/x86/boot/compressed/efi_stub_64.S index 7ff3632806b1..99494dff2113 100644 --- a/arch/x86/boot/compressed/efi_stub_64.S +++ b/arch/x86/boot/compressed/efi_stub_64.S | |||
| @@ -3,28 +3,3 @@ | |||
| 3 | #include <asm/processor-flags.h> | 3 | #include <asm/processor-flags.h> |
| 4 | 4 | ||
| 5 | #include "../../platform/efi/efi_stub_64.S" | 5 | #include "../../platform/efi/efi_stub_64.S" |
| 6 | |||
| 7 | #ifdef CONFIG_EFI_MIXED | ||
| 8 | .code64 | ||
| 9 | .text | ||
| 10 | ENTRY(efi64_thunk) | ||
| 11 | push %rbp | ||
| 12 | push %rbx | ||
| 13 | |||
| 14 | subq $16, %rsp | ||
| 15 | leaq efi_exit32(%rip), %rax | ||
| 16 | movl %eax, 8(%rsp) | ||
| 17 | leaq efi_gdt64(%rip), %rax | ||
| 18 | movl %eax, 4(%rsp) | ||
| 19 | movl %eax, 2(%rax) /* Fixup the gdt base address */ | ||
| 20 | leaq efi32_boot_gdt(%rip), %rax | ||
| 21 | movl %eax, (%rsp) | ||
| 22 | |||
| 23 | call __efi64_thunk | ||
| 24 | |||
| 25 | addq $16, %rsp | ||
| 26 | pop %rbx | ||
| 27 | pop %rbp | ||
| 28 | ret | ||
| 29 | ENDPROC(efi64_thunk) | ||
| 30 | #endif /* CONFIG_EFI_MIXED */ | ||
diff --git a/arch/x86/boot/compressed/efi_thunk_64.S b/arch/x86/boot/compressed/efi_thunk_64.S new file mode 100644 index 000000000000..630384a4c14a --- /dev/null +++ b/arch/x86/boot/compressed/efi_thunk_64.S | |||
| @@ -0,0 +1,196 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014, 2015 Intel Corporation; author Matt Fleming | ||
| 3 | * | ||
| 4 | * Early support for invoking 32-bit EFI services from a 64-bit kernel. | ||
| 5 | * | ||
| 6 | * Because this thunking occurs before ExitBootServices() we have to | ||
| 7 | * restore the firmware's 32-bit GDT before we make EFI serivce calls, | ||
| 8 | * since the firmware's 32-bit IDT is still currently installed and it | ||
| 9 | * needs to be able to service interrupts. | ||
| 10 | * | ||
| 11 | * On the plus side, we don't have to worry about mangling 64-bit | ||
| 12 | * addresses into 32-bits because we're executing with an identify | ||
| 13 | * mapped pagetable and haven't transitioned to 64-bit virtual addresses | ||
| 14 | * yet. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include <linux/linkage.h> | ||
| 18 | #include <asm/msr.h> | ||
| 19 | #include <asm/page_types.h> | ||
| 20 | #include <asm/processor-flags.h> | ||
| 21 | #include <asm/segment.h> | ||
| 22 | |||
| 23 | .code64 | ||
| 24 | .text | ||
| 25 | ENTRY(efi64_thunk) | ||
| 26 | push %rbp | ||
| 27 | push %rbx | ||
| 28 | |||
| 29 | subq $8, %rsp | ||
| 30 | leaq efi_exit32(%rip), %rax | ||
