UML - Three-level page table support
PATCH 4/28 UML - Three-level page table support
This is the three-level page table support from the x86_64 patch. It can be enabled on x86, although it's not particularly needed at this point. However, it can be used to implement very large physical memory (with almost all of it in highmem) on UML.
Signed-off-by Jeff Dike <[email protected]>
arch/um/Kconfig +2 -0
@@ -68,6 +68,8 @@ to CONFIG_MODE_TT). Otherwise, it is safe to say Y. Disabling this option will shrink the UML binary slightly. +source "arch/um/Kconfig_arch" + config NET bool "Networking support" help
arch/um/Kconfig_i386 +8 -0
@@ -0,0 +1,8 @@ +config 3_LEVEL_PGTABLES + bool "Three-level pagetables" + default n + help + Three-level pagetables will let UML have more than 4G of physical + memory. All the memory that can't be mapped directly will be treated + as high memory. +
arch/um/Makefile +1 -1
@@ -17,7 +17,7 @@ # Have to precede the include because the included Makefiles reference them. SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \ - arch-signal.h module.h + arch-signal.h module.h vm-flags.h SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
arch/um/defconfig +1 -0
@@ -17,6 +17,7 @@ # CONFIG_MODE_TT=y CONFIG_MODE_SKAS=y +# CONFIG_3_LEVEL_PGTABLES is not set CONFIG_NET=y CONFIG_BINFMT_ELF=y CONFIG_BINFMT_MISC=m
arch/um/kernel/mem.c +3 -2
@@ -25,7 +25,7 @@/* Changed during early boot */ unsigned long *empty_zero_page =NULL ;unsigned long *empty_bad_page =NULL ; -pgd_t swapper_pg_dir[1024 ]; +pgd_t swapper_pg_dir[PTRS_PER_PGD ];unsigned long highmem;int kmalloc_ok =0 ;
@@ -242,6 +242,7 @@ } addr +=PAGE_SIZE ; } +if (i == (1 << order))return (page); page =alloc_pages (mask, order); goto again;
@@ -336,7 +337,7 @@ {struct page *pte; - pte =alloc_pages (GFP_KERNEL |__GFP_REPEAT|__GFP_ZERO,0 ); + pte =alloc_page (GFP_KERNEL |__GFP_REPEAT|__GFP_ZERO);return pte; }
arch/um/kernel/physmem.c +4 -3
@@ -309,7 +309,7 @@return (&mem_map[__pa (virt) >>PAGE_SHIFT ]); } -unsigned long page_to_phys (struct page *page) +phys_t page_to_phys (struct page *page) {return ((page - mem_map) <<PAGE_SHIFT ); }
@@ -318,8 +318,9 @@ {pte_t pte; -pte_val (pte) =page_to_phys (page) +pgprot_val (pgprot); -if (pte_present (pte))pte_mknewprot (pte_mknewpage (pte)); +pte_set_val (pte,page_to_phys (page), pgprot); +if (pte_present (pte)) +pte_mknewprot (pte_mknewpage (pte));return (pte); }
arch/um/kernel/skas/tlb.c +109 -40
213 lines not on this page · raw message
arch/um/kernel/trap_kern.c +4 -1
@@ -59,7 +59,7 @@if (is_write && !(vma->vm_flags &VM_WRITE )) goto out; page = address &PAGE_MASK ; - pgd =pgd_offset (mm); + pgd =pgd_offset (mm, page); pud =pud_offset (pgd, page); pmd =pmd_offset (pud, page); do {
@@ -80,6 +80,9 @@default :BUG (); } + pgd =pgd_offset (mm, page); + pud =pud_offset (pgd, page); + pmd =pmd_offset (pud, page); pte =pte_offset_kernel (pmd, page); }while (!pte_present (*pte)); err =0 ;
arch/um/kernel/tt/tlb.c +114 -42
219 lines not on this page · raw message
include/asm-um/page.h +91 -13
128 lines not on this page · raw message
include/asm-um/pgalloc.h +6 -6
@@ -1,5 +1,6 @@/* * Copyright (C) 2000, 2001, 2002 Jeff Dike ([email protected]) +* Copyright 2003 PathScale, Inc. * Derived from include/asm-i386/pgalloc.h and include/asm-i386/pgtable.h * Licensed under the GPL */
@@ -7,11 +8,12 @@#ifndef __UM_PGALLOC_H#define __UM_PGALLOC_H +#include "linux/config.h" #include "linux/mm.h" #include "asm/fixmap.h" #define pmd_populate_kernel (mm, pmd, pte) \ - set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte))) + set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte)))#define pmd_populate (mm, pmd, pte) \ set_pmd(pmd, __pmd(_PAGE_TABLE + \
@@ -39,15 +41,13 @@#define __pte_free_tlb (tlb,pte) tlb_remove_page((tlb),(pte)) +#ifdef CONFIG_3_LEVEL_PGTABLES /* -* allocating and freeing a pmd is trivial: the 1-entry pmd is -* inside the pgd, so has no extra memory associated with it. +* In the 3-level case we free the pmds as part of the pgd. */ - -#define pmd_alloc_one (mm, addr) ({ BUG(); ((pmd_t *)2); })#define pmd_free (x) do { } while (0)#define __pmd_free_tlb (tlb,x) do { } while (0) -#define pud_populate (mm, pmd, pte) BUG() +#endif #define check_pgt_cache () do { } while (0)
include/asm-um/pgtable-2level.h +83 -0
83 lines not on this page · raw message
include/asm-um/pgtable-3level.h +172 -0
172 lines not on this page · raw message
include/asm-um/pgtable.h +75 -136
368 lines not on this page · raw message
include/asm-um/vm-flags-i386.h +14 -0
@@ -0,0 +1,14 @@ +/* +* Copyright (C) 2004 Jeff Dike ([email protected]) +* Licensed under the GPL +*/ + +#ifndef __VM_FLAGS_I386_H +#define __VM_FLAGS_I386_H + +#define VM_DATA_DEFAULT_FLAGS \ + (VM_READ | VM_WRITE | \ + ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) + +#endif
include/asm-um/vm-flags-x86_64.h +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (C) 2004 Jeff Dike ([email protected]) +* Copyright 2003 PathScale, Inc. +* Licensed under the GPL +*/ + +#ifndef __VM_FLAGS_X86_64_H +#define __VM_FLAGS_X86_64_H + +#define __VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) +#define __VM_STACK_FLAGS (VM_GROWSDOWN | VM_READ | VM_WRITE | \ + VM_EXEC | VM_MAYREAD | VM_MAYWRITE | \ + VM_MAYEXEC) + +extern unsigned long vm_stack_flags, vm_stack_flags32; +extern unsigned long vm_data_default_flags, vm_data_default_flags32; +extern unsigned long vm_force_exec32; + +#define VM_DATA_DEFAULT_FLAGS \ + (test_thread_flag(TIF_IA32) ? vm_data_default_flags32 : \ + vm_data_default_flags) + +#define VM_STACK_DEFAULT_FLAGS \ + (test_thread_flag(TIF_IA32) ? vm_stack_flags32 : vm_stack_flags) + +#endif