Release 4.14 arch/um/kernel/mem.c
/*
* Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
#include <linux/stddef.h>
#include <linux/module.h>
#include <linux/bootmem.h>
#include <linux/highmem.h>
#include <linux/mm.h>
#include <linux/swap.h>
#include <linux/slab.h>
#include <asm/fixmap.h>
#include <asm/page.h>
#include <as-layout.h>
#include <init.h>
#include <kern.h>
#include <kern_util.h>
#include <mem_user.h>
#include <os.h>
/* allocated in paging_init, zeroed in mem_init, and unchanged thereafter */
unsigned long *empty_zero_page = NULL;
EXPORT_SYMBOL(empty_zero_page);
/* allocated in paging_init and unchanged thereafter */
static unsigned long *empty_bad_page = NULL;
/*
* Initialized during boot, and readonly for initializing page tables
* afterwards
*/
pgd_t swapper_pg_dir[PTRS_PER_PGD];
/* Initialized at boot time, and readonly after that */
unsigned long long highmem;
int kmalloc_ok = 0;
/* Used during early boot */
static unsigned long brk_end;
void __init mem_init(void)
{
/* clear the zero-page */
memset(empty_zero_page, 0, PAGE_SIZE);
/* 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));
map_memory(brk_end, __pa(brk_end), uml_reserved - brk_end, 1, 1, 0);
free_bootmem(__pa(brk_end), uml_reserved - brk_end);
uml_reserved = brk_end;
/* this will put all low memory onto the freelists */
free_all_bootmem();
max_low_pfn = totalram_pages;
max_pfn = totalram_pages;
mem_init_print_info(NULL);
kmalloc_ok = 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 77 | 85.56% | 5 | 62.50% |
Paolo 'Blaisorblade' Giarrusso | 7 | 7.78% | 1 | 12.50% |
Jason Lunz | 4 | 4.44% | 1 | 12.50% |
Jiang Liu | 2 | 2.22% | 1 | 12.50% |
Total | 90 | 100.00% | 8 | 100.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();
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 67 | 100.00% | 1 | 100.00% |
Total | 67 | 100.00% | 1 | 100.00% |
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
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 62 | 100.00% | 1 | 100.00% |
Total | 62 | 100.00% | 1 | 100.00% |
static void __init fixrange_init(unsigned long start, unsigned long end,
pgd_t *pgd_base)
{
pgd_t *pgd;
pud_t *pud;
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++) {
pud = pud_offset(pgd, vaddr);
if (pud_none(*pud))
one_md_table_init(pud);
pmd = pmd_offset(pud, vaddr);
for (; (j < PTRS_PER_PMD) && (vaddr < end); pmd++, j++) {
one_page_table_init(pmd);
vaddr += PMD_SIZE;
}
j = 0;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 152 | 98.70% | 3 | 60.00% |
Andrew Morton | 2 | 1.30% | 2 | 40.00% |
Total | 154 | 100.00% | 5 | 100.00% |
static void __init fixaddr_user_init( void)
{
#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
long size = FIXADDR_USER_END - FIXADDR_USER_START;
pgd_t *pgd;
pud_t *pud;
pmd_t *pmd;
pte_t *pte;
phys_t p;
unsigned long v, vaddr = FIXADDR_USER_START;
if (!size)
return;
fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
v = (unsigned long) alloc_bootmem_low_pages(size);
memcpy((void *) v , (void *) FIXADDR_USER_START, size);
p = __pa(v);
for ( ; size > 0; size -= PAGE_SIZE, vaddr += PAGE_SIZE,
p += PAGE_SIZE) {
pgd = swapper_pg_dir + pgd_index(vaddr);
pud = pud_offset(pgd, vaddr);
pmd = pmd_offset(pud, vaddr);
pte = pte_offset_kernel(pmd, vaddr);
pte_set_val(*pte, p, PAGE_READONLY);
}
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 163 | 98.79% | 4 | 80.00% |
Al Viro | 2 | 1.21% | 1 | 20.00% |
Total | 165 | 100.00% | 5 | 100.00% |
void __init paging_init(void)
{
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);
for (i = 0; i < ARRAY_SIZE(zones_size); i++)
zones_size[i] = 0;
zones_size[ZONE_NORMAL] = (end_iomem >> PAGE_SHIFT) -
(uml_physmem >> PAGE_SHIFT);
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();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 78 | 69.03% | 1 | 14.29% |
Jeff Dike | 35 | 30.97% | 6 | 85.71% |
Total | 113 | 100.00% | 7 | 100.00% |
/*
* This can't do anything because nothing in the kernel image can be freed
* since it's not in kernel physical memory.
*/
void free_initmem(void)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Paolo 'Blaisorblade' Giarrusso | 6 | 100.00% | 1 | 100.00% |
Total | 6 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
free_reserved_area((void *)start, (void *)end, -1, "initrd");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jiang Liu | 15 | 45.45% | 3 | 60.00% |
Paolo 'Blaisorblade' Giarrusso | 11 | 33.33% | 1 | 20.00% |
Jeff Dike | 7 | 21.21% | 1 | 20.00% |
Total | 33 | 100.00% | 5 | 100.00% |
#endif
/* Allocate and free page tables. */
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));
memcpy(pgd + USER_PTRS_PER_PGD,
swapper_pg_dir + USER_PTRS_PER_PGD,
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
}
return pgd;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 69 | 100.00% | 1 | 100.00% |
Total | 69 | 100.00% | 1 | 100.00% |
void pgd_free(struct mm_struct *mm, pgd_t *pgd)
{
free_page((unsigned long) pgd);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 18 | 78.26% | 1 | 50.00% |
Benjamin Herrenschmidt | 5 | 21.74% | 1 | 50.00% |
Total | 23 | 100.00% | 2 | 100.00% |
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_ZERO);
return pte;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 33 | 94.29% | 1 | 33.33% |
Christoph Lameter | 1 | 2.86% | 1 | 33.33% |
Andrew Morton | 1 | 2.86% | 1 | 33.33% |
Total | 35 | 100.00% | 3 | 100.00% |
pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long address)
{
struct page *pte;
pte = alloc_page(GFP_KERNEL|__GFP_ZERO);
if (!pte)
return NULL;
if (!pgtable_page_ctor(pte)) {
__free_page(pte);
return NULL;
}
return pte;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 28 | 49.12% | 2 | 33.33% |
Kirill A. Shutemov | 17 | 29.82% | 1 | 16.67% |
Martin Schwidefsky | 10 | 17.54% | 1 | 16.67% |
Christoph Lameter | 1 | 1.75% | 1 | 16.67% |
Andrew Morton | 1 | 1.75% | 1 | 16.67% |
Total | 57 | 100.00% | 6 | 100.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;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 44 | 100.00% | 1 | 100.00% |
Total | 44 | 100.00% | 1 | 100.00% |
#endif
void *uml_kmalloc(int size, int flags)
{
return kmalloc(size, flags);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 20 | 100.00% | 1 | 100.00% |
Total | 20 | 100.00% | 1 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 852 | 81.69% | 24 | 57.14% |
Paolo 'Blaisorblade' Giarrusso | 111 | 10.64% | 1 | 2.38% |
Jiang Liu | 17 | 1.63% | 4 | 9.52% |
Kirill A. Shutemov | 17 | 1.63% | 1 | 2.38% |
Al Viro | 16 | 1.53% | 3 | 7.14% |
Martin Schwidefsky | 10 | 0.96% | 1 | 2.38% |
Benjamin Herrenschmidt | 5 | 0.48% | 1 | 2.38% |
Andrew Morton | 4 | 0.38% | 3 | 7.14% |
Jason Lunz | 4 | 0.38% | 1 | 2.38% |
Tejun Heo | 4 | 0.38% | 1 | 2.38% |
Christoph Lameter | 2 | 0.19% | 1 | 2.38% |
Américo Wang | 1 | 0.10% | 1 | 2.38% |
Total | 1043 | 100.00% | 42 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.