ia64/xen-unstable

changeset 7691:a5195bf5671d

Merged.
author emellor@leeni.uk.xensource.com
date Tue Nov 08 12:31:43 2005 +0100 (2005-11-08)
parents 8e1703090053 1470a9d40072
children 6e2225934d84 e2bb85722b91
files
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen-mkbuildtree-pre	Tue Nov 08 12:30:38 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen-mkbuildtree-pre	Tue Nov 08 12:31:43 2005 +0100
     1.3 @@ -48,10 +48,10 @@ cp arch/ia64/xen/drivers/evtchn_ia64.c d
     1.4  cp arch/ia64/xen/drivers/motherboard.c drivers/acpi/motherboard.c
     1.5  
     1.6  #still a few x86-ism's in various drivers/xen files, patch them
     1.7 -cd drivers/xen
     1.8 -if [ ! -e ia64.patch.semaphore ]
     1.9 -then
    1.10 -	cat ../../arch/ia64/xen/drivers/patches/* | patch -p1 -b
    1.11 -fi
    1.12 -touch ia64.patch.semaphore
    1.13 -cd ../..
    1.14 +#cd drivers/xen
    1.15 +#if [ ! -e ia64.patch.semaphore ]
    1.16 +#then
    1.17 +#	cat ../../arch/ia64/xen/drivers/patches/* | patch -p1 -b
    1.18 +#fi
    1.19 +#touch ia64.patch.semaphore
    1.20 +#cd ../..
     2.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Tue Nov 08 12:30:38 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/Makefile	Tue Nov 08 12:31:43 2005 +0100
     2.3 @@ -2,4 +2,4 @@
     2.4  # Makefile for Xen components
     2.5  #
     2.6  
     2.7 -obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o
     2.8 +obj-y := hypercall.o xenivt.o xenentry.o xensetup.o xenpal.o xenhpski.o xenconsole.o xen_ksyms.o
     3.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c	Tue Nov 08 12:30:38 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/evtchn_ia64.c	Tue Nov 08 12:31:43 2005 +0100
     3.3 @@ -22,6 +22,7 @@ unsigned int bind_virq_to_evtchn(int vir
     3.4  
     3.5      op.cmd = EVTCHNOP_bind_virq;
     3.6      op.u.bind_virq.virq = virq;
     3.7 +    op.u.bind_virq.vcpu = 0;
     3.8      if ( HYPERVISOR_event_channel_op(&op) != 0 )
     3.9          BUG();
    3.10  
     4.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/console.c.patch	Tue Nov 08 12:30:38 2005 +0100
     4.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/console.c.patch	Tue Nov 08 12:31:43 2005 +0100
     4.3 @@ -1,7 +1,6 @@
     4.4 -diff -Naur xen/console/console.c xen.patched/console/console.c
     4.5 ---- xen/console/console.c	2005-09-23 10:54:50.000000000 -0600
     4.6 -+++ xen.patched/console/console.c	2005-09-23 10:57:51.000000000 -0600
     4.7 -@@ -768,9 +768,16 @@
     4.8 +--- xen/console/console.c	2005-11-02 14:13:07.000000000 +0100
     4.9 ++++ xen.patched/console/console.c	2005-11-02 14:21:20.000000000 +0100
    4.10 +@@ -768,9 +771,15 @@
    4.11   #endif
    4.12   
    4.13   	if (xen_start_info->flags & SIF_INITDOMAIN) {
    4.14 @@ -10,8 +9,7 @@ diff -Naur xen/console/console.c xen.pat
    4.15  +		bind_evtchn_to_irqhandler(xencons_priv_irq,
    4.16  +				xencons_priv_interrupt, 0, "console", NULL);
    4.17  +#else
    4.18 -+
    4.19 - 		xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE);
    4.20 + 		xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
    4.21   		(void)request_irq(xencons_priv_irq,
    4.22   				  xencons_priv_interrupt, 0, "console", NULL);
    4.23  +#endif
     5.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/devmem.c.patch	Tue Nov 08 12:30:38 2005 +0100
     5.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/devmem.c.patch	Tue Nov 08 12:31:43 2005 +0100
     5.3 @@ -1,13 +1,3 @@
     5.4  diff -Naur xen/core/devmem.c xen.patched/core/devmem.c
     5.5  --- xen/core/devmem.c	2005-09-23 10:54:50.000000000 -0600
     5.6  +++ xen.patched/core/devmem.c	2005-09-23 10:57:51.000000000 -0600
     5.7 -@@ -93,6 +93,9 @@
     5.8 - 	if (uncached_access(file))
     5.9 - 		vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
    5.10 - 
    5.11 -+#ifdef __ia64__
    5.12 -+#define	direct_remap_pfn_range(a,b,c,d,e,f)	remap_pfn_range(a,b,c,d,e)
    5.13 -+#endif
    5.14 - 	if (direct_remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
    5.15 - 				   vma->vm_end - vma->vm_start,
    5.16 - 				   vma->vm_page_prot, DOMID_IO))
     6.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/gnttab.c.patch	Tue Nov 08 12:30:38 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/gnttab.c.patch	Tue Nov 08 12:31:43 2005 +0100
     6.3 @@ -1,17 +1,6 @@
     6.4  diff -Naur xen/core/gnttab.c xen.patched/core/gnttab.c
     6.5  --- xen/core/gnttab.c	2005-09-23 10:54:50.000000000 -0600
     6.6  +++ xen.patched/core/gnttab.c	2005-09-23 10:57:51.000000000 -0600
     6.7 -@@ -19,6 +19,10 @@
     6.8 - #include <asm-xen/gnttab.h>
     6.9 - #include <asm/synch_bitops.h>
    6.10 - 
    6.11 -+#ifdef __ia64__
    6.12 -+#define synch_cmpxchg	ia64_cmpxchg4_acq
    6.13 -+#endif
    6.14 -+
    6.15 - #if 1
    6.16 - #define ASSERT(_p)							      \
    6.17 - 	if ( !(_p) ) { printk(KERN_ALERT"Assertion '%s': line %d, file %s\n", \
    6.18  @@ -346,6 +350,10 @@
    6.19   	if ( hypercall.op != __HYPERVISOR_grant_table_op )
    6.20   		return -ENOSYS;
    6.21 @@ -45,17 +34,6 @@ diff -Naur xen/core/gnttab.c xen.patched
    6.22   
    6.23   	return 0;
    6.24   }
    6.25 -@@ -434,8 +448,10 @@
    6.26 - {
    6.27 - 	int i;
    6.28 - 
    6.29 -+#ifndef __ia64__
    6.30 - 	for (i = 0; i < NR_GRANT_FRAMES; i++)
    6.31 - 		clear_fixmap(FIX_GNTTAB_END - i);
    6.32 -+#endif
    6.33 - 
    6.34 - 	return 0;
    6.35 - }
    6.36  @@ -450,7 +466,9 @@
    6.37   
    6.38   	BUG_ON(gnttab_resume());
     7.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/privcmd.c.patch	Tue Nov 08 12:30:38 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/drivers/patches/privcmd.c.patch	Tue Nov 08 12:31:43 2005 +0100
     7.3 @@ -1,49 +1,43 @@
     7.4  diff -Naur xen/privcmd/privcmd.c xen.patched/privcmd/privcmd.c
     7.5  --- xen/privcmd/privcmd.c	2005-09-23 10:54:50.000000000 -0600
     7.6  +++ xen.patched/privcmd/privcmd.c	2005-09-23 10:57:51.000000000 -0600
     7.7 -@@ -134,6 +134,9 @@
     7.8 - 				    > vma->vm_end )
     7.9 - 					return -EINVAL;
    7.10 +@@ -180,6 +183,15 @@
    7.11 + 		for (i = 0; i < m.num; i++, addr += PAGE_SIZE, p++) {
    7.12 + 			if (get_user(mfn, p))
    7.13 + 				return -EFAULT;
    7.14 ++#ifdef __ia64__
    7.15 ++			ret = remap_pfn_range(vma,
    7.16 ++					      addr&PAGE_MASK,
    7.17 ++					      mfn,
    7.18 ++					      1<<PAGE_SHIFT,
    7.19 ++					      vma->vm_page_prot);
    7.20 ++			if (ret < 0)
    7.21 ++			    goto batch_err;
    7.22 ++#else
    7.23   
    7.24 -+#ifdef __ia64__
    7.25 -+#define	direct_remap_pfn_range(a,b,c,d,e,f) remap_pfn_range(a,b,c,d,e)
    7.26 + 			ret = create_lookup_pte_addr(vma->vm_mm, addr, &ptep);
    7.27 + 			if (ret)
    7.28 +@@ -190,6 +202,7 @@
    7.29 + 
    7.30 + 			if (HYPERVISOR_mmu_update(&u, 1, NULL, m.dom) < 0)
    7.31 + 				put_user(0xF0000000 | mfn, p);
    7.32  +#endif
    7.33 - 				if ((rc = direct_remap_pfn_range(
    7.34 - 					vma,
    7.35 - 					msg[j].va&PAGE_MASK, 
    7.36 -@@ -148,6 +151,7 @@
    7.37 - 	}
    7.38 - 	break;
    7.39 + 		}
    7.40   
    7.41 -+#ifndef __ia64__
    7.42 - 	case IOCTL_PRIVCMD_MMAPBATCH: {
    7.43 - 		mmu_update_t u;
    7.44 - 		privcmd_mmapbatch_t m;
    7.45 -@@ -206,7 +210,9 @@
    7.46 - 	}
    7.47 + 		ret = 0;
    7.48 +@@ -205,6 +218,7 @@
    7.49   	break;
    7.50   #endif
    7.51 -+#endif
    7.52   
    7.53  +#ifndef __ia64__
    7.54   	case IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN: {
    7.55   		unsigned long m2pv = (unsigned long)machine_to_phys_mapping;
    7.56   		pgd_t *pgd = pgd_offset_k(m2pv);
    7.57 -@@ -218,6 +224,7 @@
    7.58 +@@ -216,6 +230,7 @@
    7.59   			-EFAULT: 0;
    7.60   	}
    7.61   	break;
    7.62  +#endif
    7.63   
    7.64 - 	case IOCTL_PRIVCMD_INITDOMAIN_STORE: {
    7.65 - 		extern int do_xenbus_probe(void*);
    7.66 -@@ -241,6 +248,9 @@
    7.67 - 
    7.68 - 		/* Initial connect. Setup channel and page. */
    7.69 - 		xen_start_info->store_evtchn = data;
    7.70 -+#ifdef __ia64__
    7.71 -+#define	pfn_to_mfn(x)	(x)
    7.72 -+#endif
    7.73 - 		xen_start_info->store_mfn =
    7.74 - 			pfn_to_mfn(virt_to_phys((void *)page) >>
    7.75 - 				   PAGE_SHIFT);
    7.76 + 	default:
    7.77 + 		ret = -EINVAL;
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xen_ksyms.c	Tue Nov 08 12:31:43 2005 +0100
     8.3 @@ -0,0 +1,12 @@
     8.4 +/*
     8.5 + * Architecture-specific kernel symbols
     8.6 + *
     8.7 + * Don't put any exports here unless it's defined in an assembler file.
     8.8 + * All other exports should be put directly after the definition.
     8.9 + */
    8.10 +
    8.11 +#include <linux/config.h>
    8.12 +#include <linux/module.h>
    8.13 +
    8.14 +extern int is_running_on_xen(void);
    8.15 +EXPORT_SYMBOL(is_running_on_xen);
     9.1 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Tue Nov 08 12:30:38 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xensetup.S	Tue Nov 08 12:31:43 2005 +0100
     9.3 @@ -25,3 +25,9 @@ GLOBAL_ENTRY(early_xen_setup)
     9.4  (p7)	mov cr.iva=r10
     9.5  	br.ret.sptk.many rp;;
     9.6  END(xen_init)
     9.7 +
     9.8 +GLOBAL_ENTRY(is_running_on_xen)
     9.9 +	movl r9=running_on_xen;;
    9.10 +	ld4 r8=[r9];;
    9.11 +	br.ret.sptk.many rp;;
    9.12 +END(is_running_on_xen)
    10.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c	Tue Nov 08 12:30:38 2005 +0100
    10.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/devmem.c	Tue Nov 08 12:31:43 2005 +0100
    10.3 @@ -26,6 +26,7 @@
    10.4  #include <asm/pgalloc.h>
    10.5  #include <asm/uaccess.h>
    10.6  #include <asm/io.h>
    10.7 +#include <asm/hypervisor.h>
    10.8  
    10.9  static inline int uncached_access(struct file *file)
   10.10  {
    11.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Tue Nov 08 12:30:38 2005 +0100
    11.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/gnttab.c	Tue Nov 08 12:31:43 2005 +0100
    11.3 @@ -337,49 +337,7 @@ gnttab_request_free_callback(struct gntt
    11.4  #ifdef CONFIG_PROC_FS
    11.5  
    11.6  static struct proc_dir_entry *grant_pde;
    11.7 -
    11.8 -static int
    11.9 -grant_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
   11.10 -	    unsigned long data)
   11.11 -{
   11.12 -	int                     ret;
   11.13 -	privcmd_hypercall_t     hypercall;
   11.14 -
   11.15 -	/*
   11.16 -	 * XXX Need safety checks here if using for anything other
   11.17 -	 *     than debugging.
   11.18 -	 */
   11.19 -	return -ENOSYS;
   11.20 -
   11.21 -	if ( cmd != IOCTL_PRIVCMD_HYPERCALL )
   11.22 -		return -ENOSYS;
   11.23 -
   11.24 -	if ( copy_from_user(&hypercall, (void *)data, sizeof(hypercall)) )
   11.25 -		return -EFAULT;
   11.26 -
   11.27 -	if ( hypercall.op != __HYPERVISOR_grant_table_op )
   11.28 -		return -ENOSYS;
   11.29 -
   11.30 -	/* hypercall-invoking asm taken from privcmd.c */
   11.31 -	__asm__ __volatile__ (
   11.32 -		"pushl %%ebx; pushl %%ecx; pushl %%edx; "
   11.33 -		"pushl %%esi; pushl %%edi; "
   11.34 -		"movl  4(%%eax),%%ebx ;"
   11.35 -		"movl  8(%%eax),%%ecx ;"
   11.36 -		"movl 12(%%eax),%%edx ;"
   11.37 -		"movl 16(%%eax),%%esi ;"
   11.38 -		"movl 20(%%eax),%%edi ;"
   11.39 -		"movl   (%%eax),%%eax ;"
   11.40 -		TRAP_INSTR "; "
   11.41 -		"popl %%edi; popl %%esi; popl %%edx; popl %%ecx; popl %%ebx"
   11.42 -		: "=a" (ret) : "0" (&hypercall) : "memory" );
   11.43 -
   11.44 -	return ret;
   11.45 -}
   11.46 -
   11.47 -static struct file_operations grant_file_ops = {
   11.48 -	ioctl:  grant_ioctl,
   11.49 -};
   11.50 +static struct file_operations grant_file_ops;
   11.51  
   11.52  static int
   11.53  grant_read(char *page, char **start, off_t off, int count, int *eof,
   11.54 @@ -437,8 +395,13 @@ gnttab_resume(void)
   11.55  	BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1));
   11.56  	BUG_ON(setup.status != 0);
   11.57  
   11.58 +#ifdef __ia64__
   11.59 +	shared = __va(frames[0] << PAGE_SHIFT);
   11.60 +	printk("grant table at %p\n", shared);
   11.61 +#else
   11.62  	for (i = 0; i < NR_GRANT_FRAMES; i++)
   11.63  		set_fixmap(FIX_GNTTAB_END - i, frames[i] << PAGE_SHIFT);
   11.64 +#endif
   11.65  
   11.66  	return 0;
   11.67  }
   11.68 @@ -464,7 +427,9 @@ gnttab_init(void)
   11.69  
   11.70  	BUG_ON(gnttab_resume());
   11.71  
   11.72 +#ifndef __ia64__
   11.73  	shared = (grant_entry_t *)fix_to_virt(FIX_GNTTAB_END);
   11.74 +#endif
   11.75  
   11.76  	for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++)
   11.77  		gnttab_list[i] = i + 1;
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Nov 08 12:30:38 2005 +0100
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Tue Nov 08 12:31:43 2005 +0100
    12.3 @@ -13,6 +13,7 @@
    12.4  
    12.5  #include <linux/spinlock.h>
    12.6  #include <asm-xen/balloon.h>
    12.7 +#include <asm/hypervisor.h>
    12.8  #include "common.h"
    12.9  
   12.10  /*
   12.11 @@ -30,10 +31,16 @@
   12.12  static unsigned long mmap_vstart;
   12.13  #define MMAP_PAGES						\
   12.14  	(MAX_PENDING_REQS * BLKIF_MAX_SEGMENTS_PER_REQUEST)
   12.15 +#ifdef __ia64__
   12.16 +static void *pending_vaddrs[MMAP_PAGES];
   12.17 +#define MMAP_VADDR(_idx, _i) \
   12.18 +	(unsigned long)(pending_vaddrs[((_idx) * BLKIF_MAX_SEGMENTS_PER_REQUEST) + (_i)])
   12.19 +#else
   12.20  #define MMAP_VADDR(_req,_seg)						\
   12.21  	(mmap_vstart +							\
   12.22  	 ((_req) * BLKIF_MAX_SEGMENTS_PER_REQUEST * PAGE_SIZE) +	\
   12.23  	 ((_seg) * PAGE_SIZE))
   12.24 +#endif
   12.25  
   12.26  /*
   12.27   * Each outstanding request that we've passed to the lower device layers has a 
   12.28 @@ -376,9 +383,13 @@ static void dispatch_rw_block_io(blkif_t
   12.29  	for (i = 0; i < nseg; i++) {
   12.30  		if (likely(map[i].handle >= 0)) {
   12.31  			pending_handle(pending_idx, i) = map[i].handle;
   12.32 +#ifdef __ia64__
   12.33 +			MMAP_VADDR(pending_idx,i) = gnttab_map_vaddr(map[i]);
   12.34 +#else
   12.35  			phys_to_machine_mapping[__pa(MMAP_VADDR(
   12.36  				pending_idx, i)) >> PAGE_SHIFT] =
   12.37  				FOREIGN_FRAME(map[i].dev_bus_addr>>PAGE_SHIFT);
   12.38 +#endif
   12.39  			fas        = req->frame_and_sects[i];
   12.40  			seg[i].buf = map[i].dev_bus_addr | 
   12.41  				(blkif_first_sect(fas) << 9);
   12.42 @@ -501,11 +512,27 @@ static int __init blkif_init(void)
   12.43  	for (i = 0; i < MMAP_PAGES; i++)
   12.44  		pending_grant_handles[i] = BLKBACK_INVALID_HANDLE;
   12.45  
   12.46 +	if (xen_init() < 0)
   12.47 +		return -ENODEV;
   12.48 +
   12.49  	blkif_interface_init();
   12.50  
   12.51 +#ifdef __ia64__
   12.52 +    {
   12.53 +	extern unsigned long alloc_empty_foreign_map_page_range(unsigned long pages);
   12.54 +	int i;
   12.55 +
   12.56 +	mmap_vstart =  alloc_empty_foreign_map_page_range(MMAP_PAGES);
   12.57 +	printk("Allocated mmap_vstart: 0x%lx\n", mmap_vstart);
   12.58 +	for(i = 0; i < MMAP_PAGES; i++)
   12.59 +	    pending_vaddrs[i] = mmap_vstart + (i << PAGE_SHIFT);
   12.60 +	BUG_ON(mmap_vstart == NULL);
   12.61 +    }
   12.62 +#else
   12.63  	page = balloon_alloc_empty_page_range(MMAP_PAGES);
   12.64  	BUG_ON(page == NULL);
   12.65  	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
   12.66 +#endif
   12.67  
   12.68  	pending_cons = 0;
   12.69  	pending_prod = MAX_PENDING_REQS;
    13.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Nov 08 12:30:38 2005 +0100
    13.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Nov 08 12:31:43 2005 +0100
    13.3 @@ -49,6 +49,7 @@
    13.4  #include <asm-xen/xenbus.h>
    13.5  #include <asm-xen/xen-public/grant_table.h>
    13.6  #include <asm-xen/gnttab.h>
    13.7 +#include <asm/hypervisor.h>
    13.8  
    13.9  #define BLKIF_STATE_DISCONNECTED 0
   13.10  #define BLKIF_STATE_CONNECTED    1
   13.11 @@ -728,6 +729,9 @@ static struct xenbus_driver blkfront = {
   13.12  
   13.13  static int __init xlblk_init(void)
   13.14  {
   13.15 +	if (xen_init() < 0)
   13.16 +		return -ENODEV;
   13.17 +
   13.18  	xenbus_register_driver(&blkfront);
   13.19  	return 0;
   13.20  }
    14.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/console.c	Tue Nov 08 12:30:38 2005 +0100
    14.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/console.c	Tue Nov 08 12:31:43 2005 +0100
    14.3 @@ -196,6 +196,9 @@ static int __init xen_console_init(void)
    14.4  void xen_console_init(void)
    14.5  #endif
    14.6  {
    14.7 +	if (xen_init() < 0)
    14.8 +		return __RETCODE;
    14.9 +
   14.10  	if (xen_start_info->flags & SIF_INITDOMAIN) {
   14.11  		if (xc_mode == XC_DEFAULT)
   14.12  			xc_mode = XC_SERIAL;
   14.13 @@ -768,9 +771,15 @@ static int __init xencons_init(void)
   14.14  #endif
   14.15  
   14.16  	if (xen_start_info->flags & SIF_INITDOMAIN) {
   14.17 +#ifdef __ia64__
   14.18 +		xencons_priv_irq = bind_virq_to_evtchn(VIRQ_CONSOLE);
   14.19 +		bind_evtchn_to_irqhandler(xencons_priv_irq,
   14.20 +				xencons_priv_interrupt, 0, "console", NULL);
   14.21 +#else
   14.22  		xencons_priv_irq = bind_virq_to_irq(VIRQ_CONSOLE, 0);
   14.23  		(void)request_irq(xencons_priv_irq,
   14.24  				  xencons_priv_interrupt, 0, "console", NULL);
   14.25 +#endif
   14.26  	} else {
   14.27  		xencons_ring_register_receiver(xencons_rx);
   14.28  	}
    15.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Tue Nov 08 12:30:38 2005 +0100
    15.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Tue Nov 08 12:31:43 2005 +0100
    15.3 @@ -20,6 +20,7 @@
    15.4  #include <linux/pagemap.h>
    15.5  #include <linux/seq_file.h>
    15.6  #include <linux/kthread.h>
    15.7 +#include <asm/hypervisor.h>
    15.8  
    15.9  #include <asm/pgalloc.h>
   15.10  #include <asm/pgtable.h>
   15.11 @@ -180,6 +181,15 @@ static int privcmd_ioctl(struct inode *i
   15.12  		for (i = 0; i < m.num; i++, addr += PAGE_SIZE, p++) {
   15.13  			if (get_user(mfn, p))
   15.14  				return -EFAULT;
   15.15 +#ifdef __ia64__
   15.16 +			ret = remap_pfn_range(vma,
   15.17 +					      addr&PAGE_MASK,
   15.18 +					      mfn,
   15.19 +					      1<<PAGE_SHIFT,
   15.20 +					      vma->vm_page_prot);
   15.21 +			if (ret < 0)
   15.22 +			    goto batch_err;
   15.23 +#else
   15.24  
   15.25  			ret = create_lookup_pte_addr(vma->vm_mm, addr, &ptep);
   15.26  			if (ret)
   15.27 @@ -190,6 +200,7 @@ static int privcmd_ioctl(struct inode *i
   15.28  
   15.29  			if (HYPERVISOR_mmu_update(&u, 1, NULL, m.dom) < 0)
   15.30  				put_user(0xF0000000 | mfn, p);
   15.31 +#endif
   15.32  		}
   15.33  
   15.34  		ret = 0;
   15.35 @@ -205,6 +216,7 @@ static int privcmd_ioctl(struct inode *i
   15.36  	break;
   15.37  #endif
   15.38  
   15.39 +#ifndef __ia64__
   15.40  	case IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN: {
   15.41  		unsigned long m2pv = (unsigned long)machine_to_phys_mapping;
   15.42  		pgd_t *pgd = pgd_offset_k(m2pv);
   15.43 @@ -216,6 +228,7 @@ static int privcmd_ioctl(struct inode *i
   15.44  			-EFAULT: 0;
   15.45  	}
   15.46  	break;
   15.47 +#endif
   15.48  
   15.49  	default:
   15.50  		ret = -EINVAL;
    16.1 --- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Tue Nov 08 12:30:38 2005 +0100
    16.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h	Tue Nov 08 12:31:43 2005 +0100
    16.3 @@ -36,7 +36,12 @@
    16.4  #endif
    16.5  
    16.6  #ifndef __ASSEMBLY__
    16.7 +#ifdef MODULE
    16.8 +extern int is_running_on_xen(void);
    16.9 +#define running_on_xen (is_running_on_xen())
   16.10 +#else
   16.11  extern int running_on_xen;
   16.12 +#endif
   16.13  
   16.14  #define	XEN_HYPER_SSM_I			asm("break 0x7");
   16.15  #define	XEN_HYPER_GET_IVR		asm("break 0x8");
    17.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/fixmap.h	Tue Nov 08 12:30:38 2005 +0100
    17.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/fixmap.h	Tue Nov 08 12:31:43 2005 +0100
    17.3 @@ -1,1 +1,2 @@
    17.4 -/* empty */
    17.5 +#define clear_fixmap(x)	do {} while (0)
    17.6 +#define	set_fixmap(x,y)	do {} while (0)
    18.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/synch_bitops.h	Tue Nov 08 12:30:38 2005 +0100
    18.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-ia64/synch_bitops.h	Tue Nov 08 12:31:43 2005 +0100
    18.3 @@ -51,6 +51,8 @@ static __inline__ int synch_var_test_bit
    18.4      return test_bit(nr, addr);
    18.5  }
    18.6  
    18.7 +#define synch_cmpxchg	ia64_cmpxchg4_acq
    18.8 +
    18.9  #define synch_test_bit(nr,addr) \
   18.10  (__builtin_constant_p(nr) ? \
   18.11   synch_const_test_bit((nr),(addr)) : \
    19.1 --- a/tools/examples/Makefile	Tue Nov 08 12:30:38 2005 +0100
    19.2 +++ b/tools/examples/Makefile	Tue Nov 08 12:31:43 2005 +0100
    19.3 @@ -26,14 +26,14 @@ XEN_SCRIPTS += network-route vif-route
    19.4  XEN_SCRIPTS += network-nat vif-nat
    19.5  XEN_SCRIPTS += block
    19.6  XEN_SCRIPTS += block-enbd block-nbd
    19.7 -XEN_SCRIPTS += xen-script-common.sh
    19.8 -XEN_SCRIPTS += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
    19.9 -XEN_SCRIPTS += block-common.sh
   19.10 +XEN_SCRIPT_DATA = xen-script-common.sh
   19.11 +XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
   19.12 +XEN_SCRIPT_DATA += block-common.sh
   19.13  
   19.14  XEN_HOTPLUG_DIR = /etc/hotplug
   19.15  XEN_HOTPLUG_SCRIPTS = xen-backend.agent
   19.16  
   19.17 -UDEV_RULES_DIR = /etc/udev/rules.d
   19.18 +UDEV_RULES_DIR = /etc/udev
   19.19  UDEV_RULES = xen-backend.rules
   19.20  
   19.21  DI = $(shell readlink -f $(DISTDIR))
   19.22 @@ -77,6 +77,10 @@ install-scripts:
   19.23  	    do \
   19.24  	    $(INSTALL_PROG) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
   19.25  	done
   19.26 +	for i in $(XEN_SCRIPT_DATA); \
   19.27 +	    do \
   19.28 +	    $(INSTALL_DATA) $$i $(DESTDIR)$(XEN_SCRIPT_DIR); \
   19.29 +	done
   19.30  
   19.31  install-hotplug:
   19.32  	[ -d $(DESTDIR)$(XEN_HOTPLUG_DIR) ] || \
   19.33 @@ -88,10 +92,12 @@ install-hotplug:
   19.34  
   19.35  install-udev:
   19.36  	[ -d $(DESTDIR)$(UDEV_RULES_DIR) ] || \
   19.37 -		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)
   19.38 +		$(INSTALL_DIR) $(DESTDIR)$(UDEV_RULES_DIR)/rules.d
   19.39  	for i in $(UDEV_RULES); \
   19.40  	    do \
   19.41 -	    $(INSTALL_PROG) $$i $(DESTDIR)$(UDEV_RULES_DIR); \
   19.42 +	    $(INSTALL_DATA) $$i $(DESTDIR)$(UDEV_RULES_DIR); \
   19.43 +	    ( cd $(DESTDIR)$(UDEV_RULES_DIR)/rules.d ; \
   19.44 +	        ln -sf ../$$i . ) \
   19.45  	done
   19.46  
   19.47  clean:
    20.1 --- a/tools/examples/README	Tue Nov 08 12:30:38 2005 +0100
    20.2 +++ b/tools/examples/README	Tue Nov 08 12:31:43 2005 +0100
    20.3 @@ -9,20 +9,29 @@ If you write a useful script and would l
    20.4  send it (preferably with a little summary to go in this file) to
    20.5  <xen-devel@lists.sourceforge.net> so we can add it to this directory.
    20.6  
    20.7 +block               - called by xen-backend.agent to bind/unbind dev  
    20.8 +block-common.sh     - sourced by block, block-*
    20.9  block-enbd          - binds/unbinds network block devices
   20.10 -block-file          - binds/unbinds file to loopback device
   20.11 -mem-map.sxp         - memory map xend configuration file.
   20.12 -network             - default network setup script called by xend at startup.
   20.13 -network-route       - default xen network start/stop script.
   20.14 -network-nat         - default xen network start/stop script when using NAT.
   20.15 -vif-bridge          - default virtual network interface setup script.
   20.16 -vif-route           - default xen virtual network start/stop script
   20.17 -vif-nat             - configures vif in routed-nat mode.
   20.18 -xend-config.sxp     - default xend configuration file.
   20.19 -xmexample1          - example configuration script for 'xm create'.
   20.20 -xmexample2          - a more complex configuration script for 'xm create'.
   20.21 +block-nbd           - binds/unbinds network block devices
   20.22 +network-bridge      - xen network start/stop script when using bridging
   20.23 +network-nat         - xen network start/stop script when using NAT
   20.24 +network-route       - xen network start/stop script when using routing
   20.25 +vif-bridge          - virtual network start/stop script in bridged mode
   20.26 +vif-common.sh       - sourced by vif-bridge 
   20.27 +vif-nat             - xen virtual network start/stop script in NAT mode 
   20.28 +vif-route           - xen virtual network start/stop script in routed mode
   20.29 +xen-backend.agent   - calls block, vif-* scripts to add, remove, hotplug 
   20.30 +                      devices  
   20.31 +xen-backend.rules   - hotplug script rules
   20.32 +xend-config.sxp     - default xend configuration file
   20.33 +xen-hotplug-common.sh - sourced by vif-common.sh
   20.34 +xen-network-common.sh - sourced by vif-common.sh
   20.35 +xen-script-common.sh  - sourced by network-bridge, xen-hotplug-common.sh
   20.36 +xmexample1          - example configuration script for 'xm create'
   20.37 +xmexample2          - a more complex configuration script for 'xm create'
   20.38  xmexample3          - an advanced configuration script for 'xm create' 
   20.39 -                      that utilizes the vmid.
   20.40 +                      that utilizes the vmid
   20.41 +xmexample.nbd       - configuration script that uses NBD filesystems
   20.42  xmexample.vmx       - a configuration script for creating a vmx domain with
   20.43 -                      'xm create'.
   20.44 -
   20.45 +                      'xm create'
   20.46 +xmexample.vti       - a configuration script for creating a domain on vti
    21.1 --- a/tools/python/xen/xend/image.py	Tue Nov 08 12:30:38 2005 +0100
    21.2 +++ b/tools/python/xen/xend/image.py	Tue Nov 08 12:31:43 2005 +0100
    21.3 @@ -24,6 +24,7 @@ import xen.lowlevel.xc
    21.4  from xen.xend import sxp
    21.5  from xen.xend.XendError import VmError
    21.6  from xen.xend.XendLogging import log
    21.7 +from xen.xend.server.netif import randomMAC
    21.8  
    21.9  
   21.10  xc = xen.lowlevel.xc.new()
   21.11 @@ -276,6 +277,8 @@ class VmxImageHandler(ImageHandler):
   21.12                 ret.append("%s" % vbdparam)
   21.13              if name == 'vif':
   21.14                 mac = sxp.child_value(info, 'mac')
   21.15 +               if mac == None:
   21.16 +                   mac = randomMAC()
   21.17                 ret.append("-macaddr")
   21.18                 ret.append("%s" % mac)
   21.19              if name == 'vtpm':
    22.1 --- a/tools/xenstore/Makefile	Tue Nov 08 12:30:38 2005 +0100
    22.2 +++ b/tools/xenstore/Makefile	Tue Nov 08 12:31:43 2005 +0100
    22.3 @@ -77,7 +77,7 @@ libxenstore.so: xs.opic xs_lib.opic
    22.4  clean: testsuite-clean
    22.5  	rm -f *.o *.opic *.so
    22.6  	rm -f xenstored xs_random xs_stress xs_crashme
    22.7 -	rm -f xs_test xenstored_test xs_tdb_dump
    22.8 +	rm -f xs_test xenstored_test xs_tdb_dump xsls $(CLIENTS)
    22.9  	$(RM) $(PROG_DEP)
   22.10  
   22.11  print-dir:
    23.1 --- a/xen/arch/ia64/linux-xen/efi.c	Tue Nov 08 12:30:38 2005 +0100
    23.2 +++ b/xen/arch/ia64/linux-xen/efi.c	Tue Nov 08 12:31:43 2005 +0100
    23.3 @@ -24,7 +24,6 @@
    23.4  #include <linux/init.h>
    23.5  #include <linux/types.h>
    23.6  #include <linux/time.h>
    23.7 -#include <linux/efi.h>
    23.8  
    23.9  #include <asm/io.h>
   23.10  #include <asm/kregs.h>
   23.11 @@ -33,6 +32,8 @@
   23.12  #include <asm/processor.h>
   23.13  #include <asm/mca.h>
   23.14  
   23.15 +#include <linux/efi.h>
   23.16 +
   23.17  #define EFI_DEBUG	0
   23.18  
   23.19  extern efi_status_t efi_call_phys (void *, ...);
    24.1 --- a/xen/arch/ia64/linux-xen/mm_contig.c	Tue Nov 08 12:30:38 2005 +0100
    24.2 +++ b/xen/arch/ia64/linux-xen/mm_contig.c	Tue Nov 08 12:31:43 2005 +0100
    24.3 @@ -16,7 +16,6 @@
    24.4   */
    24.5  #include <linux/config.h>
    24.6  #include <linux/bootmem.h>
    24.7 -#include <linux/efi.h>
    24.8  #include <linux/mm.h>
    24.9  #include <linux/swap.h>
   24.10  
   24.11 @@ -26,6 +25,7 @@
   24.12  #include <asm/sections.h>
   24.13  #include <asm/mca.h>
   24.14  
   24.15 +#include <linux/efi.h>
   24.16  #ifdef CONFIG_VIRTUAL_MEM_MAP
   24.17  static unsigned long num_dma_physpages;
   24.18  #endif
    25.1 --- a/xen/arch/ia64/xen/hypercall.c	Tue Nov 08 12:30:38 2005 +0100
    25.2 +++ b/xen/arch/ia64/xen/hypercall.c	Tue Nov 08 12:31:43 2005 +0100
    25.3 @@ -187,6 +187,10 @@ ia64_hypercall (struct pt_regs *regs)
    25.4  		regs->r8 = do_console_io(regs->r14, regs->r15, regs->r16);
    25.5  		break;
    25.6  
    25.7 +	    case __HYPERVISOR_xen_version:
    25.8 +		regs->r8 = do_xen_version(regs->r14, regs->r15);
    25.9 +		break;
   25.10 +
   25.11  	    default:
   25.12  		printf("unknown hypercall %x\n", regs->r2);
   25.13  		regs->r8 = (unsigned long)-1;
    26.1 --- a/xen/arch/ia64/xen/hyperprivop.S	Tue Nov 08 12:30:38 2005 +0100
    26.2 +++ b/xen/arch/ia64/xen/hyperprivop.S	Tue Nov 08 12:31:43 2005 +0100
    26.3 @@ -14,6 +14,7 @@
    26.4  #include <asm/system.h>
    26.5  #include <public/arch-ia64.h>
    26.6  
    26.7 +
    26.8  #define	_PAGE_PPN_MASK	0x0003fffffffff000 //asm/pgtable.h doesn't do assembly
    26.9  #define PAGE_PHYS	0x0010000000000761 //__pgprot(__DIRTY_BITS|_PAGE_PL_2|_PAGE_AR_RWX)
   26.10  #define _PAGE_PL_2	(2<<7)
   26.11 @@ -22,13 +23,14 @@
   26.12  #define FAST_HYPERPRIVOPS
   26.13  #define FAST_HYPERPRIVOP_CNT
   26.14  #define FAST_REFLECT_CNT
   26.15 -//#define FAST_TICK
   26.16 +//#define FAST_TICK // mostly working (unat problems) but default off for now
   26.17 +//#define FAST_TLB_MISS_REFLECT	// mostly working but default off for now
   26.18 +//#define FAST_ITC	// working but default off for now
   26.19  #define FAST_BREAK
   26.20  #define FAST_ACCESS_REFLECT
   26.21  #define FAST_RFI
   26.22  #define FAST_SSM_I
   26.23  #define FAST_PTC_GA
   26.24 -#undef FAST_ITC	// working but default off for now
   26.25  #undef RFI_TO_INTERRUPT // not working yet
   26.26  #endif
   26.27  
   26.28 @@ -57,7 +59,7 @@
   26.29  #endif
   26.30  
   26.31  // FIXME: turn off for now... but NaTs may crash Xen so re-enable soon!
   26.32 -//#define HANDLE_AR_UNAT
   26.33 +#define HANDLE_AR_UNAT
   26.34  
   26.35  // FIXME: This is defined in include/asm-ia64/hw_irq.h but this
   26.36  // doesn't appear to be include'able from assembly?
   26.37 @@ -495,19 +497,29 @@ GLOBAL_ENTRY(fast_tick_reflect)
   26.38  	.mem.offset 0,0; st8.spill [r2]=r30,16;
   26.39  	.mem.offset 8,0; st8.spill [r3]=r31,16 ;;
   26.40  #ifdef HANDLE_AR_UNAT
   26.41 -	// bank0 regs have no NaT bit, so ensure they are NaT clean
   26.42 -	mov r16=r0; mov r17=r0; mov r18=r0; mov r19=r0;
   26.43 -	mov r20=r0; mov r21=r0; mov r22=r0; mov r23=r0;
   26.44 -	mov r24=r0; mov r25=r0; mov r26=r0; mov r27=r0;
   26.45 -	mov r28=r0; mov r29=r0; mov r30=r0; movl r31=XSI_IPSR;;
   26.46 + 	// r16~r23 are preserved regsin bank0 regs, we need to restore them,
   26.47 +    // r24~r31 are scratch regs, we don't need to handle NaT bit,
   26.48 +    // because OS handler must assign it before access it
   26.49 +    ld8 r16=[r2],16;
   26.50 +    ld8 r17=[r3],16;;
   26.51 +    ld8 r18=[r2],16;
   26.52 +    ld8 r19=[r3],16;;
   26.53 +    ld8 r20=[r2],16;
   26.54 +    ld8 r21=[r3],16;;
   26.55 +    ld8 r22=[r2],16;
   26.56 +    ld8 r23=[r3],16;;
   26.57  #endif
   26.58 -	bsw.0 ;;
   26.59 -	mov r2=r30; mov r3=r29;;
   26.60 +    movl r31=XSI_IPSR;;
   26.61 +    bsw.0 ;;
   26.62 +    mov r24=ar.unat;
   26.63 +    mov r2=r30; mov r3=r29;;
   26.64  #ifdef HANDLE_AR_UNAT
   26.65 -	mov ar.unat=r28;
   26.66 +    mov ar.unat=r28;
   26.67  #endif
   26.68 -	adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
   26.69 -	st4 [r20]=r0 ;;
   26.70 +    adds r25=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18 ;
   26.71 +    adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
   26.72 +    st8 [r25]=r24;
   26.73 +    st4 [r20]=r0 ;;
   26.74  fast_tick_reflect_done:
   26.75  	mov pr=r31,-1 ;;
   26.76  	rfi
   26.77 @@ -649,19 +661,28 @@ ENTRY(fast_reflect)
   26.78  	.mem.offset 0,0; st8.spill [r2]=r30,16;
   26.79  	.mem.offset 8,0; st8.spill [r3]=r31,16 ;;
   26.80  #ifdef HANDLE_AR_UNAT
   26.81 -	// bank0 regs have no NaT bit, so ensure they are NaT clean
   26.82 -	mov r16=r0; mov r17=r0; mov r18=r0; mov r19=r0;
   26.83 -	mov r20=r0; mov r21=r0; mov r22=r0; mov r23=r0;
   26.84 -	mov r24=r0; mov r25=r0; mov r26=r0; mov r27=r0;
   26.85 -	mov r28=r0; mov r29=r0; mov r30=r0; movl r31=XSI_IPSR;;
   26.86 +	// r16~r23 are preserved regsin bank0 regs, we need to restore them,
   26.87 +    // r24~r31 are scratch regs, we don't need to handle NaT bit,
   26.88 +    // because OS handler must assign it before access it
   26.89 +	ld8 r16=[r2],16;
   26.90 +    ld8 r17=[r3],16;;
   26.91 +    ld8 r18=[r2],16;
   26.92 +    ld8 r19=[r3],16;;
   26.93 +	ld8 r20=[r2],16;
   26.94 +    ld8 r21=[r3],16;;
   26.95 +    ld8 r22=[r2],16;
   26.96 +    ld8 r23=[r3],16;;
   26.97  #endif
   26.98  	movl r31=XSI_IPSR;;
   26.99  	bsw.0 ;;
  26.100 +    mov r24=ar.unat;
  26.101  	mov r2=r30; mov r3=r29;;
  26.102  #ifdef HANDLE_AR_UNAT
  26.103  	mov ar.unat=r28;
  26.104  #endif
  26.105 +    adds r25=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18 ;
  26.106  	adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.107 +    st8 [r25]=r24;
  26.108  	st4 [r20]=r0 ;;
  26.109  	mov pr=r31,-1 ;;
  26.110  	rfi
  26.111 @@ -705,6 +726,251 @@ GLOBAL_ENTRY(fast_access_reflect)
  26.112  	st8 [r23]=r22;;
  26.113  	br.cond.sptk.many fast_reflect;;
  26.114  
  26.115 +// when we get to here, VHPT_CCHAIN_LOOKUP has failed and everything
  26.116 +// is as it was at the time of original miss.  We want to preserve that
  26.117 +// so if we get a nested fault, we can just branch to page_fault
  26.118 +GLOBAL_ENTRY(fast_tlb_miss_reflect)
  26.119 +#ifndef FAST_TLB_MISS_REFLECT // see beginning of file
  26.120 +	br.spnt.few page_fault ;;
  26.121 +#endif
  26.122 +	mov r31=pr
  26.123 +	mov r30=cr.ipsr
  26.124 +	mov r29=cr.iip
  26.125 +	mov r16=cr.isr
  26.126 +	mov r17=cr.ifa;;
  26.127 +	// for now, always take slow path for region 0 (e.g. metaphys mode)
  26.128 +	extr.u r21=r17,61,3;;
  26.129 +	cmp.eq p7,p0=r0,r21
  26.130 +(p7)	br.spnt.few page_fault ;;
  26.131 +	// always take slow path for PL0 (e.g. __copy_from_user)
  26.132 +	extr.u r21=r30,IA64_PSR_CPL0_BIT,2 ;;
  26.133 +	cmp.eq p7,p0=r21,r0
  26.134 +(p7)	br.spnt.few page_fault ;;
  26.135 +	// slow path if strange ipsr or isr bits set
  26.136 +	extr.u r21=r30,IA64_PSR_BE_BIT,1 ;;
  26.137 +	cmp.ne p7,p0=r21,r0
  26.138 +(p7)	br.spnt.few page_fault ;;
  26.139 +	extr.u r21=r30,IA64_PSR_PP_BIT,1 ;;
  26.140 +	cmp.ne p7,p0=r21,r0
  26.141 +(p7)	br.spnt.few page_fault ;;
  26.142 +	movl r21=IA64_ISR_IR|IA64_ISR_SP|IA64_ISR_NA ;;
  26.143 +	and r21=r16,r21;;
  26.144 +	cmp.ne p7,p0=r0,r21
  26.145 +(p7)	br.spnt.few page_fault ;;
  26.146 +	// also take slow path if virtual psr.ic=0
  26.147 +	movl r18=XSI_PSR_IC;;
  26.148 +	ld4 r21=[r18];;
  26.149 +	cmp.eq p7,p0=r0,r21
  26.150 +(p7)	br.spnt.few page_fault ;;
  26.151 +	// OK, if we get to here, we are doing a fast vcpu_translate.  Need to:
  26.152 +	// 1) look in the virtual TR's (pinned), if not there
  26.153 +	// 2) look in the 1-entry TLB (pinned), if not there
  26.154 +	// 3) check the domain VHPT (NOT pinned, accesses domain memory!)
  26.155 +	// If we find it in any of these places, we need to effectively do
  26.156 +	// a hyper_itc_i/d
  26.157 +
  26.158 +	// short-term hack for now, if in region 5-7, take slow path
  26.159 +	// since all Linux TRs are in region 5 or 7, we need not check TRs
  26.160 +	extr.u r21=r17,61,3;;
  26.161 +	cmp.le p7,p0=5,r21
  26.162 +(p7)	br.spnt.few page_fault ;;
  26.163 +fast_tlb_no_tr_match:
  26.164 +	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  26.165 +	ld8 r27=[r27];;
  26.166 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  26.167 +(p6)	adds r25=IA64_VCPU_ITLB_OFFSET,r27;;
  26.168 +(p7)	adds r25=IA64_VCPU_DTLB_OFFSET,r27;;
  26.169 +	ld8 r20=[r25],8;;
  26.170 +	tbit.z p7,p0=r20,0;;	// present?
  26.171 +(p7)	br.cond.spnt.few 1f;;
  26.172 +	// if ifa is in range of tlb, don't bother to check rid, go slow path
  26.173 +	ld8 r21=[r25],8;;
  26.174 +	mov r23=1
  26.175 +	extr.u r21=r21,2,6;;
  26.176 +	shl r22=r23,r21
  26.177 +	ld8 r21=[r25],8;;
  26.178 +	cmp.ltu p7,p0=r17,r21
  26.179 +(p7)	br.cond.sptk.many 1f;
  26.180 +	add r21=r22,r21;;
  26.181 +	cmp.ltu p7,p0=r17,r21
  26.182 +(p7)	br.cond.spnt.few page_fault;;
  26.183 +	
  26.184 +1:	// check the guest VHPT
  26.185 +	adds r19 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18;;
  26.186 +	ld8 r19=[r19];;
  26.187 +	tbit.nz p7,p0=r19,IA64_PTA_VF_BIT;;	// long format VHPT
  26.188 +(p7)	br.cond.spnt.few page_fault;;
  26.189 +	// if (!rr.ve || !(pta & IA64_PTA_VE)) take slow way for now
  26.190 +	// FIXME: later, we deliver an alt_d/i vector after thash and itir
  26.191 +	tbit.z p7,p0=r19,IA64_PTA_VE_BIT;;	// 
  26.192 +(p7)	br.cond.spnt.few page_fault;;
  26.193 +	extr.u r25=r17,61,3;;
  26.194 +	adds r21=XSI_RR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.195 +	shl r25=r25,3;;
  26.196 +	add r21=r21,r25;;
  26.197 +	ld8 r22=[r21];;
  26.198 +	tbit.z p7,p0=r22,0
  26.199 +(p7)	br.cond.spnt.few page_fault;;
  26.200 +
  26.201 +	// compute and save away itir (r22 & RR_PS_MASK)
  26.202 +	movl r21=0xfc;;
  26.203 +	and r22=r22,r21;;
  26.204 +	adds r21=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.205 +	st8 [r21]=r22;;
  26.206 +	
  26.207 +	// save away ifa
  26.208 +	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.209 +	st8 [r21]=r17;;
  26.210 +	// see vcpu_thash to save away iha
  26.211 +	shr.u r20 = r17, 61
  26.212 +	addl r25 = 1, r0
  26.213 +	movl r30 = 0xe000000000000000
  26.214 +	;;
  26.215 +	and r21 = r30, r17		// VHPT_Addr1
  26.216 +	;;
  26.217 +	shladd r28 = r20, 3, r18
  26.218 +	adds r19 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18
  26.219 +	;;
  26.220 +	adds r27 = XSI_RR0_OFS-XSI_PSR_IC_OFS, r28
  26.221 +	addl r28 = 32767, r0
  26.222 +	ld8 r24 = [r19]			// pta
  26.223 +	;;
  26.224 +	ld8 r23 = [r27]			// rrs[vadr>>61]
  26.225 +	extr.u r26 = r24, 2, 6
  26.226 +	;;
  26.227 +	extr.u r22 = r23, 2, 6
  26.228 +	shl r30 = r25, r26
  26.229 +	;;
  26.230 +	shr.u r19 = r17, r22
  26.231 +	shr.u r29 = r24, 15
  26.232 +	;;
  26.233 +	adds r30 = -1, r30
  26.234 +	;;
  26.235 +	shladd r27 = r19, 3, r0
  26.236 +	extr.u r26 = r30, 15, 46
  26.237 +	;;
  26.238 +	andcm r24 = r29, r26
  26.239 +	and r19 = r28, r27
  26.240 +	shr.u r25 = r27, 15
  26.241 +	;;
  26.242 +	and r23 = r26, r25
  26.243 +	;;
  26.244 +	or r22 = r24, r23
  26.245 +	;;
  26.246 +	dep.z r20 = r22, 15, 46
  26.247 +	;;
  26.248 +	or r30 = r20, r21
  26.249 +	;;
  26.250 +	//or r8 = r19, r30
  26.251 +	or r19 = r19, r30
  26.252 +	;;
  26.253 +	adds r23=XSI_IHA_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.254 +	st8 [r23]=r19;;
  26.255 +	// done with thash, check guest VHPT
  26.256 +
  26.257 +	adds r20 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18;;
  26.258 +	ld8 r24 = [r20];;			// pta
  26.259 +	// avoid recursively walking the VHPT
  26.260 +	// if (((r17=address ^ r24=pta) & ((itir_mask(pta) << 3) >> 3)) != 0) {
  26.261 +	mov r20=-8
  26.262 +	xor r21=r17,r24
  26.263 +	extr.u r24=r24,2,6;;
  26.264 +	shl r20=r20,r24;;
  26.265 +	shr.u r20=r20,3;;
  26.266 +	and r21=r20,r21;;
  26.267 +	cmp.eq p7,p0=r21,r0
  26.268 +(p7)	br.cond.spnt.few 1f;;
  26.269 +	// __copy_from_user(&pte, r19=(void *)(*iha), sizeof(pte)=8)
  26.270 +	// prepare for possible nested dtlb fault
  26.271 +	mov r29=b0
  26.272 +	movl r30=guest_vhpt_miss;;
  26.273 +	// now go fetch the entry from the guest VHPT
  26.274 +	ld8 r20=[r19];;
  26.275 +	// if we wind up here, we successfully loaded the VHPT entry
  26.276 +
  26.277 +	// this VHPT walker aborts on non-present pages instead
  26.278 +	// of inserting a not-present translation, this allows
  26.279 +	// vectoring directly to the miss handler
  26.280 +	tbit.z p7,p0=r20,0
  26.281 +(p7)	br.cond.spnt.few page_not_present;;
  26.282 +
  26.283 +#ifdef FAST_REFLECT_CNT
  26.284 +	movl r21=fast_vhpt_translate_count;;
  26.285 +	ld8 r22=[r21];;
  26.286 +	adds r22=1,r22;;
  26.287 +	st8 [r21]=r22;;
  26.288 +#endif
  26.289 +
  26.290 +// prepare for fast_insert(PSCB(ifa),PSCB(itir),r16=pte)
  26.291 +//	r16 == pte
  26.292 +//	r17 == bit0: 1=inst, 0=data; bit1: 1=itc, 0=vcpu_translate
  26.293 +//	r18 == XSI_PSR_IC_OFS
  26.294 +//	r24 == ps
  26.295 +//	r29 == saved value of b0 in case of recovery
  26.296 +//	r30 == recovery ip if failure occurs
  26.297 +//	r31 == pr
  26.298 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  26.299 +(p6)	mov r17=1;;
  26.300 +(p7)	mov r17=0;;
  26.301 +	mov r16=r20
  26.302 +	mov r29=b0 ;;
  26.303 +	movl r30=recover_and_page_fault ;;
  26.304 +	adds r21=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.305 +	ld8 r24=[r21];;
  26.306 +	extr.u r24=r24,2,6;;
  26.307 +	// IFA already in PSCB
  26.308 +	br.cond.sptk.many fast_insert;;
  26.309 +
  26.310 +// we get here if fast_insert fails (e.g. due to metaphysical lookup)
  26.311 +ENTRY(recover_and_page_fault)
  26.312 +#ifdef FAST_REFLECT_CNT
  26.313 +	movl r21=recover_to_page_fault_count;;
  26.314 +	ld8 r22=[r21];;
  26.315 +	adds r22=1,r22;;
  26.316 +	st8 [r21]=r22;;
  26.317 +#endif
  26.318 +	mov b0=r29;;
  26.319 +	br.cond.sptk.many page_fault;;
  26.320 +
  26.321 +// if we wind up here, we missed in guest VHPT so recover
  26.322 +// from nested dtlb fault and reflect a tlb fault to the guest
  26.323 +guest_vhpt_miss:
  26.324 +	mov b0=r29;;
  26.325 +	// fault = IA64_VHPT_FAULT
  26.326 +	mov r20=r0
  26.327 +	br.cond.sptk.many 1f;
  26.328 +
  26.329 +	// if we get to here, we are ready to reflect
  26.330 +	// need to set up virtual ifa, iha, itir (fast_reflect handles
  26.331 +	// virtual isr, iip, ipsr, ifs
  26.332 +	// see vcpu_get_itir_on_fault: get ps,rid,(FIXME key) from rr[ifa]
  26.333 +page_not_present:
  26.334 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  26.335 +(p6)	movl r20=0x400;;
  26.336 +(p7)	movl r20=0x800;;
  26.337 +
  26.338 +1:	extr.u r25=r17,61,3;;
  26.339 +	adds r21=XSI_RR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.340 +	shl r25=r25,3;;
  26.341 +	add r21=r21,r25;;
  26.342 +	ld8 r22=[r21];;
  26.343 +	extr.u r22=r22,2,30;;
  26.344 +	dep.z r22=r22,2,30;;
  26.345 +	adds r23=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.346 +	st8 [r23]=r22;;
  26.347 +
  26.348 +	// fast reflect expects
  26.349 +	//	r16 == cr.isr
  26.350 +	//	r18 == XSI_PSR_IC
  26.351 +	//	r20 == offset into ivt
  26.352 +	//	r29 == iip
  26.353 +	//	r30 == ipsr
  26.354 +	//	r31 == pr
  26.355 +	//mov r16=cr.isr
  26.356 +	mov r29=cr.iip
  26.357 +	mov r30=cr.ipsr
  26.358 +	br.sptk.many fast_reflect;;
  26.359 +END(fast_tlb_miss_reflect)
  26.360  
  26.361  // ensure that, if giving up, registers at entry to fast_hyperprivop unchanged
  26.362  ENTRY(hyper_rfi)
  26.363 @@ -807,6 +1073,7 @@ just_do_rfi:
  26.364  	// OK, now all set to go except for switch to virtual bank1
  26.365  	mov r22=1;; st4 [r20]=r22;
  26.366  	mov r30=r2; mov r29=r3;;
  26.367 +    mov r17=ar.unat;;
  26.368      adds r16=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18
  26.369  	adds r2=XSI_BANK1_OFS-XSI_PSR_IC_OFS,r18;
  26.370  	adds r3=(XSI_BANK1_OFS+8)-XSI_PSR_IC_OFS,r18;;
  26.371 @@ -832,6 +1099,7 @@ just_do_rfi:
  26.372  	.mem.offset 8,0; ld8.fill r30=[r2],16 ;
  26.373  	.mem.offset 8,0; ld8.fill r31=[r3],16 ;;
  26.374  	bsw.0 ;;
  26.375 +    mov ar.unat=r17;;
  26.376  	mov r2=r30; mov r3=r29;;
  26.377  1:	mov pr=r31,-1
  26.378  	;;
  26.379 @@ -1485,7 +1753,7 @@ ENTRY(hyper_set_kr)
  26.380  	adds r21=XSI_KR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.381  	shl r20=r8,3;;
  26.382  	add r22=r20,r21;;
  26.383 -	st8 [r21]=r9;;
  26.384 +	st8 [r22]=r9;;
  26.385  	cmp.eq p7,p0=r8,r0
  26.386  	adds r8=-1,r8;;
  26.387  (p7)	mov ar0=r9;;
  26.388 @@ -1671,6 +1939,17 @@ 2:
  26.389  	;;
  26.390  END(hyper_ptc_ga)
  26.391  
  26.392 +// recovery block for hyper_itc metaphysical memory lookup
  26.393 +ENTRY(recover_and_dispatch_break_fault)
  26.394 +#ifdef FAST_REFLECT_CNT
  26.395 +	movl r21=recover_to_break_fault_count;;
  26.396 +	ld8 r22=[r21];;
  26.397 +	adds r22=1,r22;;
  26.398 +	st8 [r21]=r22;;
  26.399 +#endif
  26.400 +	mov b0=r29 ;;
  26.401 +	br.sptk.many dispatch_break_fault;;
  26.402 +
  26.403  //  Registers at entry
  26.404  //	r17 = break immediate (XEN_HYPER_ITC_D or I)
  26.405  //	r18 == XSI_PSR_IC_OFS
  26.406 @@ -1680,24 +1959,14 @@ ENTRY(hyper_itc_i)
  26.407  	// fall through, hyper_itc_d handles both i and d
  26.408  ENTRY(hyper_itc_d)
  26.409  #ifndef FAST_ITC
  26.410 -	br.spnt.many dispatch_break_fault ;;
  26.411 +	br.sptk.many dispatch_break_fault ;;
  26.412  #endif
  26.413 +	// ensure itir.ps >= xen's pagesize
  26.414  	adds r23=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.415  	ld8 r23=[r23];;
  26.416  	extr.u r24=r23,2,6;;		// r24==logps
  26.417  	cmp.gt p7,p0=PAGE_SHIFT,r24
  26.418  (p7)	br.spnt.many dispatch_break_fault ;;
  26.419 -	// translate_domain_pte(r8=pteval,PSCB(ifa)=address,r24=itir)
  26.420 -	mov r19=1;;
  26.421 -	shl r20=r19,r24;;
  26.422 -	adds r20=-1,r20;;	// r20 == mask
  26.423 -	movl r19=_PAGE_PPN_MASK;;
  26.424 -	and r22=r8,r19;;	// r22 == pteval & _PAGE_PPN_MASK
  26.425 -	andcm r19=r22,r20;;
  26.426 -	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.427 -	ld8 r21=[r21];;
  26.428 -	and r20=r21,r20;;
  26.429 -	or r19=r19,r20;;	// r19 == mpaddr
  26.430  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  26.431  	ld8 r27=[r27];;
  26.432  	adds r27=IA64_VCPU_DOMAIN_OFFSET,r27;;
  26.433 @@ -1708,7 +1977,6 @@ ENTRY(hyper_itc_d)
  26.434  // FIXME: for now, only handle dom0 (see lookup_domain_mpa below)
  26.435  	cmp.ne p7,p0=r27,r28
  26.436  (p7)	br.spnt.many dispatch_break_fault ;;
  26.437 -	// if region 6, go slow way
  26.438  #ifdef FAST_HYPERPRIVOP_CNT
  26.439  	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  26.440  (p6)	movl r20=fast_hyperpriv_cnt+(8*XEN_HYPER_ITC_D);;
  26.441 @@ -1717,19 +1985,47 @@ ENTRY(hyper_itc_d)
  26.442  	adds r21=1,r21;;
  26.443  	st8 [r20]=r21;;
  26.444  #endif
  26.445 +(p6)	mov r17=2;;
  26.446 +(p7)	mov r17=3;;
  26.447 +	mov r29=b0 ;;
  26.448 +	movl r30=recover_and_dispatch_break_fault ;;
  26.449 +	mov r16=r8;;
  26.450 +	// fall through
  26.451 +
  26.452 +
  26.453 +// fast_insert(PSCB(ifa),r24=ps,r16=pte)
  26.454 +//	r16 == pte
  26.455 +//	r17 == bit0: 1=inst, 0=data; bit1: 1=itc, 0=vcpu_translate
  26.456 +//	r18 == XSI_PSR_IC_OFS
  26.457 +//	r24 == ps
  26.458 +//	r29 == saved value of b0 in case of recovery
  26.459 +//	r30 == recovery ip if failure occurs
  26.460 +//	r31 == pr
  26.461 +GLOBAL_ENTRY(fast_insert)
  26.462 +	// translate_domain_pte(r16=pteval,PSCB(ifa)=address,r24=itir)
  26.463 +	mov r19=1;;
  26.464 +	shl r20=r19,r24;;
  26.465 +	adds r20=-1,r20;;	// r20 == mask
  26.466 +	movl r19=_PAGE_PPN_MASK;;
  26.467 +	and r22=r16,r19;;	// r22 == pteval & _PAGE_PPN_MASK
  26.468 +	andcm r19=r22,r20;;
  26.469 +	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.470 +	ld8 r21=[r21];;
  26.471 +	and r20=r21,r20;;
  26.472 +	or r19=r19,r20;;	// r19 == mpaddr
  26.473  // FIXME: for now, just do domain0 and skip mpaddr range checks
  26.474  	dep r20=r0,r19,0,PAGE_SHIFT
  26.475  	movl r21=PAGE_PHYS ;;
  26.476  	or r20=r20,r21 ;;	// r20==return value from lookup_domain_mpa
  26.477 -	// r8=pteval,r20=pteval2
  26.478 +	// r16=pteval,r20=pteval2
  26.479  	movl r19=_PAGE_PPN_MASK
  26.480  	movl r21=_PAGE_PL_2;;
  26.481 -	andcm r25=r8,r19;;	// r25==pteval & ~_PAGE_PPN_MASK
  26.482 +	andcm r25=r16,r19;;	// r25==pteval & ~_PAGE_PPN_MASK
  26.483  	and r22=r20,r19;;
  26.484  	or r22=r22,r21;;
  26.485  	or r22=r22,r25;;	// r22==return value from translate_domain_pte
  26.486  	// done with translate_domain_pte
  26.487 -	// now do vcpu_itc_no_srlz(vcpu,IorD,ifa,r22=pte,r8=mppte,r24=logps)
  26.488 +	// now do vcpu_itc_no_srlz(vcpu,IorD,ifa,r22=pte,r16=mppte,r24=logps)
  26.489  // FIXME: for now, just domain0 and skip range check
  26.490  	// psr.ic already cleared
  26.491  	// NOTE: r24 still contains ps (from above)
  26.492 @@ -1738,7 +2034,7 @@ ENTRY(hyper_itc_d)
  26.493  	adds r23=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  26.494  	ld8 r23=[r23];;
  26.495  	mov cr.ifa=r23;;
  26.496 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  26.497 +	tbit.z p6,p7=r17,0;;
  26.498  (p6)	itc.d r22;;
  26.499  (p7)	itc.i r22;;
  26.500  	dv_serialize_data
  26.501 @@ -1755,7 +2051,7 @@ ENTRY(hyper_itc_d)
  26.502  	st8 [r20]=r21;;
  26.503  	// vcpu_set_tr_entry(trp,r22=pte|1,r24=itir,r23=ifa)
  26.504  	// TR_ENTRY = {page_flags,itir,addr,rid}
  26.505 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17
  26.506 +	tbit.z p6,p7=r17,0;;
  26.507  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  26.508  	ld8 r27=[r27];;
  26.509  	adds r28=IA64_VCPU_STARTING_RID_OFFSET,r27
  26.510 @@ -1766,7 +2062,6 @@ ENTRY(hyper_itc_d)
  26.511  	mov r19=-4096;;
  26.512  	and r23=r23,r19;;
  26.513  	st8 [r27]=r23,8;;	// ifa & ~0xfff
  26.514 -// ?? is virtualize_rid(v,get_rr(ifa))==vcpu_get_rr(ifa)?? YES!!
  26.515  	adds r29 = XSI_RR0_OFS-XSI_PSR_IC_OFS,r18
  26.516  	extr.u r25=r23,61,3;;
  26.517  	shladd r29=r25,3,r29;;
  26.518 @@ -1804,13 +2099,16 @@ 1:	// done with vcpu_set_tr_entry
  26.519  	//PSCBX(vcpu,i/dtlb_pte) = mp_pte
  26.520  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  26.521  	ld8 r27=[r27];;
  26.522 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  26.523 +	tbit.z p6,p7=r17,0;;
  26.524  (p6)	adds r27=IA64_VCPU_DTLB_PTE_OFFSET,r27
  26.525  (p7)	adds r27=IA64_VCPU_ITLB_PTE_OFFSET,r27;;
  26.526 -	st8 [r27]=r8;;
  26.527 +	st8 [r27]=r16;;
  26.528  	// done with vcpu_itc_no_srlz
  26.529  
  26.530 -	// done, increment to point to next instruction
  26.531 +	// if hyper_itc, increment to point to next instruction
  26.532 +	tbit.z p7,p0=r17,1
  26.533 +(p7)	br.cond.sptk.few no_inc_iip;;
  26.534 +
  26.535  	mov r29=cr.ipsr
  26.536  	mov r30=cr.iip;;
  26.537  	extr.u r26=r29,41,2 ;;
  26.538 @@ -1822,8 +2120,11 @@ 1:	// done with vcpu_set_tr_entry
  26.539  	dep r29=r26,r29,41,2
  26.540  	;;
  26.541  	mov cr.ipsr=r29
  26.542 -	mov cr.iip=r30
  26.543 +	mov cr.iip=r30;;
  26.544 +
  26.545 +no_inc_iip:
  26.546  	mov pr=r31,-1 ;;
  26.547  	rfi
  26.548  	;;
  26.549 -END(hyper_itc_d)
  26.550 +END(fast_insert)
  26.551 +
    27.1 --- a/xen/arch/ia64/xen/ivt.S	Tue Nov 08 12:30:38 2005 +0100
    27.2 +++ b/xen/arch/ia64/xen/ivt.S	Tue Nov 08 12:31:43 2005 +0100
    27.3 @@ -246,7 +246,8 @@ ENTRY(itlb_miss)
    27.4  #ifdef XEN
    27.5  	VHPT_CCHAIN_LOOKUP(itlb_miss,i)
    27.6  #ifdef VHPT_GLOBAL
    27.7 -	br.cond.sptk page_fault
    27.8 +//	br.cond.sptk page_fault
    27.9 +	br.cond.sptk fast_tlb_miss_reflect
   27.10  	;;
   27.11  #endif
   27.12  #endif
   27.13 @@ -297,7 +298,8 @@ ENTRY(dtlb_miss)
   27.14  #ifdef XEN
   27.15  	VHPT_CCHAIN_LOOKUP(dtlb_miss,d)
   27.16  #ifdef VHPT_GLOBAL
   27.17 -	br.cond.sptk page_fault
   27.18 +//	br.cond.sptk page_fault
   27.19 +	br.cond.sptk fast_tlb_miss_reflect
   27.20  	;;
   27.21  #endif
   27.22  #endif
   27.23 @@ -485,6 +487,11 @@ END(alt_dtlb_miss)
   27.24  // 0x1400 Entry 5 (size 64 bundles) Data nested TLB (6,45)
   27.25  ENTRY(nested_dtlb_miss)
   27.26  	DBG_FAULT(5)
   27.27 +#ifdef XEN
   27.28 +	mov b0=r30
   27.29 +	br.sptk.many b0				// return to continuation point
   27.30 +	;;
   27.31 +#endif
   27.32  	/*
   27.33  	 * In the absence of kernel bugs, we get here when the virtually mapped linear
   27.34  	 * page table is accessed non-speculatively (e.g., in the Dirty-bit, Instruction
   27.35 @@ -562,7 +569,11 @@ END(ikey_miss)
   27.36  
   27.37  	//-----------------------------------------------------------------------------------
   27.38  	// call do_page_fault (predicates are in r31, psr.dt may be off, r16 is faulting address)
   27.39 +#ifdef XEN
   27.40 +GLOBAL_ENTRY(page_fault)
   27.41 +#else
   27.42  ENTRY(page_fault)
   27.43 +#endif
   27.44  	ssm psr.dt
   27.45  	;;
   27.46  	srlz.i
    28.1 --- a/xen/arch/ia64/xen/privop.c	Tue Nov 08 12:30:38 2005 +0100
    28.2 +++ b/xen/arch/ia64/xen/privop.c	Tue Nov 08 12:31:43 2005 +0100
    28.3 @@ -1040,6 +1040,9 @@ extern unsigned long dtlb_translate_coun
    28.4  extern unsigned long tr_translate_count;
    28.5  extern unsigned long phys_translate_count;
    28.6  extern unsigned long vhpt_translate_count;
    28.7 +extern unsigned long fast_vhpt_translate_count;
    28.8 +extern unsigned long recover_to_page_fault_count;
    28.9 +extern unsigned long recover_to_break_fault_count;
   28.10  extern unsigned long lazy_cover_count;
   28.11  extern unsigned long idle_when_pending;
   28.12  extern unsigned long pal_halt_light_count;
   28.13 @@ -1049,9 +1052,12 @@ int dump_misc_stats(char *buf)
   28.14  {
   28.15  	char *s = buf;
   28.16  	s += sprintf(s,"Virtual TR translations: %d\n",tr_translate_count);
   28.17 -	s += sprintf(s,"Virtual VHPT translations: %d\n",vhpt_translate_count);
   28.18 +	s += sprintf(s,"Virtual VHPT slow translations: %d\n",vhpt_translate_count);
   28.19 +	s += sprintf(s,"Virtual VHPT fast translations: %d\n",fast_vhpt_translate_count);
   28.20  	s += sprintf(s,"Virtual DTLB translations: %d\n",dtlb_translate_count);
   28.21  	s += sprintf(s,"Physical translations: %d\n",phys_translate_count);
   28.22 +	s += sprintf(s,"Recoveries to page fault: %d\n",recover_to_page_fault_count);
   28.23 +	s += sprintf(s,"Recoveries to break fault: %d\n",recover_to_break_fault_count);
   28.24  	s += sprintf(s,"Idle when pending: %d\n",idle_when_pending);
   28.25  	s += sprintf(s,"PAL_HALT_LIGHT (no pending): %d\n",pal_halt_light_count);
   28.26  	s += sprintf(s,"context switches: %d\n",context_switch_count);
   28.27 @@ -1065,6 +1071,9 @@ void zero_misc_stats(void)
   28.28  	tr_translate_count = 0;
   28.29  	phys_translate_count = 0;
   28.30  	vhpt_translate_count = 0;
   28.31 +	fast_vhpt_translate_count = 0;
   28.32 +	recover_to_page_fault_count = 0;
   28.33 +	recover_to_break_fault_count = 0;
   28.34  	lazy_cover_count = 0;
   28.35  	pal_halt_light_count = 0;
   28.36  	idle_when_pending = 0;
    29.1 --- a/xen/arch/ia64/xen/process.c	Tue Nov 08 12:30:38 2005 +0100
    29.2 +++ b/xen/arch/ia64/xen/process.c	Tue Nov 08 12:31:43 2005 +0100
    29.3 @@ -83,9 +83,8 @@ void schedule_tail(struct vcpu *next)
    29.4      if(VMX_DOMAIN(current)){
    29.5      	vmx_load_all_rr(current);
    29.6      }else{
    29.7 -	    if (rr7 = load_region_regs(current)) {
    29.8 -		    printk("schedule_tail: change to rr7 not yet implemented\n");
    29.9 -    	}
   29.10 +	    load_region_regs(current);
   29.11 +            vcpu_load_kernel_regs(current);
   29.12      }
   29.13  }
   29.14  
   29.15 @@ -185,6 +184,7 @@ void check_bad_nested_interruption(unsig
   29.16  	if (!(PSCB(v,ipsr) & IA64_PSR_DT)) {
   29.17  		panic_domain(regs,"psr.dt off, trying to deliver nested dtlb!\n");
   29.18  	}
   29.19 +	vector &= ~0xf;
   29.20  	if (vector != IA64_DATA_TLB_VECTOR &&
   29.21  		vector != IA64_ALT_DATA_TLB_VECTOR &&
   29.22  		vector != IA64_VHPT_TRANS_VECTOR) {
    30.1 --- a/xen/arch/ia64/xen/regionreg.c	Tue Nov 08 12:30:38 2005 +0100
    30.2 +++ b/xen/arch/ia64/xen/regionreg.c	Tue Nov 08 12:31:43 2005 +0100
    30.3 @@ -341,23 +341,13 @@ virtualize_rid(struct vcpu *v, unsigned 
    30.4  // rr7 (because we have to to assembly and physical mode
    30.5  // to change rr7).  If no change to rr7 is required, returns 0.
    30.6  //
    30.7 -unsigned long load_region_regs(struct vcpu *v)
    30.8 +void load_region_regs(struct vcpu *v)
    30.9  {
   30.10  	unsigned long rr0, rr1,rr2, rr3, rr4, rr5, rr6, rr7;
   30.11  	// TODO: These probably should be validated
   30.12  	unsigned long bad = 0;
   30.13  
   30.14  	if (VCPU(v,metaphysical_mode)) {
   30.15 -		ia64_rr rrv;
   30.16 -
   30.17 -#if 0
   30.18 -		rrv.rrval = 0;
   30.19 -		rrv.rid = v->domain->arch.metaphysical_rr0;
   30.20 -		rrv.ps = PAGE_SHIFT;
   30.21 -		rrv.ve = 1;
   30.22 -		rr0 = rrv.rrval;
   30.23 -		set_rr_no_srlz(0x0000000000000000L, rr0);
   30.24 -#endif
   30.25  		rr0 = v->domain->arch.metaphysical_rr0;
   30.26  		ia64_set_rr(0x0000000000000000L, rr0);
   30.27  		ia64_srlz_d();
   30.28 @@ -383,5 +373,4 @@ unsigned long load_region_regs(struct vc
   30.29  	if (bad) {
   30.30  		panic_domain(0,"load_region_regs: can't set! bad=%lx\n",bad);
   30.31  	}
   30.32 -	return 0;
   30.33  }
    31.1 --- a/xen/arch/ia64/xen/vcpu.c	Tue Nov 08 12:30:38 2005 +0100
    31.2 +++ b/xen/arch/ia64/xen/vcpu.c	Tue Nov 08 12:31:43 2005 +0100
    31.3 @@ -135,6 +135,18 @@ vcpu_set_gr(VCPU *vcpu, unsigned reg, UI
    31.4   VCPU privileged application register access routines
    31.5  **************************************************************************/
    31.6  
    31.7 +void vcpu_load_kernel_regs(VCPU *vcpu)
    31.8 +{
    31.9 +	ia64_set_kr(0, VCPU(vcpu, krs[0]));
   31.10 +	ia64_set_kr(1, VCPU(vcpu, krs[1]));
   31.11 +	ia64_set_kr(2, VCPU(vcpu, krs[2]));
   31.12 +	ia64_set_kr(3, VCPU(vcpu, krs[3]));
   31.13 +	ia64_set_kr(4, VCPU(vcpu, krs[4]));
   31.14 +	ia64_set_kr(5, VCPU(vcpu, krs[5]));
   31.15 +	ia64_set_kr(6, VCPU(vcpu, krs[6]));
   31.16 +	ia64_set_kr(7, VCPU(vcpu, krs[7]));
   31.17 +}
   31.18 +
   31.19  IA64FAULT vcpu_set_ar(VCPU *vcpu, UINT64 reg, UINT64 val)
   31.20  {
   31.21  	if (reg == 44) return (vcpu_set_itc(vcpu,val));
   31.22 @@ -1271,6 +1283,9 @@ IA64FAULT vcpu_ttag(VCPU *vcpu, UINT64 v
   31.23  #define itir_mask(itir) (~((1UL << itir_ps(itir)) - 1))
   31.24  
   31.25  unsigned long vhpt_translate_count = 0;
   31.26 +unsigned long fast_vhpt_translate_count = 0;
   31.27 +unsigned long recover_to_page_fault_count = 0;
   31.28 +unsigned long recover_to_break_fault_count = 0;
   31.29  
   31.30  IA64FAULT vcpu_translate(VCPU *vcpu, UINT64 address, BOOLEAN is_data, UINT64 *pteval, UINT64 *itir, UINT64 *iha)
   31.31  {
   31.32 @@ -1872,4 +1887,3 @@ IA64FAULT vcpu_ptr_i(VCPU *vcpu,UINT64 v
   31.33  	// don't forget to recompute itr_regions
   31.34  	return (IA64_ILLOP_FAULT);
   31.35  }
   31.36 -
    32.1 --- a/xen/arch/ia64/xen/xenmisc.c	Tue Nov 08 12:30:38 2005 +0100
    32.2 +++ b/xen/arch/ia64/xen/xenmisc.c	Tue Nov 08 12:31:43 2005 +0100
    32.3 @@ -290,8 +290,8 @@ void context_switch(struct vcpu *prev, s
    32.4  //prev->domain->domain_id,(long)prev&0xffffff,next->domain->domain_id,(long)next&0xffffff);
    32.5  //if (prev->domain->domain_id == 1 && next->domain->domain_id == 0) cs10foo();
    32.6  //if (prev->domain->domain_id == 0 && next->domain->domain_id == 1) cs01foo();
    32.7 -printk("@@sw%d/%x %d->%d\n",smp_processor_id(), hard_smp_processor_id (),
    32.8 -       prev->domain->domain_id,next->domain->domain_id);
    32.9 +//printk("@@sw%d/%x %d->%d\n",smp_processor_id(), hard_smp_processor_id (),
   32.10 +//       prev->domain->domain_id,next->domain->domain_id);
   32.11      if(VMX_DOMAIN(prev)){
   32.12      	vtm_domain_out(prev);
   32.13      }
   32.14 @@ -320,6 +320,7 @@ if (!i--) { printk("+",id); i = 1000000;
   32.15  		VHPT_ENABLED);
   32.16      	if (!is_idle_task(current->domain)) {
   32.17  	    	load_region_regs(current);
   32.18 +	    	vcpu_load_kernel_regs(current);
   32.19  		    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
   32.20      	}
   32.21  	    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
    33.1 --- a/xen/include/asm-ia64/time.h	Tue Nov 08 12:30:38 2005 +0100
    33.2 +++ b/xen/include/asm-ia64/time.h	Tue Nov 08 12:31:43 2005 +0100
    33.3 @@ -1,1 +1,2 @@
    33.4  #include <asm/linux/time.h>
    33.5 +#include <asm/timex.h>