Skip to content

Commit e621bd1

Browse files
hidaveIngo Molnar
authored andcommitted
i386: vmalloc size fix
Booting kernel with vmalloc=[any size<=16m] will oops on my pc (i386/1G memory). BUG_ON in arch/x86/mm/init_32.c triggered: BUG_ON((unsigned long)high_memory > VMALLOC_START); It's due to the vm area hole. In include/asm-x86/pgtable_32.h: #define VMALLOC_OFFSET (8 * 1024 * 1024) #define VMALLOC_START (((unsigned long)high_memory + 2 * VMALLOC_OFFSET - 1) \ & ~(VMALLOC_OFFSET - 1)) There's several related point: 1. MAXMEM : (-__PAGE_OFFSET - __VMALLOC_RESERVE). The space after VMALLOC_END is included as well, I set it to (VMALLOC_END - PAGE_OFFSET - __VMALLOC_RESERVE) 2. VMALLOC_OFFSET is not considered in __VMALLOC_RESERVE fixed by adding VMALLOC_OFFSET to it. 3. VMALLOC_START : (((unsigned long)high_memory + 2 * VMALLOC_OFFSET - 1) & ~(VMALLOC_OFFSET - 1)) So it's not always 8M, bigger than 8M possible. I set it to ((unsigned long)high_memory + VMALLOC_OFFSET) 4. the VMALLOC_RESERVE is an unused macro, so remove it here. Signed-off-by: Dave Young <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6a55617 commit e621bd1

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

arch/x86/mm/pgtable_32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ static int __init parse_vmalloc(char *arg)
123123
if (!arg)
124124
return -EINVAL;
125125

126-
__VMALLOC_RESERVE = memparse(arg, &arg);
126+
/* Add VMALLOC_OFFSET to the parsed value due to vm area guard hole*/
127+
__VMALLOC_RESERVE = memparse(arg, &arg) + VMALLOC_OFFSET;
127128
return 0;
128129
}
129130
early_param("vmalloc", parse_vmalloc);

include/asm-x86/page_32.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ extern int nx_enabled;
8989
extern unsigned int __VMALLOC_RESERVE;
9090
extern int sysctl_legacy_va_layout;
9191

92-
#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
93-
#define MAXMEM (-__PAGE_OFFSET - __VMALLOC_RESERVE)
94-
9592
extern void find_low_pfn_range(void);
9693
extern unsigned long init_memory_mapping(unsigned long start,
9794
unsigned long end);

include/asm-x86/pgtable_32.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ void paging_init(void);
5656
* area for the same reason. ;)
5757
*/
5858
#define VMALLOC_OFFSET (8 * 1024 * 1024)
59-
#define VMALLOC_START (((unsigned long)high_memory + 2 * VMALLOC_OFFSET - 1) \
60-
& ~(VMALLOC_OFFSET - 1))
59+
#define VMALLOC_START ((unsigned long)high_memory + VMALLOC_OFFSET)
6160
#ifdef CONFIG_X86_PAE
6261
#define LAST_PKMAP 512
6362
#else
@@ -73,6 +72,8 @@ void paging_init(void);
7372
# define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
7473
#endif
7574

75+
#define MAXMEM (VMALLOC_END - PAGE_OFFSET - __VMALLOC_RESERVE)
76+
7677
/*
7778
* Define this if things work differently on an i386 and an i486:
7879
* it will (on an i486) warn about kernel memory accesses that are

0 commit comments

Comments
 (0)