[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] linux/x86-64: miscellaneous initialization code cleanup



Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>

Index: head-2007-06-11/arch/x86_64/kernel/head-xen.S
===================================================================
--- head-2007-06-11.orig/arch/x86_64/kernel/head-xen.S  2007-06-11 
09:08:18.000000000 +0200
+++ head-2007-06-11/arch/x86_64/kernel/head-xen.S       2007-06-11 
09:09:41.000000000 +0200
@@ -53,15 +53,13 @@ ENTRY(name)
 NEXT_PAGE(init_level4_pgt)
        /* This gets initialized in x86_64_start_kernel */
        .fill   512,8,0
-
         /*
          * We update two pgd entries to make kernel and user pgd consistent
          * at pgd_populate(). It can be used for kernel modules. So we place 
          * this page here for those cases to avoid memory corruption.
-         * We also use this page to establish the initiali mapping for
+         * We also use this page to establish the initial mapping for the
          * vsyscall area.
          */
-NEXT_PAGE(init_level4_user_pgt)
        .fill   512,8,0
 
 NEXT_PAGE(level3_kernel_pgt)
Index: head-2007-06-11/arch/x86_64/kernel/setup64-xen.c
===================================================================
--- head-2007-06-11.orig/arch/x86_64/kernel/setup64-xen.c       2007-06-11 
09:08:18.000000000 +0200
+++ head-2007-06-11/arch/x86_64/kernel/setup64-xen.c    2007-06-11 
09:09:41.000000000 +0200
@@ -128,8 +128,8 @@ void __init setup_per_cpu_areas(void)
 #ifdef CONFIG_XEN
 static void switch_pt(void)
 {
-       xen_pt_switch(__pa(init_level4_pgt));
-        xen_new_user_pt(__pa(init_level4_user_pgt));
+       xen_pt_switch(__pa_symbol(init_level4_pgt));
+       xen_new_user_pt(__pa_symbol(__user_pgd(init_level4_pgt)));
 }
 
 void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
Index: head-2007-06-11/arch/x86_64/kernel/vsyscall-xen.c
===================================================================
--- head-2007-06-11.orig/arch/x86_64/kernel/vsyscall-xen.c      2007-06-11 
09:08:18.000000000 +0200
+++ head-2007-06-11/arch/x86_64/kernel/vsyscall-xen.c   2007-06-11 
09:09:41.000000000 +0200
@@ -208,17 +208,6 @@ static void __init map_vsyscall(void)
        __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
 }
 
-#ifdef CONFIG_XEN
-static void __init map_vsyscall_user(void)
-{
-       extern void __set_fixmap_user(enum fixed_addresses, unsigned long, 
pgprot_t);
-       extern char __vsyscall_0;
-       unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
-
-       __set_fixmap_user(VSYSCALL_FIRST_PAGE, physaddr_page0, 
PAGE_KERNEL_VSYSCALL);
-}
-#endif
-
 static int __init vsyscall_init(void)
 {
        BUG_ON(((unsigned long) &vgettimeofday !=
@@ -227,7 +216,6 @@ static int __init vsyscall_init(void)
        BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
        map_vsyscall();
 #ifdef CONFIG_XEN
-       map_vsyscall_user();
        sysctl_vsyscall = 0; /* disable vgettimeofay() */
 #endif
 #ifdef CONFIG_SYSCTL
Index: head-2007-06-11/arch/x86_64/mm/init-xen.c
===================================================================
--- head-2007-06-11.orig/arch/x86_64/mm/init-xen.c      2007-06-11 
09:08:50.000000000 +0200
+++ head-2007-06-11/arch/x86_64/mm/init-xen.c   2007-06-11 09:09:41.000000000 
+0200
@@ -227,14 +227,8 @@ static __init void *spp_getpage(void)
        return ptr;
 } 
 
-#define pgd_offset_u(address) (pgd_t *)(init_level4_user_pgt + 
pgd_index(address))
-
-static inline pud_t *pud_offset_u(unsigned long address)
-{
-       pud_t *pud = level3_user_pgt;
-
-       return pud + pud_index(address);
-}
+#define pgd_offset_u(address) (__user_pgd(init_level4_pgt) + 
pgd_index(address))
+#define pud_offset_u(address) (level3_user_pgt + pud_index(address))
 
 static __init void set_pte_phys(unsigned long vaddr,
                         unsigned long phys, pgprot_t prot, int user_mode)
@@ -337,9 +331,6 @@ static __init void set_pte_phys_ma(unsig
        __flush_tlb_one(vaddr);
 }
 
