Skip to contentSkip to conversation

linux/x86-64: miscellaneous initialization code cleanup

PATCH In review Jan Beulich 3 participants 4 messages Jun 12, 2007 – Jun 13, 2007 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/x86-64: miscellaneous initialization code cleanup

arch/x86_64/kernel/head-xen.S +1 -3
Index: head-2007-06-11/arch/x86_64/kernel/head-xen.S
===================================================================
@@ -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)
arch/x86_64/kernel/setup64-xen.c +2 -2
Index: head-2007-06-11/arch/x86_64/kernel/setup64-xen.c
===================================================================
@@ -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)
arch/x86_64/kernel/vsyscall-xen.c +0 -12
Index: head-2007-06-11/arch/x86_64/kernel/vsyscall-xen.c
===================================================================
@@ -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
arch/x86_64/mm/init-xen.c +11 -36

87 lines not on this page · raw message

drivers/xen/core/smpboot.c +0 -2
Index: head-2007-06-11/drivers/xen/core/smpboot.c
===================================================================
@@ -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)
include/asm-x86_64/mach-xen/asm/pgalloc.h +2 -2
Index: head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgalloc.h
===================================================================
@@ -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;
 }
 
include/asm-x86_64/mach-xen/asm/pgtable.h +1 -2
Index: head-2007-06-11/include/asm-x86_64/mach-xen/asm/pgtable.h
===================================================================
@@ -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)
 
#1 lore raw

See whinges below. I applied the patch anyway, plus the required fixes.

Thanks,
Keir

Quoted 8 lines
arch/x86_64/kernel/head-xen.S +0 -1
@@ -53,15 +53,13 @@ ENTRY(name)
 NEXT_PAGE(init_level4_pgt)
 	/* This gets initialized in x86_64_start_kernel */
 	.fill	512,8,0
-
         /*

arch/x86_64/kernel/head-xen.S ENTRY(name) · line 64

Quoted 10 lines
arch/x86_64/kernel/head-xen.S +1 -2
          * 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)

Breaks the build, since removeing NEXT_PAGE(init_level4_user_pgt) means the $page variable isn't incremented, and so the next NEXT_PAGE produces a backwards org statement. How could this ever have worked?

drivers/xen/core/smpboot.c EXPORT_SYMBOL(cpu_core_map); · line 75

Quoted 11 lines

Index: head-2007-06-11/drivers/xen/core/smpboot.c
===================================================================

drivers/xen/core/smpboot.c +0 -2
@@ -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

Breaks the 64-bit SMP domU build, at least in our linux-2.6.18-xen-hg repo. maxcpus actually is referenced in arxh/x86_64/setup.c. Perhaps it shouldn't be, since it looks to be properly handled in init/main.c?

#2 lore raw
Quoted 2 lines
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 12.06.07 19:28 >>>

See whinges below. I applied the patch anyway, plus the required fixes.

Sorry for that, us being at 2.6.22-rc4 means we diverged so far that I probably shouldn't submit any kernel patches anymore (at least not cleanup type ones), until there's a proper linux-tip tree again.

Jan

Quoted 8 lines
arch/x86_64/kernel/head-xen.S +0 -1
@@ -53,15 +53,13 @@ ENTRY(name)
 NEXT_PAGE(init_level4_pgt)
 	/* This gets initialized in x86_64_start_kernel */
 	.fill	512,8,0
-
         /*

arch/x86_64/kernel/head-xen.S ENTRY(name) · line 64

Quoted 10 lines
arch/x86_64/kernel/head-xen.S +1 -2
          * 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)

Breaks the build, since removeing NEXT_PAGE(init_level4_user_pgt) means the $page variable isn't incremented, and so the next NEXT_PAGE produces a backwards org statement. How could this ever have worked?

drivers/xen/core/smpboot.c EXPORT_SYMBOL(cpu_core_map); · line 75

Quoted 11 lines

Index: head-2007-06-11/drivers/xen/core/smpboot.c
===================================================================

drivers/xen/core/smpboot.c +0 -2
@@ -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

Breaks the 64-bit SMP domU build, at least in our linux-2.6.18-xen-hg repo. maxcpus actually is referenced in arxh/x86_64/setup.c. Perhaps it shouldn't be, since it looks to be properly handled in init/main.c?

#3 lore raw
Quoted 6 lines · Jan Beulich
Quoted 1 line

See whinges below. I applied the patch anyway, plus the required fixes.

Sorry for that, us being at 2.6.22-rc4 means we diverged so far that I probably
shouldn't submit any kernel patches anymore (at least not cleanup type ones), until there's a proper linux-tip tree again.

I liked the cleanups though. I'm happy to receive them so long as you make the caveat clear when you post them ('not tested on 2.6.18').

-- Keir