From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 19 Aug 2005 16:46:51 +0000 (+0000) Subject: Simplify pagetable initialisation. Since swapper_pg_dir now X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16888^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=40326f9fc30fb0fa94f7367e7e41c2e7a6b1efa1;p=xen.git Simplify pagetable initialisation. Since swapper_pg_dir now is the one allocated by the domain builder, we can be sure it is below 4GB (essential for PAE). Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile index 58e1498388..bd15b70f35 100644 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile @@ -14,8 +14,7 @@ obj-y := process.o signal.o entry.o traps.o \ c-obj-y := semaphore.o vm86.o \ ptrace.o sys_i386.o \ - i387.o dmi_scan.o bootflag.o \ - doublefault.o + i387.o dmi_scan.o bootflag.o s-obj-y := obj-y += cpu/ @@ -85,7 +84,7 @@ $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \ $(obj)/vsyscall-sysenter.o FORCE $(call if_changed,syscall) -c-link := init_task.o +c-link := s-link := vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o syscall_table.o $(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-obj-m) $(c-link)) $(patsubst %.o,$(obj)/%.S,$(s-obj-y) $(s-link)): diff --git a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S index d68beee323..f8be911e65 100644 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S @@ -136,9 +136,6 @@ cpu_gdt_descr: ENTRY(empty_zero_page) .org 0x2000 -ENTRY(swapper_pg_dir) - -.org 0x3000 ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* NULL descriptor */ .quad 0x0000000000000000 /* 0x0b reserved */ @@ -190,10 +187,10 @@ ENTRY(cpu_gdt_table) .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */ .fill GDT_ENTRIES-32,8,0 -.org 0x4000 +.org 0x3000 ENTRY(default_ldt) -.org 0x5000 +.org 0x4000 /* * Real beginning of normal "text" segment */ diff --git a/linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c b/linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c new file mode 100644 index 0000000000..55502d58ac --- /dev/null +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +static struct fs_struct init_fs = INIT_FS; +static struct files_struct init_files = INIT_FILES; +static struct signal_struct init_signals = INIT_SIGNALS(init_signals); +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); + +#define swapper_pg_dir ((pgd_t *)NULL) +struct mm_struct init_mm = INIT_MM(init_mm); +#undef swapper_pg_dir + +EXPORT_SYMBOL(init_mm); + +/* + * Initial thread structure. + * + * We need to make sure that this is THREAD_SIZE aligned due to the + * way process stacks are handled. This is done by having a special + * "init_task" linker map entry.. + */ +union thread_union init_thread_union + __attribute__((__section__(".data.init_task"))) = + { INIT_THREAD_INFO(init_task) }; + +/* + * Initial task structure. + * + * All other task structs will be allocated on slabs in fork.c + */ +struct task_struct init_task = INIT_TASK(init_task); + +EXPORT_SYMBOL(init_task); + +/* + * per-CPU TSS segments. Threads are completely 'soft' on Linux, + * no more per-task TSS's. + */ +DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_maxaligned_in_smp = INIT_TSS; + diff --git a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c index 3bb8b00258..5016b86a86 100644 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c @@ -342,11 +342,15 @@ unsigned long long __PAGE_KERNEL_EXEC = _PAGE_KERNEL_EXEC; extern void __init remap_numa_kva(void); #endif +pgd_t *swapper_pg_dir; + static void __init pagetable_init (void) { unsigned long vaddr; - pgd_t *pgd_base = swapper_pg_dir; - pgd_t *old_pgd = (pgd_t *)xen_start_info.pt_base; + pgd_t *pgd_base = (pgd_t *)xen_start_info.pt_base; + + swapper_pg_dir = pgd_base; + init_mm.pgd = pgd_base; #ifdef CONFIG_X86_PAE int i; @@ -367,44 +371,6 @@ static void __init pagetable_init (void) __PAGE_KERNEL_EXEC |= _PAGE_GLOBAL; } - /* - * Switch to proper mm_init page directory. Initialise from the current - * page directory, write-protect the new page directory, then switch to - * it. We clean up by write-enabling and then freeing the old page dir. - */ -#ifndef CONFIG_X86_PAE - memcpy(pgd_base, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t)); - make_page_readonly(pgd_base); - xen_pgd_pin(__pa(pgd_base)); - load_cr3(pgd_base); - xen_pgd_unpin(__pa(old_pgd)); - make_page_writable(old_pgd); - __flush_tlb_all(); - free_bootmem(__pa(old_pgd), PAGE_SIZE); -#else - { - pud_t *old_pud = pud_offset(old_pgd+3, PAGE_OFFSET); - pmd_t *old_pmd = pmd_offset(old_pud, PAGE_OFFSET); - pmd_t *new_pmd = alloc_bootmem_low_pages(PAGE_SIZE); - - memcpy(new_pmd, old_pmd, PAGE_SIZE); - memcpy(pgd_base, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t)); - set_pgd(&pgd_base[3], __pgd(__pa(new_pmd) | _PAGE_PRESENT)); - - make_page_readonly(new_pmd); - make_page_readonly(pgd_base); - xen_pgd_pin(__pa(pgd_base)); - load_cr3(pgd_base); - xen_pgd_unpin(__pa(old_pgd)); - make_page_writable(old_pgd); - make_page_writable(old_pmd); - __flush_tlb_all(); - - free_bootmem(__pa(old_pgd), PAGE_SIZE); - free_bootmem(__pa(old_pmd), PAGE_SIZE); - } -#endif - init_mm.context.pinned = 1; kernel_physical_mapping_init(pgd_base); remap_numa_kva(); diff --git a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h index b1c425c221..6e33a59886 100644 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h @@ -32,7 +32,7 @@ */ #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) extern unsigned long empty_zero_page[1024]; -extern pgd_t swapper_pg_dir[1024]; +extern pgd_t *swapper_pg_dir; extern kmem_cache_t *pgd_cache; extern kmem_cache_t *pmd_cache; extern spinlock_t pgd_lock;