Skip to content

Commit

Permalink
Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/lin…
Browse files Browse the repository at this point in the history
…ux/kernel/git/tip/tip

Pull x86 boot updates from Ingo Molnar:
 "The biggest changes in this cycle were:

   - reworking of the e820 code: separate in-kernel and boot-ABI data
     structures and apply a whole range of cleanups to the kernel side.

     No change in functionality.

   - enable KASLR by default: it's used by all major distros and it's
     out of the experimental stage as well.

   - ... misc fixes and cleanups"

* 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (63 commits)
  x86/KASLR: Fix kexec kernel boot crash when KASLR randomization fails
  x86/reboot: Turn off KVM when halting a CPU
  x86/boot: Fix BSS corruption/overwrite bug in early x86 kernel startup
  x86: Enable KASLR by default
  boot/param: Move next_arg() function to lib/cmdline.c for later reuse
  x86/boot: Fix Sparse warning by including required header file
  x86/boot/64: Rename start_cpu()
  x86/xen: Update e820 table handling to the new core x86 E820 code
  x86/boot: Fix pr_debug() API braindamage
  xen, x86/headers: Add <linux/device.h> dependency to <asm/xen/page.h>
  x86/boot/e820: Simplify e820__update_table()
  x86/boot/e820: Separate the E820 ABI structures from the in-kernel structures
  x86/boot/e820: Fix and clean up e820_type switch() statements
  x86/boot/e820: Rename the remaining E820 APIs to the e820__*() prefix
  x86/boot/e820: Remove unnecessary #include's
  x86/boot/e820: Rename e820_mark_nosave_regions() to e820__register_nosave_regions()
  x86/boot/e820: Rename e820_reserve_resources*() to e820__reserve_resources*()
  x86/boot/e820: Use bool in query APIs
  x86/boot/e820: Document e820__reserve_setup_data()
  x86/boot/e820: Clean up __e820__update_table() et al
  ...
  • Loading branch information
torvalds committed May 2, 2017
2 parents 3dee9fb + da63b6b commit 16b7629
Show file tree
Hide file tree
Showing 75 changed files with 1,127 additions and 944 deletions.
6 changes: 3 additions & 3 deletions Documentation/x86/zero-page.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ Offset Proto Name Meaning
1C0/020 ALL efi_info EFI 32 information (struct efi_info)
1E0/004 ALL alk_mem_k Alternative mem check, in KB
1E4/004 ALL scratch Scratch field for the kernel setup code
1E8/001 ALL e820_entries Number of entries in e820_map (below)
1E8/001 ALL e820_entries Number of entries in e820_table (below)
1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below)
1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer
(below)
1EB/001 ALL kbd_status Numlock is enabled
1EC/001 ALL secure_boot Secure boot is enabled in the firmware
1EF/001 ALL sentinel Used to detect broken bootloaders
290/040 ALL edd_mbr_sig_buffer EDD MBR signatures
2D0/A00 ALL e820_map E820 memory map table
(array of struct e820entry)
2D0/A00 ALL e820_table E820 memory map table
(array of struct e820_entry)
D00/1EC ALL eddbuf EDD data (array of struct edd_info)
6 changes: 3 additions & 3 deletions arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ config RELOCATABLE
config RANDOMIZE_BASE
bool "Randomize the address of the kernel image (KASLR)"
depends on RELOCATABLE
default n
default y
---help---
In support of Kernel Address Space Layout Randomization (KASLR),
this randomizes the physical address at which the kernel image
Expand Down Expand Up @@ -2003,7 +2003,7 @@ config RANDOMIZE_BASE
theoretically possible, but the implementations are further
limited due to memory layouts.

If unsure, say N.
If unsure, say Y.

# Relocation on x86 needs some additional build support
config X86_NEED_RELOCS
Expand Down Expand Up @@ -2052,7 +2052,7 @@ config RANDOMIZE_MEMORY
configuration have in average 30,000 different possible virtual
addresses for each memory section.

If unsure, say N.
If unsure, say Y.

config RANDOMIZE_MEMORY_PHYSICAL_PADDING
hex "Physical memory mapping padding" if EXPERT
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/boot/boot.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef BOOT_BOOT_H
#define BOOT_BOOT_H

#define STACK_SIZE 512 /* Minimum number of bytes for stack */
#define STACK_SIZE 1024 /* Minimum number of bytes for stack */

