ia64/xen-unstable

changeset 13106:37309be26861

merge with xen-ia64-unstable.hg
author awilliam@xenbuild2.aw
date Tue Dec 19 13:49:41 2006 -0700 (2006-12-19)
parents baa07859f24f c3b455c4676c
children 80c5b5914b79
files
line diff
     1.1 --- a/.hgignore	Tue Dec 19 13:21:24 2006 -0700
     1.2 +++ b/.hgignore	Tue Dec 19 13:49:41 2006 -0700
     1.3 @@ -229,3 +229,4 @@
     1.4  ^unmodified_drivers/linux-2.6/.*\.cmd$
     1.5  ^unmodified_drivers/linux-2.6/.*\.ko$
     1.6  ^unmodified_drivers/linux-2.6/.*\.mod\.c$
     1.7 +^LibVNCServer.*
     2.1 --- a/config/x86_32.mk	Tue Dec 19 13:21:24 2006 -0700
     2.2 +++ b/config/x86_32.mk	Tue Dec 19 13:49:41 2006 -0700
     2.3 @@ -1,4 +1,5 @@
     2.4  CONFIG_X86 := y
     2.5 +CONFIG_X86_32 := y
     2.6  CONFIG_X86_$(XEN_OS) := y
     2.7  
     2.8  CONFIG_HVM := y
     3.1 --- a/config/x86_64.mk	Tue Dec 19 13:21:24 2006 -0700
     3.2 +++ b/config/x86_64.mk	Tue Dec 19 13:49:41 2006 -0700
     3.3 @@ -1,4 +1,5 @@
     3.4  CONFIG_X86 := y
     3.5 +CONFIG_X86_64 := y
     3.6  CONFIG_X86_$(XEN_OS) := y
     3.7  
     3.8  CONFIG_HVM := y
     4.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c	Tue Dec 19 13:21:24 2006 -0700
     4.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/asm-offsets.c	Tue Dec 19 13:49:41 2006 -0700
     4.3 @@ -280,7 +280,6 @@ void foo(void)
     4.4  	DEFINE_MAPPED_REG_OFS(XSI_IHA_OFS, iha);
     4.5  	DEFINE_MAPPED_REG_OFS(XSI_ITIR_OFS, itir);
     4.6  	DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS, interrupt_collection_enabled);
     4.7 -	DEFINE_MAPPED_REG_OFS(XSI_PEND_OFS, pending_interruption);
     4.8  	DEFINE_MAPPED_REG_OFS(XSI_INCOMPL_REGFR_OFS, incomplete_regframe);
     4.9  	DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
    4.10  	DEFINE_MAPPED_REG_OFS(XSI_BANK0_R16_OFS, bank0_regs[0]);
     5.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S	Tue Dec 19 13:21:24 2006 -0700
     5.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/gate.S	Tue Dec 19 13:49:41 2006 -0700
     5.3 @@ -128,9 +128,9 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
     5.4  	;;
     5.5  #ifdef CONFIG_XEN_IA64_VDSO_PARAVIRT
     5.6  	// r20 = 1
     5.7 -	// r22 = &vcpu->evtchn_mask
     5.8 +	// r22 = &vcpu->vcpu_info->evtchn_upcall_mask
     5.9  	// r23 = &vpsr.ic
    5.10 -	// r24 = &vcpu->pending_interruption
    5.11 +	// r24 = &vcpu->vcpu_info->evtchn_upcall_pending
    5.12  	// r25 = tmp
    5.13  	// r28 = &running_on_xen
    5.14  	// r30 = running_on_xen
    5.15 @@ -144,8 +144,11 @@ GLOBAL_ENTRY(__kernel_syscall_via_epc)
    5.16  #define isRaw	p13
    5.17  	LOAD_RUNNING_ON_XEN(r28)
    5.18  	movl r22=XSI_PSR_I_ADDR
    5.19 +	;;
    5.20 +	ld8 r22=[r22]
    5.21 +	;;
    5.22  	movl r23=XSI_PSR_IC
    5.23 -	movl r24=XSI_PSR_I_ADDR+(XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS)
    5.24 +	adds r24=-1,r22
    5.25  	mov r20=1
    5.26  	;;
    5.27  	ld4 r30=[r28]
     6.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S	Tue Dec 19 13:21:24 2006 -0700
     6.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypercall.S	Tue Dec 19 13:49:41 2006 -0700
     6.3 @@ -356,8 +356,6 @@ END(xen_send_ipi)
     6.4  // Those are vdso specialized.
     6.5  // In fsys mode, call, ret can't be used.
     6.6  GLOBAL_ENTRY(xen_rsm_be_i)
     6.7 -	ld8 r22=[r22]
     6.8 -	;; 
     6.9  	st1 [r22]=r20
    6.10  	st4 [r23]=r0
    6.11  	XEN_HYPER_RSM_BE
    6.12 @@ -380,23 +378,23 @@ GLOBAL_ENTRY(xen_get_psr)
    6.13  END(xen_get_psr)
    6.14  
    6.15  	// see xen_ssm_i() in privop.h
    6.16 -	// r22 = &vcpu->evtchn_mask
    6.17 +	// r22 = &vcpu->vcpu_info->evtchn_upcall_mask
    6.18  	// r23 = &vpsr.ic
    6.19 -	// r24 = &vcpu->pending_interruption
    6.20 +	// r24 = &vcpu->vcpu_info->evtchn_upcall_pending
    6.21  	// r25 = tmp
    6.22  	// r31 = tmp
    6.23  	// p11 = tmp
    6.24  	// p14 = tmp
    6.25  #define XEN_SET_PSR_I			\
    6.26 -	ld4 r31=[r22];			\
    6.27 -	ld4 r25=[r24];			\
    6.28 +	ld1 r31=[r22];			\
    6.29 +	ld1 r25=[r24];			\
    6.30  	;;				\
    6.31 -	st4 [r22]=r0;			\
    6.32 +	st1 [r22]=r0;			\
    6.33  	cmp.ne.unc p14,p0=r0,r31;	\
    6.34  	;;				\
    6.35  (p14)	cmp.ne.unc p11,p0=r0,r25;	\
    6.36  	;;				\
    6.37 -(p11)	st4 [r22]=r20;			\
    6.38 +(p11)	st1 [r22]=r20;			\
    6.39  (p11)	st4 [r23]=r0;			\
    6.40  (p11)	XEN_HYPER_SSM_I;
    6.41  		
     7.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue Dec 19 13:21:24 2006 -0700
     7.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/hypervisor.c	Tue Dec 19 13:49:41 2006 -0700
     7.3 @@ -60,7 +60,7 @@ void
     7.4  contiguous_bitmap_init(unsigned long end_pfn)
     7.5  {
     7.6  	unsigned long size = (end_pfn + 2 * BITS_PER_LONG) >> 3;
     7.7 -	contiguous_bitmap = alloc_bootmem_low_pages(size);
     7.8 +	contiguous_bitmap = alloc_bootmem_pages(size);
     7.9  	BUG_ON(!contiguous_bitmap);
    7.10  	memset(contiguous_bitmap, 0, size);
    7.11  }
     8.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S	Tue Dec 19 13:21:24 2006 -0700
     8.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenivt.S	Tue Dec 19 13:49:41 2006 -0700
     8.3 @@ -737,10 +737,10 @@ xen_page_fault:
     8.4  	;;
     8.5  (p15)	ld8 r3=[r3]
     8.6  	;;
     8.7 -(p15)	st1 [r3]=r0,XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS	// if (p15) vpsr.i = 1
     8.8 +(p15)	st1 [r3]=r0,-1	// if (p15) vpsr.i = 1
     8.9  	mov r14=r0
    8.10  	;;
    8.11 -(p15)	ld4 r14=[r3]				// if (pending_interrupts)
    8.12 +(p15)	ld1 r14=[r3]				// if (pending_events)
    8.13  	adds r3=8,r2				// re-set up second base pointer
    8.14  	;;
    8.15  (p15)	cmp.ne	p15,p0=r14,r0
    8.16 @@ -1170,10 +1170,10 @@ 1:
    8.17  #ifdef CONFIG_XEN
    8.18  (p15)	ld8 r16=[r16]				// vpsr.i
    8.19  	;;
    8.20 -(p15)	st1 [r16]=r0,XSI_PEND_OFS-XSI_PSR_I_ADDR_OFS	// if (p15) vpsr.i = 1
    8.21 +(p15)	st1 [r16]=r0,-1		// if (p15) vpsr.i = 1
    8.22  	mov r2=r0
    8.23  	;;
    8.24 -(p15)	ld4 r2=[r16]				// if (pending_interrupts)
    8.25 +(p15)	ld1 r2=[r16]				// if (pending_events)
    8.26  	;;
    8.27  	cmp.ne	p6,p0=r2,r0
    8.28  	;;
    8.29 @@ -2159,13 +2159,22 @@ GLOBAL_ENTRY(xen_event_callback)
    8.30  	;;
    8.31  	SAVE_REST
    8.32  	;;
    8.33 +1:
    8.34  	alloc r14=ar.pfs,0,0,1,0 // must be first in an insn group
    8.35  	add out0=16,sp		// pass pointer to pt_regs as first arg
    8.36  	;;
    8.37 -	srlz.d			// make sure we see the effect of cr.ivr
    8.38 -	movl r14=ia64_leave_kernel
    8.39 +	br.call.sptk.many b0=evtchn_do_upcall
    8.40 +	;;
    8.41 +	movl r20=XSI_PSR_I_ADDR
    8.42 +	;;
    8.43 +	ld8 r20=[r20]
    8.44  	;;
    8.45 -	mov rp=r14
    8.46 -	br.call.sptk.many b6=evtchn_do_upcall
    8.47 +	adds r20=-1,r20		// vcpu_info->evtchn_upcall_pending
    8.48 +	;;
    8.49 +	ld1 r20=[r20]
    8.50 +	;;
    8.51 +	cmp.ne p6,p0=r20,r0	// if there are pending events, 
    8.52 +	(p6) br.spnt.few 1b	// call evtchn_do_upcall again.
    8.53 +	br.sptk.many ia64_leave_kernel   
    8.54  END(xen_event_callback)
    8.55  #endif
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c	Tue Dec 19 13:21:24 2006 -0700
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c	Tue Dec 19 13:49:41 2006 -0700
     9.3 @@ -49,8 +49,9 @@ struct xenfb_info
     9.4  	struct timer_list	refresh;
     9.5  	int			dirty;
     9.6  	int			x1, y1, x2, y2;	/* dirty rectangle,
     9.7 -						   protected by mm_lock */
     9.8 -	spinlock_t		mm_lock;
     9.9 +						   protected by dirty_lock */
    9.10 +	spinlock_t		dirty_lock;
    9.11 +	struct mutex		mm_lock;
    9.12  	int			nr_pages;
    9.13  	struct page		**pages;
    9.14  	struct list_head	mappings; /* protected by mm_lock */
    9.15 @@ -64,6 +65,70 @@ struct xenfb_info
    9.16  	struct xenbus_device	*xbdev;
    9.17  };
    9.18  
    9.19 +/*
    9.20 + * How the locks work together
    9.21 + *
    9.22 + * There are two locks: spinlock dirty_lock protecting the dirty
    9.23 + * rectangle, and mutex mm_lock protecting mappings.
    9.24 + *
    9.25 + * The problem is that dirty rectangle and mappings aren't
    9.26 + * independent: the dirty rectangle must cover all faulted pages in
    9.27 + * mappings.  We need to prove that our locking maintains this
    9.28 + * invariant.
    9.29 + *
    9.30 + * There are several kinds of critical regions:
    9.31 + *
    9.32 + * 1. Holding only dirty_lock: xenfb_refresh().  May run in
    9.33 + *    interrupts.  Extends the dirty rectangle.  Trivially preserves
    9.34 + *    invariant.
    9.35 + *
    9.36 + * 2. Holding only mm_lock: xenfb_mmap() and xenfb_vm_close().  Touch
    9.37 + *    only mappings.  The former creates unfaulted pages.  Preserves
    9.38 + *    invariant.  The latter removes pages.  Preserves invariant.
    9.39 + *
    9.40 + * 3. Holding both locks: xenfb_vm_nopage().  Extends the dirty
    9.41 + *    rectangle and updates mappings consistently.  Preserves
    9.42 + *    invariant.
    9.43 + *
    9.44 + * 4. The ugliest one: xenfb_update_screen().  Clear the dirty
    9.45 + *    rectangle and update mappings consistently.
    9.46 + *
    9.47 + *    We can't simply hold both locks, because zap_page_range() cannot
    9.48 + *    be called with a spinlock held.
    9.49 + *
    9.50 + *    Therefore, we first clear the dirty rectangle with both locks
    9.51 + *    held.  Then we unlock dirty_lock and update the mappings.
    9.52 + *    Critical regions that hold only dirty_lock may interfere with
    9.53 + *    that.  This can only be region 1: xenfb_refresh().  But that
    9.54 + *    just extends the dirty rectangle, which can't harm the
    9.55 + *    invariant.
    9.56 + *
    9.57 + * But FIXME: the invariant is too weak.  It misses that the fault
    9.58 + * record in mappings must be consistent with the mapping of pages in
    9.59 + * the associated address space!  do_no_page() updates the PTE after
    9.60 + * xenfb_vm_nopage() returns, i.e. outside the critical region.  This
    9.61 + * allows the following race:
    9.62 + *
    9.63 + * X writes to some address in the Xen frame buffer
    9.64 + * Fault - call do_no_page()
    9.65 + *     call xenfb_vm_nopage()
    9.66 + *         grab mm_lock
    9.67 + *         map->faults++;
    9.68 + *         release mm_lock
    9.69 + *     return back to do_no_page()
    9.70 + * (preempted, or SMP)
    9.71 + * Xen worker thread runs.
    9.72 + *      grab mm_lock
    9.73 + *      look at mappings
    9.74 + *          find this mapping, zaps its pages (but page not in pte yet)
    9.75 + *          clear map->faults
    9.76 + *      releases mm_lock
    9.77 + * (back to X process)
    9.78 + *     put page in X's pte
    9.79 + *
    9.80 + * Oh well, we wont be updating the writes to this page anytime soon.
    9.81 + */
    9.82 +
    9.83  static int xenfb_fps = 20;
    9.84  static unsigned long xenfb_mem_len = XENFB_WIDTH * XENFB_HEIGHT * XENFB_DEPTH / 8;
    9.85  
    9.86 @@ -105,6 +170,7 @@ static int xenfb_queue_full(struct xenfb
    9.87  
    9.88  static void xenfb_update_screen(struct xenfb_info *info)
    9.89  {
    9.90 +	unsigned long flags;
    9.91  	int y1, y2, x1, x2;
    9.92  	struct xenfb_mapping *map;
    9.93  
    9.94 @@ -113,14 +179,16 @@ static void xenfb_update_screen(struct x
    9.95  	if (xenfb_queue_full(info))
    9.96  		return;
    9.97  
    9.98 -	spin_lock(&info->mm_lock);
    9.99 +	mutex_lock(&info->mm_lock);
   9.100  
   9.101 +	spin_lock_irqsave(&info->dirty_lock, flags);
   9.102  	y1 = info->y1;
   9.103  	y2 = info->y2;
   9.104  	x1 = info->x1;
   9.105  	x2 = info->x2;
   9.106  	info->x1 = info->y1 = INT_MAX;
   9.107  	info->x2 = info->y2 = 0;
   9.108 +	spin_unlock_irqrestore(&info->dirty_lock, flags);
   9.109  
   9.110  	list_for_each_entry(map, &info->mappings, link) {
   9.111  		if (!map->faults)
   9.112 @@ -130,7 +198,7 @@ static void xenfb_update_screen(struct x
   9.113  		map->faults = 0;
   9.114  	}
   9.115  
   9.116 -	spin_unlock(&info->mm_lock);
   9.117 +	mutex_unlock(&info->mm_lock);
   9.118  
   9.119  	xenfb_do_update(info, x1, y1, x2 - x1, y2 - y1);
   9.120  }
   9.121 @@ -213,9 +281,11 @@ static void __xenfb_refresh(struct xenfb
   9.122  static void xenfb_refresh(struct xenfb_info *info,
   9.123  			  int x1, int y1, int w, int h)
   9.124  {
   9.125 -	spin_lock(&info->mm_lock);
   9.126 +	unsigned long flags;
   9.127 +
   9.128 +	spin_lock_irqsave(&info->dirty_lock, flags);
   9.129  	__xenfb_refresh(info, x1, y1, w, h);
   9.130 -	spin_unlock(&info->mm_lock);
   9.131 +	spin_unlock_irqrestore(&info->dirty_lock, flags);
   9.132  }
   9.133  
   9.134  static void xenfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
   9.135 @@ -253,12 +323,12 @@ static void xenfb_vm_close(struct vm_are
   9.136  	struct xenfb_mapping *map = vma->vm_private_data;
   9.137  	struct xenfb_info *info = map->info;
   9.138  
   9.139 -	spin_lock(&info->mm_lock);
   9.140 +	mutex_lock(&info->mm_lock);
   9.141  	if (atomic_dec_and_test(&map->map_refs)) {
   9.142  		list_del(&map->link);
   9.143  		kfree(map);
   9.144  	}
   9.145 -	spin_unlock(&info->mm_lock);
   9.146 +	mutex_unlock(&info->mm_lock);
   9.147  }
   9.148  
   9.149  static struct page *xenfb_vm_nopage(struct vm_area_struct *vma,
   9.150 @@ -267,13 +337,15 @@ static struct page *xenfb_vm_nopage(stru
   9.151  	struct xenfb_mapping *map = vma->vm_private_data;
   9.152  	struct xenfb_info *info = map->info;
   9.153  	int pgnr = (vaddr - vma->vm_start) >> PAGE_SHIFT;
   9.154 +	unsigned long flags;
   9.155  	struct page *page;
   9.156  	int y1, y2;
   9.157  
   9.158  	if (pgnr >= info->nr_pages)
   9.159  		return NOPAGE_SIGBUS;
   9.160  
   9.161 -	spin_lock(&info->mm_lock);
   9.162 +	mutex_lock(&info->mm_lock);
   9.163 +	spin_lock_irqsave(&info->dirty_lock, flags);
   9.164  	page = info->pages[pgnr];
   9.165  	get_page(page);
   9.166  	map->faults++;
   9.167 @@ -283,7 +355,8 @@ static struct page *xenfb_vm_nopage(stru
   9.168  	if (y2 > info->fb_info->var.yres)
   9.169  		y2 = info->fb_info->var.yres;
   9.170  	__xenfb_refresh(info, 0, y1, info->fb_info->var.xres, y2 - y1);
   9.171 -	spin_unlock(&info->mm_lock);
   9.172 +	spin_unlock_irqrestore(&info->dirty_lock, flags);
   9.173 +	mutex_unlock(&info->mm_lock);
   9.174  
   9.175  	if (type)
   9.176  		*type = VM_FAULT_MINOR;
   9.177 @@ -323,9 +396,9 @@ static int xenfb_mmap(struct fb_info *fb
   9.178  	map->info = info;
   9.179  	atomic_set(&map->map_refs, 1);
   9.180  
   9.181 -	spin_lock(&info->mm_lock);
   9.182 +	mutex_lock(&info->mm_lock);
   9.183  	list_add(&map->link, &info->mappings);
   9.184 -	spin_unlock(&info->mm_lock);
   9.185 +	mutex_unlock(&info->mm_lock);
   9.186  
   9.187  	vma->vm_ops = &xenfb_vm_ops;
   9.188  	vma->vm_flags |= (VM_DONTEXPAND | VM_RESERVED);
   9.189 @@ -382,7 +455,8 @@ static int __devinit xenfb_probe(struct 
   9.190  	info->xbdev = dev;
   9.191  	info->irq = -1;
   9.192  	info->x1 = info->y1 = INT_MAX;
   9.193 -	spin_lock_init(&info->mm_lock);
   9.194 +	spin_lock_init(&info->dirty_lock);
   9.195 +	mutex_init(&info->mm_lock);
   9.196  	init_waitqueue_head(&info->wq);
   9.197  	init_timer(&info->refresh);
   9.198  	info->refresh.function = xenfb_timer;
    10.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Dec 19 13:21:24 2006 -0700
    10.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/hypervisor.h	Tue Dec 19 13:49:41 2006 -0700
    10.3 @@ -215,7 +215,8 @@ asmlinkage int xprintk(const char *fmt, 
    10.4  #endif /* CONFIG_XEN || CONFIG_VMX_GUEST */
    10.5  
    10.6  #ifdef CONFIG_XEN_PRIVILEGED_GUEST
    10.7 -#define is_initial_xendomain() (xen_start_info->flags & SIF_INITDOMAIN)
    10.8 +#define is_initial_xendomain()						\
    10.9 +	(is_running_on_xen() ? xen_start_info->flags & SIF_INITDOMAIN : 0)
   10.10  #else
   10.11  #define is_initial_xendomain() 0
   10.12  #endif
    11.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Tue Dec 19 13:21:24 2006 -0700
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Tue Dec 19 13:49:41 2006 -0700
    11.3 @@ -113,7 +113,8 @@ extern void xen_set_eflag(unsigned long)
    11.4  	({ XSI_PSR_I = (uint8_t)(_val) ? 0 : 1; })
    11.5  #define xen_set_virtual_psr_ic(_val)	\
    11.6  	({ XEN_MAPPEDREGS->interrupt_collection_enabled = _val ? 1 : 0; })
    11.7 -#define xen_get_virtual_pend()		(XEN_MAPPEDREGS->pending_interruption)
    11.8 +#define xen_get_virtual_pend()		\
    11.9 +	(*(((uint8_t *)XEN_MAPPEDREGS->interrupt_mask_addr) - 1))
   11.10  
   11.11  /* Hyperprivops are "break" instructions with a well-defined API.
   11.12   * In particular, the virtual psr.ic bit must be off; in this way
    12.1 --- a/tools/ioemu/target-i386-dm/exec-dm.c	Tue Dec 19 13:21:24 2006 -0700
    12.2 +++ b/tools/ioemu/target-i386-dm/exec-dm.c	Tue Dec 19 13:49:41 2006 -0700
    12.3 @@ -128,10 +128,28 @@ char *logfilename = "/tmp/qemu.log";
    12.4  FILE *logfile;
    12.5  int loglevel;
    12.6  
    12.7 +
    12.8 +#if defined(__i386__) || defined(__x86_64__)
    12.9 +#define MAPCACHE
   12.10 +#endif
   12.11 +
   12.12 +#ifdef MAPCACHE
   12.13 +static pthread_mutex_t mapcache_mutex;
   12.14 +#define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
   12.15 +#define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
   12.16 +#else 
   12.17 +#define mapcache_lock() ( (void)0 )
   12.18 +#define mapcache_unlock() ( (void)0 )
   12.19 +#endif
   12.20 +
   12.21 +
   12.22  void cpu_exec_init(CPUState *env)
   12.23  {
   12.24      CPUState **penv;
   12.25      int cpu_index;
   12.26 +#ifdef MAPCACHE
   12.27 +    pthread_mutexattr_t mxattr; 
   12.28 +#endif
   12.29  
   12.30      env->next_cpu = NULL;
   12.31      penv = &first_cpu;
   12.32 @@ -145,6 +163,14 @@ void cpu_exec_init(CPUState *env)
   12.33  
   12.34      /* alloc dirty bits array */
   12.35      phys_ram_dirty = qemu_malloc(phys_ram_size >> TARGET_PAGE_BITS);
   12.36 +
   12.37 +#ifdef MAPCACHE
   12.38 +    /* setup memory access mutex to protect mapcache */
   12.39 +    pthread_mutexattr_init(&mxattr); 
   12.40 +    pthread_mutexattr_settype(&mxattr, PTHREAD_MUTEX_RECURSIVE);
   12.41 +    pthread_mutex_init(&mapcache_mutex, &mxattr); 
   12.42 +    pthread_mutexattr_destroy(&mxattr); 
   12.43 +#endif
   12.44  }
   12.45  
   12.46  /* enable or disable low levels log */
   12.47 @@ -440,10 +466,7 @@ void cpu_physical_memory_rw(target_phys_
   12.48      uint8_t *ptr;
   12.49      uint32_t val;
   12.50  
   12.51 -#if defined(__i386__) || defined(__x86_64__)
   12.52 -    static pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
   12.53 -    pthread_mutex_lock(&mutex);
   12.54 -#endif
   12.55 +    mapcache_lock();
   12.56  
   12.57      while (len > 0) {
   12.58          /* How much can we copy before the next page boundary? */
   12.59 @@ -510,9 +533,7 @@ void cpu_physical_memory_rw(target_phys_
   12.60          addr += l;
   12.61      }
   12.62  
   12.63 -#if defined(__i386__) || defined(__x86_64__)
   12.64 -    pthread_mutex_unlock(&mutex);
   12.65 -#endif
   12.66 +    mapcache_unlock();
   12.67  }
   12.68  #endif
   12.69  
    13.1 --- a/tools/python/xen/xend/XendAPI.py	Tue Dec 19 13:21:24 2006 -0700
    13.2 +++ b/tools/python/xen/xend/XendAPI.py	Tue Dec 19 13:49:41 2006 -0700
    13.3 @@ -663,7 +663,10 @@ class XendAPI:
    13.4              XendDomain.instance().get_vm_by_uuid(vm_ref).info[name])
    13.5  
    13.6      def VM_set(self, name, session, vm_ref, value):
    13.7 -        XendDomain.instance().get_vm_by_uuid(vm_ref).info[name] = value
    13.8 +        xd = XendDomain.instance()
    13.9 +        dominfo = xd.get_vm_by_uuid(vm_ref)
   13.10 +        dominfo.info[name] = value
   13.11 +        xd.managed_config_save(dominfo)
   13.12          return xen_api_success_void()
   13.13  
   13.14      # attributes (ro)
    14.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Tue Dec 19 13:21:24 2006 -0700
    14.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Tue Dec 19 13:49:41 2006 -0700
    14.3 @@ -218,18 +218,17 @@ def forkHelper(cmd, fd, inputHandler, cl
    14.4                      log.debug('%s', line)
    14.5                      inputHandler(line, child.tochild)
    14.6  
    14.7 -            thread.join()
    14.8 -
    14.9          except IOError, exn:
   14.10              raise XendError('Error reading from child process for %s: %s' %
   14.11                              (cmd, exn))
   14.12      finally:
   14.13          child.fromchild.close()
   14.14 -        child.childerr.close()
   14.15          if not closeToChild:
   14.16              child.tochild.close()
   14.17 +        thread.join()
   14.18 +        child.childerr.close()
   14.19 +        status = child.wait()
   14.20  
   14.21 -    status = child.wait()
   14.22      if status >> 8 == 127:
   14.23          raise XendError("%s failed: popen failed" % string.join(cmd))
   14.24      elif status != 0:
    15.1 --- a/tools/python/xen/xend/XendConfig.py	Tue Dec 19 13:21:24 2006 -0700
    15.2 +++ b/tools/python/xen/xend/XendConfig.py	Tue Dec 19 13:49:41 2006 -0700
    15.3 @@ -15,6 +15,7 @@
    15.4  # Copyright (C) 2006 XenSource Ltd
    15.5  #============================================================================
    15.6  
    15.7 +import logging
    15.8  import re
    15.9  import time
   15.10  import types
   15.11 @@ -23,10 +24,13 @@ from xen.xend import sxp
   15.12  from xen.xend import uuid
   15.13  from xen.xend.XendError import VmError
   15.14  from xen.xend.XendDevices import XendDevices
   15.15 -from xen.xend.XendLogging import log
   15.16  from xen.xend.PrettyPrint import prettyprintstring
   15.17  from xen.xend.XendConstants import DOM_STATE_HALTED
   15.18  
   15.19 +log = logging.getLogger("xend.XendConfig")
   15.20 +log.setLevel(logging.WARN)
   15.21 +
   15.22 +
   15.23  """
   15.24  XendConfig API
   15.25  
   15.26 @@ -81,6 +85,7 @@ def scrub_password(data):
   15.27  XENAPI_CFG_TO_LEGACY_CFG = {
   15.28      'uuid': 'uuid',
   15.29      'vcpus_number': 'vcpus',
   15.30 +    'cpus': 'cpus',
   15.31      'memory_static_min': 'memory',
   15.32      'memory_static_max': 'maxmem',
   15.33      'name_label': 'name',
   15.34 @@ -182,18 +187,18 @@ LEGACY_CFG_TYPES = {
   15.35      'shadow_memory': int,
   15.36      'maxmem':        int,
   15.37      'start_time':    float,
   15.38 -    'cpu_cap':         int,
   15.39 -    'cpu_weight':      int,
   15.40 +    'cpu_cap':       int,
   15.41 +    'cpu_weight':    int,
   15.42      'cpu_time':      float,
   15.43 -    'features':        str,
   15.44 -    'localtime':       int,
   15.45 -    'name':        str,
   15.46 -    'on_poweroff': str,
   15.47 -    'on_reboot':   str,
   15.48 -    'on_crash':    str,
   15.49 -    'on_xend_stop': str,
   15.50 +    'features':      str,
   15.51 +    'localtime':     int,
   15.52 +    'name':          str,
   15.53 +    'on_poweroff':   str,
   15.54 +    'on_reboot':     str,
   15.55 +    'on_crash':      str,
   15.56 +    'on_xend_stop':  str,
   15.57      'on_xend_start': str,
   15.58 -    'online_vcpus': int,
   15.59 +    'online_vcpus':  int,
   15.60  }
   15.61  
   15.62  # Values that should be stored in xenstore's /vm/<uuid> that is used
   15.63 @@ -430,8 +435,12 @@ class XendConfig(dict):
   15.64          """
   15.65          cfg = {}
   15.66  
   15.67 -        # First step is to convert deprecated options to
   15.68 -        # current equivalents.
   15.69 +        for key, typ in XENAPI_CFG_TYPES.items():
   15.70 +            val = sxp.child_value(sxp_cfg, key)
   15.71 +            if val is not None:
   15.72 +                cfg[key] = typ(val)
   15.73 +
   15.74 +        # Convert deprecated options to current equivalents.
   15.75          
   15.76          restart = sxp.child_value(sxp_cfg, 'restart')
   15.77          if restart:
   15.78 @@ -574,8 +583,15 @@ class XendConfig(dict):
   15.79          """Read in an SXP Configuration object and
   15.80          populate at much of the Xen API with valid values.
   15.81          """
   15.82 +        log.debug('_sxp_to_xapi(%s)' % scrub_password(sxp_cfg))
   15.83 +
   15.84          cfg = self._parse_sxp(sxp_cfg)
   15.85  
   15.86 +        for key, typ in XENAPI_CFG_TYPES.items():
   15.87 +            val = cfg.get(key)
   15.88 +            if val is not None:
   15.89 +                self[key] = typ(val)
   15.90 +
   15.91          # Convert parameters that can be directly mapped from
   15.92          # the Legacy Config to Xen API Config
   15.93          
   15.94 @@ -590,9 +606,13 @@ class XendConfig(dict):
   15.95              except KeyError:
   15.96                  pass
   15.97  
   15.98 -        self['PV_bootloader']      = cfg.get('bootloader',      '')
   15.99 -        self['PV_bootloader_args'] = cfg.get('bootloader_args', '')
  15.100 -        
  15.101 +        def update_with(n, o):
  15.102 +            if not self.get(n):
  15.103 +                self[n] = cfg.get(o, '')
  15.104 +
  15.105 +        update_with('PV_bootloader',      'bootloader')
  15.106 +        update_with('PV_bootloader_args', 'bootloader_args')
  15.107 +
  15.108          image_sxp = sxp.child_value(sxp_cfg, 'image', [])
  15.109          if image_sxp:
  15.110              self.update_with_image_sxp(image_sxp)
  15.111 @@ -635,6 +655,8 @@ class XendConfig(dict):
  15.112          the Xen API.
  15.113          """
  15.114  
  15.115 +        log.debug('_sxp_to_xapi_unsupported(%s)' % scrub_password(sxp_cfg))
  15.116 +
  15.117          # Parse and convert parameters used to configure
  15.118          # the image (as well as HVM images)
  15.119          image_sxp = sxp.child_value(sxp_cfg, 'image', [])
  15.120 @@ -748,6 +770,9 @@ class XendConfig(dict):
  15.121          @param xapi: Xen API VM Struct
  15.122          @type xapi: dict
  15.123          """
  15.124 +
  15.125 +        log.debug('update_with_xenapi_config: %s' % scrub_password(xapi))
  15.126 +
  15.127          for key, val in xapi.items():
  15.128              type_conv = XENAPI_CFG_TYPES.get(key)
  15.129              if type_conv is None:
  15.130 @@ -760,11 +785,8 @@ class XendConfig(dict):
  15.131  
  15.132          self.validate()
  15.133  
  15.134 -    def to_xml(self):
  15.135 -        """Return an XML string representing the configuration."""
  15.136 -        pass
  15.137 -
  15.138 -    def to_sxp(self, domain = None, ignore_devices = False, ignore = []):
  15.139 +    def to_sxp(self, domain = None, ignore_devices = False, ignore = [],
  15.140 +               legacy_only = True):
  15.141          """ Get SXP representation of this config object.
  15.142  
  15.143          Incompat: removed store_mfn, console_mfn
  15.144 @@ -785,6 +807,11 @@ class XendConfig(dict):
  15.145          if domain.getDomid() is not None:
  15.146              sxpr.append(['domid', domain.getDomid()])
  15.147  
  15.148 +        if not legacy_only:
  15.149 +            for name in XENAPI_CFG_TYPES.keys():
  15.150 +                if name in self and self[name] not in (None, []):
  15.151 +                    sxpr.append([name, str(self[name])])
  15.152 +
  15.153          for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items():
  15.154              if self.has_key(xenapi) and self[xenapi] not in (None, []):
  15.155                  if type(self[xenapi]) == bool:
  15.156 @@ -1044,12 +1071,12 @@ class XendConfig(dict):
  15.157          """Returns a backwards compatible image SXP expression that is
  15.158          used in xenstore's /vm/<uuid>/image value and xm list."""
  15.159          image = [self['image'].get('type', 'linux')]
  15.160 -        if self.has_key('kernel_kernel'):
  15.161 -            image.append(['kernel', self['kernel_kernel']])
  15.162 -        if self.has_key('kernel_initrd') and self['kernel_initrd']:
  15.163 -            image.append(['ramdisk', self['kernel_initrd']])
  15.164 -        if self.has_key('kernel_args') and self['kernel_args']:
  15.165 -            image.append(['args', self['kernel_args']])
  15.166 +        if self.has_key('PV_kernel'):
  15.167 +            image.append(['kernel', self['PV_kernel']])
  15.168 +        if self.has_key('PV_ramdisk') and self['PV_ramdisk']:
  15.169 +            image.append(['ramdisk', self['PV_ramdisk']])
  15.170 +        if self.has_key('PV_args') and self['PV_args']:
  15.171 +            image.append(['args', self['PV_args']])
  15.172  
  15.173          for arg, conv in LEGACY_IMAGE_CFG:
  15.174              if self['image'].has_key(arg):
  15.175 @@ -1069,8 +1096,10 @@ class XendConfig(dict):
  15.176          return image
  15.177  
  15.178      def update_with_image_sxp(self, image_sxp):
  15.179 -        # Convert Legacy "image" config to Xen API kernel_*
  15.180 +        # Convert Legacy "image" config to Xen API PV_*
  15.181          # configuration
  15.182 +        log.debug("update_with_image_sxp(%s)" % scrub_password(image_sxp))
  15.183 +
  15.184          self['PV_kernel'] = sxp.child_value(image_sxp, 'kernel','')
  15.185          self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
  15.186          kernel_args = sxp.child_value(image_sxp, 'args', '')
    16.1 --- a/tools/python/xen/xend/XendDomain.py	Tue Dec 19 13:21:24 2006 -0700
    16.2 +++ b/tools/python/xen/xend/XendDomain.py	Tue Dec 19 13:49:41 2006 -0700
    16.3 @@ -26,6 +26,7 @@ import os
    16.4  import stat
    16.5  import shutil
    16.6  import socket
    16.7 +import tempfile
    16.8  import threading
    16.9  
   16.10  import xen.lowlevel.xc
   16.11 @@ -280,16 +281,21 @@ class XendDomain:
   16.12              make_or_raise(domain_config_dir)
   16.13  
   16.14              try:
   16.15 -                sxp_cache_file = open(self._managed_config_path(dom_uuid),'w')
   16.16 -                prettyprint(dominfo.sxpr(), sxp_cache_file, width = 78)
   16.17 -                sxp_cache_file.close()
   16.18 +                fd, fn = tempfile.mkstemp()
   16.19 +                f = os.fdopen(fd, 'w+b')
   16.20 +                try:
   16.21 +                    prettyprint(dominfo.sxpr(legacy_only = False), f,
   16.22 +                                width = 78)
   16.23 +                finally:
   16.24 +                    f.close()
   16.25 +                try:
   16.26 +                    os.rename(fn, self._managed_config_path(dom_uuid))
   16.27 +                except:
   16.28 +                    log.exception("Renaming %s" % fn)
   16.29 +                    os.remove(fn)
   16.30              except:
   16.31                  log.exception("Error occurred saving configuration file " +
   16.32                                "to %s" % domain_config_dir)
   16.33 -                try:
   16.34 -                    self._managed_domain_remove(dom_uuid)
   16.35 -                except:
   16.36 -                    pass
   16.37                  raise XendError("Failed to save configuration file to: %s" %
   16.38                                  domain_config_dir)
   16.39          else:
    17.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Dec 19 13:21:24 2006 -0700
    17.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Dec 19 13:49:41 2006 -0700
    17.3 @@ -1800,9 +1800,10 @@ class XendDomainInfo:
    17.4          log.trace("XendDomainInfo.update done on domain %s: %s",
    17.5                    str(self.domid), self.info)
    17.6  
    17.7 -    def sxpr(self, ignore_store = False):
    17.8 +    def sxpr(self, ignore_store = False, legacy_only = True):
    17.9          result = self.info.to_sxp(domain = self,
   17.10 -                                   ignore_devices = ignore_store)
   17.11 +                                  ignore_devices = ignore_store,
   17.12 +                                  legacy_only = legacy_only)
   17.13  
   17.14          if not ignore_store and self.dompath:
   17.15              vnc_port = self.readDom('console/vnc-port')
    18.1 --- a/tools/python/xen/xend/server/netif.py	Tue Dec 19 13:21:24 2006 -0700
    18.2 +++ b/tools/python/xen/xend/server/netif.py	Tue Dec 19 13:49:41 2006 -0700
    18.3 @@ -140,7 +140,7 @@ class NetifController(DevController):
    18.4  
    18.5          script = os.path.join(xroot.network_script_dir,
    18.6                                config.get('script', xroot.get_vif_script()))
    18.7 -        typ = config.get('type')
    18.8 +        typ     = config.get('type')
    18.9          bridge  = config.get('bridge')
   18.10          mac     = config.get('mac')
   18.11          vifname = config.get('vifname')
    19.1 --- a/tools/python/xen/xend/server/vfbif.py	Tue Dec 19 13:21:24 2006 -0700
    19.2 +++ b/tools/python/xen/xend/server/vfbif.py	Tue Dec 19 13:49:41 2006 -0700
    19.3 @@ -1,4 +1,5 @@
    19.4  from xen.xend.server.DevController import DevController
    19.5 +from xen.xend.XendLogging import log
    19.6  
    19.7  from xen.xend.XendError import VmError
    19.8  import xen.xend
    19.9 @@ -12,6 +13,9 @@ def spawn_detached(path, args, env):
   19.10      else:
   19.11          os.waitpid(p, 0)
   19.12          
   19.13 +CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
   19.14 +                  'display', 'xauthority']
   19.15 +
   19.16  class VfbifController(DevController):
   19.17      """Virtual frame buffer controller. Handles all vfb devices for a domain.
   19.18      Note that we only support a single vfb per domain at the moment.
   19.19 @@ -19,28 +23,42 @@ class VfbifController(DevController):
   19.20  
   19.21      def __init__(self, vm):
   19.22          DevController.__init__(self, vm)
   19.23 -        self.config = {}
   19.24          
   19.25      def getDeviceDetails(self, config):
   19.26          """@see DevController.getDeviceDetails"""
   19.27 -        devid = 0
   19.28 -        back = {}
   19.29 -        front = {}
   19.30 -        return (devid, back, front)
   19.31 +
   19.32 +        back = dict([(k, config[k]) for k in CONFIG_ENTRIES
   19.33 +                     if config.has_key(k)])
   19.34 +
   19.35 +        return (0, back, {})
   19.36 +
   19.37  
   19.38      def getDeviceConfiguration(self, devid):
   19.39 -        r = DevController.getDeviceConfiguration(self, devid)
   19.40 -        for (k,v) in self.config.iteritems():
   19.41 -            r[k] = v
   19.42 -        return r
   19.43 -    
   19.44 +        result = DevController.getDeviceConfiguration(self, devid)
   19.45 +
   19.46 +        devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
   19.47 +        return dict([(CONFIG_ENTRIES[i], devinfo[i])
   19.48 +                     for i in range(len(CONFIG_ENTRIES))
   19.49 +                     if devinfo[i] is not None])
   19.50 +
   19.51 +
   19.52      def createDevice(self, config):
   19.53          DevController.createDevice(self, config)
   19.54 -        self.config = config
   19.55          std_args = [ "--domid", "%d" % self.vm.getDomid(),
   19.56                       "--title", self.vm.getName() ]
   19.57          t = config.get("type", None)
   19.58          if t == "vnc":
   19.59 +            passwd = None
   19.60 +            if config.has_key("vncpasswd"):
   19.61 +                passwd = config["vncpasswd"]
   19.62 +            else:
   19.63 +                passwd = xen.xend.XendRoot.instance().get_vncpasswd_default()
   19.64 +            if passwd:
   19.65 +                self.vm.storeVm("vncpasswd", passwd)
   19.66 +                log.debug("Stored a VNC password for vfb access")
   19.67 +            else:
   19.68 +                log.debug("No VNC passwd configured for vfb access")
   19.69 +
   19.70              # Try to start the vnc backend
   19.71              args = [xen.util.auxbin.pathTo("xen-vncfb")]
   19.72              if config.has_key("vncunused"):
    20.1 --- a/tools/python/xen/xm/XenAPI.py	Tue Dec 19 13:21:24 2006 -0700
    20.2 +++ b/tools/python/xen/xm/XenAPI.py	Tue Dec 19 13:49:41 2006 -0700
    20.3 @@ -83,20 +83,24 @@ class Session(xen.util.xmlrpclib2.Server
    20.4  
    20.5  
    20.6      def xenapi_request(self, methodname, params):
    20.7 -        full_params = (self._session,) + params
    20.8 -        return _parse_result(getattr(self, methodname)(*full_params))
    20.9 +        if methodname.startswith('login'):
   20.10 +            self._login(methodname, params)
   20.11 +            return None
   20.12 +        else:
   20.13 +            full_params = (self._session,) + params
   20.14 +            return _parse_result(getattr(self, methodname)(*full_params))
   20.15  
   20.16  
   20.17 -    def _login(self, method, username, password):
   20.18 +    def _login(self, method, params):
   20.19          self._session = _parse_result(
   20.20 -            getattr(self, 'session.%s' % method)(username, password))
   20.21 +            getattr(self, 'session.%s' % method)(*params))
   20.22  
   20.23  
   20.24      def __getattr__(self, name):
   20.25          if name == 'xenapi':
   20.26              return _Dispatcher(self.xenapi_request, None)
   20.27          elif name.startswith('login'):
   20.28 -            return lambda u, p: self._login(name, u, p)
   20.29 +            return lambda *params: self._login(name, params)
   20.30          else:
   20.31              return xen.util.xmlrpclib2.ServerProxy.__getattr__(self, name)
   20.32  
    21.1 --- a/tools/python/xen/xm/create.py	Tue Dec 19 13:21:24 2006 -0700
    21.2 +++ b/tools/python/xen/xm/create.py	Tue Dec 19 13:49:41 2006 -0700
    21.3 @@ -284,7 +284,7 @@ gopts.var('usbport', val='PATH',
    21.4            use="""Add a physical USB port to a domain, as specified by the path
    21.5            to that port.  This option may be repeated to add more than one port.""")
    21.6  
    21.7 -gopts.var('vfb', val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY",
    21.8 +gopts.var('vfb', val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD",
    21.9            fn=append_value, default=[],
   21.10            use="""Make the domain a framebuffer backend.
   21.11            The backend type should be either sdl or vnc.
   21.12 @@ -584,7 +584,7 @@ def configure_vfbs(config_devs, vals):
   21.13              d['type'] = 'sdl'
   21.14          for (k,v) in d.iteritems():
   21.15              if not k in [ 'vnclisten', 'vncunused', 'vncdisplay', 'display',
   21.16 -                          'xauthority', 'type' ]:
   21.17 +                          'xauthority', 'type', 'vncpasswd' ]:
   21.18                  err("configuration option %s unknown to vfbs" % k)
   21.19              config.append([k,v])
   21.20          if not d.has_key("display") and os.environ.has_key("DISPLAY"):
    22.1 --- a/tools/python/xen/xm/main.py	Tue Dec 19 13:21:24 2006 -0700
    22.2 +++ b/tools/python/xen/xm/main.py	Tue Dec 19 13:49:41 2006 -0700
    22.3 @@ -558,7 +558,7 @@ class Shell(cmd.Cmd):
    22.4                  ok, res = _run_cmd(lambda x: server.xenapi_request(words[0],
    22.5                                                                     tuple(x)),
    22.6                                     words[0], words[1:])
    22.7 -                if ok and res != '':
    22.8 +                if ok and res is not None and res != '':
    22.9                      pprint.pprint(res)
   22.10              else:
   22.11                  print '*** Unknown command: %s' % words[0]
   22.12 @@ -1556,7 +1556,11 @@ def detach(args, command, deviceClass):
   22.13  
   22.14  
   22.15  def xm_block_detach(args):
   22.16 -    detach(args, 'block-detach', 'vbd')
   22.17 +    try:
   22.18 +        detach(args, 'block-detach', 'vbd')
   22.19 +        return
   22.20 +    except:
   22.21 +        pass
   22.22      detach(args, 'block-detach', 'tap')
   22.23  
   22.24  
   22.25 @@ -1798,7 +1802,7 @@ def _run_cmd(cmd, cmd_name, args):
   22.26      except OptionError, e:
   22.27          err(str(e))
   22.28          _usage(cmd_name)
   22.29 -        print e.usage()
   22.30 +        print e.usage
   22.31      except security.ACMError, e:
   22.32          err(str(e))
   22.33      except:
    23.1 --- a/tools/xenfb/vncfb.c	Tue Dec 19 13:21:24 2006 -0700
    23.2 +++ b/tools/xenfb/vncfb.c	Tue Dec 19 13:49:41 2006 -0700
    23.3 @@ -148,6 +148,10 @@ static int xk2linux[0x10000] = {
    23.4  	[XK_plus] = KEY_EQUAL,
    23.5  };
    23.6  
    23.7 +static int btnmap[] = {
    23.8 +	BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, BTN_FORWARD, BTN_BACK
    23.9 +};
   23.10 +
   23.11  static void on_kbd_event(rfbBool down, rfbKeySym keycode, rfbClientPtr cl)
   23.12  {
   23.13  	/*
   23.14 @@ -184,8 +188,11 @@ static void on_ptr_event(int buttonMask,
   23.15  		down = buttonMask & (1 << i);
   23.16  		if (down == last_down)
   23.17  			continue;
   23.18 -		/* FIXME this assumes buttons are numbered the same; verify they are */
   23.19 -		if (xenfb_send_key(xenfb, down != 0, BTN_MOUSE + i) < 0)
   23.20 +		if (i >= sizeof(btnmap) / sizeof(*btnmap))
   23.21 +			break;
   23.22 +		if (btnmap[i] == 0)
   23.23 +			break;
   23.24 +		if (xenfb_send_key(xenfb, down != 0, btnmap[i]) < 0)
   23.25  			fprintf(stderr, "Button %d %s lost (%s)\n",
   23.26  				i, down ? "down" : "up", strerror(errno));
   23.27  	}
   23.28 @@ -205,15 +212,10 @@ static void on_ptr_event(int buttonMask,
   23.29  	last_y = y;
   23.30  }
   23.31  
   23.32 -static void xenstore_write_vncport(int port, int domid)
   23.33 +static void xenstore_write_vncport(struct xs_handle *xsh, int port, int domid)
   23.34  {
   23.35 -	char *buf = NULL, *path;
   23.36 +	char *buf, *path;
   23.37  	char portstr[10];
   23.38 -	struct xs_handle *xsh = NULL;
   23.39 -
   23.40 -	xsh = xs_daemon_open();
   23.41 -	if (xsh == NULL)
   23.42 -		return;
   23.43  
   23.44  	path = xs_get_domain_path(xsh, domid);
   23.45  	if (path == NULL) {
   23.46 @@ -241,6 +243,56 @@ static void xenstore_write_vncport(int p
   23.47  }
   23.48  
   23.49  
   23.50 +static int xenstore_read_vncpasswd(struct xs_handle *xsh, int domid, char *pwbuf, int pwbuflen)
   23.51 +{
   23.52 +	char buf[256], *path, *uuid = NULL, *passwd = NULL;
   23.53 +	unsigned int len, rc = 0;
   23.54 +
   23.55 +	if (xsh == NULL) {
   23.56 +		return -1;
   23.57 +	}
   23.58 +
   23.59 +	path = xs_get_domain_path(xsh, domid);
   23.60 +	if (path == NULL) {
   23.61 +		fprintf(stderr, "xs_get_domain_path() error\n");
   23.62 +		return -1;
   23.63 +	}
   23.64 +
   23.65 +	snprintf(buf, 256, "%s/vm", path);
   23.66 +	uuid = xs_read(xsh, XBT_NULL, buf, &len);
   23.67 +	if (uuid == NULL) {
   23.68 +		fprintf(stderr, "xs_read(): uuid get error\n");
   23.69 +		free(path);
   23.70 +		return -1;
   23.71 +	}
   23.72 +
   23.73 +	snprintf(buf, 256, "%s/vncpasswd", uuid);
   23.74 +	passwd = xs_read(xsh, XBT_NULL, buf, &len);
   23.75 +	if (passwd == NULL) {
   23.76 +		free(uuid);
   23.77 +		free(path);
   23.78 +		return rc;
   23.79 +	}
   23.80 +
   23.81 +	strncpy(pwbuf, passwd, pwbuflen-1);
   23.82 +	pwbuf[pwbuflen-1] = '\0';
   23.83 +
   23.84 +	fprintf(stderr, "Got a VNC password read from XenStore\n");
   23.85 +
   23.86 +	passwd[0] = '\0';
   23.87 +	snprintf(buf, 256, "%s/vncpasswd", uuid);
   23.88 +	if (xs_write(xsh, XBT_NULL, buf, passwd, len) == 0) {
   23.89 +		fprintf(stderr, "xs_write() vncpasswd failed\n");
   23.90 +		rc = -1;
   23.91 +	}
   23.92 +
   23.93 +	free(passwd);
   23.94 +	free(uuid);
   23.95 +	free(path);
   23.96 +
   23.97 +	return rc;
   23.98 +}
   23.99 +
  23.100  static void vnc_update(struct xenfb *xenfb, int x, int y, int w, int h)
  23.101  {
  23.102  	rfbScreenInfoPtr server = xenfb->user_data;
  23.103 @@ -274,6 +326,10 @@ int main(int argc, char **argv)
  23.104  	char portstr[10];
  23.105  	char *endp;
  23.106  	int r;
  23.107 +	struct xs_handle *xsh;
  23.108 +	char vncpasswd[1024];
  23.109 +
  23.110 +	vncpasswd[0] = '\0';
  23.111  
  23.112  	while ((opt = getopt_long(argc, argv, "d:p:t:u", options,
  23.113  				  NULL)) != -1) {
  23.114 @@ -346,6 +402,19 @@ int main(int argc, char **argv)
  23.115  		exit(1);
  23.116  	}
  23.117  
  23.118 +	xsh = xs_daemon_open();
  23.119 +	if (xsh == NULL) {
  23.120 +	        fprintf(stderr, "cannot open connection to xenstore\n");
  23.121 +		exit(1);
  23.122 +	}
  23.123 +
  23.124 +
  23.125 +	if (xenstore_read_vncpasswd(xsh, domid, vncpasswd, sizeof(vncpasswd)/sizeof(char)) < 0) {
  23.126 +		fprintf(stderr, "cannot read VNC password from xenstore\n");
  23.127 +		exit(1);
  23.128 +	}
  23.129 +	  
  23.130 +
  23.131  	server = rfbGetScreen(&fake_argc, fake_argv, 
  23.132  			      xenfb->width, xenfb->height,
  23.133  			      8, 3, xenfb->depth / 8);
  23.134 @@ -360,6 +429,21 @@ int main(int argc, char **argv)
  23.135          if (unused)
  23.136  		server->autoPort = true;
  23.137  
  23.138 +	if (vncpasswd[0]) {
  23.139 +		char **passwds = malloc(sizeof(char**)*2);
  23.140 +		if (!passwds) {
  23.141 +			fprintf(stderr, "cannot allocate memory (%s)\n", strerror(errno));
  23.142 +			exit(1);
  23.143 +		}
  23.144 +		fprintf(stderr, "Registered password\n");
  23.145 +		passwds[0] = vncpasswd;
  23.146 +		passwds[1] = NULL;
  23.147 +
  23.148 +		server->authPasswdData = passwds;
  23.149 +		server->passwordCheck = rfbCheckPasswordByList;
  23.150 +	} else {
  23.151 +		fprintf(stderr, "Running with no password\n");
  23.152 +	}
  23.153  	server->serverFormat.redShift = 16;
  23.154  	server->serverFormat.greenShift = 8;
  23.155  	server->serverFormat.blueShift = 0;
  23.156 @@ -372,7 +456,7 @@ int main(int argc, char **argv)
  23.157  
  23.158  	rfbRunEventLoop(server, -1, true);
  23.159  
  23.160 -        xenstore_write_vncport(server->port, domid);
  23.161 +        xenstore_write_vncport(xsh, server->port, domid);
  23.162  
  23.163  	for (;;) {
  23.164  		FD_ZERO(&readfds);
    24.1 --- a/tools/xm-test/lib/XmTestLib/acm.py	Tue Dec 19 13:21:24 2006 -0700
    24.2 +++ b/tools/xm-test/lib/XmTestLib/acm.py	Tue Dec 19 13:49:41 2006 -0700
    24.3 @@ -57,6 +57,8 @@ def ACMLabelResources(resources):
    24.4  
    24.5  # Applications may label resources explicitly by calling this function
    24.6  def ACMLabelResource(resource, label='red'):
    24.7 +    if not isACMEnabled():
    24.8 +        return
    24.9      if acm_verbose:
   24.10          print "labeling resource %s with label %s" % (resource, label)
   24.11      if not ACM_LABEL_RESOURCES:
    25.1 --- a/xen/arch/ia64/asm-offsets.c	Tue Dec 19 13:21:24 2006 -0700
    25.2 +++ b/xen/arch/ia64/asm-offsets.c	Tue Dec 19 13:49:41 2006 -0700
    25.3 @@ -41,6 +41,8 @@ void foo(void)
    25.4  	DEFINE(VCPU_VTM_OFFSET_OFS, offsetof(struct vcpu, arch.arch_vmx.vtm.vtm_offset));
    25.5  	DEFINE(VCPU_VTM_LAST_ITC_OFS, offsetof(struct vcpu, arch.arch_vmx.vtm.last_itc));
    25.6  	DEFINE(VCPU_VRR0_OFS, offsetof(struct vcpu, arch.arch_vmx.vrr[0]));
    25.7 +	DEFINE(VCPU_ITR0_OFS, offsetof(struct vcpu, arch.itrs[0]));
    25.8 +	DEFINE(VCPU_CALLBACK_OFS, offsetof(struct vcpu, arch.event_callback_ip));
    25.9  #ifdef   VTI_DEBUG
   25.10  	DEFINE(IVT_CUR_OFS, offsetof(struct vcpu, arch.arch_vmx.ivt_current));
   25.11  	DEFINE(IVT_DBG_OFS, offsetof(struct vcpu, arch.arch_vmx.ivt_debug));
    26.1 --- a/xen/arch/ia64/asm-xsi-offsets.c	Tue Dec 19 13:21:24 2006 -0700
    26.2 +++ b/xen/arch/ia64/asm-xsi-offsets.c	Tue Dec 19 13:49:41 2006 -0700
    26.3 @@ -62,7 +62,6 @@ void foo(void)
    26.4  	DEFINE_MAPPED_REG_OFS(XSI_ITV_OFS, itv);
    26.5  	DEFINE_MAPPED_REG_OFS(XSI_PTA_OFS, pta);
    26.6  	DEFINE_MAPPED_REG_OFS(XSI_PSR_IC_OFS, interrupt_collection_enabled);
    26.7 -	DEFINE_MAPPED_REG_OFS(XSI_PEND_OFS, pending_interruption);
    26.8  	DEFINE_MAPPED_REG_OFS(XSI_INCOMPL_REGFR_OFS, incomplete_regframe);
    26.9  	DEFINE_MAPPED_REG_OFS(XSI_METAPHYS_OFS, metaphysical_mode);
   26.10  	DEFINE_MAPPED_REG_OFS(XSI_BANKNUM_OFS, banknum);
    27.1 --- a/xen/arch/ia64/xen/faults.c	Tue Dec 19 13:21:24 2006 -0700
    27.2 +++ b/xen/arch/ia64/xen/faults.c	Tue Dec 19 13:49:41 2006 -0700
    27.3 @@ -605,6 +605,9 @@ ia64_handle_reflection(unsigned long ifa
    27.4  		check_lazy_cover = 1;
    27.5  		vector = IA64_DATA_ACCESS_RIGHTS_VECTOR;
    27.6  		break;
    27.7 +	case 24:
    27.8 +		vector = IA64_GENEX_VECTOR;
    27.9 +		break;
   27.10  	case 25:
   27.11  		vector = IA64_DISABLED_FPREG_VECTOR;
   27.12  		break;
    28.1 --- a/xen/arch/ia64/xen/hyperprivop.S	Tue Dec 19 13:21:24 2006 -0700
    28.2 +++ b/xen/arch/ia64/xen/hyperprivop.S	Tue Dec 19 13:49:41 2006 -0700
    28.3 @@ -37,8 +37,10 @@
    28.4  # define FAST_BREAK
    28.5  # undef FAST_ACCESS_REFLECT 	//XXX TODO fast_access_reflect
    28.6                              	//    doesn't support dom0 vp yet.
    28.7 -# define FAST_RFI
    28.8 -# define FAST_SSM_I
    28.9 +//# define FAST_RFI
   28.10 +// TODO: Since we use callback to deliver interrupt, 
   28.11 +//       FAST_SSM_I needs to be rewritten.
   28.12 +//# define FAST_SSM_I
   28.13  # define FAST_PTC_GA
   28.14  # undef RFI_TO_INTERRUPT // not working yet
   28.15  #endif
   28.16 @@ -87,29 +89,13 @@ GLOBAL_ENTRY(fast_hyperprivop)
   28.17  	cmp.eq p7,p6=HYPERPRIVOP_SSM_I,r17
   28.18  (p7)	br.sptk.many hyper_ssm_i;;
   28.19  
   28.20 -	// FIXME. This algorithm gives up (goes to the slow path) if there
   28.21 -	// are ANY interrupts pending, even if they are currently
   28.22 -	// undeliverable.  This should be improved later...
   28.23 -	adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
   28.24 -	ld4 r20=[r20] ;;
   28.25 -	cmp.eq p7,p0=r0,r20
   28.26 -(p7)	br.cond.sptk.many 1f
   28.27 -	movl r20=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
   28.28 -	ld8 r20=[r20];;
   28.29 -	adds r21=IA64_VCPU_IRR0_OFFSET,r20;
   28.30 -	adds r22=IA64_VCPU_IRR0_OFFSET+8,r20;;
   28.31 -	ld8 r23=[r21],16; ld8 r24=[r22],16;;
   28.32 -	ld8 r21=[r21]; ld8 r22=[r22];;
   28.33 -	or r23=r23,r24; or r21=r21,r22;;
   28.34 -	or r20=r23,r21;;
   28.35 -1:	// when we get to here r20=~=interrupts pending
   28.36  	// Check pending event indication
   28.37 -(p7)	movl r20=THIS_CPU(current_psr_i_addr);;
   28.38 -(p7)	ld8 r20=[r20]
   28.39 +	adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS, r18;;
   28.40 +	ld8 r20=[r20]
   28.41  	;;
   28.42 -(p7)	adds r20=-1,r20				// evtchn_upcall_pending
   28.43 +	ld1 r22=[r20],-1	// evtchn_upcall_mask
   28.44  	;;
   28.45 -(p7)	ld1 r20=[r20]
   28.46 +	ld1 r20=[r20]		// evtchn_upcall_pending
   28.47  	;;
   28.48  
   28.49  	// HYPERPRIVOP_RFI?
   28.50 @@ -117,12 +103,10 @@ 1:	// when we get to here r20=~=interrup
   28.51  (p7)	br.sptk.many hyper_rfi
   28.52  	;;
   28.53  
   28.54 -	// HYPERPRIVOP_GET_IVR?
   28.55 -	cmp.eq p7,p6=HYPERPRIVOP_GET_IVR,r17
   28.56 -(p7)	br.sptk.many hyper_get_ivr
   28.57 +	// if event enabled and there are pending events
   28.58 +	cmp.ne p7,p0=r20,r0
   28.59  	;;
   28.60 -
   28.61 -	cmp.ne p7,p0=r20,r0
   28.62 +	cmp.eq.and p7,p0=r22,r0
   28.63  (p7)	br.spnt.many dispatch_break_fault
   28.64  	;;
   28.65  
   28.66 @@ -141,21 +125,6 @@ 1:	// when we get to here r20=~=interrup
   28.67  (p7)	br.sptk.many hyper_rsm_dt
   28.68  	;;
   28.69  
   28.70 -	// HYPERPRIVOP_GET_TPR?
   28.71 -	cmp.eq p7,p6=HYPERPRIVOP_GET_TPR,r17
   28.72 -(p7)	br.sptk.many hyper_get_tpr
   28.73 -	;;
   28.74 -
   28.75 -	// HYPERPRIVOP_SET_TPR?
   28.76 -	cmp.eq p7,p6=HYPERPRIVOP_SET_TPR,r17
   28.77 -(p7)	br.sptk.many hyper_set_tpr
   28.78 -	;;
   28.79 -
   28.80 -	// HYPERPRIVOP_EOI?
   28.81 -	cmp.eq p7,p6=HYPERPRIVOP_EOI,r17
   28.82 -(p7)	br.sptk.many hyper_eoi
   28.83 -	;;
   28.84 -
   28.85  	// HYPERPRIVOP_SET_ITM?
   28.86  	cmp.eq p7,p6=HYPERPRIVOP_SET_ITM,r17
   28.87  (p7)	br.sptk.many hyper_set_itm
   28.88 @@ -425,10 +394,11 @@ GLOBAL_ENTRY(fast_tick_reflect)
   28.89  	ld8 r23=[r21];;
   28.90  	or r22=r22,r23;;
   28.91  	st8 [r21]=r22;;
   28.92 -	// set PSCB(pending_interruption)!
   28.93 -	adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
   28.94 -	st4 [r20]=r25;;
   28.95 -	
   28.96 +	// set evtchn_upcall_pending!
   28.97 +	adds r20=XSI_PSR_I_ADDR_OFS-XSI_PSR_IC_OFS,r18;;
   28.98 +	ld8 r20=[r20];;
   28.99 +	adds r20=-1,r20;;		// evtchn_upcall_pending
  28.100 +	st1 [r20]=r25;;
  28.101  	// if interrupted at pl0, we're done
  28.102  	extr.u r16=r17,IA64_PSR_CPL0_BIT,2;;
  28.103  	cmp.eq p6,p0=r16,r0;;
  28.104 @@ -1465,236 +1435,6 @@ 1:	extr.u r26=r24,41,2 ;;
  28.105  	;;
  28.106  END(hyper_rsm_dt)
  28.107  
  28.108 -ENTRY(hyper_get_tpr)
  28.109 -#ifdef FAST_HYPERPRIVOP_CNT
  28.110 -	movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_GET_TPR);;
  28.111 -	ld4 r21=[r20];;
  28.112 -	adds r21=1,r21;;
  28.113 -	st4 [r20]=r21;;
  28.114 -#endif
  28.115 -	mov r24=cr.ipsr
  28.116 -	mov r25=cr.iip;;
  28.117 -	adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
  28.118 -	ld8 r8=[r20];;
  28.119 -	extr.u r26=r24,41,2 ;;
  28.120 -	cmp.eq p6,p7=2,r26 ;;
  28.121 -(p6)	mov r26=0
  28.122 -(p6)	adds r25=16,r25
  28.123 -(p7)	adds r26=1,r26
  28.124 -	;;
  28.125 -	dep r24=r26,r24,41,2
  28.126 -	;;
  28.127 -	mov cr.ipsr=r24
  28.128 -	mov cr.iip=r25
  28.129 -	mov pr=r31,-1 ;;
  28.130 -	rfi
  28.131 -	;;
  28.132 -END(hyper_get_tpr)
  28.133 -
  28.134 -// if we get to here, there are no interrupts pending so we
  28.135 -// can change virtual tpr to any value without fear of provoking
  28.136 -// (or accidentally missing) delivering an interrupt
  28.137 -ENTRY(hyper_set_tpr)
  28.138 -#ifdef FAST_HYPERPRIVOP_CNT
  28.139 -	movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_SET_TPR);;
  28.140 -	ld4 r21=[r20];;
  28.141 -	adds r21=1,r21;;
  28.142 -	st4 [r20]=r21;;
  28.143 -#endif
  28.144 -	mov r24=cr.ipsr
  28.145 -	mov r25=cr.iip;;
  28.146 -	movl r27=0xff00;;
  28.147 -	adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
  28.148 -	andcm r8=r8,r27;;
  28.149 -	st8 [r20]=r8;;
  28.150 -	extr.u r26=r24,41,2 ;;
  28.151 -	cmp.eq p6,p7=2,r26 ;;
  28.152 -(p6)	mov r26=0
  28.153 -(p6)	adds r25=16,r25
  28.154 -(p7)	adds r26=1,r26
  28.155 -	;;
  28.156 -	dep r24=r26,r24,41,2
  28.157 -	;;
  28.158 -	mov cr.ipsr=r24
  28.159 -	mov cr.iip=r25
  28.160 -	mov pr=r31,-1 ;;
  28.161 -	rfi
  28.162 -	;;
  28.163 -END(hyper_set_tpr)
  28.164 -
  28.165 -ENTRY(hyper_get_ivr)
  28.166 -#ifdef FAST_HYPERPRIVOP_CNT
  28.167 -	movl r22=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_GET_IVR);;
  28.168 -	ld4 r21=[r22];;
  28.169 -	adds r21=1,r21;;
  28.170 -	st4 [r22]=r21;;
  28.171 -#endif
  28.172 -	mov r8=15;;
  28.173 -	// when we get to here r20=~=interrupts pending
  28.174 -	cmp.eq p7,p0=r20,r0;;
  28.175 -(p7)	adds r20=XSI_PEND_OFS-XSI_PSR_IC_OFS,r18 ;;
  28.176 -(p7)	st4 [r20]=r0;;
  28.177 -(p7)	br.spnt.many 1f ;;
  28.178 -	movl r30=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  28.179 -	ld8 r30=[r30];;
  28.180 -	adds r24=IA64_VCPU_INSVC3_OFFSET,r30;;
  28.181 -	mov r25=192
  28.182 -	adds r22=IA64_VCPU_IRR3_OFFSET,r30;;
  28.183 -	ld8 r23=[r22];;
  28.184 -	cmp.eq p6,p0=r23,r0;;
  28.185 -(p6)	adds r22=-8,r22;;
  28.186 -(p6)	adds r24=-8,r24;;
  28.187 -(p6)	adds r25=-64,r25;;
  28.188 -(p6)	ld8 r23=[r22];;
  28.189 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.190 -(p6)	adds r22=-8,r22;;
  28.191 -(p6)	adds r24=-8,r24;;
  28.192 -(p6)	adds r25=-64,r25;;
  28.193 -(p6)	ld8 r23=[r22];;
  28.194 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.195 -(p6)	adds r22=-8,r22;;
  28.196 -(p6)	adds r24=-8,r24;;
  28.197 -(p6)	adds r25=-64,r25;;
  28.198 -(p6)	ld8 r23=[r22];;
  28.199 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.200 -	cmp.eq p6,p0=r23,r0
  28.201 -(p6)	br.cond.spnt.few 1f;	// this is actually an error
  28.202 -	// r22 points to non-zero element of irr, r23 has value
  28.203 -	// r24 points to corr element of insvc, r25 has elt*64
  28.204 -	ld8 r26=[r24];;
  28.205 -	cmp.geu p6,p0=r26,r23
  28.206 -(p6)	br.cond.spnt.many 1f;
  28.207 -	// not masked by insvc, get vector number
  28.208 -	shr.u r26=r23,1;;
  28.209 -	or r26=r23,r26;;
  28.210 -	shr.u r27=r26,2;;
  28.211 -	or r26=r26,r27;;
  28.212 -	shr.u r27=r26,4;;
  28.213 -	or r26=r26,r27;;
  28.214 -	shr.u r27=r26,8;;
  28.215 -	or r26=r26,r27;;
  28.216 -	shr.u r27=r26,16;;
  28.217 -	or r26=r26,r27;;
  28.218 -	shr.u r27=r26,32;;
  28.219 -	or r26=r26,r27;;
  28.220 -	andcm r26=0xffffffffffffffff,r26;;
  28.221 -	popcnt r26=r26;;
  28.222 -	sub r26=63,r26;;
  28.223 -	// r26 now contains the bit index (mod 64)
  28.224 -	mov r27=1;;
  28.225 -	shl r27=r27,r26;;
  28.226 -	// r27 now contains the (within the proper word) bit mask 
  28.227 -	add r26=r25,r26
  28.228 -	// r26 now contains the vector [0..255]
  28.229 -	adds r20=XSI_TPR_OFS-XSI_PSR_IC_OFS,r18 ;;
  28.230 -	ld8 r20=[r20] ;;
  28.231 -	extr.u r28=r20,16,1
  28.232 -	extr.u r29=r20,4,4 ;;
  28.233 -	cmp.ne p6,p0=r28,r0	// if tpr.mmi is set, return SPURIOUS
  28.234 -(p6)	br.cond.spnt.few 1f;
  28.235 -	shl r29=r29,4;;
  28.236 -	adds r29=15,r29;;
  28.237 -	cmp.ge p6,p0=r29,r26
  28.238 -(p6)	br.cond.spnt.few 1f;
  28.239 -	// OK, have an unmasked vector to process/return
  28.240 -	ld8 r25=[r24];;
  28.241 -	or r25=r25,r27;;
  28.242 -	st8 [r24]=r25;;
  28.243 -	ld8 r25=[r22];;
  28.244 -	andcm r25=r25,r27;;
  28.245 -	st8 [r22]=r25;;
  28.246 -	mov r8=r26;;
  28.247 -	// if its a clock tick, remember itm to avoid delivering it twice
  28.248 -	adds r20=XSI_ITV_OFS-XSI_PSR_IC_OFS,r18 ;;
  28.249 -	ld8 r20=[r20];;
  28.250 -	extr.u r20=r20,0,8;;
  28.251 -	cmp.eq p6,p0=r20,r8
  28.252 -	adds r22=IA64_VCPU_DOMAIN_ITM_LAST_OFFSET,r30
  28.253 -	adds r23=IA64_VCPU_DOMAIN_ITM_OFFSET,r30;;
  28.254 -	ld8 r23=[r23];;
  28.255 -(p6)	st8 [r22]=r23;;
  28.256 -	// all done
  28.257 -1:	mov r24=cr.ipsr
  28.258 -	mov r25=cr.iip;;
  28.259 -	extr.u r26=r24,41,2 ;;
  28.260 -	cmp.eq p6,p7=2,r26 ;;
  28.261 -(p6)	mov r26=0
  28.262 -(p6)	adds r25=16,r25
  28.263 -(p7)	adds r26=1,r26
  28.264 -	;;
  28.265 -	dep r24=r26,r24,41,2
  28.266 -	;;
  28.267 -	mov cr.ipsr=r24
  28.268 -	mov cr.iip=r25
  28.269 -	mov pr=r31,-1 ;;
  28.270 -	rfi
  28.271 -	;;
  28.272 -END(hyper_get_ivr)
  28.273 -
  28.274 -ENTRY(hyper_eoi)
  28.275 -	// when we get to here r20=~=interrupts pending
  28.276 -	cmp.ne p7,p0=r20,r0
  28.277 -(p7)	br.spnt.many dispatch_break_fault ;;
  28.278 -#ifdef FAST_HYPERPRIVOP_CNT
  28.279 -	movl r20=FAST_HYPERPRIVOP_PERFC(HYPERPRIVOP_EOI);;
  28.280 -	ld4 r21=[r20];;
  28.281 -	adds r21=1,r21;;
  28.282 -	st4 [r20]=r21;;
  28.283 -#endif
  28.284 -	movl r22=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  28.285 -	ld8 r22=[r22];;
  28.286 -	adds r22=IA64_VCPU_INSVC3_OFFSET,r22;;
  28.287 -	ld8 r23=[r22];;
  28.288 -	cmp.eq p6,p0=r23,r0;;
  28.289 -(p6)	adds r22=-8,r22;;
  28.290 -(p6)	ld8 r23=[r22];;
  28.291 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.292 -(p6)	adds r22=-8,r22;;
  28.293 -(p6)	ld8 r23=[r22];;
  28.294 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.295 -(p6)	adds r22=-8,r22;;
  28.296 -(p6)	ld8 r23=[r22];;
  28.297 -(p6)	cmp.eq p6,p0=r23,r0;;
  28.298 -	cmp.eq p6,p0=r23,r0
  28.299 -(p6)	br.cond.spnt.few 1f;	// this is actually an error
  28.300 -	// r22 points to non-zero element of insvc, r23 has value
  28.301 -	shr.u r24=r23,1;;
  28.302 -	or r24=r23,r24;;
  28.303 -	shr.u r25=r24,2;;
  28.304 -	or r24=r24,r25;;
  28.305 -	shr.u r25=r24,4;;
  28.306 -	or r24=r24,r25;;
  28.307 -	shr.u r25=r24,8;;
  28.308 -	or r24=r24,r25;;
  28.309 -	shr.u r25=r24,16;;
  28.310 -	or r24=r24,r25;;
  28.311 -	shr.u r25=r24,32;;
  28.312 -	or r24=r24,r25;;
  28.313 -	andcm r24=0xffffffffffffffff,r24;;
  28.314 -	popcnt r24=r24;;
  28.315 -	sub r24=63,r24;;
  28.316 -	// r24 now contains the bit index
  28.317 -	mov r25=1;;
  28.318 -	shl r25=r25,r24;;
  28.319 -	andcm r23=r23,r25;;
  28.320 -	st8 [r22]=r23;;
  28.321 -1:	mov r24=cr.ipsr
  28.322 -	mov r25=cr.iip;;
  28.323 -	extr.u r26=r24,41,2 ;;
  28.324 -	cmp.eq p6,p7=2,r26 ;;
  28.325 -(p6)	mov r26=0
  28.326 -(p6)	adds r25=16,r25
  28.327 -(p7)	adds r26=1,r26
  28.328 -	;;
  28.329 -	dep r24=r26,r24,41,2
  28.330 -	;;
  28.331 -	mov cr.ipsr=r24
  28.332 -	mov cr.iip=r25
  28.333 -	mov pr=r31,-1 ;;
  28.334 -	rfi
  28.335 -	;;
  28.336 -END(hyper_eoi)
  28.337 -
  28.338  ENTRY(hyper_set_itm)
  28.339  	// when we get to here r20=~=interrupts pending
  28.340  	cmp.ne p7,p0=r20,r0
    29.1 --- a/xen/arch/ia64/xen/ivt.S	Tue Dec 19 13:21:24 2006 -0700
    29.2 +++ b/xen/arch/ia64/xen/ivt.S	Tue Dec 19 13:49:41 2006 -0700
    29.3 @@ -1737,6 +1737,8 @@ ENTRY(general_exception)
    29.4  #ifdef XEN
    29.5  	cmp4.ge p6,p0=0x20,r16
    29.6  (p6)	br.sptk.many dispatch_privop_fault
    29.7 +	;;
    29.8 +	FAULT_OR_REFLECT(24)
    29.9  #else
   29.10  	cmp4.eq p6,p0=0,r16
   29.11  (p6)	br.sptk.many dispatch_illegal_op_fault
    30.1 --- a/xen/arch/ia64/xen/vcpu.c	Tue Dec 19 13:21:24 2006 -0700
    30.2 +++ b/xen/arch/ia64/xen/vcpu.c	Tue Dec 19 13:49:41 2006 -0700
    30.3 @@ -2162,6 +2162,7 @@ vcpu_itc_no_srlz(VCPU * vcpu, u64 IorD, 
    30.4  	BUG_ON(logps > PAGE_SHIFT);
    30.5  	vcpu_tlb_track_insert_or_dirty(vcpu, vaddr, entry);
    30.6  	psr = ia64_clear_ic();
    30.7 +	pte &= ~(_PAGE_RV2 | _PAGE_RV1);	// Mask out the reserved bits.
    30.8  	ia64_itc(IorD, vaddr, pte, ps);	// FIXME: look for bigger mappings
    30.9  	ia64_set_psr(psr);
   30.10  	// ia64_srlz_i(); // no srls req'd, will rfi later
    31.1 --- a/xen/common/page_alloc.c	Tue Dec 19 13:21:24 2006 -0700
    31.2 +++ b/xen/common/page_alloc.c	Tue Dec 19 13:49:41 2006 -0700
    31.3 @@ -490,16 +490,16 @@ void scrub_heap_pages(void)
    31.4  
    31.5      for ( mfn = first_valid_mfn; mfn < max_page; mfn++ )
    31.6      {
    31.7 -        /* Every 100MB, print a progress dot. */
    31.8 -        if ( (mfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
    31.9 -            printk(".");
   31.10 -
   31.11          process_pending_timers();
   31.12  
   31.13          /* Quick lock-free check. */
   31.14          if ( allocated_in_map(mfn) )
   31.15              continue;
   31.16  
   31.17 +        /* Every 100MB, print a progress dot. */
   31.18 +        if ( (mfn % ((100*1024*1024)/PAGE_SIZE)) == 0 )
   31.19 +            printk(".");
   31.20 +
   31.21          spin_lock_irq(&heap_lock);
   31.22  
   31.23          /* Re-check page status with lock held. */
    32.1 --- a/xen/common/xenoprof.c	Tue Dec 19 13:21:24 2006 -0700
    32.2 +++ b/xen/common/xenoprof.c	Tue Dec 19 13:49:41 2006 -0700
    32.3 @@ -384,7 +384,7 @@ static int add_passive_list(XEN_GUEST_HA
    32.4      d->xenoprof->domain_type = XENOPROF_DOMAIN_PASSIVE;
    32.5      passive.nbuf = d->xenoprof->nbuf;
    32.6      passive.bufsize = d->xenoprof->bufsize;
    32.7 -    if ( !shadow_mode_translate(d) )
    32.8 +    if ( !shadow_mode_translate(current->domain) )
    32.9          passive.buf_gmaddr = __pa(d->xenoprof->rawbuf);
   32.10      else
   32.11          xenoprof_shared_gmfn_with_guest(
    33.1 --- a/xen/include/asm-ia64/linux-xen/asm/pgtable.h	Tue Dec 19 13:21:24 2006 -0700
    33.2 +++ b/xen/include/asm-ia64/linux-xen/asm/pgtable.h	Tue Dec 19 13:49:41 2006 -0700
    33.3 @@ -39,6 +39,11 @@
    33.4  #define _PAGE_P			(1 << _PAGE_P_BIT)	/* page present bit */
    33.5  #define _PAGE_MA_WB		(0x0 <<  2)	/* write back memory attribute */
    33.6  #ifdef XEN
    33.7 +#define _PAGE_RV1_BIT		1
    33.8 +#define _PAGE_RV2_BIT		50
    33.9 +#define _PAGE_RV1		(__IA64_UL(1) << _PAGE_RV1_BIT)	/* reserved bit */
   33.10 +#define _PAGE_RV2		(__IA64_UL(3) << _PAGE_RV2_BIT)	/* reserved bits */
   33.11 +
   33.12  #define _PAGE_MA_ST		(0x1 <<  2)	/* is reserved for software use */
   33.13  #endif
   33.14  #define _PAGE_MA_UC		(0x4 <<  2)	/* uncacheable memory attribute */
    34.1 --- a/xen/include/xen/elfcore.h	Tue Dec 19 13:21:24 2006 -0700
    34.2 +++ b/xen/include/xen/elfcore.h	Tue Dec 19 13:49:41 2006 -0700
    34.3 @@ -87,7 +87,7 @@ typedef struct
    34.4              desctype desc;                      \
    34.5              PAD32(sizeof(desctype));            \
    34.6          } desc;                                 \
    34.7 -    } type
    34.8 +    } __attribute__ ((packed)) type
    34.9  
   34.10  #define CORE_STR                "CORE"
   34.11  #define CORE_STR_LEN            5 /* including terminating zero */
   34.12 @@ -119,7 +119,7 @@ typedef struct {
   34.13      crash_note_core_t core;
   34.14      crash_note_xen_core_t xen_regs;
   34.15      crash_note_xen_info_t xen_info;
   34.16 -} crash_note_t;
   34.17 +} __attribute__ ((packed)) crash_note_t;
   34.18  
   34.19  #define setup_crash_note(np, member, str, str_len, id) \
   34.20    np->member.note.note.note.namesz = str_len; \