ia64/xen-unstable

diff xen/arch/ia64/xen/xensetup.c @ 15131:26492c6476f0

[IA64] free initmem and add __init and __initdata.

ia64 counter part of xen-unstable.hg 15043:759d924af6d8.
By freeing init area, un/pickle_domain() is broken because
__init_begin < xen_heap_start. This is fixed by introducing xen_pickle_offset.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Wed May 23 08:51:42 2007 -0600 (2007-05-23)
parents aeac9a7d97e0
children 90f19b7667f7
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Mon May 21 14:30:09 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed May 23 08:51:42 2007 -0600
     1.3 @@ -33,7 +33,7 @@
     1.4  unsigned long xenheap_phys_end, total_pages;
     1.5  
     1.6  char saved_command_line[COMMAND_LINE_SIZE];
     1.7 -char dom0_command_line[COMMAND_LINE_SIZE];
     1.8 +char __initdata dom0_command_line[COMMAND_LINE_SIZE];
     1.9  
    1.10  cpumask_t cpu_present_map;
    1.11  
    1.12 @@ -58,17 +58,17 @@ static int opt_nosmp;
    1.13  boolean_param("nosmp", opt_nosmp);
    1.14  
    1.15  /* maxcpus: maximum number of CPUs to activate. */
    1.16 -static unsigned int max_cpus = NR_CPUS;
    1.17 +static unsigned int __initdata max_cpus = NR_CPUS;
    1.18  integer_param("maxcpus", max_cpus); 
    1.19  
    1.20  /* xencons: if true enable xenconsole input (and irq).
    1.21     Note: you have to disable 8250 serials in domains (to avoid use of the
    1.22     same resource).  */
    1.23 -static int opt_xencons = 1;
    1.24 +static int __initdata opt_xencons = 1;
    1.25  integer_param("xencons", opt_xencons);
    1.26  
    1.27  /* Toggle to allow non-legacy xencons UARTs to run in polling mode */
    1.28 -static int opt_xencons_poll;
    1.29 +static int __initdata opt_xencons_poll;
    1.30  boolean_param("xencons_poll", opt_xencons_poll);
    1.31  
    1.32  /*
    1.33 @@ -85,9 +85,9 @@ unsigned int opt_xenheap_megabytes = XEN
    1.34  unsigned long xenheap_size = XENHEAP_DEFAULT_SIZE;
    1.35  extern long running_on_sim;
    1.36  unsigned long xen_pstart;
    1.37 -void *xen_heap_start __read_mostly;
    1.38 +void *xen_pickle_offset __read_mostly;
    1.39  
    1.40 -static int
    1.41 +static int __init
    1.42  xen_count_pages(u64 start, u64 end, void *arg)
    1.43  {
    1.44      unsigned long *count = arg;
    1.45 @@ -119,7 +119,7 @@ static void __init do_initcalls(void)
    1.46   */
    1.47  static char null[4] = { 0 };
    1.48  
    1.49 -void early_cmdline_parse(char **cmdline_p)
    1.50 +void __init early_cmdline_parse(char **cmdline_p)
    1.51  {
    1.52      char *guest_cmd;
    1.53      static const char * const split = "--";
    1.54 @@ -164,11 +164,11 @@ struct ns16550_defaults ns16550_com2 = {
    1.55  };
    1.56  
    1.57  /* efi_print: print efi table at boot */
    1.58 -static int opt_efi_print;
    1.59 +static int __initdata opt_efi_print;
    1.60  boolean_param("efi_print", opt_efi_print);
    1.61  
    1.62  /* print EFI memory map: */
    1.63 -static void
    1.64 +static void __init
    1.65  efi_print(void)
    1.66  {
    1.67      void *efi_map_start, *efi_map_end;
    1.68 @@ -242,7 +242,19 @@ md_overlaps(efi_memory_desc_t *md, unsig
    1.69  
    1.70  #define MD_SIZE(md) (md->num_pages << EFI_PAGE_SHIFT)
    1.71  
    1.72 -void start_kernel(void)
    1.73 +extern char __init_begin[], __init_end[];
    1.74 +static void noinline init_done(void)
    1.75 +{
    1.76 +    memset(__init_begin, 0, __init_end - __init_begin);
    1.77 +    flush_icache_range((unsigned long)__init_begin, (unsigned long)__init_end);
    1.78 +    init_xenheap_pages(__pa(__init_begin), __pa(__init_end));
    1.79 +    printk("Freed %ldkB init memory.\n",
    1.80 +           (long)(__init_end-__init_begin)>>10);
    1.81 +    
    1.82 +    startup_cpu_idle_loop();
    1.83 +}
    1.84 +
    1.85 +void __init start_kernel(void)
    1.86  {
    1.87      char *cmdline;
    1.88      unsigned long nr_pages;
    1.89 @@ -252,6 +264,7 @@ void start_kernel(void)
    1.90      struct domain *idle_domain;
    1.91      struct vcpu *dom0_vcpu0;
    1.92      efi_memory_desc_t *kern_md, *last_md, *md;
    1.93 +    void *xen_heap_start;
    1.94  #ifdef CONFIG_SMP
    1.95      int i;
    1.96  #endif
    1.97 @@ -391,6 +404,14 @@ void start_kernel(void)
    1.98      efi_memmap_walk(find_max_pfn, &max_page);
    1.99      printk("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
   1.100      efi_print();
   1.101 +    
   1.102 +    /*
   1.103 +     * later [__init_begin, __init_end) will be freed up as xen heap
   1.104 +     * so that struct domain might be allocated from the init area
   1.105 +     * which is < xen_heap_start. so we can't simply set
   1.106 +     * xen_pickle_offset = xen_heap_start.
   1.107 +     */
   1.108 +    xen_pickle_offset = ia64_imva(__init_begin);
   1.109  
   1.110      xen_heap_start = memguard_init(ia64_imva(&_end));
   1.111      printk("Before xen_heap_start: %p\n", xen_heap_start);
   1.112 @@ -546,7 +567,7 @@ printk("num_online_cpus=%d, max_cpus=%d\
   1.113  
   1.114      domain_unpause_by_systemcontroller(dom0);
   1.115  
   1.116 -    startup_cpu_idle_loop();
   1.117 +    init_done();
   1.118  }
   1.119  
   1.120  void arch_get_xen_caps(xen_capabilities_info_t *info)