direct-io.hg

changeset 5447:dce7deb4c508

bitkeeper revision 1.1709.1.3 (42ae02a99ck6N11hVBch3RRAXKHWgw)

Various fixes for multi-domain prep

Signed-off-by: Matthew Chapman <matthewc@hp.com>
author djm@sportsman.spdomain
date Mon Jun 13 22:03:21 2005 +0000 (2005-06-13)
parents 01a9f1e50dd8
children a8d6aae1c5ac
files .rootkeys xen/arch/ia64/dom0_ops.c xen/arch/ia64/domain.c xen/arch/ia64/hypercall.c xen/arch/ia64/patch/linux-2.6.11/uaccess.h xen/arch/ia64/tools/mkbuildtree xen/arch/ia64/vcpu.c xen/arch/ia64/xenmisc.c xen/include/asm-ia64/config.h xen/include/asm-ia64/domain.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/.rootkeys	Mon Jun 13 20:50:16 2005 +0000
     1.2 +++ b/.rootkeys	Mon Jun 13 22:03:21 2005 +0000
     1.3 @@ -1140,6 +1140,7 @@ 425ae516p4ICTkjqNYEfYFxqULj4dw xen/arch/
     1.4  425ae516juUB257qrwUdsL9AsswrqQ xen/arch/ia64/patch/linux-2.6.11/time.c
     1.5  425ae5167zQn7zYcgKtDUDX2v-e8mw xen/arch/ia64/patch/linux-2.6.11/tlb.c
     1.6  425ae5162bIl2Dgd19x-FceB4L9oGw xen/arch/ia64/patch/linux-2.6.11/types.h
     1.7 +42ae01f01KDfSgVQnscwJ0psRmEaCw xen/arch/ia64/patch/linux-2.6.11/uaccess.h
     1.8  425ae516cFUNY2jHD46bujcF5NJheA xen/arch/ia64/patch/linux-2.6.11/unaligned.c
     1.9  421098b39QFMC-1t1r38CA7NxAYBPA xen/arch/ia64/patch/linux-2.6.7/bootmem.h
    1.10  421098b3SIA1vZX9fFUjo1T3o_jMCQ xen/arch/ia64/patch/linux-2.6.7/current.h
     2.1 --- a/xen/arch/ia64/dom0_ops.c	Mon Jun 13 20:50:16 2005 +0000
     2.2 +++ b/xen/arch/ia64/dom0_ops.c	Mon Jun 13 22:03:21 2005 +0000
     2.3 @@ -18,14 +18,6 @@
     2.4  #include <xen/console.h>
     2.5  #include <public/sched_ctl.h>
     2.6  
     2.7 -#define TRC_DOM0OP_ENTER_BASE  0x00020000
     2.8 -#define TRC_DOM0OP_LEAVE_BASE  0x00030000
     2.9 -
    2.10 -static int msr_cpu_mask;
    2.11 -static unsigned long msr_addr;
    2.12 -static unsigned long msr_lo;
    2.13 -static unsigned long msr_hi;
    2.14 -
    2.15  long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
    2.16  {
    2.17      long ret = 0;
    2.18 @@ -35,6 +27,49 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
    2.19  
    2.20      switch ( op->cmd )
    2.21      {
    2.22 +    /*
    2.23 +     * NOTE: DOM0_GETMEMLIST has somewhat different semantics on IA64 -
    2.24 +     * it actually allocates and maps pages.
    2.25 +     */
    2.26 +    case DOM0_GETMEMLIST:
    2.27 +    {
    2.28 +        unsigned long i;
    2.29 +        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
    2.30 +        unsigned long start_page = op->u.getmemlist.max_pfns >> 32;
    2.31 +        unsigned long nr_pages = op->u.getmemlist.max_pfns & 0xffffffff;
    2.32 +        unsigned long pfn;
    2.33 +        unsigned long *buffer = op->u.getmemlist.buffer;
    2.34 +        struct page *page;
    2.35 +
    2.36 +        ret = -EINVAL;
    2.37 +        if ( d != NULL )
    2.38 +        {
    2.39 +            ret = 0;
    2.40 +
    2.41 +            for ( i = start_page; i < (start_page + nr_pages); i++ )
    2.42 +            {
    2.43 +                page = map_new_domain_page(d, i << PAGE_SHIFT);
    2.44 +                if ( page == NULL )
    2.45 +                {
    2.46 +                    ret = -ENOMEM;
    2.47 +                    break;
    2.48 +                }
    2.49 +                pfn = page_to_pfn(page);
    2.50 +                if ( put_user(pfn, buffer) )
    2.51 +                {
    2.52 +                    ret = -EFAULT;
    2.53 +                    break;
    2.54 +                }
    2.55 +                buffer++;
    2.56 +            }
    2.57 +
    2.58 +            op->u.getmemlist.num_pfns = i - start_page;
    2.59 +            copy_to_user(u_dom0_op, op, sizeof(*op));
    2.60 +            
    2.61 +            put_domain(d);
    2.62 +        }
    2.63 +    }
    2.64 +    break;
    2.65  
    2.66      default:
    2.67          ret = -ENOSYS;
    2.68 @@ -43,10 +78,3 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
    2.69  
    2.70      return ret;
    2.71  }
    2.72 -
    2.73 -void arch_getdomaininfo_ctxt(struct domain *d, struct vcpu_guest_context *c)
    2.74 -{ 
    2.75 -    int i;
    2.76 -
    2.77 -	dummy();
    2.78 -}
     3.1 --- a/xen/arch/ia64/domain.c	Mon Jun 13 20:50:16 2005 +0000
     3.2 +++ b/xen/arch/ia64/domain.c	Mon Jun 13 22:03:21 2005 +0000
     3.3 @@ -76,7 +76,7 @@ extern unsigned long dom_fw_setup(struct
     3.4  /* this belongs in include/asm, but there doesn't seem to be a suitable place */
     3.5  void free_perdomain_pt(struct domain *d)
     3.6  {
     3.7 -	dummy();
     3.8 +	printf("free_perdomain_pt: not implemented\n");
     3.9  	//free_page((unsigned long)d->mm.perdomain_pt);
    3.10  }
    3.11  
    3.12 @@ -166,12 +166,34 @@ void arch_free_vcpu_struct(struct vcpu *
    3.13  	free_xenheap_pages(v, KERNEL_STACK_SIZE_ORDER);
    3.14  }
    3.15  
    3.16 +static void init_switch_stack(struct vcpu *v)
    3.17 +{
    3.18 +	struct pt_regs *regs = (struct pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
    3.19 +	struct switch_stack *sw = (struct switch_stack *) regs - 1;
    3.20 +	extern void ia64_ret_from_clone;
    3.21 +
    3.22 +	memset(sw, 0, sizeof(struct switch_stack) + sizeof(struct pt_regs));
    3.23 +	sw->ar_bspstore = (unsigned long)v + IA64_RBS_OFFSET;
    3.24 +	sw->b0 = (unsigned long) &ia64_ret_from_clone;
    3.25 +	sw->ar_fpsr = FPSR_DEFAULT;
    3.26 +	v->arch._thread.ksp = (unsigned long) sw - 16;
    3.27 +	// stay on kernel stack because may get interrupts!
    3.28 +	// ia64_ret_from_clone (which b0 gets in new_thread) switches
    3.29 +	// to user stack
    3.30 +	v->arch._thread.on_ustack = 0;
    3.31 +	memset(v->arch._thread.fph,0,sizeof(struct ia64_fpreg)*96);
    3.32 +}
    3.33 +
    3.34  #ifdef CONFIG_VTI
    3.35  void arch_do_createdomain(struct vcpu *v)
    3.36  {
    3.37  	struct domain *d = v->domain;
    3.38  	struct thread_info *ti = alloc_thread_info(v);
    3.39  
    3.40 +	/* Clear thread_info to clear some important fields, like preempt_count */
    3.41 +	memset(ti, 0, sizeof(struct thread_info));
    3.42 +	init_switch_stack(v);
    3.43 +
    3.44  	/* If domain is VMX domain, shared info area is created
    3.45  	 * by domain and then domain notifies HV by specific hypercall.
    3.46  	 * If domain is xenolinux, shared info area is created by
    3.47 @@ -194,9 +216,6 @@ void arch_do_createdomain(struct vcpu *v
    3.48  	}
    3.49  	memset(v->vcpu_info, 0, PAGE_SIZE);
    3.50  
    3.51 -	/* Clear thread_info to clear some important fields, like preempt_count */
    3.52 -	memset(ti, 0, sizeof(struct thread_info));
    3.53 -
    3.54  	/* Allocate per-domain vTLB and vhpt */
    3.55  	v->arch.vtlb = init_domain_tlb(v);
    3.56  
    3.57 @@ -212,37 +231,37 @@ void arch_do_createdomain(struct vcpu *v
    3.58  	d->xen_vaend = 0xf300000000000000;
    3.59  	d->arch.breakimm = 0x1000;
    3.60  
    3.61 -	// stay on kernel stack because may get interrupts!
    3.62 -	// ia64_ret_from_clone (which b0 gets in new_thread) switches
    3.63 -	// to user stack
    3.64 -	v->arch._thread.on_ustack = 0;
    3.65 +	d->arch.mm = xmalloc(struct mm_struct);
    3.66 +	if (unlikely(!d->arch.mm)) {
    3.67 +		printk("Can't allocate mm_struct for domain %d\n",d->domain_id);
    3.68 +		return -ENOMEM;
    3.69 +	}
    3.70 +	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
    3.71 +	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
    3.72 +	if (unlikely(!d->arch.mm->pgd)) {
    3.73 +		printk("Can't allocate pgd for domain %d\n",d->domain_id);
    3.74 +		return -ENOMEM;
    3.75 +	}
    3.76 +}
    3.77  }
    3.78  #else // CONFIG_VTI
    3.79  void arch_do_createdomain(struct vcpu *v)
    3.80  {
    3.81  	struct domain *d = v->domain;
    3.82 +	struct thread_info *ti = alloc_thread_info(v);
    3.83 +
    3.84 +	/* Clear thread_info to clear some important fields, like preempt_count */
    3.85 +	memset(ti, 0, sizeof(struct thread_info));
    3.86 +	init_switch_stack(v);
    3.87  
    3.88  	d->shared_info = (void *)alloc_xenheap_page();
    3.89 -	v->vcpu_info = (void *)alloc_xenheap_page();
    3.90 -	if (!v->vcpu_info) {
    3.91 +	if (!d->shared_info) {
    3.92     		printk("ERROR/HALTING: CAN'T ALLOC PAGE\n");
    3.93     		while (1);
    3.94  	}
    3.95 -	memset(v->vcpu_info, 0, PAGE_SIZE);
    3.96 -	/* pin mapping */
    3.97 -	// FIXME: Does this belong here?  Or do only at domain switch time?
    3.98 -#if 0
    3.99 -	// this is now done in ia64_new_rr7
   3.100 -	{
   3.101 -		/* WARNING: following must be inlined to avoid nested fault */
   3.102 -		unsigned long psr = ia64_clear_ic();
   3.103 -		ia64_itr(0x2, IA64_TR_SHARED_INFO, SHAREDINFO_ADDR,
   3.104 -		 pte_val(pfn_pte(ia64_tpa(d->shared_info) >> PAGE_SHIFT, PAGE_KERNEL)),
   3.105 -		 PAGE_SHIFT);
   3.106 -		ia64_set_psr(psr);
   3.107 -		ia64_srlz_i();
   3.108 -	}
   3.109 -#endif
   3.110 +	memset(d->shared_info, 0, PAGE_SIZE);
   3.111 +	v->vcpu_info = &(d->shared_info->vcpu_data[0]);
   3.112 +
   3.113  	d->max_pages = (128*1024*1024)/PAGE_SIZE; // 128MB default // FIXME
   3.114  	if ((d->arch.metaphysical_rr0 = allocate_metaphysical_rr0()) == -1UL)
   3.115  		BUG();
   3.116 @@ -258,33 +277,63 @@ void arch_do_createdomain(struct vcpu *v
   3.117  	d->shared_info_va = 0xf100000000000000;
   3.118  	d->arch.breakimm = 0x1000;
   3.119  	v->arch.breakimm = d->arch.breakimm;
   3.120 -	// stay on kernel stack because may get interrupts!
   3.121 -	// ia64_ret_from_clone (which b0 gets in new_thread) switches
   3.122 -	// to user stack
   3.123 -	v->arch._thread.on_ustack = 0;
   3.124 +
   3.125 +	d->arch.mm = xmalloc(struct mm_struct);
   3.126 +	if (unlikely(!d->arch.mm)) {
   3.127 +		printk("Can't allocate mm_struct for domain %d\n",d->domain_id);
   3.128 +		return -ENOMEM;
   3.129 +	}
   3.130 +	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   3.131 +	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   3.132 +	if (unlikely(!d->arch.mm->pgd)) {
   3.133 +		printk("Can't allocate pgd for domain %d\n",d->domain_id);
   3.134 +		return -ENOMEM;
   3.135 +	}
   3.136  }
   3.137  #endif // CONFIG_VTI
   3.138  
   3.139 -void arch_do_boot_vcpu(struct vcpu *v)
   3.140 +void arch_getdomaininfo_ctxt(struct vcpu *v, struct vcpu_guest_context *c)
   3.141  {
   3.142 -	return;
   3.143 +	struct pt_regs *regs = (struct pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
   3.144 +
   3.145 +	printf("arch_getdomaininfo_ctxt\n");
   3.146 +	c->regs = *regs;
   3.147 +	c->vcpu = v->vcpu_info->arch;
   3.148 +	c->shared = v->domain->shared_info->arch;
   3.149  }
   3.150  
   3.151  int arch_set_info_guest(struct vcpu *v, struct vcpu_guest_context *c)
   3.152  {
   3.153 -	dummy();
   3.154 -	return 1;
   3.155 +	struct pt_regs *regs = (struct pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
   3.156 +
   3.157 +	printf("arch_set_info_guest\n");
   3.158 +	*regs = c->regs;
   3.159 +	regs->cr_ipsr = IA64_PSR_IT|IA64_PSR_DT|IA64_PSR_RT|IA64_PSR_IC|IA64_PSR_I|IA64_PSR_DFH|IA64_PSR_BN|IA64_PSR_SP|IA64_PSR_DI;
   3.160 +	regs->cr_ipsr |= 2UL << IA64_PSR_CPL0_BIT;
   3.161 +	regs->ar_rsc |= (2 << 2); /* force PL2/3 */
   3.162 +
   3.163 +	v->vcpu_info->arch = c->vcpu;
   3.164 +	init_all_rr(v);
   3.165 +
   3.166 +	// this should be in userspace
   3.167 +	regs->r28 = dom_fw_setup(v->domain,"nomca nosmp xencons=ttyS console=ttyS0",256L);  //FIXME
   3.168 +	v->vcpu_info->arch.banknum = 1;
   3.169 +	v->vcpu_info->arch.metaphysical_mode = 1;
   3.170 +
   3.171 +	v->domain->shared_info->arch = c->shared;
   3.172 +	return 0;
   3.173  }
   3.174  
   3.175 -int arch_final_setup_guest(struct vcpu *v, struct vcpu_guest_context *c)
   3.176 +void arch_do_boot_vcpu(struct vcpu *v)
   3.177  {
   3.178 -	dummy();
   3.179 -	return 1;
   3.180 +	printf("arch_do_boot_vcpu: not implemented\n");
   3.181 +	return;
   3.182  }
   3.183  
   3.184  void domain_relinquish_resources(struct domain *d)
   3.185  {
   3.186 -	dummy();
   3.187 +	/* FIXME */
   3.188 +	printf("domain_relinquish_resources: not implemented\n");
   3.189  }
   3.190  
   3.191  #ifdef CONFIG_VTI
   3.192 @@ -294,10 +343,8 @@ void new_thread(struct vcpu *v,
   3.193                  unsigned long start_info)
   3.194  {
   3.195  	struct domain *d = v->domain;
   3.196 -	struct switch_stack *sw;
   3.197  	struct xen_regs *regs;
   3.198  	struct ia64_boot_param *bp;
   3.199 -	extern char ia64_ret_from_clone;
   3.200  	extern char saved_command_line[];
   3.201  	//char *dom0_cmdline = "BOOT_IMAGE=scsi0:\EFI\redhat\xenlinux nomca root=/dev/sdb1 ro";
   3.202  
   3.203 @@ -305,11 +352,8 @@ void new_thread(struct vcpu *v,
   3.204  #ifdef CONFIG_DOMAIN0_CONTIGUOUS
   3.205  	if (d == dom0) start_pc += dom0_start;
   3.206  #endif
   3.207 -	regs = (struct xen_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
   3.208 -	sw = (struct switch_stack *) regs - 1;
   3.209 -	/* Sanity Clear */
   3.210 -	memset(sw, 0, sizeof(struct xen_regs) + sizeof(struct switch_stack));
   3.211  
   3.212 +	regs = (struct pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
   3.213  	if (VMX_DOMAIN(v)) {
   3.214  		/* dt/rt/it:1;i/ic:1, si:1, vm/bn:1, ac:1 */
   3.215  		regs->cr_ipsr = 0x501008826008; /* Need to be expanded as macro */
   3.216 @@ -320,34 +364,23 @@ void new_thread(struct vcpu *v,
   3.217  		regs->cr_ipsr |= 2UL << IA64_PSR_CPL0_BIT; // domain runs at PL2
   3.218  	}
   3.219  	regs->cr_iip = start_pc;
   3.220 -	regs->ar_rsc = 0x0;
   3.221 -	regs->cr_ifs = 0x0;
   3.222 -	regs->ar_fpsr = sw->ar_fpsr = FPSR_DEFAULT;
   3.223 -	sw->ar_bspstore = (unsigned long)v + IA64_RBS_OFFSET;
   3.224 -	printf("new_thread: v=%p, regs=%p, sw=%p, new_rbs=%p, IA64_STK_OFFSET=%p, &r8=%p\n",
   3.225 -		v,regs,sw,sw->ar_bspstore,IA64_STK_OFFSET,&regs->r8);
   3.226 -	printf("iip:0x%lx,ipsr:0x%lx\n", regs->cr_iip, regs->cr_ipsr);
   3.227 -
   3.228 -	sw->b0 = (unsigned long) &ia64_ret_from_clone;
   3.229 -	v->arch._thread.ksp = (unsigned long) sw - 16;
   3.230 -	printk("new_thread, about to call init_all_rr\n");
   3.231 -	if (VMX_DOMAIN(v)) {
   3.232 +	regs->cr_ifs = 0; /* why? - matthewc */
   3.233 +	regs->ar_fpsr = FPSR_DEFAULT;
   3.234 +	if (VMX_DOMAIN(ed)) {
   3.235  		vmx_init_all_rr(v);
   3.236  	} else
   3.237  		init_all_rr(v);
   3.238 -	// set up boot parameters (and fake firmware)
   3.239 -	printk("new_thread, about to call dom_fw_setup\n");
   3.240 +	/* should this be regs->r28 in the non-VMX case? - matthewc */
   3.241  	VMX_VPD(v,vgr[12]) = dom_fw_setup(d,saved_command_line,256L);  //FIXME
   3.242 -	printk("new_thread, done with dom_fw_setup\n");
   3.243 -
   3.244  	if (VMX_DOMAIN(v)) {
   3.245  		/* Virtual processor context setup */
   3.246  		VMX_VPD(v, vpsr) = IA64_PSR_BN;
   3.247  		VPD_CR(v, dcr) = 0;
   3.248  	} else {
   3.249 -		// don't forget to set this!
   3.250  		v->vcpu_info->arch.banknum = 1;
   3.251 +		/* v->vcpu_info->arch.metaphysical_mode = 1;  why not? - matthewc */
   3.252  	}
   3.253 +	/* d->shared_info->arch.flags = (d == dom0) ? (SIF_INITDOMAIN|SIF_PRIVILEGED|SIF_BLK_BE_DOMAIN|SIF_NET_BE_DOMAIN|SIF_USB_BE_DOMAIN) : 0;  shared_info not set yet? */
   3.254  }
   3.255  #else // CONFIG_VTI
   3.256  
   3.257 @@ -359,54 +392,27 @@ void new_thread(struct vcpu *v,
   3.258  	            unsigned long start_info)
   3.259  {
   3.260  	struct domain *d = v->domain;
   3.261 -	struct switch_stack *sw;
   3.262  	struct pt_regs *regs;
   3.263 -	unsigned long new_rbs;
   3.264  	struct ia64_boot_param *bp;
   3.265 -	extern char ia64_ret_from_clone;
   3.266  	extern char saved_command_line[];
   3.267  
   3.268  #ifdef CONFIG_DOMAIN0_CONTIGUOUS
   3.269  	if (d == dom0) start_pc += dom0_start;
   3.270  #endif
   3.271 +
   3.272  	regs = (struct pt_regs *) ((unsigned long) v + IA64_STK_OFFSET) - 1;
   3.273 -	sw = (struct switch_stack *) regs - 1;
   3.274 -	memset(sw,0,sizeof(struct switch_stack)+sizeof(struct pt_regs));
   3.275 -	new_rbs = (unsigned long) v + IA64_RBS_OFFSET;
   3.276  	regs->cr_ipsr = ia64_getreg(_IA64_REG_PSR)
   3.277  		| IA64_PSR_BITS_TO_SET | IA64_PSR_BN
   3.278  		& ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_RI | IA64_PSR_IS);
   3.279  	regs->cr_ipsr |= 2UL << IA64_PSR_CPL0_BIT; // domain runs at PL2
   3.280  	regs->cr_iip = start_pc;
   3.281 -	regs->ar_rsc = 0;		/* lazy mode */
   3.282 -	regs->ar_rnat = 0;
   3.283 -	regs->ar_fpsr = sw->ar_fpsr = FPSR_DEFAULT;
   3.284 -	regs->loadrs = 0;
   3.285 -	//regs->r8 = current->mm->dumpable; /* set "don't zap registers" flag */
   3.286 -	//regs->r8 = 0x01234567890abcdef; // FIXME: temp marker
   3.287 -	//regs->r12 = ((unsigned long) regs - 16);	/* 16 byte scratch */
   3.288  	regs->cr_ifs = 1UL << 63;
   3.289 -	regs->pr = 0;
   3.290 -	sw->pr = 0;
   3.291 -	regs->ar_pfs = 0;
   3.292 -	sw->caller_unat = 0;
   3.293 -	sw->ar_pfs = 0;
   3.294 -	sw->ar_bspstore = new_rbs;
   3.295 -	//regs->r13 = (unsigned long) v;
   3.296 -printf("new_thread: v=%p, start_pc=%p, regs=%p, sw=%p, new_rbs=%p, IA64_STK_OFFSET=%p, &r8=%p\n",
   3.297 -v,start_pc,regs,sw,new_rbs,IA64_STK_OFFSET,&regs->r8);
   3.298 -	sw->b0 = (unsigned long) &ia64_ret_from_clone;
   3.299 -	v->arch._thread.ksp = (unsigned long) sw - 16;
   3.300 -	//v->thread_info->flags = 0;
   3.301 -printk("new_thread, about to call init_all_rr\n");
   3.302 +	regs->ar_fpsr = FPSR_DEFAULT;
   3.303  	init_all_rr(v);
   3.304 -	// set up boot parameters (and fake firmware)
   3.305 -printk("new_thread, about to call dom_fw_setup\n");
   3.306  	regs->r28 = dom_fw_setup(d,saved_command_line,256L);  //FIXME
   3.307 -printk("new_thread, done with dom_fw_setup\n");
   3.308 -	// don't forget to set this!
   3.309  	v->vcpu_info->arch.banknum = 1;
   3.310 -	memset(v->arch._thread.fph,0,sizeof(struct ia64_fpreg)*96);
   3.311 +	v->vcpu_info->arch.metaphysical_mode = 1;
   3.312 +	d->shared_info->arch.flags = (d == dom0) ? (SIF_INITDOMAIN|SIF_PRIVILEGED|SIF_BLK_BE_DOMAIN|SIF_NET_BE_DOMAIN|SIF_USB_BE_DOMAIN) : 0;
   3.313  }
   3.314  #endif // CONFIG_VTI
   3.315  
   3.316 @@ -1037,21 +1043,6 @@ int construct_dom0(struct domain *d,
   3.317  	strcpy(d->name,"Domain0");
   3.318  #endif
   3.319  
   3.320 -	// prepare domain0 pagetable (maps METAphysical to physical)
   3.321 -	// following is roughly mm_init() in linux/kernel/fork.c
   3.322 -	d->arch.mm = xmalloc(struct mm_struct);
   3.323 -	if (unlikely(!d->arch.mm)) {
   3.324 -	    	printk("Can't allocate mm_struct for domain0\n");
   3.325 -	    	return -ENOMEM;
   3.326 -	}
   3.327 -	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   3.328 -	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   3.329 -	if (unlikely(!d->arch.mm->pgd)) {
   3.330 -	    	printk("Can't allocate pgd for domain0\n");
   3.331 -	    	return -ENOMEM;
   3.332 -	}
   3.333 -
   3.334 -
   3.335  	/* Mask all upcalls... */
   3.336  	for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   3.337  	    d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
   3.338 @@ -1146,19 +1137,6 @@ int construct_domU(struct domain *d,
   3.339  	printk("parsedomainelfimage returns %d\n",rc);
   3.340  	if ( rc != 0 ) return rc;
   3.341  
   3.342 -	d->arch.mm = xmalloc(struct mm_struct);
   3.343 -	if (unlikely(!d->arch.mm)) {
   3.344 -	    	printk("Can't allocate mm_struct for domain %d\n",d->domain_id);
   3.345 -	    	return -ENOMEM;
   3.346 -	}
   3.347 -	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   3.348 -	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   3.349 -	if (unlikely(!d->arch.mm->pgd)) {
   3.350 -	    	printk("Can't allocate pgd for domain %d\n",d->domain_id);
   3.351 -	    	return -ENOMEM;
   3.352 -	}
   3.353 -
   3.354 -
   3.355  	/* Mask all upcalls... */
   3.356  	for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   3.357  		d->shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
   3.358 @@ -1231,10 +1209,10 @@ void machine_halt(void)
   3.359  	while(1);
   3.360  }
   3.361  
   3.362 -void dummy(void)
   3.363 +void dummy_called(char *function)
   3.364  {
   3.365  	if (platform_is_hp_ski()) asm("break 0;;");
   3.366 -	printf("dummy called: spinning....\n");
   3.367 +	printf("dummy called in %s: spinning....\n", function);
   3.368  	while(1);
   3.369  }
   3.370  
     4.1 --- a/xen/arch/ia64/hypercall.c	Mon Jun 13 20:50:16 2005 +0000
     4.2 +++ b/xen/arch/ia64/hypercall.c	Mon Jun 13 22:03:21 2005 +0000
     4.3 @@ -19,8 +19,6 @@ extern unsigned long translate_domain_mp
     4.4  extern struct ia64_sal_retval pal_emulator_static(UINT64);
     4.5  extern struct ia64_sal_retval sal_emulator(UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64,UINT64);
     4.6  
     4.7 -void fooefi(void) {}
     4.8 -
     4.9  int
    4.10  ia64_hypercall (struct pt_regs *regs)
    4.11  {
    4.12 @@ -122,6 +120,28 @@ ia64_hypercall (struct pt_regs *regs)
    4.13  	    case 0xfffb: // test dummy hypercall
    4.14  		regs->r8 = domU_staging_read_8(vcpu_get_gr(v,32));
    4.15  		break;
    4.16 +
    4.17 +	    case __HYPERVISOR_dom0_op:
    4.18 +		regs->r8 = do_dom0_op(regs->r14);
    4.19 +		break;
    4.20 +
    4.21 +	    case __HYPERVISOR_dom_mem_op:
    4.22 +		/* regs->r8 = do_dom_mem_op(regs->r14, regs->r15, regs->r16, regs->r17, regs->r18); */
    4.23 +		/* we don't handle reservations; just return success */
    4.24 +		regs->r8 = regs->r16;
    4.25 +		break;
    4.26 +
    4.27 +	    case __HYPERVISOR_event_channel_op:
    4.28 +		regs->r8 = do_event_channel_op(regs->r14);
    4.29 +		break;
    4.30 +
    4.31 +	    case __HYPERVISOR_console_io:
    4.32 +		regs->r8 = do_console_io(regs->r14, regs->r15, regs->r16);
    4.33 +		break;
    4.34 +
    4.35 +	    default:
    4.36 +		printf("unknown hypercall %x\n", regs->r2);
    4.37 +		regs->r8 = (unsigned long)-1;
    4.38  	}
    4.39  	return 1;
    4.40  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/xen/arch/ia64/patch/linux-2.6.11/uaccess.h	Mon Jun 13 22:03:21 2005 +0000
     5.3 @@ -0,0 +1,22 @@
     5.4 +--- ../../linux-2.6.11/include/asm-ia64/uaccess.h	2005-06-06 10:36:23.000000000 -0600
     5.5 ++++ include/asm-ia64/uaccess.h	2005-06-10 18:08:06.000000000 -0600
     5.6 +@@ -60,6 +60,11 @@
     5.7 +  * address TASK_SIZE is never valid.  We also need to make sure that the address doesn't
     5.8 +  * point inside the virtually mapped linear page table.
     5.9 +  */
    5.10 ++#ifdef XEN
    5.11 ++/* VT-i reserves bit 60 for the VMM; guest addresses have bit 60 = bit 59 */
    5.12 ++#define IS_VMM_ADDRESS(addr) ((((addr) >> 60) ^ ((addr) >> 59)) & 1)
    5.13 ++#define __access_ok(addr, size, segment) (!IS_VMM_ADDRESS((unsigned long)(addr)))
    5.14 ++#else
    5.15 + #define __access_ok(addr, size, segment)						\
    5.16 + ({											\
    5.17 + 	__chk_user_ptr(addr);								\
    5.18 +@@ -67,6 +72,7 @@
    5.19 + 	 && ((segment).seg == KERNEL_DS.seg						\
    5.20 + 	     || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT)));	\
    5.21 + })
    5.22 ++#endif
    5.23 + #define access_ok(type, addr, size)	__access_ok((addr), (size), get_fs())
    5.24 + 
    5.25 + static inline int
     6.1 --- a/xen/arch/ia64/tools/mkbuildtree	Mon Jun 13 20:50:16 2005 +0000
     6.2 +++ b/xen/arch/ia64/tools/mkbuildtree	Mon Jun 13 22:03:21 2005 +0000
     6.3 @@ -259,7 +259,7 @@ softlink include/asm-ia64/string.h inclu
     6.4  softlink include/asm-ia64/thread_info.h include/asm-ia64/thread_info.h
     6.5  softlink include/asm-ia64/timex.h include/asm-ia64/timex.h
     6.6  softlink include/asm-ia64/topology.h include/asm-ia64/topology.h
     6.7 -softlink include/asm-ia64/uaccess.h include/asm-ia64/uaccess.h
     6.8 +cp_patch include/asm-ia64/uaccess.h include/asm-ia64/uaccess.h uaccess.h
     6.9  softlink include/asm-ia64/unaligned.h include/asm-ia64/unaligned.h
    6.10  softlink include/asm-ia64/unistd.h include/asm-ia64/unistd.h
    6.11  softlink include/asm-ia64/unwind.h include/asm-ia64/unwind.h
     7.1 --- a/xen/arch/ia64/vcpu.c	Mon Jun 13 20:50:16 2005 +0000
     7.2 +++ b/xen/arch/ia64/vcpu.c	Mon Jun 13 22:03:21 2005 +0000
     7.3 @@ -539,7 +539,7 @@ void vcpu_pend_interrupt(VCPU *vcpu, UIN
     7.4      } else
     7.5  #endif // CONFIG_VTI
     7.6      {
     7.7 -	if (!test_bit(vector,PSCB(vcpu,delivery_mask))) return;
     7.8 +	/* if (!test_bit(vector,PSCB(vcpu,delivery_mask))) return; */
     7.9  	if (test_bit(vector,PSCBX(vcpu,irr))) {
    7.10  //printf("vcpu_pend_interrupt: overrun\n");
    7.11  	}
    7.12 @@ -569,10 +569,10 @@ UINT64 vcpu_check_pending_interrupts(VCP
    7.13  	UINT64 *p, *q, *r, bits, bitnum, mask, i, vector;
    7.14  
    7.15  	p = &PSCBX(vcpu,irr[3]);
    7.16 -	q = &PSCB(vcpu,delivery_mask[3]);
    7.17 +	/* q = &PSCB(vcpu,delivery_mask[3]); */
    7.18  	r = &PSCBX(vcpu,insvc[3]);
    7.19  	for (i = 3; ; p--, q--, r--, i--) {
    7.20 -		bits = *p & *q;
    7.21 +		bits = *p /* & *q */;
    7.22  		if (bits) break; // got a potential interrupt
    7.23  		if (*r) {
    7.24  			// nothing in this word which is pending+inservice
     8.1 --- a/xen/arch/ia64/xenmisc.c	Mon Jun 13 20:50:16 2005 +0000
     8.2 +++ b/xen/arch/ia64/xenmisc.c	Mon Jun 13 22:03:21 2005 +0000
     8.3 @@ -63,13 +63,7 @@ void sync_lazy_execstate_mask(cpumask_t 
     8.4  void sync_lazy_execstate_all(void) {}
     8.5  
     8.6  int grant_table_create(struct domain *d) { return 0; }
     8.7 -void grant_table_destroy(struct domain *d)
     8.8 -{
     8.9 -	printf("grant_table_destroy: domain_destruct not tested!!!\n");
    8.10 -	printf("grant_table_destroy: ensure atomic_* calls work in domain_destruct!!\n");
    8.11 -	dummy();
    8.12 -	return;
    8.13 -}
    8.14 +void grant_table_destroy(struct domain *d) { return; }
    8.15  
    8.16  struct pt_regs *guest_cpu_user_regs(void) { return ia64_task_regs(current); }
    8.17  
     9.1 --- a/xen/include/asm-ia64/config.h	Mon Jun 13 20:50:16 2005 +0000
     9.2 +++ b/xen/include/asm-ia64/config.h	Mon Jun 13 22:03:21 2005 +0000
     9.3 @@ -177,8 +177,7 @@ void sort_main_extable(void);
     9.4  // see include/asm-x86/atomic.h (different from standard linux)
     9.5  #define _atomic_set(v,i) (((v).counter) = (i))
     9.6  #define _atomic_read(v) ((v).counter)
     9.7 -// FIXME following needs work
     9.8 -#define atomic_compareandswap(old, new, v) old
     9.9 +#define atomic_compareandswap(old, new, v) ((atomic_t){ cmpxchg(v, _atomic_read(old), _atomic_read(new)) })
    9.10  
    9.11  // see include/asm-ia64/mm.h, handle remaining pfn_info uses until gone
    9.12  #define pfn_info page
    9.13 @@ -227,6 +226,8 @@ struct screen_info { };
    9.14  
    9.15  #define FORCE_CRASH()	asm("break 0;;");
    9.16  
    9.17 +#define dummy()	dummy_called(__FUNCTION__)
    9.18 +
    9.19  // these declarations got moved at some point, find a better place for them
    9.20  extern int ht_per_core;
    9.21  
    10.1 --- a/xen/include/asm-ia64/domain.h	Mon Jun 13 20:50:16 2005 +0000
    10.2 +++ b/xen/include/asm-ia64/domain.h	Mon Jun 13 22:03:21 2005 +0000
    10.3 @@ -11,9 +11,6 @@
    10.4  
    10.5  extern void arch_do_createdomain(struct vcpu *);
    10.6  
    10.7 -extern int arch_final_setup_guestos(
    10.8 -    struct vcpu *, struct vcpu_guest_context *);
    10.9 -
   10.10  extern void domain_relinquish_resources(struct domain *);
   10.11  
   10.12  #ifdef CONFIG_VTI
    11.1 --- a/xen/include/public/arch-ia64.h	Mon Jun 13 20:50:16 2005 +0000
    11.2 +++ b/xen/include/public/arch-ia64.h	Mon Jun 13 22:03:21 2005 +0000
    11.3 @@ -64,18 +64,25 @@ typedef struct {
    11.4  	unsigned long krs[8];	// kernel registers
    11.5  	unsigned long pkrs[8];	// protection key registers
    11.6  	unsigned long tmp[8];	// temp registers (e.g. for hyperprivops)
    11.7 -//} PACKED arch_shared_info_t;
    11.8 +//} PACKED arch_vcpu_info_t;
    11.9  } arch_vcpu_info_t;		// DON'T PACK 
   11.10  
   11.11  typedef struct {
   11.12 +	int evtchn_vector;
   11.13 +	int domain_controller_evtchn;
   11.14 +	unsigned int flags;
   11.15 +//} PACKED arch_shared_info_t;
   11.16  } arch_shared_info_t;		// DON'T PACK 
   11.17  
   11.18  /*
   11.19   * The following is all CPU context. Note that the i387_ctxt block is filled 
   11.20   * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used.
   11.21   */
   11.22 +#include <asm/ptrace.h>
   11.23  typedef struct vcpu_guest_context {
   11.24 -    //unsigned long flags;
   11.25 +	struct pt_regs regs;
   11.26 +	arch_vcpu_info_t vcpu;
   11.27 +	arch_shared_info_t shared;
   11.28  } PACKED vcpu_guest_context_t;
   11.29  
   11.30  #endif /* !__ASSEMBLY__ */