x86/boot changes for v4.11
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: 5773ebfee729acf93b330664eab4c8d77edc2193 x86/kconfig: Remove misleading note regarding hibernation and KASLR
Misc updates: fix e820 error handling, convert page table setup code from assembly to C, fix kexec environment bug, plus small cleanups.
Thanks,
Ingo
------------------>
Arnd Bergmann (1):
x86/e820/32: Fix e820_search_gap() error handling on x86-32
Boris Ostrovsky (1):
x86/boot/32: Convert the 32-bit pgtable setup code from assembly to C
Dave Jiang (1):
x86/boot: Fix KASLR and memmap= collision
Niklas Cassel (1):
x86/kconfig: Remove misleading note regarding hibernation and KASLR
Wei Yang (1):
x86/e820: Make e820_search_gap() static and remove unused variables
arch/x86/Kconfig | 4 -- arch/x86/boot/boot.h | 1 + arch/x86/boot/compressed/kaslr.c | 140 +++++++++++++++++++++++++++++++++++++- arch/x86/boot/string.c | 13 ++++ arch/x86/include/asm/e820.h | 2 - arch/x86/include/asm/pgtable_32.h | 32 +++++++++ arch/x86/kernel/e820.c | 22 +++--- arch/x86/kernel/head32.c | 62 +++++++++++++++++ arch/x86/kernel/head_32.S | 121 ++------------------------------ 9 files changed, 261 insertions(+), 136 deletions(-)
arch/x86/Kconfig +0 -4
@@ -1994,10 +1994,6 @@ config RANDOMIZE_BASE theoretically possible, but the implementations are further limited due to memory layouts. - If CONFIG_HIBERNATE is also enabled, KASLR is disabled at boot - time. To enable it, boot with "kaslr" on the kernel command - line (which will also disable hibernation). - If unsure, say N. # Relocation on x86 needs some additional build support
arch/x86/boot/boot.h +1 -0
@@ -333,6 +333,7 @@ size_t strnlen(const char *s, size_t maxlen);unsigned int atou (const char *s);unsigned long long simple_strtoull (const char *cp,char **endp,unsigned int base);size_t strlen (const char *s); +char *strchr (const char *s,int c);/* tty.c */ void puts (const char *);
arch/x86/boot/compressed/kaslr.c +137 -3
183 lines not on this page · raw message
arch/x86/boot/string.c +13 -0
@@ -156,3 +156,16 @@ char *strstr(const char *s1, const char *s2) }return NULL ; } + +/** +* strchr - Find the first occurrence of the character c in the string s. +* @s: the string to be searched +* @c: the character to search for +*/ +char *strchr (const char *s,int c) +{ +while (*s != (char )c) +if (*s++ =='\0' ) +return NULL ; +return (char *)s; +}
arch/x86/include/asm/e820.h +0 -2
@@ -30,8 +30,6 @@ extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype);extern void update_e820 (void );extern void e820_setup_gap (void ); -extern int e820_search_gap (unsigned long *gapstart,unsigned long *gapsize, -unsigned long start_addr,unsigned long long end_addr);struct setup_data ;extern void parse_e820_ext (u64 phys_addr,u32 data_len);
arch/x86/include/asm/pgtable_32.h +32 -0
@@ -27,6 +27,7 @@ struct vm_area_struct;extern pgd_t swapper_pg_dir[1024 ];extern pgd_t initial_page_table[1024 ]; +extern pmd_t initial_pg_pmd[];static inline void pgtable_cache_init (void ) { }static inline void check_pgt_cache (void ) { }
@@ -75,4 +76,35 @@ do { \#define kern_addr_valid (kaddr) (0)#endif +/* +* This is how much memory in addition to the memory covered up to +* and including _end we need mapped initially. +* We need: +* (KERNEL_IMAGE_SIZE/4096) / 1024 pages (worst case, non PAE) +* (KERNEL_IMAGE_SIZE/4096) / 512 + 4 pages (worst case for PAE) +* +* Modulo rounding, each megabyte assigned here requires a kilobyte of +* memory, which is currently unreclaimed. +* +* This should be a multiple of a page. +* +* KERNEL_IMAGE_SIZE should be greater than pa(_end) +* and small than max_low_pfn, otherwise will waste some page table entries +*/ +#if PTRS_PER_PMD >1 +#define PAGE_TABLE_SIZE (pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD) +#else +#define PAGE_TABLE_SIZE (pages) ((pages) / PTRS_PER_PGD) +#endif + +/* +* Number of possible pages in the lowmem region. +* +* We shift 2 by 31 instead of 1 by 32 to the left in order to avoid a +* gas warning about overflowing shift count when gas has been compiled +* with only a host target support using a 32-bit type for internal +* representation. +*/ +#define LOWMEM_PAGES ((((2<<31) - __PAGE_OFFSET) >> PAGE_SHIFT)) +#endif /* _ASM_X86_PGTABLE_32_H */
arch/x86/kernel/e820.c +9 -13
@@ -580,24 +580,19 @@ static void __init update_e820_saved(void) }#define MAX_GAP_END 0x100000000ull/* -* Search for a gap in the e820 memory space from start_addr to end_addr. +* Search for a gap in the e820 memory space from 0 to MAX_GAP_END. */ -__init int e820_search_gap (unsigned long *gapstart,unsigned long *gapsize, -unsigned long start_addr,unsigned long long end_addr) +static int __init e820_search_gap (unsigned long *gapstart, +unsigned long *gapsize) { -unsigned long long last; +unsigned long long last =MAX_GAP_END ;int i = e820->nr_map;int found =0 ; - last = (end_addr && end_addr <MAX_GAP_END ) ? end_addr :MAX_GAP_END ; -while (--i >=0 ) {unsigned long long start = e820->map[i].addr;unsigned long long end = start + e820->map[i].size; -if (end < start_addr) -continue ; -/* * Since "last" is at most 4GB, we know we'll * fit in 32 bits if this condition is true
@@ -628,18 +623,19 @@ __init void e820_setup_gap(void)unsigned long gapstart, gapsize;int found; - gapstart =0x10000000 ; gapsize =0x400000 ; - found =e820_search_gap (&gapstart, &gapsize,0 ,MAX_GAP_END ); + found =e820_search_gap (&gapstart, &gapsize); -#ifdef CONFIG_X86_64 if (!found) { +#ifdef CONFIG_X86_64 gapstart = (max_pfn <<PAGE_SHIFT ) +1024 *1024 ;printk (KERN_ERR "e820: cannot find a gap in the 32bit address range\n" "e820: PCI devices with unassigned 32bit BARs may break!\n" ); - } +#else + gapstart =0x10000000 ;#endif + }/* * e820_reserve_resources_late protect stolen RAM already
arch/x86/kernel/head32.c +62 -0
65 lines not on this page · raw message
arch/x86/kernel/head_32.S +7 -114
153 lines not on this page · raw message