-#define SET_FIXMAP_KERNEL 0
-#define SET_FIXMAP_USER   1
-
 /* NOTE: this is meant to be run only at boot */
 void __init 
 __set_fixmap (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
@@ -352,7 +343,8 @@ __set_fixmap (enum fixed_addresses idx, 
        }
        switch (idx) {
        case VSYSCALL_LAST_PAGE ... VSYSCALL_FIRST_PAGE:
-               set_pte_phys(address, phys, prot, SET_FIXMAP_KERNEL);
+               set_pte_phys(address, phys, prot, 0);
+               set_pte_phys(address, phys, prot, 1);
                break;
        default:
                set_pte_phys_ma(address, phys, prot);
@@ -360,22 +352,6 @@ __set_fixmap (enum fixed_addresses idx, 
        }
 }
 
-/*
- * This only supports vsyscall area.
- */
-void __init
-__set_fixmap_user (enum fixed_addresses idx, unsigned long phys, pgprot_t prot)
-{
-       unsigned long address = __fix_to_virt(idx);
-
-       if (idx >= __end_of_fixed_addresses) {
-               printk("Invalid __set_fixmap\n");
-               return;
-       }
-
-       set_pte_phys(address, phys, prot, SET_FIXMAP_USER); 
-}
-
 unsigned long __initdata table_start, table_end; 
 
 static __meminit void *alloc_static_page(unsigned long *phys)
@@ -579,13 +555,15 @@ void __init xen_init_pt(void)
        init_level4_pgt[pgd_index(__START_KERNEL_map)] = 
                __pgd(__pa_symbol(level3_kernel_pgt) | _PAGE_TABLE);
        level3_kernel_pgt[pud_index(__START_KERNEL_map)] = 
-               __pud(__pa_symbol(level2_kernel_pgt) |
-                     _KERNPG_TABLE);
-       memcpy((void *)level2_kernel_pgt, page, PAGE_SIZE);
+               __pud(__pa_symbol(level2_kernel_pgt) | _PAGE_TABLE);
+       memcpy(level2_kernel_pgt, page, PAGE_SIZE);
+
+       __user_pgd(init_level4_pgt)[pgd_index(VSYSCALL_START)] =
+               __pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE);
 
        early_make_page_readonly(init_level4_pgt,
                                 XENFEAT_writable_page_tables);
-       early_make_page_readonly(init_level4_user_pgt,
+       early_make_page_readonly(__user_pgd(init_level4_pgt),
                                 XENFEAT_writable_page_tables);
        early_make_page_readonly(level3_kernel_pgt,
                                 XENFEAT_writable_page_tables);
@@ -596,11 +574,8 @@ void __init xen_init_pt(void)
 
        if (!xen_feature(XENFEAT_writable_page_tables)) {
                xen_pgd_pin(__pa_symbol(init_level4_pgt));
-               xen_pgd_pin(__pa_symbol(init_level4_user_pgt));
+               xen_pgd_pin(__pa_symbol(__user_pgd(init_level4_pgt)));
        }
-
-       set_pgd((pgd_t *)(init_level4_user_pgt + 511), 
-               mk_kernel_pgd(__pa_symbol(level3_user_pgt)));
 }
 
 static void __init extend_init_mapping(unsigned long tables_space)
Index: head-2007-06-11/drivers/xen/core/smpboot.c
===================================================================
--- head-2007-06-11.orig/drivers/xen/core/smpboot.c     2007-06-11 
09:08:18.000000000 +0200
+++ head-2007-06-11/drivers/xen/core/smpboot.c  2007-06-11 09:09:41.000000000 
+0200
@@ -72,8 +72,6 @@ EXPORT_SYMBOL(cpu_core_map);
 #if defined(__i386__)
 u8 x86_cpu_to_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = 0xff };
 EXPORT_SYMBOL(x86_cpu_to_apicid);
-#elif !defined(CONFIG_X86_IO_APIC)
-unsigned int maxcpus = NR_CPUS;
 #endif
 
 void __init prefill_possible_map(void)
Index: head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgalloc.h
===================================================================
--- head-2007-06-11.orig/include/asm-x86_64/mach-xen/asm/pgalloc.h      
2007-06-11 09:08:18.000000000 +0200
+++ head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgalloc.h   2007-06-11 
09:09:41.000000000 +0200
@@ -146,8 +146,8 @@ static inline pgd_t *pgd_alloc(struct mm
        /*
         * Set level3_user_pgt for vsyscall area
         */
-       set_pgd(__user_pgd(pgd) + pgd_index(VSYSCALL_START),
-               __pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE));
+       __user_pgd(pgd)[pgd_index(VSYSCALL_START)] =
+               __pgd(__pa_symbol(level3_user_pgt) | _PAGE_TABLE);
        return pgd;
 }
 
Index: head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
--- head-2007-06-11.orig/include/asm-x86_64/mach-xen/asm/pgtable.h      
2007-06-11 09:08:18.000000000 +0200
+++ head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgtable.h   2007-06-11 
09:09:41.000000000 +0200
@@ -15,7 +15,6 @@
 #include <asm/hypervisor.h>
 
 extern pud_t level3_user_pgt[512];
-extern pud_t init_level4_user_pgt[];
 
 extern void xen_init_pt(void);
 
@@ -395,7 +394,7 @@ static inline int pmd_large(pmd_t pte) {
 #define pgd_page(pgd) ((unsigned long) __va(pgd_val(pgd) & PTE_MASK))
 #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
 #define pgd_offset(mm, addr) ((mm)->pgd + pgd_index(addr))
-#define pgd_offset_k(address) (pgd_t *)(init_level4_pgt + pgd_index(address))
+#define pgd_offset_k(address) (init_level4_pgt + pgd_index(address))
 #define pgd_present(pgd) (__pgd_val(pgd) & _PAGE_PRESENT)
 #define mk_kernel_pgd(address) __pgd((address) | _KERNPG_TABLE)
 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.