ia64/xen-unstable

changeset 4293:48ddf32dad5b

bitkeeper revision 1.1236.1.125 (4242ef8aRFQzhOTTcIl53kSEbAetfg)

Merge bk://xen.bkbits.net/xeno-unstable.bk
into bkbits.net:/repos/x/xen-ia64/xeno-unstable-ia64.bk
author xen-ia64.adm@bkbits.net
date Thu Mar 24 16:49:14 2005 +0000 (2005-03-24)
parents 0c7d16e71835 2f89618be8d4
children de1a42be018c
files .rootkeys BitKeeper/etc/logging_ok xen/arch/ia64/Makefile xen/arch/ia64/domain.c xen/arch/ia64/hypercall.c xen/arch/ia64/patch/linux-2.6.7/system.h xen/arch/ia64/patch/linux-2.6.7/time.c xen/arch/ia64/process.c xen/arch/ia64/regionreg.c xen/arch/ia64/tools/README.xenia64linux xen/arch/ia64/vcpu.c xen/arch/ia64/xenasm.S xen/arch/ia64/xenmisc.c xen/arch/ia64/xensetup.c xen/drivers/char/console.c xen/include/asm-ia64/config.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/.rootkeys	Thu Mar 24 11:04:24 2005 +0000
     1.2 +++ b/.rootkeys	Thu Mar 24 16:49:14 2005 +0000
     1.3 @@ -987,6 +987,7 @@ 421098b26C_0yoypoHqjDcJA9UrG_g xen/arch/
     1.4  421098b2PHgzf_Gg4R65YRNi_QzMKQ xen/arch/ia64/dom0_ops.c
     1.5  421098b2O7jsNfzQXA1v3rbAc1QhpA xen/arch/ia64/dom_fw.c
     1.6  421098b2ZlaBcyiuuPr3WpzaSDwg6Q xen/arch/ia64/domain.c
     1.7 +4239e98a_HX-FCIcXtVqY0BbrDqVug xen/arch/ia64/hypercall.c
     1.8  421098b3LYAS8xJkQiGP7tiTlyBt0Q xen/arch/ia64/idle0_task.c
     1.9  421098b3ys5GAr4z6_H1jD33oem82g xen/arch/ia64/irq.c
    1.10  421098b3Heh72KuoVlND3CH6c0B0aA xen/arch/ia64/lib/Makefile
    1.11 @@ -1037,6 +1038,7 @@ 41a26ebcJ30TFl1v2kR8rqpEBvOtVw xen/arch/
    1.12  421098b69pUiIJrqu_w0JMUnZ2uc2A xen/arch/ia64/smp.c
    1.13  421098b6_ToSGrf6Pk1Uwg5aMAIBxg xen/arch/ia64/smpboot.c
    1.14  421098b6AUdbxR3wyn1ATcmNuTao_Q xen/arch/ia64/tools/README.xenia64
    1.15 +42376c6dfyY0eq8MS2dK3BW2rFuEGg xen/arch/ia64/tools/README.xenia64linux
    1.16  421098b6rQ2BQ103qu1n1HNofbS2Og xen/arch/ia64/tools/mkbuildtree
    1.17  41a26ebc--sjlYZQxmIxyCx3jw70qA xen/arch/ia64/vcpu.c
    1.18  421098b6M2WhsJ_ZMzFamAQcdc5gzw xen/arch/ia64/vhpt.c
     2.1 --- a/BitKeeper/etc/logging_ok	Thu Mar 24 11:04:24 2005 +0000
     2.2 +++ b/BitKeeper/etc/logging_ok	Thu Mar 24 16:49:14 2005 +0000
     2.3 @@ -20,7 +20,9 @@ cl349@freefall.cl.cam.ac.uk
     2.4  cl349@labyrinth.cl.cam.ac.uk
     2.5  cwc22@centipede.cl.cam.ac.uk
     2.6  cwc22@donkeykong.cl.cam.ac.uk
     2.7 +djm@djmnc4000.(none)
     2.8  djm@kirby.fc.hp.com
     2.9 +djm@sportsman.spdomain
    2.10  doogie@brainfood.com
    2.11  gm281@boulderdash.cl.cam.ac.uk
    2.12  gm281@tetrapod.cl.cam.ac.uk
     3.1 --- a/xen/arch/ia64/Makefile	Thu Mar 24 11:04:24 2005 +0000
     3.2 +++ b/xen/arch/ia64/Makefile	Thu Mar 24 16:49:14 2005 +0000
     3.3 @@ -3,7 +3,7 @@ include $(BASEDIR)/Rules.mk
     3.4  # libs-y	+= arch/ia64/lib/lib.a
     3.5  
     3.6  OBJS = xensetup.o setup.o time.o irq.o ia64_ksyms.o process.o smp.o \
     3.7 -	xenmisc.o pdb-stub.o acpi.o \
     3.8 +	xenmisc.o pdb-stub.o acpi.o hypercall.o \
     3.9  	machvec.o dom0_ops.o domain.o \
    3.10  	idle0_task.o pal.o hpsim.o efi.o efi_stub.o ivt.o mm_contig.o \
    3.11  	mm_bootmem.o sal.o cmdline.o mm_init.o tlb.o page_alloc.o slab.o \
     4.1 --- a/xen/arch/ia64/domain.c	Thu Mar 24 11:04:24 2005 +0000
     4.2 +++ b/xen/arch/ia64/domain.c	Thu Mar 24 16:49:14 2005 +0000
     4.3 @@ -44,9 +44,11 @@ extern kmem_cache_t *domain_struct_cache
     4.4  // initialized by arch/ia64/setup.c:find_initrd()
     4.5  unsigned long initrd_start = 0, initrd_end = 0;
     4.6  
     4.7 +#define IS_XEN_ADDRESS(d,a) ((a >= d->xen_vastart) && (a <= d->xen_vaend))
     4.8 +
     4.9  extern int loadelfimage(char *);
    4.10  extern int readelfimage_base_and_size(char *, unsigned long,
    4.11 -                  unsigned long *, unsigned long *, unsigned long *);
    4.12 +	              unsigned long *, unsigned long *, unsigned long *);
    4.13  
    4.14  unsigned long map_domain_page0(struct domain *);
    4.15  extern unsigned long dom_fw_setup(struct domain *, char *, int);
    4.16 @@ -54,63 +56,63 @@ extern unsigned long dom_fw_setup(struct
    4.17  /* this belongs in include/asm, but there doesn't seem to be a suitable place */
    4.18  void free_perdomain_pt(struct domain *d)
    4.19  {
    4.20 -    dummy();
    4.21 -    //free_page((unsigned long)d->mm.perdomain_pt);
    4.22 +	dummy();
    4.23 +	//free_page((unsigned long)d->mm.perdomain_pt);
    4.24  }
    4.25  
    4.26  int hlt_counter;
    4.27  
    4.28  void disable_hlt(void)
    4.29  {
    4.30 -    hlt_counter++;
    4.31 +	hlt_counter++;
    4.32  }
    4.33  
    4.34  void enable_hlt(void)
    4.35  {
    4.36 -    hlt_counter--;
    4.37 +	hlt_counter--;
    4.38  }
    4.39  
    4.40  static void default_idle(void)
    4.41  {
    4.42 -    if ( hlt_counter == 0 )
    4.43 -    {
    4.44 +	if ( hlt_counter == 0 )
    4.45 +	{
    4.46  	local_irq_disable();
    4.47 -        if ( !softirq_pending(smp_processor_id()) )
    4.48 -            safe_halt();
    4.49 -        //else
    4.50 +	    if ( !softirq_pending(smp_processor_id()) )
    4.51 +	        safe_halt();
    4.52 +	    //else
    4.53  		local_irq_enable();
    4.54 -    }
    4.55 +	}
    4.56  }
    4.57  
    4.58  void continue_cpu_idle_loop(void)
    4.59  {
    4.60 -    int cpu = smp_processor_id();
    4.61 -    for ( ; ; )
    4.62 -    {
    4.63 +	int cpu = smp_processor_id();
    4.64 +	for ( ; ; )
    4.65 +	{
    4.66  #ifdef IA64
    4.67  //        __IRQ_STAT(cpu, idle_timestamp) = jiffies
    4.68  #else
    4.69 -        irq_stat[cpu].idle_timestamp = jiffies;
    4.70 +	    irq_stat[cpu].idle_timestamp = jiffies;
    4.71  #endif
    4.72 -        while ( !softirq_pending(cpu) )
    4.73 -            default_idle();
    4.74 -        do_softirq();
    4.75 -    }
    4.76 +	    while ( !softirq_pending(cpu) )
    4.77 +	        default_idle();
    4.78 +	    do_softirq();
    4.79 +	}
    4.80  }
    4.81  
    4.82  void startup_cpu_idle_loop(void)
    4.83  {
    4.84 -    /* Just some sanity to ensure that the scheduler is set up okay. */
    4.85 -    ASSERT(current->domain == IDLE_DOMAIN_ID);
    4.86 -    domain_unpause_by_systemcontroller(current);
    4.87 -    __enter_scheduler();
    4.88 +	/* Just some sanity to ensure that the scheduler is set up okay. */
    4.89 +	ASSERT(current->domain == IDLE_DOMAIN_ID);
    4.90 +	domain_unpause_by_systemcontroller(current->domain);
    4.91 +	__enter_scheduler();
    4.92  
    4.93 -    /*
    4.94 -     * Declares CPU setup done to the boot processor.
    4.95 -     * Therefore memory barrier to ensure state is visible.
    4.96 -     */
    4.97 -    smp_mb();
    4.98 -    init_idle();
    4.99 +	/*
   4.100 +	 * Declares CPU setup done to the boot processor.
   4.101 +	 * Therefore memory barrier to ensure state is visible.
   4.102 +	 */
   4.103 +	smp_mb();
   4.104 +	init_idle();
   4.105  #if 0
   4.106  //do we have to ensure the idle task has a shared page so that, for example,
   4.107  //region registers can be loaded from it.  Apparently not...
   4.108 @@ -129,7 +131,7 @@ void startup_cpu_idle_loop(void)
   4.109  	}
   4.110  #endif
   4.111  
   4.112 -    continue_cpu_idle_loop();
   4.113 +	continue_cpu_idle_loop();
   4.114  }
   4.115  
   4.116  struct domain *arch_alloc_domain_struct(void)
   4.117 @@ -214,9 +216,9 @@ void domain_relinquish_memory(struct dom
   4.118  // heavily leveraged from linux/arch/ia64/kernel/process.c:copy_thread()
   4.119  // and linux/arch/ia64/kernel/process.c:kernel_thread()
   4.120  void new_thread(struct exec_domain *ed,
   4.121 -                unsigned long start_pc,
   4.122 -                unsigned long start_stack,
   4.123 -                unsigned long start_info)
   4.124 +	            unsigned long start_pc,
   4.125 +	            unsigned long start_stack,
   4.126 +	            unsigned long start_info)
   4.127  {
   4.128  	struct domain *d = ed->domain;
   4.129  	struct switch_stack *sw;
   4.130 @@ -248,6 +250,7 @@ void new_thread(struct exec_domain *ed,
   4.131  	regs->pr = 0;
   4.132  	sw->pr = 0;
   4.133  	regs->ar_pfs = 0;
   4.134 +	sw->caller_unat = 0;
   4.135  	sw->ar_pfs = 0;
   4.136  	sw->ar_bspstore = new_rbs;
   4.137  	//regs->r13 = (unsigned long) ed;
   4.138 @@ -392,24 +395,38 @@ int elf_sanity_check(Elf_Ehdr *ehdr)
   4.139  	return (IS_ELF(*ehdr));
   4.140  }
   4.141  
   4.142 +static void copy_memory(void *dst, void *src, int size)
   4.143 +{
   4.144 +	if (IS_XEN_ADDRESS(dom0,src)) {
   4.145 +		memcpy(dst,src,size);
   4.146 +	}
   4.147 +	else {
   4.148 +		if (__copy_from_user(dst,src,size))
   4.149 +			printf("incomplete user copy\n");
   4.150 +	}
   4.151 +}
   4.152 +
   4.153  void loaddomainelfimage(struct domain *d, unsigned long image_start)
   4.154  {
   4.155 -    char *elfbase = image_start;
   4.156 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)image_start;
   4.157 -    Elf_Phdr *phdr;
   4.158 -    int h, filesz, memsz, paddr;
   4.159 -    unsigned long elfaddr, dom_mpaddr, dom_imva;
   4.160 -    struct page *p;
   4.161 +	char *elfbase = image_start;
   4.162 +	//Elf_Ehdr *ehdr = (Elf_Ehdr *)image_start;
   4.163 +	Elf_Ehdr ehdr;
   4.164 +	Elf_Phdr phdr;
   4.165 +	int h, filesz, memsz, paddr;
   4.166 +	unsigned long elfaddr, dom_mpaddr, dom_imva;
   4.167 +	struct page *p;
   4.168    
   4.169 -    for ( h = 0; h < ehdr->e_phnum; h++ ) {
   4.170 -        phdr = (Elf_Phdr *)(elfbase + ehdr->e_phoff + (h*ehdr->e_phentsize));
   4.171 -        //if ( !is_loadable_phdr(phdr) )
   4.172 -        if ((phdr->p_type != PT_LOAD)) {
   4.173 -            continue;
   4.174 +	copy_memory(&ehdr,image_start,sizeof(Elf_Ehdr));
   4.175 +	for ( h = 0; h < ehdr.e_phnum; h++ ) {
   4.176 +		copy_memory(&phdr,elfbase + ehdr.e_phoff + (h*ehdr.e_phentsize),
   4.177 +		sizeof(Elf_Phdr));
   4.178 +	    //if ( !is_loadable_phdr(phdr) )
   4.179 +	    if ((phdr.p_type != PT_LOAD)) {
   4.180 +	        continue;
   4.181  	}
   4.182 -	filesz = phdr->p_filesz; memsz = phdr->p_memsz;
   4.183 -	elfaddr = elfbase + phdr->p_offset;
   4.184 -	dom_mpaddr = phdr->p_paddr;
   4.185 +	filesz = phdr.p_filesz; memsz = phdr.p_memsz;
   4.186 +	elfaddr = elfbase + phdr.p_offset;
   4.187 +	dom_mpaddr = phdr.p_paddr;
   4.188  //printf("p_offset: %x, size=%x\n",elfaddr,filesz);
   4.189  #ifdef CONFIG_DOMAIN0_CONTIGUOUS
   4.190  	if (d == dom0) {
   4.191 @@ -418,10 +435,10 @@ void loaddomainelfimage(struct domain *d
   4.192  			while(1);
   4.193  		}
   4.194  		dom_imva = __va(dom_mpaddr + dom0_start);
   4.195 -		memcpy(dom_imva,elfaddr,filesz);
   4.196 +		copy_memory(dom_imva,elfaddr,filesz);
   4.197  		if (memsz > filesz) memset(dom_imva+filesz,0,memsz-filesz);
   4.198  //FIXME: This test for code seems to find a lot more than objdump -x does
   4.199 -		if (phdr->p_flags & PF_X) privify_memory(dom_imva,filesz);
   4.200 +		if (phdr.p_flags & PF_X) privify_memory(dom_imva,filesz);
   4.201  	}
   4.202  	else
   4.203  #endif
   4.204 @@ -431,13 +448,13 @@ void loaddomainelfimage(struct domain *d
   4.205  		dom_imva = __va(page_to_phys(p));
   4.206  		if (filesz > 0) {
   4.207  			if (filesz >= PAGE_SIZE)
   4.208 -				memcpy(dom_imva,elfaddr,PAGE_SIZE);
   4.209 +				copy_memory(dom_imva,elfaddr,PAGE_SIZE);
   4.210  			else { // copy partial page, zero the rest of page
   4.211 -				memcpy(dom_imva,elfaddr,filesz);
   4.212 +				copy_memory(dom_imva,elfaddr,filesz);
   4.213  				memset(dom_imva+filesz,0,PAGE_SIZE-filesz);
   4.214  			}
   4.215  //FIXME: This test for code seems to find a lot more than objdump -x does
   4.216 -			if (phdr->p_flags & PF_X)
   4.217 +			if (phdr.p_flags & PF_X)
   4.218  				privify_memory(dom_imva,PAGE_SIZE);
   4.219  		}
   4.220  		else if (memsz > 0) // always zero out entire page
   4.221 @@ -445,66 +462,102 @@ void loaddomainelfimage(struct domain *d
   4.222  		memsz -= PAGE_SIZE; filesz -= PAGE_SIZE;
   4.223  		elfaddr += PAGE_SIZE; dom_mpaddr += PAGE_SIZE;
   4.224  	}
   4.225 -    }
   4.226 +	}
   4.227 +}
   4.228 +
   4.229 +int
   4.230 +parsedomainelfimage(char *elfbase, unsigned long elfsize, unsigned long *entry)
   4.231 +{
   4.232 +	Elf_Ehdr ehdr;
   4.233 +
   4.234 +	copy_memory(&ehdr,elfbase,sizeof(Elf_Ehdr));
   4.235 +
   4.236 +	if ( !elf_sanity_check(&ehdr) ) {
   4.237 +	    printk("ELF sanity check failed.\n");
   4.238 +	    return -EINVAL;
   4.239 +	}
   4.240 +
   4.241 +	if ( (ehdr.e_phoff + (ehdr.e_phnum * ehdr.e_phentsize)) > elfsize )
   4.242 +	{
   4.243 +	    printk("ELF program headers extend beyond end of image.\n");
   4.244 +	    return -EINVAL;
   4.245 +	}
   4.246 +
   4.247 +	if ( (ehdr.e_shoff + (ehdr.e_shnum * ehdr.e_shentsize)) > elfsize )
   4.248 +	{
   4.249 +	    printk("ELF section headers extend beyond end of image.\n");
   4.250 +	    return -EINVAL;
   4.251 +	}
   4.252 +
   4.253 +	/* Find the section-header strings table. */
   4.254 +	if ( ehdr.e_shstrndx == SHN_UNDEF )
   4.255 +	{
   4.256 +	    printk("ELF image has no section-header strings table (shstrtab).\n");
   4.257 +	    return -EINVAL;
   4.258 +	}
   4.259 +
   4.260 +	*entry = ehdr.e_entry;
   4.261 +
   4.262 +	return 0;
   4.263  }
   4.264  
   4.265  
   4.266  void alloc_dom0(void)
   4.267  {
   4.268  #ifdef CONFIG_DOMAIN0_CONTIGUOUS
   4.269 -    if (platform_is_hp_ski()) {
   4.270 +	if (platform_is_hp_ski()) {
   4.271  	dom0_size = 128*1024*1024; //FIXME: Should be configurable
   4.272 -    }
   4.273 -    printf("alloc_dom0: starting (initializing %d MB...)\n",dom0_size/(1024*1024));
   4.274 -    dom0_start = __alloc_bootmem(dom0_size,dom0_align,__pa(MAX_DMA_ADDRESS));
   4.275 -    if (!dom0_start) {
   4.276 +	}
   4.277 +	printf("alloc_dom0: starting (initializing %d MB...)\n",dom0_size/(1024*1024));
   4.278 +	dom0_start = __alloc_bootmem(dom0_size,dom0_align,__pa(MAX_DMA_ADDRESS));
   4.279 +	if (!dom0_start) {
   4.280  	printf("construct_dom0: can't allocate contiguous memory size=%p\n",
   4.281  		dom0_size);
   4.282  	while(1);
   4.283 -    }
   4.284 -    printf("alloc_dom0: dom0_start=%p\n",dom0_start);
   4.285 +	}
   4.286 +	printf("alloc_dom0: dom0_start=%p\n",dom0_start);
   4.287  #else
   4.288 -    dom0_start = 0;
   4.289 +	dom0_start = 0;
   4.290  #endif
   4.291  
   4.292  }
   4.293  
   4.294  int construct_dom0(struct domain *d, 
   4.295 -                   unsigned long image_start, unsigned long image_len, 
   4.296 -                   unsigned long initrd_start, unsigned long initrd_len,
   4.297 -                   char *cmdline)
   4.298 +	               unsigned long image_start, unsigned long image_len, 
   4.299 +	               unsigned long initrd_start, unsigned long initrd_len,
   4.300 +	               char *cmdline)
   4.301  {
   4.302 -    char *dst;
   4.303 -    int i, rc;
   4.304 -    unsigned long pfn, mfn;
   4.305 -    unsigned long nr_pt_pages;
   4.306 -    unsigned long count;
   4.307 -    //l2_pgentry_t *l2tab, *l2start;
   4.308 -    //l1_pgentry_t *l1tab = NULL, *l1start = NULL;
   4.309 -    struct pfn_info *page = NULL;
   4.310 -    start_info_t *si;
   4.311 -    struct exec_domain *ed = d->exec_domain[0];
   4.312 +	char *dst;
   4.313 +	int i, rc;
   4.314 +	unsigned long pfn, mfn;
   4.315 +	unsigned long nr_pt_pages;
   4.316 +	unsigned long count;
   4.317 +	//l2_pgentry_t *l2tab, *l2start;
   4.318 +	//l1_pgentry_t *l1tab = NULL, *l1start = NULL;
   4.319 +	struct pfn_info *page = NULL;
   4.320 +	start_info_t *si;
   4.321 +	struct exec_domain *ed = d->exec_domain[0];
   4.322  
   4.323 -    struct domain_setup_info dsi;
   4.324 -    unsigned long p_start;
   4.325 -    unsigned long pkern_start;
   4.326 -    unsigned long pkern_entry;
   4.327 -    unsigned long pkern_end;
   4.328 +	struct domain_setup_info dsi;
   4.329 +	unsigned long p_start;
   4.330 +	unsigned long pkern_start;
   4.331 +	unsigned long pkern_entry;
   4.332 +	unsigned long pkern_end;
   4.333  
   4.334 -    extern void physdev_init_dom0(struct domain *);
   4.335 +	extern void physdev_init_dom0(struct domain *);
   4.336  
   4.337  //printf("construct_dom0: starting\n");
   4.338 -    /* Sanity! */
   4.339 +	/* Sanity! */
   4.340  #ifndef CLONE_DOMAIN0
   4.341 -    if ( d != dom0 ) 
   4.342 -        BUG();
   4.343 -    if ( test_bit(DF_CONSTRUCTED, &d->d_flags) ) 
   4.344 -        BUG();
   4.345 +	if ( d != dom0 ) 
   4.346 +	    BUG();
   4.347 +	if ( test_bit(DF_CONSTRUCTED, &d->d_flags) ) 
   4.348 +	    BUG();
   4.349  #endif
   4.350  
   4.351 -    memset(&dsi, 0, sizeof(struct domain_setup_info));
   4.352 +	memset(&dsi, 0, sizeof(struct domain_setup_info));
   4.353  
   4.354 -    printk("*** LOADING DOMAIN 0 ***\n");
   4.355 +	printk("*** LOADING DOMAIN 0 ***\n");
   4.356  
   4.357  	d->max_pages = dom0_size/PAGE_SIZE;
   4.358  	image_start = __va(ia64_boot_param->initrd_start);
   4.359 @@ -513,139 +566,211 @@ int construct_dom0(struct domain *d,
   4.360  //printk("First word of image: %lx\n",*(unsigned long *)image_start);
   4.361  
   4.362  //printf("construct_dom0: about to call parseelfimage\n");
   4.363 -    rc = parseelfimage(image_start, image_len, &dsi);
   4.364 -    if ( rc != 0 )
   4.365 -        return rc;
   4.366 +	rc = parseelfimage(image_start, image_len, &dsi);
   4.367 +	if ( rc != 0 )
   4.368 +	    return rc;
   4.369  
   4.370 -    p_start = dsi.v_start;
   4.371 -    pkern_start = dsi.v_kernstart;
   4.372 -    pkern_end = dsi.v_kernend;
   4.373 -    pkern_entry = dsi.v_kernentry;
   4.374 +	p_start = dsi.v_start;
   4.375 +	pkern_start = dsi.v_kernstart;
   4.376 +	pkern_end = dsi.v_kernend;
   4.377 +	pkern_entry = dsi.v_kernentry;
   4.378  
   4.379  //printk("p_start=%lx, pkern_start=%lx, pkern_end=%lx, pkern_entry=%lx\n",p_start,pkern_start,pkern_end,pkern_entry);
   4.380  
   4.381 -    if ( (p_start & (PAGE_SIZE-1)) != 0 )
   4.382 -    {
   4.383 -        printk("Initial guest OS must load to a page boundary.\n");
   4.384 -        return -EINVAL;
   4.385 -    }
   4.386 +	if ( (p_start & (PAGE_SIZE-1)) != 0 )
   4.387 +	{
   4.388 +	    printk("Initial guest OS must load to a page boundary.\n");
   4.389 +	    return -EINVAL;
   4.390 +	}
   4.391  
   4.392 -    printk("METAPHYSICAL MEMORY ARRANGEMENT:\n"
   4.393 -           " Kernel image:  %lx->%lx\n"
   4.394 -           " Entry address: %lx\n"
   4.395 -           " Init. ramdisk:   (NOT IMPLEMENTED YET)\n",
   4.396 -           pkern_start, pkern_end, pkern_entry);
   4.397 +	printk("METAPHYSICAL MEMORY ARRANGEMENT:\n"
   4.398 +	       " Kernel image:  %lx->%lx\n"
   4.399 +	       " Entry address: %lx\n"
   4.400 +	       " Init. ramdisk:   (NOT IMPLEMENTED YET)\n",
   4.401 +	       pkern_start, pkern_end, pkern_entry);
   4.402  
   4.403 -    if ( (pkern_end - pkern_start) > (d->max_pages * PAGE_SIZE) )
   4.404 -    {
   4.405 -        printk("Initial guest OS requires too much space\n"
   4.406 -               "(%luMB is greater than %luMB limit)\n",
   4.407 -               (pkern_end-pkern_start)>>20, (d->max_pages<<PAGE_SHIFT)>>20);
   4.408 -        return -ENOMEM;
   4.409 -    }
   4.410 +	if ( (pkern_end - pkern_start) > (d->max_pages * PAGE_SIZE) )
   4.411 +	{
   4.412 +	    printk("Initial guest OS requires too much space\n"
   4.413 +	           "(%luMB is greater than %luMB limit)\n",
   4.414 +	           (pkern_end-pkern_start)>>20, (d->max_pages<<PAGE_SHIFT)>>20);
   4.415 +	    return -ENOMEM;
   4.416 +	}
   4.417  
   4.418 -    // if high 3 bits of pkern start are non-zero, error
   4.419 +	// if high 3 bits of pkern start are non-zero, error
   4.420  
   4.421 -    // if pkern end is after end of metaphysical memory, error
   4.422 -    //  (we should be able to deal with this... later)
   4.423 +	// if pkern end is after end of metaphysical memory, error
   4.424 +	//  (we should be able to deal with this... later)
   4.425  
   4.426  
   4.427 -    //
   4.428 +	//
   4.429  
   4.430  #if 0
   4.431 -    strcpy(d->name,"Domain0");
   4.432 +	strcpy(d->name,"Domain0");
   4.433  #endif
   4.434  
   4.435  	// prepare domain0 pagetable (maps METAphysical to physical)
   4.436  	// following is roughly mm_init() in linux/kernel/fork.c
   4.437  	d->arch.mm = kmem_cache_alloc(mm_cachep, SLAB_KERNEL);
   4.438  	if (unlikely(!d->arch.mm)) {
   4.439 -        	printk("Can't allocate mm_struct for domain0\n");
   4.440 -        	return -ENOMEM;
   4.441 +	    	printk("Can't allocate mm_struct for domain0\n");
   4.442 +	    	return -ENOMEM;
   4.443  	}
   4.444  	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   4.445  	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   4.446  	if (unlikely(!d->arch.mm->pgd)) {
   4.447 -        	printk("Can't allocate pgd for domain0\n");
   4.448 -        	return -ENOMEM;
   4.449 +	    	printk("Can't allocate pgd for domain0\n");
   4.450 +	    	return -ENOMEM;
   4.451  	}
   4.452  
   4.453  
   4.454 -    /* Mask all upcalls... */
   4.455 -    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   4.456 -        d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
   4.457 +	/* Mask all upcalls... */
   4.458 +	for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   4.459 +	    d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
   4.460  
   4.461 -    /* Copy the OS image. */
   4.462 -    //(void)loadelfimage(image_start);
   4.463 +	/* Copy the OS image. */
   4.464 +	//(void)loadelfimage(image_start);
   4.465  	loaddomainelfimage(d,image_start);
   4.466  
   4.467 -    /* Copy the initial ramdisk. */
   4.468 -    //if ( initrd_len != 0 )
   4.469 -    //    memcpy((void *)vinitrd_start, initrd_start, initrd_len);
   4.470 +	/* Copy the initial ramdisk. */
   4.471 +	//if ( initrd_len != 0 )
   4.472 +	//    memcpy((void *)vinitrd_start, initrd_start, initrd_len);
   4.473  
   4.474  #if 0
   4.475 -    /* Set up start info area. */
   4.476 -    //si = (start_info_t *)vstartinfo_start;
   4.477 -    memset(si, 0, PAGE_SIZE);
   4.478 -    si->nr_pages     = d->tot_pages;
   4.479 -    si->shared_info  = virt_to_phys(d->shared_info);
   4.480 -    si->flags        = SIF_PRIVILEGED | SIF_INITDOMAIN;
   4.481 -    //si->pt_base      = vpt_start;
   4.482 -    //si->nr_pt_frames = nr_pt_pages;
   4.483 -    //si->mfn_list     = vphysmap_start;
   4.484 +	/* Set up start info area. */
   4.485 +	//si = (start_info_t *)vstartinfo_start;
   4.486 +	memset(si, 0, PAGE_SIZE);
   4.487 +	si->nr_pages     = d->tot_pages;
   4.488 +	si->shared_info  = virt_to_phys(d->shared_info);
   4.489 +	si->flags        = SIF_PRIVILEGED | SIF_INITDOMAIN;
   4.490 +	//si->pt_base      = vpt_start;
   4.491 +	//si->nr_pt_frames = nr_pt_pages;
   4.492 +	//si->mfn_list     = vphysmap_start;
   4.493  
   4.494 -    if ( initrd_len != 0 )
   4.495 -    {
   4.496 -        //si->mod_start = vinitrd_start;
   4.497 -        si->mod_len   = initrd_len;
   4.498 -        printk("Initrd len 0x%lx, start at 0x%08lx\n",
   4.499 -               si->mod_len, si->mod_start);
   4.500 -    }
   4.501 +	if ( initrd_len != 0 )
   4.502 +	{
   4.503 +	    //si->mod_start = vinitrd_start;
   4.504 +	    si->mod_len   = initrd_len;
   4.505 +	    printk("Initrd len 0x%lx, start at 0x%08lx\n",
   4.506 +	           si->mod_len, si->mod_start);
   4.507 +	}
   4.508  
   4.509 -    dst = si->cmd_line;
   4.510 -    if ( cmdline != NULL )
   4.511 -    {
   4.512 -        for ( i = 0; i < 255; i++ )
   4.513 -        {
   4.514 -            if ( cmdline[i] == '\0' )
   4.515 -                break;
   4.516 -            *dst++ = cmdline[i];
   4.517 -        }
   4.518 -    }
   4.519 -    *dst = '\0';
   4.520 +	dst = si->cmd_line;
   4.521 +	if ( cmdline != NULL )
   4.522 +	{
   4.523 +	    for ( i = 0; i < 255; i++ )
   4.524 +	    {
   4.525 +	        if ( cmdline[i] == '\0' )
   4.526 +	            break;
   4.527 +	        *dst++ = cmdline[i];
   4.528 +	    }
   4.529 +	}
   4.530 +	*dst = '\0';
   4.531  
   4.532 -    zap_low_mappings(); /* Do the same for the idle page tables. */
   4.533 +	zap_low_mappings(); /* Do the same for the idle page tables. */
   4.534  #endif
   4.535 -    
   4.536 -    /* Give up the VGA console if DOM0 is configured to grab it. */
   4.537 +	
   4.538 +	/* Give up the VGA console if DOM0 is configured to grab it. */
   4.539  #ifdef IA64
   4.540  	if (cmdline != NULL)
   4.541  #endif
   4.542 -    console_endboot(strstr(cmdline, "tty0") != NULL);
   4.543 +	console_endboot(strstr(cmdline, "tty0") != NULL);
   4.544  
   4.545 -    /* DOM0 gets access to everything. */
   4.546 +	/* DOM0 gets access to everything. */
   4.547 +#ifdef CLONE_DOMAIN0
   4.548 +if (d == dom0)
   4.549 +#endif
   4.550 +	physdev_init_dom0(d);
   4.551 +
   4.552 +	set_bit(DF_CONSTRUCTED, &d->d_flags);
   4.553 +
   4.554 +	new_thread(ed, pkern_entry, 0, 0);
   4.555 +	// FIXME: Hack for keyboard input
   4.556  #ifdef CLONE_DOMAIN0
   4.557  if (d == dom0)
   4.558  #endif
   4.559 -    physdev_init_dom0(d);
   4.560 +	serial_input_init();
   4.561 +	if (d == dom0) {
   4.562 +		ed->vcpu_info->arch.delivery_mask[0] = -1L;
   4.563 +		ed->vcpu_info->arch.delivery_mask[1] = -1L;
   4.564 +		ed->vcpu_info->arch.delivery_mask[2] = -1L;
   4.565 +		ed->vcpu_info->arch.delivery_mask[3] = -1L;
   4.566 +	}
   4.567 +	else __set_bit(0x30,ed->vcpu_info->arch.delivery_mask);
   4.568 +
   4.569 +	return 0;
   4.570 +}
   4.571  
   4.572 -    set_bit(DF_CONSTRUCTED, &d->d_flags);
   4.573 +// FIXME: When dom0 can construct domains, this goes away (or is rewritten)
   4.574 +int construct_domN(struct domain *d,
   4.575 +		   unsigned long image_start, unsigned long image_len,
   4.576 +	           unsigned long initrd_start, unsigned long initrd_len,
   4.577 +	           char *cmdline)
   4.578 +{
   4.579 +	int i, rc;
   4.580 +	struct exec_domain *ed = d->exec_domain[0];
   4.581 +	unsigned long pkern_entry;
   4.582 +
   4.583 +	if ( test_bit(DF_CONSTRUCTED, &d->d_flags) ) BUG();
   4.584 +
   4.585 +	printk("*** LOADING DOMAIN %d ***\n",d->id);
   4.586 +
   4.587 +	d->max_pages = dom0_size/PAGE_SIZE;	// FIXME: use dom0 size
   4.588 +	// FIXME: use domain0 command line
   4.589 +	rc = parsedomainelfimage(image_start, image_len, &pkern_entry);
   4.590 +	printk("parsedomainelfimage returns %d\n",rc);
   4.591 +	if ( rc != 0 ) return rc;
   4.592  
   4.593 -    new_thread(ed, pkern_entry, 0, 0);
   4.594 -    // FIXME: Hack for keyboard input
   4.595 -#ifdef CLONE_DOMAIN0
   4.596 -if (d == dom0)
   4.597 -#endif
   4.598 -    serial_input_init();
   4.599 -    if (d == dom0) {
   4.600 -    	ed->vcpu_info->arch.delivery_mask[0] = -1L;
   4.601 -    	ed->vcpu_info->arch.delivery_mask[1] = -1L;
   4.602 -    	ed->vcpu_info->arch.delivery_mask[2] = -1L;
   4.603 -    	ed->vcpu_info->arch.delivery_mask[3] = -1L;
   4.604 -    }
   4.605 -    else __set_bit(0x30,ed->vcpu_info->arch.delivery_mask);
   4.606 +	d->arch.mm = kmem_cache_alloc(mm_cachep, SLAB_KERNEL);
   4.607 +	if (unlikely(!d->arch.mm)) {
   4.608 +	    	printk("Can't allocate mm_struct for domain %d\n",d->id);
   4.609 +	    	return -ENOMEM;
   4.610 +	}
   4.611 +	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   4.612 +	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   4.613 +	if (unlikely(!d->arch.mm->pgd)) {
   4.614 +	    	printk("Can't allocate pgd for domain %d\n",d->id);
   4.615 +	    	return -ENOMEM;
   4.616 +	}
   4.617 +
   4.618 +
   4.619 +	/* Mask all upcalls... */
   4.620 +	for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   4.621 +		d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
   4.622 +
   4.623 +	/* Copy the OS image. */
   4.624 +	printk("calling loaddomainelfimage\n");
   4.625 +	loaddomainelfimage(d,image_start);
   4.626 +	printk("loaddomainelfimage returns\n");
   4.627 +
   4.628 +	set_bit(DF_CONSTRUCTED, &d->d_flags);
   4.629  
   4.630 -    return 0;
   4.631 +	printk("calling new_thread\n");
   4.632 +	new_thread(ed, pkern_entry, 0, 0);
   4.633 +	printk("new_thread returns\n");
   4.634 +	__set_bit(0x30,ed->vcpu_info->arch.delivery_mask);
   4.635 +
   4.636 +	return 0;
   4.637 +}
   4.638 +
   4.639 +// FIXME: When dom0 can construct domains, this goes away (or is rewritten)
   4.640 +int launch_domainN(unsigned long start, unsigned long len,
   4.641 +		   unsigned long initrd_start, unsigned long initrd_len,
   4.642 +		   char *cmdline)
   4.643 +{
   4.644 +	static int next = 100;  // FIXME
   4.645 +
   4.646 +	struct domain *d = do_createdomain(next,0);
   4.647 +	if (!d) {
   4.648 +		printf("launch_domainN: couldn't create\n");
   4.649 +		return 1;
   4.650 +	}
   4.651 +	if (construct_domN(d, start, len, 0, 0, 0)) {
   4.652 +		printf("launch_domainN: couldn't construct(id=%d,%lx,%lx)\n",
   4.653 +			d->id,start,len);
   4.654 +		return 2;
   4.655 +	}
   4.656 +	domain_unpause_by_systemcontroller(d);
   4.657  }
   4.658  
   4.659  void machine_restart(char * __unused)
   4.660 @@ -670,6 +795,7 @@ void dummy(void)
   4.661  }
   4.662  
   4.663  
   4.664 +#if 0
   4.665  void switch_to(struct exec_domain *prev, struct exec_domain *next)
   4.666  {
   4.667   	struct exec_domain *last;
   4.668 @@ -677,6 +803,7 @@ void switch_to(struct exec_domain *prev,
   4.669  	__switch_to(prev,next,last);
   4.670  	//set_current(next);
   4.671  }
   4.672 +#endif
   4.673  
   4.674  void domain_pend_keyboard_interrupt(int irq)
   4.675  {
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xen/arch/ia64/hypercall.c	Thu Mar 24 16:49:14 2005 +0000
     5.3 @@ -0,0 +1,98 @@
     5.4 +/*
     5.5 + * Hypercall implementations
     5.6 + * 
     5.7 + * Copyright (C) 2005 Hewlett-Packard Co.
     5.8 + *	Dan Magenheimer (dan.magenheimer@hp.com)
     5.9 + *
    5.10 + */
    5.11 +
    5.12 +#include <xen/config.h>
    5.13 +#include <xen/sched.h>
    5.14 +
    5.15 +#include <linux/efi.h>	/* FOR EFI_UNIMPLEMENTED */
    5.16 +#include <asm/sal.h>	/* FOR struct ia64_sal_retval */
    5.17 +
    5.18 +#include <asm/vcpu.h>
    5.19 +#include <asm/dom_fw.h>
    5.20 +
    5.21 +extern unsigned long translate_domain_mpaddr(unsigned long);
    5.22 +extern struct ia64_sal_retval pal_emulator_static(UINT64);
    5.23 +extern struct ia64_sal_retval sal_emulator(UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64);
    5.24 +
    5.25 +void fooefi(void) {}
    5.26 +
    5.27 +void
    5.28 +ia64_hypercall (struct pt_regs *regs)
    5.29 +{
    5.30 +	struct exec_domain *ed = (struct domain *) current;
    5.31 +	struct ia64_sal_retval x;
    5.32 +	unsigned long *tv, *tc;
    5.33 +
    5.34 +	switch (regs->r2) {
    5.35 +	    case FW_HYPERCALL_PAL_CALL:
    5.36 +		//printf("*** PAL hypercall: index=%d\n",regs->r28);
    5.37 +		//FIXME: This should call a C routine
    5.38 +		x = pal_emulator_static(regs->r28);
    5.39 +		regs->r8 = x.status; regs->r9 = x.v0;
    5.40 +		regs->r10 = x.v1; regs->r11 = x.v2;
    5.41 +		break;
    5.42 +	    case FW_HYPERCALL_SAL_CALL:
    5.43 +		x = sal_emulator(vcpu_get_gr(ed,32),vcpu_get_gr(ed,33),
    5.44 +			vcpu_get_gr(ed,34),vcpu_get_gr(ed,35),
    5.45 +			vcpu_get_gr(ed,36),vcpu_get_gr(ed,37),
    5.46 +			vcpu_get_gr(ed,38),vcpu_get_gr(ed,39));
    5.47 +		regs->r8 = x.status; regs->r9 = x.v0;
    5.48 +		regs->r10 = x.v1; regs->r11 = x.v2;
    5.49 +		break;
    5.50 +	    case FW_HYPERCALL_EFI_RESET_SYSTEM:
    5.51 +		printf("efi.reset_system called ");
    5.52 +		if (current->domain == dom0) {
    5.53 +			printf("(by dom0)\n ");
    5.54 +			(*efi.reset_system)(EFI_RESET_WARM,0,0,NULL);
    5.55 +		}
    5.56 +		printf("(not supported for non-0 domain)\n");
    5.57 +		regs->r8 = EFI_UNSUPPORTED;
    5.58 +		break;
    5.59 +	    case FW_HYPERCALL_EFI_GET_TIME:
    5.60 +		fooefi();
    5.61 +		tv = vcpu_get_gr(ed,32);
    5.62 +		tc = vcpu_get_gr(ed,33);
    5.63 +		//printf("efi_get_time(%p,%p) called...",tv,tc);
    5.64 +		tv = __va(translate_domain_mpaddr(tv));
    5.65 +		if (tc) tc = __va(translate_domain_mpaddr(tc));
    5.66 +		regs->r8 = (*efi.get_time)(tv,tc);
    5.67 +		//printf("and returns %lx\n",regs->r8);
    5.68 +		break;
    5.69 +	    case FW_HYPERCALL_EFI_SET_TIME:
    5.70 +	    case FW_HYPERCALL_EFI_GET_WAKEUP_TIME:
    5.71 +	    case FW_HYPERCALL_EFI_SET_WAKEUP_TIME:
    5.72 +		// FIXME: need fixes in efi.h from 2.6.9
    5.73 +	    case FW_HYPERCALL_EFI_SET_VIRTUAL_ADDRESS_MAP:
    5.74 +		// FIXME: WARNING!! IF THIS EVER GETS IMPLEMENTED
    5.75 +		// SOME OF THE OTHER EFI EMULATIONS WILL CHANGE AS 
    5.76 +		// POINTER ARGUMENTS WILL BE VIRTUAL!!
    5.77 +	    case FW_HYPERCALL_EFI_GET_VARIABLE:
    5.78 +		// FIXME: need fixes in efi.h from 2.6.9
    5.79 +	    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
    5.80 +	    case FW_HYPERCALL_EFI_SET_VARIABLE:
    5.81 +	    case FW_HYPERCALL_EFI_GET_NEXT_HIGH_MONO_COUNT:
    5.82 +		// FIXME: need fixes in efi.h from 2.6.9
    5.83 +		regs->r8 = EFI_UNSUPPORTED;
    5.84 +		break;
    5.85 +	    case 0xffff: // test dummy hypercall
    5.86 +		regs->r8 = dump_privop_counts_to_user(
    5.87 +			vcpu_get_gr(ed,32),
    5.88 +			vcpu_get_gr(ed,33));
    5.89 +		break;
    5.90 +	    case 0xfffe: // test dummy hypercall
    5.91 +		regs->r8 = zero_privop_counts_to_user(
    5.92 +			vcpu_get_gr(ed,32),
    5.93 +			vcpu_get_gr(ed,33));
    5.94 +		break;
    5.95 +	    case 0xfffd: // test dummy hypercall
    5.96 +		regs->r8 = launch_domainN(
    5.97 +			vcpu_get_gr(ed,32),
    5.98 +			vcpu_get_gr(ed,33), 0, 0, 0);
    5.99 +		break;
   5.100 +	}
   5.101 +}
     6.1 --- a/xen/arch/ia64/patch/linux-2.6.7/system.h	Thu Mar 24 11:04:24 2005 +0000
     6.2 +++ b/xen/arch/ia64/patch/linux-2.6.7/system.h	Thu Mar 24 16:49:14 2005 +0000
     6.3 @@ -1,5 +1,5 @@
     6.4 ---- /home/djm/src/xen/xeno-ia64.bk/xen/linux-2.6.7/include/asm-ia64/system.h	2005-01-23 13:23:36.000000000 -0700
     6.5 -+++ /home/djm/src/xen/xeno-ia64.bk/xen/include/asm-ia64/system.h	2004-09-17 18:27:22.000000000 -0600
     6.6 +--- ../../linux-2.6.7/include/asm-ia64/system.h	2005-01-31 11:15:23.000000000 -0700
     6.7 ++++ include/asm-ia64/system.h	2005-03-14 11:31:12.000000000 -0700
     6.8  @@ -24,8 +24,16 @@
     6.9    * 0xa000000000000000+2*PERCPU_PAGE_SIZE
    6.10    * - 0xa000000000000000+3*PERCPU_PAGE_SIZE remain unmapped (guard page)
    6.11 @@ -35,9 +35,9 @@
    6.12   #else
    6.13   # define switch_to(prev,next,last)	__switch_to(prev, next, last)
    6.14   #endif
    6.15 -+#ifdef XEN
    6.16 -+#undef switch_to
    6.17 -+#endif
    6.18 ++//#ifdef XEN
    6.19 ++//#undef switch_to
    6.20 ++//#endif
    6.21   
    6.22   /*
    6.23    * On IA-64, we don't want to hold the runqueue's lock during the low-level context-switch,
     7.1 --- a/xen/arch/ia64/patch/linux-2.6.7/time.c	Thu Mar 24 11:04:24 2005 +0000
     7.2 +++ b/xen/arch/ia64/patch/linux-2.6.7/time.c	Thu Mar 24 16:49:14 2005 +0000
     7.3 @@ -1,5 +1,5 @@
     7.4  --- ../../linux-2.6.7/arch/ia64/kernel/time.c	2004-06-15 23:19:01.000000000 -0600
     7.5 -+++ arch/ia64/time.c	2005-03-09 13:22:52.000000000 -0700
     7.6 ++++ arch/ia64/time.c	2005-03-14 17:27:11.000000000 -0700
     7.7  @@ -10,16 +10,22 @@
     7.8    */
     7.9   #include <linux/config.h>
    7.10 @@ -208,7 +208,7 @@
    7.11  +	}
    7.12  +	if (domain0_ready && vcpu_timer_expired(dom0->exec_domain[0])) {
    7.13  +		vcpu_pend_timer(dom0->exec_domain[0]);
    7.14 -+		vcpu_set_next_timer(dom0->exec_domain[0]);
    7.15 ++		//vcpu_set_next_timer(dom0->exec_domain[0]);
    7.16  +		domain_wake(dom0->exec_domain[0]);
    7.17  +	}
    7.18  +	if (!is_idle_task(current->domain) && current->domain != dom0) {
     8.1 --- a/xen/arch/ia64/process.c	Thu Mar 24 11:04:24 2005 +0000
     8.2 +++ b/xen/arch/ia64/process.c	Thu Mar 24 16:49:14 2005 +0000
     8.3 @@ -143,15 +143,13 @@ void reflect_interruption(unsigned long 
     8.4  	}
     8.5  	if (!PSCB(ed,interrupt_collection_enabled)) {
     8.6  		if (!(PSCB(ed,ipsr) & IA64_PSR_DT)) {
     8.7 -			printf("psr.dt off, trying to deliver nested dtlb!\n");
     8.8 -			while(1);
     8.9 +			panic_domain(regs,"psr.dt off, trying to deliver nested dtlb!\n");
    8.10  		}
    8.11  		vector &= ~0xf;
    8.12  		if (vector != IA64_DATA_TLB_VECTOR &&
    8.13 -		    vector != IA64_DATA_TLB_VECTOR) {
    8.14 -printf("psr.ic off, delivering fault=%lx,iip=%p,isr=%p,PSCB.iip=%p\n",
    8.15 -	vector,regs->cr_iip,isr,PSCB(ed,iip));
    8.16 -			while(1);
    8.17 +		    vector != IA64_ALT_DATA_TLB_VECTOR) {
    8.18 +panic_domain(regs,"psr.ic off, delivering fault=%lx,iip=%p,ifa=%p,isr=%p,PSCB.iip=%p\n",
    8.19 +	vector,regs->cr_iip,ifa,isr,PSCB(ed,iip));
    8.20  			
    8.21  		}
    8.22  //printf("Delivering NESTED DATA TLB fault\n");
    8.23 @@ -206,10 +204,11 @@ void deliver_pending_interrupt(struct pt
    8.24  	struct exec_domain *ed = current;
    8.25  	// FIXME: Will this work properly if doing an RFI???
    8.26  	if (!is_idle_task(d) && user_mode(regs)) {
    8.27 -		vcpu_poke_timer(ed);
    8.28 +		//vcpu_poke_timer(ed);
    8.29  		if (vcpu_deliverable_interrupts(ed)) {
    8.30  			unsigned long isr = regs->cr_ipsr & IA64_PSR_RI;
    8.31 -			foodpi();
    8.32 +			if (vcpu_timer_pending_early(ed))
    8.33 +printf("*#*#*#* about to deliver early timer to domain %d!!!\n",ed->domain->id);
    8.34  			reflect_interruption(0,isr,0,regs,IA64_EXTINT_VECTOR);
    8.35  		}
    8.36  	}
    8.37 @@ -243,9 +242,6 @@ void xen_handle_domain_access(unsigned l
    8.38  	unsigned long lookup_domain_mpa(struct domain *,unsigned long);
    8.39  	unsigned long match_dtlb(struct exec_domain *,unsigned long, unsigned long *, unsigned long *);
    8.40  	IA64FAULT fault;
    8.41 -#ifndef USER_ACCESS
    8.42 -	extern void __get_domain_bundle(void);
    8.43 -#endif
    8.44  
    8.45  // NEED TO HANDLE THREE CASES:
    8.46  // 1) domain is in metaphysical mode
    8.47 @@ -268,13 +264,6 @@ void xen_handle_domain_access(unsigned l
    8.48  		vcpu_itc_no_srlz(ed,2,address,pteval,-1UL,PAGE_SHIFT);
    8.49  		return;
    8.50  	}
    8.51 -#ifndef USER_ACCESS
    8.52 -	if (*(unsigned long *)__get_domain_bundle != iip) {
    8.53 -		printf("Bad user space access @%p ",address);
    8.54 -		printf("iip=%p, ipsr=%p, b0=%p\n",iip,psr,regs->b0);
    8.55 -		while(1);
    8.56 -	}
    8.57 -#endif
    8.58  if (address < 0x4000) printf("WARNING: page_fault @%p, iip=%p\n",address,iip);
    8.59  		
    8.60  	// if we are fortunate enough to have it in the 1-entry TLB...
    8.61 @@ -285,13 +274,6 @@ if (address < 0x4000) printf("WARNING: p
    8.62  	// look in the TRs
    8.63  	fault = vcpu_tpa(ed,address,&mpaddr);
    8.64  	if (fault != IA64_NO_FAULT) {
    8.65 -#ifndef USER_ACCESS
    8.66 -		// this is hardcoded to handle __get_domain_bundle only
    8.67 -		regs->r8 = 0; regs->r9 = 0;
    8.68 -		regs->cr_iip += 0x20;
    8.69 -		//regs->cr_iip |= (2UL << IA64_PSR_RI_BIT);
    8.70 -		return;
    8.71 -#else /* USER_ACCESS */
    8.72  		static int uacnt = 0;
    8.73  		// can't translate it, just fail (poor man's exception)
    8.74  		// which results in retrying execution
    8.75 @@ -306,9 +288,10 @@ if (address < 0x4000) printf("WARNING: p
    8.76  			printk("*** xen_handle_domain_access: exception table"
    8.77                                 " lookup failed, iip=%p, addr=%p, spinning...\n",
    8.78  				iip,address);
    8.79 -			while(1);
    8.80 +			panic_domain(regs,"*** xen_handle_domain_access: exception table"
    8.81 +                               " lookup failed, iip=%p, addr=%p, spinning...\n",
    8.82 +				iip,address);
    8.83  		}
    8.84 -#endif /* USER_ACCESS */
    8.85  	}
    8.86  	if (d == dom0) {
    8.87  		if (mpaddr < dom0_start || mpaddr >= dom0_start + dom0_size) {
    8.88 @@ -375,7 +358,9 @@ void ia64_do_page_fault (unsigned long a
    8.89  	}
    8.90  	vector = is_data ? IA64_DATA_TLB_VECTOR : IA64_INST_TLB_VECTOR;
    8.91  	if (handle_lazy_cover(current, isr, regs)) return;
    8.92 -if (!(address>>61)) { printf("ia64_do_page_fault: @%p???, iip=%p, itc=%p (spinning...)\n",address,iip,ia64_get_itc()); while(1); }
    8.93 +if (!(address>>61)) {
    8.94 +panic_domain(0,"ia64_do_page_fault: @%p???, iip=%p, itc=%p (spinning...)\n",address,iip,ia64_get_itc());
    8.95 +}
    8.96  	if ((isr & IA64_ISR_SP)
    8.97  	    || ((isr & IA64_ISR_NA) && (isr & IA64_ISR_CODE_MASK) == IA64_ISR_CODE_LFETCH))
    8.98  	{
    8.99 @@ -711,8 +696,6 @@ if (!running_on_sim) { printf("SSC_OPEN,
   8.100  	vcpu_increment_iip(current);
   8.101  }
   8.102  
   8.103 -void fooefi(void) {}
   8.104 -
   8.105  void
   8.106  ia64_handle_break (unsigned long ifa, struct pt_regs *regs, unsigned long isr, unsigned long iim)
   8.107  {
   8.108 @@ -731,72 +714,7 @@ ia64_handle_break (unsigned long ifa, st
   8.109  		else do_ssc(vcpu_get_gr(current,36), regs);
   8.110  	}
   8.111  	else if (iim == d->breakimm) {
   8.112 -		struct ia64_sal_retval x;
   8.113 -		switch (regs->r2) {
   8.114 -		    case FW_HYPERCALL_PAL_CALL:
   8.115 -			//printf("*** PAL hypercall: index=%d\n",regs->r28);
   8.116 -			//FIXME: This should call a C routine
   8.117 -			x = pal_emulator_static(regs->r28);
   8.118 -			regs->r8 = x.status; regs->r9 = x.v0;
   8.119 -			regs->r10 = x.v1; regs->r11 = x.v2;
   8.120 -			break;
   8.121 -		    case FW_HYPERCALL_SAL_CALL:
   8.122 -			x = sal_emulator(vcpu_get_gr(ed,32),vcpu_get_gr(ed,33),
   8.123 -				vcpu_get_gr(ed,34),vcpu_get_gr(ed,35),
   8.124 -				vcpu_get_gr(ed,36),vcpu_get_gr(ed,37),
   8.125 -				vcpu_get_gr(ed,38),vcpu_get_gr(ed,39));
   8.126 -			regs->r8 = x.status; regs->r9 = x.v0;
   8.127 -			regs->r10 = x.v1; regs->r11 = x.v2;
   8.128 -			break;
   8.129 -		    case FW_HYPERCALL_EFI_RESET_SYSTEM:
   8.130 -			printf("efi.reset_system called ");
   8.131 -			if (current->domain == dom0) {
   8.132 -				printf("(by dom0)\n ");
   8.133 -				(*efi.reset_system)(EFI_RESET_WARM,0,0,NULL);
   8.134 -			}
   8.135 -			printf("(not supported for non-0 domain)\n");
   8.136 -			regs->r8 = EFI_UNSUPPORTED;
   8.137 -			break;
   8.138 -		    case FW_HYPERCALL_EFI_GET_TIME:
   8.139 -			{
   8.140 -			unsigned long *tv, *tc;
   8.141 -			fooefi();
   8.142 -			tv = vcpu_get_gr(ed,32);
   8.143 -			tc = vcpu_get_gr(ed,33);
   8.144 -			//printf("efi_get_time(%p,%p) called...",tv,tc);
   8.145 -			tv = __va(translate_domain_mpaddr(tv));
   8.146 -			if (tc) tc = __va(translate_domain_mpaddr(tc));
   8.147 -			regs->r8 = (*efi.get_time)(tv,tc);
   8.148 -			//printf("and returns %lx\n",regs->r8);
   8.149 -			}
   8.150 -			break;
   8.151 -		    case FW_HYPERCALL_EFI_SET_TIME:
   8.152 -		    case FW_HYPERCALL_EFI_GET_WAKEUP_TIME:
   8.153 -		    case FW_HYPERCALL_EFI_SET_WAKEUP_TIME:
   8.154 -			// FIXME: need fixes in efi.h from 2.6.9
   8.155 -		    case FW_HYPERCALL_EFI_SET_VIRTUAL_ADDRESS_MAP:
   8.156 -			// FIXME: WARNING!! IF THIS EVER GETS IMPLEMENTED
   8.157 -			// SOME OF THE OTHER EFI EMULATIONS WILL CHANGE AS 
   8.158 -			// POINTER ARGUMENTS WILL BE VIRTUAL!!
   8.159 -		    case FW_HYPERCALL_EFI_GET_VARIABLE:
   8.160 -			// FIXME: need fixes in efi.h from 2.6.9
   8.161 -		    case FW_HYPERCALL_EFI_GET_NEXT_VARIABLE:
   8.162 -		    case FW_HYPERCALL_EFI_SET_VARIABLE:
   8.163 -		    case FW_HYPERCALL_EFI_GET_NEXT_HIGH_MONO_COUNT:
   8.164 -			// FIXME: need fixes in efi.h from 2.6.9
   8.165 -			regs->r8 = EFI_UNSUPPORTED;
   8.166 -			break;
   8.167 -		    case 0xffff: // test dummy hypercall
   8.168 -			regs->r8 = dump_privop_counts_to_user(
   8.169 -				vcpu_get_gr(ed,32),
   8.170 -				vcpu_get_gr(ed,33));
   8.171 -			break;
   8.172 -		    case 0xfffe: // test dummy hypercall
   8.173 -			regs->r8 = zero_privop_counts_to_user(
   8.174 -				vcpu_get_gr(ed,32),
   8.175 -				vcpu_get_gr(ed,33));
   8.176 -			break;
   8.177 -		}
   8.178 +		ia64_hypercall(regs);
   8.179  		vcpu_increment_iip(current);
   8.180  	}
   8.181  	else reflect_interruption(ifa,isr,iim,regs,IA64_BREAK_VECTOR);
   8.182 @@ -835,8 +753,7 @@ ia64_handle_reflection (unsigned long if
   8.183  	unsigned long itir = vcpu_get_itir_on_fault(ed,ifa);
   8.184  
   8.185  	if (!(psr & IA64_PSR_CPL)) {
   8.186 -		printf("ia64_handle_reflection: reflecting with priv=0!!\n");
   8.187 -		while(1);
   8.188 +		printk("ia64_handle_reflection: reflecting with priv=0!!\n");
   8.189  	}
   8.190  	// FIXME: no need to pass itir in to this routine as we need to
   8.191  	// compute the virtual itir anyway (based on domain's RR.ps)
     9.1 --- a/xen/arch/ia64/regionreg.c	Thu Mar 24 11:04:24 2005 +0000
     9.2 +++ b/xen/arch/ia64/regionreg.c	Thu Mar 24 16:49:14 2005 +0000
     9.3 @@ -262,7 +262,12 @@ int set_one_rr(unsigned long rr, unsigne
     9.4  	newrrv.rrval = 0;
     9.5  	newrid = ed->domain->starting_rid + rrv.rid;
     9.6  
     9.7 -	if (newrid > ed->domain->ending_rid) return 0;
     9.8 +	if (newrid > ed->domain->ending_rid) {
     9.9 +		printk("can't set rr%d to %lx, starting_rid=%lx,"
    9.10 +			"ending_rid=%lx, val=%lx\n", rreg, newrid,
    9.11 +			ed->domain->starting_rid,ed->domain->ending_rid,val);
    9.12 +		return 0;
    9.13 +	}
    9.14  
    9.15  	memrrv.rrval = rrv.rrval;
    9.16  	if (rreg == 7) {
    9.17 @@ -335,21 +340,21 @@ if (!ed->vcpu_info) { printf("Stopping i
    9.18  
    9.19  /* XEN/ia64 INTERNAL ROUTINES */
    9.20  
    9.21 -unsigned long physicalize_rid(struct exec_domain *ed, unsigned long rid)
    9.22 +unsigned long physicalize_rid(struct exec_domain *ed, unsigned long rrval)
    9.23  {
    9.24  	ia64_rr rrv;
    9.25  	    
    9.26 -	rrv.rrval = rid;
    9.27 +	rrv.rrval = rrval;
    9.28  	rrv.rid += ed->domain->starting_rid;
    9.29  	return rrv.rrval;
    9.30  }
    9.31  
    9.32  unsigned long
    9.33 -virtualize_rid(struct exec_domain *ed, unsigned long rid)
    9.34 +virtualize_rid(struct exec_domain *ed, unsigned long rrval)
    9.35  {
    9.36  	ia64_rr rrv;
    9.37  	    
    9.38 -	rrv.rrval = rid;
    9.39 +	rrv.rrval = rrval;
    9.40  	rrv.rid -= ed->domain->starting_rid;
    9.41  	return rrv.rrval;
    9.42  }
    9.43 @@ -365,6 +370,7 @@ unsigned long load_region_regs(struct ex
    9.44  {
    9.45  	unsigned long rr0, rr1,rr2, rr3, rr4, rr5, rr6, rr7;
    9.46  	// TODO: These probably should be validated
    9.47 +	unsigned long bad = 0;
    9.48  
    9.49  	if (ed->vcpu_info->arch.metaphysical_mode) {
    9.50  		ia64_rr rrv;
    9.51 @@ -373,35 +379,29 @@ unsigned long load_region_regs(struct ex
    9.52  		rrv.rid = ed->domain->metaphysical_rid;
    9.53  		rrv.ps = PAGE_SHIFT;
    9.54  		rrv.ve = 1;
    9.55 -		rr0 = rr1 = rr2 = rr3 = rr4 = rr5 = rrv.rrval;
    9.56 -		rrv.ve = 0;
    9.57 -		rr6 = rrv.rrval;
    9.58 +		rr0 = rrv.rrval;
    9.59  		set_rr_no_srlz(0x0000000000000000L, rr0);
    9.60 -		set_rr_no_srlz(0x2000000000000000L, rr1);
    9.61 -		set_rr_no_srlz(0x4000000000000000L, rr2);
    9.62 -		set_rr_no_srlz(0x6000000000000000L, rr3);
    9.63 -		set_rr_no_srlz(0x8000000000000000L, rr4);
    9.64 -		set_rr_no_srlz(0xa000000000000000L, rr5);
    9.65 -		set_rr_no_srlz(0xc000000000000000L, rr6);
    9.66 +		ia64_srlz_d();
    9.67  	}
    9.68  	else {
    9.69 -		rr0 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[0]);
    9.70 -		rr1 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[1]);
    9.71 -		rr2 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[2]);
    9.72 -		rr3 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[3]);
    9.73 -		rr4 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[4]);
    9.74 -		rr5 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[5]);
    9.75 -		rr6 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[6]);
    9.76 -		set_one_rr(0x0000000000000000L, rr0);
    9.77 -		set_one_rr(0x2000000000000000L, rr1);
    9.78 -		set_one_rr(0x4000000000000000L, rr2);
    9.79 -		set_one_rr(0x6000000000000000L, rr3);
    9.80 -		set_one_rr(0x8000000000000000L, rr4);
    9.81 -		set_one_rr(0xa000000000000000L, rr5);
    9.82 -		set_one_rr(0xc000000000000000L, rr6);
    9.83 -		ia64_srlz_d();
    9.84 +		rr0 =  ed->vcpu_info->arch.rrs[0];
    9.85 +		if (!set_one_rr(0x0000000000000000L, rr0)) bad |= 1;
    9.86  	}
    9.87 -	rr7 = physicalize_rid(ed, ed->vcpu_info->arch.rrs[7]);
    9.88 -	set_one_rr(0xe000000000000000L, rr7);
    9.89 -	ia64_srlz_d();
    9.90 +	rr1 =  ed->vcpu_info->arch.rrs[1];
    9.91 +	rr2 =  ed->vcpu_info->arch.rrs[2];
    9.92 +	rr3 =  ed->vcpu_info->arch.rrs[3];
    9.93 +	rr4 =  ed->vcpu_info->arch.rrs[4];
    9.94 +	rr5 =  ed->vcpu_info->arch.rrs[5];
    9.95 +	rr6 =  ed->vcpu_info->arch.rrs[6];
    9.96 +	rr7 =  ed->vcpu_info->arch.rrs[7];
    9.97 +	if (!set_one_rr(0x2000000000000000L, rr1)) bad |= 2;
    9.98 +	if (!set_one_rr(0x4000000000000000L, rr2)) bad |= 4;
    9.99 +	if (!set_one_rr(0x6000000000000000L, rr3)) bad |= 8;
   9.100 +	if (!set_one_rr(0x8000000000000000L, rr4)) bad |= 0x10;
   9.101 +	if (!set_one_rr(0xa000000000000000L, rr5)) bad |= 0x20;
   9.102 +	if (!set_one_rr(0xc000000000000000L, rr6)) bad |= 0x40;
   9.103 +	if (!set_one_rr(0xe000000000000000L, rr7)) bad |= 0x80;
   9.104 +	if (bad) {
   9.105 +		panic_domain(0,"load_region_regs: can't set! bad=%lx\n",bad);
   9.106 +	}
   9.107  }
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/xen/arch/ia64/tools/README.xenia64linux	Thu Mar 24 16:49:14 2005 +0000
    10.3 @@ -0,0 +1,50 @@
    10.4 +INSTRUCTIONS FOR BUILDING XENLINUX/IA64
    10.5 +
    10.6 +1) In linux-2.6.9: (also tested with 2.6.10, 2.6.11.2)
    10.7 +	cp arch/ia64/configs/zx1_defconfig .config
    10.8 +2) vi .config
    10.9 +	unset CONFIG_IA32_SUPPORT
   10.10 +	unset CONFIG_IDE [for now, need to fix later]
   10.11 +	unset CONFIG_VIRTUAL_MEM_MAP [for now, need to fix later]
   10.12 +	set CONFIG_DISABLE_VHPT
   10.13 +3) if running on ski, it is useful to make the following change:
   10.14 +   a) at the beginning of drivers/acpi/motherboard.c:acpi_reserve_resources()
   10.15 +      add the line:
   10.16 +	if (!acpi_gbl_FADT) return;
   10.17 +4) Build linux.
   10.18 +   a) yes "" | make oldconfig
   10.19 +   b) check the resulting .config to ensure there are no modules used (because
   10.20 +      Xen/ia64 doesn't support them yet).  Change '=m' to '=n' and remake
   10.21 +   c) yes "" | make oldconfig
   10.22 +   d) make
   10.23 +5) Linux must be "privified" to run on Xen/ia64.  This process converts all
   10.24 +   privilege-sensitive instructions into privileged instructions.
   10.25 +	Usage: privify infile outfile
   10.26 +   Privify is very dumb... it will not overwrite outfile.  It also prints
   10.27 +   out a bunch of useless info that can be safely ignored (except for "panic").
   10.28 +   The privify program can be obtained from:
   10.29 +	ftp://ftp.hpl.hp.com/pub/xen-ia64/privify
   10.30 +6) debug fixes:
   10.31 +   a) periodically xenlinux/ia64 goes into a fit of printing
   10.32 +      "Oops: timer tick before it is due..."  This can be changed
   10.33 +      in arch/ia64/kernel/time.c to either ignore it or print something
   10.34 +      shorter
   10.35 +   b) The hp simulator (ski) console drivers can be turned on to allow
   10.36 +      output of early boot information from xenlinux.  This results
   10.37 +      in some duplication of later output (which can be ignored).
   10.38 +      i) in linux/arch/ia64/Makefile, force the sim drivers by changing
   10.39 +		drivers-$(CONFIG_IA64_HP_SIM) += arch/ia64/hp/sim to
   10.40 +		drivers-y += arch/ia64/hp/sim
   10.41 +      ii) in linux/arch/ia64/hp/sim/Makefile, force the sim drivers
   10.42 +	  by changing obj-$(CONFIG_HP_SIMSERIAL) to obj-y and
   10.43 +          obj-$(CONFIG_HP_SIM_SERIAL_CONSOLE) to obj-y
   10.44 +      iii) in arch/ia64/kernel/setup.c:early_console_setup(), replace
   10.45 +           the contents of the routine with:
   10.46 +		extern struct console hpsim_cons;
   10.47 +		register_console(&hpsim_cons);
   10.48 +		return 0;
   10.49 +           (It may be necessary also to un-inline the routine, not sure.)
   10.50 +   c) It can be useful to modify linux/init/main.c to add a printf before
   10.51 +      or after a lot of the init calls
   10.52 +6) NOTE: mca currently has a problem with binary translation,
   10.53 +   must run with "nomca" as a kernel argument
    11.1 --- a/xen/arch/ia64/vcpu.c	Thu Mar 24 11:04:24 2005 +0000
    11.2 +++ b/xen/arch/ia64/vcpu.c	Thu Mar 24 16:49:14 2005 +0000
    11.3 @@ -511,6 +511,13 @@ void vcpu_pend_interrupt(VCPU *vcpu, UIN
    11.4  	set_bit(vector,PSCB(vcpu,irr));
    11.5  }
    11.6  
    11.7 +void early_tick(VCPU *vcpu)
    11.8 +{
    11.9 +	UINT64 *p = &PSCB(vcpu,irr[3]);
   11.10 +	printf("vcpu_check_pending: about to deliver early tick\n");
   11.11 +	printf("&irr[0]=%p, irr[0]=0x%lx\n",p,*p);
   11.12 +}
   11.13 +
   11.14  #define	IA64_TPR_MMI	0x10000
   11.15  #define	IA64_TPR_MIC	0x000f0
   11.16  
   11.17 @@ -563,6 +570,14 @@ UINT64 vcpu_check_pending_interrupts(VCP
   11.18  	}
   11.19  
   11.20  //printf("returned to caller\n");
   11.21 +#if 0
   11.22 +if (vector == (PSCB(vcpu,itv) & 0xff)) {
   11.23 +	UINT64 now = ia64_get_itc();
   11.24 +	UINT64 itm = PSCB(vcpu,domain_itm);
   11.25 +	if (now < itm) early_tick(vcpu);
   11.26 +	
   11.27 +}
   11.28 +#endif
   11.29  	return vector;
   11.30  }
   11.31  
   11.32 @@ -572,6 +587,12 @@ UINT64 vcpu_deliverable_interrupts(VCPU 
   11.33  		vcpu_check_pending_interrupts(vcpu) != SPURIOUS_VECTOR);
   11.34  }
   11.35  
   11.36 +UINT64 vcpu_deliverable_timer(VCPU *vcpu)
   11.37 +{
   11.38 +	return (vcpu_get_psr_i(vcpu) &&
   11.39 +		vcpu_check_pending_interrupts(vcpu) == PSCB(vcpu,itv));
   11.40 +}
   11.41 +
   11.42  IA64FAULT vcpu_get_lid(VCPU *vcpu, UINT64 *pval)
   11.43  {
   11.44  extern unsigned long privop_trace;
   11.45 @@ -618,6 +639,10 @@ IA64FAULT vcpu_get_ivr(VCPU *vcpu, UINT6
   11.46  	PSCB(vcpu,irr[i]) &= ~mask;
   11.47  	PSCB(vcpu,pending_interruption)--;
   11.48  	*pval = vector;
   11.49 +	// if delivering a timer interrupt, remember domain_itm
   11.50 +	if (vector == (PSCB(vcpu,itv) & 0xff)) {
   11.51 +		PSCB(vcpu,domain_itm_last) = PSCB(vcpu,domain_itm);
   11.52 +	}
   11.53  	return IA64_NO_FAULT;
   11.54  }
   11.55  
   11.56 @@ -809,14 +834,21 @@ BOOLEAN vcpu_timer_disabled(VCPU *vcpu)
   11.57  	return(!itv || !!(itv & 0x10000));
   11.58  }
   11.59  
   11.60 +BOOLEAN vcpu_timer_inservice(VCPU *vcpu)
   11.61 +{
   11.62 +	UINT64 itv = PSCB(vcpu,itv);
   11.63 +	return (test_bit(itv, PSCB(vcpu,insvc)));
   11.64 +}
   11.65 +
   11.66  BOOLEAN vcpu_timer_expired(VCPU *vcpu)
   11.67  {
   11.68  	unsigned long domain_itm = PSCB(vcpu,domain_itm);
   11.69  	unsigned long now = ia64_get_itc();
   11.70   
   11.71 -	if (domain_itm && (now > domain_itm) &&
   11.72 -		!vcpu_timer_disabled(vcpu)) return TRUE;
   11.73 -	return FALSE;
   11.74 +	if (!domain_itm) return FALSE;
   11.75 +	if (now < domain_itm) return FALSE;
   11.76 +	if (vcpu_timer_disabled(vcpu)) return FALSE;
   11.77 +	return TRUE;
   11.78  }
   11.79  
   11.80  void vcpu_safe_set_itm(unsigned long val)
   11.81 @@ -950,9 +982,34 @@ void vcpu_pend_timer(VCPU *vcpu)
   11.82  	UINT64 itv = PSCB(vcpu,itv) & 0xff;
   11.83  
   11.84  	if (vcpu_timer_disabled(vcpu)) return;
   11.85 +	//if (vcpu_timer_inservice(vcpu)) return;
   11.86 +	if (PSCB(vcpu,domain_itm_last) == PSCB(vcpu,domain_itm)) {
   11.87 +		// already delivered an interrupt for this so
   11.88 +		// don't deliver another
   11.89 +		return;
   11.90 +	}
   11.91 +#if 0
   11.92 +	// attempt to flag "timer tick before its due" source
   11.93 +	{
   11.94 +	UINT64 itm = PSCB(vcpu,domain_itm);
   11.95 +	UINT64 now = ia64_get_itc();
   11.96 +	if (now < itm) printf("******* vcpu_pend_timer: pending before due!\n");
   11.97 +	}
   11.98 +#endif
   11.99  	vcpu_pend_interrupt(vcpu, itv);
  11.100  }
  11.101  
  11.102 +// returns true if ready to deliver a timer interrupt too early
  11.103 +UINT64 vcpu_timer_pending_early(VCPU *vcpu)
  11.104 +{
  11.105 +	UINT64 now = ia64_get_itc();
  11.106 +	UINT64 itm = PSCB(vcpu,domain_itm);
  11.107 +
  11.108 +	if (vcpu_timer_disabled(vcpu)) return 0;
  11.109 +	if (!itm) return 0;
  11.110 +	return (vcpu_deliverable_timer(vcpu) && (now < itm));
  11.111 +}
  11.112 +
  11.113  //FIXME: This is a hack because everything dies if a timer tick is lost
  11.114  void vcpu_poke_timer(VCPU *vcpu)
  11.115  {
  11.116 @@ -974,7 +1031,7 @@ void vcpu_poke_timer(VCPU *vcpu)
  11.117  			if (irr & (1L<<(0xef-0xc0))) return;
  11.118  if (now-itm>0x800000)
  11.119  printf("*** poking timer: now=%lx,vitm=%lx,xitm=%lx,itm=%lx\n",now,itm,local_cpu_data->itm_next,ia64_get_itm());
  11.120 -			vcpu_pend_interrupt(vcpu, 0xefL);
  11.121 +			vcpu_pend_timer(vcpu);
  11.122  		}
  11.123  	}
  11.124  }
  11.125 @@ -1046,6 +1103,7 @@ while(1);
  11.126  
  11.127  IA64FAULT vcpu_cover(VCPU *vcpu)
  11.128  {
  11.129 +	// TODO: Only allowed for current vcpu
  11.130  	REGS *regs = vcpu_regs(vcpu);
  11.131  
  11.132  	if (!PSCB(vcpu,interrupt_collection_enabled)) {
  11.133 @@ -1204,6 +1262,7 @@ IA64FAULT vcpu_get_pmd(VCPU *vcpu, UINT6
  11.134  
  11.135  IA64FAULT vcpu_bsw0(VCPU *vcpu)
  11.136  {
  11.137 +	// TODO: Only allowed for current vcpu
  11.138  	REGS *regs = vcpu_regs(vcpu);
  11.139  	unsigned long *r = &regs->r16;
  11.140  	unsigned long *b0 = &PSCB(vcpu,bank0_regs[0]);
  11.141 @@ -1219,6 +1278,7 @@ IA64FAULT vcpu_bsw0(VCPU *vcpu)
  11.142  
  11.143  IA64FAULT vcpu_bsw1(VCPU *vcpu)
  11.144  {
  11.145 +	// TODO: Only allowed for current vcpu
  11.146  	REGS *regs = vcpu_regs(vcpu);
  11.147  	unsigned long *r = &regs->r16;
  11.148  	unsigned long *b0 = &PSCB(vcpu,bank0_regs[0]);
  11.149 @@ -1510,6 +1570,7 @@ IA64FAULT vcpu_ptc_l(VCPU *vcpu, UINT64 
  11.150  // on the physical address, which is guaranteed to flush the same cache line
  11.151  IA64FAULT vcpu_fc(VCPU *vcpu, UINT64 vadr)
  11.152  {
  11.153 +	// TODO: Only allowed for current vcpu
  11.154  	UINT64 mpaddr, ps;
  11.155  	IA64FAULT fault;
  11.156  	unsigned long match_dtlb(VCPU *, unsigned long, unsigned long *, unsigned long *);
    12.1 --- a/xen/arch/ia64/xenasm.S	Thu Mar 24 11:04:24 2005 +0000
    12.2 +++ b/xen/arch/ia64/xenasm.S	Thu Mar 24 16:49:14 2005 +0000
    12.3 @@ -261,24 +261,6 @@ GLOBAL_ENTRY(ia64_prepare_handle_reflect
    12.4  	br.cond.sptk.many rp			// goes to ia64_leave_kernel
    12.5  END(ia64_prepare_handle_reflection)
    12.6  
    12.7 -#ifndef USER_ACCESS
    12.8 -// REMOVE: replaced with get_user
    12.9 -// NOTE: instruction spacing must be explicit for recovery on miss
   12.10 -GLOBAL_ENTRY(__get_domain_bundle)
   12.11 -	ld8 r8=[r32],8
   12.12 -	nop 0
   12.13 -	nop 0
   12.14 -	;;
   12.15 -	ld8 r9=[r32]
   12.16 -	nop 0
   12.17 -	nop 0
   12.18 -	;;
   12.19 -	br.ret.sptk.many rp
   12.20 -	nop 0
   12.21 -	nop 0
   12.22 -	;;
   12.23 -END(__get_domain_bundle)
   12.24 -#else
   12.25  GLOBAL_ENTRY(__get_domain_bundle)
   12.26  	EX(.failure_in_get_bundle,ld8 r8=[r32],8)
   12.27  	;;
   12.28 @@ -294,7 +276,6 @@ GLOBAL_ENTRY(__get_domain_bundle)
   12.29  	br.ret.sptk.many rp
   12.30  	;;
   12.31  END(__get_domain_bundle)
   12.32 -#endif
   12.33  
   12.34  GLOBAL_ENTRY(dorfirfi)
   12.35  #define SI_CR_IIP_OFFSET 0x10
    13.1 --- a/xen/arch/ia64/xenmisc.c	Thu Mar 24 11:04:24 2005 +0000
    13.2 +++ b/xen/arch/ia64/xenmisc.c	Thu Mar 24 16:49:14 2005 +0000
    13.3 @@ -203,7 +203,7 @@ char * __devinit  pcibios_setup(char *st
    13.4  
    13.5  void show_registers(struct pt_regs *regs)
    13.6  {
    13.7 -	dummy();
    13.8 +	printf("*** ADD REGISTER DUMP HERE FOR DEBUGGING\n");
    13.9  }	
   13.10  
   13.11  ///////////////////////////////
   13.12 @@ -240,12 +240,43 @@ void *module_text_address(unsigned long 
   13.13  	return NULL;
   13.14  }
   13.15  
   13.16 +void cs10foo(void) {}
   13.17 +void cs01foo(void) {}
   13.18 +
   13.19  // context_switch
   13.20  void context_switch(struct exec_domain *prev, struct exec_domain *next)
   13.21  {
   13.22 -	switch_to(prev,next);
   13.23 +//printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
   13.24 +//printk("@@@@@@ context switch from domain %d (%x) to domain %d (%x)\n",
   13.25 +//prev->domain->id,(long)prev&0xffffff,next->domain->id,(long)next&0xffffff);
   13.26 +//printk("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
   13.27 +//if (prev->domain->id == 1 && next->domain->id == 0) cs10foo();
   13.28 +//if (prev->domain->id == 0 && next->domain->id == 1) cs01foo();
   13.29 +	switch_to(prev,next,prev);
   13.30  	clear_bit(EDF_RUNNING, &prev->ed_flags);
   13.31  	//if (!is_idle_task(next->domain) )
   13.32  		//send_guest_virq(next, VIRQ_TIMER);
   13.33 -	schedule_tail(next);
   13.34 +	load_region_regs(current);
   13.35 +	if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
   13.36  }
   13.37 +
   13.38 +void panic_domain(struct pt_regs *regs, const char *fmt, ...)
   13.39 +{
   13.40 +	va_list args;
   13.41 +	char buf[128];
   13.42 +	struct exec_domain *ed = current;
   13.43 +	static volatile int test = 1;	// so can continue easily in debug
   13.44 +	extern spinlock_t console_lock;
   13.45 +	unsigned long flags;
   13.46 +    
   13.47 +	printf("$$$$$ PANIC in domain %d (k6=%p): ",
   13.48 +		ed->domain->id, ia64_get_kr(IA64_KR_CURRENT));
   13.49 +	va_start(args, fmt);
   13.50 +	(void)vsnprintf(buf, sizeof(buf), fmt, args);
   13.51 +	va_end(args);
   13.52 +	printf(buf);
   13.53 +	if (regs) show_registers(regs);
   13.54 +	domain_pause_by_systemcontroller(current->domain);
   13.55 +	set_bit(DF_CRASHED, ed->domain->d_flags);
   13.56 +	//while(test);
   13.57 +}
    14.1 --- a/xen/arch/ia64/xensetup.c	Thu Mar 24 11:04:24 2005 +0000
    14.2 +++ b/xen/arch/ia64/xensetup.c	Thu Mar 24 16:49:14 2005 +0000
    14.3 @@ -362,9 +362,11 @@ printk("About to call construct_dom0()\n
    14.4  #ifdef CLONE_DOMAIN0
    14.5      {
    14.6      int i;
    14.7 +    dom0_memory_start = __va(ia64_boot_param->initrd_start);
    14.8 +    dom0_memory_end = ia64_boot_param->initrd_size;
    14.9      for (i = 0; i < CLONE_DOMAIN0; i++) {
   14.10  printk("CONSTRUCTING DOMAIN0 CLONE #%d\n",i+1);
   14.11 -        if ( construct_dom0(clones[i], dom0_memory_start, dom0_memory_end,
   14.12 +        if ( construct_domN(clones[i], dom0_memory_start, dom0_memory_end,
   14.13                          0, 
   14.14                          0,
   14.15  			0) != 0)
   14.16 @@ -389,7 +391,7 @@ printk("About to call init_trace_bufs()\
   14.17      console_endboot(cmdline && strstr(cmdline, "tty0"));
   14.18  #endif
   14.19  
   14.20 -    domain_unpause_by_systemcontroller(current);
   14.21 +    domain_unpause_by_systemcontroller(current->domain);
   14.22  #ifdef CLONE_DOMAIN0
   14.23      {
   14.24      int i;
    15.1 --- a/xen/drivers/char/console.c	Thu Mar 24 11:04:24 2005 +0000
    15.2 +++ b/xen/drivers/char/console.c	Thu Mar 24 16:49:14 2005 +0000
    15.3 @@ -645,3 +645,4 @@ void __out_of_line_bug(int line)
    15.4   * indent-tabs-mode: nil
    15.5   * End:
    15.6   */
    15.7 +
    16.1 --- a/xen/include/asm-ia64/config.h	Thu Mar 24 11:04:24 2005 +0000
    16.2 +++ b/xen/include/asm-ia64/config.h	Thu Mar 24 16:49:14 2005 +0000
    16.3 @@ -1,8 +1,6 @@
    16.4  // control flags for turning on/off features under test
    16.5  #undef CLONE_DOMAIN0
    16.6 -//#define CLONE_DOMAIN0 1
    16.7 -//#undef CLONE_DOMAIN0
    16.8 -#define USER_ACCESS
    16.9 +//#define CLONE_DOMAIN0 5
   16.10  
   16.11  // manufactured from component pieces
   16.12  
    17.1 --- a/xen/include/public/arch-ia64.h	Thu Mar 24 11:04:24 2005 +0000
    17.2 +++ b/xen/include/public/arch-ia64.h	Thu Mar 24 16:49:14 2005 +0000
    17.3 @@ -78,7 +78,7 @@ typedef struct {
    17.4  	unsigned long dcr;
    17.5  	unsigned long itc;
    17.6  	unsigned long domain_itm;
    17.7 -	unsigned long domain_timer_interval;
    17.8 +	unsigned long domain_itm_last;
    17.9  	unsigned long xen_itm;
   17.10  	unsigned long xen_timer_interval;
   17.11  //} PACKED arch_shared_info_t;