ia64/xen-unstable

changeset 16792:8977f087351a

[IA64] Fix start_kernel() to call init_xenheap_pages() with correct range.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:44 2008 -0700 (2008-01-17)
parents 4fbde3a39909
children 003036d7db0f
files xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/xensetup.c	Thu Jan 17 12:05:43 2008 -0700
     1.2 +++ b/xen/arch/ia64/xen/xensetup.c	Thu Jan 17 12:05:44 2008 -0700
     1.3 @@ -255,7 +255,7 @@ md_overlap_with_boot_param(const efi_mem
     1.4  }
     1.5  
     1.6  #define MD_SIZE(md) (md->num_pages << EFI_PAGE_SHIFT)
     1.7 -#define MD_END(md) ((md)->phys_addr + ((md)->num_pages << EFI_PAGE_SHIFT))
     1.8 +#define MD_END(md) ((md)->phys_addr + MD_SIZE(md))
     1.9  
    1.10  extern char __init_begin[], __init_end[];
    1.11  static void noinline init_done(void)
    1.12 @@ -269,6 +269,41 @@ static void noinline init_done(void)
    1.13      startup_cpu_idle_loop();
    1.14  }
    1.15  
    1.16 +struct xen_heap_desc {
    1.17 +    void*               xen_heap_start;
    1.18 +    unsigned long       xenheap_phys_end;
    1.19 +    efi_memory_desc_t*  kern_md;
    1.20 +};
    1.21 +
    1.22 +static int __init
    1.23 +init_xenheap_mds(unsigned long start, unsigned long end, void *arg)
    1.24 +{
    1.25 +    struct xen_heap_desc *desc = (struct xen_heap_desc*)arg;
    1.26 +    unsigned long md_end = __pa(desc->xen_heap_start);
    1.27 +    efi_memory_desc_t* md;
    1.28 +
    1.29 +    start = __pa(start);
    1.30 +    end = __pa(end);
    1.31 +    
    1.32 +    for (md = efi_get_md(md_end);
    1.33 +         md != NULL && md->phys_addr < desc->xenheap_phys_end;
    1.34 +         md = efi_get_md(md_end)) {
    1.35 +        md_end = MD_END(md);
    1.36 +
    1.37 +        if (md == desc->kern_md ||
    1.38 +            (md->type == EFI_LOADER_DATA && !md_overlap_with_boot_param(md)) ||
    1.39 +            ((md->attribute & EFI_MEMORY_WB) &&
    1.40 +             is_xenheap_usable_memory(md))) {
    1.41 +            unsigned long s = max(start, max(__pa(desc->xen_heap_start),
    1.42 +                                             md->phys_addr));
    1.43 +            unsigned long e = min(end, min(md_end, desc->xenheap_phys_end));
    1.44 +            init_xenheap_pages(s, e);
    1.45 +        }
    1.46 +    }
    1.47 +
    1.48 +    return 0;
    1.49 +}
    1.50 +
    1.51  int running_on_sim;
    1.52  
    1.53  static int __init
    1.54 @@ -305,6 +340,7 @@ void __init start_kernel(void)
    1.55      struct vcpu *dom0_vcpu0;
    1.56      efi_memory_desc_t *kern_md, *last_md, *md;
    1.57      void *xen_heap_start;
    1.58 +    struct xen_heap_desc heap_desc;
    1.59  #ifdef CONFIG_SMP
    1.60      int i;
    1.61  #endif
    1.62 @@ -384,8 +420,12 @@ void __init start_kernel(void)
    1.63          if (relo_start < md->phys_addr)
    1.64              relo_start = md->phys_addr;
    1.65          
    1.66 -        if (!is_xenheap_usable_memory(md))
    1.67 +        if (!is_xenheap_usable_memory(md)) {
    1.68 +            /* Skip this area */
    1.69 +            if (md_end > relo_start)
    1.70 +                relo_start = md_end;
    1.71              continue;
    1.72 +        }
    1.73  
    1.74          /*
    1.75           * The dom0 kernel or initrd could overlap, reserve space
    1.76 @@ -488,18 +528,11 @@ skip_move:
    1.77      if (vmx_enabled)
    1.78          xen_heap_start = vmx_init_env(xen_heap_start, xenheap_phys_end);
    1.79  
    1.80 -    md_end = __pa(xen_heap_start);
    1.81 -    for (md = efi_get_md(md_end);
    1.82 -         md != NULL && md->phys_addr < xenheap_phys_end;
    1.83 -         md = efi_get_md(md_end)) {
    1.84 -        md_end = MD_END(md);
    1.85 +    heap_desc.xen_heap_start   = xen_heap_start;
    1.86 +    heap_desc.xenheap_phys_end = xenheap_phys_end;
    1.87 +    heap_desc.kern_md          = kern_md;
    1.88 +    efi_memmap_walk(&init_xenheap_mds, &heap_desc);
    1.89  
    1.90 -        if (md == kern_md ||
    1.91 -            (md->type == EFI_LOADER_DATA && !md_overlap_with_boot_param(md)) ||
    1.92 -            (md->attribute & EFI_MEMORY_WB))
    1.93 -            init_xenheap_pages(max(__pa(xen_heap_start), md->phys_addr),
    1.94 -                               min(md_end, xenheap_phys_end));
    1.95 -    }
    1.96      printk("Xen heap: %luMB (%lukB)\n",
    1.97             (xenheap_phys_end-__pa(xen_heap_start)) >> 20,
    1.98             (xenheap_phys_end-__pa(xen_heap_start)) >> 10);