ia64/xen-unstable

changeset 15339:da5f8f1961e5

[IA64] Fix dom0 load address

Calculate load address of dom0 image based on xen_pstart rather than
address from ELF image.

Signed-off-by: Jes Sorensen <jes@sgi.com>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jun 14 14:36:15 2007 -0600 (2007-06-14)
parents 96617c4f19aa
children ed3bd3953287
files xen/arch/ia64/xen/domain.c
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jun 12 20:41:08 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Thu Jun 14 14:36:15 2007 -0600
     1.3 @@ -1104,7 +1104,8 @@ int shadow_mode_control(struct domain *d
     1.4  #define	privify_memory(x,y) do {} while(0)
     1.5  #endif
     1.6  
     1.7 -static void __init loaddomainelfimage(struct domain *d, struct elf_binary *elf)
     1.8 +static void __init loaddomainelfimage(struct domain *d, struct elf_binary *elf,
     1.9 +				      unsigned long phys_load_offset)
    1.10  {
    1.11  	const elf_phdr *phdr;
    1.12  	int phnum, h, filesz, memsz;
    1.13 @@ -1121,6 +1122,7 @@ static void __init loaddomainelfimage(st
    1.14  		memsz = elf_uval(elf, phdr, p_memsz);
    1.15  		elfaddr = (unsigned long) elf->image + elf_uval(elf, phdr, p_offset);
    1.16  		dom_mpaddr = elf_uval(elf, phdr, p_paddr);
    1.17 +		dom_mpaddr += phys_load_offset;
    1.18  
    1.19  		while (memsz > 0) {
    1.20  			p = assign_new_domain_page(d,dom_mpaddr);
    1.21 @@ -1211,6 +1213,7 @@ int __init construct_dom0(struct domain 
    1.22  	unsigned long pkern_end;
    1.23  	unsigned long pinitrd_start = 0;
    1.24  	unsigned long pstart_info;
    1.25 +	unsigned long phys_load_offset;
    1.26  	struct page_info *start_info_page;
    1.27  	unsigned long bp_mpa;
    1.28  	struct ia64_boot_param *bp;
    1.29 @@ -1238,6 +1241,19 @@ int __init construct_dom0(struct domain 
    1.30  	if (0 != (elf_xen_parse(&elf, &parms)))
    1.31  		return rc;
    1.32  
    1.33 +	/*
    1.34 +	 * We cannot rely on the load address in the ELF headers to
    1.35 +	 * determine the meta physical address at which the image
    1.36 +	 * is loaded.  Patch the address to match the real one, based
    1.37 +	 * on xen_pstart
    1.38 +	 */
    1.39 +	phys_load_offset = xen_pstart - elf.pstart;
    1.40 +	elf.pstart += phys_load_offset;
    1.41 +	elf.pend += phys_load_offset;
    1.42 +	parms.virt_kstart += phys_load_offset;
    1.43 +	parms.virt_kend += phys_load_offset;
    1.44 +	parms.virt_entry += phys_load_offset;
    1.45 +
    1.46  	printk(" Dom0 kernel: %s, %s, paddr 0x%" PRIx64 " -> 0x%" PRIx64 "\n",
    1.47  	       elf_64bit(&elf) ? "64-bit" : "32-bit",
    1.48  	       elf_msb(&elf)   ? "msb"    : "lsb",
    1.49 @@ -1268,8 +1284,10 @@ int __init construct_dom0(struct domain 
    1.50  	    /* The next page aligned boundary after the start info.
    1.51  	       Note: EFI_PAGE_SHIFT = 12 <= PAGE_SHIFT */
    1.52  	    pinitrd_start = pstart_info + PAGE_SIZE;
    1.53 -	    if (pinitrd_start + initrd_len >= dom0_size)
    1.54 +
    1.55 +	    if ((pinitrd_start + initrd_len - phys_load_offset) >= dom0_size)
    1.56  		    panic("%s: not enough memory assigned to dom0", __func__);
    1.57 +
    1.58  	    for (offset = 0; offset < initrd_len; offset += PAGE_SIZE) {
    1.59  		struct page_info *p;
    1.60  		p = assign_new_domain_page(d, pinitrd_start + offset);
    1.61 @@ -1322,7 +1340,7 @@ int __init construct_dom0(struct domain 
    1.62  		panic("Cannot allocate dom0 vcpu %d\n", i);
    1.63  
    1.64  	/* Copy the OS image. */
    1.65 -	loaddomainelfimage(d,&elf);
    1.66 +	loaddomainelfimage(d, &elf, phys_load_offset);
    1.67  
    1.68  	BUILD_BUG_ON(sizeof(start_info_t) + sizeof(dom0_vga_console_info_t) +
    1.69  	             sizeof(struct ia64_boot_param) > PAGE_SIZE);