2005-09-17 09:27:51 +07:00
|
|
|
/*
|
2008-02-05 13:30:53 +07:00
|
|
|
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-17 05:20:36 +07:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2008-02-05 13:30:53 +07:00
|
|
|
#include <linux/stddef.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
#include <linux/gfp.h>
|
|
|
|
#include <linux/highmem.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/swap.h>
|
|
|
|
#include <asm/fixmap.h>
|
|
|
|
#include <asm/page.h>
|
2007-05-07 04:51:08 +07:00
|
|
|
#include "as-layout.h"
|
2008-02-05 13:30:53 +07:00
|
|
|
#include "init.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "kern.h"
|
2008-02-05 13:30:53 +07:00
|
|
|
#include "kern_util.h"
|
2005-04-17 05:20:36 +07:00
|
|
|
#include "mem_user.h"
|
|
|
|
#include "os.h"
|
|
|
|
|
2007-02-10 16:44:18 +07:00
|
|
|
/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long *empty_zero_page = NULL;
|
2007-02-10 16:44:18 +07:00
|
|
|
/* allocated in paging_init and unchanged thereafter */
|
2005-04-17 05:20:36 +07:00
|
|
|
unsigned long *empty_bad_page = NULL;
|
2008-02-05 13:31:17 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialized during boot, and readonly for initializing page tables
|
|
|
|
* afterwards
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
pgd_t swapper_pg_dir[PTRS_PER_PGD];
|
2008-02-05 13:31:17 +07:00
|
|
|
|
|
|
|
/* Initialized at boot time, and readonly after that */
|
2006-03-31 17:30:09 +07:00
|
|
|
unsigned long long highmem;
|
2005-04-17 05:20:36 +07:00
|
|
|
int kmalloc_ok = 0;
|
|
|
|
|
2008-02-05 13:31:17 +07:00
|
|
|
/* Used during early boot */
|
2005-04-17 05:20:36 +07:00
|
|
|
static unsigned long brk_end;
|
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
static void setup_highmem(unsigned long highmem_start,
|
|
|
|
unsigned long highmem_len)
|
|
|
|
{
|
|
|
|
struct page *page;
|
|
|
|
unsigned long highmem_pfn;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
highmem_pfn = __pa(highmem_start) >> PAGE_SHIFT;
|
2008-02-05 13:30:53 +07:00
|
|
|
for (i = 0; i < highmem_len >> PAGE_SHIFT; i++) {
|
2005-04-17 05:20:36 +07:00
|
|
|
page = &mem_map[highmem_pfn + i];
|
|
|
|
ClearPageReserved(page);
|
2006-03-22 15:08:40 +07:00
|
|
|
init_page_count(page);
|
2005-04-17 05:20:36 +07:00
|
|
|
__free_page(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-24 08:43:48 +07:00
|
|
|
void __init mem_init(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-02-10 16:44:10 +07:00
|
|
|
/* clear the zero-page */
|
2008-02-05 13:30:41 +07:00
|
|
|
memset(empty_zero_page, 0, PAGE_SIZE);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Map in the area just after the brk now that kmalloc is about
|
|
|
|
* to be turned on.
|
|
|
|
*/
|
|
|
|
brk_end = (unsigned long) UML_ROUND_UP(sbrk(0));
|
2008-02-05 13:31:24 +07:00
|
|
|
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
|
2005-04-17 05:20:36 +07:00
|
|
|
free_bootmem(__pa(brk_end), uml_reserved - brk_end);
|
|
|
|
uml_reserved = brk_end;
|
|
|
|
|
|
|
|
/* this will put all low memory onto the freelists */
|
|
|
|
totalram_pages = free_all_bootmem();
|
2007-03-29 15:20:31 +07:00
|
|
|
max_low_pfn = totalram_pages;
|
2006-09-26 13:31:11 +07:00
|
|
|
#ifdef CONFIG_HIGHMEM
|
2005-04-17 05:20:36 +07:00
|
|
|
totalhigh_pages = highmem >> PAGE_SHIFT;
|
|
|
|
totalram_pages += totalhigh_pages;
|
2006-09-26 13:31:11 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
num_physpages = totalram_pages;
|
|
|
|
max_pfn = totalram_pages;
|
2008-02-05 13:30:53 +07:00
|
|
|
printk(KERN_INFO "Memory: %luk available\n",
|
2005-04-17 05:20:36 +07:00
|
|
|
(unsigned long) nr_free_pages() << (PAGE_SHIFT-10));
|
|
|
|
kmalloc_ok = 1;
|
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
setup_highmem(end_iomem, highmem);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-05-21 03:59:12 +07:00
|
|
|
/*
|
|
|
|
* Create a page table and place a pointer to it in a middle page
|
|
|
|
* directory entry.
|
|
|
|
*/
|
|
|
|
static void __init one_page_table_init(pmd_t *pmd)
|
|
|
|
{
|
|
|
|
if (pmd_none(*pmd)) {
|
|
|
|
pte_t *pte = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
|
|
|
|
set_pmd(pmd, __pmd(_KERNPG_TABLE +
|
|
|
|
(unsigned long) __pa(pte)));
|
|
|
|
if (pte != pte_offset_kernel(pmd, 0))
|
|
|
|
BUG();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __init one_md_table_init(pud_t *pud)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_3_LEVEL_PGTABLES
|
|
|
|
pmd_t *pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
|
|
|
|
set_pud(pud, __pud(_KERNPG_TABLE + (unsigned long) __pa(pmd_table)));
|
|
|
|
if (pmd_table != pmd_offset(pud, 0))
|
|
|
|
BUG();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-02-05 13:30:53 +07:00
|
|
|
static void __init fixrange_init(unsigned long start, unsigned long end,
|
2005-04-17 05:20:36 +07:00
|
|
|
pgd_t *pgd_base)
|
|
|
|
{
|
|
|
|
pgd_t *pgd;
|
2005-05-21 03:59:12 +07:00
|
|
|
pud_t *pud;
|
2005-04-17 05:20:36 +07:00
|
|
|
pmd_t *pmd;
|
|
|
|
int i, j;
|
|
|
|
unsigned long vaddr;
|
|
|
|
|
|
|
|
vaddr = start;
|
|
|
|
i = pgd_index(vaddr);
|
|
|
|
j = pmd_index(vaddr);
|
|
|
|
pgd = pgd_base + i;
|
|
|
|
|
|
|
|
for ( ; (i < PTRS_PER_PGD) && (vaddr < end); pgd++, i++) {
|
2005-05-21 03:59:12 +07:00
|
|
|
pud = pud_offset(pgd, vaddr);
|
|
|
|
if (pud_none(*pud))
|
|
|
|
one_md_table_init(pud);
|
|
|
|
pmd = pmd_offset(pud, vaddr);
|
2008-02-05 13:30:55 +07:00
|
|
|
for (; (j < PTRS_PER_PMD) && (vaddr < end); pmd++, j++) {
|
2005-05-21 03:59:12 +07:00
|
|
|
one_page_table_init(pmd);
|
2005-04-17 05:20:36 +07:00
|
|
|
vaddr += PMD_SIZE;
|
|
|
|
}
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
pte_t *kmap_pte;
|
|
|
|
pgprot_t kmap_prot;
|
|
|
|
|
|
|
|
#define kmap_get_fixmap_pte(vaddr) \
|
|
|
|
pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)),\
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 13:30:53 +07:00
|
|
|
(vaddr)), (vaddr))
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static void __init kmap_init(void)
|
|
|
|
{
|
|
|
|
unsigned long kmap_vstart;
|
|
|
|
|
|
|
|
/* cache the first kmap pte */
|
|
|
|
kmap_vstart = __fix_to_virt(FIX_KMAP_BEGIN);
|
|
|
|
kmap_pte = kmap_get_fixmap_pte(kmap_vstart);
|
|
|
|
|
|
|
|
kmap_prot = PAGE_KERNEL;
|
|
|
|
}
|
|
|
|
|
2007-10-29 11:36:10 +07:00
|
|
|
static void __init init_highmem(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
pgd_t *pgd;
|
|
|
|
pud_t *pud;
|
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t *pte;
|
|
|
|
unsigned long vaddr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Permanent kmaps:
|
|
|
|
*/
|
|
|
|
vaddr = PKMAP_BASE;
|
|
|
|
fixrange_init(vaddr, vaddr + PAGE_SIZE*LAST_PKMAP, swapper_pg_dir);
|
|
|
|
|
|
|
|
pgd = swapper_pg_dir + pgd_index(vaddr);
|
|
|
|
pud = pud_offset(pgd, vaddr);
|
|
|
|
pmd = pmd_offset(pud, vaddr);
|
|
|
|
pte = pte_offset_kernel(pmd, vaddr);
|
|
|
|
pkmap_page_table = pte;
|
|
|
|
|
|
|
|
kmap_init();
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_HIGHMEM */
|
|
|
|
|
|
|
|
static void __init fixaddr_user_init( void)
|
|
|
|
{
|
2005-09-08 05:21:11 +07:00
|
|
|
#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
|
2005-04-17 05:20:36 +07:00
|
|
|
long size = FIXADDR_USER_END - FIXADDR_USER_START;
|
|
|
|
pgd_t *pgd;
|
|
|
|
pud_t *pud;
|
|
|
|
pmd_t *pmd;
|
|
|
|
pte_t *pte;
|
2008-02-05 13:30:55 +07:00
|
|
|
phys_t p;
|
|
|
|
unsigned long v, vaddr = FIXADDR_USER_START;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-02-05 13:30:55 +07:00
|
|
|
if (!size)
|
2005-04-17 05:20:36 +07:00
|
|
|
return;
|
|
|
|
|
|
|
|
fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
|
2008-02-05 13:30:55 +07:00
|
|
|
v = (unsigned long) alloc_bootmem_low_pages(size);
|
|
|
|
memcpy((void *) v , (void *) FIXADDR_USER_START, size);
|
|
|
|
p = __pa(v);
|
2008-02-05 13:30:53 +07:00
|
|
|
for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
|
2008-02-05 13:30:55 +07:00
|
|
|
p += PAGE_SIZE) {
|
2005-04-17 05:20:36 +07:00
|
|
|
pgd = swapper_pg_dir + pgd_index(vaddr);
|
|
|
|
pud = pud_offset(pgd, vaddr);
|
|
|
|
pmd = pmd_offset(pud, vaddr);
|
|
|
|
pte = pte_offset_kernel(pmd, vaddr);
|
2008-02-05 13:30:55 +07:00
|
|
|
pte_set_val(*pte, p, PAGE_READONLY);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-05-07 04:51:11 +07:00
|
|
|
void __init paging_init(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned long zones_size[MAX_NR_ZONES], vaddr;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
empty_zero_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
|
|
|
|
empty_bad_page = (unsigned long *) alloc_bootmem_low_pages(PAGE_SIZE);
|
2008-02-05 13:30:53 +07:00
|
|
|
for (i = 0; i < ARRAY_SIZE(zones_size); i++)
|
2005-04-17 05:20:36 +07:00
|
|
|
zones_size[i] = 0;
|
2006-09-26 13:33:00 +07:00
|
|
|
|
2006-09-27 15:50:34 +07:00
|
|
|
zones_size[ZONE_NORMAL] = (end_iomem >> PAGE_SHIFT) -
|
|
|
|
(uml_physmem >> PAGE_SHIFT);
|
2006-09-26 13:31:14 +07:00
|
|
|
#ifdef CONFIG_HIGHMEM
|
2005-11-07 15:58:58 +07:00
|
|
|
zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT;
|
2006-09-26 13:31:14 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
free_area_init(zones_size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fixed mappings, only the page table structure has to be
|
|
|
|
* created - mappings will be set by set_fixmap():
|
|
|
|
*/
|
|
|
|
vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
|
|
|
|
fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
|
|
|
|
|
|
|
|
fixaddr_user_init();
|
|
|
|
|
|
|
|
#ifdef CONFIG_HIGHMEM
|
|
|
|
init_highmem();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-10-21 14:22:24 +07:00
|
|
|
struct page *arch_validate(struct page *page, gfp_t mask, int order)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned long addr, zero = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
again:
|
2008-02-05 13:30:53 +07:00
|
|
|
if (page == NULL)
|
2007-02-10 16:44:10 +07:00
|
|
|
return page;
|
2008-02-05 13:30:53 +07:00
|
|
|
if (PageHighMem(page))
|
2007-02-10 16:44:10 +07:00
|
|
|
return page;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
addr = (unsigned long) page_address(page);
|
2008-02-05 13:30:53 +07:00
|
|
|
for (i = 0; i < (1 << order); i++) {
|
2005-04-17 05:20:36 +07:00
|
|
|
current->thread.fault_addr = (void *) addr;
|
2008-02-05 13:30:53 +07:00
|
|
|
if (__do_copy_to_user((void __user *) addr, &zero,
|
2005-04-17 05:20:36 +07:00
|
|
|
sizeof(zero),
|
|
|
|
¤t->thread.fault_addr,
|
2008-02-05 13:30:53 +07:00
|
|
|
¤t->thread.fault_catcher)) {
|
|
|
|
if (!(mask & __GFP_WAIT))
|
2007-02-10 16:44:10 +07:00
|
|
|
return NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
else break;
|
|
|
|
}
|
|
|
|
addr += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
|
2008-02-05 13:30:53 +07:00
|
|
|
if (i == (1 << order))
|
2007-02-10 16:44:10 +07:00
|
|
|
return page;
|
2005-04-17 05:20:36 +07:00
|
|
|
page = alloc_pages(mask, order);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 13:30:53 +07:00
|
|
|
/*
|
|
|
|
* This can't do anything because nothing in the kernel image can be freed
|
2005-04-17 05:20:36 +07:00
|
|
|
* since it's not in kernel physical memory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void free_initmem(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
|
|
|
void free_initrd_mem(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
if (start < end)
|
2008-02-05 13:30:53 +07:00
|
|
|
printk(KERN_INFO "Freeing initrd memory: %ldk freed\n",
|
|
|
|
(end - start) >> 10);
|
2005-04-17 05:20:36 +07:00
|
|
|
for (; start < end; start += PAGE_SIZE) {
|
|
|
|
ClearPageReserved(virt_to_page(start));
|
2006-03-22 15:08:40 +07:00
|
|
|
init_page_count(virt_to_page(start));
|
2005-04-17 05:20:36 +07:00
|
|
|
free_page(start);
|
|
|
|
totalram_pages++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void show_mem(void)
|
|
|
|
{
|
2007-02-10 16:44:10 +07:00
|
|
|
int pfn, total = 0, reserved = 0;
|
|
|
|
int shared = 0, cached = 0;
|
|
|
|
int highmem = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
struct page *page;
|
|
|
|
|
2008-02-05 13:30:53 +07:00
|
|
|
printk(KERN_INFO "Mem-info:\n");
|
2007-02-10 16:44:10 +07:00
|
|
|
show_free_areas();
|
2008-02-05 13:30:53 +07:00
|
|
|
printk(KERN_INFO "Free swap: %6ldkB\n",
|
|
|
|
nr_swap_pages<<(PAGE_SHIFT-10));
|
2007-02-10 16:44:10 +07:00
|
|
|
pfn = max_mapnr;
|
2008-02-05 13:30:53 +07:00
|
|
|
while (pfn-- > 0) {
|
2005-04-17 05:20:36 +07:00
|
|
|
page = pfn_to_page(pfn);
|
2007-02-10 16:44:10 +07:00
|
|
|
total++;
|
2008-02-05 13:30:53 +07:00
|
|
|
if (PageHighMem(page))
|
2007-02-10 16:44:10 +07:00
|
|
|
highmem++;
|
2008-02-05 13:30:53 +07:00
|
|
|
if (PageReserved(page))
|
2007-02-10 16:44:10 +07:00
|
|
|
reserved++;
|
2008-02-05 13:30:53 +07:00
|
|
|
else if (PageSwapCache(page))
|
2007-02-10 16:44:10 +07:00
|
|
|
cached++;
|
2008-02-05 13:30:53 +07:00
|
|
|
else if (page_count(page))
|
2007-02-10 16:44:10 +07:00
|
|
|
shared += page_count(page) - 1;
|
|
|
|
}
|
2008-02-05 13:30:53 +07:00
|
|
|
printk(KERN_INFO "%d pages of RAM\n", total);
|
|
|
|
printk(KERN_INFO "%d pages of HIGHMEM\n", highmem);
|
|
|
|
printk(KERN_INFO "%d reserved pages\n", reserved);
|
|
|
|
printk(KERN_INFO "%d pages shared\n", shared);
|
|
|
|
printk(KERN_INFO "%d pages swap cached\n", cached);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 13:30:53 +07:00
|
|
|
/* Allocate and free page tables. */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
pgd_t *pgd_alloc(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
|
|
|
|
|
|
|
|
if (pgd) {
|
|
|
|
memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
|
2008-02-05 13:30:53 +07:00
|
|
|
memcpy(pgd + USER_PTRS_PER_PGD,
|
|
|
|
swapper_pg_dir + USER_PTRS_PER_PGD,
|
2005-04-17 05:20:36 +07:00
|
|
|
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
|
|
|
}
|
|
|
|
return pgd;
|
|
|
|
}
|
|
|
|
|
2008-02-05 13:29:14 +07:00
|
|
|
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
free_page((unsigned long) pgd);
|
|
|
|
}
|
|
|
|
|
|
|
|
pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
|
|
|
|
{
|
|
|
|
pte_t *pte;
|
|
|
|
|
|
|
|
pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
|
|
|
|
return pte;
|
|
|
|
}
|
|
|
|
|
2008-02-08 19:22:04 +07:00
|
|
|
pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
struct page *pte;
|
2007-02-10 16:44:10 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
pte = alloc_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
|
2008-02-08 19:22:04 +07:00
|
|
|
if (pte)
|
|
|
|
pgtable_page_ctor(pte);
|
2005-04-17 05:20:36 +07:00
|
|
|
return pte;
|
|
|
|
}
|
uml: header untangling
Untangle UML headers somewhat and add some includes where they were
needed explicitly, but gotten accidentally via some other header.
arch/um/include/um_uaccess.h loses asm/fixmap.h because it uses no
fixmap stuff and gains elf.h, because it needs FIXADDR_USER_*, and
archsetjmp.h, because it needs jmp_buf.
pmd_alloc_one is uninlined because it needs mm_struct, and that's
inconvenient to provide in asm-um/pgtable-3level.h.
elf_core_copy_fpregs is also uninlined from elf-i386.h and
elf-x86_64.h, which duplicated the code anyway, to
arch/um/kernel/process.c, so that the reference to current_thread
doesn't pull sched.h or anything related into asm/elf.h.
arch/um/sys-i386/ldt.c, arch/um/kernel/tlb.c and
arch/um/kernel/skas/uaccess.c got sched.h because they dereference
task_structs. Its includes of linux and asm headers got turned from
"" to <>.
arch/um/sys-i386/bug.c gets asm/errno.h because it needs errno
constants.
asm/elf-i386 gets asm/user.h because it needs user_regs_struct.
asm/fixmap.h gets page.h because it needs PAGE_SIZE and PAGE_MASK and
system.h for BUG_ON.
asm/pgtable doesn't need sched.h.
asm/processor-generic.h defined mm_segment_t, but didn't use it. So,
that definition is moved to uaccess.h, which defines a bunch of
mm_segment_t-related stuff. thread_info.h uses mm_segment_t, and
includes uaccess.h, which causes a recursion. So, the definition is
placed above the include of thread_info. in uaccess.h. thread_info.h
also gets page.h because it needs PAGE_SIZE.
ObCheckpatchViolationJustification - I'm not adding a typedef; I'm
moving mm_segment_t from one place to another.
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-02-05 13:30:53 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_3_LEVEL_PGTABLES
|
|
|
|
pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
|
|
|
|
{
|
|
|
|
pmd_t *pmd = (pmd_t *) __get_free_page(GFP_KERNEL);
|
|
|
|
|
|
|
|
if (pmd)
|
|
|
|
memset(pmd, 0, PAGE_SIZE);
|
|
|
|
|
|
|
|
return pmd;
|
|
|
|
}
|
|
|
|
#endif
|