#ifndef __ASSEMBLY__

Expand Down
44 changes: 23 additions & 21 deletions arch/x86/boot/compressed/eboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

#include <linux/efi.h>
#include <linux/pci.h>

#include <asm/efi.h>
#include <asm/e820/types.h>
#include <asm/setup.h>
#include <asm/desc.h>

Expand Down Expand Up @@ -729,7 +731,7 @@ static void add_e820ext(struct boot_params *params,
unsigned long size;

e820ext->type = SETUP_E820_EXT;
e820ext->len = nr_entries * sizeof(struct e820entry);
e820ext->len = nr_entries * sizeof(struct boot_e820_entry);
e820ext->next = 0;

data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
Expand All @@ -746,9 +748,9 @@ static void add_e820ext(struct boot_params *params,
static efi_status_t setup_e820(struct boot_params *params,
struct setup_data *e820ext, u32 e820ext_size)
{
struct e820entry *e820_map = &params->e820_map[0];
struct boot_e820_entry *entry = params->e820_table;
struct efi_info *efi = &params->efi_info;
struct e820entry *prev = NULL;
struct boot_e820_entry *prev = NULL;
u32 nr_entries;
u32 nr_desc;
int i;
Expand All @@ -773,31 +775,31 @@ static efi_status_t setup_e820(struct boot_params *params,
case EFI_MEMORY_MAPPED_IO:
case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
case EFI_PAL_CODE:
e820_type = E820_RESERVED;
e820_type = E820_TYPE_RESERVED;
break;

case EFI_UNUSABLE_MEMORY:
e820_type = E820_UNUSABLE;
e820_type = E820_TYPE_UNUSABLE;
break;

case EFI_ACPI_RECLAIM_MEMORY:
e820_type = E820_ACPI;
e820_type = E820_TYPE_ACPI;
break;

case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
e820_type = E820_RAM;
e820_type = E820_TYPE_RAM;
break;

case EFI_ACPI_MEMORY_NVS:
e820_type = E820_NVS;
e820_type = E820_TYPE_NVS;
break;

case EFI_PERSISTENT_MEMORY:
e820_type = E820_PMEM;
e820_type = E820_TYPE_PMEM;
break;

default:
Expand All @@ -811,26 +813,26 @@ static efi_status_t setup_e820(struct boot_params *params,
continue;
}

if (nr_entries == ARRAY_SIZE(params->e820_map)) {
u32 need = (nr_desc - i) * sizeof(struct e820entry) +
if (nr_entries == ARRAY_SIZE(params->e820_table)) {
u32 need = (nr_desc - i) * sizeof(struct e820_entry) +
sizeof(struct setup_data);

if (!e820ext || e820ext_size < need)
return EFI_BUFFER_TOO_SMALL;

/* boot_params map full, switch to e820 extended */
e820_map = (struct e820entry *)e820ext->data;
entry = (struct boot_e820_entry *)e820ext->data;
}

e820_map->addr = d->phys_addr;
e820_map->size = d->num_pages << PAGE_SHIFT;
e820_map->type = e820_type;
prev = e820_map++;
entry->addr = d->phys_addr;
entry->size = d->num_pages << PAGE_SHIFT;
entry->type = e820_type;
prev = entry++;
nr_entries++;
}

if (nr_entries > ARRAY_SIZE(params->e820_map)) {
u32 nr_e820ext = nr_entries - ARRAY_SIZE(params->e820_map);
if (nr_entries > ARRAY_SIZE(params->e820_table)) {
u32 nr_e820ext = nr_entries - ARRAY_SIZE(params->e820_table);

add_e820ext(params, e820ext, nr_e820ext);
nr_entries -= nr_e820ext;
Expand All @@ -848,7 +850,7 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
unsigned long size;

size = sizeof(struct setup_data) +
sizeof(struct e820entry) * nr_desc;
sizeof(struct e820_entry) * nr_desc;

if (*e820ext) {
efi_call_early(free_pool, *e820ext);
Expand Down Expand Up @@ -884,9 +886,9 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,

if (first) {
nr_desc = *map->buff_size / *map->desc_size;
if (nr_desc > ARRAY_SIZE(p->boot_params->e820_map)) {
if (nr_desc > ARRAY_SIZE(p->boot_params->e820_table)) {
u32 nr_e820ext = nr_desc -
ARRAY_SIZE(p->boot_params->e820_map);
ARRAY_SIZE(p->boot_params->e820_table);

status = alloc_e820ext(nr_e820ext, &p->e820ext,
&p->e820ext_size);
Expand Down
17 changes: 12 additions & 5 deletions arch/x86/boot/compressed/kaslr.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static unsigned long slots_fetch_random(void)
return 0;
}

static void process_e820_entry(struct e820entry *entry,
static void process_e820_entry(struct boot_e820_entry *entry,
unsigned long minimum,
unsigned long image_size)
{
Expand All @@ -435,7 +435,7 @@ static void process_e820_entry(struct e820entry *entry,
unsigned long start_orig;

/* Skip non-RAM entries. */
if (entry->type != E820_RAM)
if (entry->type != E820_TYPE_RAM)
return;

/* On 32-bit, ignore entries entirely above our maximum. */
Expand Down Expand Up @@ -518,7 +518,7 @@ static unsigned long find_random_phys_addr(unsigned long minimum,

/* Verify potential e820 positions, appending to slots list. */
for (i = 0; i < boot_params->e820_entries; i++) {
process_e820_entry(&boot_params->e820_map[i], minimum,
process_e820_entry(&boot_params->e820_table[i], minimum,
image_size);
if (slot_area_index == MAX_SLOT_AREA) {
debug_putstr("Aborted e820 scan (slot_areas full)!\n");
Expand Down Expand Up @@ -597,10 +597,17 @@ void choose_random_location(unsigned long input,
add_identity_map(random_addr, output_size);
*output = random_addr;
}

/*
* This loads the identity mapping page table.
* This should only be done if a new physical address
* is found for the kernel, otherwise we should keep
* the old page table to make it be like the "nokaslr"
* case.
*/
finalize_identity_maps();
}

/* This actually loads the identity pagetable on x86_64. */
finalize_identity_maps();

/* Pick random virtual address starting from LOAD_PHYSICAL_ADDR. */
if (IS_ENABLED(CONFIG_X86_64))
Expand Down
1 change: 0 additions & 1 deletion arch/x86/boot/header.S
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <asm/segment.h>
#include <generated/utsrelease.h>
#include <asm/boot.h>
#include <asm/e820.h>
#include <asm/page_types.h>
#include <asm/setup.h>
#include <asm/bootparam.h>
Expand Down
6 changes: 3 additions & 3 deletions arch/x86/boot/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ static int detect_memory_e820(void)
{
int count = 0;
struct biosregs ireg, oreg;
struct e820entry *desc = boot_params.e820_map;
static struct e820entry buf; /* static so it is zeroed */
struct boot_e820_entry *desc = boot_params.e820_table;
static struct boot_e820_entry buf; /* static so it is zeroed */

initregs(&ireg);
ireg.ax = 0xe820;
Expand Down Expand Up @@ -66,7 +66,7 @@ static int detect_memory_e820(void)

*desc++ = buf;
count++;
} while (ireg.ebx && count < ARRAY_SIZE(boot_params.e820_map));
} while (ireg.ebx && count < ARRAY_SIZE(boot_params.e820_table));

return boot_params.e820_entries = count;
}
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/configs/i386_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ CONFIG_EFI=y
CONFIG_HZ_1000=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_RANDOMIZE_BASE=y
CONFIG_RANDOMIZE_MEMORY=y
# CONFIG_COMPAT_VDSO is not set
CONFIG_HIBERNATION=y
CONFIG_PM_DEBUG=y
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/configs/x86_64_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ CONFIG_EFI=y
CONFIG_HZ_1000=y
CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_RANDOMIZE_BASE=y
CONFIG_RANDOMIZE_MEMORY=y
# CONFIG_COMPAT_VDSO is not set
CONFIG_HIBERNATION=y
CONFIG_PM_DEBUG=y
Expand Down
2 changes: 2 additions & 0 deletions arch/x86/include/asm/acpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ extern u8 acpi_sci_flags;
extern int acpi_sci_override_gsi;
void acpi_pic_sci_set_trigger(unsigned int, u16);

struct device;

extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi,
int trigger, int polarity);
extern void (*__acpi_unregister_gsi)(u32 gsi);
Expand Down
73 changes: 0 additions & 73 deletions arch/x86/include/asm/e820.h

This file was deleted.

Loading

0 comments on commit 16b7629

Please sign in to comment.