ia64/xen-unstable

changeset 6295:74044b8186a9

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 <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Aug 19 16:46:51 2005 +0000 (2005-08-19)
parents 1a0723cd37f1
children 0608852073c8 42f0160093ff
files linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c linux-2.6-xen-sparse/arch/xen/i386/mm/init.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Fri Aug 19 16:06:43 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/Makefile	Fri Aug 19 16:46:51 2005 +0000
     1.3 @@ -14,8 +14,7 @@ obj-y	:= process.o signal.o entry.o trap
     1.4  
     1.5  c-obj-y	:= semaphore.o vm86.o \
     1.6  		ptrace.o sys_i386.o \
     1.7 -		i387.o dmi_scan.o bootflag.o \
     1.8 -		doublefault.o
     1.9 +		i387.o dmi_scan.o bootflag.o
    1.10  s-obj-y	:=
    1.11  
    1.12  obj-y				+= cpu/
    1.13 @@ -85,7 +84,7 @@ SYSCFLAGS_vsyscall-syms.o = -r
    1.14  			$(obj)/vsyscall-sysenter.o FORCE
    1.15  	$(call if_changed,syscall)
    1.16  
    1.17 -c-link	:= init_task.o
    1.18 +c-link	:=
    1.19  s-link	:= vsyscall-int80.o vsyscall-sysenter.o vsyscall-sigreturn.o vsyscall.lds.o syscall_table.o
    1.20  
    1.21  $(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-obj-m) $(c-link)) $(patsubst %.o,$(obj)/%.S,$(s-obj-y) $(s-link)):
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Aug 19 16:06:43 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/head.S	Fri Aug 19 16:46:51 2005 +0000
     2.3 @@ -136,9 +136,6 @@ cpu_gdt_descr:
     2.4  ENTRY(empty_zero_page)
     2.5  
     2.6  .org 0x2000
     2.7 -ENTRY(swapper_pg_dir)
     2.8 -
     2.9 -.org 0x3000
    2.10  ENTRY(cpu_gdt_table)
    2.11  	.quad 0x0000000000000000	/* NULL descriptor */
    2.12  	.quad 0x0000000000000000	/* 0x0b reserved */
    2.13 @@ -190,10 +187,10 @@ ENTRY(cpu_gdt_table)
    2.14  	.quad 0x0000000000000000	/* 0xf8 - GDT entry 31: double-fault TSS */
    2.15  	.fill GDT_ENTRIES-32,8,0
    2.16  
    2.17 -.org 0x4000
    2.18 +.org 0x3000
    2.19  ENTRY(default_ldt)
    2.20  
    2.21 -.org 0x5000
    2.22 +.org 0x4000
    2.23  /*
    2.24   * Real beginning of normal "text" segment
    2.25   */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/init_task.c	Fri Aug 19 16:46:51 2005 +0000
     3.3 @@ -0,0 +1,49 @@
     3.4 +#include <linux/mm.h>
     3.5 +#include <linux/module.h>
     3.6 +#include <linux/sched.h>
     3.7 +#include <linux/init.h>
     3.8 +#include <linux/init_task.h>
     3.9 +#include <linux/fs.h>
    3.10 +#include <linux/mqueue.h>
    3.11 +
    3.12 +#include <asm/uaccess.h>
    3.13 +#include <asm/pgtable.h>
    3.14 +#include <asm/desc.h>
    3.15 +
    3.16 +static struct fs_struct init_fs = INIT_FS;
    3.17 +static struct files_struct init_files = INIT_FILES;
    3.18 +static struct signal_struct init_signals = INIT_SIGNALS(init_signals);
    3.19 +static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
    3.20 +
    3.21 +#define swapper_pg_dir ((pgd_t *)NULL)
    3.22 +struct mm_struct init_mm = INIT_MM(init_mm);
    3.23 +#undef swapper_pg_dir
    3.24 +
    3.25 +EXPORT_SYMBOL(init_mm);
    3.26 +
    3.27 +/*
    3.28 + * Initial thread structure.
    3.29 + *
    3.30 + * We need to make sure that this is THREAD_SIZE aligned due to the
    3.31 + * way process stacks are handled. This is done by having a special
    3.32 + * "init_task" linker map entry..
    3.33 + */
    3.34 +union thread_union init_thread_union 
    3.35 +	__attribute__((__section__(".data.init_task"))) =
    3.36 +		{ INIT_THREAD_INFO(init_task) };
    3.37 +
    3.38 +/*
    3.39 + * Initial task structure.
    3.40 + *
    3.41 + * All other task structs will be allocated on slabs in fork.c
    3.42 + */
    3.43 +struct task_struct init_task = INIT_TASK(init_task);
    3.44 +
    3.45 +EXPORT_SYMBOL(init_task);
    3.46 +
    3.47 +/*
    3.48 + * per-CPU TSS segments. Threads are completely 'soft' on Linux,
    3.49 + * no more per-task TSS's.
    3.50 + */ 
    3.51 +DEFINE_PER_CPU(struct tss_struct, init_tss) ____cacheline_maxaligned_in_smp = INIT_TSS;
    3.52 +
     4.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Aug 19 16:06:43 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Fri Aug 19 16:46:51 2005 +0000
     4.3 @@ -342,11 +342,15 @@ unsigned long long __PAGE_KERNEL_EXEC = 
     4.4  extern void __init remap_numa_kva(void);
     4.5  #endif
     4.6  
     4.7 +pgd_t *swapper_pg_dir;
     4.8 +
     4.9  static void __init pagetable_init (void)
    4.10  {
    4.11  	unsigned long vaddr;
    4.12 -	pgd_t *pgd_base = swapper_pg_dir;
    4.13 -	pgd_t *old_pgd = (pgd_t *)xen_start_info.pt_base;
    4.14 +	pgd_t *pgd_base = (pgd_t *)xen_start_info.pt_base;
    4.15 +
    4.16 +	swapper_pg_dir = pgd_base;
    4.17 +	init_mm.pgd    = pgd_base;
    4.18  
    4.19  #ifdef CONFIG_X86_PAE
    4.20  	int i;
    4.21 @@ -367,44 +371,6 @@ static void __init pagetable_init (void)
    4.22  		__PAGE_KERNEL_EXEC |= _PAGE_GLOBAL;
    4.23  	}
    4.24  
    4.25 -	/*
    4.26 -	 * Switch to proper mm_init page directory. Initialise from the current
    4.27 -	 * page directory, write-protect the new page directory, then switch to
    4.28 -	 * it. We clean up by write-enabling and then freeing the old page dir.
    4.29 -	 */
    4.30 -#ifndef CONFIG_X86_PAE
    4.31 -	memcpy(pgd_base, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t));
    4.32 -	make_page_readonly(pgd_base);
    4.33 -	xen_pgd_pin(__pa(pgd_base));
    4.34 -	load_cr3(pgd_base);
    4.35 -	xen_pgd_unpin(__pa(old_pgd));
    4.36 -	make_page_writable(old_pgd);
    4.37 -	__flush_tlb_all();
    4.38 -	free_bootmem(__pa(old_pgd), PAGE_SIZE);
    4.39 -#else
    4.40 -	{
    4.41 -		pud_t *old_pud = pud_offset(old_pgd+3, PAGE_OFFSET);
    4.42 -		pmd_t *old_pmd = pmd_offset(old_pud, PAGE_OFFSET);
    4.43 -		pmd_t *new_pmd = alloc_bootmem_low_pages(PAGE_SIZE);
    4.44 -
    4.45 -		memcpy(new_pmd,  old_pmd, PAGE_SIZE);
    4.46 -		memcpy(pgd_base, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t));
    4.47 -		set_pgd(&pgd_base[3], __pgd(__pa(new_pmd) | _PAGE_PRESENT));
    4.48 -
    4.49 -		make_page_readonly(new_pmd);
    4.50 -		make_page_readonly(pgd_base);
    4.51 -		xen_pgd_pin(__pa(pgd_base));
    4.52 -		load_cr3(pgd_base);
    4.53 -		xen_pgd_unpin(__pa(old_pgd));
    4.54 -		make_page_writable(old_pgd);
    4.55 -		make_page_writable(old_pmd);
    4.56 -		__flush_tlb_all();
    4.57 -
    4.58 -		free_bootmem(__pa(old_pgd), PAGE_SIZE);
    4.59 -		free_bootmem(__pa(old_pmd), PAGE_SIZE);
    4.60 -	}
    4.61 -#endif
    4.62 -
    4.63  	init_mm.context.pinned = 1;
    4.64  	kernel_physical_mapping_init(pgd_base);
    4.65  	remap_numa_kva();
     5.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug 19 16:06:43 2005 +0000
     5.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Fri Aug 19 16:46:51 2005 +0000
     5.3 @@ -32,7 +32,7 @@
     5.4   */
     5.5  #define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
     5.6  extern unsigned long empty_zero_page[1024];
     5.7 -extern pgd_t swapper_pg_dir[1024];
     5.8 +extern pgd_t *swapper_pg_dir;
     5.9  extern kmem_cache_t *pgd_cache;
    5.10  extern kmem_cache_t *pmd_cache;
    5.11  extern spinlock_t pgd_lock;