ia64/xen-unstable

changeset 9758:ae0d41bd3bba

[IA64] domain0 builder change

make domain0 builder for dom0 vp model.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Alex Williamson <alex.williamson@hp.com>
author awilliam@ldap.hp.com
date Tue Apr 25 13:48:02 2006 -0600 (2006-04-25)
parents bb99a6e5456a
children 7a9a00c51588
files xen/arch/ia64/xen/dom_fw.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/xensetup.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw.c	Tue Apr 25 13:11:15 2006 -0600
     1.2 +++ b/xen/arch/ia64/xen/dom_fw.c	Tue Apr 25 13:48:02 2006 -0600
     1.3 @@ -10,6 +10,7 @@
     1.4  #include <asm/pgalloc.h>
     1.5  
     1.6  #include <linux/efi.h>
     1.7 +#include <linux/sort.h>
     1.8  #include <asm/io.h>
     1.9  #include <asm/pal.h>
    1.10  #include <asm/sal.h>
    1.11 @@ -48,12 +49,25 @@ dom_pa(unsigned long imva)
    1.12  	return dom_fw_base_mpa + (imva - imva_fw_base);
    1.13  }
    1.14  
    1.15 +// allocate a page for fw
    1.16 +// build_physmap_table() which is called by new_thread()
    1.17 +// does for domU.
    1.18 +#define ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, mpaddr)   \
    1.19 +    do {                                            \
    1.20 +        if ((d) == dom0) {                          \
    1.21 +            assign_new_domain0_page((d), (mpaddr)); \
    1.22 +        }                                           \
    1.23 +    } while (0)
    1.24 +
    1.25  // builds a hypercall bundle at domain physical address
    1.26  static void dom_efi_hypercall_patch(struct domain *d, unsigned long paddr, unsigned long hypercall)
    1.27  {
    1.28  	unsigned long *imva;
    1.29  
    1.30 +#ifndef CONFIG_XEN_IA64_DOM0_VP
    1.31  	if (d == dom0) paddr += dom0_start;
    1.32 +#endif
    1.33 +	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    1.34  	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    1.35  	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, 1);
    1.36  }
    1.37 @@ -64,6 +78,7 @@ static void dom_fw_hypercall_patch(struc
    1.38  {
    1.39  	unsigned long *imva;
    1.40  
    1.41 +	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    1.42  	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    1.43  	build_hypercall_bundle(imva, d->arch.breakimm, hypercall, ret);
    1.44  }
    1.45 @@ -72,6 +87,7 @@ static void dom_fw_pal_hypercall_patch(s
    1.46  {
    1.47  	unsigned long *imva;
    1.48  
    1.49 +	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, paddr);
    1.50  	imva = (unsigned long *) domain_mpa_to_imva(d, paddr);
    1.51  	build_pal_hypercall_bundles(imva, d->arch.breakimm, FW_HYPERCALL_PAL_CALL);
    1.52  }
    1.53 @@ -85,7 +101,10 @@ unsigned long dom_fw_setup(struct domain
    1.54  	struct ia64_boot_param *bp;
    1.55  
    1.56  	dom_fw_base_mpa = 0;
    1.57 +#ifndef CONFIG_XEN_IA64_DOM0_VP
    1.58  	if (d == dom0) dom_fw_base_mpa += dom0_start;
    1.59 +#endif
    1.60 +	ASSIGN_NEW_DOMAIN_PAGE_IF_DOM0(d, dom_fw_base_mpa);
    1.61  	imva_fw_base = domain_mpa_to_imva(d, dom_fw_base_mpa);
    1.62  	bp = dom_fw_init(d, args, arglen, (char *) imva_fw_base, PAGE_SIZE);
    1.63  	return dom_pa((unsigned long) bp);
    1.64 @@ -645,7 +664,75 @@ dom_fw_fake_acpi(struct domain *d, struc
    1.65  }
    1.66  
    1.67  #define NUM_EFI_SYS_TABLES 6
    1.68 -#define NUM_MEM_DESCS	5
    1.69 +#define NUM_MEM_DESCS	64 //large enough
    1.70 +
    1.71 +struct dom0_passthrough_arg {
    1.72 +#ifdef CONFIG_XEN_IA64_DOM0_VP
    1.73 +    struct domain*      d;
    1.74 +#endif
    1.75 +    efi_memory_desc_t *md;
    1.76 +    int*                i;
    1.77 +};
    1.78 +
    1.79 +static int
    1.80 +dom_fw_dom0_passthrough(efi_memory_desc_t *md, void *arg__)
    1.81 +{
    1.82 +    struct dom0_passthrough_arg* arg = (struct dom0_passthrough_arg*)arg__;
    1.83 +    unsigned long paddr;
    1.84 +
    1.85 +#ifdef CONFIG_XEN_IA64_DOM0_VP
    1.86 +    struct domain* d = arg->d;
    1.87 +    u64 start = md->phys_addr;
    1.88 +    u64 end = start + (md->num_pages << EFI_PAGE_SHIFT);
    1.89 +
    1.90 +    if (md->type == EFI_MEMORY_MAPPED_IO ||
    1.91 +        md->type == EFI_MEMORY_MAPPED_IO_PORT_SPACE) {
    1.92 +
    1.93 +        //XXX some machine has large mmio area whose size is about several TB.
    1.94 +        //    It requires impractical memory to map such a huge region
    1.95 +        //    to a domain.
    1.96 +        //    For now we don't map it, but later we must fix this.
    1.97 +        if (md->type == EFI_MEMORY_MAPPED_IO &&
    1.98 +            ((md->num_pages << EFI_PAGE_SHIFT) > 0x100000000UL))
    1.99 +            return 0;
   1.100 +
   1.101 +        paddr = assign_domain_mmio_page(d, start, end - start);
   1.102 +    } else
   1.103 +        paddr = assign_domain_mach_page(d, start, end - start);
   1.104 +#else
   1.105 +    paddr = md->phys_addr;
   1.106 +#endif
   1.107 +
   1.108 +    BUG_ON(md->type != EFI_RUNTIME_SERVICES_CODE &&
   1.109 +           md->type != EFI_RUNTIME_SERVICES_DATA &&
   1.110 +           md->type != EFI_ACPI_RECLAIM_MEMORY &&
   1.111 +           md->type != EFI_MEMORY_MAPPED_IO &&
   1.112 +           md->type != EFI_MEMORY_MAPPED_IO_PORT_SPACE);
   1.113 +
   1.114 +    arg->md->type = md->type;
   1.115 +    arg->md->pad = 0;
   1.116 +    arg->md->phys_addr = paddr;
   1.117 +    arg->md->virt_addr = 0;
   1.118 +    arg->md->num_pages = md->num_pages;
   1.119 +    arg->md->attribute = md->attribute;
   1.120 +    print_md(arg->md);
   1.121 +
   1.122 +    (*arg->i)++;
   1.123 +    arg->md++;
   1.124 +    return 0;
   1.125 +}
   1.126 +
   1.127 +static int
   1.128 +efi_mdt_cmp(const void *a, const void *b)
   1.129 +{
   1.130 +	const efi_memory_desc_t *x = a, *y = b;
   1.131 +
   1.132 +	if (x->phys_addr > y->phys_addr)
   1.133 +		return 1;
   1.134 +	if (x->phys_addr < y->phys_addr)
   1.135 +		return -1;
   1.136 +	return 0;
   1.137 +}
   1.138  
   1.139  static struct ia64_boot_param *
   1.140  dom_fw_init (struct domain *d, const char *args, int arglen, char *fw_mem, int fw_mem_size)
   1.141 @@ -663,7 +750,11 @@ dom_fw_init (struct domain *d, const cha
   1.142  	char *cp, *cmd_line, *fw_vendor;
   1.143  	int i = 0;
   1.144  	unsigned long maxmem = (d->max_pages - d->arch.sys_pgnr) * PAGE_SIZE;
   1.145 +#ifdef CONFIG_XEN_IA64_DOM0_VP
   1.146 +	const unsigned long start_mpaddr = 0;
   1.147 +#else
   1.148  	const unsigned long start_mpaddr = ((d==dom0)?dom0_start:0);
   1.149 +#endif
   1.150  
   1.151  #	define MAKE_MD(typ, attr, start, end, abs) 	\
   1.152  	do {						\
   1.153 @@ -751,11 +842,17 @@ dom_fw_init (struct domain *d, const cha
   1.154  		efi_tables[i].table = 0;
   1.155  	}
   1.156  	if (d == dom0) {
   1.157 +#ifdef CONFIG_XEN_IA64_DOM0_VP
   1.158 +# define ASSIGN_DOMAIN_MACH_PAGE(d, p) assign_domain_mach_page(d, p, PAGE_SIZE)
   1.159 +#else
   1.160 +# define ASSIGN_DOMAIN_MACH_PAGE(d, p) ({p;})
   1.161 +#endif
   1.162 +
   1.163  		printf("Domain0 EFI passthrough:");
   1.164  		i = 1;
   1.165  		if (efi.mps) {
   1.166  			efi_tables[i].guid = MPS_TABLE_GUID;
   1.167 -			efi_tables[i].table = __pa(efi.mps);
   1.168 +			efi_tables[i].table = ASSIGN_DOMAIN_MACH_PAGE(d, __pa(efi.mps));
   1.169  			printf(" MPS=0x%lx",efi_tables[i].table);
   1.170  			i++;
   1.171  		}
   1.172 @@ -764,25 +861,25 @@ dom_fw_init (struct domain *d, const cha
   1.173  
   1.174  		if (efi.acpi20) {
   1.175  			efi_tables[i].guid = ACPI_20_TABLE_GUID;
   1.176 -			efi_tables[i].table = __pa(efi.acpi20);
   1.177 +			efi_tables[i].table = ASSIGN_DOMAIN_MACH_PAGE(d, __pa(efi.acpi20));
   1.178  			printf(" ACPI 2.0=0x%lx",efi_tables[i].table);
   1.179  			i++;
   1.180  		}
   1.181  		if (efi.acpi) {
   1.182  			efi_tables[i].guid = ACPI_TABLE_GUID;
   1.183 -			efi_tables[i].table = __pa(efi.acpi);
   1.184 +			efi_tables[i].table = ASSIGN_DOMAIN_MACH_PAGE(d, __pa(efi.acpi));
   1.185  			printf(" ACPI=0x%lx",efi_tables[i].table);
   1.186  			i++;
   1.187  		}
   1.188  		if (efi.smbios) {
   1.189  			efi_tables[i].guid = SMBIOS_TABLE_GUID;
   1.190 -			efi_tables[i].table = __pa(efi.smbios);
   1.191 +			efi_tables[i].table = ASSIGN_DOMAIN_MACH_PAGE(d, __pa(efi.smbios));
   1.192  			printf(" SMBIOS=0x%lx",efi_tables[i].table);
   1.193  			i++;
   1.194  		}
   1.195  		if (efi.hcdp) {
   1.196  			efi_tables[i].guid = HCDP_TABLE_GUID;
   1.197 -			efi_tables[i].table = __pa(efi.hcdp);
   1.198 +			efi_tables[i].table = ASSIGN_DOMAIN_MACH_PAGE(d, __pa(efi.hcdp));
   1.199  			printf(" HCDP=0x%lx",efi_tables[i].table);
   1.200  			i++;
   1.201  		}
   1.202 @@ -835,6 +932,7 @@ dom_fw_init (struct domain *d, const cha
   1.203  
   1.204  	i = 0;
   1.205  	if (d == dom0) {
   1.206 +#ifndef CONFIG_XEN_IA64_DOM0_VP
   1.207  		/*
   1.208  		 * This is a bad hack.  Dom0 may share other domains' memory
   1.209  		 * through a dom0 physical address.  Unfortunately, this
   1.210 @@ -849,31 +947,42 @@ dom_fw_init (struct domain *d, const cha
   1.211  		unsigned long last_end = last_start + IA64_GRANULE_SIZE;
   1.212  
   1.213  		/* simulate 1MB free memory at physical address zero */
   1.214 -		MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);
   1.215 +		MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 0);//XXX
   1.216 +#endif
   1.217  		/* hypercall patches live here, masquerade as reserved PAL memory */
   1.218  		MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 0);
   1.219 -		MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE, 0);
   1.220 + 		MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem-IA64_GRANULE_SIZE, 0);//XXX make sure this doesn't overlap on i/o, runtime area.
   1.221 +#ifndef CONFIG_XEN_IA64_DOM0_VP
   1.222  /* hack */	MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,last_start,last_end,1);
   1.223 +#endif
   1.224  
   1.225  		/* pass through the I/O port space */
   1.226  		if (!running_on_sim) {
   1.227 -			efi_memory_desc_t *efi_get_io_md(void);
   1.228 -			efi_memory_desc_t *ia64_efi_io_md;
   1.229 -			u32 type;
   1.230 -			u64 iostart, ioend, ioattr;
   1.231 -
   1.232 -			ia64_efi_io_md = efi_get_io_md();
   1.233 -			type = ia64_efi_io_md->type;
   1.234 -			iostart = ia64_efi_io_md->phys_addr;
   1.235 -			ioend = ia64_efi_io_md->phys_addr +
   1.236 -				(ia64_efi_io_md->num_pages << 12);
   1.237 -			ioattr = ia64_efi_io_md->attribute;
   1.238 -			MAKE_MD(type,ioattr,iostart,ioend, 1);
   1.239 +			struct dom0_passthrough_arg arg;
   1.240 +#ifdef CONFIG_XEN_IA64_DOM0_VP
   1.241 +			arg.d = d;
   1.242 +#endif
   1.243 +			arg.md = &efi_memmap[i];
   1.244 +			arg.i = &i;
   1.245 +			//XXX Is this needed?
   1.246 +			efi_memmap_walk_type(EFI_RUNTIME_SERVICES_CODE,
   1.247 +			                     dom_fw_dom0_passthrough, &arg);
   1.248 +			// for ACPI table.
   1.249 +			efi_memmap_walk_type(EFI_RUNTIME_SERVICES_DATA,
   1.250 +			                     dom_fw_dom0_passthrough, &arg);
   1.251 +			efi_memmap_walk_type(EFI_ACPI_RECLAIM_MEMORY,
   1.252 +			                     dom_fw_dom0_passthrough, &arg);
   1.253 +			efi_memmap_walk_type(EFI_MEMORY_MAPPED_IO,
   1.254 +			                     dom_fw_dom0_passthrough, &arg);
   1.255 +			efi_memmap_walk_type(EFI_MEMORY_MAPPED_IO_PORT_SPACE,
   1.256 +			                     dom_fw_dom0_passthrough, &arg);
   1.257  		}
   1.258  		else MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
   1.259  	}
   1.260  	else {
   1.261 +#ifndef CONFIG_XEN_IA64_DOM0_VP
   1.262  		MAKE_MD(EFI_LOADER_DATA,EFI_MEMORY_WB,0*MB,1*MB, 1);
   1.263 +#endif
   1.264  		/* hypercall patches live here, masquerade as reserved PAL memory */
   1.265  		MAKE_MD(EFI_PAL_CODE,EFI_MEMORY_WB,HYPERCALL_START,HYPERCALL_END, 1);
   1.266  		MAKE_MD(EFI_CONVENTIONAL_MEMORY,EFI_MEMORY_WB,HYPERCALL_END,maxmem, 1);
   1.267 @@ -884,9 +993,12 @@ dom_fw_init (struct domain *d, const cha
   1.268  		MAKE_MD(EFI_RESERVED_TYPE,0,0,0,0);
   1.269  	}
   1.270  
   1.271 +	sort(efi_memmap, i, sizeof(efi_memory_desc_t), efi_mdt_cmp, NULL);
   1.272 +
   1.273  	bp->efi_systab = dom_pa((unsigned long) fw_mem);
   1.274  	bp->efi_memmap = dom_pa((unsigned long) efi_memmap);
   1.275 -	bp->efi_memmap_size = NUM_MEM_DESCS*sizeof(efi_memory_desc_t);
   1.276 +	BUG_ON(i > NUM_MEM_DESCS);
   1.277 +	bp->efi_memmap_size = i * sizeof(efi_memory_desc_t);
   1.278  	bp->efi_memdesc_size = sizeof(efi_memory_desc_t);
   1.279  	bp->efi_memdesc_version = 1;
   1.280  	bp->command_line = dom_pa((unsigned long) cmd_line);
   1.281 @@ -896,6 +1008,8 @@ dom_fw_init (struct domain *d, const cha
   1.282  	bp->console_info.orig_y = 24;
   1.283  	bp->fpswa = 0;
   1.284  	if (d == dom0) {
   1.285 +		// XXX CONFIG_XEN_IA64_DOM0_VP
   1.286 +		// initrd_start address is hard coded in start_kernel()
   1.287  		bp->initrd_start = (dom0_start+dom0_size) -
   1.288  		  (PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
   1.289  		bp->initrd_size = ia64_boot_param->initrd_size;
     2.1 --- a/xen/arch/ia64/xen/domain.c	Tue Apr 25 13:11:15 2006 -0600
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Tue Apr 25 13:48:02 2006 -0600
     2.3 @@ -1078,10 +1078,10 @@ static void loaddomainelfimage(struct do
     2.4  
     2.5  void alloc_dom0(void)
     2.6  {
     2.7 -#ifdef CONFIG_DOMAIN0_CONTIGUOUS
     2.8  	if (platform_is_hp_ski()) {
     2.9 -	dom0_size = 128*1024*1024; //FIXME: Should be configurable
    2.10 +		dom0_size = 128*1024*1024; //FIXME: Should be configurable
    2.11  	}
    2.12 +#ifdef CONFIG_DOMAIN0_CONTIGUOUS
    2.13  	printf("alloc_dom0: starting (initializing %lu MB...)\n",dom0_size/(1024*1024));
    2.14   
    2.15  	/* FIXME: The first trunk (say 256M) should always be assigned to
    2.16 @@ -1098,6 +1098,8 @@ void alloc_dom0(void)
    2.17  	}
    2.18  	printf("alloc_dom0: dom0_start=0x%lx\n", dom0_start);
    2.19  #else
    2.20 +	// no need to allocate pages for now
    2.21 +	// pages are allocated by map_new_domain_page() via loaddomainelfimage()
    2.22  	dom0_start = 0;
    2.23  #endif
    2.24  
    2.25 @@ -1128,6 +1130,7 @@ int construct_dom0(struct domain *d,
    2.26  	unsigned long alloc_start, alloc_end;
    2.27  	start_info_t *si;
    2.28  	struct vcpu *v = d->vcpu[0];
    2.29 +	unsigned long max_pages;
    2.30  
    2.31  	struct domain_setup_info dsi;
    2.32  	unsigned long p_start;
    2.33 @@ -1136,11 +1139,8 @@ int construct_dom0(struct domain *d,
    2.34  	unsigned long pkern_end;
    2.35  	unsigned long pinitrd_start = 0;
    2.36  	unsigned long pstart_info;
    2.37 -#if 0
    2.38 -	char *dst;
    2.39 -	unsigned long nr_pt_pages;
    2.40 -	unsigned long count;
    2.41 -#endif
    2.42 +	struct page_info *start_info_page;
    2.43 +
    2.44  #ifdef VALIDATE_VT
    2.45  	unsigned long mfn;
    2.46  	struct page_info *page = NULL;
    2.47 @@ -1159,7 +1159,13 @@ int construct_dom0(struct domain *d,
    2.48  
    2.49  	alloc_start = dom0_start;
    2.50  	alloc_end = dom0_start + dom0_size;
    2.51 -	d->tot_pages = d->max_pages = dom0_size/PAGE_SIZE;
    2.52 +	max_pages = dom0_size / PAGE_SIZE;
    2.53 +	d->max_pages = max_pages;
    2.54 +#ifndef CONFIG_XEN_IA64_DOM0_VP
    2.55 +	d->tot_pages = d->max_pages;
    2.56 +#else
    2.57 +	d->tot_pages = 0;
    2.58 +#endif
    2.59  	dsi.image_addr = (unsigned long)image_start;
    2.60  	dsi.image_len  = image_len;
    2.61  	rc = parseelfimage(&dsi);
    2.62 @@ -1196,15 +1202,27 @@ int construct_dom0(struct domain *d,
    2.63  	    return -EINVAL;
    2.64  	}
    2.65  
    2.66 -        if(initrd_start&&initrd_len){
    2.67 -             pinitrd_start=(dom0_start+dom0_size) -
    2.68 -                          (PAGE_ALIGN(initrd_len) + 4*1024*1024);
    2.69 +	pstart_info = PAGE_ALIGN(pkern_end);
    2.70 +	if(initrd_start && initrd_len){
    2.71 +	    unsigned long offset;
    2.72  
    2.73 -             memcpy(__va(pinitrd_start), (void *) initrd_start, initrd_len);
    2.74 -             pstart_info = PAGE_ALIGN(pinitrd_start + initrd_len);
    2.75 -        } else {
    2.76 -             pstart_info = PAGE_ALIGN(pkern_end);
    2.77 -        }
    2.78 +	    pinitrd_start= (dom0_start + dom0_size) -
    2.79 +	                   (PAGE_ALIGN(initrd_len) + 4*1024*1024);
    2.80 +	    if (pinitrd_start <= pstart_info)
    2.81 +		panic("%s:enough memory is not assigned to dom0", __func__);
    2.82 +
    2.83 +	    for (offset = 0; offset < initrd_len; offset += PAGE_SIZE) {
    2.84 +		struct page_info *p;
    2.85 +		p = assign_new_domain_page(d, pinitrd_start + offset);
    2.86 +		if (p == NULL)
    2.87 +		    panic("%s: can't allocate page for initrd image", __func__);
    2.88 +		if (initrd_len < offset + PAGE_SIZE)
    2.89 +		    memcpy(page_to_virt(p), (void*)(initrd_start + offset),
    2.90 +		           initrd_len - offset);
    2.91 +		else
    2.92 +		    copy_page(page_to_virt(p), (void*)(initrd_start + offset));
    2.93 +	    }
    2.94 +	}
    2.95  
    2.96  	printk("METAPHYSICAL MEMORY ARRANGEMENT:\n"
    2.97  	       " Kernel image:  %lx->%lx\n"
    2.98 @@ -1214,12 +1232,12 @@ int construct_dom0(struct domain *d,
    2.99  	       pkern_start, pkern_end, pkern_entry, pinitrd_start, initrd_len,
   2.100  	       pstart_info, pstart_info + PAGE_SIZE);
   2.101  
   2.102 -	if ( (pkern_end - pkern_start) > (d->max_pages * PAGE_SIZE) )
   2.103 +	if ( (pkern_end - pkern_start) > (max_pages * PAGE_SIZE) )
   2.104  	{
   2.105  	    printk("Initial guest OS requires too much space\n"
   2.106  	           "(%luMB is greater than %luMB limit)\n",
   2.107  	           (pkern_end-pkern_start)>>20,
   2.108 -	           (unsigned long) (d->max_pages<<PAGE_SHIFT)>>20);
   2.109 +	           (max_pages <<PAGE_SHIFT)>>20);
   2.110  	    return -ENOMEM;
   2.111  	}
   2.112  
   2.113 @@ -1228,13 +1246,6 @@ int construct_dom0(struct domain *d,
   2.114  	// if pkern end is after end of metaphysical memory, error
   2.115  	//  (we should be able to deal with this... later)
   2.116  
   2.117 -
   2.118 -	//
   2.119 -
   2.120 -#if 0
   2.121 -	strcpy(d->name,"Domain0");
   2.122 -#endif
   2.123 -
   2.124  	/* Mask all upcalls... */
   2.125  	for ( i = 1; i < MAX_VIRT_CPUS; i++ )
   2.126  	    d->shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   2.127 @@ -1251,7 +1262,7 @@ int construct_dom0(struct domain *d,
   2.128  	    if (alloc_vcpu(d, i, i) == NULL)
   2.129  		printf ("Cannot allocate dom0 vcpu %d\n", i);
   2.130  
   2.131 -#ifdef VALIDATE_VT 
   2.132 +#if defined(VALIDATE_VT) && !defined(CONFIG_XEN_IA64_DOM0_VP)
   2.133  	/* Construct a frame-allocation list for the initial domain, since these
   2.134  	 * pages are allocated by boot allocator and pfns are not set properly
   2.135  	 */
   2.136 @@ -1266,9 +1277,8 @@ int construct_dom0(struct domain *d,
   2.137              list_add_tail(&page->list, &d->page_list);
   2.138  
   2.139  	    /* Construct 1:1 mapping */
   2.140 -	    machine_to_phys_mapping[mfn] = mfn;
   2.141 +	    set_gpfn_from_mfn(mfn, mfn);
   2.142  	}
   2.143 -
   2.144  #endif
   2.145  
   2.146  	/* Copy the OS image. */
   2.147 @@ -1281,41 +1291,14 @@ int construct_dom0(struct domain *d,
   2.148  
   2.149  	/* Set up start info area. */
   2.150  	d->shared_info->arch.start_info_pfn = pstart_info >> PAGE_SHIFT;
   2.151 -	si = __va(pstart_info);
   2.152 +	start_info_page = assign_new_domain_page(d, pstart_info);
   2.153 +	if (start_info_page == NULL)
   2.154 +		panic("can't allocate start info page");
   2.155 +	si = page_to_virt(start_info_page);
   2.156  	memset(si, 0, PAGE_SIZE);
   2.157  	sprintf(si->magic, "xen-%i.%i-ia64", XEN_VERSION, XEN_SUBVERSION);
   2.158 -	si->nr_pages     = d->tot_pages;
   2.159 -
   2.160 -#if 0
   2.161 -	si->shared_info  = virt_to_maddr(d->shared_info);
   2.162 -	si->flags        = SIF_PRIVILEGED | SIF_INITDOMAIN;
   2.163 -	//si->pt_base      = vpt_start;
   2.164 -	//si->nr_pt_frames = nr_pt_pages;
   2.165 -	//si->mfn_list     = vphysmap_start;
   2.166 +	si->nr_pages     = max_pages;
   2.167  
   2.168 -	if ( initrd_len != 0 )
   2.169 -	{
   2.170 -	    //si->mod_start = vinitrd_start;
   2.171 -	    si->mod_len   = initrd_len;
   2.172 -	    printk("Initrd len 0x%lx, start at 0x%08lx\n",
   2.173 -	           si->mod_len, si->mod_start);
   2.174 -	}
   2.175 -
   2.176 -	dst = si->cmd_line;
   2.177 -	if ( cmdline != NULL )
   2.178 -	{
   2.179 -	    for ( i = 0; i < 255; i++ )
   2.180 -	    {
   2.181 -	        if ( cmdline[i] == '\0' )
   2.182 -	            break;
   2.183 -	        *dst++ = cmdline[i];
   2.184 -	    }
   2.185 -	}
   2.186 -	*dst = '\0';
   2.187 -
   2.188 -	zap_low_mappings(); /* Do the same for the idle page tables. */
   2.189 -#endif
   2.190 -	
   2.191  	/* Give up the VGA console if DOM0 is configured to grab it. */
   2.192  	if (cmdline != NULL)
   2.193  	    console_endboot(strstr(cmdline, "tty0") != NULL);
   2.194 @@ -1332,6 +1315,14 @@ int construct_dom0(struct domain *d,
   2.195  	new_thread(v, pkern_entry, 0, 0);
   2.196  	physdev_init_dom0(d);
   2.197  
   2.198 +	// dom0 doesn't need build_physmap_table()
   2.199 +	// see arch_set_info_guest()
   2.200 +	// instead we allocate pages manually.
   2.201 +	for (i = 0; i < max_pages; i++) {
   2.202 +		assign_new_domain0_page(d, i << PAGE_SHIFT);
   2.203 +	}
   2.204 +	d->arch.physmap_built = 1;
   2.205 +
   2.206  	// FIXME: Hack for keyboard input
   2.207  	//serial_input_init();
   2.208  
     3.1 --- a/xen/arch/ia64/xen/xensetup.c	Tue Apr 25 13:11:15 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/xensetup.c	Tue Apr 25 13:48:02 2006 -0600
     3.3 @@ -294,11 +294,13 @@ void start_kernel(void)
     3.4      max_page = 0;
     3.5      efi_memmap_walk(find_max_pfn, &max_page);
     3.6      printf("find_memory: efi_memmap_walk returns max_page=%lx\n",max_page);
     3.7 +#ifndef CONFIG_XEN_IA64_DOM0_VP
     3.8      /* this is a bad hack.  see dom_fw.c creation of EFI map for dom0 */
     3.9      max_page = (GRANULEROUNDDOWN(max_page << PAGE_SHIFT)
    3.10  	- IA64_GRANULE_SIZE) >> PAGE_SHIFT;
    3.11      printf("find_memory: last granule reserved for dom0; xen max_page=%lx\n",
    3.12  	max_page);
    3.13 +#endif
    3.14      efi_print();
    3.15  
    3.16      heap_start = memguard_init(ia64_imva(&_end));