From: "Jan Beulich" Subject: [PATCH 0/2] x86: improve boot loader module handling Date: Tue, 09 Nov 2010 11:20:21 +0000 Message-ID: <4CD93C8502000078000211DD@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB69B2E65.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartB69B2E65.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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. Signed-off-by: Jan Beulich --=__PartB69B2E65.0__= Content-Type: text/plain; name="xen-x86_64-unmapped-initrd.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xen-x86_64-unmapped-initrd.patch" From: jbeulich@novell.com=0ASubject: eliminate scalability issues from = initrd hanling=0APatch-mainline: n/a=0A=0ASize restrictions native kernels = wouldn't have resulted from the initrd=0Agetting mapped into the initial = mapping. The kernel doesn't really need=0Athe initrd to be mapped, so use = new infrastructure available in 4.1+=0AXen to avoid the mapping and hence = the restriction.=0A=0A--- head-2010-10-25.orig/arch/x86/include/mach-xen/as= m/setup.h 2010-06-22 11:48:53.000000000 +0200=0A+++ head-2010-10-25/a= rch/x86/include/mach-xen/asm/setup.h 2010-11-02 17:43:24.000000000 = +0100=0A@@ -3,6 +3,13 @@=0A void xen_start_kernel(void);=0A void xen_arch_s= etup(void);=0A =0A+#ifdef CONFIG_X86_64=0A+void reserve_pfn_range(unsigned = long pfn, unsigned long nr, char *);=0A+void reserve_pgtable_low(void);=0A+= #endif=0A+=0A+extern unsigned long xen_initrd_start;=0A+=0A #endif=0A =0A = #include_next =0A--- head-2010-10-25.orig/arch/x86/kernel/head= -xen.c 2010-10-20 14:13:56.000000000 +0200=0A+++ head-2010-10-25/arch/x86/= kernel/head-xen.c 2010-11-02 16:26:25.000000000 +0100=0A@@ -74,6 = +74,8 @@ extern void nmi(void);=0A #define CALLBACK_ADDR(fn) { __KERNEL_CS,= (unsigned long)(fn) }=0A #endif=0A =0A+unsigned long __initdata xen_initrd= _start;=0A+=0A unsigned long *__read_mostly machine_to_phys_mapping =3D=0A = (void *)MACH2PHYS_VIRT_START;=0A EXPORT_SYMBOL(machine_to_phys_mapp= ing);=0A--- head-2010-10-25.orig/arch/x86/kernel/head32-xen.c 2010-10-20 = 14:13:30.000000000 +0200=0A+++ head-2010-10-25/arch/x86/kernel/head32-xen.c= 2010-11-02 16:28:20.000000000 +0100=0A@@ -83,6 +83,11 @@ void = __init i386_start_kernel(void)=0A break;=0A }=0A = #else=0A+#ifdef CONFIG_BLK_DEV_INITRD=0A+ BUG_ON(xen_start_info->flag= s & SIF_MOD_START_PFN);=0A+ if (xen_start_info->mod_start)=0A+ = xen_initrd_start =3D __pa(xen_start_info->mod_start);=0A+#endif=0A = {=0A int max_cmdline;=0A =0A--- head-2010-10-25.orig/arch/x86/ke= rnel/head64-xen.c 2010-06-22 16:36:23.000000000 +0200=0A+++ = head-2010-10-25/arch/x86/kernel/head64-xen.c 2010-11-02 16:58:05.0000000= 00 +0100=0A@@ -121,13 +121,23 @@ void __init x86_64_start_reservations(ch= =0A =0A reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop)= , "TEXT DATA BSS");=0A =0A+#ifdef CONFIG_BLK_DEV_INITRD=0A+ /* Reserve = INITRD if needed. */=0A+ if (xen_start_info->flags & SIF_MOD_START_P= FN) {=0A+ reserve_pfn_range(xen_start_info->mod_start,=0A+ = PFN_UP(xen_start_info->mod_len),=0A+ = "RAMDISK");=0A+ xen_initrd_start =3D xen_start_info= ->mod_start << PAGE_SHIFT;=0A+ } else if (xen_start_info->mod_start)=0A+ = xen_initrd_start =3D __pa(xen_start_info->mod_start);=0A+#endif=0A+= =0A if (xen_feature(XENFEAT_auto_translated_physmap))=0A = xen_start_info->mfn_list =3D ~0UL;=0A else if (xen_start_info->mfn_list = < __START_KERNEL_map)=0A- reserve_early(xen_start_info->first= _p2m_pfn << PAGE_SHIFT,=0A- (xen_start_info->firs= t_p2m_pfn=0A- + xen_start_info->nr_p2m_frames) << = PAGE_SHIFT,=0A- "INITP2M");=0A+ reserve_pfn= _range(xen_start_info->first_p2m_pfn,=0A+ = xen_start_info->nr_p2m_frames,=0A+ = "INITP2M");=0A =0A /*=0A * At this point everything still needed = from the boot loader=0A--- head-2010-10-25.orig/arch/x86/kernel/head_64-xen= .S 2010-06-22 16:36:23.000000000 +0200=0A+++ head-2010-10-25/arch/x86/= kernel/head_64-xen.S 2010-11-02 16:14:58.000000000 +0100=0A@@ -147,6 = +147,7 @@ ENTRY(empty_zero_page)=0A ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, = .quad startup_64)=0A ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, = .quad hypercall_page)=0A ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, = .quad _PAGE_PRESENT, _PAGE_PRESENT)=0A+ ELFNOTE(Xen, XEN_ELFNOTE_MOD_START_= PFN, .long 1)=0A ELFNOTE(Xen, XEN_ELFNOTE_INIT_P2M, .quad = VMEMMAP_START)=0A ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz = "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pa= e_pgdir_above_4gb|supervisor_mode_kernel")=0A ELFNOTE(Xen, XEN_ELFNOTE_LO= ADER, .asciz "generic")=0A--- head-2010-10-25.orig/arch/x86/kernel/= setup-xen.c 2010-11-08 16:08:51.000000000 +0100=0A+++ head-2010-10-25/a= rch/x86/kernel/setup-xen.c 2010-11-08 16:10:30.000000000 +0100=0A@@ = -407,7 +407,7 @@ static void __init relocate_initrd(void)=0A #else=0A = printk(KERN_ERR "initrd extends beyond end of memory "=0A = "(0x%08lx > 0x%08lx)\ndisabling initrd\n",=0A- __pa(xen_start_info-= >mod_start) + xen_start_info->mod_len,=0A+ xen_initrd_start + = xen_start_info->mod_len,=0A max_low_pfn_mapped << PAGE_SHIFT);= =0A initrd_start =3D 0;=0A #endif=0A@@ -426,7 +426,7 @@ static void = __init reserve_initrd(void)=0A !ramdisk_image || !ramdisk_size)=0A = return; /* No initrd provided by bootloader */=0A = #else=0A- unsigned long ramdisk_image =3D __pa(xen_start_info->mod_st= art);=0A+ unsigned long ramdisk_image =3D xen_initrd_start;=0A = unsigned long ramdisk_size =3D xen_start_info->mod_len;=0A unsigned = long ramdisk_end =3D PAGE_ALIGN(ramdisk_image + ramdisk_size);=0A = unsigned long end_of_lowmem =3D max_low_pfn_mapped << PAGE_SHIFT;=0A--- = head-2010-10-25.orig/arch/x86/mm/init-xen.c 2010-06-22 16:36:23.0000000= 00 +0200=0A+++ head-2010-10-25/arch/x86/mm/init-xen.c 2010-11-02 = 17:05:20.000000000 +0100=0A@@ -341,16 +341,7 @@ unsigned long __init_refok = init_memory_m=0A =0A if (!after_bootmem && e820_table_top > e820_table_s= tart) {=0A #ifdef CONFIG_X86_64=0A- if (xen_start_info->mfn_lis= t < __START_KERNEL_map=0A- && e820_table_start <=3D = xen_start_info->first_p2m_pfn=0A- && e820_table_top > = xen_start_info->first_p2m_pfn) {=0A- reserve_early(e820_= table_start << PAGE_SHIFT,=0A- xen_start_inf= o->first_p2m_pfn=0A- << PAGE_SHIFT,=0A- = "PGTABLE");=0A- e820_table_= start =3D xen_start_info->first_p2m_pfn=0A- = + xen_start_info->nr_p2m_frames;=0A- }=0A+ reserve_pgt= able_low();=0A #endif=0A reserve_early(e820_table_start << = PAGE_SHIFT,=0A e820_table_top << PAGE_SHIFT, = "PGTABLE");=0A--- head-2010-10-25.orig/arch/x86/mm/init_64-xen.c = 2010-08-18 14:39:04.000000000 +0200=0A+++ head-2010-10-25/arch/x86/mm/init_= 64-xen.c 2010-11-08 15:13:29.000000000 +0100=0A@@ -183,13 +183,72 = @@ static int __init nonx32_setup(char *str=0A }=0A __setup("noexec32=3D", = nonx32_setup);=0A =0A+static struct reserved_pfn_range {=0A+ unsigned = long pfn, nr;=0A+} reserved_pfn_ranges[3] __meminitdata;=0A+=0A+void = __init reserve_pfn_range(unsigned long pfn, unsigned long nr, char = *name)=0A+{=0A+ unsigned int i;=0A+=0A+ for (i =3D 0; i < ARRAY_SIZE(reserv= ed_pfn_ranges); ++i) {=0A+ struct reserved_pfn_range *range = =3D reserved_pfn_ranges + i;=0A+=0A+ if (!range->nr) {=0A+ = range->pfn =3D pfn;=0A+ range->nr =3D nr;=0A+ = break;=0A+ }=0A+ BUG_ON(range->pfn < pfn + = nr && pfn < range->pfn + range->nr);=0A+ if (range->pfn > = pfn) {=0A+ i =3D ARRAY_SIZE(reserved_pfn_ranges) - = 1;=0A+ if (reserved_pfn_ranges[i].nr)=0A+ = continue;=0A+ for (; reserved_pfn_ranges + i > = range; --i)=0A+ reserved_pfn_ranges[i]=0A+ = =3D reserved_pfn_ranges[i - 1];=0A+ = range->pfn =3D pfn;=0A+ range->nr =3D nr;=0A+ = break;=0A+ }=0A+ }=0A+ BUG_ON(i >=3D ARRAY_SIZE(reserved_p= fn_ranges));=0A+ reserve_early(pfn << PAGE_SHIFT, (pfn + nr) << = PAGE_SHIFT, name);=0A+}=0A+=0A+void __init reserve_pgtable_low(void)=0A+{= =0A+ unsigned int i;=0A+=0A+ for (i =3D 0; i < ARRAY_SIZE(reserved_pfn_r= anges); ++i) {=0A+ struct reserved_pfn_range *range =3D = reserved_pfn_ranges + i;=0A+=0A+ if (!range->nr)=0A+ = break;=0A+ if (e820_table_start <=3D range->pfn=0A+ = && e820_table_top > range->pfn) {=0A+ = reserve_early(e820_table_start << PAGE_SHIFT,=0A+ = range->pfn << PAGE_SHIFT,=0A+ = "PGTABLE");=0A+ e820_table_start =3D range->pfn + = range->nr;=0A+ }=0A+ }=0A+}=0A+=0A static __init unsigned long = get_table_end(void)=0A {=0A+ unsigned int i;=0A+=0A BUG_ON(!e820_table_= end);=0A- if (xen_start_info->mfn_list < __START_KERNEL_map=0A- = && e820_table_end =3D=3D xen_start_info->first_p2m_pfn) {=0A- = e820_table_end +=3D xen_start_info->nr_p2m_frames;=0A- e820_table_= top +=3D xen_start_info->nr_p2m_frames;=0A+ for (i =3D 0; i < = ARRAY_SIZE(reserved_pfn_ranges); ++i) {=0A+ struct reserved_pfn= _range *range =3D reserved_pfn_ranges + i;=0A+=0A+ if = (!range->nr)=0A+ break;=0A+ if = (e820_table_end =3D=3D range->pfn) {=0A+ e820_table_= end +=3D range->nr;=0A+ e820_table_top +=3D range->nr;=0A+ = }=0A }=0A return e820_table_end++;=0A }=0A@@ -428,14 +487,25 = @@ static inline int __meminit make_readonl=0A && !max_pfn_mapped=0A = && (paddr >=3D (e820_table_start << PAGE_SHIFT))) {=0A = unsigned long top =3D e820_table_top;=0A+ unsigned int = i;=0A+=0A+ /* Account for the ranges get_table_end() skips. = */=0A+ for (i =3D 0; i < ARRAY_SIZE(reserved_pfn_ranges); ++i) = {=0A+ const struct reserved_pfn_range *range;=0A =0A- = /* Account for the range get_table_end() skips. */=0A- if = (xen_start_info->mfn_list < __START_KERNEL_map=0A- && = e820_table_end <=3D xen_start_info->first_p2m_pfn=0A- && top = > xen_start_info->first_p2m_pfn)=0A- top +=3D xen_start_= info->nr_p2m_frames;=0A+ range =3D reserved_pfn_rang= es + i;=0A+ if (!range->nr)=0A+ = continue;=0A+ if (e820_table_end <=3D range->pfn && top = > range->pfn) {=0A+ if (paddr > (range->pfn << = PAGE_SHIFT)=0A+ && paddr < ((range->pfn + = range->nr)=0A+ << PAGE_SHIFT))=0A+= break;=0A+ = top +=3D range->nr;=0A+ }=0A+ }=0A if = (paddr < (top << PAGE_SHIFT))=0A- readonly =3D = 1;=0A+ readonly =3D (i >=3D ARRAY_SIZE(reserved_pfn_ranges= ));=0A }=0A /* Make old page tables read-only. */=0A if = (!xen_feature(XENFEAT_writable_page_tables)=0A@@ -796,9 +866,6 @@ void = __init xen_finish_init_mapping(void=0A && xen_start_info->mfn_list = >=3D __START_KERNEL_map)=0A phys_to_machine_mapping =3D=0A = __va(__pa(xen_start_info->mfn_list));=0A- if (xen_start_info-= >mod_start)=0A- xen_start_info->mod_start =3D (unsigned long)=0A- = __va(__pa(xen_start_info->mod_start));=0A =0A /* Unpin = the no longer used Xen provided page tables. */=0A mmuext.cmd =3D = MMUEXT_UNPIN_TABLE;=0A--- head-2010-10-25.orig/include/xen/interface/elfnot= e.h 2010-01-19 16:01:04.000000000 +0100=0A+++ head-2010-10-25/include/x= en/interface/elfnote.h 2010-10-29 15:51:09.000000000 +0200=0A@@ -173,9 = +173,15 @@=0A #define XEN_ELFNOTE_INIT_P2M 15=0A =0A /*=0A+ * Whether = or not the guest can deal with being passed an initrd not=0A+ * mapped = through its initial page tables.=0A+ */=0A+#define XEN_ELFNOTE_MOD_START_PF= N 16=0A+=0A+/*=0A * The number of the highest elfnote defined.=0A = */=0A-#define XEN_ELFNOTE_MAX XEN_ELFNOTE_INIT_P2M=0A+#define XEN_ELFNOTE_M= AX XEN_ELFNOTE_MOD_START_PFN=0A =0A /*=0A * System information exported = through crash notes.=0A--- head-2010-10-25.orig/include/xen/interface/xen.h= 2010-08-31 09:56:12.000000000 +0200=0A+++ head-2010-10-25/include/x= en/interface/xen.h 2010-10-29 15:47:16.000000000 +0200=0A@@ -604,7 = +604,9 @@ struct start_info {=0A unsigned long pt_base; /* = VIRTUAL address of page directory. */=0A unsigned long nr_pt_frames= ; /* Number of bootstrap p.t. frames. */=0A unsigned long = mfn_list; /* VIRTUAL address of page-frame list. */=0A- unsigned = long mod_start; /* VIRTUAL address of pre-loaded module. */=0A+ = unsigned long mod_start; /* VIRTUAL address of pre-loaded module = */=0A+ /* (PFN of pre-loaded module if = */=0A+ /* SIF_MOD_START_PFN set in = flags). */=0A unsigned long mod_len; /* Size (bytes) of = pre-loaded module. */=0A int8_t cmd_line[MAX_GUEST_CMDLINE];=0A = /* The pfn range here covers both page table and p->m table frames. = */=0A@@ -623,6 +625,7 @@ typedef struct start_info start_info_t;=0A = #define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */=0A = #define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? = */=0A #define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot = module? */=0A+#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? = */=0A #define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm = options */=0A =0A /*=0A --=__PartB69B2E65.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartB69B2E65.0__=--