From: "Jan Beulich" Subject: [PATCH 2/2] x86: allow passing initrd to kernel without exposing it through the initial mapping Date: Tue, 09 Nov 2010 11:24:33 +0000 Message-ID: <4CD93D8102000078000211F8@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB39E2B61.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. --=__PartB39E2B61.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The (Dom0 only for now) kernel can indicate that it doesn't need its initrd mapped through a newly added ELF note - it gets passed the PFN of the initrd in this case instead of the virtual address. Even for kernels not making use of the new feature, the initrd will no longer get copied into the initial mapping, but the memory it lives in will get assigned to and mapped for the guest instead. Signed-off-by: Jan Beulich --- 2010-11-09.orig/xen/arch/x86/domain_build.c 2010-11-09 10:30:06.0000000= 00 +0100 +++ 2010-11-09/xen/arch/x86/domain_build.c 2010-11-09 10:30:14.0000000= 00 +0100 @@ -225,7 +225,9 @@ static unsigned long __init compute_dom0 size_t sizeof_long =3D is_pv_32bit_domain(d) ? sizeof(int) : = sizeof(long); =20 vstart =3D parms->virt_base; - vend =3D round_pgup(parms->virt_kend) + round_pgup(initrd_len); + vend =3D round_pgup(parms->virt_kend); + if ( !parms->elf_notes[XEN_ELFNOTE_MOD_START_PFN].data.num ) + vend +=3D round_pgup(initrd_len); end =3D vend + nr_pages * sizeof_long; =20 if ( end > vstart ) @@ -286,7 +288,7 @@ static void __init process_dom0_ioports_ int __init construct_dom0( struct domain *d, const module_t *image, unsigned long image_headroom, - const module_t *initrd, + module_t *initrd, void *(*bootstrap_map)(const module_t *), char *cmdline) { @@ -297,6 +299,7 @@ int __init construct_dom0( unsigned long nr_pt_pages; unsigned long alloc_spfn; unsigned long alloc_epfn; + unsigned long initrd_pfn =3D -1, initrd_mfn =3D 0; unsigned long count; struct page_info *page =3D NULL; start_info_t *si; @@ -449,9 +452,17 @@ int __init construct_dom0( v_start =3D parms.virt_base; vkern_start =3D parms.virt_kstart; vkern_end =3D parms.virt_kend; - vinitrd_start =3D round_pgup(vkern_end); - vinitrd_end =3D vinitrd_start + initrd_len; - vphysmap_start =3D round_pgup(vinitrd_end); + if ( parms.elf_notes[XEN_ELFNOTE_MOD_START_PFN].data.num ) + { + vinitrd_start =3D vinitrd_end =3D 0; + vphysmap_start =3D round_pgup(vkern_end); + } + else + { + vinitrd_start =3D round_pgup(vkern_end); + vinitrd_end =3D vinitrd_start + initrd_len; + vphysmap_start =3D round_pgup(vinitrd_end); + } vphysmap_end =3D vphysmap_start + (nr_pages * (!is_pv_32on64_domai= n(d) ? sizeof(unsigned = long) : sizeof(unsigned = int))); @@ -490,8 +501,11 @@ int __init construct_dom0( #endif } =20 - order =3D get_order_from_bytes(v_end - v_start); - if ( (1UL << order) > nr_pages ) + count =3D v_end - v_start; + if ( vinitrd_start ) + count -=3D PAGE_ALIGN(initrd_len); + order =3D get_order_from_bytes(count); + if ( (1UL << order) + PFN_UP(initrd_len) > nr_pages ) panic("Domain 0 allocation is too small for kernel image.\n"); =20 if ( parms.p2m_base !=3D UNSET_ADDR ) @@ -510,12 +524,54 @@ int __init construct_dom0( alloc_spfn =3D page_to_mfn(page); alloc_epfn =3D alloc_spfn + d->tot_pages; =20 + if ( initrd_len ) + { + initrd_pfn =3D vinitrd_start ? + (vinitrd_start - v_start) >> PAGE_SHIFT : + d->tot_pages; + initrd_mfn =3D mfn =3D initrd->mod_start; + count =3D PFN_UP(initrd_len); +#ifdef __x86_64__ + if ( d->arch.physaddr_bitsize && + ((mfn + count - 1) >> (d->arch.physaddr_bitsize - PAGE_SHIFT)= ) ) + { + order =3D get_order_from_pages(count); + page =3D alloc_domheap_pages(d, order, 0); + if ( !page ) + panic("Not enough RAM for domain 0 initrd.\n"); + for ( count =3D -count; order--; ) + if ( count & (1UL << order) ) + { + free_domheap_pages(page, order); + page +=3D 1UL << order; + } + memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start), + initrd_len); + mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + init_domheap_pages(mpt_alloc, + mpt_alloc + PAGE_ALIGN(initrd_len)); + initrd->mod_start =3D initrd_mfn =3D page_to_mfn(page); + } + else +#endif + while ( count-- ) + if ( assign_pages(d, mfn_to_page(mfn++), 0, 0) ) + BUG(); + initrd->mod_end =3D 0; + } + printk("PHYSICAL MEMORY ARRANGEMENT:\n" " Dom0 alloc.: %"PRIpaddr"->%"PRIpaddr, pfn_to_paddr(alloc_spfn), pfn_to_paddr(alloc_epfn)); if ( d->tot_pages < nr_pages ) printk(" (%lu pages to be allocated)", nr_pages - d->tot_pages); + if ( initrd ) + { + mpt_alloc =3D (paddr_t)initrd->mod_start << PAGE_SHIFT; + printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr, + mpt_alloc, mpt_alloc + initrd_len); + } printk("\nVIRTUAL MEMORY ARRANGEMENT:\n" " Loaded kernel: %p->%p\n" " Init. ramdisk: %p->%p\n" @@ -534,6 +590,8 @@ int __init construct_dom0( printk(" ENTRY ADDRESS: %p\n", _p(parms.virt_entry)); =20 mpt_alloc =3D (vpt_start - v_start) + pfn_to_paddr(alloc_spfn); + if ( vinitrd_start ) + mpt_alloc -=3D PAGE_ALIGN(initrd_len); =20 #if defined(__i386__) /* @@ -571,7 +629,7 @@ int __init construct_dom0( l2e_from_page(perdomain_pt_page(d, i), __PAGE_HYPERVISOR); =20 l2tab +=3D l2_linear_offset(v_start); - mfn =3D alloc_spfn; + pfn =3D alloc_spfn; for ( count =3D 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ ) { if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) @@ -584,14 +642,16 @@ int __init construct_dom0( if ( count =3D=3D 0 ) l1tab +=3D l1_table_offset(v_start); } + if ( count < initrd_pfn || count >=3D initrd_pfn + PFN_UP(initrd_l= en) ) + mfn =3D pfn++; + else + mfn =3D initrd_mfn++; *l1tab =3D l1e_from_pfn(mfn, L1_PROT); l1tab++; =20 page =3D mfn_to_page(mfn); if ( !get_page_and_type(page, d, PGT_writable_page) ) BUG(); - - mfn++; } #undef MPT_ALLOC =20 @@ -688,7 +748,7 @@ int __init construct_dom0( v->arch.guest_table_user =3D v->arch.guest_table; =20 l4tab +=3D l4_table_offset(v_start); - mfn =3D alloc_spfn; + pfn =3D alloc_spfn; for ( count =3D 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ ) { if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) ) @@ -722,6 +782,10 @@ int __init construct_dom0( *l2tab =3D l2e_from_paddr(__pa(l1start), L2_PROT); l2tab++; } + if ( count < initrd_pfn || count >=3D initrd_pfn + PFN_UP(initrd_l= en) ) + mfn =3D pfn++; + else + mfn =3D initrd_mfn++; *l1tab =3D l1e_from_pfn(mfn, (!is_pv_32on64_domain(d) ? L1_PROT : COMPAT_L1_PROT)); l1tab++; @@ -730,8 +794,6 @@ int __init construct_dom0( if ( (page->u.inuse.type_info =3D=3D 0) && !get_page_and_type(page, d, PGT_writable_page) ) BUG(); - - mfn++; } =20 if ( is_pv_32on64_domain(d) ) @@ -837,15 +899,6 @@ int __init construct_dom0( d, (void *)(unsigned long)parms.virt_hypercall); } =20 - /* Copy the initial ramdisk. */ - if ( initrd_len !=3D 0 ) - { - char *initrd_start =3D bootstrap_map(initrd); - - memcpy((void *)vinitrd_start, initrd_start, initrd_len); - bootstrap_map(NULL); - } - /* Free temporary buffers. */ discard_initial_images(); =20 @@ -857,6 +910,8 @@ int __init construct_dom0( si->shared_info =3D virt_to_maddr(d->shared_info); =20 si->flags =3D SIF_PRIVILEGED | SIF_INITDOMAIN; + if ( !vinitrd_start && initrd_len ) + si->flags |=3D SIF_MOD_START_PFN; si->flags |=3D (xen_processor_pmbits << 8) & SIF_PM_MASK; si->pt_base =3D vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_domain= (d); si->nr_pt_frames =3D nr_pt_pages; @@ -971,9 +1026,16 @@ int __init construct_dom0( for ( pfn =3D 0; pfn < count; pfn++ ) { mfn =3D pfn + alloc_spfn; + if ( pfn >=3D initrd_pfn ) + { + if ( pfn < initrd_pfn + PFN_UP(initrd_len) ) + mfn =3D initrd->mod_start + (pfn - initrd_pfn); + else + mfn -=3D PFN_UP(initrd_len); + } #ifndef NDEBUG #define REVERSE_START ((v_end - v_start) >> PAGE_SHIFT) - if ( pfn > REVERSE_START ) + if ( pfn > REVERSE_START && (vinitrd_start || pfn < initrd_pfn) ) mfn =3D alloc_epfn - (pfn - REVERSE_START); #endif if ( !is_pv_32on64_domain(d) ) @@ -999,14 +1061,14 @@ int __init construct_dom0( ((unsigned long *)vphysmap_start)[pfn] =3D mfn; set_gpfn_from_mfn(mfn, pfn); ++pfn; -#ifndef NDEBUG - ++alloc_epfn; -#endif if (!(pfn & 0xfffff)) process_pending_softirqs(); } } BUG_ON(pfn !=3D d->tot_pages); +#ifndef NDEBUG + alloc_epfn +=3D PFN_UP(initrd_len) + si->nr_p2m_frames; +#endif while ( pfn < nr_pages ) { if ( (page =3D alloc_chunk(d, nr_pages - d->tot_pages)) =3D=3D = NULL ) @@ -1031,7 +1093,7 @@ int __init construct_dom0( =20 if ( initrd_len !=3D 0 ) { - si->mod_start =3D vinitrd_start; + si->mod_start =3D vinitrd_start ?: initrd_pfn; si->mod_len =3D initrd_len; } =20 --- 2010-11-09.orig/xen/common/libelf/libelf-dominfo.c 2010-08-27 = 11:44:09.000000000 +0200 +++ 2010-11-09/xen/common/libelf/libelf-dominfo.c 2010-11-09 = 10:30:14.000000000 +0100 @@ -115,6 +115,7 @@ int elf_xen_parse_note(struct elf_binary [XEN_ELFNOTE_FEATURES] =3D { "FEATURES", 1}, [XEN_ELFNOTE_BSD_SYMTAB] =3D { "BSD_SYMTAB", 1}, [XEN_ELFNOTE_SUSPEND_CANCEL] =3D { "SUSPEND_CANCEL", 0 }, + [XEN_ELFNOTE_MOD_START_PFN] =3D { "MOD_START_PFN", 0 }, }; /* *INDENT-ON* */ =20 --- 2010-11-09.orig/xen/include/asm-x86/setup.h 2010-11-09 10:30:06.0000000= 00 +0100 +++ 2010-11-09/xen/include/asm-x86/setup.h 2010-11-09 10:30:14.0000000= 00 +0100 @@ -30,7 +30,7 @@ void vesa_mtrr_init(void); int construct_dom0( struct domain *d, const module_t *kernel, unsigned long kernel_headroom, - const module_t *initrd, + module_t *initrd, void *(*bootstrap_map)(const module_t *), char *cmdline); =20 --- 2010-11-09.orig/xen/include/public/elfnote.h 2009-01-14 = 09:47:07.000000000 +0100 +++ 2010-11-09/xen/include/public/elfnote.h 2010-11-09 10:30:14.0000000= 00 +0100 @@ -173,9 +173,15 @@ #define XEN_ELFNOTE_INIT_P2M 15 =20 /* + * 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 =20 /* * System information exported through crash notes. --- 2010-11-09.orig/xen/include/public/xen.h 2010-06-11 11:41:35.0000000= 00 +0200 +++ 2010-11-09/xen/include/public/xen.h 2010-11-09 10:30:14.000000000 = +0100 @@ -581,7 +581,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. = */ @@ -600,6 +602,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 = */ =20 /* --=__PartB39E2B61.0__= Content-Type: text/plain; name="x86-dom0-initrd-map.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-dom0-initrd-map.patch" The (Dom0 only for now) kernel can indicate that it doesn't need its=0Ainit= rd mapped through a newly added ELF note - it gets passed the PFN=0Aof the = initrd in this case instead of the virtual address.=0A=0AEven for kernels = not making use of the new feature, the initrd will=0Ano longer get copied = into the initial mapping, but the memory it lives=0Ain will get assigned = to and mapped for the guest instead.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- 2010-11-09.orig/xen/arch/x86/domain_build.c = 2010-11-09 10:30:06.000000000 +0100=0A+++ 2010-11-09/xen/arch/x86/domain_bu= ild.c 2010-11-09 10:30:14.000000000 +0100=0A@@ -225,7 +225,9 @@ static = unsigned long __init compute_dom0=0A size_t sizeof_long =3D = is_pv_32bit_domain(d) ? sizeof(int) : sizeof(long);=0A =0A vstart = =3D parms->virt_base;=0A- vend =3D round_pgup(parms->virt_kend) + = round_pgup(initrd_len);=0A+ vend =3D round_pgup(parms->virt_kend);= =0A+ if ( !parms->elf_notes[XEN_ELFNOTE_MOD_START_PFN].data.num = )=0A+ vend +=3D round_pgup(initrd_len);=0A end =3D vend = + nr_pages * sizeof_long;=0A =0A if ( end > vstart )=0A@@ -286,7 = +288,7 @@ static void __init process_dom0_ioports_=0A int __init construct_= dom0(=0A struct domain *d,=0A const module_t *image, unsigned long = image_headroom,=0A- const module_t *initrd,=0A+ module_t *initrd,=0A = void *(*bootstrap_map)(const module_t *),=0A char *cmdline)=0A = {=0A@@ -297,6 +299,7 @@ int __init construct_dom0(=0A unsigned long = nr_pt_pages;=0A unsigned long alloc_spfn;=0A unsigned long = alloc_epfn;=0A+ unsigned long initrd_pfn =3D -1, initrd_mfn =3D 0;=0A = unsigned long count;=0A struct page_info *page =3D NULL;=0A = start_info_t *si;=0A@@ -449,9 +452,17 @@ int __init construct_dom0(=0A = v_start =3D parms.virt_base;=0A vkern_start =3D = parms.virt_kstart;=0A vkern_end =3D parms.virt_kend;=0A- = vinitrd_start =3D round_pgup(vkern_end);=0A- vinitrd_end =3D = vinitrd_start + initrd_len;=0A- vphysmap_start =3D round_pgup(vinitrd_= end);=0A+ if ( parms.elf_notes[XEN_ELFNOTE_MOD_START_PFN].data.num = )=0A+ {=0A+ vinitrd_start =3D vinitrd_end =3D 0;=0A+ = vphysmap_start =3D round_pgup(vkern_end);=0A+ }=0A+ else=0A+ = {=0A+ vinitrd_start =3D round_pgup(vkern_end);=0A+ = vinitrd_end =3D vinitrd_start + initrd_len;=0A+ vphysmap_start = =3D round_pgup(vinitrd_end);=0A+ }=0A vphysmap_end =3D = vphysmap_start + (nr_pages * (!is_pv_32on64_domain(d) ?=0A = sizeof(unsigned long) :=0A = sizeof(unsigned int)));=0A@@ = -490,8 +501,11 @@ int __init construct_dom0(=0A #endif=0A }=0A =0A- = order =3D get_order_from_bytes(v_end - v_start);=0A- if ( (1UL << = order) > nr_pages )=0A+ count =3D v_end - v_start;=0A+ if ( = vinitrd_start )=0A+ count -=3D PAGE_ALIGN(initrd_len);=0A+ order = =3D get_order_from_bytes(count);=0A+ if ( (1UL << order) + PFN_UP(initrd= _len) > nr_pages )=0A panic("Domain 0 allocation is too small for = kernel image.\n");=0A =0A if ( parms.p2m_base !=3D UNSET_ADDR )=0A@@ = -510,12 +524,54 @@ int __init construct_dom0(=0A alloc_spfn =3D = page_to_mfn(page);=0A alloc_epfn =3D alloc_spfn + d->tot_pages;=0A = =0A+ if ( initrd_len )=0A+ {=0A+ initrd_pfn =3D vinitrd_start = ?=0A+ (vinitrd_start - v_start) >> PAGE_SHIFT :=0A+ = d->tot_pages;=0A+ initrd_mfn =3D mfn =3D initrd->mo= d_start;=0A+ count =3D PFN_UP(initrd_len);=0A+#ifdef __x86_64__=0A+ = if ( d->arch.physaddr_bitsize &&=0A+ ((mfn + count - 1) = >> (d->arch.physaddr_bitsize - PAGE_SHIFT)) )=0A+ {=0A+ = order =3D get_order_from_pages(count);=0A+ page =3D alloc_domhea= p_pages(d, order, 0);=0A+ if ( !page )=0A+ = panic("Not enough RAM for domain 0 initrd.\n");=0A+ for ( count = =3D -count; order--; )=0A+ if ( count & (1UL << order) = )=0A+ {=0A+ free_domheap_pages(page, = order);=0A+ page +=3D 1UL << order;=0A+ = }=0A+ memcpy(page_to_virt(page), mfn_to_virt(initrd->mod_start),= =0A+ initrd_len);=0A+ mpt_alloc =3D (paddr_t)i= nitrd->mod_start << PAGE_SHIFT;=0A+ init_domheap_pages(mpt_alloc= ,=0A+ mpt_alloc + PAGE_ALIGN(initrd_len));=0A= + initrd->mod_start =3D initrd_mfn =3D page_to_mfn(page);=0A+ = }=0A+ else=0A+#endif=0A+ while ( count-- )=0A+ = if ( assign_pages(d, mfn_to_page(mfn++), 0, 0) )=0A+ = BUG();=0A+ initrd->mod_end =3D 0;=0A+ }=0A+=0A = printk("PHYSICAL MEMORY ARRANGEMENT:\n"=0A " Dom0 alloc.: = %"PRIpaddr"->%"PRIpaddr,=0A pfn_to_paddr(alloc_spfn), pfn_to_pad= dr(alloc_epfn));=0A if ( d->tot_pages < nr_pages )=0A printk(" = (%lu pages to be allocated)",=0A nr_pages - d->tot_pages);= =0A+ if ( initrd )=0A+ {=0A+ mpt_alloc =3D (paddr_t)initrd->mo= d_start << PAGE_SHIFT;=0A+ printk("\n Init. ramdisk: %"PRIpaddr"->%"= PRIpaddr,=0A+ mpt_alloc, mpt_alloc + initrd_len);=0A+ = }=0A printk("\nVIRTUAL MEMORY ARRANGEMENT:\n"=0A " Loaded = kernel: %p->%p\n"=0A " Init. ramdisk: %p->%p\n"=0A@@ -534,6 = +590,8 @@ int __init construct_dom0(=0A printk(" ENTRY ADDRESS: %p\n", = _p(parms.virt_entry));=0A =0A mpt_alloc =3D (vpt_start - v_start) + = pfn_to_paddr(alloc_spfn);=0A+ if ( vinitrd_start )=0A+ mpt_alloc = -=3D PAGE_ALIGN(initrd_len);=0A =0A #if defined(__i386__)=0A /*=0A@@ = -571,7 +629,7 @@ int __init construct_dom0(=0A l2e_from_page(pe= rdomain_pt_page(d, i), __PAGE_HYPERVISOR);=0A =0A l2tab +=3D l2_linear_= offset(v_start);=0A- mfn =3D alloc_spfn;=0A+ pfn =3D alloc_spfn;=0A = for ( count =3D 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ )=0A = {=0A if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )=0A@@ = -584,14 +642,16 @@ int __init construct_dom0(=0A if ( count = =3D=3D 0 )=0A l1tab +=3D l1_table_offset(v_start);=0A = }=0A+ if ( count < initrd_pfn || count >=3D initrd_pfn + = PFN_UP(initrd_len) )=0A+ mfn =3D pfn++;=0A+ else=0A+ = mfn =3D initrd_mfn++;=0A *l1tab =3D l1e_from_pfn(mfn, = L1_PROT);=0A l1tab++;=0A =0A page =3D mfn_to_page(m= fn);=0A if ( !get_page_and_type(page, d, PGT_writable_page) )=0A = BUG();=0A-=0A- mfn++;=0A }=0A #undef MPT_ALLOC=0A = =0A@@ -688,7 +748,7 @@ int __init construct_dom0(=0A v->arch.guest_= table_user =3D v->arch.guest_table;=0A =0A l4tab +=3D l4_table_offset(v= _start);=0A- mfn =3D alloc_spfn;=0A+ pfn =3D alloc_spfn;=0A for = ( count =3D 0; count < ((v_end-v_start)>>PAGE_SHIFT); count++ )=0A = {=0A if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )=0A@@ -722,6 = +782,10 @@ int __init construct_dom0(=0A *l2tab =3D l2e_from_pa= ddr(__pa(l1start), L2_PROT);=0A l2tab++;=0A }=0A+ = if ( count < initrd_pfn || count >=3D initrd_pfn + PFN_UP(initrd_len) = )=0A+ mfn =3D pfn++;=0A+ else=0A+ mfn =3D = initrd_mfn++;=0A *l1tab =3D l1e_from_pfn(mfn, (!is_pv_32on64_domain= (d) ?=0A L1_PROT : COMPAT_L1_PROT));=0A= l1tab++;=0A@@ -730,8 +794,6 @@ int __init construct_dom0(=0A = if ( (page->u.inuse.type_info =3D=3D 0) &&=0A !get_page_and= _type(page, d, PGT_writable_page) )=0A BUG();=0A-=0A- = mfn++;=0A }=0A =0A if ( is_pv_32on64_domain(d) )=0A@@ -837,15 = +899,6 @@ int __init construct_dom0(=0A d, (void *)(unsigned = long)parms.virt_hypercall);=0A }=0A =0A- /* Copy the initial = ramdisk. */=0A- if ( initrd_len !=3D 0 )=0A- {=0A- char = *initrd_start =3D bootstrap_map(initrd);=0A-=0A- memcpy((void = *)vinitrd_start, initrd_start, initrd_len);=0A- bootstrap_map(NULL);= =0A- }=0A-=0A /* Free temporary buffers. */=0A discard_initial_i= mages();=0A =0A@@ -857,6 +910,8 @@ int __init construct_dom0(=0A = si->shared_info =3D virt_to_maddr(d->shared_info);=0A =0A si->flags = =3D SIF_PRIVILEGED | SIF_INITDOMAIN;=0A+ if ( !vinitrd_start && = initrd_len )=0A+ si->flags |=3D SIF_MOD_START_PFN;=0A = si->flags |=3D (xen_processor_pmbits << 8) & SIF_PM_MASK;=0A = si->pt_base =3D vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_domain(d);= =0A si->nr_pt_frames =3D nr_pt_pages;=0A@@ -971,9 +1026,16 @@ int = __init construct_dom0(=0A for ( pfn =3D 0; pfn < count; pfn++ )=0A = {=0A mfn =3D pfn + alloc_spfn;=0A+ if ( pfn >=3D initrd_pfn = )=0A+ {=0A+ if ( pfn < initrd_pfn + PFN_UP(initrd_len) = )=0A+ mfn =3D initrd->mod_start + (pfn - initrd_pfn);=0A+ = else=0A+ mfn -=3D PFN_UP(initrd_len);=0A+ = }=0A #ifndef NDEBUG=0A #define REVERSE_START ((v_end - v_start) >> = PAGE_SHIFT)=0A- if ( pfn > REVERSE_START )=0A+ if ( pfn > = REVERSE_START && (vinitrd_start || pfn < initrd_pfn) )=0A mfn = =3D alloc_epfn - (pfn - REVERSE_START);=0A #endif=0A if ( = !is_pv_32on64_domain(d) )=0A@@ -999,14 +1061,14 @@ int __init construct_dom= 0(=0A ((unsigned long *)vphysmap_start)[pfn] =3D mfn;=0A = set_gpfn_from_mfn(mfn, pfn);=0A ++pfn;=0A-#ifndef = NDEBUG=0A- ++alloc_epfn;=0A-#endif=0A if (!(pfn & = 0xfffff))=0A process_pending_softirqs();=0A }=0A = }=0A BUG_ON(pfn !=3D d->tot_pages);=0A+#ifndef NDEBUG=0A+ = alloc_epfn +=3D PFN_UP(initrd_len) + si->nr_p2m_frames;=0A+#endif=0A = while ( pfn < nr_pages )=0A {=0A if ( (page =3D alloc_chunk(d, = nr_pages - d->tot_pages)) =3D=3D NULL )=0A@@ -1031,7 +1093,7 @@ int __init = construct_dom0(=0A =0A if ( initrd_len !=3D 0 )=0A {=0A- = si->mod_start =3D vinitrd_start;=0A+ si->mod_start =3D vinitrd_start= ?: initrd_pfn;=0A si->mod_len =3D initrd_len;=0A }=0A = =0A--- 2010-11-09.orig/xen/common/libelf/libelf-dominfo.c 2010-08-27 = 11:44:09.000000000 +0200=0A+++ 2010-11-09/xen/common/libelf/libelf-dominfo.= c 2010-11-09 10:30:14.000000000 +0100=0A@@ -115,6 +115,7 @@ int = elf_xen_parse_note(struct elf_binary=0A [XEN_ELFNOTE_FEATURES] =3D = { "FEATURES", 1},=0A [XEN_ELFNOTE_BSD_SYMTAB] =3D { "BSD_SYMTAB", = 1},=0A [XEN_ELFNOTE_SUSPEND_CANCEL] =3D { "SUSPEND_CANCEL", 0 = },=0A+ [XEN_ELFNOTE_MOD_START_PFN] =3D { "MOD_START_PFN", 0 },=0A = };=0A /* *INDENT-ON* */=0A =0A--- 2010-11-09.orig/xen/include/asm-x86/set= up.h 2010-11-09 10:30:06.000000000 +0100=0A+++ 2010-11-09/xen/include/as= m-x86/setup.h 2010-11-09 10:30:14.000000000 +0100=0A@@ -30,7 +30,7 @@ = void vesa_mtrr_init(void);=0A int construct_dom0(=0A struct domain = *d,=0A const module_t *kernel, unsigned long kernel_headroom,=0A- = const module_t *initrd,=0A+ module_t *initrd,=0A void *(*bootstrap_m= ap)(const module_t *),=0A char *cmdline);=0A =0A--- 2010-11-09.orig/xen= /include/public/elfnote.h 2009-01-14 09:47:07.000000000 +0100=0A+++ = 2010-11-09/xen/include/public/elfnote.h 2010-11-09 10:30:14.000000000 = +0100=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_PFN 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_MAX XEN_ELFNOTE_MOD_START_PFN=0A =0A /*=0A * System = information exported through crash notes.=0A--- 2010-11-09.orig/xen/include= /public/xen.h 2010-06-11 11:41:35.000000000 +0200=0A+++ 2010-11-09/xen/in= clude/public/xen.h 2010-11-09 10:30:14.000000000 +0100=0A@@ -581,7 = +581,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@@ -600,6 +602,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 --=__PartB39E2B61.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 --=__PartB39E2B61.0__=--