ia64/xen-unstable

changeset 9067:62309ca8b708

Clean up management of 'initial images' temporary buffers.
Avoid double-freeing boundary pages.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 28 11:58:45 2006 +0100 (2006-02-28)
parents e5aba4f62131
children c369d960f96b
files xen/arch/x86/domain_build.c xen/arch/x86/setup.c
line diff
     1.1 --- a/xen/arch/x86/domain_build.c	Tue Feb 28 11:41:54 2006 +0100
     1.2 +++ b/xen/arch/x86/domain_build.c	Tue Feb 28 11:58:45 2006 +0100
     1.3 @@ -28,6 +28,9 @@
     1.4  
     1.5  #include <public/version.h>
     1.6  
     1.7 +extern unsigned long initial_images_nrpages(void);
     1.8 +extern void discard_initial_images(void);
     1.9 +
    1.10  static long dom0_nrpages;
    1.11  
    1.12  /*
    1.13 @@ -249,9 +252,6 @@ int construct_dom0(struct domain *d,
    1.14      uint32_t dom0_features_supported[XENFEAT_NR_SUBMAPS] = { 0 };
    1.15      uint32_t dom0_features_required[XENFEAT_NR_SUBMAPS] = { 0 };
    1.16  
    1.17 -    extern void translate_l2pgtable(
    1.18 -        struct domain *d, l1_pgentry_t *p2m, unsigned long l2mfn);
    1.19 -
    1.20      /* Sanity! */
    1.21      BUG_ON(d->domain_id != 0);
    1.22      BUG_ON(d->vcpu[0] == NULL);
    1.23 @@ -272,18 +272,14 @@ int construct_dom0(struct domain *d,
    1.24       */
    1.25      if ( dom0_nrpages == 0 )
    1.26      {
    1.27 -        dom0_nrpages = avail_domheap_pages() +
    1.28 -            ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    1.29 -            ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT);
    1.30 +        dom0_nrpages = avail_domheap_pages() + initial_images_nrpages();
    1.31          dom0_nrpages = min(dom0_nrpages / 16, 128L << (20 - PAGE_SHIFT));
    1.32          dom0_nrpages = -dom0_nrpages;
    1.33      }
    1.34  
    1.35      /* Negative memory specification means "all memory - specified amount". */
    1.36      if ( dom0_nrpages < 0 )
    1.37 -        nr_pages = avail_domheap_pages() +
    1.38 -            ((initrd_len + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    1.39 -            ((image_len  + PAGE_SIZE - 1) >> PAGE_SHIFT) +
    1.40 +        nr_pages = avail_domheap_pages() + initial_images_nrpages() +
    1.41              dom0_nrpages;
    1.42      else
    1.43          nr_pages = dom0_nrpages;
    1.44 @@ -705,16 +701,12 @@ int construct_dom0(struct domain *d,
    1.45          hypercall_page_initialise((void *)hypercall_page);
    1.46      }
    1.47  
    1.48 -    init_domheap_pages(
    1.49 -        _image_start, (_image_start+image_len+PAGE_SIZE-1) & PAGE_MASK);
    1.50 -
    1.51 -    /* Copy the initial ramdisk and free temporary buffer. */
    1.52 +    /* Copy the initial ramdisk. */
    1.53      if ( initrd_len != 0 )
    1.54 -    {
    1.55          memcpy((void *)vinitrd_start, initrd_start, initrd_len);
    1.56 -        init_domheap_pages(
    1.57 -            _initrd_start, (_initrd_start+initrd_len+PAGE_SIZE-1) & PAGE_MASK);
    1.58 -    }
    1.59 +
    1.60 +    /* Free temporary buffers. */
    1.61 +    discard_initial_images();
    1.62  
    1.63      /* Set up start info area. */
    1.64      si = (start_info_t *)vstartinfo_start;
     2.1 --- a/xen/arch/x86/setup.c	Tue Feb 28 11:41:54 2006 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Tue Feb 28 11:58:45 2006 +0100
     2.3 @@ -144,6 +144,20 @@ static void __init do_initcalls(void)
     2.4  
     2.5  static struct e820entry e820_raw[E820MAX];
     2.6  
     2.7 +static unsigned long initial_images_start, initial_images_end;
     2.8 +
     2.9 +unsigned long initial_images_nrpages(void)
    2.10 +{
    2.11 +    unsigned long s = initial_images_start + PAGE_SIZE - 1;
    2.12 +    unsigned long e = initial_images_end;
    2.13 +    return ((e >> PAGE_SHIFT) - (s >> PAGE_SHIFT));
    2.14 +}
    2.15 +
    2.16 +void discard_initial_images(void)
    2.17 +{
    2.18 +    init_domheap_pages(initial_images_start, initial_images_end);
    2.19 +}
    2.20 +
    2.21  void __init __start_xen(multiboot_info_t *mbi)
    2.22  {
    2.23      char *cmdline;
    2.24 @@ -152,7 +166,6 @@ void __init __start_xen(multiboot_info_t
    2.25      unsigned int initrdidx = 1;
    2.26      module_t *mod = (module_t *)__va(mbi->mods_addr);
    2.27      unsigned long nr_pages, modules_length;
    2.28 -    unsigned long initial_images_start, initial_images_end;
    2.29      paddr_t s, e;
    2.30      int i, e820_warn = 0, e820_raw_nr = 0, bytes = 0;
    2.31      struct ns16550_defaults ns16550 = {