Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138766
b: refs/heads/master
c: 93dbda7
h: refs/heads/master
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and H. Peter Anvin committed Mar 14, 2009
1 parent d0cf212 commit 463e676
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b9719a4d9cfa5d46fa6a1eb3e3fc2238e7981e4d
refs/heads/master: 93dbda7cbcd70a0bd1a99f39f44a9ccde8ab9040
7 changes: 7 additions & 0 deletions trunk/arch/x86/include/asm/sections.h
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#ifndef _ASM_X86_SECTIONS_H
#define _ASM_X86_SECTIONS_H

#include <asm-generic/sections.h>

extern char __brk_base[], __brk_limit[];

#endif /* _ASM_X86_SECTIONS_H */
4 changes: 4 additions & 0 deletions trunk/arch/x86/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ extern struct boot_params boot_params;
*/
#define LOWMEMSIZE() (0x9f000)

/* exceedingly early brk-like allocator */
extern unsigned long _brk_end;
void *extend_brk(size_t size, size_t align);

#ifdef __i386__

void __init i386_start_kernel(void);
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/head32.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void __init i386_start_kernel(void)
{
reserve_trampoline_memory();

reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");

#ifdef CONFIG_BLK_DEV_INITRD
/* Reserve INITRD */
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/x86/kernel/head64.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void __init x86_64_start_reservations(char *real_mode_data)

reserve_trampoline_memory();

reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");

#ifdef CONFIG_BLK_DEV_INITRD
/* Reserve INITRD */
Expand Down
39 changes: 34 additions & 5 deletions trunk/arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@

unsigned int boot_cpu_id __read_mostly;

static __initdata unsigned long _brk_start = (unsigned long)__brk_base;
unsigned long _brk_end = (unsigned long)__brk_base;

#ifdef CONFIG_X86_64
int default_cpu_present_to_apicid(int mps_cpu)
{
Expand Down Expand Up @@ -337,6 +340,34 @@ static void __init relocate_initrd(void)
}
#endif

void * __init extend_brk(size_t size, size_t align)
{
size_t mask = align - 1;
void *ret;

BUG_ON(_brk_start == 0);
BUG_ON(align & mask);

_brk_end = (_brk_end + mask) & ~mask;
BUG_ON((char *)(_brk_end + size) > __brk_limit);

ret = (void *)_brk_end;
_brk_end += size;

memset(ret, 0, size);

return ret;
}

static void __init reserve_brk(void)
{
if (_brk_end > _brk_start)
reserve_early(__pa(_brk_start), __pa(_brk_end), "BRK");

/* Mark brk area as locked down and no longer taking any new allocations */
_brk_start = 0;
}

static void __init reserve_initrd(void)
{
u64 ramdisk_image = boot_params.hdr.ramdisk_image;
Expand Down Expand Up @@ -717,11 +748,7 @@ void __init setup_arch(char **cmdline_p)
init_mm.start_code = (unsigned long) _text;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
#ifdef CONFIG_X86_32
init_mm.brk = init_pg_tables_end + PAGE_OFFSET;
#else
init_mm.brk = (unsigned long) &_end;
#endif
init_mm.brk = _brk_end;

code_resource.start = virt_to_phys(_text);
code_resource.end = virt_to_phys(_etext)-1;
Expand Down Expand Up @@ -842,6 +869,8 @@ void __init setup_arch(char **cmdline_p)
setup_bios_corruption_check();
#endif

reserve_brk();

/* max_pfn_mapped is updated here */
max_low_pfn_mapped = init_memory_mapping(0, max_low_pfn<<PAGE_SHIFT);
max_pfn_mapped = max_low_pfn_mapped;
Expand Down
7 changes: 7 additions & 0 deletions trunk/arch/x86/kernel/vmlinux_32.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ SECTIONS
*(.bss)
. = ALIGN(4);
__bss_stop = .;

. = ALIGN(PAGE_SIZE);
__brk_base = . ;
. += 1024 * 1024 ;
__brk_limit = . ;

_end = . ;

/* This is where the kernel creates the early boot page tables */
. = ALIGN(PAGE_SIZE);
pg0 = . ;
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/x86/kernel/vmlinux_64.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ SECTIONS
*(.bss.page_aligned)
*(.bss)
__bss_stop = .;

. = ALIGN(PAGE_SIZE);
__brk_base = . ;
. += 1024 * 1024 ;
__brk_limit = . ;
}

_end = . ;
Expand Down
5 changes: 3 additions & 2 deletions trunk/arch/x86/mm/pageattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <asm/processor.h>
#include <asm/tlbflush.h>
#include <asm/sections.h>
#include <asm/setup.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
#include <asm/proto.h>
Expand Down Expand Up @@ -95,7 +96,7 @@ static inline unsigned long highmap_start_pfn(void)

static inline unsigned long highmap_end_pfn(void)
{
return __pa(roundup((unsigned long)_end, PMD_SIZE)) >> PAGE_SHIFT;
return __pa(roundup(_brk_end, PMD_SIZE)) >> PAGE_SHIFT;
}

#endif
Expand Down Expand Up @@ -711,7 +712,7 @@ static int cpa_process_alias(struct cpa_data *cpa)
* No need to redo, when the primary call touched the high
* mapping already:
*/
if (within(vaddr, (unsigned long) _text, (unsigned long) _end))
if (within(vaddr, (unsigned long) _text, _brk_end))
return 0;

/*
Expand Down
6 changes: 3 additions & 3 deletions trunk/arch/x86/xen/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1723,9 +1723,9 @@ __init pgd_t *xen_setup_kernel_pagetable(pgd_t *pgd,
{
pmd_t *kernel_pmd;

init_pg_tables_start = __pa(pgd);
init_pg_tables_end = __pa(pgd) + xen_start_info->nr_pt_frames*PAGE_SIZE;
max_pfn_mapped = PFN_DOWN(init_pg_tables_end + 512*1024);
max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->pt_base) +
xen_start_info->nr_pt_frames * PAGE_SIZE +
512*1024);

kernel_pmd = m2v(pgd[KERNEL_PGD_BOUNDARY].pgd);
memcpy(level2_kernel_pgt, kernel_pmd, sizeof(pmd_t) * PTRS_PER_PMD);
Expand Down

0 comments on commit 463e676

Please sign in to comment.