Skip to contentSkip to conversation

x86: improve boot loader module handling

PATCH New Jan Beulich 1 participant 1 message Nov 9, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover x86: improve boot loader module handling

Currently, initrd size is limited by the virtual space available in the initial mapping. Linux in particular, however, has no need for the initrd to be mapped at all - it deals with it in terms of physical addresses, and hence this limitation can be easily removed on the kernel side (patch - not applicable to the 2.6.18 or pv-ops trees - attached here for reference).

Additionally, the initrd could get copied around up to three times (once [32-bit only] in the early boot relocation code, once when coalescing modules to a single physical address area, and once when placing it into Dom0's initial mapping). Obviously, when the initrd is large, this can visibly delay the boot process, but it can be reduced to a single copy (or, in rare cases, to no copy at all; in a special case [32-on-64 with huge amounts of memory] two copy operations may still be needed).

Further, no provisions seem to have existed to avoid a collision of the area Xen gets relocated to (on x86-64) with any of the modules.

From: [email protected]
Subject: eliminate scalability issues from initrd hanling
Patch-mainline: n/a

Size restrictions native kernels wouldn't have resulted from the initrd getting mapped into the initial mapping. The kernel doesn't really need the initrd to be mapped, so use new infrastructure available in 4.1+ Xen to avoid the mapping and hence the restriction.

arch/x86/include/mach-xen/asm/setup.h +7 -0
@@ -3,6 +3,13 @@
 void xen_start_kernel(void);
 void xen_arch_setup(void);
 
+#ifdef CONFIG_X86_64
+void reserve_pfn_range(unsigned long pfn, unsigned long nr, char *);
+void reserve_pgtable_low(void);
+#endif
+
+extern unsigned long xen_initrd_start;
+
 #endif
 
 #include_next <asm/setup.h>
arch/x86/kernel/head-xen.c +2 -0
@@ -74,6 +74,8 @@ extern void nmi(void);
 #define CALLBACK_ADDR(fn) { __KERNEL_CS, (unsigned long)(fn) }
 #endif
 
+unsigned long __initdata xen_initrd_start;
+
 unsigned long *__read_mostly machine_to_phys_mapping =
 	(void *)MACH2PHYS_VIRT_START;
 EXPORT_SYMBOL(machine_to_phys_mapping);
arch/x86/kernel/head32-xen.c +5 -0
@@ -83,6 +83,11 @@ void __init i386_start_kernel(void)
 		break;
 	}
 #else
