# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1166691403 -32400 # Node ID 2f68d7084097db57cb43c82a7c74e08dde170392 # Parent 39d2b340885f1cf4367651e976c36ab7f29a051b fix dom0 builder so that xen doesn't assign memory on I/O area. PATCHNAME: fix_dom0_builder Signed-off-by: Alex Williamson Signed-off-by: Isaku Yamahata diff -r 39d2b340885f -r 2f68d7084097 xen/arch/ia64/xen/dom_fw.c --- a/xen/arch/ia64/xen/dom_fw.c Wed Dec 20 12:50:35 2006 +0900 +++ b/xen/arch/ia64/xen/dom_fw.c Thu Dec 21 17:56:43 2006 +0900 @@ -516,10 +516,10 @@ complete_dom0_memmap(struct domain *d, { efi_memory_desc_t *md; u64 addr; - int j; void *efi_map_start, *efi_map_end, *p; u64 efi_desc_size; int i; + unsigned long leftmem = maxmem - (d->tot_pages << PAGE_SHIFT); /* Walk through all MDT entries. Copy all interesting entries. */ @@ -566,26 +566,21 @@ complete_dom0_memmap(struct domain *d, case EFI_LOADER_DATA: case EFI_BOOT_SERVICES_CODE: case EFI_BOOT_SERVICES_DATA: - /* Create dom0 MDT entries for conventional memory - below 1MB. Without this Linux will assume VGA is - present because 0xA0000 will always be either a hole - in the MDT or an I/O region via the passthrough. */ - - end = min(ONE_MB, end); - - /* Avoid firmware and hypercall area. - We know they are 0-based. */ - if (end < FW_END_PADDR || start >= ONE_MB) + if (!(md->attribute & EFI_MEMORY_WB)) break; - if (start < FW_END_PADDR) - start = FW_END_PADDR; - + start = max(FW_END_PADDR, start); + end = min(start + leftmem, end); + if (end <= start) + break; + dom_md->type = EFI_CONVENTIONAL_MEMORY; dom_md->phys_addr = start; dom_md->virt_addr = 0; dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT; - dom_md->attribute = md->attribute; + dom_md->attribute = EFI_MEMORY_WB; num_mds++; + + leftmem -= dom_md->num_pages << EFI_PAGE_SHIFT; break; case EFI_UNUSABLE_MEMORY: @@ -601,57 +596,6 @@ complete_dom0_memmap(struct domain *d, } BUG_ON(num_mds > NUM_MEM_DESCS); - sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t), - efi_mdt_cmp, NULL); - - /* find gaps and fill them with conventional memory */ - i = num_mds; - for (j = 0; j < num_mds; j++) { - unsigned long end; - unsigned long next_start; - - md = &tables->efi_memmap[j]; - end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT); - - if (j + 1 < num_mds) { - efi_memory_desc_t* next_md; - next_md = &tables->efi_memmap[j + 1]; - next_start = next_md->phys_addr; - - /* Have just been sorted. */ - BUG_ON(end > next_start); - - /* No room for memory! */ - if (end == next_start) - continue; - - if (next_start > maxmem) - next_start = maxmem; - } - else - next_start = maxmem; - - /* Avoid "legacy" low memory addresses - and the HYPERCALL area. */ - if (end < ONE_MB) - end = ONE_MB; - - // clip the range and align to PAGE_SIZE - next_start = next_start & PAGE_MASK; - end = PAGE_ALIGN(end); - - /* No room for memory. */ - if (end >= next_start) - continue; - - MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, - end, next_start); - - if (next_start >= maxmem) - break; - } - num_mds = i; - BUG_ON(num_mds > NUM_MEM_DESCS); sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL); @@ -661,9 +605,7 @@ complete_dom0_memmap(struct domain *d, */ for (i = 0; i < num_mds; i++) { md = &tables->efi_memmap[i]; - if (md->phys_addr > maxmem) - break; - + if (md->type == EFI_LOADER_DATA || md->type == EFI_PAL_CODE || md->type == EFI_CONVENTIONAL_MEMORY) { @@ -675,8 +617,6 @@ complete_dom0_memmap(struct domain *d, /* md->num_pages = 0 is allowed. */ continue; } - if (end > (max_page << PAGE_SHIFT)) - end = (max_page << PAGE_SHIFT); for (addr = start; addr < end; addr += PAGE_SIZE) assign_new_domain0_page(d, addr);