ia64/xen-unstable

changeset 4298:96924dd0a482

bitkeeper revision 1.1262 (424320fcePB50JiZWWcQK3UQI1bAhQ)

Remove the changes to linux for running in shadow translate mode.
These changes are still in the bitkeeper tree, and will probably be pulled
forward at some future date.

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author mafetter@fleming.research
date Thu Mar 24 20:20:12 2005 +0000 (2005-03-24)
parents 13032fd25c06
children b2a62a1f2f20
files .rootkeys linux-2.6.10-xen-sparse/arch/xen/Kconfig linux-2.6.10-xen-sparse/arch/xen/configs/xen0_defconfig linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile linux-2.6.10-xen-sparse/arch/xen/i386/kernel/cpu/common.c linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S linux-2.6.10-xen-sparse/arch/xen/i386/kernel/ldt.c linux-2.6.10-xen-sparse/arch/xen/i386/kernel/pci-dma.c linux-2.6.10-xen-sparse/arch/xen/i386/kernel/process.c linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/fault.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/init.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/ioremap.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/pageattr.c linux-2.6.10-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.10-xen-sparse/arch/xen/kernel/reboot.c linux-2.6.10-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c linux-2.6.10-xen-sparse/drivers/xen/netback/netback.c linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6.10-xen-sparse/drivers/xen/privcmd/privcmd.c linux-2.6.10-xen-sparse/fs/exec.c linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/fixmap.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/io.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/page.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6.10-xen-sparse/mm/highmem.c linux-2.6.10-xen-sparse/mm/memory.c linux-2.6.10-xen-sparse/mm/swapfile.c xen/include/public/arch-x86_32.h
line diff
     1.1 --- a/.rootkeys	Thu Mar 24 16:48:36 2005 +0000
     1.2 +++ b/.rootkeys	Thu Mar 24 20:20:12 2005 +0000
     1.3 @@ -159,7 +159,6 @@ 40f56238YQIJoYG2ehDGEcdTgLmGbg linux-2.6
     1.4  40f56238nWMQg7CKbyTy0KJNvCzbtg linux-2.6.10-xen-sparse/arch/xen/i386/kernel/signal.c
     1.5  41811cac4lkCB-fHir6CcxuEJ2pGsQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smp.c
     1.6  41811ca9mbGpqBrZVrUGEiv8CTV3ng linux-2.6.10-xen-sparse/arch/xen/i386/kernel/smpboot.c
     1.7 -42308df8u332Gs7XX-jX4gsfFU2zOQ linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c
     1.8  40f56238qVGkpO_ycnQA8k03kQzAgA linux-2.6.10-xen-sparse/arch/xen/i386/kernel/time.c
     1.9  40f56238NzTgeO63RGoxHrW5NQeO3Q linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/Makefile
    1.10  40f56238BMqG5PuSHufpjbvp_helBw linux-2.6.10-xen-sparse/arch/xen/i386/kernel/timers/timer_tsc.c
    1.11 @@ -230,7 +229,6 @@ 41ee5e8bSs3BGC7yegM_ek2Tn0Ahvw linux-2.6
    1.12  41ee5e8bglvqKvZSY5uJ5JGQejEwyQ linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c
    1.13  41ee5e8ckZ9xVNvu9NHIZDK7JqApmQ linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c
    1.14  41ee5e8ck9scpGirfqEZRARbGDyTXA linux-2.6.10-xen-sparse/drivers/xen/usbfront/xhci.h
    1.15 -4236f620IqJ4VZVDPfMJzrpFrio8Sw linux-2.6.10-xen-sparse/fs/exec.c
    1.16  412f47e4RKD-R5IS5gEXvcT8L4v8gA linux-2.6.10-xen-sparse/include/asm-generic/pgtable.h
    1.17  40f56239YAjS52QG2FIAQpHDZAdGHg linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h
    1.18  4107adf1E5O4ztGHNGMzCCNhcvqNow linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h
    1.19 @@ -275,10 +273,8 @@ 419dfc609zbti8rqL60tL2dHXQ_rvQ linux-2.6
    1.20  4124f66f4NaKNa0xPiGGykn9QaZk3w linux-2.6.10-xen-sparse/include/linux/skbuff.h
    1.21  419dfc6awx7w88wk6cG9P3mPidX6LQ linux-2.6.10-xen-sparse/kernel/irq/manage.c
    1.22  40f56a0ddHCSs3501MY4hRf22tctOw linux-2.6.10-xen-sparse/mkbuildtree
    1.23 -4236f620IaM-42pgVYuNGF4cFrttbw linux-2.6.10-xen-sparse/mm/highmem.c
    1.24  412f46c0LJuKAgSPGoC0Z1DEkLfuLA linux-2.6.10-xen-sparse/mm/memory.c
    1.25  410a94a4KT6I6X0LVc7djB39tRDp4g linux-2.6.10-xen-sparse/mm/page_alloc.c
    1.26 -4236f620F2ZXlYSPUkwtN85tZMqDFQ linux-2.6.10-xen-sparse/mm/swapfile.c
    1.27  41505c572m-s9ATiO1LiD1GPznTTIg linux-2.6.10-xen-sparse/net/core/skbuff.c
    1.28  413cb1e4zst25MDYjg63Y-NGC5_pLg netbsd-2.0-xen-sparse/Makefile
    1.29  413cb1e5c_Mkxf_X0zimEhTKI_l4DA netbsd-2.0-xen-sparse/mkbuildtree
     2.1 --- a/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Thu Mar 24 16:48:36 2005 +0000
     2.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Thu Mar 24 20:20:12 2005 +0000
     2.3 @@ -115,44 +115,9 @@ config XEN_BLKDEV_TAP
     2.4  	  space.  Odds are that you want to say N here.
     2.5  
     2.6  config XEN_WRITABLE_PAGETABLES
     2.7 -	bool "writable page tables"
     2.8 +	bool
     2.9  	default y
    2.10  
    2.11 -config XEN_SYSCALL_STATS
    2.12 -	bool "system call statistics"
    2.13 -	default n
    2.14 -
    2.15 -config XEN_DEBUG_NO_MMU_BATCHING
    2.16 -	bool "Disables batching on MMU updates"
    2.17 -	default n
    2.18 -    help
    2.19 -      This does a hypercall per PTE update
    2.20 -      we only use this for benchmarking
    2.21 -      enable only if you know what you are doing
    2.22 -
    2.23 -config XEN_BATCH_MODE1
    2.24 -	bool "A variant of writable pagetable using the batch interface"
    2.25 -	default n
    2.26 -    help
    2.27 -      default is no batching and minor mods for some batching
    2.28 -      we only use this for benchmarking
    2.29 -      enable only if you know what you are doing
    2.30 -
    2.31 -config XEN_BATCH_MODE2
    2.32 -	bool "forward port of 2.4 batching"
    2.33 -	default n
    2.34 -    help
    2.35 -      default is batching + flushes where 2.4 had them
    2.36 -      we only use this for benchmarking
    2.37 -      enable only if you know what you are doing
    2.38 -
    2.39 -config XEN_SHADOW_MODE
    2.40 -	bool "Fake shadow mode"
    2.41 -	default n
    2.42 -    help
    2.43 -      fakes out a shadow mode kernel
    2.44 -
    2.45 -
    2.46  config XEN_SCRUB_PAGES
    2.47  	bool "Scrub memory before freeing it to Xen"
    2.48  	default y
     3.1 --- a/linux-2.6.10-xen-sparse/arch/xen/configs/xen0_defconfig	Thu Mar 24 16:48:36 2005 +0000
     3.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/configs/xen0_defconfig	Thu Mar 24 20:20:12 2005 +0000
     3.3 @@ -1,7 +1,7 @@
     3.4  #
     3.5  # Automatically generated make config: don't edit
     3.6  # Linux kernel version: 2.6.10-xen0
     3.7 -# Mon Mar 21 17:07:15 2005
     3.8 +# Mon Feb 21 13:46:38 2005
     3.9  #
    3.10  CONFIG_XEN=y
    3.11  CONFIG_ARCH_XEN=y
    3.12 @@ -12,18 +12,14 @@ CONFIG_NO_IDLE_HZ=y
    3.13  #
    3.14  CONFIG_XEN_PRIVILEGED_GUEST=y
    3.15  CONFIG_XEN_PHYSDEV_ACCESS=y
    3.16 -# CONFIG_XEN_BLKDEV_BACKEND is not set
    3.17 -# CONFIG_XEN_NETDEV_BACKEND is not set
    3.18 +CONFIG_XEN_BLKDEV_BACKEND=y
    3.19 +# CONFIG_XEN_BLKDEV_TAP_BE is not set
    3.20 +CONFIG_XEN_NETDEV_BACKEND=y
    3.21  CONFIG_XEN_BLKDEV_FRONTEND=y
    3.22  CONFIG_XEN_NETDEV_FRONTEND=y
    3.23  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
    3.24  # CONFIG_XEN_BLKDEV_TAP is not set
    3.25  CONFIG_XEN_WRITABLE_PAGETABLES=y
    3.26 -CONFIG_XEN_SYSCALL_STATS=y
    3.27 -# CONFIG_XEN_DEBUG_NO_MMU_BATCHING is not set
    3.28 -# CONFIG_XEN_BATCH_MODE1 is not set
    3.29 -# CONFIG_XEN_BATCH_MODE2 is not set
    3.30 -CONFIG_XEN_SHADOW_MODE=y
    3.31  CONFIG_XEN_SCRUB_PAGES=y
    3.32  CONFIG_X86=y
    3.33  # CONFIG_X86_64 is not set
     4.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile	Thu Mar 24 16:48:36 2005 +0000
     4.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/Makefile	Thu Mar 24 20:20:12 2005 +0000
     4.3 @@ -43,8 +43,6 @@ c-obj-$(CONFIG_HPET_TIMER) 	+= time_hpet
     4.4  c-obj-$(CONFIG_EFI) 		+= efi.o efi_stub.o
     4.5  c-obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
     4.6  
     4.7 -c-obj-$(CONFIG_XEN_SYSCALL_STATS) += syscall_stats.o
     4.8 -
     4.9  EXTRA_AFLAGS   := -traditional
    4.10  
    4.11  c-obj-$(CONFIG_SCx200)		+= scx200.o
     5.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Thu Mar 24 16:48:36 2005 +0000
     5.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Thu Mar 24 20:20:12 2005 +0000
     5.3 @@ -512,11 +512,7 @@ void __init cpu_gdt_init(struct Xgt_desc
     5.4  	for (va = gdt_descr->address, f = 0;
     5.5  	     va < gdt_descr->address + gdt_descr->size;
     5.6  	     va += PAGE_SIZE, f++) {
     5.7 -#ifndef CONFIG_XEN_SHADOW_MODE
     5.8  		frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
     5.9 -#else /* CONFIG_XEN_SHADOW_MODE */
    5.10 -		frames[f] = __vms_virt_to_machine(va) >> PAGE_SHIFT;
    5.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
    5.12  		make_page_readonly((void *)va);
    5.13  	}
    5.14  	flush_page_update_queue();
     6.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Mar 24 16:48:36 2005 +0000
     6.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/entry.S	Thu Mar 24 20:20:12 2005 +0000
     6.3 @@ -280,10 +280,7 @@ 1:	movl (%ebp),%ebp
     6.4  	jnz syscall_trace_entry
     6.5  	cmpl $(nr_syscalls), %eax
     6.6  	jae syscall_badsys
     6.7 -#ifdef CONFIG_XEN_SYSCALL_STATS
     6.8 -    lock incl syscall_stats(,%eax,4)
     6.9 -#endif
    6.10 -    call *sys_call_table(,%eax,4)
    6.11 +	call *sys_call_table(,%eax,4)
    6.12  	movl %eax,EAX(%esp)
    6.13  	cli
    6.14  	movl TI_flags(%ebp), %ecx
    6.15 @@ -308,10 +305,7 @@ ENTRY(system_call)
    6.16  	cmpl $(nr_syscalls), %eax
    6.17  	jae syscall_badsys
    6.18  syscall_call:
    6.19 -#ifdef CONFIG_XEN_SYSCALL_STATS
    6.20 -    lock incl syscall_stats(,%eax,4)
    6.21 -#endif
    6.22 -    call *sys_call_table(,%eax,4)
    6.23 +	call *sys_call_table(,%eax,4)
    6.24  	movl %eax,EAX(%esp)		# store the return value
    6.25  syscall_exit:
    6.26  	XEN_BLOCK_EVENTS(%esi)		# make sure we don't miss an interrupt
     7.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/ldt.c	Thu Mar 24 16:48:36 2005 +0000
     7.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/ldt.c	Thu Mar 24 20:20:12 2005 +0000
     7.3 @@ -61,10 +61,8 @@ static int alloc_ldt(mm_context_t *pc, i
     7.4  		cpumask_t mask;
     7.5  		preempt_disable();
     7.6  #endif
     7.7 -#ifndef CONFIG_XEN_SHADOW_MODE
     7.8  		make_pages_readonly(pc->ldt, (pc->size * LDT_ENTRY_SIZE) /
     7.9  				    PAGE_SIZE);
    7.10 -#endif /* CONFIG_XEN_SHADOW_MODE */
    7.11  		load_LDT(pc);
    7.12  		flush_page_update_queue();
    7.13  #ifdef CONFIG_SMP
    7.14 @@ -75,10 +73,8 @@ static int alloc_ldt(mm_context_t *pc, i
    7.15  #endif
    7.16  	}
    7.17  	if (oldsize) {
    7.18 -#ifndef CONFIG_XEN_SHADOW_MODE
    7.19  		make_pages_writable(oldldt, (oldsize * LDT_ENTRY_SIZE) /
    7.20  			PAGE_SIZE);
    7.21 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
    7.22  		flush_page_update_queue();
    7.23  		if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
    7.24  			vfree(oldldt);
    7.25 @@ -94,10 +90,8 @@ static inline int copy_ldt(mm_context_t 
    7.26  	if (err < 0)
    7.27  		return err;
    7.28  	memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
    7.29 -#ifndef CONFIG_XEN_SHADOW_MODE
    7.30  	make_pages_readonly(new->ldt, (new->size * LDT_ENTRY_SIZE) /
    7.31  			    PAGE_SIZE);
    7.32 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
    7.33  	flush_page_update_queue();
    7.34  	return 0;
    7.35  }
    7.36 @@ -130,11 +124,9 @@ void destroy_context(struct mm_struct *m
    7.37  	if (mm->context.size) {
    7.38  		if (mm == current->active_mm)
    7.39  			clear_LDT();
    7.40 -#ifndef CONFIG_XEN_SHADOW_MODE
    7.41  		make_pages_writable(mm->context.ldt, 
    7.42  				    (mm->context.size * LDT_ENTRY_SIZE) /
    7.43  				    PAGE_SIZE);
    7.44 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
    7.45  		flush_page_update_queue();
    7.46  		if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
    7.47  			vfree(mm->context.ldt);
    7.48 @@ -230,11 +222,7 @@ static int write_ldt(void __user * ptr, 
    7.49  	}
    7.50  
    7.51  	lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
    7.52 -#ifndef CONFIG_XEN_SHADOW_MODE
    7.53  	mach_lp = arbitrary_virt_to_machine(lp);
    7.54 -#else /* CONFIG_XEN_SHADOW_MODE */
    7.55 -	mach_lp = arbitrary_virt_to_phys(lp);
    7.56 -#endif /* CONFIG_XEN_SHADOW_MODE */
    7.57  
    7.58     	/* Allow LDTs to be cleared by the user. */
    7.59     	if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
     8.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Thu Mar 24 16:48:36 2005 +0000
     8.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Thu Mar 24 20:20:12 2005 +0000
     8.3 @@ -30,7 +30,6 @@ struct dma_coherent_mem {
     8.4  static void
     8.5  xen_contig_memory(unsigned long vstart, unsigned int order)
     8.6  {
     8.7 -#ifndef CONFIG_XEN_SHADOW_MODE
     8.8  	/*
     8.9  	 * Ensure multi-page extents are contiguous in machine memory.
    8.10  	 * This code could be cleaned up some, and the number of
    8.11 @@ -77,7 +76,6 @@ xen_contig_memory(unsigned long vstart, 
    8.12  	xen_tlb_flush();
    8.13  
    8.14          balloon_unlock(flags);
    8.15 -#endif /* CONFIG_XEN_SHADOW_MODE */
    8.16  }
    8.17  
    8.18  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
     9.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/process.c	Thu Mar 24 16:48:36 2005 +0000
     9.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/process.c	Thu Mar 24 20:20:12 2005 +0000
     9.3 @@ -514,23 +514,17 @@ struct task_struct fastcall * __switch_t
     9.4  	 * Load the per-thread Thread-Local Storage descriptor.
     9.5  	 * This is load_TLS(next, cpu) with multicalls.
     9.6  	 */
     9.7 -#ifndef CONFIG_XEN_SHADOW_MODE
     9.8 -#define C_VIRT_TO_MACH virt_to_machine
     9.9 -#else /* CONFIG_XEN_SHADOW_MODE */
    9.10 -#define C_VIRT_TO_MACH virt_to_phys
    9.11 -#endif
    9.12  #define C(i) do {							    \
    9.13  	if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||	    \
    9.14  		     next->tls_array[i].b != prev->tls_array[i].b))	    \
    9.15  		queue_multicall3(__HYPERVISOR_update_descriptor,	    \
    9.16 -				 C_VIRT_TO_MACH(&get_cpu_gdt_table(cpu)     \
    9.17 +				 virt_to_machine(&get_cpu_gdt_table(cpu)    \
    9.18  						 [GDT_ENTRY_TLS_MIN + i]),  \
    9.19  				 ((u32 *)&next->tls_array[i])[0],	    \
    9.20  				 ((u32 *)&next->tls_array[i])[1]);	    \
    9.21  } while (0)
    9.22  	C(0); C(1); C(2);
    9.23  #undef C
    9.24 -#undef C_VIRT_TO_MACH
    9.25  
    9.26  	if (xen_start_info.flags & SIF_PRIVILEGED) {
    9.27  		op.cmd           = DOM0_IOPL;
    10.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Mar 24 16:48:36 2005 +0000
    10.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c	Thu Mar 24 20:20:12 2005 +0000
    10.3 @@ -345,13 +345,8 @@ static void __init probe_roms(void)
    10.4  shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
    10.5  EXPORT_SYMBOL(HYPERVISOR_shared_info);
    10.6  
    10.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    10.8  unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
    10.9  EXPORT_SYMBOL(phys_to_machine_mapping);
   10.10 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.11 -unsigned int *__vms_phys_to_machine_mapping, *__vms_pfn_to_mfn_frame_list;
   10.12 -EXPORT_SYMBOL(__vms_phys_to_machine_mapping);
   10.13 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.14  
   10.15  DEFINE_PER_CPU(multicall_entry_t, multicall_list[8]);
   10.16  DEFINE_PER_CPU(int, nr_multicall_ents);
   10.17 @@ -1147,11 +1142,7 @@ static unsigned long __init setup_memory
   10.18  	}
   10.19  #endif
   10.20  
   10.21 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.22  	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
   10.23 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.24 -	__vms_phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
   10.25 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.26  
   10.27  	return max_low_pfn;
   10.28  }
   10.29 @@ -1446,23 +1437,11 @@ void __init setup_arch(char **cmdline_p)
   10.30  
   10.31  	/* Make sure we have a large enough P->M table. */
   10.32  	if (max_pfn > xen_start_info.nr_pages) {
   10.33 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.34  		phys_to_machine_mapping = alloc_bootmem_low_pages(
   10.35 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.36 -		__vms_phys_to_machine_mapping = alloc_bootmem_low_pages(
   10.37 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.38  			max_pfn * sizeof(unsigned long));
   10.39 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.40  		memset(phys_to_machine_mapping, ~0,
   10.41 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.42 -		memset(__vms_phys_to_machine_mapping, ~0,
   10.43 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.44  			max_pfn * sizeof(unsigned long));
   10.45 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.46  		memcpy(phys_to_machine_mapping,
   10.47 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.48 -		memcpy(__vms_phys_to_machine_mapping,
   10.49 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.50  			(unsigned long *)xen_start_info.mfn_list,
   10.51  			xen_start_info.nr_pages * sizeof(unsigned long));
   10.52  		free_bootmem(
   10.53 @@ -1471,27 +1450,14 @@ void __init setup_arch(char **cmdline_p)
   10.54  			sizeof(unsigned long))));
   10.55  	}
   10.56  
   10.57 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.58  	pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
   10.59 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.60 -	__vms_pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
   10.61 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.62  	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
   10.63  	{	
   10.64 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.65  	     pfn_to_mfn_frame_list[j] = 
   10.66  		  virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   10.67 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.68 -	     __vms_pfn_to_mfn_frame_list[j] = 
   10.69 -		  __vms_virt_to_machine(&__vms_phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   10.70 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.71  	}
   10.72  	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
   10.73 -#ifndef CONFIG_XEN_SHADOW_MODE
   10.74  	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   10.75 -#else /* CONFIG_XEN_SHADOW_MODE */
   10.76 -	     __vms_virt_to_machine(__vms_pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   10.77 -#endif /* CONFIG_XEN_SHADOW_MODE */
   10.78  
   10.79  
   10.80  	/*
    11.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/syscall_stats.c	Thu Mar 24 16:48:36 2005 +0000
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,101 +0,0 @@
    11.4 -/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
    11.5 - ****************************************************************************
    11.6 - * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge
    11.7 - ****************************************************************************
    11.8 - *
    11.9 - *        File: syscall_stats.c
   11.10 - *      Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
   11.11 - *        Date: Mar 2005
   11.12 - * 
   11.13 - * Description: add a proc interface to get per system call stats
   11.14 - */
   11.15 -
   11.16 -
   11.17 -#include <linux/config.h>
   11.18 -#include <linux/proc_fs.h>
   11.19 -#include <linux/seq_file.h>
   11.20 -#include <asm/unistd.h>
   11.21 -
   11.22 -unsigned long syscall_stats[NR_syscalls];
   11.23 -static unsigned char foobar[4];
   11.24 -
   11.25 -unsigned long c_do_page_fault;
   11.26 -unsigned long c_minor_page_fault;
   11.27 -unsigned long c_major_page_fault;
   11.28 -
   11.29 -/* a write just resests the counter */
   11.30 -static ssize_t syscall_write(struct file *f, const  char *data,
   11.31 -                             size_t size, loff_t  *pos)
   11.32 -{
   11.33 -    printk("resetting syscall stats\n");
   11.34 -    memset(&syscall_stats, 0, sizeof(syscall_stats));
   11.35 -    c_do_page_fault = 0;
   11.36 -    c_minor_page_fault = 0;
   11.37 -    c_major_page_fault = 0;
   11.38 -    return size;
   11.39 -}
   11.40 -
   11.41 -static int show_syscall(struct seq_file *m, void *v)
   11.42 -{
   11.43 -    int i;
   11.44 -    for ( i=0; i<NR_syscalls; i++ )
   11.45 -    {
   11.46 -        seq_printf(m, "%lu ", syscall_stats[i]);
   11.47 -    }
   11.48 -    seq_printf(m, "\n");
   11.49 -    seq_printf(m, "%lu %lu %lu\n", c_do_page_fault,
   11.50 -               c_minor_page_fault, c_major_page_fault);
   11.51 -    
   11.52 -    return 0;
   11.53 -}
   11.54 -
   11.55 -static void *c_start(struct seq_file *m, loff_t *pos)
   11.56 -{
   11.57 -    return *pos == 0 ? foobar : NULL;
   11.58 -}
   11.59 -
   11.60 -static void *c_next(struct seq_file *m, void *v, loff_t *pos)
   11.61 -{
   11.62 -    ++*pos;
   11.63 -    return c_start(m, pos);
   11.64 -}
   11.65 -
   11.66 -static void c_stop(struct seq_file *m, void *v)
   11.67 -{
   11.68 -}
   11.69 -
   11.70 -static struct seq_operations syscall_op = {
   11.71 -    start:  c_start,
   11.72 -    next:   c_next,
   11.73 -    stop:   c_stop,
   11.74 -    show:   show_syscall,
   11.75 -};
   11.76 -
   11.77 -static int syscall_open(struct inode *inode, struct file *file)
   11.78 -{
   11.79 -    return seq_open(file, &syscall_op);
   11.80 -}
   11.81 -
   11.82 -static struct file_operations proc_syscall_operations = {
   11.83 -    open:           syscall_open,
   11.84 -    read:           seq_read,
   11.85 -    write:          syscall_write,
   11.86 -    llseek:         seq_lseek,
   11.87 -    release:        seq_release,
   11.88 -};
   11.89 -
   11.90 -
   11.91 -static struct proc_dir_entry *entry;
   11.92 -
   11.93 -static int __init syscall_stats_init(void)
   11.94 -{
   11.95 -    printk("Initialising syscall stats.\n");
   11.96 -
   11.97 -    entry = create_proc_entry("syscalls", 0777, NULL);
   11.98 -    if (entry)
   11.99 -        entry->proc_fops = &proc_syscall_operations;
  11.100 -    else
  11.101 -        printk("Unable to create /proc/syscalls.\n");
  11.102 -    return 0;
  11.103 -}
  11.104 -subsys_initcall(syscall_stats_init);
    12.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/fault.c	Thu Mar 24 16:48:36 2005 +0000
    12.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/fault.c	Thu Mar 24 20:20:12 2005 +0000
    12.3 @@ -216,11 +216,6 @@ fastcall void do_invalid_op(struct pt_re
    12.4   *	bit 1 == 0 means read, 1 means write
    12.5   *	bit 2 == 0 means kernel, 1 means user-mode
    12.6   */
    12.7 -
    12.8 -extern unsigned long c_do_page_fault;
    12.9 -extern unsigned long c_minor_page_fault;
   12.10 -extern unsigned long c_major_page_fault;
   12.11 -
   12.12  fastcall void do_page_fault(struct pt_regs *regs, unsigned long error_code,
   12.13  			      unsigned long address)
   12.14  {
   12.15 @@ -231,19 +226,11 @@ fastcall void do_page_fault(struct pt_re
   12.16  	int write;
   12.17  	siginfo_t info;
   12.18  
   12.19 -    c_do_page_fault++;
   12.20 -
   12.21  	/* Set the "privileged fault" bit to something sane. */
   12.22  	error_code &= 3;
   12.23  	error_code |= (regs->xcs & 2) << 1;
   12.24  	if (regs->eflags & X86_EFLAGS_VM)
   12.25  		error_code |= 4;
   12.26 -
   12.27 -#ifdef CONFIG_XEN_BATCH_MODE2
   12.28 -    /* ensure all updates have completed */
   12.29 -    flush_page_update_queue();
   12.30 -#endif
   12.31 -
   12.32  		
   12.33   	if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
   12.34   					SIGSEGV) == NOTIFY_STOP)
   12.35 @@ -366,11 +353,9 @@ good_area:
   12.36  	switch (handle_mm_fault(mm, vma, address, write)) {
   12.37  		case VM_FAULT_MINOR:
   12.38  			tsk->min_flt++;
   12.39 -            c_minor_page_fault++;
   12.40  			break;
   12.41  		case VM_FAULT_MAJOR:
   12.42  			tsk->maj_flt++;
   12.43 -            c_major_page_fault++;
   12.44  			break;
   12.45  		case VM_FAULT_SIGBUS:
   12.46  			goto do_sigbus;
   12.47 @@ -473,13 +458,8 @@ no_context:
   12.48  	printk("%08lx\n", regs->eip);
   12.49  	page = ((unsigned long *) per_cpu(cur_pgd, smp_processor_id()))
   12.50  	    [address >> 22];
   12.51 -#ifndef CONFIG_XEN_SHADOW_MODE
   12.52  	printk(KERN_ALERT "*pde = ma %08lx pa %08lx\n", page,
   12.53  	       machine_to_phys(page));
   12.54 -#else /* CONFIG_XEN_SHADOW_MODE */
   12.55 -	printk(KERN_ALERT "*pde = ma %08lx pa %08lx\n",
   12.56 -	       __vms_phys_to_machine(page), page);
   12.57 -#endif /* CONFIG_XEN_SHADOW_MODE */
   12.58  	/*
   12.59  	 * We must not directly access the pte in the highpte
   12.60  	 * case, the page table might be allocated in highmem.
   12.61 @@ -490,17 +470,10 @@ no_context:
   12.62  	if (page & 1) {
   12.63  		page &= PAGE_MASK;
   12.64  		address &= 0x003ff000;
   12.65 -#ifndef CONFIG_XEN_SHADOW_MODE
   12.66  		page = machine_to_phys(page);
   12.67 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   12.68  		page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT];
   12.69 -#ifndef CONFIG_XEN_SHADOW_MODE
   12.70  		printk(KERN_ALERT "*pte = ma %08lx pa %08lx\n", page,
   12.71  		       machine_to_phys(page));
   12.72 -#else /* CONFIG_XEN_SHADOW_MODE */
   12.73 -		printk(KERN_ALERT "*pte = ma %08lx pa %08lx\n",
   12.74 -		       __vms_phys_to_machine(page), page);
   12.75 -#endif /* CONFIG_XEN_SHADOW_MODE */
   12.76  	}
   12.77  #endif
   12.78  	show_trace(NULL, (unsigned long *)&regs[1]);
    13.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Mar 24 16:48:36 2005 +0000
    13.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Thu Mar 24 20:20:12 2005 +0000
    13.3 @@ -56,11 +56,7 @@ static spinlock_t update_lock = SPIN_LOC
    13.4  #ifdef CONFIG_SMP
    13.5  #define QUEUE_SIZE 1
    13.6  #else
    13.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    13.8  #define QUEUE_SIZE 128
    13.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   13.10 -#define QUEUE_SIZE 1
   13.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.12  #endif
   13.13  #endif
   13.14  
   13.15 @@ -129,27 +125,6 @@ static inline void increment_index_and_f
   13.16  
   13.17  void queue_l1_entry_update(pte_t *ptr, unsigned long val)
   13.18  {
   13.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   13.20 -    int cpu = smp_processor_id();
   13.21 -    int idx;
   13.22 -    unsigned long flags;
   13.23 -    spin_lock_irqsave(&update_lock, flags);
   13.24 -    idx = per_cpu(mmu_update_queue_idx, cpu);
   13.25 -    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
   13.26 -    per_cpu(update_queue[idx], cpu).val = val;
   13.27 -    increment_index();
   13.28 -#ifdef CONFIG_XEN_DEBUG_NO_MMU_BATCHING
   13.29 -    __flush_page_update_queue();
   13.30 -#endif
   13.31 -    spin_unlock_irqrestore(&update_lock, flags);
   13.32 -#else
   13.33 -    set_pte(ptr, __pte(val));
   13.34 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.35 -}
   13.36 -
   13.37 -void queue_l2_entry_update(pmd_t *ptr, unsigned long val)
   13.38 -{
   13.39 -#ifndef CONFIG_XEN_SHADOW_MODE
   13.40      int cpu = smp_processor_id();
   13.41      int idx;
   13.42      unsigned long flags;
   13.43 @@ -159,9 +134,19 @@ void queue_l2_entry_update(pmd_t *ptr, u
   13.44      per_cpu(update_queue[idx], cpu).val = val;
   13.45      increment_index();
   13.46      spin_unlock_irqrestore(&update_lock, flags);
   13.47 -#else
   13.48 -    set_pmd(ptr, __pmd(val));
   13.49 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.50 +}
   13.51 +
   13.52 +void queue_l2_entry_update(pmd_t *ptr, unsigned long val)
   13.53 +{
   13.54 +    int cpu = smp_processor_id();
   13.55 +    int idx;
   13.56 +    unsigned long flags;
   13.57 +    spin_lock_irqsave(&update_lock, flags);
   13.58 +    idx = per_cpu(mmu_update_queue_idx, cpu);
   13.59 +    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
   13.60 +    per_cpu(update_queue[idx], cpu).val = val;
   13.61 +    increment_index();
   13.62 +    spin_unlock_irqrestore(&update_lock, flags);
   13.63  }
   13.64  
   13.65  void queue_pt_switch(unsigned long ptr)
   13.66 @@ -171,11 +156,7 @@ void queue_pt_switch(unsigned long ptr)
   13.67      unsigned long flags;
   13.68      spin_lock_irqsave(&update_lock, flags);
   13.69      idx = per_cpu(mmu_update_queue_idx, cpu);
   13.70 -#ifndef CONFIG_XEN_SHADOW_MODE
   13.71      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   13.72 -#else /* CONFIG_XEN_SHADOW_MODE */
   13.73 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   13.74 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.75      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   13.76      per_cpu(update_queue[idx], cpu).val  = MMUEXT_NEW_BASEPTR;
   13.77      increment_index();
   13.78 @@ -209,88 +190,56 @@ void queue_invlpg(unsigned long ptr)
   13.79      spin_unlock_irqrestore(&update_lock, flags);
   13.80  }
   13.81  
   13.82 -#ifndef CONFIG_XEN_SHADOW_MODE
   13.83  void queue_pgd_pin(unsigned long ptr)
   13.84 -#else /* CONFIG_XEN_SHADOW_MODE */
   13.85 -void __vms_queue_pgd_pin(unsigned long ptr)
   13.86 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.87  {
   13.88      int cpu = smp_processor_id();
   13.89      int idx;
   13.90      unsigned long flags;
   13.91      spin_lock_irqsave(&update_lock, flags);
   13.92      idx = per_cpu(mmu_update_queue_idx, cpu);
   13.93 -#ifndef CONFIG_XEN_SHADOW_MODE
   13.94      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   13.95 -#else /* CONFIG_XEN_SHADOW_MODE */
   13.96 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   13.97 -#endif /* CONFIG_XEN_SHADOW_MODE */
   13.98      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   13.99      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L2_TABLE;
  13.100      increment_index();
  13.101      spin_unlock_irqrestore(&update_lock, flags);
  13.102  }
  13.103  
  13.104 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.105  void queue_pgd_unpin(unsigned long ptr)
  13.106 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.107 -void __vms_queue_pgd_unpin(unsigned long ptr)
  13.108 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.109  {
  13.110      int cpu = smp_processor_id();
  13.111      int idx;
  13.112      unsigned long flags;
  13.113      spin_lock_irqsave(&update_lock, flags);
  13.114      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.115 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.116      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.117 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.118 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.119 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.120      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.121      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
  13.122      increment_index();
  13.123      spin_unlock_irqrestore(&update_lock, flags);
  13.124  }
  13.125  
  13.126 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.127  void queue_pte_pin(unsigned long ptr)
  13.128 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.129 -void __vms_queue_pte_pin(unsigned long ptr)
  13.130 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.131  {
  13.132      int cpu = smp_processor_id();
  13.133      int idx;
  13.134      unsigned long flags;
  13.135      spin_lock_irqsave(&update_lock, flags);
  13.136      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.137 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.138      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.139 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.140 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.141 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.142      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.143      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L1_TABLE;
  13.144      increment_index();
  13.145      spin_unlock_irqrestore(&update_lock, flags);
  13.146  }
  13.147  
  13.148 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.149  void queue_pte_unpin(unsigned long ptr)
  13.150 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.151 -void __vms_queue_pte_unpin(unsigned long ptr)
  13.152 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.153  {
  13.154      int cpu = smp_processor_id();
  13.155      int idx;
  13.156      unsigned long flags;
  13.157      spin_lock_irqsave(&update_lock, flags);
  13.158      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.159 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.160      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.161 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.162 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.163 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.164      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.165      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
  13.166      increment_index();
  13.167 @@ -326,7 +275,6 @@ void queue_machphys_update(unsigned long
  13.168  /* queue and flush versions of the above */
  13.169  void xen_l1_entry_update(pte_t *ptr, unsigned long val)
  13.170  {
  13.171 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.172      int cpu = smp_processor_id();
  13.173      int idx;
  13.174      unsigned long flags;
  13.175 @@ -336,14 +284,10 @@ void xen_l1_entry_update(pte_t *ptr, uns
  13.176      per_cpu(update_queue[idx], cpu).val = val;
  13.177      increment_index_and_flush();
  13.178      spin_unlock_irqrestore(&update_lock, flags);
  13.179 -#else
  13.180 -    set_pte(ptr, __pte(val));
  13.181 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.182  }
  13.183  
  13.184  void xen_l2_entry_update(pmd_t *ptr, unsigned long val)
  13.185  {
  13.186 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.187      int cpu = smp_processor_id();
  13.188      int idx;
  13.189      unsigned long flags;
  13.190 @@ -353,9 +297,6 @@ void xen_l2_entry_update(pmd_t *ptr, uns
  13.191      per_cpu(update_queue[idx], cpu).val = val;
  13.192      increment_index_and_flush();
  13.193      spin_unlock_irqrestore(&update_lock, flags);
  13.194 -#else
  13.195 -    set_pmd(ptr, __pmd(val));
  13.196 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.197  }
  13.198  
  13.199  void xen_pt_switch(unsigned long ptr)
  13.200 @@ -365,11 +306,7 @@ void xen_pt_switch(unsigned long ptr)
  13.201      unsigned long flags;
  13.202      spin_lock_irqsave(&update_lock, flags);
  13.203      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.204 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.205      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.206 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.207 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.208 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.209      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.210      per_cpu(update_queue[idx], cpu).val  = MMUEXT_NEW_BASEPTR;
  13.211      increment_index_and_flush();
  13.212 @@ -403,88 +340,56 @@ void xen_invlpg(unsigned long ptr)
  13.213      spin_unlock_irqrestore(&update_lock, flags);
  13.214  }
  13.215  
  13.216 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.217  void xen_pgd_pin(unsigned long ptr)
  13.218 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.219 -void __vms_xen_pgd_pin(unsigned long ptr)
  13.220 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.221  {
  13.222      int cpu = smp_processor_id();
  13.223      int idx;
  13.224      unsigned long flags;
  13.225      spin_lock_irqsave(&update_lock, flags);
  13.226      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.227 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.228      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.229 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.230 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.231 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.232      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.233      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L2_TABLE;
  13.234      increment_index_and_flush();
  13.235      spin_unlock_irqrestore(&update_lock, flags);
  13.236  }
  13.237  
  13.238 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.239  void xen_pgd_unpin(unsigned long ptr)
  13.240 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.241 -void __vms_xen_pgd_unpin(unsigned long ptr)
  13.242 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.243  {
  13.244      int cpu = smp_processor_id();
  13.245      int idx;
  13.246      unsigned long flags;
  13.247      spin_lock_irqsave(&update_lock, flags);
  13.248      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.249 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.250      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.251 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.252 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.253 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.254      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.255      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
  13.256      increment_index_and_flush();
  13.257      spin_unlock_irqrestore(&update_lock, flags);
  13.258  }
  13.259  
  13.260 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.261  void xen_pte_pin(unsigned long ptr)
  13.262 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.263 -void __vms_xen_pte_pin(unsigned long ptr)
  13.264 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.265  {
  13.266      int cpu = smp_processor_id();
  13.267      int idx;
  13.268      unsigned long flags;
  13.269      spin_lock_irqsave(&update_lock, flags);
  13.270      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.271 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.272      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.273 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.274 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.275 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.276      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.277      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L1_TABLE;
  13.278      increment_index_and_flush();
  13.279      spin_unlock_irqrestore(&update_lock, flags);
  13.280  }
  13.281  
  13.282 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.283  void xen_pte_unpin(unsigned long ptr)
  13.284 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.285 -void __vms_xen_pte_unpin(unsigned long ptr)
  13.286 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.287  {
  13.288      int cpu = smp_processor_id();
  13.289      int idx;
  13.290      unsigned long flags;
  13.291      spin_lock_irqsave(&update_lock, flags);
  13.292      idx = per_cpu(mmu_update_queue_idx, cpu);
  13.293 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.294      per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
  13.295 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.296 -    per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
  13.297 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.298      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
  13.299      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
  13.300      increment_index_and_flush();
  13.301 @@ -546,11 +451,7 @@ unsigned long allocate_empty_lowmem_regi
  13.302          pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE))); 
  13.303          pfn_array[i] = pte->pte_low >> PAGE_SHIFT;
  13.304          queue_l1_entry_update(pte, 0);
  13.305 -#ifndef CONFIG_XEN_SHADOW_MODE
  13.306          phys_to_machine_mapping[__pa(vstart)>>PAGE_SHIFT] = INVALID_P2M_ENTRY;
  13.307 -#else /* CONFIG_XEN_SHADOW_MODE */
  13.308 -        __vms_phys_to_machine_mapping[__pa(vstart)>>PAGE_SHIFT] = INVALID_P2M_ENTRY;
  13.309 -#endif /* CONFIG_XEN_SHADOW_MODE */
  13.310      }
  13.311  
  13.312      /* Flush updates through and flush the TLB. */
    14.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/init.c	Thu Mar 24 16:48:36 2005 +0000
    14.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/init.c	Thu Mar 24 20:20:12 2005 +0000
    14.3 @@ -77,9 +77,7 @@ static pte_t * __init one_page_table_ini
    14.4  {
    14.5  	if (pmd_none(*pmd)) {
    14.6  		pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
    14.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    14.8  		make_page_readonly(page_table);
    14.9 -#endif
   14.10  		set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
   14.11  		if (page_table != pte_offset_kernel(pmd, 0))
   14.12  			BUG();	
   14.13 @@ -351,18 +349,12 @@ static void __init pagetable_init (void)
   14.14  	 * it. We clean up by write-enabling and then freeing the old page dir.
   14.15  	 */
   14.16  	memcpy(new_pgd, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t));
   14.17 -#ifndef CONFIG_XEN_SHADOW_MODE
   14.18  	make_page_readonly(new_pgd);
   14.19  	queue_pgd_pin(__pa(new_pgd));
   14.20 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   14.21  	load_cr3(new_pgd);
   14.22 -#ifndef CONFIG_XEN_SHADOW_MODE
   14.23  	queue_pgd_unpin(__pa(old_pgd));
   14.24 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   14.25  	__flush_tlb_all(); /* implicit flush */
   14.26 -#ifndef CONFIG_XEN_SHADOW_MODE
   14.27  	make_page_writable(old_pgd);
   14.28 -#endif /* CONFIG_XEN_SHADOW_MODE */
   14.29  	flush_page_update_queue();
   14.30  	free_bootmem(__pa(old_pgd), PAGE_SIZE);
   14.31  
   14.32 @@ -570,31 +562,18 @@ void __init paging_init(void)
   14.33  
   14.34  	/* Switch to the real shared_info page, and clear the dummy page. */
   14.35  	flush_page_update_queue();
   14.36 -#ifndef CONFIG_XEN_SHADOW_MODE
   14.37  	set_fixmap_ma(FIX_SHARED_INFO, xen_start_info.shared_info);
   14.38 -#else /* CONFIG_XEN_SHADOW_MODE */
   14.39 -        printk("xen_start_info.shared_info=%x\n", xen_start_info.shared_info);
   14.40 -	set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
   14.41 -#endif /* CONFIG_XEN_SHADOW_MODE */
   14.42  	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   14.43  	memset(empty_zero_page, 0, sizeof(empty_zero_page));
   14.44  
   14.45  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
   14.46  	/* Setup mapping of lower 1st MB */
   14.47  	for (i = 0; i < NR_FIX_ISAMAPS; i++)
   14.48 -#ifndef CONFIG_XEN_SHADOW_MODE
   14.49  		if (xen_start_info.flags & SIF_PRIVILEGED)
   14.50  			set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
   14.51  		else
   14.52  			set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i,
   14.53  					 virt_to_machine(empty_zero_page));
   14.54 -#else /* CONFIG_XEN_SHADOW_MODE */
   14.55 -		if (xen_start_info.flags & SIF_PRIVILEGED)
   14.56 -			__vms_set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
   14.57 -		else
   14.58 -			__vms_set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i,
   14.59 -					 __vms_virt_to_machine(empty_zero_page));
   14.60 -#endif /* CONFIG_XEN_SHADOW_MODE */
   14.61  #endif
   14.62  }
   14.63  
    15.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/ioremap.c	Thu Mar 24 16:48:36 2005 +0000
    15.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/ioremap.c	Thu Mar 24 20:20:12 2005 +0000
    15.3 @@ -56,14 +56,9 @@ void __init bt_iounmap(void *addr, unsig
    15.4  static inline int is_local_lowmem(unsigned long address)
    15.5  {
    15.6  	extern unsigned long max_low_pfn;
    15.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    15.8  	unsigned long mfn = address >> PAGE_SHIFT;
    15.9  	unsigned long pfn = mfn_to_pfn(mfn);
   15.10  	return ((pfn < max_low_pfn) && (pfn_to_mfn(pfn) == mfn));
   15.11 -#else /* CONFIG_XEN_SHADOW_MODE */
   15.12 -	unsigned long pfn = address >> PAGE_SHIFT;
   15.13 -	return (pfn < max_low_pfn);
   15.14 -#endif /* CONFIG_XEN_SHADOW_MODE */
   15.15  }
   15.16  
   15.17  /*
   15.18 @@ -102,7 +97,6 @@ void __iomem * __ioremap(unsigned long p
   15.19  	/*
   15.20  	 * Don't allow anybody to remap normal RAM that we're using..
   15.21  	 */
   15.22 -#ifndef CONFIG_XEN_SHADOW_MODE
   15.23  	if (is_local_lowmem(phys_addr)) {
   15.24  		char *t_addr, *t_end;
   15.25  		struct page *page;
   15.26 @@ -116,7 +110,6 @@ void __iomem * __ioremap(unsigned long p
   15.27  
   15.28  		domid = DOMID_LOCAL;
   15.29  	}
   15.30 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   15.31  
   15.32  	/*
   15.33  	 * Mappings have to be page-aligned
   15.34 @@ -262,11 +255,7 @@ void __init *bt_ioremap(unsigned long ph
   15.35  	 */
   15.36  	idx = FIX_BTMAP_BEGIN;
   15.37  	while (nrpages > 0) {
   15.38 -#ifndef CONFIG_XEN_SHADOW_MODE
   15.39  		set_fixmap_ma(idx, phys_addr);
   15.40 -#else /* CONFIG_XEN_SHADOW_MODE */
   15.41 -		__vms_set_fixmap_ma(idx, phys_addr);
   15.42 -#endif /* CONFIG_XEN_SHADOW_MODE */
   15.43  		phys_addr += PAGE_SIZE;
   15.44  		--idx;
   15.45  		--nrpages;
   15.46 @@ -323,11 +312,7 @@ static inline void direct_remap_area_pte
   15.47  		BUG();
   15.48  
   15.49  	do {
   15.50 -#ifndef CONFIG_XEN_SHADOW_MODE
   15.51  		(*v)->ptr = virt_to_machine(pte);
   15.52 -#else /* CONFIG_XEN_SHADOW_MODE */
   15.53 -		(*v)->ptr = __vms_virt_to_machine(pte);
   15.54 -#endif /* CONFIG_XEN_SHADOW_MODE */
   15.55  		(*v)++;
   15.56  		address += PAGE_SIZE;
   15.57  		pte++;
   15.58 @@ -401,14 +386,12 @@ int direct_remap_area_pages(struct mm_st
   15.59  	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *w, *v;
   15.60  
   15.61  	v = w = &u[0];
   15.62 -#ifndef CONFIG_XEN_SHADOW_MODE
   15.63  	if (domid != DOMID_LOCAL) {
   15.64  		u[0].ptr  = MMU_EXTENDED_COMMAND;
   15.65  		u[0].val  = MMUEXT_SET_FOREIGNDOM;
   15.66  		u[0].val |= (unsigned long)domid << 16;
   15.67  		v = w = &u[1];
   15.68  	}
   15.69 -#endif /* CONFIG_XEN_SHADOW_MODE */
   15.70  
   15.71  	start_address = address;
   15.72  
   15.73 @@ -432,24 +415,8 @@ int direct_remap_area_pages(struct mm_st
   15.74  		 * Fill in the machine address: PTE ptr is done later by
   15.75  		 * __direct_remap_area_pages(). 
   15.76  		 */
   15.77 -#ifndef CONFIG_XEN_SHADOW_MODE
   15.78  		v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot);
   15.79  
   15.80 -#else /* CONFIG_XEN_SHADOW_MODE */
   15.81 -        {
   15.82 -            mmu_update_t update;
   15.83 -            int success = 0;
   15.84 -            unsigned long ppfn;
   15.85 -
   15.86 -            update.ptr = (machine_addr & PAGE_MASK) | MMU_MACHPHYS_UPDATE;
   15.87 -            update.val = -1;
   15.88 -            ppfn = HYPERVISOR_mmu_update(&update, 1, &success);
   15.89 -            if (! success)
   15.90 -                BUG();
   15.91 -                
   15.92 -		v->val = (ppfn << PAGE_SHIFT) | pgprot_val(prot);
   15.93 -        }
   15.94 -#endif /* CONFIG_XEN_SHADOW_MODE */
   15.95  		machine_addr += PAGE_SIZE;
   15.96  		address += PAGE_SIZE; 
   15.97  		v++;
    16.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pageattr.c	Thu Mar 24 16:48:36 2005 +0000
    16.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pageattr.c	Thu Mar 24 20:20:12 2005 +0000
    16.3 @@ -119,11 +119,7 @@ static int
    16.4  		if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
    16.5  			pte_t old = *kpte;
    16.6  			pte_t standard = mk_pte(page, PAGE_KERNEL); 
    16.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    16.8  			set_pte_batched(kpte, mk_pte(page, prot)); 
    16.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   16.10 -			set_pte_atomic(kpte, mk_pte(page, prot)); 
   16.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   16.12  			if (pte_same(old,standard))
   16.13  				get_page(kpte_page);
   16.14  		} else {
   16.15 @@ -134,11 +130,7 @@ static int
   16.16  			set_pmd_pte(kpte,address,mk_pte(split, PAGE_KERNEL));
   16.17  		}	
   16.18  	} else if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
   16.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   16.20  		set_pte_batched(kpte, mk_pte(page, PAGE_KERNEL));
   16.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   16.22 -		set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL));
   16.23 -#endif /* CONFIG_XEN_SHADOW_MODE */
   16.24  		__put_page(kpte_page);
   16.25  	}
   16.26  
   16.27 @@ -179,9 +171,7 @@ int change_page_attr(struct page *page, 
   16.28  		if (err) 
   16.29  			break; 
   16.30  	} 	
   16.31 -#ifndef CONFIG_XEN_SHADOW_MODE
   16.32  	flush_page_update_queue();
   16.33 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   16.34  	spin_unlock_irqrestore(&cpa_lock, flags);
   16.35  	return err;
   16.36  }
    17.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Mar 24 16:48:36 2005 +0000
    17.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Mar 24 20:20:12 2005 +0000
    17.3 @@ -93,11 +93,7 @@ static void set_pte_pfn(unsigned long va
    17.4   * Associate a virtual page frame with a given physical page frame 
    17.5   * and protection flags for that frame.
    17.6   */ 
    17.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    17.8  static void set_pte_pfn_ma(unsigned long vaddr, unsigned long pfn,
    17.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   17.10 -static void __vms_set_pte_pfn_ma(unsigned long vaddr, unsigned long pfn,
   17.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   17.12  			   pgprot_t flags)
   17.13  {
   17.14  	pgd_t *pgd;
   17.15 @@ -116,22 +112,7 @@ static void __vms_set_pte_pfn_ma(unsigne
   17.16  	}
   17.17  	pte = pte_offset_kernel(pmd, vaddr);
   17.18  	/* <pfn,flags> stored as-is, to permit clearing entries */
   17.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.20  	set_pte(pte, pfn_pte_ma(pfn, flags));
   17.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   17.22 -        {
   17.23 -            mmu_update_t update;
   17.24 -            int success = 0;
   17.25 -            unsigned long ppfn;
   17.26 -
   17.27 -            update.ptr = (pfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   17.28 -            update.val = -1;
   17.29 -            ppfn = HYPERVISOR_mmu_update(&update, 1, &success);
   17.30 -            if (! success)
   17.31 -                BUG();
   17.32 -            set_pte(pte, pfn_pte(ppfn, flags));
   17.33 -        }
   17.34 -#endif /* CONFIG_XEN_SHADOW_MODE */
   17.35  
   17.36  	/*
   17.37  	 * It's enough to flush this one mapping.
   17.38 @@ -184,11 +165,7 @@ void __set_fixmap (enum fixed_addresses 
   17.39  	set_pte_pfn(address, phys >> PAGE_SHIFT, flags);
   17.40  }
   17.41  
   17.42 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.43  void __set_fixmap_ma (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
   17.44 -#else /* CONFIG_XEN_SHADOW_MODE */
   17.45 -void __vms___set_fixmap_ma (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
   17.46 -#endif /* CONFIG_XEN_SHADOW_MODE */
   17.47  {
   17.48  	unsigned long address = __fix_to_virt(idx);
   17.49  
   17.50 @@ -196,11 +173,7 @@ void __vms___set_fixmap_ma (enum fixed_a
   17.51  		BUG();
   17.52  		return;
   17.53  	}
   17.54 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.55  	set_pte_pfn_ma(address, phys >> PAGE_SHIFT, flags);
   17.56 -#else /* CONFIG_XEN_SHADOW_MODE */
   17.57 -	__vms_set_pte_pfn_ma(address, phys >> PAGE_SHIFT, flags);
   17.58 -#endif /* CONFIG_XEN_SHADOW_MODE */
   17.59  }
   17.60  
   17.61  pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
   17.62 @@ -208,10 +181,8 @@ pte_t *pte_alloc_one_kernel(struct mm_st
   17.63  	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
   17.64  	if (pte) {
   17.65  		clear_page(pte);
   17.66 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.67  		make_page_readonly(pte);
   17.68  		xen_flush_page_update_queue();
   17.69 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   17.70  	}
   17.71  	return pte;
   17.72  }
   17.73 @@ -223,11 +194,9 @@ void pte_ctor(void *pte, kmem_cache_t *c
   17.74  	set_page_count(page, 1);
   17.75  
   17.76  	clear_page(pte);
   17.77 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.78  	make_page_readonly(pte);
   17.79  	queue_pte_pin(__pa(pte));
   17.80  	flush_page_update_queue();
   17.81 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   17.82  }
   17.83  
   17.84  void pte_dtor(void *pte, kmem_cache_t *cache, unsigned long unused)
   17.85 @@ -235,11 +204,9 @@ void pte_dtor(void *pte, kmem_cache_t *c
   17.86  	struct page *page = virt_to_page(pte);
   17.87  	ClearPageForeign(page);
   17.88  
   17.89 -#ifndef CONFIG_XEN_SHADOW_MODE
   17.90  	queue_pte_unpin(__pa(pte));
   17.91  	make_page_writable(pte);
   17.92  	flush_page_update_queue();
   17.93 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   17.94  }
   17.95  
   17.96  struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
   17.97 @@ -272,11 +239,7 @@ void pte_free(struct page *pte)
   17.98  	if (pte < highmem_start_page)
   17.99  #endif
  17.100  		kmem_cache_free(pte_cache,
  17.101 -#ifndef CONFIG_XEN_SHADOW_MODE
  17.102  				phys_to_virt(page_to_pseudophys(pte)));
  17.103 -#else /* CONFIG_XEN_SHADOW_MODE */
  17.104 -				phys_to_virt(__vms_page_to_pseudophys(pte)));
  17.105 -#endif /* CONFIG_XEN_SHADOW_MODE */
  17.106  #ifdef CONFIG_HIGHPTE
  17.107  	else
  17.108  		__free_page(pte);
  17.109 @@ -341,13 +304,9 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
  17.110  	spin_unlock_irqrestore(&pgd_lock, flags);
  17.111  	memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
  17.112   out:
  17.113 -#ifndef CONFIG_XEN_SHADOW_MODE
  17.114  	make_page_readonly(pgd);
  17.115  	queue_pgd_pin(__pa(pgd));
  17.116  	flush_page_update_queue();
  17.117 -#else /* CONFIG_XEN_SHADOW_MODE */
  17.118 -	;
  17.119 -#endif /* CONFIG_XEN_SHADOW_MODE */
  17.120  }
  17.121  
  17.122  /* never called when PTRS_PER_PMD > 1 */
  17.123 @@ -355,11 +314,9 @@ void pgd_dtor(void *pgd, kmem_cache_t *c
  17.124  {
  17.125  	unsigned long flags; /* can be called from interrupt context */
  17.126  
  17.127 -#ifndef CONFIG_XEN_SHADOW_MODE
  17.128  	queue_pgd_unpin(__pa(pgd));
  17.129  	make_page_writable(pgd);
  17.130  	flush_page_update_queue();
  17.131 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
  17.132  
  17.133  	if (PTRS_PER_PMD > 1)
  17.134  		return;
  17.135 @@ -426,7 +383,6 @@ void make_page_readonly(void *va)
  17.136  	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
  17.137  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  17.138  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
  17.139 -#ifndef CONFIG_XEN_SHADOW_MODE
  17.140  	if ( (unsigned long)va >= (unsigned long)high_memory )
  17.141  	{
  17.142  		unsigned long phys;
  17.143 @@ -436,7 +392,6 @@ void make_page_readonly(void *va)
  17.144  #endif
  17.145  			make_lowmem_page_readonly(phys_to_virt(phys));
  17.146  	}
  17.147 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
  17.148  }
  17.149  
  17.150  void make_page_writable(void *va)
  17.151 @@ -448,11 +403,7 @@ void make_page_writable(void *va)
  17.152  	if ( (unsigned long)va >= (unsigned long)high_memory )
  17.153  	{
  17.154  		unsigned long phys;
  17.155 -#ifndef CONFIG_XEN_SHADOW_MODE
  17.156  		phys = machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  17.157 -#else /* CONFIG_XEN_SHADOW_MODE */
  17.158 -		phys = __vms_machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  17.159 -#endif /* CONFIG_XEN_SHADOW_MODE */
  17.160  #ifdef CONFIG_HIGHMEM
  17.161  		if ( (phys >> PAGE_SHIFT) < highstart_pfn )
  17.162  #endif
    18.1 --- a/linux-2.6.10-xen-sparse/arch/xen/kernel/reboot.c	Thu Mar 24 16:48:36 2005 +0000
    18.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/kernel/reboot.c	Thu Mar 24 20:20:12 2005 +0000
    18.3 @@ -80,11 +80,7 @@ static void __do_suspend(void)
    18.4      extern void time_suspend(void);
    18.5      extern void time_resume(void);
    18.6      extern unsigned long max_pfn;
    18.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    18.8      extern unsigned int *pfn_to_mfn_frame_list;
    18.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   18.10 -    extern unsigned int *__vms_pfn_to_mfn_frame_list;
   18.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   18.12  
   18.13      suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
   18.14      if ( suspend_record == NULL )
   18.15 @@ -109,11 +105,7 @@ static void __do_suspend(void)
   18.16  
   18.17      memcpy(&suspend_record->resume_info, &xen_start_info, sizeof(xen_start_info));
   18.18  
   18.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   18.20      HYPERVISOR_suspend(virt_to_machine(suspend_record) >> PAGE_SHIFT);
   18.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   18.22 -    HYPERVISOR_suspend(__vms_virt_to_machine(suspend_record) >> PAGE_SHIFT);
   18.23 -#endif /* CONFIG_XEN_SHADOW_MODE */
   18.24  
   18.25      HYPERVISOR_vm_assist(VMASST_CMD_enable,
   18.26  			 VMASST_TYPE_4gb_segments);
   18.27 @@ -126,7 +118,7 @@ static void __do_suspend(void)
   18.28  
   18.29      memcpy(&xen_start_info, &suspend_record->resume_info, sizeof(xen_start_info));
   18.30  
   18.31 -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && !defined(CONFIG_XEN_SHADOW_MODE)
   18.32 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
   18.33      set_fixmap_ma(FIX_SHARED_INFO, xen_start_info.shared_info);
   18.34  #else
   18.35      set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
   18.36 @@ -138,20 +130,11 @@ static void __do_suspend(void)
   18.37  
   18.38      for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
   18.39      {
   18.40 -#ifndef CONFIG_XEN_SHADOW_MODE
   18.41          pfn_to_mfn_frame_list[j] = 
   18.42              virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   18.43 -#else /* CONFIG_XEN_SHADOW_MODE */
   18.44 -        __vms_pfn_to_mfn_frame_list[j] = 
   18.45 -            __vms_virt_to_machine(&__vms_phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   18.46 -#endif /* CONFIG_XEN_SHADOW_MODE */
   18.47      }
   18.48      HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
   18.49 -#ifndef CONFIG_XEN_SHADOW_MODE
   18.50          virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   18.51 -#else /* CONFIG_XEN_SHADOW_MODE */
   18.52 -        __vms_virt_to_machine(__vms_pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   18.53 -#endif /* CONFIG_XEN_SHADOW_MODE */
   18.54  
   18.55  
   18.56      irq_resume();
    19.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 24 16:48:36 2005 +0000
    19.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/balloon/balloon.c	Thu Mar 24 20:20:12 2005 +0000
    19.3 @@ -206,19 +206,11 @@ static void balloon_process(void *unused
    19.4                  BUG();
    19.5  
    19.6              pfn = page - mem_map;
    19.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    19.8              if ( phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
    19.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   19.10 -            if ( __vms_phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
   19.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   19.12                  BUG();
   19.13  
   19.14              /* Update P->M and M->P tables. */
   19.15 -#ifndef CONFIG_XEN_SHADOW_MODE
   19.16              phys_to_machine_mapping[pfn] = mfn_list[i];
   19.17 -#else /* CONFIG_XEN_SHADOW_MODE */
   19.18 -            __vms_phys_to_machine_mapping[pfn] = mfn_list[i];
   19.19 -#endif /* CONFIG_XEN_SHADOW_MODE */
   19.20              queue_machphys_update(mfn_list[i], pfn);
   19.21              
   19.22              /* Link back into the page tables if it's not a highmem page. */
   19.23 @@ -252,13 +244,8 @@ static void balloon_process(void *unused
   19.24              }
   19.25  
   19.26              pfn = page - mem_map;
   19.27 -#ifndef CONFIG_XEN_SHADOW_MODE
   19.28              mfn_list[i] = phys_to_machine_mapping[pfn];
   19.29              phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
   19.30 -#else /* CONFIG_XEN_SHADOW_MODE */
   19.31 -            mfn_list[i] = __vms_phys_to_machine_mapping[pfn];
   19.32 -            __vms_phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
   19.33 -#endif /* CONFIG_XEN_SHADOW_MODE */
   19.34  
   19.35              if ( !PageHighMem(page) )
   19.36              {
    20.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 24 16:48:36 2005 +0000
    20.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Thu Mar 24 20:20:12 2005 +0000
    20.3 @@ -444,11 +444,7 @@ static void dispatch_rw_block_io(blkif_t
    20.4  #else
    20.5          mcl[i].args[3] = blkif->domid;
    20.6  #endif
    20.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    20.8          phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
    20.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   20.10 -        __vms_phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
   20.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   20.12              FOREIGN_FRAME(phys_seg[i].buffer >> PAGE_SHIFT);
   20.13      }
   20.14  
    21.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Mar 24 16:48:36 2005 +0000
    21.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Thu Mar 24 20:20:12 2005 +0000
    21.3 @@ -129,11 +129,7 @@ static inline void translate_req_to_pfn(
    21.4      xreq->sector_number = req->sector_number;
    21.5  
    21.6      for ( i = 0; i < req->nr_segments; i++ )
    21.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    21.8          xreq->frame_and_sects[i] = machine_to_phys(req->frame_and_sects[i]);
    21.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   21.10 -        xreq->frame_and_sects[i] = __vms_machine_to_phys(req->frame_and_sects[i]);
   21.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   21.12  }
   21.13  
   21.14  static inline void translate_req_to_mfn(blkif_request_t *xreq,
   21.15 @@ -148,11 +144,7 @@ static inline void translate_req_to_mfn(
   21.16      xreq->sector_number = req->sector_number;
   21.17  
   21.18      for ( i = 0; i < req->nr_segments; i++ )
   21.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   21.20          xreq->frame_and_sects[i] = phys_to_machine(req->frame_and_sects[i]);
   21.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   21.22 -        xreq->frame_and_sects[i] = __vms_phys_to_machine(req->frame_and_sects[i]);
   21.23 -#endif /* CONFIG_XEN_SHADOW_MODE */
   21.24  }
   21.25  
   21.26  
   21.27 @@ -1099,11 +1091,7 @@ static void blkif_send_interface_connect
   21.28      blkif_fe_interface_connect_t *msg = (void*)cmsg.msg;
   21.29      
   21.30      msg->handle      = 0;
   21.31 -#ifndef CONFIG_XEN_SHADOW_MODE
   21.32      msg->shmem_frame = (virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
   21.33 -#else /* CONFIG_XEN_SHADOW_MODE */
   21.34 -    msg->shmem_frame = (__vms_virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
   21.35 -#endif /* CONFIG_XEN_SHADOW_MODE */
   21.36      
   21.37      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   21.38  }
   21.39 @@ -1413,11 +1401,7 @@ void blkif_completion(blkif_request_t *r
   21.40          for ( i = 0; i < req->nr_segments; i++ )
   21.41          {
   21.42              unsigned long pfn = req->frame_and_sects[i] >> PAGE_SHIFT;
   21.43 -#ifndef CONFIG_XEN_SHADOW_MODE
   21.44              unsigned long mfn = phys_to_machine_mapping[pfn];
   21.45 -#else /* CONFIG_XEN_SHADOW_MODE */
   21.46 -            unsigned long mfn = __vms_phys_to_machine_mapping[pfn];
   21.47 -#endif /* CONFIG_XEN_SHADOW_MODE */
   21.48              xen_machphys_update(mfn, pfn);
   21.49          }
   21.50          break;
    22.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Mar 24 16:48:36 2005 +0000
    22.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c	Thu Mar 24 20:20:12 2005 +0000
    22.3 @@ -112,11 +112,7 @@ static int xlvbd_get_vbd_info(vdisk_t *d
    22.4      memset(&req, 0, sizeof(req));
    22.5      req.operation   = BLKIF_OP_PROBE;
    22.6      req.nr_segments = 1;
    22.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    22.8      req.frame_and_sects[0] = virt_to_machine(buf) | 7;
    22.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   22.10 -    req.frame_and_sects[0] = __vms_virt_to_machine(buf) | 7;
   22.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   22.12  
   22.13      blkif_control_send(&req, &rsp);
   22.14  
    23.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/netback/netback.c	Thu Mar 24 16:48:36 2005 +0000
    23.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/netback/netback.c	Thu Mar 24 20:20:12 2005 +0000
    23.3 @@ -207,11 +207,7 @@ static void net_rx_action(unsigned long 
    23.4      {
    23.5          netif   = netdev_priv(skb->dev);
    23.6          vdata   = (unsigned long)skb->data;
    23.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    23.8          mdata   = virt_to_machine(vdata);
    23.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   23.10 -        mdata   = __vms_virt_to_machine(vdata);
   23.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   23.12  
   23.13          /* Memory squeeze? Back off for an arbitrary while. */
   23.14          if ( (new_mfn = alloc_mfn()) == 0 )
   23.15 @@ -227,11 +223,7 @@ static void net_rx_action(unsigned long 
   23.16           * Set the new P2M table entry before reassigning the old data page.
   23.17           * Heed the comment in pgtable-2level.h:pte_page(). :-)
   23.18           */
   23.19 -#ifndef CONFIG_XEN_SHADOW_MODE
   23.20          phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] = new_mfn;
   23.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   23.22 -        __vms_phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] = new_mfn;
   23.23 -#endif /* CONFIG_XEN_SHADOW_MODE */
   23.24          
   23.25          mmu[0].ptr  = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   23.26          mmu[0].val  = __pa(vdata) >> PAGE_SHIFT;  
   23.27 @@ -598,11 +590,7 @@ static void net_tx_action(unsigned long 
   23.28              continue;
   23.29          }
   23.30  
   23.31 -#ifndef CONFIG_XEN_SHADOW_MODE
   23.32          phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
   23.33 -#else /* CONFIG_XEN_SHADOW_MODE */
   23.34 -        __vms_phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
   23.35 -#endif /* CONFIG_XEN_SHADOW_MODE */
   23.36              FOREIGN_FRAME(txreq.addr >> PAGE_SHIFT);
   23.37  
   23.38          data_len = (txreq.size > PKT_PROT_LEN) ? PKT_PROT_LEN : txreq.size;
    24.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	Thu Mar 24 16:48:36 2005 +0000
    24.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	Thu Mar 24 20:20:12 2005 +0000
    24.3 @@ -375,18 +375,10 @@ static void network_alloc_rx_buffers(str
    24.4          
    24.5          np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id;
    24.6          
    24.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    24.8          rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
    24.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.10 -        rx_pfn_array[i] = __vms_virt_to_machine(skb->head) >> PAGE_SHIFT;
   24.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.12  
   24.13  	/* Remove this page from pseudo phys map before passing back to Xen. */
   24.14 -#ifndef CONFIG_XEN_SHADOW_MODE
   24.15  	phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
   24.16 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.17 -	__vms_phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
   24.18 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.19  	    = INVALID_P2M_ENTRY;
   24.20  
   24.21          rx_mcl[i].op = __HYPERVISOR_update_va_mapping;
   24.22 @@ -472,11 +464,7 @@ static int network_start_xmit(struct sk_
   24.23      tx = &np->tx->ring[MASK_NETIF_TX_IDX(i)].req;
   24.24  
   24.25      tx->id   = id;
   24.26 -#ifndef CONFIG_XEN_SHADOW_MODE
   24.27      tx->addr = virt_to_machine(skb->data);
   24.28 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.29 -    tx->addr = __vms_virt_to_machine(skb->data);
   24.30 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.31      tx->size = skb->len;
   24.32  
   24.33      wmb(); /* Ensure that backend will see the request. */
   24.34 @@ -591,11 +579,7 @@ static int netif_poll(struct net_device 
   24.35          mcl->args[2] = 0;
   24.36          mcl++;
   24.37  
   24.38 -#ifndef CONFIG_XEN_SHADOW_MODE
   24.39          phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
   24.40 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.41 -        __vms_phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
   24.42 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.43              rx->addr >> PAGE_SHIFT;
   24.44  
   24.45          __skb_queue_tail(&rxq, skb);
   24.46 @@ -752,11 +736,7 @@ static void network_connect(struct net_d
   24.47                  tx = &np->tx->ring[requeue_idx++].req;
   24.48                  
   24.49                  tx->id   = i;
   24.50 -#ifndef CONFIG_XEN_SHADOW_MODE
   24.51                  tx->addr = virt_to_machine(skb->data);
   24.52 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.53 -                tx->addr = __vms_virt_to_machine(skb->data);
   24.54 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.55                  tx->size = skb->len;
   24.56                  
   24.57                  np->stats.tx_bytes += skb->len;
   24.58 @@ -819,13 +799,8 @@ static void send_interface_connect(struc
   24.59      netif_fe_interface_connect_t *msg = (void*)cmsg.msg;
   24.60  
   24.61      msg->handle = np->handle;
   24.62 -#ifndef CONFIG_XEN_SHADOW_MODE
   24.63      msg->tx_shmem_frame = (virt_to_machine(np->tx) >> PAGE_SHIFT);
   24.64      msg->rx_shmem_frame = (virt_to_machine(np->rx) >> PAGE_SHIFT);
   24.65 -#else /* CONFIG_XEN_SHADOW_MODE */
   24.66 -    msg->tx_shmem_frame = (__vms_virt_to_machine(np->tx) >> PAGE_SHIFT);
   24.67 -    msg->rx_shmem_frame = (__vms_virt_to_machine(np->rx) >> PAGE_SHIFT);
   24.68 -#endif /* CONFIG_XEN_SHADOW_MODE */
   24.69          
   24.70      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   24.71  }
    25.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Mar 24 16:48:36 2005 +0000
    25.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/privcmd/privcmd.c	Thu Mar 24 20:20:12 2005 +0000
    25.3 @@ -174,11 +174,7 @@ static int privcmd_ioctl(struct inode *i
    25.4  
    25.5      case IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN:
    25.6      {
    25.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    25.8          unsigned long m2pv = (unsigned long)machine_to_phys_mapping;
    25.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   25.10 -        unsigned long m2pv = (unsigned long)__vms_machine_to_phys_mapping;
   25.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   25.12          pgd_t *pgd = pgd_offset_k(m2pv);
   25.13          pmd_t *pmd = pmd_offset(pgd, m2pv);
   25.14          unsigned long m2p_start_mfn = pmd_val(*pmd) >> PAGE_SHIFT;
    26.1 --- a/linux-2.6.10-xen-sparse/fs/exec.c	Thu Mar 24 16:48:36 2005 +0000
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,1432 +0,0 @@
    26.4 -/*
    26.5 - *  linux/fs/exec.c
    26.6 - *
    26.7 - *  Copyright (C) 1991, 1992  Linus Torvalds
    26.8 - */
    26.9 -
   26.10 -/*
   26.11 - * #!-checking implemented by tytso.
   26.12 - */
   26.13 -/*
   26.14 - * Demand-loading implemented 01.12.91 - no need to read anything but
   26.15 - * the header into memory. The inode of the executable is put into
   26.16 - * "current->executable", and page faults do the actual loading. Clean.
   26.17 - *
   26.18 - * Once more I can proudly say that linux stood up to being changed: it
   26.19 - * was less than 2 hours work to get demand-loading completely implemented.
   26.20 - *
   26.21 - * Demand loading changed July 1993 by Eric Youngdale.   Use mmap instead,
   26.22 - * current->executable is only used by the procfs.  This allows a dispatch
   26.23 - * table to check for several different types  of binary formats.  We keep
   26.24 - * trying until we recognize the file or we run out of supported binary
   26.25 - * formats. 
   26.26 - */
   26.27 -
   26.28 -#include <linux/config.h>
   26.29 -#include <linux/slab.h>
   26.30 -#include <linux/file.h>
   26.31 -#include <linux/mman.h>
   26.32 -#include <linux/a.out.h>
   26.33 -#include <linux/stat.h>
   26.34 -#include <linux/fcntl.h>
   26.35 -#include <linux/smp_lock.h>
   26.36 -#include <linux/init.h>
   26.37 -#include <linux/pagemap.h>
   26.38 -#include <linux/highmem.h>
   26.39 -#include <linux/spinlock.h>
   26.40 -#include <linux/key.h>
   26.41 -#include <linux/personality.h>
   26.42 -#include <linux/binfmts.h>
   26.43 -#include <linux/swap.h>
   26.44 -#include <linux/utsname.h>
   26.45 -#include <linux/module.h>
   26.46 -#include <linux/namei.h>
   26.47 -#include <linux/proc_fs.h>
   26.48 -#include <linux/ptrace.h>
   26.49 -#include <linux/mount.h>
   26.50 -#include <linux/security.h>
   26.51 -#include <linux/syscalls.h>
   26.52 -#include <linux/rmap.h>
   26.53 -
   26.54 -#include <asm/uaccess.h>
   26.55 -#include <asm/mmu_context.h>
   26.56 -
   26.57 -#ifdef CONFIG_KMOD
   26.58 -#include <linux/kmod.h>
   26.59 -#endif
   26.60 -
   26.61 -int core_uses_pid;
   26.62 -char core_pattern[65] = "core";
   26.63 -/* The maximal length of core_pattern is also specified in sysctl.c */
   26.64 -
   26.65 -static struct linux_binfmt *formats;
   26.66 -static rwlock_t binfmt_lock = RW_LOCK_UNLOCKED;
   26.67 -
   26.68 -int register_binfmt(struct linux_binfmt * fmt)
   26.69 -{
   26.70 -	struct linux_binfmt ** tmp = &formats;
   26.71 -
   26.72 -	if (!fmt)
   26.73 -		return -EINVAL;
   26.74 -	if (fmt->next)
   26.75 -		return -EBUSY;
   26.76 -	write_lock(&binfmt_lock);
   26.77 -	while (*tmp) {
   26.78 -		if (fmt == *tmp) {
   26.79 -			write_unlock(&binfmt_lock);
   26.80 -			return -EBUSY;
   26.81 -		}
   26.82 -		tmp = &(*tmp)->next;
   26.83 -	}
   26.84 -	fmt->next = formats;
   26.85 -	formats = fmt;
   26.86 -	write_unlock(&binfmt_lock);
   26.87 -	return 0;	
   26.88 -}
   26.89 -
   26.90 -EXPORT_SYMBOL(register_binfmt);
   26.91 -
   26.92 -int unregister_binfmt(struct linux_binfmt * fmt)
   26.93 -{
   26.94 -	struct linux_binfmt ** tmp = &formats;
   26.95 -
   26.96 -	write_lock(&binfmt_lock);
   26.97 -	while (*tmp) {
   26.98 -		if (fmt == *tmp) {
   26.99 -			*tmp = fmt->next;
  26.100 -			write_unlock(&binfmt_lock);
  26.101 -			return 0;
  26.102 -		}
  26.103 -		tmp = &(*tmp)->next;
  26.104 -	}
  26.105 -	write_unlock(&binfmt_lock);
  26.106 -	return -EINVAL;
  26.107 -}
  26.108 -
  26.109 -EXPORT_SYMBOL(unregister_binfmt);
  26.110 -
  26.111 -static inline void put_binfmt(struct linux_binfmt * fmt)
  26.112 -{
  26.113 -	module_put(fmt->module);
  26.114 -}
  26.115 -
  26.116 -/*
  26.117 - * Note that a shared library must be both readable and executable due to
  26.118 - * security reasons.
  26.119 - *
  26.120 - * Also note that we take the address to load from from the file itself.
  26.121 - */
  26.122 -asmlinkage long sys_uselib(const char __user * library)
  26.123 -{
  26.124 -	struct file * file;
  26.125 -	struct nameidata nd;
  26.126 -	int error;
  26.127 -
  26.128 -	nd.intent.open.flags = FMODE_READ;
  26.129 -	error = __user_walk(library, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
  26.130 -	if (error)
  26.131 -		goto out;
  26.132 -
  26.133 -	error = -EINVAL;
  26.134 -	if (!S_ISREG(nd.dentry->d_inode->i_mode))
  26.135 -		goto exit;
  26.136 -
  26.137 -	error = permission(nd.dentry->d_inode, MAY_READ | MAY_EXEC, &nd);
  26.138 -	if (error)
  26.139 -		goto exit;
  26.140 -
  26.141 -	file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
  26.142 -	error = PTR_ERR(file);
  26.143 -	if (IS_ERR(file))
  26.144 -		goto out;
  26.145 -
  26.146 -	error = -ENOEXEC;
  26.147 -	if(file->f_op) {
  26.148 -		struct linux_binfmt * fmt;
  26.149 -
  26.150 -		read_lock(&binfmt_lock);
  26.151 -		for (fmt = formats ; fmt ; fmt = fmt->next) {
  26.152 -			if (!fmt->load_shlib)
  26.153 -				continue;
  26.154 -			if (!try_module_get(fmt->module))
  26.155 -				continue;
  26.156 -			read_unlock(&binfmt_lock);
  26.157 -			error = fmt->load_shlib(file);
  26.158 -			read_lock(&binfmt_lock);
  26.159 -			put_binfmt(fmt);
  26.160 -			if (error != -ENOEXEC)
  26.161 -				break;
  26.162 -		}
  26.163 -		read_unlock(&binfmt_lock);
  26.164 -	}
  26.165 -	fput(file);
  26.166 -out:
  26.167 -  	return error;
  26.168 -exit:
  26.169 -	path_release(&nd);
  26.170 -	goto out;
  26.171 -}
  26.172 -
  26.173 -/*
  26.174 - * count() counts the number of strings in array ARGV.
  26.175 - */
  26.176 -static int count(char __user * __user * argv, int max)
  26.177 -{
  26.178 -	int i = 0;
  26.179 -
  26.180 -	if (argv != NULL) {
  26.181 -		for (;;) {
  26.182 -			char __user * p;
  26.183 -
  26.184 -			if (get_user(p, argv))
  26.185 -				return -EFAULT;
  26.186 -			if (!p)
  26.187 -				break;
  26.188 -			argv++;
  26.189 -			if(++i > max)
  26.190 -				return -E2BIG;
  26.191 -		}
  26.192 -	}
  26.193 -	return i;
  26.194 -}
  26.195 -
  26.196 -/*
  26.197 - * 'copy_strings()' copies argument/environment strings from user
  26.198 - * memory to free pages in kernel mem. These are in a format ready
  26.199 - * to be put directly into the top of new user memory.
  26.200 - */
  26.201 -int copy_strings(int argc,char __user * __user * argv, struct linux_binprm *bprm)
  26.202 -{
  26.203 -	struct page *kmapped_page = NULL;
  26.204 -	char *kaddr = NULL;
  26.205 -	int ret;
  26.206 -
  26.207 -	while (argc-- > 0) {
  26.208 -		char __user *str;
  26.209 -		int len;
  26.210 -		unsigned long pos;
  26.211 -
  26.212 -		if (get_user(str, argv+argc) ||
  26.213 -				!(len = strnlen_user(str, bprm->p))) {
  26.214 -			ret = -EFAULT;
  26.215 -			goto out;
  26.216 -		}
  26.217 -
  26.218 -		if (bprm->p < len)  {
  26.219 -			ret = -E2BIG;
  26.220 -			goto out;
  26.221 -		}
  26.222 -
  26.223 -		bprm->p -= len;
  26.224 -		/* XXX: add architecture specific overflow check here. */
  26.225 -		pos = bprm->p;
  26.226 -
  26.227 -		while (len > 0) {
  26.228 -			int i, new, err;
  26.229 -			int offset, bytes_to_copy;
  26.230 -			struct page *page;
  26.231 -
  26.232 -			offset = pos % PAGE_SIZE;
  26.233 -			i = pos/PAGE_SIZE;
  26.234 -			page = bprm->page[i];
  26.235 -			new = 0;
  26.236 -			if (!page) {
  26.237 -				page = alloc_page(GFP_HIGHUSER);
  26.238 -				bprm->page[i] = page;
  26.239 -				if (!page) {
  26.240 -					ret = -ENOMEM;
  26.241 -					goto out;
  26.242 -				}
  26.243 -				new = 1;
  26.244 -			}
  26.245 -
  26.246 -			if (page != kmapped_page) {
  26.247 -				if (kmapped_page)
  26.248 -					kunmap(kmapped_page);
  26.249 -				kmapped_page = page;
  26.250 -				kaddr = kmap(kmapped_page);
  26.251 -			}
  26.252 -			if (new && offset)
  26.253 -				memset(kaddr, 0, offset);
  26.254 -			bytes_to_copy = PAGE_SIZE - offset;
  26.255 -			if (bytes_to_copy > len) {
  26.256 -				bytes_to_copy = len;
  26.257 -				if (new)
  26.258 -					memset(kaddr+offset+len, 0,
  26.259 -						PAGE_SIZE-offset-len);
  26.260 -			}
  26.261 -			err = copy_from_user(kaddr+offset, str, bytes_to_copy);
  26.262 -			if (err) {
  26.263 -				ret = -EFAULT;
  26.264 -				goto out;
  26.265 -			}
  26.266 -
  26.267 -			pos += bytes_to_copy;
  26.268 -			str += bytes_to_copy;
  26.269 -			len -= bytes_to_copy;
  26.270 -		}
  26.271 -	}
  26.272 -	ret = 0;
  26.273 -out:
  26.274 -	if (kmapped_page)
  26.275 -		kunmap(kmapped_page);
  26.276 -	return ret;
  26.277 -}
  26.278 -
  26.279 -/*
  26.280 - * Like copy_strings, but get argv and its values from kernel memory.
  26.281 - */
  26.282 -int copy_strings_kernel(int argc,char ** argv, struct linux_binprm *bprm)
  26.283 -{
  26.284 -	int r;
  26.285 -	mm_segment_t oldfs = get_fs();
  26.286 -	set_fs(KERNEL_DS);
  26.287 -	r = copy_strings(argc, (char __user * __user *)argv, bprm);
  26.288 -	set_fs(oldfs);
  26.289 -	return r;
  26.290 -}
  26.291 -
  26.292 -EXPORT_SYMBOL(copy_strings_kernel);
  26.293 -
  26.294 -#ifdef CONFIG_MMU
  26.295 -/*
  26.296 - * This routine is used to map in a page into an address space: needed by
  26.297 - * execve() for the initial stack and environment pages.
  26.298 - *
  26.299 - * vma->vm_mm->mmap_sem is held for writing.
  26.300 - */
  26.301 -void install_arg_page(struct vm_area_struct *vma,
  26.302 -			struct page *page, unsigned long address)
  26.303 -{
  26.304 -	struct mm_struct *mm = vma->vm_mm;
  26.305 -	pgd_t * pgd;
  26.306 -	pmd_t * pmd;
  26.307 -	pte_t * pte;
  26.308 -
  26.309 -	if (unlikely(anon_vma_prepare(vma)))
  26.310 -		goto out_sig;
  26.311 -
  26.312 -	flush_dcache_page(page);
  26.313 -	pgd = pgd_offset(mm, address);
  26.314 -
  26.315 -	spin_lock(&mm->page_table_lock);
  26.316 -	pmd = pmd_alloc(mm, pgd, address);
  26.317 -	if (!pmd)
  26.318 -		goto out;
  26.319 -	pte = pte_alloc_map(mm, pmd, address);
  26.320 -	if (!pte)
  26.321 -		goto out;
  26.322 -	if (!pte_none(*pte)) {
  26.323 -		pte_unmap(pte);
  26.324 -		goto out;
  26.325 -	}
  26.326 -	mm->rss++;
  26.327 -	lru_cache_add_active(page);
  26.328 -	set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(
  26.329 -					page, vma->vm_page_prot))));
  26.330 -#ifdef CONFIG_XEN_BATCH_MODE2
  26.331 -    XEN_flush_page_update_queue();
  26.332 -#endif
  26.333 -	page_add_anon_rmap(page, vma, address);
  26.334 -	pte_unmap(pte);
  26.335 -	spin_unlock(&mm->page_table_lock);
  26.336 -
  26.337 -	/* no need for flush_tlb */
  26.338 -	return;
  26.339 -out:
  26.340 -	spin_unlock(&mm->page_table_lock);
  26.341 -out_sig:
  26.342 -	__free_page(page);
  26.343 -	force_sig(SIGKILL, current);
  26.344 -}
  26.345 -
  26.346 -int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
  26.347 -{
  26.348 -	unsigned long stack_base;
  26.349 -	struct vm_area_struct *mpnt;
  26.350 -	struct mm_struct *mm = current->mm;
  26.351 -	int i, ret;
  26.352 -	long arg_size;
  26.353 -
  26.354 -#ifdef CONFIG_STACK_GROWSUP
  26.355 -	/* Move the argument and environment strings to the bottom of the
  26.356 -	 * stack space.
  26.357 -	 */
  26.358 -	int offset, j;
  26.359 -	char *to, *from;
  26.360 -
  26.361 -	/* Start by shifting all the pages down */
  26.362 -	i = 0;
  26.363 -	for (j = 0; j < MAX_ARG_PAGES; j++) {
  26.364 -		struct page *page = bprm->page[j];
  26.365 -		if (!page)
  26.366 -			continue;
  26.367 -		bprm->page[i++] = page;
  26.368 -	}
  26.369 -
  26.370 -	/* Now move them within their pages */
  26.371 -	offset = bprm->p % PAGE_SIZE;
  26.372 -	to = kmap(bprm->page[0]);
  26.373 -	for (j = 1; j < i; j++) {
  26.374 -		memmove(to, to + offset, PAGE_SIZE - offset);
  26.375 -		from = kmap(bprm->page[j]);
  26.376 -		memcpy(to + PAGE_SIZE - offset, from, offset);
  26.377 -		kunmap(bprm->page[j - 1]);
  26.378 -		to = from;
  26.379 -	}
  26.380 -	memmove(to, to + offset, PAGE_SIZE - offset);
  26.381 -	kunmap(bprm->page[j - 1]);
  26.382 -
  26.383 -	/* Adjust bprm->p to point to the end of the strings. */
  26.384 -	bprm->p = PAGE_SIZE * i - offset;
  26.385 -
  26.386 -	/* Limit stack size to 1GB */
  26.387 -	stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max;
  26.388 -	if (stack_base > (1 << 30))
  26.389 -		stack_base = 1 << 30;
  26.390 -	stack_base = PAGE_ALIGN(STACK_TOP - stack_base);
  26.391 -
  26.392 -	mm->arg_start = stack_base;
  26.393 -	arg_size = i << PAGE_SHIFT;
  26.394 -
  26.395 -	/* zero pages that were copied above */
  26.396 -	while (i < MAX_ARG_PAGES)
  26.397 -		bprm->page[i++] = NULL;
  26.398 -#else
  26.399 -	stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
  26.400 -	mm->arg_start = bprm->p + stack_base;
  26.401 -	arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
  26.402 -#endif
  26.403 -
  26.404 -	bprm->p += stack_base;
  26.405 -	if (bprm->loader)
  26.406 -		bprm->loader += stack_base;
  26.407 -	bprm->exec += stack_base;
  26.408 -
  26.409 -	mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
  26.410 -	if (!mpnt)
  26.411 -		return -ENOMEM;
  26.412 -
  26.413 -	if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
  26.414 -		kmem_cache_free(vm_area_cachep, mpnt);
  26.415 -		return -ENOMEM;
  26.416 -	}
  26.417 -
  26.418 -	memset(mpnt, 0, sizeof(*mpnt));
  26.419 -
  26.420 -	down_write(&mm->mmap_sem);
  26.421 -	{
  26.422 -		mpnt->vm_mm = mm;
  26.423 -#ifdef CONFIG_STACK_GROWSUP
  26.424 -		mpnt->vm_start = stack_base;
  26.425 -		mpnt->vm_end = PAGE_MASK &
  26.426 -			(PAGE_SIZE - 1 + (unsigned long) bprm->p);
  26.427 -#else
  26.428 -		mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
  26.429 -		mpnt->vm_end = STACK_TOP;
  26.430 -#endif
  26.431 -		/* Adjust stack execute permissions; explicitly enable
  26.432 -		 * for EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X
  26.433 -		 * and leave alone (arch default) otherwise. */
  26.434 -		if (unlikely(executable_stack == EXSTACK_ENABLE_X))
  26.435 -			mpnt->vm_flags = VM_STACK_FLAGS |  VM_EXEC;
  26.436 -		else if (executable_stack == EXSTACK_DISABLE_X)
  26.437 -			mpnt->vm_flags = VM_STACK_FLAGS & ~VM_EXEC;
  26.438 -		else
  26.439 -			mpnt->vm_flags = VM_STACK_FLAGS;
  26.440 -		mpnt->vm_flags |= mm->def_flags;
  26.441 -		mpnt->vm_page_prot = protection_map[mpnt->vm_flags & 0x7];
  26.442 -		if ((ret = insert_vm_struct(mm, mpnt))) {
  26.443 -			up_write(&mm->mmap_sem);
  26.444 -			kmem_cache_free(vm_area_cachep, mpnt);
  26.445 -			return ret;
  26.446 -		}
  26.447 -		mm->stack_vm = mm->total_vm = vma_pages(mpnt);
  26.448 -	}
  26.449 -
  26.450 -	for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
  26.451 -		struct page *page = bprm->page[i];
  26.452 -		if (page) {
  26.453 -			bprm->page[i] = NULL;
  26.454 -			install_arg_page(mpnt, page, stack_base);
  26.455 -		}
  26.456 -		stack_base += PAGE_SIZE;
  26.457 -	}
  26.458 -	up_write(&mm->mmap_sem);
  26.459 -	
  26.460 -	return 0;
  26.461 -}
  26.462 -
  26.463 -EXPORT_SYMBOL(setup_arg_pages);
  26.464 -
  26.465 -#define free_arg_pages(bprm) do { } while (0)
  26.466 -
  26.467 -#else
  26.468 -
  26.469 -static inline void free_arg_pages(struct linux_binprm *bprm)
  26.470 -{
  26.471 -	int i;
  26.472 -
  26.473 -	for (i = 0; i < MAX_ARG_PAGES; i++) {
  26.474 -		if (bprm->page[i])
  26.475 -			__free_page(bprm->page[i]);
  26.476 -		bprm->page[i] = NULL;
  26.477 -	}
  26.478 -}
  26.479 -
  26.480 -#endif /* CONFIG_MMU */
  26.481 -
  26.482 -struct file *open_exec(const char *name)
  26.483 -{
  26.484 -	struct nameidata nd;
  26.485 -	int err;
  26.486 -	struct file *file;
  26.487 -
  26.488 -	nd.intent.open.flags = FMODE_READ;
  26.489 -	err = path_lookup(name, LOOKUP_FOLLOW|LOOKUP_OPEN, &nd);
  26.490 -	file = ERR_PTR(err);
  26.491 -
  26.492 -	if (!err) {
  26.493 -		struct inode *inode = nd.dentry->d_inode;
  26.494 -		file = ERR_PTR(-EACCES);
  26.495 -		if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
  26.496 -		    S_ISREG(inode->i_mode)) {
  26.497 -			int err = permission(inode, MAY_EXEC, &nd);
  26.498 -			if (!err && !(inode->i_mode & 0111))
  26.499 -				err = -EACCES;
  26.500 -			file = ERR_PTR(err);
  26.501 -			if (!err) {
  26.502 -				file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
  26.503 -				if (!IS_ERR(file)) {
  26.504 -					err = deny_write_access(file);
  26.505 -					if (err) {
  26.506 -						fput(file);
  26.507 -						file = ERR_PTR(err);
  26.508 -					}
  26.509 -				}
  26.510 -out:
  26.511 -				return file;
  26.512 -			}
  26.513 -		}
  26.514 -		path_release(&nd);
  26.515 -	}
  26.516 -	goto out;
  26.517 -}
  26.518 -
  26.519 -EXPORT_SYMBOL(open_exec);
  26.520 -
  26.521 -int kernel_read(struct file *file, unsigned long offset,
  26.522 -	char *addr, unsigned long count)
  26.523 -{
  26.524 -	mm_segment_t old_fs;
  26.525 -	loff_t pos = offset;
  26.526 -	int result;
  26.527 -
  26.528 -	old_fs = get_fs();
  26.529 -	set_fs(get_ds());
  26.530 -	/* The cast to a user pointer is valid due to the set_fs() */
  26.531 -	result = vfs_read(file, (void __user *)addr, count, &pos);
  26.532 -	set_fs(old_fs);
  26.533 -	return result;
  26.534 -}
  26.535 -
  26.536 -EXPORT_SYMBOL(kernel_read);
  26.537 -
  26.538 -static int exec_mmap(struct mm_struct *mm)
  26.539 -{
  26.540 -	struct task_struct *tsk;
  26.541 -	struct mm_struct * old_mm, *active_mm;
  26.542 -
  26.543 -	/* Notify parent that we're no longer interested in the old VM */
  26.544 -	tsk = current;
  26.545 -	old_mm = current->mm;
  26.546 -	mm_release(tsk, old_mm);
  26.547 -
  26.548 -	task_lock(tsk);
  26.549 -	active_mm = tsk->active_mm;
  26.550 -	tsk->mm = mm;
  26.551 -	tsk->active_mm = mm;
  26.552 -	activate_mm(active_mm, mm);
  26.553 -	task_unlock(tsk);
  26.554 -	arch_pick_mmap_layout(mm);
  26.555 -	if (old_mm) {
  26.556 -		if (active_mm != old_mm) BUG();
  26.557 -		mmput(old_mm);
  26.558 -		return 0;
  26.559 -	}
  26.560 -	mmdrop(active_mm);
  26.561 -	return 0;
  26.562 -}
  26.563 -
  26.564 -/*
  26.565 - * This function makes sure the current process has its own signal table,
  26.566 - * so that flush_signal_handlers can later reset the handlers without
  26.567 - * disturbing other processes.  (Other processes might share the signal
  26.568 - * table via the CLONE_SIGHAND option to clone().)
  26.569 - */
  26.570 -static inline int de_thread(struct task_struct *tsk)
  26.571 -{
  26.572 -	struct signal_struct *sig = tsk->signal;
  26.573 -	struct sighand_struct *newsighand, *oldsighand = tsk->sighand;
  26.574 -	spinlock_t *lock = &oldsighand->siglock;
  26.575 -	int count;
  26.576 -
  26.577 -	/*
  26.578 -	 * If we don't share sighandlers, then we aren't sharing anything
  26.579 -	 * and we can just re-use it all.
  26.580 -	 */
  26.581 -	if (atomic_read(&oldsighand->count) <= 1) {
  26.582 -		BUG_ON(atomic_read(&sig->count) != 1);
  26.583 -		exit_itimers(sig);
  26.584 -		return 0;
  26.585 -	}
  26.586 -
  26.587 -	newsighand = kmem_cache_alloc(sighand_cachep, GFP_KERNEL);
  26.588 -	if (!newsighand)
  26.589 -		return -ENOMEM;
  26.590 -
  26.591 -	if (thread_group_empty(current))
  26.592 -		goto no_thread_group;
  26.593 -
  26.594 -	/*
  26.595 -	 * Kill all other threads in the thread group.
  26.596 -	 * We must hold tasklist_lock to call zap_other_threads.
  26.597 -	 */
  26.598 -	read_lock(&tasklist_lock);
  26.599 -	spin_lock_irq(lock);
  26.600 -	if (sig->group_exit) {
  26.601 -		/*
  26.602 -		 * Another group action in progress, just
  26.603 -		 * return so that the signal is processed.
  26.604 -		 */
  26.605 -		spin_unlock_irq(lock);
  26.606 -		read_unlock(&tasklist_lock);
  26.607 -		kmem_cache_free(sighand_cachep, newsighand);
  26.608 -		return -EAGAIN;
  26.609 -	}
  26.610 -	sig->group_exit = 1;
  26.611 -	zap_other_threads(current);
  26.612 -	read_unlock(&tasklist_lock);
  26.613 -
  26.614 -	/*
  26.615 -	 * Account for the thread group leader hanging around:
  26.616 -	 */
  26.617 -	count = 2;
  26.618 -	if (current->pid == current->tgid)
  26.619 -		count = 1;
  26.620 -	while (atomic_read(&sig->count) > count) {
  26.621 -		sig->group_exit_task = current;
  26.622 -		sig->notify_count = count;
  26.623 -		__set_current_state(TASK_UNINTERRUPTIBLE);
  26.624 -		spin_unlock_irq(lock);
  26.625 -		schedule();
  26.626 -		spin_lock_irq(lock);
  26.627 -	}
  26.628 -	sig->group_exit_task = NULL;
  26.629 -	sig->notify_count = 0;
  26.630 -	spin_unlock_irq(lock);
  26.631 -
  26.632 -	/*
  26.633 -	 * At this point all other threads have exited, all we have to
  26.634 -	 * do is to wait for the thread group leader to become inactive,
  26.635 -	 * and to assume its PID:
  26.636 -	 */
  26.637 -	if (current->pid != current->tgid) {
  26.638 -		struct task_struct *leader = current->group_leader, *parent;
  26.639 -		struct dentry *proc_dentry1, *proc_dentry2;
  26.640 -		unsigned long exit_state, ptrace;
  26.641 -
  26.642 -		/*
  26.643 -		 * Wait for the thread group leader to be a zombie.
  26.644 -		 * It should already be zombie at this point, most
  26.645 -		 * of the time.
  26.646 -		 */
  26.647 -		while (leader->exit_state != EXIT_ZOMBIE)
  26.648 -			yield();
  26.649 -
  26.650 -		spin_lock(&leader->proc_lock);
  26.651 -		spin_lock(&current->proc_lock);
  26.652 -		proc_dentry1 = proc_pid_unhash(current);
  26.653 -		proc_dentry2 = proc_pid_unhash(leader);
  26.654 -		write_lock_irq(&tasklist_lock);
  26.655 -
  26.656 -		if (leader->tgid != current->tgid)
  26.657 -			BUG();
  26.658 -		if (current->pid == current->tgid)
  26.659 -			BUG();
  26.660 -		/*
  26.661 -		 * An exec() starts a new thread group with the
  26.662 -		 * TGID of the previous thread group. Rehash the
  26.663 -		 * two threads with a switched PID, and release
  26.664 -		 * the former thread group leader:
  26.665 -		 */
  26.666 -		ptrace = leader->ptrace;
  26.667 -		parent = leader->parent;
  26.668 -
  26.669 -		ptrace_unlink(current);
  26.670 -		ptrace_unlink(leader);
  26.671 -		remove_parent(current);
  26.672 -		remove_parent(leader);
  26.673 -
  26.674 -		switch_exec_pids(leader, current);
  26.675 -
  26.676 -		current->parent = current->real_parent = leader->real_parent;
  26.677 -		leader->parent = leader->real_parent = child_reaper;
  26.678 -		current->group_leader = current;
  26.679 -		leader->group_leader = leader;
  26.680 -
  26.681 -		add_parent(current, current->parent);
  26.682 -		add_parent(leader, leader->parent);
  26.683 -		if (ptrace) {
  26.684 -			current->ptrace = ptrace;
  26.685 -			__ptrace_link(current, parent);
  26.686 -		}
  26.687 -
  26.688 -		list_del(&current->tasks);
  26.689 -		list_add_tail(&current->tasks, &init_task.tasks);
  26.690 -		current->exit_signal = SIGCHLD;
  26.691 -		exit_state = leader->exit_state;
  26.692 -
  26.693 -		write_unlock_irq(&tasklist_lock);
  26.694 -		spin_unlock(&leader->proc_lock);
  26.695 -		spin_unlock(&current->proc_lock);
  26.696 -		proc_pid_flush(proc_dentry1);
  26.697 -		proc_pid_flush(proc_dentry2);
  26.698 -
  26.699 -		if (exit_state != EXIT_ZOMBIE)
  26.700 -			BUG();
  26.701 -		release_task(leader);
  26.702 -        }
  26.703 -
  26.704 -	/*
  26.705 -	 * Now there are really no other threads at all,
  26.706 -	 * so it's safe to stop telling them to kill themselves.
  26.707 -	 */
  26.708 -	sig->group_exit = 0;
  26.709 -
  26.710 -no_thread_group:
  26.711 -	BUG_ON(atomic_read(&sig->count) != 1);
  26.712 -	exit_itimers(sig);
  26.713 -
  26.714 -	if (atomic_read(&oldsighand->count) == 1) {
  26.715 -		/*
  26.716 -		 * Now that we nuked the rest of the thread group,
  26.717 -		 * it turns out we are not sharing sighand any more either.
  26.718 -		 * So we can just keep it.
  26.719 -		 */
  26.720 -		kmem_cache_free(sighand_cachep, newsighand);
  26.721 -	} else {
  26.722 -		/*
  26.723 -		 * Move our state over to newsighand and switch it in.
  26.724 -		 */
  26.725 -		spin_lock_init(&newsighand->siglock);
  26.726 -		atomic_set(&newsighand->count, 1);
  26.727 -		memcpy(newsighand->action, oldsighand->action,
  26.728 -		       sizeof(newsighand->action));
  26.729 -
  26.730 -		write_lock_irq(&tasklist_lock);
  26.731 -		spin_lock(&oldsighand->siglock);
  26.732 -		spin_lock(&newsighand->siglock);
  26.733 -
  26.734 -		current->sighand = newsighand;
  26.735 -		recalc_sigpending();
  26.736 -
  26.737 -		spin_unlock(&newsighand->siglock);
  26.738 -		spin_unlock(&oldsighand->siglock);
  26.739 -		write_unlock_irq(&tasklist_lock);
  26.740 -
  26.741 -		if (atomic_dec_and_test(&oldsighand->count))
  26.742 -			kmem_cache_free(sighand_cachep, oldsighand);
  26.743 -	}
  26.744 -
  26.745 -	if (!thread_group_empty(current))
  26.746 -		BUG();
  26.747 -	if (current->tgid != current->pid)
  26.748 -		BUG();
  26.749 -	return 0;
  26.750 -}
  26.751 -	
  26.752 -/*
  26.753 - * These functions flushes out all traces of the currently running executable
  26.754 - * so that a new one can be started
  26.755 - */
  26.756 -
  26.757 -static inline void flush_old_files(struct files_struct * files)
  26.758 -{
  26.759 -	long j = -1;
  26.760 -
  26.761 -	spin_lock(&files->file_lock);
  26.762 -	for (;;) {
  26.763 -		unsigned long set, i;
  26.764 -
  26.765 -		j++;
  26.766 -		i = j * __NFDBITS;
  26.767 -		if (i >= files->max_fds || i >= files->max_fdset)
  26.768 -			break;
  26.769 -		set = files->close_on_exec->fds_bits[j];
  26.770 -		if (!set)
  26.771 -			continue;
  26.772 -		files->close_on_exec->fds_bits[j] = 0;
  26.773 -		spin_unlock(&files->file_lock);
  26.774 -		for ( ; set ; i++,set >>= 1) {
  26.775 -			if (set & 1) {
  26.776 -				sys_close(i);
  26.777 -			}
  26.778 -		}
  26.779 -		spin_lock(&files->file_lock);
  26.780 -
  26.781 -	}
  26.782 -	spin_unlock(&files->file_lock);
  26.783 -}
  26.784 -
  26.785 -void get_task_comm(char *buf, struct task_struct *tsk)
  26.786 -{
  26.787 -	/* buf must be at least sizeof(tsk->comm) in size */
  26.788 -	task_lock(tsk);
  26.789 -	memcpy(buf, tsk->comm, sizeof(tsk->comm));
  26.790 -	task_unlock(tsk);
  26.791 -}
  26.792 -
  26.793 -void set_task_comm(struct task_struct *tsk, char *buf)
  26.794 -{
  26.795 -	task_lock(tsk);
  26.796 -	strlcpy(tsk->comm, buf, sizeof(tsk->comm));
  26.797 -	task_unlock(tsk);
  26.798 -}
  26.799 -
  26.800 -int flush_old_exec(struct linux_binprm * bprm)
  26.801 -{
  26.802 -	char * name;
  26.803 -	int i, ch, retval;
  26.804 -	struct files_struct *files;
  26.805 -	char tcomm[sizeof(current->comm)];
  26.806 -
  26.807 -	/*
  26.808 -	 * Make sure we have a private signal table and that
  26.809 -	 * we are unassociated from the previous thread group.
  26.810 -	 */
  26.811 -	retval = de_thread(current);
  26.812 -	if (retval)
  26.813 -		goto out;
  26.814 -
  26.815 -	/*
  26.816 -	 * Make sure we have private file handles. Ask the
  26.817 -	 * fork helper to do the work for us and the exit
  26.818 -	 * helper to do the cleanup of the old one.
  26.819 -	 */
  26.820 -	files = current->files;		/* refcounted so safe to hold */
  26.821 -	retval = unshare_files();
  26.822 -	if (retval)
  26.823 -		goto out;
  26.824 -	/*
  26.825 -	 * Release all of the old mmap stuff
  26.826 -	 */
  26.827 -	retval = exec_mmap(bprm->mm);
  26.828 -	if (retval)
  26.829 -		goto mmap_failed;
  26.830 -
  26.831 -	bprm->mm = NULL;		/* We're using it now */
  26.832 -
  26.833 -	/* This is the point of no return */
  26.834 -	steal_locks(files);
  26.835 -	put_files_struct(files);
  26.836 -
  26.837 -	current->sas_ss_sp = current->sas_ss_size = 0;
  26.838 -
  26.839 -	if (current->euid == current->uid && current->egid == current->gid)
  26.840 -		current->mm->dumpable = 1;
  26.841 -	name = bprm->filename;
  26.842 -	for (i=0; (ch = *(name++)) != '\0';) {
  26.843 -		if (ch == '/')
  26.844 -			i = 0;
  26.845 -		else
  26.846 -			if (i < (sizeof(tcomm) - 1))
  26.847 -				tcomm[i++] = ch;
  26.848 -	}
  26.849 -	tcomm[i] = '\0';
  26.850 -	set_task_comm(current, tcomm);
  26.851 -
  26.852 -	flush_thread();
  26.853 -
  26.854 -	if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || 
  26.855 -	    permission(bprm->file->f_dentry->d_inode,MAY_READ, NULL) ||
  26.856 -	    (bprm->interp_flags & BINPRM_FLAGS_ENFORCE_NONDUMP)) {
  26.857 -		suid_keys(current);
  26.858 -		current->mm->dumpable = 0;
  26.859 -	}
  26.860 -
  26.861 -	/* An exec changes our domain. We are no longer part of the thread
  26.862 -	   group */
  26.863 -
  26.864 -	current->self_exec_id++;
  26.865 -			
  26.866 -	flush_signal_handlers(current, 0);
  26.867 -	flush_old_files(current->files);
  26.868 -
  26.869 -	return 0;
  26.870 -
  26.871 -mmap_failed:
  26.872 -	put_files_struct(current->files);
  26.873 -	current->files = files;
  26.874 -out:
  26.875 -	return retval;
  26.876 -}
  26.877 -
  26.878 -EXPORT_SYMBOL(flush_old_exec);
  26.879 -
  26.880 -/* 
  26.881 - * Fill the binprm structure from the inode. 
  26.882 - * Check permissions, then read the first 128 (BINPRM_BUF_SIZE) bytes
  26.883 - */
  26.884 -int prepare_binprm(struct linux_binprm *bprm)
  26.885 -{
  26.886 -	int mode;
  26.887 -	struct inode * inode = bprm->file->f_dentry->d_inode;
  26.888 -	int retval;
  26.889 -
  26.890 -	mode = inode->i_mode;
  26.891 -	/*
  26.892 -	 * Check execute perms again - if the caller has CAP_DAC_OVERRIDE,
  26.893 -	 * generic_permission lets a non-executable through
  26.894 -	 */
  26.895 -	if (!(mode & 0111))	/* with at least _one_ execute bit set */
  26.896 -		return -EACCES;
  26.897 -	if (bprm->file->f_op == NULL)
  26.898 -		return -EACCES;
  26.899 -
  26.900 -	bprm->e_uid = current->euid;
  26.901 -	bprm->e_gid = current->egid;
  26.902 -
  26.903 -	if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
  26.904 -		/* Set-uid? */
  26.905 -		if (mode & S_ISUID) {
  26.906 -			current->personality &= ~PER_CLEAR_ON_SETID;
  26.907 -			bprm->e_uid = inode->i_uid;
  26.908 -		}
  26.909 -
  26.910 -		/* Set-gid? */
  26.911 -		/*
  26.912 -		 * If setgid is set but no group execute bit then this
  26.913 -		 * is a candidate for mandatory locking, not a setgid
  26.914 -		 * executable.
  26.915 -		 */
  26.916 -		if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
  26.917 -			current->personality &= ~PER_CLEAR_ON_SETID;
  26.918 -			bprm->e_gid = inode->i_gid;
  26.919 -		}
  26.920 -	}
  26.921 -
  26.922 -	/* fill in binprm security blob */
  26.923 -	retval = security_bprm_set(bprm);
  26.924 -	if (retval)
  26.925 -		return retval;
  26.926 -
  26.927 -	memset(bprm->buf,0,BINPRM_BUF_SIZE);
  26.928 -	return kernel_read(bprm->file,0,bprm->buf,BINPRM_BUF_SIZE);
  26.929 -}
  26.930 -
  26.931 -EXPORT_SYMBOL(prepare_binprm);
  26.932 -
  26.933 -static inline int unsafe_exec(struct task_struct *p)
  26.934 -{
  26.935 -	int unsafe = 0;
  26.936 -	if (p->ptrace & PT_PTRACED) {
  26.937 -		if (p->ptrace & PT_PTRACE_CAP)
  26.938 -			unsafe |= LSM_UNSAFE_PTRACE_CAP;
  26.939 -		else
  26.940 -			unsafe |= LSM_UNSAFE_PTRACE;
  26.941 -	}
  26.942 -	if (atomic_read(&p->fs->count) > 1 ||
  26.943 -	    atomic_read(&p->files->count) > 1 ||
  26.944 -	    atomic_read(&p->sighand->count) > 1)
  26.945 -		unsafe |= LSM_UNSAFE_SHARE;
  26.946 -
  26.947 -	return unsafe;
  26.948 -}
  26.949 -
  26.950 -void compute_creds(struct linux_binprm *bprm)
  26.951 -{
  26.952 -	int unsafe;
  26.953 -
  26.954 -	if (bprm->e_uid != current->uid)
  26.955 -		suid_keys(current);
  26.956 -	exec_keys(current);
  26.957 -
  26.958 -	task_lock(current);
  26.959 -	unsafe = unsafe_exec(current);
  26.960 -	security_bprm_apply_creds(bprm, unsafe);
  26.961 -	task_unlock(current);
  26.962 -}
  26.963 -
  26.964 -EXPORT_SYMBOL(compute_creds);
  26.965 -
  26.966 -void remove_arg_zero(struct linux_binprm *bprm)
  26.967 -{
  26.968 -	if (bprm->argc) {
  26.969 -		unsigned long offset;
  26.970 -		char * kaddr;
  26.971 -		struct page *page;
  26.972 -
  26.973 -		offset = bprm->p % PAGE_SIZE;
  26.974 -		goto inside;
  26.975 -
  26.976 -		while (bprm->p++, *(kaddr+offset++)) {
  26.977 -			if (offset != PAGE_SIZE)
  26.978 -				continue;
  26.979 -			offset = 0;
  26.980 -			kunmap_atomic(kaddr, KM_USER0);
  26.981 -inside:
  26.982 -			page = bprm->page[bprm->p/PAGE_SIZE];
  26.983 -			kaddr = kmap_atomic(page, KM_USER0);
  26.984 -		}
  26.985 -		kunmap_atomic(kaddr, KM_USER0);
  26.986 -		bprm->argc--;
  26.987 -	}
  26.988 -}
  26.989 -
  26.990 -EXPORT_SYMBOL(remove_arg_zero);
  26.991 -
  26.992 -/*
  26.993 - * cycle the list of binary formats handler, until one recognizes the image
  26.994 - */
  26.995 -int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
  26.996 -{
  26.997 -	int try,retval;
  26.998 -	struct linux_binfmt *fmt;
  26.999 -#ifdef __alpha__
 26.1000 -	/* handle /sbin/loader.. */
 26.1001 -	{
 26.1002 -	    struct exec * eh = (struct exec *) bprm->buf;
 26.1003 -
 26.1004 -	    if (!bprm->loader && eh->fh.f_magic == 0x183 &&
 26.1005 -		(eh->fh.f_flags & 0x3000) == 0x3000)
 26.1006 -	    {
 26.1007 -		struct file * file;
 26.1008 -		unsigned long loader;
 26.1009 -
 26.1010 -		allow_write_access(bprm->file);
 26.1011 -		fput(bprm->file);
 26.1012 -		bprm->file = NULL;
 26.1013 -
 26.1014 -	        loader = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 26.1015 -
 26.1016 -		file = open_exec("/sbin/loader");
 26.1017 -		retval = PTR_ERR(file);
 26.1018 -		if (IS_ERR(file))
 26.1019 -			return retval;
 26.1020 -
 26.1021 -		/* Remember if the application is TASO.  */
 26.1022 -		bprm->sh_bang = eh->ah.entry < 0x100000000UL;
 26.1023 -
 26.1024 -		bprm->file = file;
 26.1025 -		bprm->loader = loader;
 26.1026 -		retval = prepare_binprm(bprm);
 26.1027 -		if (retval<0)
 26.1028 -			return retval;
 26.1029 -		/* should call search_binary_handler recursively here,
 26.1030 -		   but it does not matter */
 26.1031 -	    }
 26.1032 -	}
 26.1033 -#endif
 26.1034 -	retval = security_bprm_check(bprm);
 26.1035 -	if (retval)
 26.1036 -		return retval;
 26.1037 -
 26.1038 -	/* kernel module loader fixup */
 26.1039 -	/* so we don't try to load run modprobe in kernel space. */
 26.1040 -	set_fs(USER_DS);
 26.1041 -	retval = -ENOENT;
 26.1042 -	for (try=0; try<2; try++) {
 26.1043 -		read_lock(&binfmt_lock);
 26.1044 -		for (fmt = formats ; fmt ; fmt = fmt->next) {
 26.1045 -			int (*fn)(struct linux_binprm *, struct pt_regs *) = fmt->load_binary;
 26.1046 -			if (!fn)
 26.1047 -				continue;
 26.1048 -			if (!try_module_get(fmt->module))
 26.1049 -				continue;
 26.1050 -			read_unlock(&binfmt_lock);
 26.1051 -			retval = fn(bprm, regs);
 26.1052 -			if (retval >= 0) {
 26.1053 -				put_binfmt(fmt);
 26.1054 -				allow_write_access(bprm->file);
 26.1055 -				if (bprm->file)
 26.1056 -					fput(bprm->file);
 26.1057 -				bprm->file = NULL;
 26.1058 -				current->did_exec = 1;
 26.1059 -				return retval;
 26.1060 -			}
 26.1061 -			read_lock(&binfmt_lock);
 26.1062 -			put_binfmt(fmt);
 26.1063 -			if (retval != -ENOEXEC || bprm->mm == NULL)
 26.1064 -				break;
 26.1065 -			if (!bprm->file) {
 26.1066 -				read_unlock(&binfmt_lock);
 26.1067 -				return retval;
 26.1068 -			}
 26.1069 -		}
 26.1070 -		read_unlock(&binfmt_lock);
 26.1071 -		if (retval != -ENOEXEC || bprm->mm == NULL) {
 26.1072 -			break;
 26.1073 -#ifdef CONFIG_KMOD
 26.1074 -		}else{
 26.1075 -#define printable(c) (((c)=='\t') || ((c)=='\n') || (0x20<=(c) && (c)<=0x7e))
 26.1076 -			if (printable(bprm->buf[0]) &&
 26.1077 -			    printable(bprm->buf[1]) &&
 26.1078 -			    printable(bprm->buf[2]) &&
 26.1079 -			    printable(bprm->buf[3]))
 26.1080 -				break; /* -ENOEXEC */
 26.1081 -			request_module("binfmt-%04x", *(unsigned short *)(&bprm->buf[2]));
 26.1082 -#endif
 26.1083 -		}
 26.1084 -	}
 26.1085 -	return retval;
 26.1086 -}
 26.1087 -
 26.1088 -EXPORT_SYMBOL(search_binary_handler);
 26.1089 -
 26.1090 -/*
 26.1091 - * sys_execve() executes a new program.
 26.1092 - */
 26.1093 -int do_execve(char * filename,
 26.1094 -	char __user *__user *argv,
 26.1095 -	char __user *__user *envp,
 26.1096 -	struct pt_regs * regs)
 26.1097 -{
 26.1098 -	struct linux_binprm *bprm;
 26.1099 -	struct file *file;
 26.1100 -	int retval;
 26.1101 -	int i;
 26.1102 -
 26.1103 -	retval = -ENOMEM;
 26.1104 -	bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
 26.1105 -	if (!bprm)
 26.1106 -		goto out_ret;
 26.1107 -	memset(bprm, 0, sizeof(*bprm));
 26.1108 -
 26.1109 -	file = open_exec(filename);
 26.1110 -	retval = PTR_ERR(file);
 26.1111 -	if (IS_ERR(file))
 26.1112 -		goto out_kfree;
 26.1113 -
 26.1114 -	sched_exec();
 26.1115 -
 26.1116 -	bprm->p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *);
 26.1117 -
 26.1118 -	bprm->file = file;
 26.1119 -	bprm->filename = filename;
 26.1120 -	bprm->interp = filename;
 26.1121 -	bprm->mm = mm_alloc();
 26.1122 -	retval = -ENOMEM;
 26.1123 -	if (!bprm->mm)
 26.1124 -		goto out_file;
 26.1125 -
 26.1126 -	retval = init_new_context(current, bprm->mm);
 26.1127 -	if (retval < 0)
 26.1128 -		goto out_mm;
 26.1129 -
 26.1130 -	bprm->argc = count(argv, bprm->p / sizeof(void *));
 26.1131 -	if ((retval = bprm->argc) < 0)
 26.1132 -		goto out_mm;
 26.1133 -
 26.1134 -	bprm->envc = count(envp, bprm->p / sizeof(void *));
 26.1135 -	if ((retval = bprm->envc) < 0)
 26.1136 -		goto out_mm;
 26.1137 -
 26.1138 -	retval = security_bprm_alloc(bprm);
 26.1139 -	if (retval)
 26.1140 -		goto out;
 26.1141 -
 26.1142 -	retval = prepare_binprm(bprm);
 26.1143 -	if (retval < 0)
 26.1144 -		goto out;
 26.1145 -
 26.1146 -	retval = copy_strings_kernel(1, &bprm->filename, bprm);
 26.1147 -	if (retval < 0)
 26.1148 -		goto out;
 26.1149 -
 26.1150 -	bprm->exec = bprm->p;
 26.1151 -	retval = copy_strings(bprm->envc, envp, bprm);
 26.1152 -	if (retval < 0)
 26.1153 -		goto out;
 26.1154 -
 26.1155 -	retval = copy_strings(bprm->argc, argv, bprm);
 26.1156 -	if (retval < 0)
 26.1157 -		goto out;
 26.1158 -
 26.1159 -	retval = search_binary_handler(bprm,regs);
 26.1160 -	if (retval >= 0) {
 26.1161 -		free_arg_pages(bprm);
 26.1162 -
 26.1163 -		/* execve success */
 26.1164 -		security_bprm_free(bprm);
 26.1165 -		kfree(bprm);
 26.1166 -		return retval;
 26.1167 -	}
 26.1168 -
 26.1169 -out:
 26.1170 -	/* Something went wrong, return the inode and free the argument pages*/
 26.1171 -	for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
 26.1172 -		struct page * page = bprm->page[i];
 26.1173 -		if (page)
 26.1174 -			__free_page(page);
 26.1175 -	}
 26.1176 -
 26.1177 -	if (bprm->security)
 26.1178 -		security_bprm_free(bprm);
 26.1179 -
 26.1180 -out_mm:
 26.1181 -	if (bprm->mm)
 26.1182 -		mmdrop(bprm->mm);
 26.1183 -
 26.1184 -out_file:
 26.1185 -	if (bprm->file) {
 26.1186 -		allow_write_access(bprm->file);
 26.1187 -		fput(bprm->file);
 26.1188 -	}
 26.1189 -
 26.1190 -out_kfree:
 26.1191 -	kfree(bprm);
 26.1192 -
 26.1193 -out_ret:
 26.1194 -	return retval;
 26.1195 -}
 26.1196 -
 26.1197 -int set_binfmt(struct linux_binfmt *new)
 26.1198 -{
 26.1199 -	struct linux_binfmt *old = current->binfmt;
 26.1200 -
 26.1201 -	if (new) {
 26.1202 -		if (!try_module_get(new->module))
 26.1203 -			return -1;
 26.1204 -	}
 26.1205 -	current->binfmt = new;
 26.1206 -	if (old)
 26.1207 -		module_put(old->module);
 26.1208 -	return 0;
 26.1209 -}
 26.1210 -
 26.1211 -EXPORT_SYMBOL(set_binfmt);
 26.1212 -
 26.1213 -#define CORENAME_MAX_SIZE 64
 26.1214 -
 26.1215 -/* format_corename will inspect the pattern parameter, and output a
 26.1216 - * name into corename, which must have space for at least
 26.1217 - * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
 26.1218 - */
 26.1219 -static void format_corename(char *corename, const char *pattern, long signr)
 26.1220 -{
 26.1221 -	const char *pat_ptr = pattern;
 26.1222 -	char *out_ptr = corename;
 26.1223 -	char *const out_end = corename + CORENAME_MAX_SIZE;
 26.1224 -	int rc;
 26.1225 -	int pid_in_pattern = 0;
 26.1226 -
 26.1227 -	/* Repeat as long as we have more pattern to process and more output
 26.1228 -	   space */
 26.1229 -	while (*pat_ptr) {
 26.1230 -		if (*pat_ptr != '%') {
 26.1231 -			if (out_ptr == out_end)
 26.1232 -				goto out;
 26.1233 -			*out_ptr++ = *pat_ptr++;
 26.1234 -		} else {
 26.1235 -			switch (*++pat_ptr) {
 26.1236 -			case 0:
 26.1237 -				goto out;
 26.1238 -			/* Double percent, output one percent */
 26.1239 -			case '%':
 26.1240 -				if (out_ptr == out_end)
 26.1241 -					goto out;
 26.1242 -				*out_ptr++ = '%';
 26.1243 -				break;
 26.1244 -			/* pid */
 26.1245 -			case 'p':
 26.1246 -				pid_in_pattern = 1;
 26.1247 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1248 -					      "%d", current->tgid);
 26.1249 -				if (rc > out_end - out_ptr)
 26.1250 -					goto out;
 26.1251 -				out_ptr += rc;
 26.1252 -				break;
 26.1253 -			/* uid */
 26.1254 -			case 'u':
 26.1255 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1256 -					      "%d", current->uid);
 26.1257 -				if (rc > out_end - out_ptr)
 26.1258 -					goto out;
 26.1259 -				out_ptr += rc;
 26.1260 -				break;
 26.1261 -			/* gid */
 26.1262 -			case 'g':
 26.1263 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1264 -					      "%d", current->gid);
 26.1265 -				if (rc > out_end - out_ptr)
 26.1266 -					goto out;
 26.1267 -				out_ptr += rc;
 26.1268 -				break;
 26.1269 -			/* signal that caused the coredump */
 26.1270 -			case 's':
 26.1271 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1272 -					      "%ld", signr);
 26.1273 -				if (rc > out_end - out_ptr)
 26.1274 -					goto out;
 26.1275 -				out_ptr += rc;
 26.1276 -				break;
 26.1277 -			/* UNIX time of coredump */
 26.1278 -			case 't': {
 26.1279 -				struct timeval tv;
 26.1280 -				do_gettimeofday(&tv);
 26.1281 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1282 -					      "%lu", tv.tv_sec);
 26.1283 -				if (rc > out_end - out_ptr)
 26.1284 -					goto out;
 26.1285 -				out_ptr += rc;
 26.1286 -				break;
 26.1287 -			}
 26.1288 -			/* hostname */
 26.1289 -			case 'h':
 26.1290 -				down_read(&uts_sem);
 26.1291 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1292 -					      "%s", system_utsname.nodename);
 26.1293 -				up_read(&uts_sem);
 26.1294 -				if (rc > out_end - out_ptr)
 26.1295 -					goto out;
 26.1296 -				out_ptr += rc;
 26.1297 -				break;
 26.1298 -			/* executable */
 26.1299 -			case 'e':
 26.1300 -				rc = snprintf(out_ptr, out_end - out_ptr,
 26.1301 -					      "%s", current->comm);
 26.1302 -				if (rc > out_end - out_ptr)
 26.1303 -					goto out;
 26.1304 -				out_ptr += rc;
 26.1305 -				break;
 26.1306 -			default:
 26.1307 -				break;
 26.1308 -			}
 26.1309 -			++pat_ptr;
 26.1310 -		}
 26.1311 -	}
 26.1312 -	/* Backward compatibility with core_uses_pid:
 26.1313 -	 *
 26.1314 -	 * If core_pattern does not include a %p (as is the default)
 26.1315 -	 * and core_uses_pid is set, then .%pid will be appended to
 26.1316 -	 * the filename */
 26.1317 -	if (!pid_in_pattern
 26.1318 -            && (core_uses_pid || atomic_read(&current->mm->mm_users) != 1)) {
 26.1319 -		rc = snprintf(out_ptr, out_end - out_ptr,
 26.1320 -			      ".%d", current->tgid);
 26.1321 -		if (rc > out_end - out_ptr)
 26.1322 -			goto out;
 26.1323 -		out_ptr += rc;
 26.1324 -	}
 26.1325 -      out:
 26.1326 -	*out_ptr = 0;
 26.1327 -}
 26.1328 -
 26.1329 -static void zap_threads (struct mm_struct *mm)
 26.1330 -{
 26.1331 -	struct task_struct *g, *p;
 26.1332 -	struct task_struct *tsk = current;
 26.1333 -	struct completion *vfork_done = tsk->vfork_done;
 26.1334 -
 26.1335 -	/*
 26.1336 -	 * Make sure nobody is waiting for us to release the VM,
 26.1337 -	 * otherwise we can deadlock when we wait on each other
 26.1338 -	 */
 26.1339 -	if (vfork_done) {
 26.1340 -		tsk->vfork_done = NULL;
 26.1341 -		complete(vfork_done);
 26.1342 -	}
 26.1343 -
 26.1344 -	read_lock(&tasklist_lock);
 26.1345 -	do_each_thread(g,p)
 26.1346 -		if (mm == p->mm && p != tsk) {
 26.1347 -			force_sig_specific(SIGKILL, p);
 26.1348 -			mm->core_waiters++;
 26.1349 -		}
 26.1350 -	while_each_thread(g,p);
 26.1351 -
 26.1352 -	read_unlock(&tasklist_lock);
 26.1353 -}
 26.1354 -
 26.1355 -static void coredump_wait(struct mm_struct *mm)
 26.1356 -{
 26.1357 -	DECLARE_COMPLETION(startup_done);
 26.1358 -
 26.1359 -	mm->core_waiters++; /* let other threads block */
 26.1360 -	mm->core_startup_done = &startup_done;
 26.1361 -
 26.1362 -	/* give other threads a chance to run: */
 26.1363 -	yield();
 26.1364 -
 26.1365 -	zap_threads(mm);
 26.1366 -	if (--mm->core_waiters) {
 26.1367 -		up_write(&mm->mmap_sem);
 26.1368 -		wait_for_completion(&startup_done);
 26.1369 -	} else
 26.1370 -		up_write(&mm->mmap_sem);
 26.1371 -	BUG_ON(mm->core_waiters);
 26.1372 -}
 26.1373 -
 26.1374 -int do_coredump(long signr, int exit_code, struct pt_regs * regs)
 26.1375 -{
 26.1376 -	char corename[CORENAME_MAX_SIZE + 1];
 26.1377 -	struct mm_struct *mm = current->mm;
 26.1378 -	struct linux_binfmt * binfmt;
 26.1379 -	struct inode * inode;
 26.1380 -	struct file * file;
 26.1381 -	int retval = 0;
 26.1382 -
 26.1383 -	binfmt = current->binfmt;
 26.1384 -	if (!binfmt || !binfmt->core_dump)
 26.1385 -		goto fail;
 26.1386 -	down_write(&mm->mmap_sem);
 26.1387 -	if (!mm->dumpable) {
 26.1388 -		up_write(&mm->mmap_sem);
 26.1389 -		goto fail;
 26.1390 -	}
 26.1391 -	mm->dumpable = 0;
 26.1392 -	init_completion(&mm->core_done);
 26.1393 -	current->signal->group_exit = 1;
 26.1394 -	current->signal->group_exit_code = exit_code;
 26.1395 -	coredump_wait(mm);
 26.1396 -
 26.1397 -	if (current->signal->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump)
 26.1398 -		goto fail_unlock;
 26.1399 -
 26.1400 -	/*
 26.1401 -	 * lock_kernel() because format_corename() is controlled by sysctl, which
 26.1402 -	 * uses lock_kernel()
 26.1403 -	 */
 26.1404 - 	lock_kernel();
 26.1405 -	format_corename(corename, core_pattern, signr);
 26.1406 -	unlock_kernel();
 26.1407 -	file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600);
 26.1408 -	if (IS_ERR(file))
 26.1409 -		goto fail_unlock;
 26.1410 -	inode = file->f_dentry->d_inode;
 26.1411 -	if (inode->i_nlink > 1)
 26.1412 -		goto close_fail;	/* multiple links - don't dump */
 26.1413 -	if (d_unhashed(file->f_dentry))
 26.1414 -		goto close_fail;
 26.1415 -
 26.1416 -	if (!S_ISREG(inode->i_mode))
 26.1417 -		goto close_fail;
 26.1418 -	if (!file->f_op)
 26.1419 -		goto close_fail;
 26.1420 -	if (!file->f_op->write)
 26.1421 -		goto close_fail;
 26.1422 -	if (do_truncate(file->f_dentry, 0) != 0)
 26.1423 -		goto close_fail;
 26.1424 -
 26.1425 -	retval = binfmt->core_dump(signr, regs, file);
 26.1426 -
 26.1427 -	if (retval)
 26.1428 -		current->signal->group_exit_code |= 0x80;
 26.1429 -close_fail:
 26.1430 -	filp_close(file, NULL);
 26.1431 -fail_unlock:
 26.1432 -	complete_all(&mm->core_done);
 26.1433 -fail:
 26.1434 -	return retval;
 26.1435 -}
    27.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h	Thu Mar 24 16:48:36 2005 +0000
    27.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h	Thu Mar 24 20:20:12 2005 +0000
    27.3 @@ -89,11 +89,7 @@ static inline void set_ldt_desc(unsigned
    27.4  
    27.5  static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
    27.6  {
    27.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    27.8  #define C(i) HYPERVISOR_update_descriptor(virt_to_machine(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), ((u32 *)&t->tls_array[i])[0], ((u32 *)&t->tls_array[i])[1])
    27.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   27.10 -#define C(i) HYPERVISOR_update_descriptor(__pa(&get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i]), ((u32 *)&t->tls_array[i])[0], ((u32 *)&t->tls_array[i])[1])
   27.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   27.12  	C(0); C(1); C(2);
   27.13  #undef C
   27.14  }
    28.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Thu Mar 24 16:48:36 2005 +0000
    28.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Thu Mar 24 20:20:12 2005 +0000
    28.3 @@ -101,26 +101,15 @@ enum fixed_addresses {
    28.4  
    28.5  extern void __set_fixmap (enum fixed_addresses idx,
    28.6  					unsigned long phys, pgprot_t flags);
    28.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    28.8  extern void __set_fixmap_ma (enum fixed_addresses idx,
    28.9 -#else /* CONFIG_XEN_SHADOW_MODE */
   28.10 -extern void __vms___set_fixmap_ma (enum fixed_addresses idx,
   28.11 -#endif /* CONFIG_XEN_SHADOW_MODE */
   28.12  					unsigned long mach, pgprot_t flags);
   28.13  
   28.14  #define set_fixmap(idx, phys) \
   28.15  		__set_fixmap(idx, phys, PAGE_KERNEL)
   28.16 -#ifndef CONFIG_XEN_SHADOW_MODE
   28.17  #define set_fixmap_ma(idx, phys) \
   28.18  		__set_fixmap_ma(idx, phys, PAGE_KERNEL)
   28.19  #define set_fixmap_ma_ro(idx, phys) \
   28.20  		__set_fixmap_ma(idx, phys, PAGE_KERNEL_RO)
   28.21 -#else /* CONFIG_XEN_SHADOW_MODE */
   28.22 -#define __vms_set_fixmap_ma(idx, phys) \
   28.23 -		__vms___set_fixmap_ma(idx, phys, PAGE_KERNEL)
   28.24 -#define __vms_set_fixmap_ma_ro(idx, phys) \
   28.25 -		__vms___set_fixmap_ma(idx, phys, PAGE_KERNEL_RO)
   28.26 -#endif /* CONFIG_XEN_SHADOW_MODE */
   28.27  /*
   28.28   * Some hardware wants to get fixmapped without caching.
   28.29   */
    29.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/io.h	Thu Mar 24 16:48:36 2005 +0000
    29.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/io.h	Thu Mar 24 20:20:12 2005 +0000
    29.3 @@ -89,44 +89,18 @@ static inline void * phys_to_virt(unsign
    29.4  /*
    29.5   * Change "struct page" to physical address.
    29.6   */
    29.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    29.8  #define page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
    29.9  #define page_to_phys(page)	 (phys_to_machine(page_to_pseudophys(page)))
   29.10 -#else /* CONFIG_XEN_SHADOW_MODE */
   29.11 -#define __vms_page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
   29.12 -#define __vms_page_to_machphys(page) (__vms_phys_to_machine(__vms_page_to_pseudophys(page)))
   29.13 -#define page_to_phys(page)	 (__vms_page_to_machphys(page))
   29.14 -#endif /* CONFIG_XEN_SHADOW_MODE */
   29.15  
   29.16 -#ifndef CONFIG_XEN_SHADOW_MODE
   29.17  #define bio_to_pseudophys(bio)	 (page_to_pseudophys(bio_page((bio))) + \
   29.18  				  (unsigned long) bio_offset((bio)))
   29.19 -#else /* CONFIG_XEN_SHADOW_MODE */
   29.20 -#define __vms_bio_to_pseudophys(bio)	 (__vms_page_to_pseudophys(bio_page((bio))) + \
   29.21 -				  (unsigned long) bio_offset((bio)))
   29.22 -#endif /* CONFIG_XEN_SHADOW_MODE */
   29.23 -
   29.24 -#ifndef CONFIG_XEN_SHADOW_MODE
   29.25  #define bvec_to_pseudophys(bv)	 (page_to_pseudophys((bv)->bv_page) + \
   29.26  				  (unsigned long) (bv)->bv_offset)
   29.27 -#else /* CONFIG_XEN_SHADOW_MODE */
   29.28 -#define __vms_bvec_to_pseudophys(bv)	 (__vms_page_to_pseudophys((bv)->bv_page) + \
   29.29 -				  (unsigned long) (bv)->bv_offset)
   29.30 -#define __vms_bvec_to_machphys(bv)	 (__vms_page_to_machphys((bv)->bv_page) + \
   29.31 -				  (unsigned long) (bv)->bv_offset)
   29.32 -#endif /* CONFIG_XEN_SHADOW_MODE */
   29.33  
   29.34 -#ifndef CONFIG_XEN_SHADOW_MODE
   29.35  #define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
   29.36  	(((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) && \
   29.37  	 ((bvec_to_pseudophys((vec1)) + (vec1)->bv_len) == \
   29.38  	  bvec_to_pseudophys((vec2))))
   29.39 -#else /* CONFIG_XEN_SHADOW_MODE */
   29.40 -#define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
   29.41 -	(((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) && \
   29.42 -	 ((__vms_bvec_to_machphys((vec1)) + (vec1)->bv_len) == \
   29.43 -	  __vms_bvec_to_machphys((vec2))))
   29.44 -#endif /* CONFIG_XEN_SHADOW_MODE */
   29.45  
   29.46  extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
   29.47  
   29.48 @@ -175,13 +149,8 @@ extern void bt_iounmap(void *addr, unsig
   29.49   *
   29.50   * Allow them on x86 for legacy drivers, though.
   29.51   */
   29.52 -#ifndef CONFIG_XEN_SHADOW_MODE
   29.53  #define virt_to_bus(_x) phys_to_machine(__pa(_x))
   29.54  #define bus_to_virt(_x) __va(machine_to_phys(_x))
   29.55 -#else /* CONFIG_XEN_SHADOW_MODE */
   29.56 -#define virt_to_bus(_x) __vms_phys_to_machine(__pa(_x))
   29.57 -#define bus_to_virt(_x) ({ BUG(); __va((_x)); })
   29.58 -#endif /* CONFIG_XEN_SHADOW_MODE */
   29.59  
   29.60  /*
   29.61   * readX/writeX() are used to access memory mapped devices. On some
    30.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Mar 24 16:48:36 2005 +0000
    30.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/page.h	Thu Mar 24 20:20:12 2005 +0000
    30.3 @@ -12,10 +12,6 @@
    30.4  #ifdef __KERNEL__
    30.5  #ifndef __ASSEMBLY__
    30.6  
    30.7 -#ifdef CONFIG_XEN_SHADOW_MODE
    30.8 -#include <asm/bug.h>
    30.9 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.10 -
   30.11  #include <linux/config.h>
   30.12  #include <linux/string.h>
   30.13  #include <linux/types.h>
   30.14 @@ -59,37 +55,18 @@
   30.15  #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
   30.16  
   30.17  /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
   30.18 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.19  extern unsigned int *phys_to_machine_mapping;
   30.20  #define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
   30.21  #define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
   30.22  static inline unsigned long phys_to_machine(unsigned long phys)
   30.23 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.24 -extern unsigned int *__vms_phys_to_machine_mapping;
   30.25 -#define __vms_pfn_to_mfn(_pfn) ((unsigned long)(__vms_phys_to_machine_mapping[(_pfn)]))
   30.26 -#define __vms_mfn_to_pfn(_mfn) ({ BUG(); ((unsigned long)(__vms_machine_to_phys_mapping[(_mfn)])); })
   30.27 -static inline unsigned long __vms_phys_to_machine(unsigned long phys)
   30.28 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.29  {
   30.30 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.31  	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   30.32 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.33 -	unsigned long machine = __vms_pfn_to_mfn(phys >> PAGE_SHIFT);
   30.34 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.35  	machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
   30.36  	return machine;
   30.37  }
   30.38 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.39  static inline unsigned long machine_to_phys(unsigned long machine)
   30.40 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.41 -static inline unsigned long __vms_machine_to_phys(unsigned long machine)
   30.42 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.43  {
   30.44 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.45  	unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   30.46 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.47 -	unsigned long phys = __vms_mfn_to_pfn(machine >> PAGE_SHIFT);
   30.48 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.49  	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
   30.50  	return phys;
   30.51  }
   30.52 @@ -112,14 +89,9 @@ typedef struct { unsigned long pmd; } pm
   30.53  typedef struct { unsigned long pgd; } pgd_t;
   30.54  typedef struct { unsigned long pgprot; } pgprot_t;
   30.55  #define boot_pte_t pte_t /* or would you rather have a typedef */
   30.56 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.57  #define pte_val(x)	(((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
   30.58  			 (x).pte_low)
   30.59  #define pte_val_ma(x)	((x).pte_low)
   30.60 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.61 -#define pte_val(x)	((x).pte_low)
   30.62 -#define __vms_pte_val_ma(x)	((x).pte_low)
   30.63 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.64  #define HPAGE_SHIFT	22
   30.65  #endif
   30.66  #define PTE_MASK	PAGE_MASK
   30.67 @@ -134,32 +106,22 @@ typedef struct { unsigned long pgprot; }
   30.68  
   30.69  static inline unsigned long pmd_val(pmd_t x)
   30.70  {
   30.71 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.72  	unsigned long ret = x.pmd;
   30.73  	if (ret) ret = machine_to_phys(ret);
   30.74  	return ret;
   30.75 -#else /* CONFIG_XEN_SHADOW_MODE */
   30.76 -	return x.pmd;
   30.77 -#endif /* CONFIG_XEN_SHADOW_MODE */
   30.78  }
   30.79  #define pgd_val(x)	({ BUG(); (unsigned long)0; })
   30.80  #define pgprot_val(x)	((x).pgprot)
   30.81  
   30.82  static inline pte_t __pte(unsigned long x)
   30.83  {
   30.84 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.85  	if (x & 1) x = phys_to_machine(x);
   30.86 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   30.87  	return ((pte_t) { (x) });
   30.88  }
   30.89 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.90  #define __pte_ma(x)	((pte_t) { (x) } )
   30.91 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   30.92  static inline pmd_t __pmd(unsigned long x)
   30.93  {
   30.94 -#ifndef CONFIG_XEN_SHADOW_MODE
   30.95  	if ((x & 1)) x = phys_to_machine(x);
   30.96 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   30.97  	return ((pmd_t) { (x) });
   30.98  }
   30.99  #define __pgd(x)	({ BUG(); (pgprot_t) { 0 }; })
  30.100 @@ -237,13 +199,8 @@ extern int sysctl_legacy_va_layout;
  30.101  		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  30.102  
  30.103  /* VIRT <-> MACHINE conversion */
  30.104 -#ifndef CONFIG_XEN_SHADOW_MODE
  30.105  #define virt_to_machine(_a)	(phys_to_machine(__pa(_a)))
  30.106  #define machine_to_virt(_m)	(__va(machine_to_phys(_m)))
  30.107 -#else /* CONFIG_XEN_SHADOW_MODE */
  30.108 -#define __vms_virt_to_machine(_a)	(__vms_phys_to_machine(__pa(_a)))
  30.109 -#define __vms_machine_to_virt(_m)	(__va(__vms_machine_to_phys(_m)))
  30.110 -#endif /* CONFIG_XEN_SHADOW_MODE */
  30.111  
  30.112  #endif /* __KERNEL__ */
  30.113  
    31.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Thu Mar 24 16:48:36 2005 +0000
    31.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Thu Mar 24 20:20:12 2005 +0000
    31.3 @@ -16,9 +16,7 @@ static inline void pmd_populate(struct m
    31.4  	set_pmd(pmd, __pmd(_PAGE_TABLE +
    31.5  		((unsigned long long)page_to_pfn(pte) <<
    31.6  			(unsigned long long) PAGE_SHIFT)));
    31.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    31.8  	flush_page_update_queue();
    31.9 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   31.10  }
   31.11  /*
   31.12   * Allocate and free page tables.
   31.13 @@ -33,10 +31,8 @@ extern struct page *pte_alloc_one(struct
   31.14  static inline void pte_free_kernel(pte_t *pte)
   31.15  {
   31.16  	free_page((unsigned long)pte);
   31.17 -#ifndef CONFIG_XEN_SHADOW_MODE
   31.18  	make_page_writable(pte);
   31.19  	flush_page_update_queue();
   31.20 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   31.21  }
   31.22  
   31.23  extern void pte_free(struct page *pte);
    32.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Thu Mar 24 16:48:36 2005 +0000
    32.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Thu Mar 24 20:20:12 2005 +0000
    32.3 @@ -36,33 +36,14 @@ do { \
    32.4  #endif
    32.5  #define set_pte_atomic(pteptr, pteval) set_pte(pteptr, pteval)
    32.6  #else
    32.7 -#if defined(CONFIG_XEN_DEBUG_NO_MMU_BATCHING)
    32.8 -#define set_pte(pteptr, pteval)\
    32.9 -    set_pte_batched(pteptr, pteval)
   32.10 -
   32.11 -#elif defined(CONFIG_XEN_BATCH_MODE1)
   32.12 -#define set_pte(pteptr, pteval)({\
   32.13 -    set_pte_batched(pteptr, pteval);\
   32.14 -    _flush_page_update_queue();})
   32.15 -
   32.16 -#elif defined(CONFIG_XEN_BATCH_MODE2)
   32.17 -#define set_pte(pteptr, pteval)\
   32.18 -    set_pte_batched(pteptr, pteval)
   32.19 -
   32.20 -#else
   32.21  #define set_pte(pteptr, pteval) (*(pteptr) = pteval)
   32.22 -#endif
   32.23  #define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
   32.24  #endif
   32.25  /*
   32.26   * (pmds are folded into pgds so this doesn't get actually called,
   32.27   * but the define is needed for a generic inline function.)
   32.28   */
   32.29 -#ifndef CONFIG_XEN_SHADOW_MODE
   32.30  #define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval).pmd)
   32.31 -#else /* CONFIG_XEN_SHADOW_MODE */
   32.32 -#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
   32.33 -#endif /* CONFIG_XEN_SHADOW_MODE */
   32.34  #define set_pgd(pgdptr, pgdval) ((void)0)
   32.35  
   32.36  #define pgd_page(pgd) \
   32.37 @@ -86,11 +67,7 @@ static inline pte_t ptep_get_and_clear(p
   32.38  {
   32.39  	pte_t pte = *xp;
   32.40  	if (pte.pte_low)
   32.41 -#ifndef CONFIG_XEN_SHADOW_MODE
   32.42  		set_pte(xp, __pte_ma(0));
   32.43 -#else /* CONFIG_XEN_SHADOW_MODE */
   32.44 -		set_pte(xp, __pte(0));
   32.45 -#endif /* CONFIG_XEN_SHADOW_MODE */
   32.46  	return pte;
   32.47  }
   32.48  
   32.49 @@ -117,7 +94,6 @@ static inline pte_t ptep_get_and_clear(p
   32.50   */
   32.51  #define INVALID_P2M_ENTRY (~0U)
   32.52  #define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
   32.53 -#ifndef CONFIG_XEN_SHADOW_MODE
   32.54  #define pte_pfn(_pte)							\
   32.55  ({									\
   32.56  	unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;		\
   32.57 @@ -126,17 +102,12 @@ static inline pte_t ptep_get_and_clear(p
   32.58  		pfn = max_mapnr; /* special: force !pfn_valid() */	\
   32.59  	pfn;								\
   32.60  })
   32.61 -#else /* CONFIG_XEN_SHADOW_MODE */
   32.62 -#define pte_pfn(_pte)		((_pte).pte_low >> PAGE_SHIFT)
   32.63 -#endif /* CONFIG_XEN_SHADOW_MODE */
   32.64  
   32.65  #define pte_page(_pte) pfn_to_page(pte_pfn(_pte))
   32.66  
   32.67  #define pte_none(x)		(!(x).pte_low)
   32.68  #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   32.69 -#ifndef CONFIG_XEN_SHADOW_MODE
   32.70  #define pfn_pte_ma(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   32.71 -#endif /* ! CONFIG_XEN_SHADOW_MODE */
   32.72  #define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   32.73  
   32.74  /*
    33.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Mar 24 16:48:36 2005 +0000
    33.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Mar 24 20:20:12 2005 +0000
    33.3 @@ -319,16 +319,10 @@ static inline pte_t pte_modify(pte_t pte
    33.4  #define pmd_page_kernel(pmd) \
    33.5  ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
    33.6  
    33.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    33.8 -#define pmd_clear(xp) do {					\
    33.9 +#define pmd_clear(xp)	do {					\
   33.10  	set_pmd(xp, __pmd(0));					\
   33.11  	xen_flush_page_update_queue();				\
   33.12  } while (0)
   33.13 -#else /* CONFIG_XEN_SHADOW_MODE */
   33.14 -#define pmd_clear(xp)	do {					\
   33.15 -	set_pmd(xp, __pmd(0));					\
   33.16 -} while (0)
   33.17 -#endif /* CONFIG_XEN_SHADOW_MODE */
   33.18  
   33.19  #ifndef CONFIG_DISCONTIGMEM
   33.20  #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
   33.21 @@ -466,7 +460,6 @@ void make_page_writable(void *va);
   33.22  void make_pages_readonly(void *va, unsigned int nr);
   33.23  void make_pages_writable(void *va, unsigned int nr);
   33.24  
   33.25 -#ifndef CONFIG_XEN_SHADOW_MODE
   33.26  #define arbitrary_virt_to_machine(__va)					\
   33.27  ({									\
   33.28  	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   33.29 @@ -475,27 +468,6 @@ void make_pages_writable(void *va, unsig
   33.30  	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   33.31  	__pa | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
   33.32  })
   33.33 -#else /* CONFIG_XEN_SHADOW_MODE */
   33.34 -#define __vms_arbitrary_virt_to_machine(__va)					\
   33.35 -({									\
   33.36 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   33.37 -	pmd_t *__pmd = pmd_offset(__pgd, (unsigned long)(__va));	\
   33.38 -	pte_t *__pte = pte_offset_kernel(__pmd, (unsigned long)(__va));	\
   33.39 -	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   33.40 -	__vms_phys_to_machine(__pa) | ((unsigned long)(__va) & (PAGE_SIZE-1)); \
   33.41 -})
   33.42 -#endif /* CONFIG_XEN_SHADOW_MODE */
   33.43 -
   33.44 -#ifdef CONFIG_XEN_SHADOW_MODE
   33.45 -#define arbitrary_virt_to_phys(__va)					\
   33.46 -({									\
   33.47 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   33.48 -	pmd_t *__pmd = pmd_offset(__pgd, (unsigned long)(__va));	\
   33.49 -	pte_t *__pte = pte_offset_kernel(__pmd, (unsigned long)(__va));	\
   33.50 -	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   33.51 -	(__pa) | ((unsigned long)(__va) & (PAGE_SIZE-1));               \
   33.52 -})
   33.53 -#endif /* CONFIG_XEN_SHADOW_MODE */
   33.54  
   33.55  #endif /* !__ASSEMBLY__ */
   33.56  
    34.1 --- a/linux-2.6.10-xen-sparse/mm/highmem.c	Thu Mar 24 16:48:36 2005 +0000
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,607 +0,0 @@
    34.4 -/*
    34.5 - * High memory handling common code and variables.
    34.6 - *
    34.7 - * (C) 1999 Andrea Arcangeli, SuSE GmbH, andrea@suse.de
    34.8 - *          Gerhard Wichert, Siemens AG, Gerhard.Wichert@pdb.siemens.de
    34.9 - *
   34.10 - *
   34.11 - * Redesigned the x86 32-bit VM architecture to deal with
   34.12 - * 64-bit physical space. With current x86 CPUs this
   34.13 - * means up to 64 Gigabytes physical RAM.
   34.14 - *
   34.15 - * Rewrote high memory support to move the page cache into
   34.16 - * high memory. Implemented permanent (schedulable) kmaps
   34.17 - * based on Linus' idea.
   34.18 - *
   34.19 - * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
   34.20 - */
   34.21 -
   34.22 -#include <linux/mm.h>
   34.23 -#include <linux/module.h>
   34.24 -#include <linux/swap.h>
   34.25 -#include <linux/bio.h>
   34.26 -#include <linux/pagemap.h>
   34.27 -#include <linux/mempool.h>
   34.28 -#include <linux/blkdev.h>
   34.29 -#include <linux/init.h>
   34.30 -#include <linux/hash.h>
   34.31 -#include <linux/highmem.h>
   34.32 -#include <asm/tlbflush.h>
   34.33 -
   34.34 -static mempool_t *page_pool, *isa_page_pool;
   34.35 -
   34.36 -static void *page_pool_alloc(int gfp_mask, void *data)
   34.37 -{
   34.38 -	int gfp = gfp_mask | (int) (long) data;
   34.39 -
   34.40 -	return alloc_page(gfp);
   34.41 -}
   34.42 -
   34.43 -static void page_pool_free(void *page, void *data)
   34.44 -{
   34.45 -	__free_page(page);
   34.46 -}
   34.47 -
   34.48 -/*
   34.49 - * Virtual_count is not a pure "count".
   34.50 - *  0 means that it is not mapped, and has not been mapped
   34.51 - *    since a TLB flush - it is usable.
   34.52 - *  1 means that there are no users, but it has been mapped
   34.53 - *    since the last TLB flush - so we can't use it.
   34.54 - *  n means that there are (n-1) current users of it.
   34.55 - */
   34.56 -#ifdef CONFIG_HIGHMEM
   34.57 -static int pkmap_count[LAST_PKMAP];
   34.58 -static unsigned int last_pkmap_nr;
   34.59 -static spinlock_t kmap_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
   34.60 -
   34.61 -pte_t * pkmap_page_table;
   34.62 -
   34.63 -static DECLARE_WAIT_QUEUE_HEAD(pkmap_map_wait);
   34.64 -
   34.65 -static void flush_all_zero_pkmaps(void)
   34.66 -{
   34.67 -	int i;
   34.68 -
   34.69 -	flush_cache_kmaps();
   34.70 -
   34.71 -	for (i = 0; i < LAST_PKMAP; i++) {
   34.72 -		struct page *page;
   34.73 -
   34.74 -		/*
   34.75 -		 * zero means we don't have anything to do,
   34.76 -		 * >1 means that it is still in use. Only
   34.77 -		 * a count of 1 means that it is free but
   34.78 -		 * needs to be unmapped
   34.79 -		 */
   34.80 -		if (pkmap_count[i] != 1)
   34.81 -			continue;
   34.82 -		pkmap_count[i] = 0;
   34.83 -
   34.84 -		/* sanity check */
   34.85 -		if (pte_none(pkmap_page_table[i]))
   34.86 -			BUG();
   34.87 -
   34.88 -		/*
   34.89 -		 * Don't need an atomic fetch-and-clear op here;
   34.90 -		 * no-one has the page mapped, and cannot get at
   34.91 -		 * its virtual address (and hence PTE) without first
   34.92 -		 * getting the kmap_lock (which is held here).
   34.93 -		 * So no dangers, even with speculative execution.
   34.94 -		 */
   34.95 -		page = pte_page(pkmap_page_table[i]);
   34.96 -		pte_clear(&pkmap_page_table[i]);
   34.97 -
   34.98 -		set_page_address(page, NULL);
   34.99 -	}
  34.100 -	flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
  34.101 -}
  34.102 -
  34.103 -static inline unsigned long map_new_virtual(struct page *page)
  34.104 -{
  34.105 -	unsigned long vaddr;
  34.106 -	int count;
  34.107 -
  34.108 -start:
  34.109 -	count = LAST_PKMAP;
  34.110 -	/* Find an empty entry */
  34.111 -	for (;;) {
  34.112 -		last_pkmap_nr = (last_pkmap_nr + 1) & LAST_PKMAP_MASK;
  34.113 -		if (!last_pkmap_nr) {
  34.114 -			flush_all_zero_pkmaps();
  34.115 -			count = LAST_PKMAP;
  34.116 -		}
  34.117 -		if (!pkmap_count[last_pkmap_nr])
  34.118 -			break;	/* Found a usable entry */
  34.119 -		if (--count)
  34.120 -			continue;
  34.121 -
  34.122 -		/*
  34.123 -		 * Sleep for somebody else to unmap their entries
  34.124 -		 */
  34.125 -		{
  34.126 -			DECLARE_WAITQUEUE(wait, current);
  34.127 -
  34.128 -			__set_current_state(TASK_UNINTERRUPTIBLE);
  34.129 -			add_wait_queue(&pkmap_map_wait, &wait);
  34.130 -			spin_unlock(&kmap_lock);
  34.131 -			schedule();
  34.132 -			remove_wait_queue(&pkmap_map_wait, &wait);
  34.133 -			spin_lock(&kmap_lock);
  34.134 -
  34.135 -			/* Somebody else might have mapped it while we slept */
  34.136 -			if (page_address(page))
  34.137 -				return (unsigned long)page_address(page);
  34.138 -
  34.139 -			/* Re-start */
  34.140 -			goto start;
  34.141 -		}
  34.142 -	}
  34.143 -	vaddr = PKMAP_ADDR(last_pkmap_nr);
  34.144 -	set_pte(&(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
  34.145 -#ifdef CONFIG_XEN_BATCH_MODE2
  34.146 -	XEN_flush_page_update_queue();
  34.147 -#endif
  34.148 -	pkmap_count[last_pkmap_nr] = 1;
  34.149 -	set_page_address(page, (void *)vaddr);
  34.150 -
  34.151 -	return vaddr;
  34.152 -}
  34.153 -
  34.154 -void fastcall *kmap_high(struct page *page)
  34.155 -{
  34.156 -	unsigned long vaddr;
  34.157 -
  34.158 -	/*
  34.159 -	 * For highmem pages, we can't trust "virtual" until
  34.160 -	 * after we have the lock.
  34.161 -	 *
  34.162 -	 * We cannot call this from interrupts, as it may block
  34.163 -	 */
  34.164 -	spin_lock(&kmap_lock);
  34.165 -	vaddr = (unsigned long)page_address(page);
  34.166 -	if (!vaddr)
  34.167 -		vaddr = map_new_virtual(page);
  34.168 -	pkmap_count[PKMAP_NR(vaddr)]++;
  34.169 -	if (pkmap_count[PKMAP_NR(vaddr)] < 2)
  34.170 -		BUG();
  34.171 -	spin_unlock(&kmap_lock);
  34.172 -	return (void*) vaddr;
  34.173 -}
  34.174 -
  34.175 -EXPORT_SYMBOL(kmap_high);
  34.176 -
  34.177 -void fastcall kunmap_high(struct page *page)
  34.178 -{
  34.179 -	unsigned long vaddr;
  34.180 -	unsigned long nr;
  34.181 -	int need_wakeup;
  34.182 -
  34.183 -	spin_lock(&kmap_lock);
  34.184 -	vaddr = (unsigned long)page_address(page);
  34.185 -	if (!vaddr)
  34.186 -		BUG();
  34.187 -	nr = PKMAP_NR(vaddr);
  34.188 -
  34.189 -	/*
  34.190 -	 * A count must never go down to zero
  34.191 -	 * without a TLB flush!
  34.192 -	 */
  34.193 -	need_wakeup = 0;
  34.194 -	switch (--pkmap_count[nr]) {
  34.195 -	case 0:
  34.196 -		BUG();
  34.197 -	case 1:
  34.198 -		/*
  34.199 -		 * Avoid an unnecessary wake_up() function call.
  34.200 -		 * The common case is pkmap_count[] == 1, but
  34.201 -		 * no waiters.
  34.202 -		 * The tasks queued in the wait-queue are guarded
  34.203 -		 * by both the lock in the wait-queue-head and by
  34.204 -		 * the kmap_lock.  As the kmap_lock is held here,
  34.205 -		 * no need for the wait-queue-head's lock.  Simply
  34.206 -		 * test if the queue is empty.
  34.207 -		 */
  34.208 -		need_wakeup = waitqueue_active(&pkmap_map_wait);
  34.209 -	}
  34.210 -	spin_unlock(&kmap_lock);
  34.211 -
  34.212 -	/* do wake-up, if needed, race-free outside of the spin lock */
  34.213 -	if (need_wakeup)
  34.214 -		wake_up(&pkmap_map_wait);
  34.215 -}
  34.216 -
  34.217 -EXPORT_SYMBOL(kunmap_high);
  34.218 -
  34.219 -#define POOL_SIZE	64
  34.220 -
  34.221 -static __init int init_emergency_pool(void)
  34.222 -{
  34.223 -	struct sysinfo i;
  34.224 -	si_meminfo(&i);
  34.225 -	si_swapinfo(&i);
  34.226 -        
  34.227 -	if (!i.totalhigh)
  34.228 -		return 0;
  34.229 -
  34.230 -	page_pool = mempool_create(POOL_SIZE, page_pool_alloc, page_pool_free, NULL);
  34.231 -	if (!page_pool)
  34.232 -		BUG();
  34.233 -	printk("highmem bounce pool size: %d pages\n", POOL_SIZE);
  34.234 -
  34.235 -	return 0;
  34.236 -}
  34.237 -
  34.238 -__initcall(init_emergency_pool);
  34.239 -
  34.240 -/*
  34.241 - * highmem version, map in to vec
  34.242 - */
  34.243 -static void bounce_copy_vec(struct bio_vec *to, unsigned char *vfrom)
  34.244 -{
  34.245 -	unsigned long flags;
  34.246 -	unsigned char *vto;
  34.247 -
  34.248 -	local_irq_save(flags);
  34.249 -	vto = kmap_atomic(to->bv_page, KM_BOUNCE_READ);
  34.250 -	memcpy(vto + to->bv_offset, vfrom, to->bv_len);
  34.251 -	kunmap_atomic(vto, KM_BOUNCE_READ);
  34.252 -	local_irq_restore(flags);
  34.253 -}
  34.254 -
  34.255 -#else /* CONFIG_HIGHMEM */
  34.256 -
  34.257 -#define bounce_copy_vec(to, vfrom)	\
  34.258 -	memcpy(page_address((to)->bv_page) + (to)->bv_offset, vfrom, (to)->bv_len)
  34.259 -
  34.260 -#endif
  34.261 -
  34.262 -#define ISA_POOL_SIZE	16
  34.263 -
  34.264 -/*
  34.265 - * gets called "every" time someone init's a queue with BLK_BOUNCE_ISA
  34.266 - * as the max address, so check if the pool has already been created.
  34.267 - */
  34.268 -int init_emergency_isa_pool(void)
  34.269 -{
  34.270 -	if (isa_page_pool)
  34.271 -		return 0;
  34.272 -
  34.273 -	isa_page_pool = mempool_create(ISA_POOL_SIZE, page_pool_alloc, page_pool_free, (void *) __GFP_DMA);
  34.274 -	if (!isa_page_pool)
  34.275 -		BUG();
  34.276 -
  34.277 -	printk("isa bounce pool size: %d pages\n", ISA_POOL_SIZE);
  34.278 -	return 0;
  34.279 -}
  34.280 -
  34.281 -/*
  34.282 - * Simple bounce buffer support for highmem pages. Depending on the
  34.283 - * queue gfp mask set, *to may or may not be a highmem page. kmap it
  34.284 - * always, it will do the Right Thing
  34.285 - */
  34.286 -static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
  34.287 -{
  34.288 -	unsigned char *vfrom;
  34.289 -	struct bio_vec *tovec, *fromvec;
  34.290 -	int i;
  34.291 -
  34.292 -	__bio_for_each_segment(tovec, to, i, 0) {
  34.293 -		fromvec = from->bi_io_vec + i;
  34.294 -
  34.295 -		/*
  34.296 -		 * not bounced
  34.297 -		 */
  34.298 -		if (tovec->bv_page == fromvec->bv_page)
  34.299 -			continue;
  34.300 -
  34.301 -		/*
  34.302 -		 * fromvec->bv_offset and fromvec->bv_len might have been
  34.303 -		 * modified by the block layer, so use the original copy,
  34.304 -		 * bounce_copy_vec already uses tovec->bv_len
  34.305 -		 */
  34.306 -		vfrom = page_address(fromvec->bv_page) + tovec->bv_offset;
  34.307 -
  34.308 -		flush_dcache_page(tovec->bv_page);
  34.309 -		bounce_copy_vec(tovec, vfrom);
  34.310 -	}
  34.311 -}
  34.312 -
  34.313 -static void bounce_end_io(struct bio *bio, mempool_t *pool, int err)
  34.314 -{
  34.315 -	struct bio *bio_orig = bio->bi_private;
  34.316 -	struct bio_vec *bvec, *org_vec;
  34.317 -	int i;
  34.318 -
  34.319 -	if (test_bit(BIO_EOPNOTSUPP, &bio->bi_flags))
  34.320 -		set_bit(BIO_EOPNOTSUPP, &bio_orig->bi_flags);
  34.321 -
  34.322 -	/*
  34.323 -	 * free up bounce indirect pages used
  34.324 -	 */
  34.325 -	__bio_for_each_segment(bvec, bio, i, 0) {
  34.326 -		org_vec = bio_orig->bi_io_vec + i;
  34.327 -		if (bvec->bv_page == org_vec->bv_page)
  34.328 -			continue;
  34.329 -
  34.330 -		mempool_free(bvec->bv_page, pool);	
  34.331 -	}
  34.332 -
  34.333 -	bio_endio(bio_orig, bio_orig->bi_size, err);
  34.334 -	bio_put(bio);
  34.335 -}
  34.336 -
  34.337 -static int bounce_end_io_write(struct bio *bio, unsigned int bytes_done,int err)
  34.338 -{
  34.339 -	if (bio->bi_size)
  34.340 -		return 1;
  34.341 -
  34.342 -	bounce_end_io(bio, page_pool, err);
  34.343 -	return 0;
  34.344 -}
  34.345 -
  34.346 -static int bounce_end_io_write_isa(struct bio *bio, unsigned int bytes_done, int err)
  34.347 -{
  34.348 -	if (bio->bi_size)
  34.349 -		return 1;
  34.350 -
  34.351 -	bounce_end_io(bio, isa_page_pool, err);
  34.352 -	return 0;
  34.353 -}
  34.354 -
  34.355 -static void __bounce_end_io_read(struct bio *bio, mempool_t *pool, int err)
  34.356 -{
  34.357 -	struct bio *bio_orig = bio->bi_private;
  34.358 -
  34.359 -	if (test_bit(BIO_UPTODATE, &bio->bi_flags))
  34.360 -		copy_to_high_bio_irq(bio_orig, bio);
  34.361 -
  34.362 -	bounce_end_io(bio, pool, err);
  34.363 -}
  34.364 -
  34.365 -static int bounce_end_io_read(struct bio *bio, unsigned int bytes_done, int err)
  34.366 -{
  34.367 -	if (bio->bi_size)
  34.368 -		return 1;
  34.369 -
  34.370 -	__bounce_end_io_read(bio, page_pool, err);
  34.371 -	return 0;
  34.372 -}
  34.373 -
  34.374 -static int bounce_end_io_read_isa(struct bio *bio, unsigned int bytes_done, int err)
  34.375 -{
  34.376 -	if (bio->bi_size)
  34.377 -		return 1;
  34.378 -
  34.379 -	__bounce_end_io_read(bio, isa_page_pool, err);
  34.380 -	return 0;
  34.381 -}
  34.382 -
  34.383 -static void __blk_queue_bounce(request_queue_t *q, struct bio **bio_orig,
  34.384 -			mempool_t *pool)
  34.385 -{
  34.386 -	struct page *page;
  34.387 -	struct bio *bio = NULL;
  34.388 -	int i, rw = bio_data_dir(*bio_orig);
  34.389 -	struct bio_vec *to, *from;
  34.390 -
  34.391 -	bio_for_each_segment(from, *bio_orig, i) {
  34.392 -		page = from->bv_page;
  34.393 -
  34.394 -		/*
  34.395 -		 * is destination page below bounce pfn?
  34.396 -		 */
  34.397 -		if (page_to_pfn(page) < q->bounce_pfn)
  34.398 -			continue;
  34.399 -
  34.400 -		/*
  34.401 -		 * irk, bounce it
  34.402 -		 */
  34.403 -		if (!bio)
  34.404 -			bio = bio_alloc(GFP_NOIO, (*bio_orig)->bi_vcnt);
  34.405 -
  34.406 -		to = bio->bi_io_vec + i;
  34.407 -
  34.408 -		to->bv_page = mempool_alloc(pool, q->bounce_gfp);
  34.409 -		to->bv_len = from->bv_len;
  34.410 -		to->bv_offset = from->bv_offset;
  34.411 -
  34.412 -		if (rw == WRITE) {
  34.413 -			char *vto, *vfrom;
  34.414 -
  34.415 -			flush_dcache_page(from->bv_page);
  34.416 -			vto = page_address(to->bv_page) + to->bv_offset;
  34.417 -			vfrom = kmap(from->bv_page) + from->bv_offset;
  34.418 -			memcpy(vto, vfrom, to->bv_len);
  34.419 -			kunmap(from->bv_page);
  34.420 -		}
  34.421 -	}
  34.422 -
  34.423 -	/*
  34.424 -	 * no pages bounced
  34.425 -	 */
  34.426 -	if (!bio)
  34.427 -		return;
  34.428 -
  34.429 -	/*
  34.430 -	 * at least one page was bounced, fill in possible non-highmem
  34.431 -	 * pages
  34.432 -	 */
  34.433 -	bio_for_each_segment(from, *bio_orig, i) {
  34.434 -		to = bio_iovec_idx(bio, i);
  34.435 -		if (!to->bv_page) {
  34.436 -			to->bv_page = from->bv_page;
  34.437 -			to->bv_len = from->bv_len;
  34.438 -			to->bv_offset = from->bv_offset;
  34.439 -		}
  34.440 -	}
  34.441 -
  34.442 -	bio->bi_bdev = (*bio_orig)->bi_bdev;
  34.443 -	bio->bi_flags |= (1 << BIO_BOUNCED);
  34.444 -	bio->bi_sector = (*bio_orig)->bi_sector;
  34.445 -	bio->bi_rw = (*bio_orig)->bi_rw;
  34.446 -
  34.447 -	bio->bi_vcnt = (*bio_orig)->bi_vcnt;
  34.448 -	bio->bi_idx = (*bio_orig)->bi_idx;
  34.449 -	bio->bi_size = (*bio_orig)->bi_size;
  34.450 -
  34.451 -	if (pool == page_pool) {
  34.452 -		bio->bi_end_io = bounce_end_io_write;
  34.453 -		if (rw == READ)
  34.454 -			bio->bi_end_io = bounce_end_io_read;
  34.455 -	} else {
  34.456 -		bio->bi_end_io = bounce_end_io_write_isa;
  34.457 -		if (rw == READ)
  34.458 -			bio->bi_end_io = bounce_end_io_read_isa;
  34.459 -	}
  34.460 -
  34.461 -	bio->bi_private = *bio_orig;
  34.462 -	*bio_orig = bio;
  34.463 -}
  34.464 -
  34.465 -void blk_queue_bounce(request_queue_t *q, struct bio **bio_orig)
  34.466 -{
  34.467 -	mempool_t *pool;
  34.468 -
  34.469 -	/*
  34.470 -	 * for non-isa bounce case, just check if the bounce pfn is equal
  34.471 -	 * to or bigger than the highest pfn in the system -- in that case,
  34.472 -	 * don't waste time iterating over bio segments
  34.473 -	 */
  34.474 -	if (!(q->bounce_gfp & GFP_DMA)) {
  34.475 -		if (q->bounce_pfn >= blk_max_pfn)
  34.476 -			return;
  34.477 -		pool = page_pool;
  34.478 -	} else {
  34.479 -		BUG_ON(!isa_page_pool);
  34.480 -		pool = isa_page_pool;
  34.481 -	}
  34.482 -
  34.483 -	/*
  34.484 -	 * slow path
  34.485 -	 */
  34.486 -	__blk_queue_bounce(q, bio_orig, pool);
  34.487 -}
  34.488 -
  34.489 -EXPORT_SYMBOL(blk_queue_bounce);
  34.490 -
  34.491 -#if defined(HASHED_PAGE_VIRTUAL)
  34.492 -
  34.493 -#define PA_HASH_ORDER	7
  34.494 -
  34.495 -/*
  34.496 - * Describes one page->virtual association
  34.497 - */
  34.498 -struct page_address_map {
  34.499 -	struct page *page;
  34.500 -	void *virtual;
  34.501 -	struct list_head list;
  34.502 -};
  34.503 -
  34.504 -/*
  34.505 - * page_address_map freelist, allocated from page_address_maps.
  34.506 - */
  34.507 -static struct list_head page_address_pool;	/* freelist */
  34.508 -static spinlock_t pool_lock;			/* protects page_address_pool */
  34.509 -
  34.510 -/*
  34.511 - * Hash table bucket
  34.512 - */
  34.513 -static struct page_address_slot {
  34.514 -	struct list_head lh;			/* List of page_address_maps */
  34.515 -	spinlock_t lock;			/* Protect this bucket's list */
  34.516 -} ____cacheline_aligned_in_smp page_address_htable[1<<PA_HASH_ORDER];
  34.517 -
  34.518 -static struct page_address_slot *page_slot(struct page *page)
  34.519 -{
  34.520 -	return &page_address_htable[hash_ptr(page, PA_HASH_ORDER)];
  34.521 -}
  34.522 -
  34.523 -void *page_address(struct page *page)
  34.524 -{
  34.525 -	unsigned long flags;
  34.526 -	void *ret;
  34.527 -	struct page_address_slot *pas;
  34.528 -
  34.529 -	if (!PageHighMem(page))
  34.530 -		return lowmem_page_address(page);
  34.531 -
  34.532 -	pas = page_slot(page);
  34.533 -	ret = NULL;
  34.534 -	spin_lock_irqsave(&pas->lock, flags);
  34.535 -	if (!list_empty(&pas->lh)) {
  34.536 -		struct page_address_map *pam;
  34.537 -
  34.538 -		list_for_each_entry(pam, &pas->lh, list) {
  34.539 -			if (pam->page == page) {
  34.540 -				ret = pam->virtual;
  34.541 -				goto done;
  34.542 -			}
  34.543 -		}
  34.544 -	}
  34.545 -done:
  34.546 -	spin_unlock_irqrestore(&pas->lock, flags);
  34.547 -	return ret;
  34.548 -}
  34.549 -
  34.550 -EXPORT_SYMBOL(page_address);
  34.551 -
  34.552 -void set_page_address(struct page *page, void *virtual)
  34.553 -{
  34.554 -	unsigned long flags;
  34.555 -	struct page_address_slot *pas;
  34.556 -	struct page_address_map *pam;
  34.557 -
  34.558 -	BUG_ON(!PageHighMem(page));
  34.559 -
  34.560 -	pas = page_slot(page);
  34.561 -	if (virtual) {		/* Add */
  34.562 -		BUG_ON(list_empty(&page_address_pool));
  34.563 -
  34.564 -		spin_lock_irqsave(&pool_lock, flags);
  34.565 -		pam = list_entry(page_address_pool.next,
  34.566 -				struct page_address_map, list);
  34.567 -		list_del(&pam->list);
  34.568 -		spin_unlock_irqrestore(&pool_lock, flags);
  34.569 -
  34.570 -		pam->page = page;
  34.571 -		pam->virtual = virtual;
  34.572 -
  34.573 -		spin_lock_irqsave(&pas->lock, flags);
  34.574 -		list_add_tail(&pam->list, &pas->lh);
  34.575 -		spin_unlock_irqrestore(&pas->lock, flags);
  34.576 -	} else {		/* Remove */
  34.577 -		spin_lock_irqsave(&pas->lock, flags);
  34.578 -		list_for_each_entry(pam, &pas->lh, list) {
  34.579 -			if (pam->page == page) {
  34.580 -				list_del(&pam->list);
  34.581 -				spin_unlock_irqrestore(&pas->lock, flags);
  34.582 -				spin_lock_irqsave(&pool_lock, flags);
  34.583 -				list_add_tail(&pam->list, &page_address_pool);
  34.584 -				spin_unlock_irqrestore(&pool_lock, flags);
  34.585 -				goto done;
  34.586 -			}
  34.587 -		}
  34.588 -		spin_unlock_irqrestore(&pas->lock, flags);
  34.589 -	}
  34.590 -done:
  34.591 -	return;
  34.592 -}
  34.593 -
  34.594 -static struct page_address_map page_address_maps[LAST_PKMAP];
  34.595 -
  34.596 -void __init page_address_init(void)
  34.597 -{
  34.598 -	int i;
  34.599 -
  34.600 -	INIT_LIST_HEAD(&page_address_pool);
  34.601 -	for (i = 0; i < ARRAY_SIZE(page_address_maps); i++)
  34.602 -		list_add(&page_address_maps[i].list, &page_address_pool);
  34.603 -	for (i = 0; i < ARRAY_SIZE(page_address_htable); i++) {
  34.604 -		INIT_LIST_HEAD(&page_address_htable[i].lh);
  34.605 -		spin_lock_init(&page_address_htable[i].lock);
  34.606 -	}
  34.607 -	spin_lock_init(&pool_lock);
  34.608 -}
  34.609 -
  34.610 -#endif	/* defined(CONFIG_HIGHMEM) && !defined(WANT_PAGE_VIRTUAL) */
    35.1 --- a/linux-2.6.10-xen-sparse/mm/memory.c	Thu Mar 24 16:48:36 2005 +0000
    35.2 +++ b/linux-2.6.10-xen-sparse/mm/memory.c	Thu Mar 24 20:20:12 2005 +0000
    35.3 @@ -152,10 +152,6 @@ void clear_page_tables(struct mmu_gather
    35.4  		free_one_pgd(tlb, page_dir);
    35.5  		page_dir++;
    35.6  	} while (--nr);
    35.7 -#ifdef CONFIG_XEN_BATCH_MODE2
    35.8 -    XEN_flush_page_update_queue();
    35.9 -#endif
   35.10 -
   35.11  }
   35.12  
   35.13  pte_t fastcall * pte_alloc_map(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
   35.14 @@ -222,11 +218,6 @@ out:
   35.15   * dst->page_table_lock is held on entry and exit,
   35.16   * but may be dropped within pmd_alloc() and pte_alloc_map().
   35.17   */
   35.18 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.19 -#undef set_pte
   35.20 -#define set_pte(pteptr, pteval)\
   35.21 -    set_pte_batched(pteptr, pteval);
   35.22 -#endif
   35.23  int copy_page_range(struct mm_struct *dst, struct mm_struct *src,
   35.24  			struct vm_area_struct *vma)
   35.25  {
   35.26 @@ -330,15 +321,8 @@ skip_copy_pte_range:
   35.27  				 * in the parent and the child
   35.28  				 */
   35.29  				if (cow) {
   35.30 -#ifdef CONFIG_XEN_BATCH_MODE2
   35.31 -/* XEN modification: modified ordering here to avoid RaW hazard. */
   35.32 -                    pte = *src_pte;
   35.33 -					pte = pte_wrprotect(pte);
   35.34 -					ptep_set_wrprotect(src_pte);
   35.35 -#else
   35.36  					ptep_set_wrprotect(src_pte);
   35.37  					pte = *src_pte;
   35.38 -#endif
   35.39  				}
   35.40  
   35.41  				/*
   35.42 @@ -370,11 +354,8 @@ cont_copy_pte_range_noset:
   35.43  			cond_resched_lock(&dst->page_table_lock);
   35.44  cont_copy_pmd_range:
   35.45  			src_pmd++;
   35.46 -			dst_pmd++;            
   35.47 +			dst_pmd++;
   35.48  		} while ((unsigned long)src_pmd & PMD_TABLE_MASK);
   35.49 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.50 -        _flush_page_update_queue();
   35.51 -#endif
   35.52  	}
   35.53  out_unlock:
   35.54  	spin_unlock(&src->page_table_lock);
   35.55 @@ -464,19 +445,9 @@ static void zap_pte_range(struct mmu_gat
   35.56  			free_swap_and_cache(pte_to_swp_entry(pte));
   35.57  		pte_clear(ptep);
   35.58  	}
   35.59 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.60 -    _flush_page_update_queue();
   35.61 -#endif
   35.62  	pte_unmap(ptep-1);
   35.63  }
   35.64  
   35.65 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.66 -#undef set_pte
   35.67 -#define set_pte(pteptr, pteval)\
   35.68 -    set_pte_batched(pteptr, pteval);\
   35.69 -    _flush_page_update_queue()
   35.70 -#endif
   35.71 -
   35.72  static void zap_pmd_range(struct mmu_gather *tlb,
   35.73  		pgd_t * dir, unsigned long address,
   35.74  		unsigned long size, struct zap_details *details)
   35.75 @@ -868,11 +839,6 @@ out:
   35.76  
   35.77  EXPORT_SYMBOL(get_user_pages);
   35.78  
   35.79 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.80 -#undef set_pte
   35.81 -#define set_pte(pteptr, pteval)\
   35.82 -    set_pte_batched(pteptr, pteval);
   35.83 -#endif
   35.84  static void zeromap_pte_range(pte_t * pte, unsigned long address,
   35.85                                       unsigned long size, pgprot_t prot)
   35.86  {
   35.87 @@ -889,18 +855,7 @@ static void zeromap_pte_range(pte_t * pt
   35.88  		address += PAGE_SIZE;
   35.89  		pte++;
   35.90  	} while (address && (address < end));
   35.91 -
   35.92 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.93 -    _flush_page_update_queue();
   35.94 -#endif
   35.95 -
   35.96  }
   35.97 -#ifdef CONFIG_XEN_BATCH_MODE1
   35.98 -#undef set_pte
   35.99 -#define set_pte(pteptr, pteval)\
  35.100 -    set_pte_batched(pteptr, pteval);\
  35.101 -    _flush_page_update_queue()
  35.102 -#endif
  35.103  
  35.104  static inline int zeromap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address,
  35.105                                      unsigned long size, pgprot_t prot)
  35.106 @@ -962,11 +917,6 @@ int zeromap_page_range(struct vm_area_st
  35.107   * mappings are removed. any references to nonexistent pages results
  35.108   * in null mappings (currently treated as "copy-on-access")
  35.109   */
  35.110 -#ifdef CONFIG_XEN_BATCH_MODE1
  35.111 -#undef set_pte
  35.112 -#define set_pte(pteptr, pteval)\
  35.113 -    set_pte_batched(pteptr, pteval);
  35.114 -#endif
  35.115  static inline void remap_pte_range(pte_t * pte, unsigned long address, unsigned long size,
  35.116  	unsigned long pfn, pgprot_t prot)
  35.117  {
  35.118 @@ -984,16 +934,7 @@ static inline void remap_pte_range(pte_t
  35.119  		pfn++;
  35.120  		pte++;
  35.121  	} while (address && (address < end));
  35.122 -#ifdef CONFIG_XEN_BATCH_MODE1
  35.123 -    _flush_page_update_queue();
  35.124 -#endif
  35.125  }
  35.126 -#ifdef CONFIG_XEN_BATCH_MODE1
  35.127 -#undef set_pte
  35.128 -#define set_pte(pteptr, pteval)\
  35.129 -    set_pte_batched(pteptr, pteval);\
  35.130 -    _flush_page_update_queue()
  35.131 -#endif
  35.132  
  35.133  static inline int remap_pmd_range(struct mm_struct *mm, pmd_t * pmd, unsigned long address, unsigned long size,
  35.134  	unsigned long pfn, pgprot_t prot)
  35.135 @@ -1462,20 +1403,7 @@ static int do_swap_page(struct mm_struct
  35.136  	unlock_page(page);
  35.137  
  35.138  	flush_icache_page(vma, page);
  35.139 -
  35.140 -#ifdef CONFIG_XEN_BATCH_MODE2
  35.141 -	if ( likely(vma->vm_mm == current->mm) ) {
  35.142 -		XEN_flush_page_update_queue();
  35.143 -		HYPERVISOR_update_va_mapping(address, pte, 0);
  35.144 -	} else {
  35.145 -		set_pte(page_table, pte);
  35.146 -		XEN_flush_page_update_queue();        
  35.147 -	}
  35.148 -#else
  35.149  	set_pte(page_table, pte);
  35.150 -#endif
  35.151 -
  35.152 -
  35.153  	page_add_anon_rmap(page, vma, address);
  35.154  
  35.155  	if (write_access) {
  35.156 @@ -1540,17 +1468,7 @@ do_anonymous_page(struct mm_struct *mm, 
  35.157  		page_add_anon_rmap(page, vma, addr);
  35.158  	}
  35.159  
  35.160 -#ifdef CONFIG_XEN_BATCH_MODE2
  35.161 -	if ( likely(vma->vm_mm == current->mm) ) {
  35.162 -		XEN_flush_page_update_queue();
  35.163 -		HYPERVISOR_update_va_mapping(addr, entry, 0);
  35.164 -	} else {
  35.165 -		set_pte(page_table, entry);
  35.166 -		XEN_flush_page_update_queue();
  35.167 -	}
  35.168 -#else
  35.169  	ptep_establish_new(vma, addr, page_table, entry);
  35.170 -#endif
  35.171  	pte_unmap(page_table);
  35.172  
  35.173  	/* No need to invalidate - it was non-present before */
  35.174 @@ -1655,17 +1573,7 @@ retry:
  35.175  		entry = mk_pte(new_page, vma->vm_page_prot);
  35.176  		if (write_access)
  35.177  			entry = maybe_mkwrite(pte_mkdirty(entry), vma);
  35.178 -#ifdef CONFIG_XEN_BATCH_MODE2
  35.179 -		if ( likely(vma->vm_mm == current->mm) ) {
  35.180 -			XEN_flush_page_update_queue();
  35.181 -			HYPERVISOR_update_va_mapping(address, entry, 0);
  35.182 -		} else {
  35.183 -			set_pte(page_table, entry);
  35.184 -			XEN_flush_page_update_queue();
  35.185 -		}
  35.186 -#else
  35.187  		ptep_establish_new(vma, address, page_table, entry);
  35.188 -#endif
  35.189  		if (anon) {
  35.190  			lru_cache_add_active(new_page);
  35.191  			page_add_anon_rmap(new_page, vma, address);
    36.1 --- a/linux-2.6.10-xen-sparse/mm/swapfile.c	Thu Mar 24 16:48:36 2005 +0000
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,1711 +0,0 @@
    36.4 -/*
    36.5 - *  linux/mm/swapfile.c
    36.6 - *
    36.7 - *  Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
    36.8 - *  Swap reorganised 29.12.95, Stephen Tweedie
    36.9 - */
   36.10 -
   36.11 -#include <linux/config.h>
   36.12 -#include <linux/mm.h>
   36.13 -#include <linux/hugetlb.h>
   36.14 -#include <linux/mman.h>
   36.15 -#include <linux/slab.h>
   36.16 -#include <linux/kernel_stat.h>
   36.17 -#include <linux/swap.h>
   36.18 -#include <linux/vmalloc.h>
   36.19 -#include <linux/pagemap.h>
   36.20 -#include <linux/namei.h>
   36.21 -#include <linux/shm.h>
   36.22 -#include <linux/blkdev.h>
   36.23 -#include <linux/writeback.h>
   36.24 -#include <linux/proc_fs.h>
   36.25 -#include <linux/seq_file.h>
   36.26 -#include <linux/init.h>
   36.27 -#include <linux/module.h>
   36.28 -#include <linux/rmap.h>
   36.29 -#include <linux/security.h>
   36.30 -#include <linux/backing-dev.h>
   36.31 -#include <linux/syscalls.h>
   36.32 -
   36.33 -#include <asm/pgtable.h>
   36.34 -#include <asm/tlbflush.h>
   36.35 -#include <linux/swapops.h>
   36.36 -
   36.37 -spinlock_t swaplock = SPIN_LOCK_UNLOCKED;
   36.38 -unsigned int nr_swapfiles;
   36.39 -long total_swap_pages;
   36.40 -static int swap_overflow;
   36.41 -
   36.42 -EXPORT_SYMBOL(total_swap_pages);
   36.43 -
   36.44 -static const char Bad_file[] = "Bad swap file entry ";
   36.45 -static const char Unused_file[] = "Unused swap file entry ";
   36.46 -static const char Bad_offset[] = "Bad swap offset entry ";
   36.47 -static const char Unused_offset[] = "Unused swap offset entry ";
   36.48 -
   36.49 -struct swap_list_t swap_list = {-1, -1};
   36.50 -
   36.51 -struct swap_info_struct swap_info[MAX_SWAPFILES];
   36.52 -
   36.53 -static DECLARE_MUTEX(swapon_sem);
   36.54 -
   36.55 -/*
   36.56 - * We need this because the bdev->unplug_fn can sleep and we cannot
   36.57 - * hold swap_list_lock while calling the unplug_fn. And swap_list_lock
   36.58 - * cannot be turned into a semaphore.
   36.59 - */
   36.60 -static DECLARE_RWSEM(swap_unplug_sem);
   36.61 -
   36.62 -#define SWAPFILE_CLUSTER 256
   36.63 -
   36.64 -void swap_unplug_io_fn(struct backing_dev_info *unused_bdi, struct page *page)
   36.65 -{
   36.66 -	swp_entry_t entry;
   36.67 -
   36.68 -	down_read(&swap_unplug_sem);
   36.69 -	entry.val = page->private;
   36.70 -	if (PageSwapCache(page)) {
   36.71 -		struct block_device *bdev = swap_info[swp_type(entry)].bdev;
   36.72 -		struct backing_dev_info *bdi;
   36.73 -
   36.74 -		/*
   36.75 -		 * If the page is removed from swapcache from under us (with a
   36.76 -		 * racy try_to_unuse/swapoff) we need an additional reference
   36.77 -		 * count to avoid reading garbage from page->private above. If
   36.78 -		 * the WARN_ON triggers during a swapoff it maybe the race
   36.79 -		 * condition and it's harmless. However if it triggers without
   36.80 -		 * swapoff it signals a problem.
   36.81 -		 */
   36.82 -		WARN_ON(page_count(page) <= 1);
   36.83 -
   36.84 -		bdi = bdev->bd_inode->i_mapping->backing_dev_info;
   36.85 -		bdi->unplug_io_fn(bdi, page);
   36.86 -	}
   36.87 -	up_read(&swap_unplug_sem);
   36.88 -}
   36.89 -
   36.90 -static inline int scan_swap_map(struct swap_info_struct *si)
   36.91 -{
   36.92 -	unsigned long offset;
   36.93 -	/* 
   36.94 -	 * We try to cluster swap pages by allocating them
   36.95 -	 * sequentially in swap.  Once we've allocated
   36.96 -	 * SWAPFILE_CLUSTER pages this way, however, we resort to
   36.97 -	 * first-free allocation, starting a new cluster.  This
   36.98 -	 * prevents us from scattering swap pages all over the entire
   36.99 -	 * swap partition, so that we reduce overall disk seek times
  36.100 -	 * between swap pages.  -- sct */
  36.101 -	if (si->cluster_nr) {
  36.102 -		while (si->cluster_next <= si->highest_bit) {
  36.103 -			offset = si->cluster_next++;
  36.104 -			if (si->swap_map[offset])
  36.105 -				continue;
  36.106 -			si->cluster_nr--;
  36.107 -			goto got_page;
  36.108 -		}
  36.109 -	}
  36.110 -	si->cluster_nr = SWAPFILE_CLUSTER;
  36.111 -
  36.112 -	/* try to find an empty (even not aligned) cluster. */
  36.113 -	offset = si->lowest_bit;
  36.114 - check_next_cluster:
  36.115 -	if (offset+SWAPFILE_CLUSTER-1 <= si->highest_bit)
  36.116 -	{
  36.117 -		unsigned long nr;
  36.118 -		for (nr = offset; nr < offset+SWAPFILE_CLUSTER; nr++)
  36.119 -			if (si->swap_map[nr])
  36.120 -			{
  36.121 -				offset = nr+1;
  36.122 -				goto check_next_cluster;
  36.123 -			}
  36.124 -		/* We found a completly empty cluster, so start
  36.125 -		 * using it.
  36.126 -		 */
  36.127 -		goto got_page;
  36.128 -	}
  36.129 -	/* No luck, so now go finegrined as usual. -Andrea */
  36.130 -	for (offset = si->lowest_bit; offset <= si->highest_bit ; offset++) {
  36.131 -		if (si->swap_map[offset])
  36.132 -			continue;
  36.133 -		si->lowest_bit = offset+1;
  36.134 -	got_page:
  36.135 -		if (offset == si->lowest_bit)
  36.136 -			si->lowest_bit++;
  36.137 -		if (offset == si->highest_bit)
  36.138 -			si->highest_bit--;
  36.139 -		if (si->lowest_bit > si->highest_bit) {
  36.140 -			si->lowest_bit = si->max;
  36.141 -			si->highest_bit = 0;
  36.142 -		}
  36.143 -		si->swap_map[offset] = 1;
  36.144 -		si->inuse_pages++;
  36.145 -		nr_swap_pages--;
  36.146 -		si->cluster_next = offset+1;
  36.147 -		return offset;
  36.148 -	}
  36.149 -	si->lowest_bit = si->max;
  36.150 -	si->highest_bit = 0;
  36.151 -	return 0;
  36.152 -}
  36.153 -
  36.154 -swp_entry_t get_swap_page(void)
  36.155 -{
  36.156 -	struct swap_info_struct * p;
  36.157 -	unsigned long offset;
  36.158 -	swp_entry_t entry;
  36.159 -	int type, wrapped = 0;
  36.160 -
  36.161 -	entry.val = 0;	/* Out of memory */
  36.162 -	swap_list_lock();
  36.163 -	type = swap_list.next;
  36.164 -	if (type < 0)
  36.165 -		goto out;
  36.166 -	if (nr_swap_pages <= 0)
  36.167 -		goto out;
  36.168 -
  36.169 -	while (1) {
  36.170 -		p = &swap_info[type];
  36.171 -		if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
  36.172 -			swap_device_lock(p);
  36.173 -			offset = scan_swap_map(p);
  36.174 -			swap_device_unlock(p);
  36.175 -			if (offset) {
  36.176 -				entry = swp_entry(type,offset);
  36.177 -				type = swap_info[type].next;
  36.178 -				if (type < 0 ||
  36.179 -					p->prio != swap_info[type].prio) {
  36.180 -						swap_list.next = swap_list.head;
  36.181 -				} else {
  36.182 -					swap_list.next = type;
  36.183 -				}
  36.184 -				goto out;
  36.185 -			}
  36.186 -		}
  36.187 -		type = p->next;
  36.188 -		if (!wrapped) {
  36.189 -			if (type < 0 || p->prio != swap_info[type].prio) {
  36.190 -				type = swap_list.head;
  36.191 -				wrapped = 1;
  36.192 -			}
  36.193 -		} else
  36.194 -			if (type < 0)
  36.195 -				goto out;	/* out of swap space */
  36.196 -	}
  36.197 -out:
  36.198 -	swap_list_unlock();
  36.199 -	return entry;
  36.200 -}
  36.201 -
  36.202 -static struct swap_info_struct * swap_info_get(swp_entry_t entry)
  36.203 -{
  36.204 -	struct swap_info_struct * p;
  36.205 -	unsigned long offset, type;
  36.206 -
  36.207 -	if (!entry.val)
  36.208 -		goto out;
  36.209 -	type = swp_type(entry);
  36.210 -	if (type >= nr_swapfiles)
  36.211 -		goto bad_nofile;
  36.212 -	p = & swap_info[type];
  36.213 -	if (!(p->flags & SWP_USED))
  36.214 -		goto bad_device;
  36.215 -	offset = swp_offset(entry);
  36.216 -	if (offset >= p->max)
  36.217 -		goto bad_offset;
  36.218 -	if (!p->swap_map[offset])
  36.219 -		goto bad_free;
  36.220 -	swap_list_lock();
  36.221 -	if (p->prio > swap_info[swap_list.next].prio)
  36.222 -		swap_list.next = type;
  36.223 -	swap_device_lock(p);
  36.224 -	return p;
  36.225 -
  36.226 -bad_free:
  36.227 -	printk(KERN_ERR "swap_free: %s%08lx\n", Unused_offset, entry.val);
  36.228 -	goto out;
  36.229 -bad_offset:
  36.230 -	printk(KERN_ERR "swap_free: %s%08lx\n", Bad_offset, entry.val);
  36.231 -	goto out;
  36.232 -bad_device:
  36.233 -	printk(KERN_ERR "swap_free: %s%08lx\n", Unused_file, entry.val);
  36.234 -	goto out;
  36.235 -bad_nofile:
  36.236 -	printk(KERN_ERR "swap_free: %s%08lx\n", Bad_file, entry.val);
  36.237 -out:
  36.238 -	return NULL;
  36.239 -}	
  36.240 -
  36.241 -static void swap_info_put(struct swap_info_struct * p)
  36.242 -{
  36.243 -	swap_device_unlock(p);
  36.244 -	swap_list_unlock();
  36.245 -}
  36.246 -
  36.247 -static int swap_entry_free(struct swap_info_struct *p, unsigned long offset)
  36.248 -{
  36.249 -	int count = p->swap_map[offset];
  36.250 -
  36.251 -	if (count < SWAP_MAP_MAX) {
  36.252 -		count--;
  36.253 -		p->swap_map[offset] = count;
  36.254 -		if (!count) {
  36.255 -			if (offset < p->lowest_bit)
  36.256 -				p->lowest_bit = offset;
  36.257 -			if (offset > p->highest_bit)
  36.258 -				p->highest_bit = offset;
  36.259 -			nr_swap_pages++;
  36.260 -			p->inuse_pages--;
  36.261 -		}
  36.262 -	}
  36.263 -	return count;
  36.264 -}
  36.265 -
  36.266 -/*
  36.267 - * Caller has made sure that the swapdevice corresponding to entry
  36.268 - * is still around or has not been recycled.
  36.269 - */
  36.270 -void swap_free(swp_entry_t entry)
  36.271 -{
  36.272 -	struct swap_info_struct * p;
  36.273 -
  36.274 -	p = swap_info_get(entry);
  36.275 -	if (p) {
  36.276 -		swap_entry_free(p, swp_offset(entry));
  36.277 -		swap_info_put(p);
  36.278 -	}
  36.279 -}
  36.280 -
  36.281 -/*
  36.282 - * Check if we're the only user of a swap page,
  36.283 - * when the page is locked.
  36.284 - */
  36.285 -static int exclusive_swap_page(struct page *page)
  36.286 -{
  36.287 -	int retval = 0;
  36.288 -	struct swap_info_struct * p;
  36.289 -	swp_entry_t entry;
  36.290 -
  36.291 -	entry.val = page->private;
  36.292 -	p = swap_info_get(entry);
  36.293 -	if (p) {
  36.294 -		/* Is the only swap cache user the cache itself? */
  36.295 -		if (p->swap_map[swp_offset(entry)] == 1) {
  36.296 -			/* Recheck the page count with the swapcache lock held.. */
  36.297 -			spin_lock_irq(&swapper_space.tree_lock);
  36.298 -			if (page_count(page) == 2)
  36.299 -				retval = 1;
  36.300 -			spin_unlock_irq(&swapper_space.tree_lock);
  36.301 -		}
  36.302 -		swap_info_put(p);
  36.303 -	}
  36.304 -	return retval;
  36.305 -}
  36.306 -
  36.307 -/*
  36.308 - * We can use this swap cache entry directly
  36.309 - * if there are no other references to it.
  36.310 - *
  36.311 - * Here "exclusive_swap_page()" does the real
  36.312 - * work, but we opportunistically check whether
  36.313 - * we need to get all the locks first..
  36.314 - */
  36.315 -int can_share_swap_page(struct page *page)
  36.316 -{
  36.317 -	int retval = 0;
  36.318 -
  36.319 -	if (!PageLocked(page))
  36.320 -		BUG();
  36.321 -	switch (page_count(page)) {
  36.322 -	case 3:
  36.323 -		if (!PagePrivate(page))
  36.324 -			break;
  36.325 -		/* Fallthrough */
  36.326 -	case 2:
  36.327 -		if (!PageSwapCache(page))
  36.328 -			break;
  36.329 -		retval = exclusive_swap_page(page);
  36.330 -		break;
  36.331 -	case 1:
  36.332 -		if (PageReserved(page))
  36.333 -			break;
  36.334 -		retval = 1;
  36.335 -	}
  36.336 -	return retval;
  36.337 -}
  36.338 -
  36.339 -/*
  36.340 - * Work out if there are any other processes sharing this
  36.341 - * swap cache page. Free it if you can. Return success.
  36.342 - */
  36.343 -int remove_exclusive_swap_page(struct page *page)
  36.344 -{
  36.345 -	int retval;
  36.346 -	struct swap_info_struct * p;
  36.347 -	swp_entry_t entry;
  36.348 -
  36.349 -	BUG_ON(PagePrivate(page));
  36.350 -	BUG_ON(!PageLocked(page));
  36.351 -
  36.352 -	if (!PageSwapCache(page))
  36.353 -		return 0;
  36.354 -	if (PageWriteback(page))
  36.355 -		return 0;
  36.356 -	if (page_count(page) != 2) /* 2: us + cache */
  36.357 -		return 0;
  36.358 -
  36.359 -	entry.val = page->private;
  36.360 -	p = swap_info_get(entry);
  36.361 -	if (!p)
  36.362 -		return 0;
  36.363 -
  36.364 -	/* Is the only swap cache user the cache itself? */
  36.365 -	retval = 0;
  36.366 -	if (p->swap_map[swp_offset(entry)] == 1) {
  36.367 -		/* Recheck the page count with the swapcache lock held.. */
  36.368 -		spin_lock_irq(&swapper_space.tree_lock);
  36.369 -		if ((page_count(page) == 2) && !PageWriteback(page)) {
  36.370 -			__delete_from_swap_cache(page);
  36.371 -			SetPageDirty(page);
  36.372 -			retval = 1;
  36.373 -		}
  36.374 -		spin_unlock_irq(&swapper_space.tree_lock);
  36.375 -	}
  36.376 -	swap_info_put(p);
  36.377 -
  36.378 -	if (retval) {
  36.379 -		swap_free(entry);
  36.380 -		page_cache_release(page);
  36.381 -	}
  36.382 -
  36.383 -	return retval;
  36.384 -}
  36.385 -
  36.386 -/*
  36.387 - * Free the swap entry like above, but also try to
  36.388 - * free the page cache entry if it is the last user.
  36.389 - */
  36.390 -void free_swap_and_cache(swp_entry_t entry)
  36.391 -{
  36.392 -	struct swap_info_struct * p;
  36.393 -	struct page *page = NULL;
  36.394 -
  36.395 -	p = swap_info_get(entry);
  36.396 -	if (p) {
  36.397 -		if (swap_entry_free(p, swp_offset(entry)) == 1) {
  36.398 -			spin_lock_irq(&swapper_space.tree_lock);
  36.399 -			page = radix_tree_lookup(&swapper_space.page_tree,
  36.400 -				entry.val);
  36.401 -			if (page && TestSetPageLocked(page))
  36.402 -				page = NULL;
  36.403 -			spin_unlock_irq(&swapper_space.tree_lock);
  36.404 -		}
  36.405 -		swap_info_put(p);
  36.406 -	}
  36.407 -	if (page) {
  36.408 -		int one_user;
  36.409 -
  36.410 -		BUG_ON(PagePrivate(page));
  36.411 -		page_cache_get(page);
  36.412 -		one_user = (page_count(page) == 2);
  36.413 -		/* Only cache user (+us), or swap space full? Free it! */
  36.414 -		if (!PageWriteback(page) && (one_user || vm_swap_full())) {
  36.415 -			delete_from_swap_cache(page);
  36.416 -			SetPageDirty(page);
  36.417 -		}
  36.418 -		unlock_page(page);
  36.419 -		page_cache_release(page);
  36.420 -	}
  36.421 -}
  36.422 -
  36.423 -/*
  36.424 - * The swap entry has been read in advance, and we return 1 to indicate
  36.425 - * that the page has been used or is no longer needed.
  36.426 - *
  36.427 - * Always set the resulting pte to be nowrite (the same as COW pages
  36.428 - * after one process has exited).  We don't know just how many PTEs will
  36.429 - * share this swap entry, so be cautious and let do_wp_page work out
  36.430 - * what to do if a write is requested later.
  36.431 - */
  36.432 -/* vma->vm_mm->page_table_lock is held */
  36.433 -static void
  36.434 -unuse_pte(struct vm_area_struct *vma, unsigned long address, pte_t *dir,
  36.435 -	swp_entry_t entry, struct page *page)
  36.436 -{
  36.437 -	vma->vm_mm->rss++;
  36.438 -	get_page(page);
  36.439 -	set_pte(dir, pte_mkold(mk_pte(page, vma->vm_page_prot)));
  36.440 -	page_add_anon_rmap(page, vma, address);
  36.441 -	swap_free(entry);
  36.442 -}
  36.443 -
  36.444 -/* vma->vm_mm->page_table_lock is held */
  36.445 -static unsigned long unuse_pmd(struct vm_area_struct * vma, pmd_t *dir,
  36.446 -	unsigned long address, unsigned long size, unsigned long offset,
  36.447 -	swp_entry_t entry, struct page *page)
  36.448 -{
  36.449 -	pte_t * pte;
  36.450 -	unsigned long end;
  36.451 -	pte_t swp_pte = swp_entry_to_pte(entry);
  36.452 -
  36.453 -	if (pmd_none(*dir))
  36.454 -		return 0;
  36.455 -	if (pmd_bad(*dir)) {
  36.456 -		pmd_ERROR(*dir);
  36.457 -		pmd_clear(dir);
  36.458 -		return 0;
  36.459 -	}
  36.460 -	pte = pte_offset_map(dir, address);
  36.461 -	offset += address & PMD_MASK;
  36.462 -	address &= ~PMD_MASK;
  36.463 -	end = address + size;
  36.464 -	if (end > PMD_SIZE)
  36.465 -		end = PMD_SIZE;
  36.466 -	do {
  36.467 -		/*
  36.468 -		 * swapoff spends a _lot_ of time in this loop!
  36.469 -		 * Test inline before going to call unuse_pte.
  36.470 -		 */
  36.471 -		if (unlikely(pte_same(*pte, swp_pte))) {
  36.472 -			unuse_pte(vma, offset + address, pte, entry, page);
  36.473 -			pte_unmap(pte);
  36.474 -
  36.475 -			/*
  36.476 -			 * Move the page to the active list so it is not
  36.477 -			 * immediately swapped out again after swapon.
  36.478 -			 */
  36.479 -			activate_page(page);
  36.480 -
  36.481 -			/* add 1 since address may be 0 */
  36.482 -			return 1 + offset + address;
  36.483 -		}
  36.484 -		address += PAGE_SIZE;
  36.485 -		pte++;
  36.486 -	} while (address && (address < end));
  36.487 -	pte_unmap(pte - 1);
  36.488 -	return 0;
  36.489 -}
  36.490 -
  36.491 -/* vma->vm_mm->page_table_lock is held */
  36.492 -static unsigned long unuse_pgd(struct vm_area_struct * vma, pgd_t *dir,
  36.493 -	unsigned long address, unsigned long size,
  36.494 -	swp_entry_t entry, struct page *page)
  36.495 -{
  36.496 -	pmd_t * pmd;
  36.497 -	unsigned long offset, end;
  36.498 -	unsigned long foundaddr;
  36.499 -
  36.500 -	if (pgd_none(*dir))
  36.501 -		return 0;
  36.502 -	if (pgd_bad(*dir)) {
  36.503 -		pgd_ERROR(*dir);
  36.504 -		pgd_clear(dir);
  36.505 -		return 0;
  36.506 -	}
  36.507 -	pmd = pmd_offset(dir, address);
  36.508 -	offset = address & PGDIR_MASK;
  36.509 -	address &= ~PGDIR_MASK;
  36.510 -	end = address + size;
  36.511 -	if (end > PGDIR_SIZE)
  36.512 -		end = PGDIR_SIZE;
  36.513 -	if (address >= end)
  36.514 -		BUG();
  36.515 -	do {
  36.516 -		foundaddr = unuse_pmd(vma, pmd, address, end - address,
  36.517 -						offset, entry, page);
  36.518 -		if (foundaddr)
  36.519 -			return foundaddr;
  36.520 -		address = (address + PMD_SIZE) & PMD_MASK;
  36.521 -		pmd++;
  36.522 -	} while (address && (address < end));
  36.523 -	return 0;
  36.524 -}
  36.525 -
  36.526 -/* vma->vm_mm->page_table_lock is held */
  36.527 -static unsigned long unuse_vma(struct vm_area_struct * vma,
  36.528 -	swp_entry_t entry, struct page *page)
  36.529 -{
  36.530 -	pgd_t *pgdir;
  36.531 -	unsigned long start, end;
  36.532 -	unsigned long foundaddr;
  36.533 -
  36.534 -	if (page->mapping) {
  36.535 -		start = page_address_in_vma(page, vma);
  36.536 -		if (start == -EFAULT)
  36.537 -			return 0;
  36.538 -		else
  36.539 -			end = start + PAGE_SIZE;
  36.540 -	} else {
  36.541 -		start = vma->vm_start;
  36.542 -		end = vma->vm_end;
  36.543 -	}
  36.544 -	pgdir = pgd_offset(vma->vm_mm, start);
  36.545 -	do {
  36.546 -		foundaddr = unuse_pgd(vma, pgdir, start, end - start,
  36.547 -						entry, page);
  36.548 -		if (foundaddr)
  36.549 -			return foundaddr;
  36.550 -		start = (start + PGDIR_SIZE) & PGDIR_MASK;
  36.551 -		pgdir++;
  36.552 -	} while (start && (start < end));
  36.553 -	return 0;
  36.554 -}
  36.555 -
  36.556 -static int unuse_process(struct mm_struct * mm,
  36.557 -			swp_entry_t entry, struct page* page)
  36.558 -{
  36.559 -	struct vm_area_struct* vma;
  36.560 -	unsigned long foundaddr = 0;
  36.561 -
  36.562 -	/*
  36.563 -	 * Go through process' page directory.
  36.564 -	 */
  36.565 -	if (!down_read_trylock(&mm->mmap_sem)) {
  36.566 -		/*
  36.567 -		 * Our reference to the page stops try_to_unmap_one from
  36.568 -		 * unmapping its ptes, so swapoff can make progress.
  36.569 -		 */
  36.570 -		unlock_page(page);
  36.571 -		down_read(&mm->mmap_sem);
  36.572 -		lock_page(page);
  36.573 -	}
  36.574 -	spin_lock(&mm->page_table_lock);
  36.575 -	for (vma = mm->mmap; vma; vma = vma->vm_next) {
  36.576 -		if (vma->anon_vma) {
  36.577 -			foundaddr = unuse_vma(vma, entry, page);
  36.578 -			if (foundaddr)
  36.579 -				break;
  36.580 -		}
  36.581 -	}
  36.582 -#ifdef CONFIG_XEN_BATCH_MODE2
  36.583 -        XEN_flush_page_update_queue();
  36.584 -#endif
  36.585 -	spin_unlock(&mm->page_table_lock);
  36.586 -	up_read(&mm->mmap_sem);
  36.587 -	/*
  36.588 -	 * Currently unuse_process cannot fail, but leave error handling
  36.589 -	 * at call sites for now, since we change it from time to time.
  36.590 -	 */
  36.591 -	return 0;
  36.592 -}
  36.593 -
  36.594 -/*
  36.595 - * Scan swap_map from current position to next entry still in use.
  36.596 - * Recycle to start on reaching the end, returning 0 when empty.
  36.597 - */
  36.598 -static int find_next_to_unuse(struct swap_info_struct *si, int prev)
  36.599 -{
  36.600 -	int max = si->max;
  36.601 -	int i = prev;
  36.602 -	int count;
  36.603 -
  36.604 -	/*
  36.605 -	 * No need for swap_device_lock(si) here: we're just looking
  36.606 -	 * for whether an entry is in use, not modifying it; false
  36.607 -	 * hits are okay, and sys_swapoff() has already prevented new
  36.608 -	 * allocations from this area (while holding swap_list_lock()).
  36.609 -	 */
  36.610 -	for (;;) {
  36.611 -		if (++i >= max) {
  36.612 -			if (!prev) {
  36.613 -				i = 0;
  36.614 -				break;
  36.615 -			}
  36.616 -			/*
  36.617 -			 * No entries in use at top of swap_map,
  36.618 -			 * loop back to start and recheck there.
  36.619 -			 */
  36.620 -			max = prev + 1;
  36.621 -			prev = 0;
  36.622 -			i = 1;
  36.623 -		}
  36.624 -		count = si->swap_map[i];
  36.625 -		if (count && count != SWAP_MAP_BAD)
  36.626 -			break;
  36.627 -	}
  36.628 -	return i;
  36.629 -}
  36.630 -
  36.631 -/*
  36.632 - * We completely avoid races by reading each swap page in advance,
  36.633 - * and then search for the process using it.  All the necessary
  36.634 - * page table adjustments can then be made atomically.
  36.635 - */
  36.636 -static int try_to_unuse(unsigned int type)
  36.637 -{
  36.638 -	struct swap_info_struct * si = &swap_info[type];
  36.639 -	struct mm_struct *start_mm;
  36.640 -	unsigned short *swap_map;
  36.641 -	unsigned short swcount;
  36.642 -	struct page *page;
  36.643 -	swp_entry_t entry;
  36.644 -	int i = 0;
  36.645 -	int retval = 0;
  36.646 -	int reset_overflow = 0;
  36.647 -	int shmem;
  36.648 -
  36.649 -	/*
  36.650 -	 * When searching mms for an entry, a good strategy is to
  36.651 -	 * start at the first mm we freed the previous entry from
  36.652 -	 * (though actually we don't notice whether we or coincidence
  36.653 -	 * freed the entry).  Initialize this start_mm with a hold.
  36.654 -	 *
  36.655 -	 * A simpler strategy would be to start at the last mm we
  36.656 -	 * freed the previous entry from; but that would take less
  36.657 -	 * advantage of mmlist ordering, which clusters forked mms
  36.658 -	 * together, child after parent.  If we race with dup_mmap(), we
  36.659 -	 * prefer to resolve parent before child, lest we miss entries
  36.660 -	 * duplicated after we scanned child: using last mm would invert
  36.661 -	 * that.  Though it's only a serious concern when an overflowed
  36.662 -	 * swap count is reset from SWAP_MAP_MAX, preventing a rescan.
  36.663 -	 */
  36.664 -	start_mm = &init_mm;
  36.665 -	atomic_inc(&init_mm.mm_users);
  36.666 -
  36.667 -	/*
  36.668 -	 * Keep on scanning until all entries have gone.  Usually,
  36.669 -	 * one pass through swap_map is enough, but not necessarily:
  36.670 -	 * there are races when an instance of an entry might be missed.
  36.671 -	 */
  36.672 -	while ((i = find_next_to_unuse(si, i)) != 0) {
  36.673 -		if (signal_pending(current)) {
  36.674 -			retval = -EINTR;
  36.675 -			break;
  36.676 -		}
  36.677 -
  36.678 -		/* 
  36.679 -		 * Get a page for the entry, using the existing swap
  36.680 -		 * cache page if there is one.  Otherwise, get a clean
  36.681 -		 * page and read the swap into it. 
  36.682 -		 */
  36.683 -		swap_map = &si->swap_map[i];
  36.684 -		entry = swp_entry(type, i);
  36.685 -		page = read_swap_cache_async(entry, NULL, 0);
  36.686 -		if (!page) {
  36.687 -			/*
  36.688 -			 * Either swap_duplicate() failed because entry
  36.689 -			 * has been freed independently, and will not be
  36.690 -			 * reused since sys_swapoff() already disabled
  36.691 -			 * allocation from here, or alloc_page() failed.
  36.692 -			 */
  36.693 -			if (!*swap_map)
  36.694 -				continue;
  36.695 -			retval = -ENOMEM;
  36.696 -			break;
  36.697 -		}
  36.698 -
  36.699 -		/*
  36.700 -		 * Don't hold on to start_mm if it looks like exiting.
  36.701 -		 */
  36.702 -		if (atomic_read(&start_mm->mm_users) == 1) {
  36.703 -			mmput(start_mm);
  36.704 -			start_mm = &init_mm;
  36.705 -			atomic_inc(&init_mm.mm_users);
  36.706 -		}
  36.707 -
  36.708 -		/*
  36.709 -		 * Wait for and lock page.  When do_swap_page races with
  36.710 -		 * try_to_unuse, do_swap_page can handle the fault much
  36.711 -		 * faster than try_to_unuse can locate the entry.  This
  36.712 -		 * apparently redundant "wait_on_page_locked" lets try_to_unuse
  36.713 -		 * defer to do_swap_page in such a case - in some tests,
  36.714 -		 * do_swap_page and try_to_unuse repeatedly compete.
  36.715 -		 */
  36.716 -		wait_on_page_locked(page);
  36.717 -		wait_on_page_writeback(page);
  36.718 -		lock_page(page);
  36.719 -		wait_on_page_writeback(page);
  36.720 -
  36.721 -		/*
  36.722 -		 * Remove all references to entry.
  36.723 -		 * Whenever we reach init_mm, there's no address space
  36.724 -		 * to search, but use it as a reminder to search shmem.
  36.725 -		 */
  36.726 -		shmem = 0;
  36.727 -		swcount = *swap_map;
  36.728 -		if (swcount > 1) {
  36.729 -			if (start_mm == &init_mm)
  36.730 -				shmem = shmem_unuse(entry, page);
  36.731 -			else
  36.732 -				retval = unuse_process(start_mm, entry, page);
  36.733 -		}
  36.734 -		if (*swap_map > 1) {
  36.735 -			int set_start_mm = (*swap_map >= swcount);
  36.736 -			struct list_head *p = &start_mm->mmlist;
  36.737 -			struct mm_struct *new_start_mm = start_mm;
  36.738 -			struct mm_struct *prev_mm = start_mm;
  36.739 -			struct mm_struct *mm;
  36.740 -
  36.741 -			atomic_inc(&new_start_mm->mm_users);
  36.742 -			atomic_inc(&prev_mm->mm_users);
  36.743 -			spin_lock(&mmlist_lock);
  36.744 -			while (*swap_map > 1 && !retval &&
  36.745 -					(p = p->next) != &start_mm->mmlist) {
  36.746 -				mm = list_entry(p, struct mm_struct, mmlist);
  36.747 -				if (atomic_inc_return(&mm->mm_users) == 1) {
  36.748 -					atomic_dec(&mm->mm_users);
  36.749 -					continue;
  36.750 -				}
  36.751 -				spin_unlock(&mmlist_lock);
  36.752 -				mmput(prev_mm);
  36.753 -				prev_mm = mm;
  36.754 -
  36.755 -				cond_resched();
  36.756 -
  36.757 -				swcount = *swap_map;
  36.758 -				if (swcount <= 1)
  36.759 -					;
  36.760 -				else if (mm == &init_mm) {
  36.761 -					set_start_mm = 1;
  36.762 -					shmem = shmem_unuse(entry, page);
  36.763 -				} else
  36.764 -					retval = unuse_process(mm, entry, page);
  36.765 -				if (set_start_mm && *swap_map < swcount) {
  36.766 -					mmput(new_start_mm);
  36.767 -					atomic_inc(&mm->mm_users);
  36.768 -					new_start_mm = mm;
  36.769 -					set_start_mm = 0;
  36.770 -				}
  36.771 -				spin_lock(&mmlist_lock);
  36.772 -			}
  36.773 -			spin_unlock(&mmlist_lock);
  36.774 -			mmput(prev_mm);
  36.775 -			mmput(start_mm);
  36.776 -			start_mm = new_start_mm;
  36.777 -		}
  36.778 -		if (retval) {
  36.779 -			unlock_page(page);
  36.780 -			page_cache_release(page);
  36.781 -			break;
  36.782 -		}
  36.783 -
  36.784 -		/*
  36.785 -		 * How could swap count reach 0x7fff when the maximum
  36.786 -		 * pid is 0x7fff, and there's no way to repeat a swap
  36.787 -		 * page within an mm (except in shmem, where it's the
  36.788 -		 * shared object which takes the reference count)?
  36.789 -		 * We believe SWAP_MAP_MAX cannot occur in Linux 2.4.
  36.790 -		 *
  36.791 -		 * If that's wrong, then we should worry more about
  36.792 -		 * exit_mmap() and do_munmap() cases described above:
  36.793 -		 * we might be resetting SWAP_MAP_MAX too early here.
  36.794 -		 * We know "Undead"s can happen, they're okay, so don't
  36.795 -		 * report them; but do report if we reset SWAP_MAP_MAX.
  36.796 -		 */
  36.797 -		if (*swap_map == SWAP_MAP_MAX) {
  36.798 -			swap_device_lock(si);
  36.799 -			*swap_map = 1;
  36.800 -			swap_device_unlock(si);
  36.801 -			reset_overflow = 1;
  36.802 -		}
  36.803 -
  36.804 -		/*
  36.805 -		 * If a reference remains (rare), we would like to leave
  36.806 -		 * the page in the swap cache; but try_to_unmap could
  36.807 -		 * then re-duplicate the entry once we drop page lock,
  36.808 -		 * so we might loop indefinitely; also, that page could
  36.809 -		 * not be swapped out to other storage meanwhile.  So:
  36.810 -		 * delete from cache even if there's another reference,
  36.811 -		 * after ensuring that the data has been saved to disk -
  36.812 -		 * since if the reference remains (rarer), it will be
  36.813 -		 * read from disk into another page.  Splitting into two
  36.814 -		 * pages would be incorrect if swap supported "shared
  36.815 -		 * private" pages, but they are handled by tmpfs files.
  36.816 -		 *
  36.817 -		 * Note shmem_unuse already deleted a swappage from
  36.818 -		 * the swap cache, unless the move to filepage failed:
  36.819 -		 * in which case it left swappage in cache, lowered its
  36.820 -		 * swap count to pass quickly through the loops above,
  36.821 -		 * and now we must reincrement count to try again later.
  36.822 -		 */
  36.823 -		if ((*swap_map > 1) && PageDirty(page) && PageSwapCache(page)) {
  36.824 -			struct writeback_control wbc = {
  36.825 -				.sync_mode = WB_SYNC_NONE,
  36.826 -			};
  36.827 -
  36.828 -			swap_writepage(page, &wbc);
  36.829 -			lock_page(page);
  36.830 -			wait_on_page_writeback(page);
  36.831 -		}
  36.832 -		if (PageSwapCache(page)) {
  36.833 -			if (shmem)
  36.834 -				swap_duplicate(entry);
  36.835 -			else
  36.836 -				delete_from_swap_cache(page);
  36.837 -		}
  36.838 -
  36.839 -		/*
  36.840 -		 * So we could skip searching mms once swap count went
  36.841 -		 * to 1, we did not mark any present ptes as dirty: must
  36.842 -		 * mark page dirty so shrink_list will preserve it.
  36.843 -		 */
  36.844 -		SetPageDirty(page);
  36.845 -		unlock_page(page);
  36.846 -		page_cache_release(page);
  36.847 -
  36.848 -		/*
  36.849 -		 * Make sure that we aren't completely killing
  36.850 -		 * interactive performance.
  36.851 -		 */
  36.852 -		cond_resched();
  36.853 -	}
  36.854 -
  36.855 -	mmput(start_mm);
  36.856 -	if (reset_overflow) {
  36.857 -		printk(KERN_WARNING "swapoff: cleared swap entry overflow\n");
  36.858 -		swap_overflow = 0;
  36.859 -	}
  36.860 -	return retval;
  36.861 -}
  36.862 -
  36.863 -/*
  36.864 - * After a successful try_to_unuse, if no swap is now in use, we know we
  36.865 - * can empty the mmlist.  swap_list_lock must be held on entry and exit.
  36.866 - * Note that mmlist_lock nests inside swap_list_lock, and an mm must be
  36.867 - * added to the mmlist just after page_duplicate - before would be racy.
  36.868 - */
  36.869 -static void drain_mmlist(void)
  36.870 -{
  36.871 -	struct list_head *p, *next;
  36.872 -	unsigned int i;
  36.873 -
  36.874 -	for (i = 0; i < nr_swapfiles; i++)
  36.875 -		if (swap_info[i].inuse_pages)
  36.876 -			return;
  36.877 -	spin_lock(&mmlist_lock);
  36.878 -	list_for_each_safe(p, next, &init_mm.mmlist)
  36.879 -		list_del_init(p);
  36.880 -	spin_unlock(&mmlist_lock);
  36.881 -}
  36.882 -
  36.883 -/*
  36.884 - * Use this swapdev's extent info to locate the (PAGE_SIZE) block which
  36.885 - * corresponds to page offset `offset'.
  36.886 - */
  36.887 -sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
  36.888 -{
  36.889 -	struct swap_extent *se = sis->curr_swap_extent;
  36.890 -	struct swap_extent *start_se = se;
  36.891 -
  36.892 -	for ( ; ; ) {
  36.893 -		struct list_head *lh;
  36.894 -
  36.895 -		if (se->start_page <= offset &&
  36.896 -				offset < (se->start_page + se->nr_pages)) {
  36.897 -			return se->start_block + (offset - se->start_page);
  36.898 -		}
  36.899 -		lh = se->list.prev;
  36.900 -		if (lh == &sis->extent_list)
  36.901 -			lh = lh->prev;
  36.902 -		se = list_entry(lh, struct swap_extent, list);
  36.903 -		sis->curr_swap_extent = se;
  36.904 -		BUG_ON(se == start_se);		/* It *must* be present */
  36.905 -	}
  36.906 -}
  36.907 -
  36.908 -/*
  36.909 - * Free all of a swapdev's extent information
  36.910 - */
  36.911 -static void destroy_swap_extents(struct swap_info_struct *sis)
  36.912 -{
  36.913 -	while (!list_empty(&sis->extent_list)) {
  36.914 -		struct swap_extent *se;
  36.915 -
  36.916 -		se = list_entry(sis->extent_list.next,
  36.917 -				struct swap_extent, list);
  36.918 -		list_del(&se->list);
  36.919 -		kfree(se);
  36.920 -	}
  36.921 -	sis->nr_extents = 0;
  36.922 -}
  36.923 -
  36.924 -/*
  36.925 - * Add a block range (and the corresponding page range) into this swapdev's
  36.926 - * extent list.  The extent list is kept sorted in block order.
  36.927 - *
  36.928 - * This function rather assumes that it is called in ascending sector_t order.
  36.929 - * It doesn't look for extent coalescing opportunities.
  36.930 - */
  36.931 -static int
  36.932 -add_swap_extent(struct swap_info_struct *sis, unsigned long start_page,
  36.933 -		unsigned long nr_pages, sector_t start_block)
  36.934 -{
  36.935 -	struct swap_extent *se;
  36.936 -	struct swap_extent *new_se;
  36.937 -	struct list_head *lh;
  36.938 -
  36.939 -	lh = sis->extent_list.next;	/* The highest-addressed block */
  36.940 -	while (lh != &sis->extent_list) {
  36.941 -		se = list_entry(lh, struct swap_extent, list);
  36.942 -		if (se->start_block + se->nr_pages == start_block &&
  36.943 -		    se->start_page  + se->nr_pages == start_page) {
  36.944 -			/* Merge it */
  36.945 -			se->nr_pages += nr_pages;
  36.946 -			return 0;
  36.947 -		}
  36.948 -		lh = lh->next;
  36.949 -	}
  36.950 -
  36.951 -	/*
  36.952 -	 * No merge.  Insert a new extent, preserving ordering.
  36.953 -	 */
  36.954 -	new_se = kmalloc(sizeof(*se), GFP_KERNEL);
  36.955 -	if (new_se == NULL)
  36.956 -		return -ENOMEM;
  36.957 -	new_se->start_page = start_page;
  36.958 -	new_se->nr_pages = nr_pages;
  36.959 -	new_se->start_block = start_block;
  36.960 -
  36.961 -	lh = sis->extent_list.prev;	/* The lowest block */
  36.962 -	while (lh != &sis->extent_list) {
  36.963 -		se = list_entry(lh, struct swap_extent, list);
  36.964 -		if (se->start_block > start_block)
  36.965 -			break;
  36.966 -		lh = lh->prev;
  36.967 -	}
  36.968 -	list_add_tail(&new_se->list, lh);
  36.969 -	sis->nr_extents++;
  36.970 -	return 0;
  36.971 -}
  36.972 -
  36.973 -/*
  36.974 - * A `swap extent' is a simple thing which maps a contiguous range of pages
  36.975 - * onto a contiguous range of disk blocks.  An ordered list of swap extents
  36.976 - * is built at swapon time and is then used at swap_writepage/swap_readpage
  36.977 - * time for locating where on disk a page belongs.
  36.978 - *
  36.979 - * If the swapfile is an S_ISBLK block device, a single extent is installed.
  36.980 - * This is done so that the main operating code can treat S_ISBLK and S_ISREG
  36.981 - * swap files identically.
  36.982 - *
  36.983 - * Whether the swapdev is an S_ISREG file or an S_ISBLK blockdev, the swap
  36.984 - * extent list operates in PAGE_SIZE disk blocks.  Both S_ISREG and S_ISBLK
  36.985 - * swapfiles are handled *identically* after swapon time.
  36.986 - *
  36.987 - * For S_ISREG swapfiles, setup_swap_extents() will walk all the file's blocks
  36.988 - * and will parse them into an ordered extent list, in PAGE_SIZE chunks.  If
  36.989 - * some stray blocks are found which do not fall within the PAGE_SIZE alignment
  36.990 - * requirements, they are simply tossed out - we will never use those blocks
  36.991 - * for swapping.
  36.992 - *
  36.993 - * For S_ISREG swapfiles we hold i_sem across the life of the swapon.  This
  36.994 - * prevents root from shooting her foot off by ftruncating an in-use swapfile,
  36.995 - * which will scribble on the fs.
  36.996 - *
  36.997 - * The amount of disk space which a single swap extent represents varies.
  36.998 - * Typically it is in the 1-4 megabyte range.  So we can have hundreds of
  36.999 - * extents in the list.  To avoid much list walking, we cache the previous
 36.1000 - * search location in `curr_swap_extent', and start new searches from there.
 36.1001 - * This is extremely effective.  The average number of iterations in
 36.1002 - * map_swap_page() has been measured at about 0.3 per page.  - akpm.
 36.1003 - */
 36.1004 -static int setup_swap_extents(struct swap_info_struct *sis)
 36.1005 -{
 36.1006 -	struct inode *inode;
 36.1007 -	unsigned blocks_per_page;
 36.1008 -	unsigned long page_no;
 36.1009 -	unsigned blkbits;
 36.1010 -	sector_t probe_block;
 36.1011 -	sector_t last_block;
 36.1012 -	int ret;
 36.1013 -
 36.1014 -	inode = sis->swap_file->f_mapping->host;
 36.1015 -	if (S_ISBLK(inode->i_mode)) {
 36.1016 -		ret = add_swap_extent(sis, 0, sis->max, 0);
 36.1017 -		goto done;
 36.1018 -	}
 36.1019 -
 36.1020 -	blkbits = inode->i_blkbits;
 36.1021 -	blocks_per_page = PAGE_SIZE >> blkbits;
 36.1022 -
 36.1023 -	/*
 36.1024 -	 * Map all the blocks into the extent list.  This code doesn't try
 36.1025 -	 * to be very smart.
 36.1026 -	 */
 36.1027 -	probe_block = 0;
 36.1028 -	page_no = 0;
 36.1029 -	last_block = i_size_read(inode) >> blkbits;
 36.1030 -	while ((probe_block + blocks_per_page) <= last_block &&
 36.1031 -			page_no < sis->max) {
 36.1032 -		unsigned block_in_page;
 36.1033 -		sector_t first_block;
 36.1034 -
 36.1035 -		first_block = bmap(inode, probe_block);
 36.1036 -		if (first_block == 0)
 36.1037 -			goto bad_bmap;
 36.1038 -
 36.1039 -		/*
 36.1040 -		 * It must be PAGE_SIZE aligned on-disk
 36.1041 -		 */
 36.1042 -		if (first_block & (blocks_per_page - 1)) {
 36.1043 -			probe_block++;
 36.1044 -			goto reprobe;
 36.1045 -		}
 36.1046 -
 36.1047 -		for (block_in_page = 1; block_in_page < blocks_per_page;
 36.1048 -					block_in_page++) {
 36.1049 -			sector_t block;
 36.1050 -
 36.1051 -			block = bmap(inode, probe_block + block_in_page);
 36.1052 -			if (block == 0)
 36.1053 -				goto bad_bmap;
 36.1054 -			if (block != first_block + block_in_page) {
 36.1055 -				/* Discontiguity */
 36.1056 -				probe_block++;
 36.1057 -				goto reprobe;
 36.1058 -			}
 36.1059 -		}
 36.1060 -
 36.1061 -		/*
 36.1062 -		 * We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks
 36.1063 -		 */
 36.1064 -		ret = add_swap_extent(sis, page_no, 1,
 36.1065 -				first_block >> (PAGE_SHIFT - blkbits));
 36.1066 -		if (ret)
 36.1067 -			goto out;
 36.1068 -		page_no++;
 36.1069 -		probe_block += blocks_per_page;
 36.1070 -reprobe:
 36.1071 -		continue;
 36.1072 -	}
 36.1073 -	ret = 0;
 36.1074 -	if (page_no == 0)
 36.1075 -		ret = -EINVAL;
 36.1076 -	sis->max = page_no;
 36.1077 -	sis->highest_bit = page_no - 1;
 36.1078 -done:
 36.1079 -	sis->curr_swap_extent = list_entry(sis->extent_list.prev,
 36.1080 -					struct swap_extent, list);
 36.1081 -	goto out;
 36.1082 -bad_bmap:
 36.1083 -	printk(KERN_ERR "swapon: swapfile has holes\n");
 36.1084 -	ret = -EINVAL;
 36.1085 -out:
 36.1086 -	return ret;
 36.1087 -}
 36.1088 -
 36.1089 -#if 0	/* We don't need this yet */
 36.1090 -#include <linux/backing-dev.h>
 36.1091 -int page_queue_congested(struct page *page)
 36.1092 -{
 36.1093 -	struct backing_dev_info *bdi;
 36.1094 -
 36.1095 -	BUG_ON(!PageLocked(page));	/* It pins the swap_info_struct */
 36.1096 -
 36.1097 -	if (PageSwapCache(page)) {
 36.1098 -		swp_entry_t entry = { .val = page->private };
 36.1099 -		struct swap_info_struct *sis;
 36.1100 -
 36.1101 -		sis = get_swap_info_struct(swp_type(entry));
 36.1102 -		bdi = sis->bdev->bd_inode->i_mapping->backing_dev_info;
 36.1103 -	} else
 36.1104 -		bdi = page->mapping->backing_dev_info;
 36.1105 -	return bdi_write_congested(bdi);
 36.1106 -}
 36.1107 -#endif
 36.1108 -
 36.1109 -asmlinkage long sys_swapoff(const char __user * specialfile)
 36.1110 -{
 36.1111 -	struct swap_info_struct * p = NULL;
 36.1112 -	unsigned short *swap_map;
 36.1113 -	struct file *swap_file, *victim;
 36.1114 -	struct address_space *mapping;
 36.1115 -	struct inode *inode;
 36.1116 -	char * pathname;
 36.1117 -	int i, type, prev;
 36.1118 -	int err;
 36.1119 -	
 36.1120 -	if (!capable(CAP_SYS_ADMIN))
 36.1121 -		return -EPERM;
 36.1122 -
 36.1123 -	pathname = getname(specialfile);
 36.1124 -	err = PTR_ERR(pathname);
 36.1125 -	if (IS_ERR(pathname))
 36.1126 -		goto out;
 36.1127 -
 36.1128 -	victim = filp_open(pathname, O_RDWR|O_LARGEFILE, 0);
 36.1129 -	putname(pathname);
 36.1130 -	err = PTR_ERR(victim);
 36.1131 -	if (IS_ERR(victim))
 36.1132 -		goto out;
 36.1133 -
 36.1134 -	mapping = victim->f_mapping;
 36.1135 -	prev = -1;
 36.1136 -	swap_list_lock();
 36.1137 -	for (type = swap_list.head; type >= 0; type = swap_info[type].next) {
 36.1138 -		p = swap_info + type;
 36.1139 -		if ((p->flags & SWP_ACTIVE) == SWP_ACTIVE) {
 36.1140 -			if (p->swap_file->f_mapping == mapping)
 36.1141 -				break;
 36.1142 -		}
 36.1143 -		prev = type;
 36.1144 -	}
 36.1145 -	if (type < 0) {
 36.1146 -		err = -EINVAL;
 36.1147 -		swap_list_unlock();
 36.1148 -		goto out_dput;
 36.1149 -	}
 36.1150 -	if (!security_vm_enough_memory(p->pages))
 36.1151 -		vm_unacct_memory(p->pages);
 36.1152 -	else {
 36.1153 -		err = -ENOMEM;
 36.1154 -		swap_list_unlock();
 36.1155 -		goto out_dput;
 36.1156 -	}
 36.1157 -	if (prev < 0) {
 36.1158 -		swap_list.head = p->next;
 36.1159 -	} else {
 36.1160 -		swap_info[prev].next = p->next;
 36.1161 -	}
 36.1162 -	if (type == swap_list.next) {
 36.1163 -		/* just pick something that's safe... */
 36.1164 -		swap_list.next = swap_list.head;
 36.1165 -	}
 36.1166 -	nr_swap_pages -= p->pages;
 36.1167 -	total_swap_pages -= p->pages;
 36.1168 -	p->flags &= ~SWP_WRITEOK;
 36.1169 -	swap_list_unlock();
 36.1170 -	current->flags |= PF_SWAPOFF;
 36.1171 -	err = try_to_unuse(type);
 36.1172 -	current->flags &= ~PF_SWAPOFF;
 36.1173 -
 36.1174 -	/* wait for any unplug function to finish */
 36.1175 -	down_write(&swap_unplug_sem);
 36.1176 -	up_write(&swap_unplug_sem);
 36.1177 -
 36.1178 -	if (err) {
 36.1179 -		/* re-insert swap space back into swap_list */
 36.1180 -		swap_list_lock();
 36.1181 -		for (prev = -1, i = swap_list.head; i >= 0; prev = i, i = swap_info[i].next)
 36.1182 -			if (p->prio >= swap_info[i].prio)
 36.1183 -				break;
 36.1184 -		p->next = i;
 36.1185 -		if (prev < 0)
 36.1186 -			swap_list.head = swap_list.next = p - swap_info;
 36.1187 -		else
 36.1188 -			swap_info[prev].next = p - swap_info;
 36.1189 -		nr_swap_pages += p->pages;
 36.1190 -		total_swap_pages += p->pages;
 36.1191 -		p->flags |= SWP_WRITEOK;
 36.1192 -		swap_list_unlock();
 36.1193 -		goto out_dput;
 36.1194 -	}
 36.1195 -	down(&swapon_sem);
 36.1196 -	swap_list_lock();
 36.1197 -	drain_mmlist();
 36.1198 -	swap_device_lock(p);
 36.1199 -	swap_file = p->swap_file;
 36.1200 -	p->swap_file = NULL;
 36.1201 -	p->max = 0;
 36.1202 -	swap_map = p->swap_map;
 36.1203 -	p->swap_map = NULL;
 36.1204 -	p->flags = 0;
 36.1205 -	destroy_swap_extents(p);
 36.1206 -	swap_device_unlock(p);
 36.1207 -	swap_list_unlock();
 36.1208 -	up(&swapon_sem);
 36.1209 -	vfree(swap_map);
 36.1210 -	inode = mapping->host;
 36.1211 -	if (S_ISBLK(inode->i_mode)) {
 36.1212 -		struct block_device *bdev = I_BDEV(inode);
 36.1213 -		set_blocksize(bdev, p->old_block_size);
 36.1214 -		bd_release(bdev);
 36.1215 -	} else {
 36.1216 -		down(&inode->i_sem);
 36.1217 -		inode->i_flags &= ~S_SWAPFILE;
 36.1218 -		up(&inode->i_sem);
 36.1219 -	}
 36.1220 -	filp_close(swap_file, NULL);
 36.1221 -	err = 0;
 36.1222 -
 36.1223 -out_dput:
 36.1224 -	filp_close(victim, NULL);
 36.1225 -out:
 36.1226 -	return err;
 36.1227 -}
 36.1228 -
 36.1229 -#ifdef CONFIG_PROC_FS
 36.1230 -/* iterator */
 36.1231 -static void *swap_start(struct seq_file *swap, loff_t *pos)
 36.1232 -{
 36.1233 -	struct swap_info_struct *ptr = swap_info;
 36.1234 -	int i;
 36.1235 -	loff_t l = *pos;
 36.1236 -
 36.1237 -	down(&swapon_sem);
 36.1238 -
 36.1239 -	for (i = 0; i < nr_swapfiles; i++, ptr++) {
 36.1240 -		if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
 36.1241 -			continue;
 36.1242 -		if (!l--)
 36.1243 -			return ptr;
 36.1244 -	}
 36.1245 -
 36.1246 -	return NULL;
 36.1247 -}
 36.1248 -
 36.1249 -static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
 36.1250 -{
 36.1251 -	struct swap_info_struct *ptr = v;
 36.1252 -	struct swap_info_struct *endptr = swap_info + nr_swapfiles;
 36.1253 -
 36.1254 -	for (++ptr; ptr < endptr; ptr++) {
 36.1255 -		if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
 36.1256 -			continue;
 36.1257 -		++*pos;
 36.1258 -		return ptr;
 36.1259 -	}
 36.1260 -
 36.1261 -	return NULL;
 36.1262 -}
 36.1263 -
 36.1264 -static void swap_stop(struct seq_file *swap, void *v)
 36.1265 -{
 36.1266 -	up(&swapon_sem);
 36.1267 -}
 36.1268 -
 36.1269 -static int swap_show(struct seq_file *swap, void *v)
 36.1270 -{
 36.1271 -	struct swap_info_struct *ptr = v;
 36.1272 -	struct file *file;
 36.1273 -	int len;
 36.1274 -
 36.1275 -	if (v == swap_info)
 36.1276 -		seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
 36.1277 -
 36.1278 -	file = ptr->swap_file;
 36.1279 -	len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
 36.1280 -	seq_printf(swap, "%*s%s\t%d\t%ld\t%d\n",
 36.1281 -		       len < 40 ? 40 - len : 1, " ",
 36.1282 -		       S_ISBLK(file->f_dentry->d_inode->i_mode) ?
 36.1283 -				"partition" : "file\t",
 36.1284 -		       ptr->pages << (PAGE_SHIFT - 10),
 36.1285 -		       ptr->inuse_pages << (PAGE_SHIFT - 10),
 36.1286 -		       ptr->prio);
 36.1287 -	return 0;
 36.1288 -}
 36.1289 -
 36.1290 -static struct seq_operations swaps_op = {
 36.1291 -	.start =	swap_start,
 36.1292 -	.next =		swap_next,
 36.1293 -	.stop =		swap_stop,
 36.1294 -	.show =		swap_show
 36.1295 -};
 36.1296 -
 36.1297 -static int swaps_open(struct inode *inode, struct file *file)
 36.1298 -{
 36.1299 -	return seq_open(file, &swaps_op);
 36.1300 -}
 36.1301 -
 36.1302 -static struct file_operations proc_swaps_operations = {
 36.1303 -	.open		= swaps_open,
 36.1304 -	.read		= seq_read,
 36.1305 -	.llseek		= seq_lseek,
 36.1306 -	.release	= seq_release,
 36.1307 -};
 36.1308 -
 36.1309 -static int __init procswaps_init(void)
 36.1310 -{
 36.1311 -	struct proc_dir_entry *entry;
 36.1312 -
 36.1313 -	entry = create_proc_entry("swaps", 0, NULL);
 36.1314 -	if (entry)
 36.1315 -		entry->proc_fops = &proc_swaps_operations;
 36.1316 -	return 0;
 36.1317 -}
 36.1318 -__initcall(procswaps_init);
 36.1319 -#endif /* CONFIG_PROC_FS */
 36.1320 -
 36.1321 -/*
 36.1322 - * Written 01/25/92 by Simmule Turner, heavily changed by Linus.
 36.1323 - *
 36.1324 - * The swapon system call
 36.1325 - */
 36.1326 -asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
 36.1327 -{
 36.1328 -	struct swap_info_struct * p;
 36.1329 -	char *name = NULL;
 36.1330 -	struct block_device *bdev = NULL;
 36.1331 -	struct file *swap_file = NULL;
 36.1332 -	struct address_space *mapping;
 36.1333 -	unsigned int type;
 36.1334 -	int i, prev;
 36.1335 -	int error;
 36.1336 -	static int least_priority;
 36.1337 -	union swap_header *swap_header = NULL;
 36.1338 -	int swap_header_version;
 36.1339 -	int nr_good_pages = 0;
 36.1340 -	unsigned long maxpages = 1;
 36.1341 -	int swapfilesize;
 36.1342 -	unsigned short *swap_map;
 36.1343 -	struct page *page = NULL;
 36.1344 -	struct inode *inode = NULL;
 36.1345 -	int did_down = 0;
 36.1346 -
 36.1347 -	if (!capable(CAP_SYS_ADMIN))
 36.1348 -		return -EPERM;
 36.1349 -	swap_list_lock();
 36.1350 -	p = swap_info;
 36.1351 -	for (type = 0 ; type < nr_swapfiles ; type++,p++)
 36.1352 -		if (!(p->flags & SWP_USED))
 36.1353 -			break;
 36.1354 -	error = -EPERM;
 36.1355 -	/*
 36.1356 -	 * Test if adding another swap device is possible. There are
 36.1357 -	 * two limiting factors: 1) the number of bits for the swap
 36.1358 -	 * type swp_entry_t definition and 2) the number of bits for
 36.1359 -	 * the swap type in the swap ptes as defined by the different
 36.1360 -	 * architectures. To honor both limitations a swap entry
 36.1361 -	 * with swap offset 0 and swap type ~0UL is created, encoded
 36.1362 -	 * to a swap pte, decoded to a swp_entry_t again and finally
 36.1363 -	 * the swap type part is extracted. This will mask all bits
 36.1364 -	 * from the initial ~0UL that can't be encoded in either the
 36.1365 -	 * swp_entry_t or the architecture definition of a swap pte.
 36.1366 -	 */
 36.1367 -	if (type > swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))))) {
 36.1368 -		swap_list_unlock();
 36.1369 -		goto out;
 36.1370 -	}
 36.1371 -	if (type >= nr_swapfiles)
 36.1372 -		nr_swapfiles = type+1;
 36.1373 -	INIT_LIST_HEAD(&p->extent_list);
 36.1374 -	p->flags = SWP_USED;
 36.1375 -	p->nr_extents = 0;
 36.1376 -	p->swap_file = NULL;
 36.1377 -	p->old_block_size = 0;
 36.1378 -	p->swap_map = NULL;
 36.1379 -	p->lowest_bit = 0;
 36.1380 -	p->highest_bit = 0;
 36.1381 -	p->cluster_nr = 0;
 36.1382 -	p->inuse_pages = 0;
 36.1383 -	spin_lock_init(&p->sdev_lock);
 36.1384 -	p->next = -1;
 36.1385 -	if (swap_flags & SWAP_FLAG_PREFER) {
 36.1386 -		p->prio =
 36.1387 -		  (swap_flags & SWAP_FLAG_PRIO_MASK)>>SWAP_FLAG_PRIO_SHIFT;
 36.1388 -	} else {
 36.1389 -		p->prio = --least_priority;
 36.1390 -	}
 36.1391 -	swap_list_unlock();
 36.1392 -	name = getname(specialfile);
 36.1393 -	error = PTR_ERR(name);
 36.1394 -	if (IS_ERR(name)) {
 36.1395 -		name = NULL;
 36.1396 -		goto bad_swap_2;
 36.1397 -	}
 36.1398 -	swap_file = filp_open(name, O_RDWR|O_LARGEFILE, 0);
 36.1399 -	error = PTR_ERR(swap_file);
 36.1400 -	if (IS_ERR(swap_file)) {
 36.1401 -		swap_file = NULL;
 36.1402 -		goto bad_swap_2;
 36.1403 -	}
 36.1404 -
 36.1405 -	p->swap_file = swap_file;
 36.1406 -	mapping = swap_file->f_mapping;
 36.1407 -	inode = mapping->host;
 36.1408 -
 36.1409 -	error = -EBUSY;
 36.1410 -	for (i = 0; i < nr_swapfiles; i++) {
 36.1411 -		struct swap_info_struct *q = &swap_info[i];
 36.1412 -
 36.1413 -		if (i == type || !q->swap_file)
 36.1414 -			continue;
 36.1415 -		if (mapping == q->swap_file->f_mapping)
 36.1416 -			goto bad_swap;
 36.1417 -	}
 36.1418 -
 36.1419 -	error = -EINVAL;
 36.1420 -	if (S_ISBLK(inode->i_mode)) {
 36.1421 -		bdev = I_BDEV(inode);
 36.1422 -		error = bd_claim(bdev, sys_swapon);
 36.1423 -		if (error < 0) {
 36.1424 -			bdev = NULL;
 36.1425 -			goto bad_swap;
 36.1426 -		}
 36.1427 -		p->old_block_size = block_size(bdev);
 36.1428 -		error = set_blocksize(bdev, PAGE_SIZE);
 36.1429 -		if (error < 0)
 36.1430 -			goto bad_swap;
 36.1431 -		p->bdev = bdev;
 36.1432 -	} else if (S_ISREG(inode->i_mode)) {
 36.1433 -		p->bdev = inode->i_sb->s_bdev;
 36.1434 -		down(&inode->i_sem);
 36.1435 -		did_down = 1;
 36.1436 -		if (IS_SWAPFILE(inode)) {
 36.1437 -			error = -EBUSY;
 36.1438 -			goto bad_swap;
 36.1439 -		}
 36.1440 -	} else {
 36.1441 -		goto bad_swap;
 36.1442 -	}
 36.1443 -
 36.1444 -	swapfilesize = i_size_read(inode) >> PAGE_SHIFT;
 36.1445 -
 36.1446 -	/*
 36.1447 -	 * Read the swap header.
 36.1448 -	 */
 36.1449 -	if (!mapping->a_ops->readpage) {
 36.1450 -		error = -EINVAL;
 36.1451 -		goto bad_swap;
 36.1452 -	}
 36.1453 -	page = read_cache_page(mapping, 0,
 36.1454 -			(filler_t *)mapping->a_ops->readpage, swap_file);
 36.1455 -	if (IS_ERR(page)) {
 36.1456 -		error = PTR_ERR(page);
 36.1457 -		goto bad_swap;
 36.1458 -	}
 36.1459 -	wait_on_page_locked(page);
 36.1460 -	if (!PageUptodate(page))
 36.1461 -		goto bad_swap;
 36.1462 -	kmap(page);
 36.1463 -	swap_header = page_address(page);
 36.1464 -
 36.1465 -	if (!memcmp("SWAP-SPACE",swap_header->magic.magic,10))
 36.1466 -		swap_header_version = 1;
 36.1467 -	else if (!memcmp("SWAPSPACE2",swap_header->magic.magic,10))
 36.1468 -		swap_header_version = 2;
 36.1469 -	else {
 36.1470 -		printk("Unable to find swap-space signature\n");
 36.1471 -		error = -EINVAL;
 36.1472 -		goto bad_swap;
 36.1473 -	}
 36.1474 -	
 36.1475 -	switch (swap_header_version) {
 36.1476 -	case 1:
 36.1477 -		printk(KERN_ERR "version 0 swap is no longer supported. "
 36.1478 -			"Use mkswap -v1 %s\n", name);
 36.1479 -		error = -EINVAL;
 36.1480 -		goto bad_swap;
 36.1481 -	case 2:
 36.1482 -		/* Check the swap header's sub-version and the size of
 36.1483 -                   the swap file and bad block lists */
 36.1484 -		if (swap_header->info.version != 1) {
 36.1485 -			printk(KERN_WARNING
 36.1486 -			       "Unable to handle swap header version %d\n",
 36.1487 -			       swap_header->info.version);
 36.1488 -			error = -EINVAL;
 36.1489 -			goto bad_swap;
 36.1490 -		}
 36.1491 -
 36.1492 -		p->lowest_bit  = 1;
 36.1493 -		/*
 36.1494 -		 * Find out how many pages are allowed for a single swap
 36.1495 -		 * device. There are two limiting factors: 1) the number of
 36.1496 -		 * bits for the swap offset in the swp_entry_t type and
 36.1497 -		 * 2) the number of bits in the a swap pte as defined by
 36.1498 -		 * the different architectures. In order to find the
 36.1499 -		 * largest possible bit mask a swap entry with swap type 0
 36.1500 -		 * and swap offset ~0UL is created, encoded to a swap pte,
 36.1501 -		 * decoded to a swp_entry_t again and finally the swap
 36.1502 -		 * offset is extracted. This will mask all the bits from
 36.1503 -		 * the initial ~0UL mask that can't be encoded in either
 36.1504 -		 * the swp_entry_t or the architecture definition of a
 36.1505 -		 * swap pte.
 36.1506 -		 */
 36.1507 -		maxpages = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0,~0UL)))) - 1;
 36.1508 -		if (maxpages > swap_header->info.last_page)
 36.1509 -			maxpages = swap_header->info.last_page;
 36.1510 -		p->highest_bit = maxpages - 1;
 36.1511 -
 36.1512 -		error = -EINVAL;
 36.1513 -		if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
 36.1514 -			goto bad_swap;
 36.1515 -		
 36.1516 -		/* OK, set up the swap map and apply the bad block list */
 36.1517 -		if (!(p->swap_map = vmalloc(maxpages * sizeof(short)))) {
 36.1518 -			error = -ENOMEM;
 36.1519 -			goto bad_swap;
 36.1520 -		}
 36.1521 -
 36.1522 -		error = 0;
 36.1523 -		memset(p->swap_map, 0, maxpages * sizeof(short));
 36.1524 -		for (i=0; i<swap_header->info.nr_badpages; i++) {
 36.1525 -			int page = swap_header->info.badpages[i];
 36.1526 -			if (page <= 0 || page >= swap_header->info.last_page)
 36.1527 -				error = -EINVAL;
 36.1528 -			else
 36.1529 -				p->swap_map[page] = SWAP_MAP_BAD;
 36.1530 -		}
 36.1531 -		nr_good_pages = swap_header->info.last_page -
 36.1532 -				swap_header->info.nr_badpages -
 36.1533 -				1 /* header page */;
 36.1534 -		if (error) 
 36.1535 -			goto bad_swap;
 36.1536 -	}
 36.1537 -	
 36.1538 -	if (swapfilesize && maxpages > swapfilesize) {
 36.1539 -		printk(KERN_WARNING
 36.1540 -		       "Swap area shorter than signature indicates\n");
 36.1541 -		error = -EINVAL;
 36.1542 -		goto bad_swap;
 36.1543 -	}
 36.1544 -	if (!nr_good_pages) {
 36.1545 -		printk(KERN_WARNING "Empty swap-file\n");
 36.1546 -		error = -EINVAL;
 36.1547 -		goto bad_swap;
 36.1548 -	}
 36.1549 -	p->swap_map[0] = SWAP_MAP_BAD;
 36.1550 -	p->max = maxpages;
 36.1551 -	p->pages = nr_good_pages;
 36.1552 -
 36.1553 -	error = setup_swap_extents(p);
 36.1554 -	if (error)
 36.1555 -		goto bad_swap;
 36.1556 -
 36.1557 -	down(&swapon_sem);
 36.1558 -	swap_list_lock();
 36.1559 -	swap_device_lock(p);
 36.1560 -	p->flags = SWP_ACTIVE;
 36.1561 -	nr_swap_pages += nr_good_pages;
 36.1562 -	total_swap_pages += nr_good_pages;
 36.1563 -	printk(KERN_INFO "Adding %dk swap on %s.  Priority:%d extents:%d\n",
 36.1564 -		nr_good_pages<<(PAGE_SHIFT-10), name,
 36.1565 -		p->prio, p->nr_extents);
 36.1566 -
 36.1567 -	/* insert swap space into swap_list: */
 36.1568 -	prev = -1;
 36.1569 -	for (i = swap_list.head; i >= 0; i = swap_info[i].next) {
 36.1570 -		if (p->prio >= swap_info[i].prio) {
 36.1571 -			break;
 36.1572 -		}
 36.1573 -		prev = i;
 36.1574 -	}
 36.1575 -	p->next = i;
 36.1576 -	if (prev < 0) {
 36.1577 -		swap_list.head = swap_list.next = p - swap_info;
 36.1578 -	} else {
 36.1579 -		swap_info[prev].next = p - swap_info;
 36.1580 -	}
 36.1581 -	swap_device_unlock(p);
 36.1582 -	swap_list_unlock();
 36.1583 -	up(&swapon_sem);
 36.1584 -	error = 0;
 36.1585 -	goto out;
 36.1586 -bad_swap:
 36.1587 -	if (bdev) {
 36.1588 -		set_blocksize(bdev, p->old_block_size);
 36.1589 -		bd_release(bdev);
 36.1590 -	}
 36.1591 -bad_swap_2:
 36.1592 -	swap_list_lock();
 36.1593 -	swap_map = p->swap_map;
 36.1594 -	p->swap_file = NULL;
 36.1595 -	p->swap_map = NULL;
 36.1596 -	p->flags = 0;
 36.1597 -	if (!(swap_flags & SWAP_FLAG_PREFER))
 36.1598 -		++least_priority;
 36.1599 -	swap_list_unlock();
 36.1600 -	destroy_swap_extents(p);
 36.1601 -	if (swap_map)
 36.1602 -		vfree(swap_map);
 36.1603 -	if (swap_file)
 36.1604 -		filp_close(swap_file, NULL);
 36.1605 -out:
 36.1606 -	if (page && !IS_ERR(page)) {
 36.1607 -		kunmap(page);
 36.1608 -		page_cache_release(page);
 36.1609 -	}
 36.1610 -	if (name)
 36.1611 -		putname(name);
 36.1612 -	if (did_down) {
 36.1613 -		if (!error)
 36.1614 -			inode->i_flags |= S_SWAPFILE;
 36.1615 -		up(&inode->i_sem);
 36.1616 -	}
 36.1617 -	return error;
 36.1618 -}
 36.1619 -
 36.1620 -void si_swapinfo(struct sysinfo *val)
 36.1621 -{
 36.1622 -	unsigned int i;
 36.1623 -	unsigned long nr_to_be_unused = 0;
 36.1624 -
 36.1625 -	swap_list_lock();
 36.1626 -	for (i = 0; i < nr_swapfiles; i++) {
 36.1627 -		if (!(swap_info[i].flags & SWP_USED) ||
 36.1628 -		     (swap_info[i].flags & SWP_WRITEOK))
 36.1629 -			continue;
 36.1630 -		nr_to_be_unused += swap_info[i].inuse_pages;
 36.1631 -	}
 36.1632 -	val->freeswap = nr_swap_pages + nr_to_be_unused;
 36.1633 -	val->totalswap = total_swap_pages + nr_to_be_unused;
 36.1634 -	swap_list_unlock();
 36.1635 -}
 36.1636 -
 36.1637 -/*
 36.1638 - * Verify that a swap entry is valid and increment its swap map count.
 36.1639 - *
 36.1640 - * Note: if swap_map[] reaches SWAP_MAP_MAX the entries are treated as
 36.1641 - * "permanent", but will be reclaimed by the next swapoff.
 36.1642 - */
 36.1643 -int swap_duplicate(swp_entry_t entry)
 36.1644 -{
 36.1645 -	struct swap_info_struct * p;
 36.1646 -	unsigned long offset, type;
 36.1647 -	int result = 0;
 36.1648 -
 36.1649 -	type = swp_type(entry);
 36.1650 -	if (type >= nr_swapfiles)
 36.1651 -		goto bad_file;
 36.1652 -	p = type + swap_info;
 36.1653 -	offset = swp_offset(entry);
 36.1654 -
 36.1655 -	swap_device_lock(p);
 36.1656 -	if (offset < p->max && p->swap_map[offset]) {
 36.1657 -		if (p->swap_map[offset] < SWAP_MAP_MAX - 1) {
 36.1658 -			p->swap_map[offset]++;
 36.1659 -			result = 1;
 36.1660 -		} else if (p->swap_map[offset] <= SWAP_MAP_MAX) {
 36.1661 -			if (swap_overflow++ < 5)
 36.1662 -				printk(KERN_WARNING "swap_dup: swap entry overflow\n");
 36.1663 -			p->swap_map[offset] = SWAP_MAP_MAX;
 36.1664 -			result = 1;
 36.1665 -		}
 36.1666 -	}
 36.1667 -	swap_device_unlock(p);
 36.1668 -out:
 36.1669 -	return result;
 36.1670 -
 36.1671 -bad_file:
 36.1672 -	printk(KERN_ERR "swap_dup: %s%08lx\n", Bad_file, entry.val);
 36.1673 -	goto out;
 36.1674 -}
 36.1675 -
 36.1676 -struct swap_info_struct *
 36.1677 -get_swap_info_struct(unsigned type)
 36.1678 -{
 36.1679 -	return &swap_info[type];
 36.1680 -}
 36.1681 -
 36.1682 -/*
 36.1683 - * swap_device_lock prevents swap_map being freed. Don't grab an extra
 36.1684 - * reference on the swaphandle, it doesn't matter if it becomes unused.
 36.1685 - */
 36.1686 -int valid_swaphandles(swp_entry_t entry, unsigned long *offset)
 36.1687 -{
 36.1688 -	int ret = 0, i = 1 << page_cluster;
 36.1689 -	unsigned long toff;
 36.1690 -	struct swap_info_struct *swapdev = swp_type(entry) + swap_info;
 36.1691 -
 36.1692 -	if (!page_cluster)	/* no readahead */
 36.1693 -		return 0;
 36.1694 -	toff = (swp_offset(entry) >> page_cluster) << page_cluster;
 36.1695 -	if (!toff)		/* first page is swap header */
 36.1696 -		toff++, i--;
 36.1697 -	*offset = toff;
 36.1698 -
 36.1699 -	swap_device_lock(swapdev);
 36.1700 -	do {
 36.1701 -		/* Don't read-ahead past the end of the swap area */
 36.1702 -		if (toff >= swapdev->max)
 36.1703 -			break;
 36.1704 -		/* Don't read in free or bad pages */
 36.1705 -		if (!swapdev->swap_map[toff])
 36.1706 -			break;
 36.1707 -		if (swapdev->swap_map[toff] == SWAP_MAP_BAD)
 36.1708 -			break;
 36.1709 -		toff++;
 36.1710 -		ret++;
 36.1711 -	} while (--i);
 36.1712 -	swap_device_unlock(swapdev);
 36.1713 -	return ret;
 36.1714 -}
    37.1 --- a/xen/include/public/arch-x86_32.h	Thu Mar 24 16:48:36 2005 +0000
    37.2 +++ b/xen/include/public/arch-x86_32.h	Thu Mar 24 20:20:12 2005 +0000
    37.3 @@ -70,15 +70,9 @@
    37.4   * machine->physical mapping table starts at this address, read-only.
    37.5   */
    37.6  #define HYPERVISOR_VIRT_START (0xFC000000UL)
    37.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    37.8  #ifndef machine_to_phys_mapping
    37.9  #define machine_to_phys_mapping ((u32 *)HYPERVISOR_VIRT_START)
   37.10  #endif
   37.11 -#else /* CONFIG_XEN_SHADOW_MODE */
   37.12 -#ifndef __vms_machine_to_phys_mapping
   37.13 -#define __vms_machine_to_phys_mapping ((u32 *)HYPERVISOR_VIRT_START)
   37.14 -#endif
   37.15 -#endif /* CONFIG_XEN_SHADOW_MODE */
   37.16  
   37.17  #ifndef __ASSEMBLY__
   37.18