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':
    23.1 --- a/tools/xenstore/Makefile	Tue Nov 08 12:30:38 2005 +0100
    23.2 +++ b/tools/xenstore/Makefile	Tue Nov 08 12:31:43 2005 +0100
    23.3 @@ -77,7 +77,7 @@ libxenstore.so: xs.opic xs_lib.opic
    23.4  clean: testsuite-clean
    23.5  	rm -f *.o *.opic *.so
    23.6  	rm -f xenstored xs_random xs_stress xs_crashme
    23.7 -	rm -f xs_test xenstored_test xs_tdb_dump
    23.8 +	rm -f xs_test xenstored_test xs_tdb_dump xsls $(CLIENTS)
    23.9  	$(RM) $(PROG_DEP)
   23.10  
   23.11  print-dir:
    24.1 --- a/xen/arch/ia64/linux-xen/efi.c	Tue Nov 08 12:30:38 2005 +0100
    24.2 +++ b/xen/arch/ia64/linux-xen/efi.c	Tue Nov 08 12:31:43 2005 +0100
    24.3 @@ -24,7 +24,6 @@
    24.4  #include <linux/init.h>
    24.5  #include <linux/types.h>
    24.6  #include <linux/time.h>
    24.7 -#include <linux/efi.h>
    24.8  
    24.9  #include <asm/io.h>
   24.10  #include <asm/kregs.h>
   24.11 @@ -33,6 +32,8 @@
   24.12  #include <asm/processor.h>
   24.13  #include <asm/mca.h>
   24.14  
   24.15 +#include <linux/efi.h>
   24.16 +
   24.17  #define EFI_DEBUG	0
   24.18  
   24.19  extern efi_status_t efi_call_phys (void *, ...);
    25.1 --- a/xen/arch/ia64/linux-xen/mm_contig.c	Tue Nov 08 12:30:38 2005 +0100
    25.2 +++ b/xen/arch/ia64/linux-xen/mm_contig.c	Tue Nov 08 12:31:43 2005 +0100
    25.3 @@ -16,7 +16,6 @@
    25.4   */
    25.5  #include <linux/config.h>
    25.6  #include <linux/bootmem.h>
    25.7 -#include <linux/efi.h>
    25.8  #include <linux/mm.h>
    25.9  #include <linux/swap.h>
   25.10  
   25.11 @@ -26,6 +25,7 @@
   25.12  #include <asm/sections.h>
   25.13  #include <asm/mca.h>
   25.14  
   25.15 +#include <linux/efi.h>
   25.16  #ifdef CONFIG_VIRTUAL_MEM_MAP
   25.17  static unsigned long num_dma_physpages;
   25.18  #endif
    26.1 --- a/xen/arch/ia64/xen/hypercall.c	Tue Nov 08 12:30:38 2005 +0100
    26.2 +++ b/xen/arch/ia64/xen/hypercall.c	Tue Nov 08 12:31:43 2005 +0100
    26.3 @@ -187,6 +187,10 @@ ia64_hypercall (struct pt_regs *regs)
    26.4  		regs->r8 = do_console_io(regs->r14, regs->r15, regs->r16);
    26.5  		break;
    26.6  
    26.7 +	    case __HYPERVISOR_xen_version:
    26.8 +		regs->r8 = do_xen_version(regs->r14, regs->r15);
    26.9 +		break;
   26.10 +
   26.11  	    default:
   26.12  		printf("unknown hypercall %x\n", regs->r2);
   26.13  		regs->r8 = (unsigned long)-1;
    27.1 --- a/xen/arch/ia64/xen/hyperprivop.S	Tue Nov 08 12:30:38 2005 +0100
    27.2 +++ b/xen/arch/ia64/xen/hyperprivop.S	Tue Nov 08 12:31:43 2005 +0100
    27.3 @@ -14,6 +14,7 @@
    27.4  #include <asm/system.h>
    27.5  #include <public/arch-ia64.h>
    27.6  
    27.7 +
    27.8  #define	_PAGE_PPN_MASK	0x0003fffffffff000 //asm/pgtable.h doesn't do assembly
    27.9  #define PAGE_PHYS	0x0010000000000761 //__pgprot(__DIRTY_BITS|_PAGE_PL_2|_PAGE_AR_RWX)
   27.10  #define _PAGE_PL_2	(2<<7)
   27.11 @@ -22,13 +23,14 @@
   27.12  #define FAST_HYPERPRIVOPS
   27.13  #define FAST_HYPERPRIVOP_CNT
   27.14  #define FAST_REFLECT_CNT
   27.15 -//#define FAST_TICK
   27.16 +//#define FAST_TICK // mostly working (unat problems) but default off for now
   27.17 +//#define FAST_TLB_MISS_REFLECT	// mostly working but default off for now
   27.18 +//#define FAST_ITC	// working but default off for now
   27.19  #define FAST_BREAK
   27.20  #define FAST_ACCESS_REFLECT
   27.21  #define FAST_RFI
   27.22  #define FAST_SSM_I
   27.23  #define FAST_PTC_GA
   27.24 -#undef FAST_ITC	// working but default off for now
   27.25  #undef RFI_TO_INTERRUPT // not working yet
   27.26  #endif
   27.27  
   27.28 @@ -57,7 +59,7 @@
   27.29  #endif
   27.30  
   27.31  // FIXME: turn off for now... but NaTs may crash Xen so re-enable soon!
   27.32 -//#define HANDLE_AR_UNAT
   27.33 +#define HANDLE_AR_UNAT
   27.34  
   27.35  // FIXME: This is defined in include/asm-ia64/hw_irq.h but this
   27.36  // doesn't appear to be include'able from assembly?
   27.37 @@ -495,19 +497,29 @@ GLOBAL_ENTRY(fast_tick_reflect)
   27.38  	.mem.offset 0,0; st8.spill [r2]=r30,16;
   27.39  	.mem.offset 8,0; st8.spill [r3]=r31,16 ;;
   27.40  #ifdef HANDLE_AR_UNAT
   27.41 -	// bank0 regs have no NaT bit, so ensure they are NaT clean
   27.42 -	mov r16=r0; mov r17=r0; mov r18=r0; mov r19=r0;
   27.43 -	mov r20=r0; mov r21=r0; mov r22=r0; mov r23=r0;
   27.44 -	mov r24=r0; mov r25=r0; mov r26=r0; mov r27=r0;
   27.45 -	mov r28=r0; mov r29=r0; mov r30=r0; movl r31=XSI_IPSR;;
   27.46 + 	// r16~r23 are preserved regsin bank0 regs, we need to restore them,
   27.47 +    // r24~r31 are scratch regs, we don't need to handle NaT bit,
   27.48 +    // because OS handler must assign it before access it
   27.49 +    ld8 r16=[r2],16;
   27.50 +    ld8 r17=[r3],16;;
   27.51 +    ld8 r18=[r2],16;
   27.52 +    ld8 r19=[r3],16;;
   27.53 +    ld8 r20=[r2],16;
   27.54 +    ld8 r21=[r3],16;;
   27.55 +    ld8 r22=[r2],16;
   27.56 +    ld8 r23=[r3],16;;
   27.57  #endif
   27.58 -	bsw.0 ;;
   27.59 -	mov r2=r30; mov r3=r29;;
   27.60 +    movl r31=XSI_IPSR;;
   27.61 +    bsw.0 ;;
   27.62 +    mov r24=ar.unat;
   27.63 +    mov r2=r30; mov r3=r29;;
   27.64  #ifdef HANDLE_AR_UNAT
   27.65 -	mov ar.unat=r28;
   27.66 +    mov ar.unat=r28;
   27.67  #endif
   27.68 -	adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
   27.69 -	st4 [r20]=r0 ;;
   27.70 +    adds r25=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18 ;
   27.71 +    adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
   27.72 +    st8 [r25]=r24;
   27.73 +    st4 [r20]=r0 ;;
   27.74  fast_tick_reflect_done:
   27.75  	mov pr=r31,-1 ;;
   27.76  	rfi
   27.77 @@ -649,19 +661,28 @@ ENTRY(fast_reflect)
   27.78  	.mem.offset 0,0; st8.spill [r2]=r30,16;
   27.79  	.mem.offset 8,0; st8.spill [r3]=r31,16 ;;
   27.80  #ifdef HANDLE_AR_UNAT
   27.81 -	// bank0 regs have no NaT bit, so ensure they are NaT clean
   27.82 -	mov r16=r0; mov r17=r0; mov r18=r0; mov r19=r0;
   27.83 -	mov r20=r0; mov r21=r0; mov r22=r0; mov r23=r0;
   27.84 -	mov r24=r0; mov r25=r0; mov r26=r0; mov r27=r0;
   27.85 -	mov r28=r0; mov r29=r0; mov r30=r0; movl r31=XSI_IPSR;;
   27.86 +	// r16~r23 are preserved regsin bank0 regs, we need to restore them,
   27.87 +    // r24~r31 are scratch regs, we don't need to handle NaT bit,
   27.88 +    // because OS handler must assign it before access it
   27.89 +	ld8 r16=[r2],16;
   27.90 +    ld8 r17=[r3],16;;
   27.91 +    ld8 r18=[r2],16;
   27.92 +    ld8 r19=[r3],16;;
   27.93 +	ld8 r20=[r2],16;
   27.94 +    ld8 r21=[r3],16;;
   27.95 +    ld8 r22=[r2],16;
   27.96 +    ld8 r23=[r3],16;;
   27.97  #endif
   27.98  	movl r31=XSI_IPSR;;
   27.99  	bsw.0 ;;
  27.100 +    mov r24=ar.unat;
  27.101  	mov r2=r30; mov r3=r29;;
  27.102  #ifdef HANDLE_AR_UNAT
  27.103  	mov ar.unat=r28;
  27.104  #endif
  27.105 +    adds r25=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18 ;
  27.106  	adds r20=XSI_BANKNUM_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.107 +    st8 [r25]=r24;
  27.108  	st4 [r20]=r0 ;;
  27.109  	mov pr=r31,-1 ;;
  27.110  	rfi
  27.111 @@ -705,6 +726,251 @@ GLOBAL_ENTRY(fast_access_reflect)
  27.112  	st8 [r23]=r22;;
  27.113  	br.cond.sptk.many fast_reflect;;
  27.114  
  27.115 +// when we get to here, VHPT_CCHAIN_LOOKUP has failed and everything
  27.116 +// is as it was at the time of original miss.  We want to preserve that
  27.117 +// so if we get a nested fault, we can just branch to page_fault
  27.118 +GLOBAL_ENTRY(fast_tlb_miss_reflect)
  27.119 +#ifndef FAST_TLB_MISS_REFLECT // see beginning of file
  27.120 +	br.spnt.few page_fault ;;
  27.121 +#endif
  27.122 +	mov r31=pr
  27.123 +	mov r30=cr.ipsr
  27.124 +	mov r29=cr.iip
  27.125 +	mov r16=cr.isr
  27.126 +	mov r17=cr.ifa;;
  27.127 +	// for now, always take slow path for region 0 (e.g. metaphys mode)
  27.128 +	extr.u r21=r17,61,3;;
  27.129 +	cmp.eq p7,p0=r0,r21
  27.130 +(p7)	br.spnt.few page_fault ;;
  27.131 +	// always take slow path for PL0 (e.g. __copy_from_user)
  27.132 +	extr.u r21=r30,IA64_PSR_CPL0_BIT,2 ;;
  27.133 +	cmp.eq p7,p0=r21,r0
  27.134 +(p7)	br.spnt.few page_fault ;;
  27.135 +	// slow path if strange ipsr or isr bits set
  27.136 +	extr.u r21=r30,IA64_PSR_BE_BIT,1 ;;
  27.137 +	cmp.ne p7,p0=r21,r0
  27.138 +(p7)	br.spnt.few page_fault ;;
  27.139 +	extr.u r21=r30,IA64_PSR_PP_BIT,1 ;;
  27.140 +	cmp.ne p7,p0=r21,r0
  27.141 +(p7)	br.spnt.few page_fault ;;
  27.142 +	movl r21=IA64_ISR_IR|IA64_ISR_SP|IA64_ISR_NA ;;
  27.143 +	and r21=r16,r21;;
  27.144 +	cmp.ne p7,p0=r0,r21
  27.145 +(p7)	br.spnt.few page_fault ;;
  27.146 +	// also take slow path if virtual psr.ic=0
  27.147 +	movl r18=XSI_PSR_IC;;
  27.148 +	ld4 r21=[r18];;
  27.149 +	cmp.eq p7,p0=r0,r21
  27.150 +(p7)	br.spnt.few page_fault ;;
  27.151 +	// OK, if we get to here, we are doing a fast vcpu_translate.  Need to:
  27.152 +	// 1) look in the virtual TR's (pinned), if not there
  27.153 +	// 2) look in the 1-entry TLB (pinned), if not there
  27.154 +	// 3) check the domain VHPT (NOT pinned, accesses domain memory!)
  27.155 +	// If we find it in any of these places, we need to effectively do
  27.156 +	// a hyper_itc_i/d
  27.157 +
  27.158 +	// short-term hack for now, if in region 5-7, take slow path
  27.159 +	// since all Linux TRs are in region 5 or 7, we need not check TRs
  27.160 +	extr.u r21=r17,61,3;;
  27.161 +	cmp.le p7,p0=5,r21
  27.162 +(p7)	br.spnt.few page_fault ;;
  27.163 +fast_tlb_no_tr_match:
  27.164 +	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  27.165 +	ld8 r27=[r27];;
  27.166 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  27.167 +(p6)	adds r25=IA64_VCPU_ITLB_OFFSET,r27;;
  27.168 +(p7)	adds r25=IA64_VCPU_DTLB_OFFSET,r27;;
  27.169 +	ld8 r20=[r25],8;;
  27.170 +	tbit.z p7,p0=r20,0;;	// present?
  27.171 +(p7)	br.cond.spnt.few 1f;;
  27.172 +	// if ifa is in range of tlb, don't bother to check rid, go slow path
  27.173 +	ld8 r21=[r25],8;;
  27.174 +	mov r23=1
  27.175 +	extr.u r21=r21,2,6;;
  27.176 +	shl r22=r23,r21
  27.177 +	ld8 r21=[r25],8;;
  27.178 +	cmp.ltu p7,p0=r17,r21
  27.179 +(p7)	br.cond.sptk.many 1f;
  27.180 +	add r21=r22,r21;;
  27.181 +	cmp.ltu p7,p0=r17,r21
  27.182 +(p7)	br.cond.spnt.few page_fault;;
  27.183 +	
  27.184 +1:	// check the guest VHPT
  27.185 +	adds r19 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18;;
  27.186 +	ld8 r19=[r19];;
  27.187 +	tbit.nz p7,p0=r19,IA64_PTA_VF_BIT;;	// long format VHPT
  27.188 +(p7)	br.cond.spnt.few page_fault;;
  27.189 +	// if (!rr.ve || !(pta & IA64_PTA_VE)) take slow way for now
  27.190 +	// FIXME: later, we deliver an alt_d/i vector after thash and itir
  27.191 +	tbit.z p7,p0=r19,IA64_PTA_VE_BIT;;	// 
  27.192 +(p7)	br.cond.spnt.few page_fault;;
  27.193 +	extr.u r25=r17,61,3;;
  27.194 +	adds r21=XSI_RR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.195 +	shl r25=r25,3;;
  27.196 +	add r21=r21,r25;;
  27.197 +	ld8 r22=[r21];;
  27.198 +	tbit.z p7,p0=r22,0
  27.199 +(p7)	br.cond.spnt.few page_fault;;
  27.200 +
  27.201 +	// compute and save away itir (r22 & RR_PS_MASK)
  27.202 +	movl r21=0xfc;;
  27.203 +	and r22=r22,r21;;
  27.204 +	adds r21=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.205 +	st8 [r21]=r22;;
  27.206 +	
  27.207 +	// save away ifa
  27.208 +	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.209 +	st8 [r21]=r17;;
  27.210 +	// see vcpu_thash to save away iha
  27.211 +	shr.u r20 = r17, 61
  27.212 +	addl r25 = 1, r0
  27.213 +	movl r30 = 0xe000000000000000
  27.214 +	;;
  27.215 +	and r21 = r30, r17		// VHPT_Addr1
  27.216 +	;;
  27.217 +	shladd r28 = r20, 3, r18
  27.218 +	adds r19 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18
  27.219 +	;;
  27.220 +	adds r27 = XSI_RR0_OFS-XSI_PSR_IC_OFS, r28
  27.221 +	addl r28 = 32767, r0
  27.222 +	ld8 r24 = [r19]			// pta
  27.223 +	;;
  27.224 +	ld8 r23 = [r27]			// rrs[vadr>>61]
  27.225 +	extr.u r26 = r24, 2, 6
  27.226 +	;;
  27.227 +	extr.u r22 = r23, 2, 6
  27.228 +	shl r30 = r25, r26
  27.229 +	;;
  27.230 +	shr.u r19 = r17, r22
  27.231 +	shr.u r29 = r24, 15
  27.232 +	;;
  27.233 +	adds r30 = -1, r30
  27.234 +	;;
  27.235 +	shladd r27 = r19, 3, r0
  27.236 +	extr.u r26 = r30, 15, 46
  27.237 +	;;
  27.238 +	andcm r24 = r29, r26
  27.239 +	and r19 = r28, r27
  27.240 +	shr.u r25 = r27, 15
  27.241 +	;;
  27.242 +	and r23 = r26, r25
  27.243 +	;;
  27.244 +	or r22 = r24, r23
  27.245 +	;;
  27.246 +	dep.z r20 = r22, 15, 46
  27.247 +	;;
  27.248 +	or r30 = r20, r21
  27.249 +	;;
  27.250 +	//or r8 = r19, r30
  27.251 +	or r19 = r19, r30
  27.252 +	;;
  27.253 +	adds r23=XSI_IHA_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.254 +	st8 [r23]=r19;;
  27.255 +	// done with thash, check guest VHPT
  27.256 +
  27.257 +	adds r20 = XSI_PTA_OFS-XSI_PSR_IC_OFS, r18;;
  27.258 +	ld8 r24 = [r20];;			// pta
  27.259 +	// avoid recursively walking the VHPT
  27.260 +	// if (((r17=address ^ r24=pta) & ((itir_mask(pta) << 3) >> 3)) != 0) {
  27.261 +	mov r20=-8
  27.262 +	xor r21=r17,r24
  27.263 +	extr.u r24=r24,2,6;;
  27.264 +	shl r20=r20,r24;;
  27.265 +	shr.u r20=r20,3;;
  27.266 +	and r21=r20,r21;;
  27.267 +	cmp.eq p7,p0=r21,r0
  27.268 +(p7)	br.cond.spnt.few 1f;;
  27.269 +	// __copy_from_user(&pte, r19=(void *)(*iha), sizeof(pte)=8)
  27.270 +	// prepare for possible nested dtlb fault
  27.271 +	mov r29=b0
  27.272 +	movl r30=guest_vhpt_miss;;
  27.273 +	// now go fetch the entry from the guest VHPT
  27.274 +	ld8 r20=[r19];;
  27.275 +	// if we wind up here, we successfully loaded the VHPT entry
  27.276 +
  27.277 +	// this VHPT walker aborts on non-present pages instead
  27.278 +	// of inserting a not-present translation, this allows
  27.279 +	// vectoring directly to the miss handler
  27.280 +	tbit.z p7,p0=r20,0
  27.281 +(p7)	br.cond.spnt.few page_not_present;;
  27.282 +
  27.283 +#ifdef FAST_REFLECT_CNT
  27.284 +	movl r21=fast_vhpt_translate_count;;
  27.285 +	ld8 r22=[r21];;
  27.286 +	adds r22=1,r22;;
  27.287 +	st8 [r21]=r22;;
  27.288 +#endif
  27.289 +
  27.290 +// prepare for fast_insert(PSCB(ifa),PSCB(itir),r16=pte)
  27.291 +//	r16 == pte
  27.292 +//	r17 == bit0: 1=inst, 0=data; bit1: 1=itc, 0=vcpu_translate
  27.293 +//	r18 == XSI_PSR_IC_OFS
  27.294 +//	r24 == ps
  27.295 +//	r29 == saved value of b0 in case of recovery
  27.296 +//	r30 == recovery ip if failure occurs
  27.297 +//	r31 == pr
  27.298 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  27.299 +(p6)	mov r17=1;;
  27.300 +(p7)	mov r17=0;;
  27.301 +	mov r16=r20
  27.302 +	mov r29=b0 ;;
  27.303 +	movl r30=recover_and_page_fault ;;
  27.304 +	adds r21=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.305 +	ld8 r24=[r21];;
  27.306 +	extr.u r24=r24,2,6;;
  27.307 +	// IFA already in PSCB
  27.308 +	br.cond.sptk.many fast_insert;;
  27.309 +
  27.310 +// we get here if fast_insert fails (e.g. due to metaphysical lookup)
  27.311 +ENTRY(recover_and_page_fault)
  27.312 +#ifdef FAST_REFLECT_CNT
  27.313 +	movl r21=recover_to_page_fault_count;;
  27.314 +	ld8 r22=[r21];;
  27.315 +	adds r22=1,r22;;
  27.316 +	st8 [r21]=r22;;
  27.317 +#endif
  27.318 +	mov b0=r29;;
  27.319 +	br.cond.sptk.many page_fault;;
  27.320 +
  27.321 +// if we wind up here, we missed in guest VHPT so recover
  27.322 +// from nested dtlb fault and reflect a tlb fault to the guest
  27.323 +guest_vhpt_miss:
  27.324 +	mov b0=r29;;
  27.325 +	// fault = IA64_VHPT_FAULT
  27.326 +	mov r20=r0
  27.327 +	br.cond.sptk.many 1f;
  27.328 +
  27.329 +	// if we get to here, we are ready to reflect
  27.330 +	// need to set up virtual ifa, iha, itir (fast_reflect handles
  27.331 +	// virtual isr, iip, ipsr, ifs
  27.332 +	// see vcpu_get_itir_on_fault: get ps,rid,(FIXME key) from rr[ifa]
  27.333 +page_not_present:
  27.334 +	tbit.nz p6,p7=r16,IA64_ISR_X_BIT;;
  27.335 +(p6)	movl r20=0x400;;
  27.336 +(p7)	movl r20=0x800;;
  27.337 +
  27.338 +1:	extr.u r25=r17,61,3;;
  27.339 +	adds r21=XSI_RR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.340 +	shl r25=r25,3;;
  27.341 +	add r21=r21,r25;;
  27.342 +	ld8 r22=[r21];;
  27.343 +	extr.u r22=r22,2,30;;
  27.344 +	dep.z r22=r22,2,30;;
  27.345 +	adds r23=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.346 +	st8 [r23]=r22;;
  27.347 +
  27.348 +	// fast reflect expects
  27.349 +	//	r16 == cr.isr
  27.350 +	//	r18 == XSI_PSR_IC
  27.351 +	//	r20 == offset into ivt
  27.352 +	//	r29 == iip
  27.353 +	//	r30 == ipsr
  27.354 +	//	r31 == pr
  27.355 +	//mov r16=cr.isr
  27.356 +	mov r29=cr.iip
  27.357 +	mov r30=cr.ipsr
  27.358 +	br.sptk.many fast_reflect;;
  27.359 +END(fast_tlb_miss_reflect)
  27.360  
  27.361  // ensure that, if giving up, registers at entry to fast_hyperprivop unchanged
  27.362  ENTRY(hyper_rfi)
  27.363 @@ -807,6 +1073,7 @@ just_do_rfi:
  27.364  	// OK, now all set to go except for switch to virtual bank1
  27.365  	mov r22=1;; st4 [r20]=r22;
  27.366  	mov r30=r2; mov r29=r3;;
  27.367 +    mov r17=ar.unat;;
  27.368      adds r16=XSI_B1NATS_OFS-XSI_PSR_IC_OFS,r18
  27.369  	adds r2=XSI_BANK1_OFS-XSI_PSR_IC_OFS,r18;
  27.370  	adds r3=(XSI_BANK1_OFS+8)-XSI_PSR_IC_OFS,r18;;
  27.371 @@ -832,6 +1099,7 @@ just_do_rfi:
  27.372  	.mem.offset 8,0; ld8.fill r30=[r2],16 ;
  27.373  	.mem.offset 8,0; ld8.fill r31=[r3],16 ;;
  27.374  	bsw.0 ;;
  27.375 +    mov ar.unat=r17;;
  27.376  	mov r2=r30; mov r3=r29;;
  27.377  1:	mov pr=r31,-1
  27.378  	;;
  27.379 @@ -1485,7 +1753,7 @@ ENTRY(hyper_set_kr)
  27.380  	adds r21=XSI_KR0_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.381  	shl r20=r8,3;;
  27.382  	add r22=r20,r21;;
  27.383 -	st8 [r21]=r9;;
  27.384 +	st8 [r22]=r9;;
  27.385  	cmp.eq p7,p0=r8,r0
  27.386  	adds r8=-1,r8;;
  27.387  (p7)	mov ar0=r9;;
  27.388 @@ -1671,6 +1939,17 @@ 2:
  27.389  	;;
  27.390  END(hyper_ptc_ga)
  27.391  
  27.392 +// recovery block for hyper_itc metaphysical memory lookup
  27.393 +ENTRY(recover_and_dispatch_break_fault)
  27.394 +#ifdef FAST_REFLECT_CNT
  27.395 +	movl r21=recover_to_break_fault_count;;
  27.396 +	ld8 r22=[r21];;
  27.397 +	adds r22=1,r22;;
  27.398 +	st8 [r21]=r22;;
  27.399 +#endif
  27.400 +	mov b0=r29 ;;
  27.401 +	br.sptk.many dispatch_break_fault;;
  27.402 +
  27.403  //  Registers at entry
  27.404  //	r17 = break immediate (XEN_HYPER_ITC_D or I)
  27.405  //	r18 == XSI_PSR_IC_OFS
  27.406 @@ -1680,24 +1959,14 @@ ENTRY(hyper_itc_i)
  27.407  	// fall through, hyper_itc_d handles both i and d
  27.408  ENTRY(hyper_itc_d)
  27.409  #ifndef FAST_ITC
  27.410 -	br.spnt.many dispatch_break_fault ;;
  27.411 +	br.sptk.many dispatch_break_fault ;;
  27.412  #endif
  27.413 +	// ensure itir.ps >= xen's pagesize
  27.414  	adds r23=XSI_ITIR_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.415  	ld8 r23=[r23];;
  27.416  	extr.u r24=r23,2,6;;		// r24==logps
  27.417  	cmp.gt p7,p0=PAGE_SHIFT,r24
  27.418  (p7)	br.spnt.many dispatch_break_fault ;;
  27.419 -	// translate_domain_pte(r8=pteval,PSCB(ifa)=address,r24=itir)
  27.420 -	mov r19=1;;
  27.421 -	shl r20=r19,r24;;
  27.422 -	adds r20=-1,r20;;	// r20 == mask
  27.423 -	movl r19=_PAGE_PPN_MASK;;
  27.424 -	and r22=r8,r19;;	// r22 == pteval & _PAGE_PPN_MASK
  27.425 -	andcm r19=r22,r20;;
  27.426 -	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.427 -	ld8 r21=[r21];;
  27.428 -	and r20=r21,r20;;
  27.429 -	or r19=r19,r20;;	// r19 == mpaddr
  27.430  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  27.431  	ld8 r27=[r27];;
  27.432  	adds r27=IA64_VCPU_DOMAIN_OFFSET,r27;;
  27.433 @@ -1708,7 +1977,6 @@ ENTRY(hyper_itc_d)
  27.434  // FIXME: for now, only handle dom0 (see lookup_domain_mpa below)
  27.435  	cmp.ne p7,p0=r27,r28
  27.436  (p7)	br.spnt.many dispatch_break_fault ;;
  27.437 -	// if region 6, go slow way
  27.438  #ifdef FAST_HYPERPRIVOP_CNT
  27.439  	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  27.440  (p6)	movl r20=fast_hyperpriv_cnt+(8*XEN_HYPER_ITC_D);;
  27.441 @@ -1717,19 +1985,47 @@ ENTRY(hyper_itc_d)
  27.442  	adds r21=1,r21;;
  27.443  	st8 [r20]=r21;;
  27.444  #endif
  27.445 +(p6)	mov r17=2;;
  27.446 +(p7)	mov r17=3;;
  27.447 +	mov r29=b0 ;;
  27.448 +	movl r30=recover_and_dispatch_break_fault ;;
  27.449 +	mov r16=r8;;
  27.450 +	// fall through
  27.451 +
  27.452 +
  27.453 +// fast_insert(PSCB(ifa),r24=ps,r16=pte)
  27.454 +//	r16 == pte
  27.455 +//	r17 == bit0: 1=inst, 0=data; bit1: 1=itc, 0=vcpu_translate
  27.456 +//	r18 == XSI_PSR_IC_OFS
  27.457 +//	r24 == ps
  27.458 +//	r29 == saved value of b0 in case of recovery
  27.459 +//	r30 == recovery ip if failure occurs
  27.460 +//	r31 == pr
  27.461 +GLOBAL_ENTRY(fast_insert)
  27.462 +	// translate_domain_pte(r16=pteval,PSCB(ifa)=address,r24=itir)
  27.463 +	mov r19=1;;
  27.464 +	shl r20=r19,r24;;
  27.465 +	adds r20=-1,r20;;	// r20 == mask
  27.466 +	movl r19=_PAGE_PPN_MASK;;
  27.467 +	and r22=r16,r19;;	// r22 == pteval & _PAGE_PPN_MASK
  27.468 +	andcm r19=r22,r20;;
  27.469 +	adds r21=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.470 +	ld8 r21=[r21];;
  27.471 +	and r20=r21,r20;;
  27.472 +	or r19=r19,r20;;	// r19 == mpaddr
  27.473  // FIXME: for now, just do domain0 and skip mpaddr range checks
  27.474  	dep r20=r0,r19,0,PAGE_SHIFT
  27.475  	movl r21=PAGE_PHYS ;;
  27.476  	or r20=r20,r21 ;;	// r20==return value from lookup_domain_mpa
  27.477 -	// r8=pteval,r20=pteval2
  27.478 +	// r16=pteval,r20=pteval2
  27.479  	movl r19=_PAGE_PPN_MASK
  27.480  	movl r21=_PAGE_PL_2;;
  27.481 -	andcm r25=r8,r19;;	// r25==pteval & ~_PAGE_PPN_MASK
  27.482 +	andcm r25=r16,r19;;	// r25==pteval & ~_PAGE_PPN_MASK
  27.483  	and r22=r20,r19;;
  27.484  	or r22=r22,r21;;
  27.485  	or r22=r22,r25;;	// r22==return value from translate_domain_pte
  27.486  	// done with translate_domain_pte
  27.487 -	// now do vcpu_itc_no_srlz(vcpu,IorD,ifa,r22=pte,r8=mppte,r24=logps)
  27.488 +	// now do vcpu_itc_no_srlz(vcpu,IorD,ifa,r22=pte,r16=mppte,r24=logps)
  27.489  // FIXME: for now, just domain0 and skip range check
  27.490  	// psr.ic already cleared
  27.491  	// NOTE: r24 still contains ps (from above)
  27.492 @@ -1738,7 +2034,7 @@ ENTRY(hyper_itc_d)
  27.493  	adds r23=XSI_IFA_OFS-XSI_PSR_IC_OFS,r18 ;;
  27.494  	ld8 r23=[r23];;
  27.495  	mov cr.ifa=r23;;
  27.496 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  27.497 +	tbit.z p6,p7=r17,0;;
  27.498  (p6)	itc.d r22;;
  27.499  (p7)	itc.i r22;;
  27.500  	dv_serialize_data
  27.501 @@ -1755,7 +2051,7 @@ ENTRY(hyper_itc_d)
  27.502  	st8 [r20]=r21;;
  27.503  	// vcpu_set_tr_entry(trp,r22=pte|1,r24=itir,r23=ifa)
  27.504  	// TR_ENTRY = {page_flags,itir,addr,rid}
  27.505 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17
  27.506 +	tbit.z p6,p7=r17,0;;
  27.507  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  27.508  	ld8 r27=[r27];;
  27.509  	adds r28=IA64_VCPU_STARTING_RID_OFFSET,r27
  27.510 @@ -1766,7 +2062,6 @@ ENTRY(hyper_itc_d)
  27.511  	mov r19=-4096;;
  27.512  	and r23=r23,r19;;
  27.513  	st8 [r27]=r23,8;;	// ifa & ~0xfff
  27.514 -// ?? is virtualize_rid(v,get_rr(ifa))==vcpu_get_rr(ifa)?? YES!!
  27.515  	adds r29 = XSI_RR0_OFS-XSI_PSR_IC_OFS,r18
  27.516  	extr.u r25=r23,61,3;;
  27.517  	shladd r29=r25,3,r29;;
  27.518 @@ -1804,13 +2099,16 @@ 1:	// done with vcpu_set_tr_entry
  27.519  	//PSCBX(vcpu,i/dtlb_pte) = mp_pte
  27.520  	movl r27=THIS_CPU(cpu_kr)+IA64_KR_CURRENT_OFFSET;;
  27.521  	ld8 r27=[r27];;
  27.522 -	cmp.eq p6,p7=XEN_HYPER_ITC_D,r17;;
  27.523 +	tbit.z p6,p7=r17,0;;
  27.524  (p6)	adds r27=IA64_VCPU_DTLB_PTE_OFFSET,r27
  27.525  (p7)	adds r27=IA64_VCPU_ITLB_PTE_OFFSET,r27;;
  27.526 -	st8 [r27]=r8;;
  27.527 +	st8 [r27]=r16;;
  27.528  	// done with vcpu_itc_no_srlz
  27.529  
  27.530 -	// done, increment to point to next instruction
  27.531 +	// if hyper_itc, increment to point to next instruction
  27.532 +	tbit.z p7,p0=r17,1
  27.533 +(p7)	br.cond.sptk.few no_inc_iip;;
  27.534 +
  27.535  	mov r29=cr.ipsr
  27.536  	mov r30=cr.iip;;
  27.537  	extr.u r26=r29,41,2 ;;
  27.538 @@ -1822,8 +2120,11 @@ 1:	// done with vcpu_set_tr_entry
  27.539  	dep r29=r26,r29,41,2
  27.540  	;;
  27.541  	mov cr.ipsr=r29
  27.542 -	mov cr.iip=r30
  27.543 +	mov cr.iip=r30;;
  27.544 +
  27.545 +no_inc_iip:
  27.546  	mov pr=r31,-1 ;;
  27.547  	rfi
  27.548  	;;
  27.549 -END(hyper_itc_d)
  27.550 +END(fast_insert)
  27.551 +
    28.1 --- a/xen/arch/ia64/xen/ivt.S	Tue Nov 08 12:30:38 2005 +0100
    28.2 +++ b/xen/arch/ia64/xen/ivt.S	Tue Nov 08 12:31:43 2005 +0100
    28.3 @@ -246,7 +246,8 @@ ENTRY(itlb_miss)
    28.4  #ifdef XEN
    28.5  	VHPT_CCHAIN_LOOKUP(itlb_miss,i)
    28.6  #ifdef VHPT_GLOBAL
    28.7 -	br.cond.sptk page_fault
    28.8 +//	br.cond.sptk page_fault
    28.9 +	br.cond.sptk fast_tlb_miss_reflect
   28.10  	;;
   28.11  #endif
   28.12  #endif
   28.13 @@ -297,7 +298,8 @@ ENTRY(dtlb_miss)
   28.14  #ifdef XEN
   28.15  	VHPT_CCHAIN_LOOKUP(dtlb_miss,d)
   28.16  #ifdef VHPT_GLOBAL
   28.17 -	br.cond.sptk page_fault
   28.18 +//	br.cond.sptk page_fault
   28.19 +	br.cond.sptk fast_tlb_miss_reflect
   28.20  	;;
   28.21  #endif
   28.22  #endif
   28.23 @@ -485,6 +487,11 @@ END(alt_dtlb_miss)
   28.24  // 0x1400 Entry 5 (size 64 bundles) Data nested TLB (6,45)
   28.25  ENTRY(nested_dtlb_miss)
   28.26  	DBG_FAULT(5)
   28.27 +#ifdef XEN
   28.28 +	mov b0=r30
   28.29 +	br.sptk.many b0				// return to continuation point
   28.30 +	;;
   28.31 +#endif
   28.32  	/*
   28.33  	 * In the absence of kernel bugs, we get here when the virtually mapped linear
   28.34  	 * page table is accessed non-speculatively (e.g., in the Dirty-bit, Instruction
   28.35 @@ -562,7 +569,11 @@ END(ikey_miss)
   28.36  
   28.37  	//-----------------------------------------------------------------------------------
   28.38  	// call do_page_fault (predicates are in r31, psr.dt may be off, r16 is faulting address)
   28.39 +#ifdef XEN
   28.40 +GLOBAL_ENTRY(page_fault)
   28.41 +#else
   28.42  ENTRY(page_fault)
   28.43 +#endif
   28.44  	ssm psr.dt
   28.45  	;;
   28.46  	srlz.i
    29.1 --- a/xen/arch/ia64/xen/privop.c	Tue Nov 08 12:30:38 2005 +0100
    29.2 +++ b/xen/arch/ia64/xen/privop.c	Tue Nov 08 12:31:43 2005 +0100
    29.3 @@ -1040,6 +1040,9 @@ extern unsigned long dtlb_translate_coun
    29.4  extern unsigned long tr_translate_count;
    29.5  extern unsigned long phys_translate_count;
    29.6  extern unsigned long vhpt_translate_count;
    29.7 +extern unsigned long fast_vhpt_translate_count;
    29.8 +extern unsigned long recover_to_page_fault_count;
    29.9 +extern unsigned long recover_to_break_fault_count;
   29.10  extern unsigned long lazy_cover_count;
   29.11  extern unsigned long idle_when_pending;
   29.12  extern unsigned long pal_halt_light_count;
   29.13 @@ -1049,9 +1052,12 @@ int dump_misc_stats(char *buf)
   29.14  {
   29.15  	char *s = buf;
   29.16  	s += sprintf(s,"Virtual TR translations: %d\n",tr_translate_count);
   29.17 -	s += sprintf(s,"Virtual VHPT translations: %d\n",vhpt_translate_count);
   29.18 +	s += sprintf(s,"Virtual VHPT slow translations: %d\n",vhpt_translate_count);
   29.19 +	s += sprintf(s,"Virtual VHPT fast translations: %d\n",fast_vhpt_translate_count);
   29.20  	s += sprintf(s,"Virtual DTLB translations: %d\n",dtlb_translate_count);
   29.21  	s += sprintf(s,"Physical translations: %d\n",phys_translate_count);
   29.22 +	s += sprintf(s,"Recoveries to page fault: %d\n",recover_to_page_fault_count);
   29.23 +	s += sprintf(s,"Recoveries to break fault: %d\n",recover_to_break_fault_count);
   29.24  	s += sprintf(s,"Idle when pending: %d\n",idle_when_pending);
   29.25  	s += sprintf(s,"PAL_HALT_LIGHT (no pending): %d\n",pal_halt_light_count);
   29.26  	s += sprintf(s,"context switches: %d\n",context_switch_count);
   29.27 @@ -1065,6 +1071,9 @@ void zero_misc_stats(void)
   29.28  	tr_translate_count = 0;
   29.29  	phys_translate_count = 0;
   29.30  	vhpt_translate_count = 0;
   29.31 +	fast_vhpt_translate_count = 0;
   29.32 +	recover_to_page_fault_count = 0;
   29.33 +	recover_to_break_fault_count = 0;
   29.34  	lazy_cover_count = 0;
   29.35  	pal_halt_light_count = 0;
   29.36  	idle_when_pending = 0;
    30.1 --- a/xen/arch/ia64/xen/process.c	Tue Nov 08 12:30:38 2005 +0100
    30.2 +++ b/xen/arch/ia64/xen/process.c	Tue Nov 08 12:31:43 2005 +0100
    30.3 @@ -83,9 +83,8 @@ void schedule_tail(struct vcpu *next)
    30.4      if(VMX_DOMAIN(current)){
    30.5      	vmx_load_all_rr(current);
    30.6      }else{
    30.7 -	    if (rr7 = load_region_regs(current)) {
    30.8 -		    printk("schedule_tail: change to rr7 not yet implemented\n");
    30.9 -    	}
   30.10 +	    load_region_regs(current);
   30.11 +            vcpu_load_kernel_regs(current);
   30.12      }
   30.13  }
   30.14  
   30.15 @@ -185,6 +184,7 @@ void check_bad_nested_interruption(unsig
   30.16  	if (!(PSCB(v,ipsr) & IA64_PSR_DT)) {
   30.17  		panic_domain(regs,"psr.dt off, trying to deliver nested dtlb!\n");
   30.18  	}
   30.19 +	vector &= ~0xf;
   30.20  	if (vector != IA64_DATA_TLB_VECTOR &&
   30.21  		vector != IA64_ALT_DATA_TLB_VECTOR &&
   30.22  		vector != IA64_VHPT_TRANS_VECTOR) {
    31.1 --- a/xen/arch/ia64/xen/regionreg.c	Tue Nov 08 12:30:38 2005 +0100
    31.2 +++ b/xen/arch/ia64/xen/regionreg.c	Tue Nov 08 12:31:43 2005 +0100
    31.3 @@ -341,23 +341,13 @@ virtualize_rid(struct vcpu *v, unsigned 
    31.4  // rr7 (because we have to to assembly and physical mode
    31.5  // to change rr7).  If no change to rr7 is required, returns 0.
    31.6  //
    31.7 -unsigned long load_region_regs(struct vcpu *v)
    31.8 +void load_region_regs(struct vcpu *v)
    31.9  {
   31.10  	unsigned long rr0, rr1,rr2, rr3, rr4, rr5, rr6, rr7;
   31.11  	// TODO: These probably should be validated
   31.12  	unsigned long bad = 0;
   31.13  
   31.14  	if (VCPU(v,metaphysical_mode)) {
   31.15 -		ia64_rr rrv;
   31.16 -
   31.17 -#if 0
   31.18 -		rrv.rrval = 0;
   31.19 -		rrv.rid = v->domain->arch.metaphysical_rr0;
   31.20 -		rrv.ps = PAGE_SHIFT;
   31.21 -		rrv.ve = 1;
   31.22 -		rr0 = rrv.rrval;
   31.23 -		set_rr_no_srlz(0x0000000000000000L, rr0);
   31.24 -#endif
   31.25  		rr0 = v->domain->arch.metaphysical_rr0;
   31.26  		ia64_set_rr(0x0000000000000000L, rr0);
   31.27  		ia64_srlz_d();
   31.28 @@ -383,5 +373,4 @@ unsigned long load_region_regs(struct vc
   31.29  	if (bad) {
   31.30  		panic_domain(0,"load_region_regs: can't set! bad=%lx\n",bad);
   31.31  	}
   31.32 -	return 0;
   31.33  }
    32.1 --- a/xen/arch/ia64/xen/vcpu.c	Tue Nov 08 12:30:38 2005 +0100
    32.2 +++ b/xen/arch/ia64/xen/vcpu.c	Tue Nov 08 12:31:43 2005 +0100
    32.3 @@ -135,6 +135,18 @@ vcpu_set_gr(VCPU *vcpu, unsigned reg, UI
    32.4   VCPU privileged application register access routines
    32.5  **************************************************************************/
    32.6  
    32.7 +void vcpu_load_kernel_regs(VCPU *vcpu)
    32.8 +{
    32.9 +	ia64_set_kr(0, VCPU(vcpu, krs[0]));
   32.10 +	ia64_set_kr(1, VCPU(vcpu, krs[1]));
   32.11 +	ia64_set_kr(2, VCPU(vcpu, krs[2]));
   32.12 +	ia64_set_kr(3, VCPU(vcpu, krs[3]));
   32.13 +	ia64_set_kr(4, VCPU(vcpu, krs[4]));
   32.14 +	ia64_set_kr(5, VCPU(vcpu, krs[5]));
   32.15 +	ia64_set_kr(6, VCPU(vcpu, krs[6]));
   32.16 +	ia64_set_kr(7, VCPU(vcpu, krs[7]));
   32.17 +}
   32.18 +
   32.19  IA64FAULT vcpu_set_ar(VCPU *vcpu, UINT64 reg, UINT64 val)
   32.20  {
   32.21  	if (reg == 44) return (vcpu_set_itc(vcpu,val));
   32.22 @@ -1271,6 +1283,9 @@ IA64FAULT vcpu_ttag(VCPU *vcpu, UINT64 v
   32.23  #define itir_mask(itir) (~((1UL << itir_ps(itir)) - 1))
   32.24  
   32.25  unsigned long vhpt_translate_count = 0;
   32.26 +unsigned long fast_vhpt_translate_count = 0;
   32.27 +unsigned long recover_to_page_fault_count = 0;
   32.28 +unsigned long recover_to_break_fault_count = 0;
   32.29  
   32.30  IA64FAULT vcpu_translate(VCPU *vcpu, UINT64 address, BOOLEAN is_data, UINT64 *pteval, UINT64 *itir, UINT64 *iha)
   32.31  {
   32.32 @@ -1872,4 +1887,3 @@ IA64FAULT vcpu_ptr_i(VCPU *vcpu,UINT64 v
   32.33  	// don't forget to recompute itr_regions
   32.34  	return (IA64_ILLOP_FAULT);
   32.35  }
   32.36 -
    33.1 --- a/xen/arch/ia64/xen/xenmisc.c	Tue Nov 08 12:30:38 2005 +0100
    33.2 +++ b/xen/arch/ia64/xen/xenmisc.c	Tue Nov 08 12:31:43 2005 +0100
    33.3 @@ -290,8 +290,8 @@ void context_switch(struct vcpu *prev, s
    33.4  //prev->domain->domain_id,(long)prev&0xffffff,next->domain->domain_id,(long)next&0xffffff);
    33.5  //if (prev->domain->domain_id == 1 && next->domain->domain_id == 0) cs10foo();
    33.6  //if (prev->domain->domain_id == 0 && next->domain->domain_id == 1) cs01foo();
    33.7 -printk("@@sw%d/%x %d->%d\n",smp_processor_id(), hard_smp_processor_id (),
    33.8 -       prev->domain->domain_id,next->domain->domain_id);
    33.9 +//printk("@@sw%d/%x %d->%d\n",smp_processor_id(), hard_smp_processor_id (),
   33.10 +//       prev->domain->domain_id,next->domain->domain_id);
   33.11      if(VMX_DOMAIN(prev)){
   33.12      	vtm_domain_out(prev);
   33.13      }
   33.14 @@ -320,6 +320,7 @@ if (!i--) { printk("+",id); i = 1000000;
   33.15  		VHPT_ENABLED);
   33.16      	if (!is_idle_task(current->domain)) {
   33.17  	    	load_region_regs(current);
   33.18 +	    	vcpu_load_kernel_regs(current);
   33.19  		    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
   33.20      	}
   33.21  	    if (vcpu_timer_expired(current)) vcpu_pend_timer(current);
    34.1 --- a/xen/include/asm-ia64/time.h	Tue Nov 08 12:30:38 2005 +0100
    34.2 +++ b/xen/include/asm-ia64/time.h	Tue Nov 08 12:31:43 2005 +0100
    34.3 @@ -1,1 +1,2 @@
    34.4  #include <asm/linux/time.h>
    34.5 +#include <asm/timex.h>