+#ifdef CONFIG_BLK_DEV_INITRD
+	BUG_ON(xen_start_info->flags & SIF_MOD_START_PFN);
+	if (xen_start_info->mod_start)
+		xen_initrd_start = __pa(xen_start_info->mod_start);
+#endif
 	{
 		int max_cmdline;
 
arch/x86/kernel/head64-xen.c +14 -4
@@ -121,13 +121,23 @@ void __init x86_64_start_reservations(ch
 
 	reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS");
 
+#ifdef CONFIG_BLK_DEV_INITRD
+	/* Reserve INITRD if needed. */
+	if (xen_start_info->flags & SIF_MOD_START_PFN) {
+		reserve_pfn_range(xen_start_info->mod_start,
+				  PFN_UP(xen_start_info->mod_len),
+				  "RAMDISK");
+		xen_initrd_start = xen_start_info->mod_start << PAGE_SHIFT;
+	} else if (xen_start_info->mod_start)
+		xen_initrd_start = __pa(xen_start_info->mod_start);
+#endif
+
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		xen_start_info->mfn_list = ~0UL;
 	else if (xen_start_info->mfn_list < __START_KERNEL_map)
-		reserve_early(xen_start_info->first_p2m_pfn << PAGE_SHIFT,
-			      (xen_start_info->first_p2m_pfn
-			       + xen_start_info->nr_p2m_frames) << PAGE_SHIFT,
-			      "INITP2M");
+		reserve_pfn_range(xen_start_info->first_p2m_pfn,
+				  xen_start_info->nr_p2m_frames,
+				  "INITP2M");
 
 	/*
 	 * At this point everything still needed from the boot loader
arch/x86/kernel/head_64-xen.S +1 -0
@@ -147,6 +147,7 @@ ENTRY(empty_zero_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad startup_64)
 	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad hypercall_page)
 	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .quad _PAGE_PRESENT, _PAGE_PRESENT)
+	ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_PFN,  .long 1)
 	ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M,       .quad VMEMMAP_START)
 	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
 	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz "generic")
arch/x86/kernel/setup-xen.c +2 -2
@@ -407,7 +407,7 @@ static void __init relocate_initrd(void)
 #else
 	printk(KERN_ERR "initrd extends beyond end of memory "
 	       "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-	       __pa(xen_start_info->mod_start) + xen_start_info->mod_len,
+	       xen_initrd_start + xen_start_info->mod_len,
 	       max_low_pfn_mapped << PAGE_SHIFT);
 	initrd_start = 0;
 #endif
@@ -426,7 +426,7 @@ static void __init reserve_initrd(void)
 	    !ramdisk_image || !ramdisk_size)
 		return;		/* No initrd provided by bootloader */
 #else
-	unsigned long ramdisk_image = __pa(xen_start_info->mod_start);
+	unsigned long ramdisk_image = xen_initrd_start;
 	unsigned long ramdisk_size  = xen_start_info->mod_len;
 	unsigned long ramdisk_end   = PAGE_ALIGN(ramdisk_image + ramdisk_size);
 	unsigned long end_of_lowmem = max_low_pfn_mapped << PAGE_SHIFT;
arch/x86/mm/init-xen.c +1 -10
@@ -341,16 +341,7 @@ unsigned long __init_refok init_memory_m
 
 	if (!after_bootmem && e820_table_top > e820_table_start) {
 #ifdef CONFIG_X86_64
-		if (xen_start_info->mfn_list < __START_KERNEL_map
-		    && e820_table_start <= xen_start_info->first_p2m_pfn
-		    && e820_table_top > xen_start_info->first_p2m_pfn) {
-			reserve_early(e820_table_start << PAGE_SHIFT,
-				      xen_start_info->first_p2m_pfn
-				      << PAGE_SHIFT,
-				      "PGTABLE");
-			e820_table_start = xen_start_info->first_p2m_pfn
-					 + xen_start_info->nr_p2m_frames;
-		}
+		reserve_pgtable_low();
 #endif
 		reserve_early(e820_table_start << PAGE_SHIFT,
 			      e820_table_top << PAGE_SHIFT, "PGTABLE");
arch/x86/mm/init_64-xen.c +80 -13

116 lines not on this page · raw message

include/xen/interface/elfnote.h +7 -1
@@ -173,9 +173,15 @@
 #define XEN_ELFNOTE_INIT_P2M      15
 
 /*
+ * Whether or not the guest can deal with being passed an initrd not
+ * mapped through its initial page tables.
+ */
+#define XEN_ELFNOTE_MOD_START_PFN 16
+
+/*
  * The number of the highest elfnote defined.
  */
-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_INIT_P2M
+#define XEN_ELFNOTE_MAX XEN_ELFNOTE_MOD_START_PFN
 
 /*
  * System information exported through crash notes.
include/xen/interface/xen.h +4 -1
@@ -604,7 +604,9 @@ struct start_info {
     unsigned long pt_base;      /* VIRTUAL address of page directory.     */
     unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames.       */
     unsigned long mfn_list;     /* VIRTUAL address of page-frame list.    */
-    unsigned long mod_start;    /* VIRTUAL address of pre-loaded module.  */
+    unsigned long mod_start;    /* VIRTUAL address of pre-loaded module   */
+                                /* (PFN of pre-loaded module if           */
+                                /*  SIF_MOD_START_PFN set in flags).      */
     unsigned long mod_len;      /* Size (bytes) of pre-loaded module.     */
     int8_t cmd_line[MAX_GUEST_CMDLINE];
     /* The pfn range here covers both page table and p->m table frames.   */
@@ -623,6 +625,7 @@ typedef struct start_info start_info_t;
 #define SIF_PRIVILEGED    (1<<0)  /* Is the domain privileged? */
 #define SIF_INITDOMAIN    (1<<1)  /* Is this the initial control domain? */
 #define SIF_MULTIBOOT_MOD (1<<2)  /* Is mod_start a multiboot module? */
+#define SIF_MOD_START_PFN (1<<3)  /* Is mod_start a PFN? */
 #define SIF_PM_MASK       (0xFF<<8) /* reserve 1 byte for xen-pm options */
 
 /*

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel