x86/boot changes for v4.14
Linus,
Please pull the latest x86-boot-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-boot-for-linus
# HEAD: 0982adc746736a313dac9cb8cc936ca51ca3741a x86/boot/KASLR: Work around firmware bugs by excluding EFI_BOOT_SERVICES_* and EFI_LOADER_* from KASLR's choice
The main changes are KASL related fixes and cleanups: in particular we now exclude certain physical memory ranges as KASLR randomization targets that have proven to be unreliable (early-)RAM on some firmware versions.
out-of-topic modifications in x86-boot-for-linus:
---------------------------------------------------
drivers/firmware/efi/libstub/efi-stub-helper.c# 02e43c2dcd3b: efi: Introduce efi_early_mem
Thanks,
Ingo
------------------>
Baoquan He (5):
x86/boot/KASLR: Wrap e820 entries walking code into new function process_e820_entries() x86/boot/KASLR: Switch to pass struct mem_vector to process_e820_entry() x86/boot/KASLR: Rename process_e820_entry() into process_mem_region()
efi: Introduce efi_early_memdesc_ptr to get pointer to memmap descriptor x86/boot/KASLR: Prefer mirrored memory regions for the kernel physical address
Naoya Horiguchi (1):
x86/boot/KASLR: Work around firmware bugs by excluding EFI_BOOT_SERVICES_* and EFI_LOADER_* from KASLR's choice
arch/x86/boot/compressed/eboot.c | 2 +- arch/x86/boot/compressed/kaslr.c | 147 ++++++++++++++++++++----- drivers/firmware/efi/libstub/efi-stub-helper.c | 4 +- include/linux/efi.h | 22 ++++ 4 files changed, 145 insertions(+), 30 deletions(-)
arch/x86/boot/compressed/eboot.c +1 -1
@@ -767,7 +767,7 @@ static efi_status_t setup_e820(struct boot_params *params, m |= (u64 )efi->efi_memmap_hi <<32 ;#endif - d = (efi_memory_desc_t *)(m + (i * efi->efi_memdesc_size)); + d =efi_early_memdesc_ptr (m, efi->efi_memdesc_size, i);switch (d->type) {case EFI_RESERVED_TYPE :case EFI_RUNTIME_SERVICES_CODE :
arch/x86/boot/compressed/kaslr.c +120 -27
208 lines not on this page · raw message
drivers/firmware/efi/libstub/efi-stub-helper.c +2 -2
@@ -205,7 +205,7 @@ efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,unsigned long m = (unsigned long )map;u64 start, end; - desc = (efi_memory_desc_t *)(m + (i * desc_size)); + desc =efi_early_memdesc_ptr (m, desc_size, i);if (desc->type !=EFI_CONVENTIONAL_MEMORY )continue ;
@@ -298,7 +298,7 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,unsigned long m = (unsigned long )map;u64 start, end; - desc = (efi_memory_desc_t *)(m + (i * desc_size)); + desc =efi_early_memdesc_ptr (m, desc_size, i);if (desc->type !=EFI_CONVENTIONAL_MEMORY )continue ;
include/linux/efi.h +22 -0
@@ -1020,6 +1020,28 @@ extern int efi_memattr_init(void);extern int efi_memattr_apply_permissions (struct mm_struct *mm,efi_memattr_perm_setter fn); +/* +* efi_early_memdesc_ptr - get the n-th EFI memmap descriptor +* @map: the start of efi memmap +* @desc_size: the size of space for each EFI memmap descriptor +* @n: the index of efi memmap descriptor +* +* EFI boot service provides the GetMemoryMap() function to get a copy of the +* current memory map which is an array of memory descriptors, each of +* which describes a contiguous block of memory. It also gets the size of the +* map, and the size of each descriptor, etc. +* +* Note that per section 6.2 of UEFI Spec 2.6 Errata A, the returned size of +* each descriptor might not be equal to sizeof(efi_memory_memdesc_t), +* since efi_memory_memdesc_t may be extended in the future. Thus the OS +* MUST use the returned size of the descriptor to find the start of each +* efi_memory_memdesc_t in the memory map array. This should only be used +* during bootup since for_each_efi_memory_desc_xxx() is available after the +* kernel initializes the EFI subsystem to set up struct efi_memory_map. +*/ +#define efi_early_memdesc_ptr (map, desc_size, n) \ + (efi_memory_desc_t *)((void *)(map) + ((n) * (desc_size))) +/* Iterate through an efi_memory_map */ #define for_each_efi_memory_desc_in_map (m, md) \ for ((md) = (m)->map; \