ia64/xen-unstable

changeset 4240:e113e917d480

bitkeeper revision 1.1236.32.15 (423ecae0WxP6Sqt4p2I9r8lcB4g8_Q)

Added #ifdef CONFIG_XEN_SHADOW_MODE to protect all of Christian's new code.

Signed-off-by: michael.fetterman@cl.cam.ac.uk
author mafetter@fleming.research
date Mon Mar 21 13:23:44 2005 +0000 (2005-03-21)
parents 2e28ec68d40b
children 688480d39d96
files 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/cpu/common.c 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/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/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 xen/include/public/arch-x86_32.h
line diff
     1.1 --- a/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Mon Mar 21 12:01:36 2005 +0000
     1.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/Kconfig	Mon Mar 21 13:23:44 2005 +0000
     1.3 @@ -115,9 +115,16 @@ config XEN_BLKDEV_TAP
     1.4  	  space.  Odds are that you want to say N here.
     1.5  
     1.6  config XEN_WRITABLE_PAGETABLES
     1.7 -	bool
     1.8 +	bool "writable page tables"
     1.9  	default y
    1.10  
    1.11 +config XEN_SHADOW_MODE
    1.12 +	bool "Fake shadow mode"
    1.13 +	default n
    1.14 +    help
    1.15 +      fakes out a shadow mode kernel
    1.16 +
    1.17 +
    1.18  config XEN_SCRUB_PAGES
    1.19  	bool "Scrub memory before freeing it to Xen"
    1.20  	default y
     2.1 --- a/linux-2.6.10-xen-sparse/arch/xen/configs/xen0_defconfig	Mon Mar 21 12:01:36 2005 +0000
     2.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/configs/xen0_defconfig	Mon Mar 21 13:23:44 2005 +0000
     2.3 @@ -20,6 +20,7 @@ CONFIG_XEN_NETDEV_FRONTEND=y
     2.4  # CONFIG_XEN_NETDEV_FRONTEND_PIPELINED_TRANSMITTER is not set
     2.5  # CONFIG_XEN_BLKDEV_TAP is not set
     2.6  CONFIG_XEN_WRITABLE_PAGETABLES=y
     2.7 +CONFIG_XEN_SHADOW_MODE=y
     2.8  CONFIG_XEN_SCRUB_PAGES=y
     2.9  CONFIG_X86=y
    2.10  # CONFIG_X86_64 is not set
     3.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Mar 21 12:01:36 2005 +0000
     3.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Mar 21 13:23:44 2005 +0000
     3.3 @@ -512,7 +512,11 @@ void __init cpu_gdt_init(struct Xgt_desc
     3.4  	for (va = gdt_descr->address, f = 0;
     3.5  	     va < gdt_descr->address + gdt_descr->size;
     3.6  	     va += PAGE_SIZE, f++) {
     3.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     3.8 +		frames[f] = virt_to_machine(va) >> PAGE_SHIFT;
     3.9 +#else /* CONFIG_XEN_SHADOW_MODE */
    3.10  		frames[f] = __vms_virt_to_machine(va) >> PAGE_SHIFT;
    3.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
    3.12  		make_page_readonly((void *)va);
    3.13  	}
    3.14  	flush_page_update_queue();
     4.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/ldt.c	Mon Mar 21 12:01:36 2005 +0000
     4.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/ldt.c	Mon Mar 21 13:23:44 2005 +0000
     4.3 @@ -61,10 +61,10 @@ static int alloc_ldt(mm_context_t *pc, i
     4.4  		cpumask_t mask;
     4.5  		preempt_disable();
     4.6  #endif
     4.7 -#if 0
     4.8 +#ifndef CONFIG_XEN_SHADOW_MODE
     4.9  		make_pages_readonly(pc->ldt, (pc->size * LDT_ENTRY_SIZE) /
    4.10  				    PAGE_SIZE);
    4.11 -#endif
    4.12 +#endif /* CONFIG_XEN_SHADOW_MODE */
    4.13  		load_LDT(pc);
    4.14  		flush_page_update_queue();
    4.15  #ifdef CONFIG_SMP
    4.16 @@ -75,10 +75,10 @@ static int alloc_ldt(mm_context_t *pc, i
    4.17  #endif
    4.18  	}
    4.19  	if (oldsize) {
    4.20 -#if 0
    4.21 +#ifndef CONFIG_XEN_SHADOW_MODE
    4.22  		make_pages_writable(oldldt, (oldsize * LDT_ENTRY_SIZE) /
    4.23  			PAGE_SIZE);
    4.24 -#endif
    4.25 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
    4.26  		flush_page_update_queue();
    4.27  		if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
    4.28  			vfree(oldldt);
    4.29 @@ -94,10 +94,10 @@ static inline int copy_ldt(mm_context_t 
    4.30  	if (err < 0)
    4.31  		return err;
    4.32  	memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
    4.33 -#if 0
    4.34 +#ifndef CONFIG_XEN_SHADOW_MODE
    4.35  	make_pages_readonly(new->ldt, (new->size * LDT_ENTRY_SIZE) /
    4.36  			    PAGE_SIZE);
    4.37 -#endif
    4.38 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
    4.39  	flush_page_update_queue();
    4.40  	return 0;
    4.41  }
    4.42 @@ -130,11 +130,11 @@ void destroy_context(struct mm_struct *m
    4.43  	if (mm->context.size) {
    4.44  		if (mm == current->active_mm)
    4.45  			clear_LDT();
    4.46 -#if 0
    4.47 +#ifndef CONFIG_XEN_SHADOW_MODE
    4.48  		make_pages_writable(mm->context.ldt, 
    4.49  				    (mm->context.size * LDT_ENTRY_SIZE) /
    4.50  				    PAGE_SIZE);
    4.51 -#endif
    4.52 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
    4.53  		flush_page_update_queue();
    4.54  		if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
    4.55  			vfree(mm->context.ldt);
    4.56 @@ -230,7 +230,11 @@ static int write_ldt(void __user * ptr, 
    4.57  	}
    4.58  
    4.59  	lp = (__u32 *) ((ldt_info.entry_number << 3) + (char *) mm->context.ldt);
    4.60 +#ifndef CONFIG_XEN_SHADOW_MODE
    4.61 +	mach_lp = arbitrary_virt_to_machine(lp);
    4.62 +#else /* CONFIG_XEN_SHADOW_MODE */
    4.63  	mach_lp = arbitrary_virt_to_phys(lp);
    4.64 +#endif /* CONFIG_XEN_SHADOW_MODE */
    4.65  
    4.66     	/* Allow LDTs to be cleared by the user. */
    4.67     	if (ldt_info.base_addr == 0 && ldt_info.limit == 0) {
     5.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Mon Mar 21 12:01:36 2005 +0000
     5.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/pci-dma.c	Mon Mar 21 13:23:44 2005 +0000
     5.3 @@ -30,8 +30,7 @@ struct dma_coherent_mem {
     5.4  static void
     5.5  xen_contig_memory(unsigned long vstart, unsigned int order)
     5.6  {
     5.7 -#define HACK
     5.8 -#ifndef HACK
     5.9 +#ifndef CONFIG_XEN_SHADOW_MODE
    5.10  	/*
    5.11  	 * Ensure multi-page extents are contiguous in machine memory.
    5.12  	 * This code could be cleaned up some, and the number of
    5.13 @@ -78,7 +77,7 @@ xen_contig_memory(unsigned long vstart, 
    5.14  	xen_tlb_flush();
    5.15  
    5.16          balloon_unlock(flags);
    5.17 -#endif
    5.18 +#endif /* CONFIG_XEN_SHADOW_MODE */
    5.19  }
    5.20  
    5.21  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
     6.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/process.c	Mon Mar 21 12:01:36 2005 +0000
     6.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/process.c	Mon Mar 21 13:23:44 2005 +0000
     6.3 @@ -514,17 +514,23 @@ struct task_struct fastcall * __switch_t
     6.4  	 * Load the per-thread Thread-Local Storage descriptor.
     6.5  	 * This is load_TLS(next, cpu) with multicalls.
     6.6  	 */
     6.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     6.8 +#define C_VIRT_TO_MACH virt_to_machine
     6.9 +#else /* CONFIG_XEN_SHADOW_MODE */
    6.10 +#define C_VIRT_TO_MACH virt_to_phys
    6.11 +#endif
    6.12  #define C(i) do {							    \
    6.13  	if (unlikely(next->tls_array[i].a != prev->tls_array[i].a ||	    \
    6.14  		     next->tls_array[i].b != prev->tls_array[i].b))	    \
    6.15  		queue_multicall3(__HYPERVISOR_update_descriptor,	    \
    6.16 -				 virt_to_phys(&get_cpu_gdt_table(cpu)       \
    6.17 +				 C_VIRT_TO_MACH(&get_cpu_gdt_table(cpu)     \
    6.18  						 [GDT_ENTRY_TLS_MIN + i]),  \
    6.19  				 ((u32 *)&next->tls_array[i])[0],	    \
    6.20  				 ((u32 *)&next->tls_array[i])[1]);	    \
    6.21  } while (0)
    6.22  	C(0); C(1); C(2);
    6.23  #undef C
    6.24 +#undef C_VIRT_TO_MACH
    6.25  
    6.26  	if (xen_start_info.flags & SIF_PRIVILEGED) {
    6.27  		op.cmd           = DOM0_IOPL;
     7.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c	Mon Mar 21 12:01:36 2005 +0000
     7.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/kernel/setup.c	Mon Mar 21 13:23:44 2005 +0000
     7.3 @@ -345,8 +345,13 @@ static void __init probe_roms(void)
     7.4  shared_info_t *HYPERVISOR_shared_info = (shared_info_t *)empty_zero_page;
     7.5  EXPORT_SYMBOL(HYPERVISOR_shared_info);
     7.6  
     7.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     7.8 +unsigned int *phys_to_machine_mapping, *pfn_to_mfn_frame_list;
     7.9 +EXPORT_SYMBOL(phys_to_machine_mapping);
    7.10 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.11  unsigned int *__vms_phys_to_machine_mapping, *__vms_pfn_to_mfn_frame_list;
    7.12  EXPORT_SYMBOL(__vms_phys_to_machine_mapping);
    7.13 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.14  
    7.15  DEFINE_PER_CPU(multicall_entry_t, multicall_list[8]);
    7.16  DEFINE_PER_CPU(int, nr_multicall_ents);
    7.17 @@ -1142,7 +1147,11 @@ static unsigned long __init setup_memory
    7.18  	}
    7.19  #endif
    7.20  
    7.21 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.22 +	phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
    7.23 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.24  	__vms_phys_to_machine_mapping = (unsigned int *)xen_start_info.mfn_list;
    7.25 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.26  
    7.27  	return max_low_pfn;
    7.28  }
    7.29 @@ -1437,11 +1446,23 @@ void __init setup_arch(char **cmdline_p)
    7.30  
    7.31  	/* Make sure we have a large enough P->M table. */
    7.32  	if (max_pfn > xen_start_info.nr_pages) {
    7.33 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.34 +		phys_to_machine_mapping = alloc_bootmem_low_pages(
    7.35 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.36  		__vms_phys_to_machine_mapping = alloc_bootmem_low_pages(
    7.37 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.38  			max_pfn * sizeof(unsigned long));
    7.39 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.40 +		memset(phys_to_machine_mapping, ~0,
    7.41 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.42  		memset(__vms_phys_to_machine_mapping, ~0,
    7.43 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.44  			max_pfn * sizeof(unsigned long));
    7.45 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.46 +		memcpy(phys_to_machine_mapping,
    7.47 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.48  		memcpy(__vms_phys_to_machine_mapping,
    7.49 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.50  			(unsigned long *)xen_start_info.mfn_list,
    7.51  			xen_start_info.nr_pages * sizeof(unsigned long));
    7.52  		free_bootmem(
    7.53 @@ -1450,14 +1471,27 @@ void __init setup_arch(char **cmdline_p)
    7.54  			sizeof(unsigned long))));
    7.55  	}
    7.56  
    7.57 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.58 +	pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
    7.59 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.60  	__vms_pfn_to_mfn_frame_list = alloc_bootmem_low_pages(PAGE_SIZE);
    7.61 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.62  	for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
    7.63  	{	
    7.64 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.65 +	     pfn_to_mfn_frame_list[j] = 
    7.66 +		  virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
    7.67 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.68  	     __vms_pfn_to_mfn_frame_list[j] = 
    7.69  		  __vms_virt_to_machine(&__vms_phys_to_machine_mapping[i]) >> PAGE_SHIFT;
    7.70 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.71  	}
    7.72  	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
    7.73 +#ifndef CONFIG_XEN_SHADOW_MODE
    7.74 +	     virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
    7.75 +#else /* CONFIG_XEN_SHADOW_MODE */
    7.76  	     __vms_virt_to_machine(__vms_pfn_to_mfn_frame_list) >> PAGE_SHIFT;
    7.77 +#endif /* CONFIG_XEN_SHADOW_MODE */
    7.78  
    7.79  
    7.80  	/*
     8.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/fault.c	Mon Mar 21 12:01:36 2005 +0000
     8.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/fault.c	Mon Mar 21 13:23:44 2005 +0000
     8.3 @@ -458,8 +458,13 @@ no_context:
     8.4  	printk("%08lx\n", regs->eip);
     8.5  	page = ((unsigned long *) per_cpu(cur_pgd, smp_processor_id()))
     8.6  	    [address >> 22];
     8.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     8.8 +	printk(KERN_ALERT "*pde = ma %08lx pa %08lx\n", page,
     8.9 +	       machine_to_phys(page));
    8.10 +#else /* CONFIG_XEN_SHADOW_MODE */
    8.11  	printk(KERN_ALERT "*pde = ma %08lx pa %08lx\n",
    8.12  	       __vms_phys_to_machine(page), page);
    8.13 +#endif /* CONFIG_XEN_SHADOW_MODE */
    8.14  	/*
    8.15  	 * We must not directly access the pte in the highpte
    8.16  	 * case, the page table might be allocated in highmem.
    8.17 @@ -470,9 +475,17 @@ no_context:
    8.18  	if (page & 1) {
    8.19  		page &= PAGE_MASK;
    8.20  		address &= 0x003ff000;
    8.21 +#ifndef CONFIG_XEN_SHADOW_MODE
    8.22 +		page = machine_to_phys(page);
    8.23 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
    8.24  		page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT];
    8.25 +#ifndef CONFIG_XEN_SHADOW_MODE
    8.26 +		printk(KERN_ALERT "*pte = ma %08lx pa %08lx\n", page,
    8.27 +		       machine_to_phys(page));
    8.28 +#else /* CONFIG_XEN_SHADOW_MODE */
    8.29  		printk(KERN_ALERT "*pte = ma %08lx pa %08lx\n",
    8.30  		       __vms_phys_to_machine(page), page);
    8.31 +#endif /* CONFIG_XEN_SHADOW_MODE */
    8.32  	}
    8.33  #endif
    8.34  	show_trace(NULL, (unsigned long *)&regs[1]);
     9.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Mon Mar 21 12:01:36 2005 +0000
     9.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/hypervisor.c	Mon Mar 21 13:23:44 2005 +0000
     9.3 @@ -56,7 +56,11 @@ static spinlock_t update_lock = SPIN_LOC
     9.4  #ifdef CONFIG_SMP
     9.5  #define QUEUE_SIZE 1
     9.6  #else
     9.7 +#ifndef CONFIG_XEN_SHADOW_MODE
     9.8 +#define QUEUE_SIZE 128
     9.9 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.10  #define QUEUE_SIZE 1
    9.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.12  #endif
    9.13  #endif
    9.14  
    9.15 @@ -125,12 +129,36 @@ static inline void increment_index_and_f
    9.16  
    9.17  void queue_l1_entry_update(pte_t *ptr, unsigned long val)
    9.18  {
    9.19 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.20 +    int cpu = smp_processor_id();
    9.21 +    int idx;
    9.22 +    unsigned long flags;
    9.23 +    spin_lock_irqsave(&update_lock, flags);
    9.24 +    idx = per_cpu(mmu_update_queue_idx, cpu);
    9.25 +    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
    9.26 +    per_cpu(update_queue[idx], cpu).val = val;
    9.27 +    increment_index();
    9.28 +    spin_unlock_irqrestore(&update_lock, flags);
    9.29 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.30      set_pte(ptr, __pte(val));
    9.31 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.32  }
    9.33  
    9.34  void queue_l2_entry_update(pmd_t *ptr, unsigned long val)
    9.35  {
    9.36 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.37 +    int cpu = smp_processor_id();
    9.38 +    int idx;
    9.39 +    unsigned long flags;
    9.40 +    spin_lock_irqsave(&update_lock, flags);
    9.41 +    idx = per_cpu(mmu_update_queue_idx, cpu);
    9.42 +    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
    9.43 +    per_cpu(update_queue[idx], cpu).val = val;
    9.44 +    increment_index();
    9.45 +    spin_unlock_irqrestore(&update_lock, flags);
    9.46 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.47      set_pmd(ptr, __pmd(val));
    9.48 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.49  }
    9.50  
    9.51  void queue_pt_switch(unsigned long ptr)
    9.52 @@ -140,7 +168,11 @@ void queue_pt_switch(unsigned long ptr)
    9.53      unsigned long flags;
    9.54      spin_lock_irqsave(&update_lock, flags);
    9.55      idx = per_cpu(mmu_update_queue_idx, cpu);
    9.56 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.57 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
    9.58 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.59      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
    9.60 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.61      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
    9.62      per_cpu(update_queue[idx], cpu).val  = MMUEXT_NEW_BASEPTR;
    9.63      increment_index();
    9.64 @@ -174,56 +206,88 @@ void queue_invlpg(unsigned long ptr)
    9.65      spin_unlock_irqrestore(&update_lock, flags);
    9.66  }
    9.67  
    9.68 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.69 +void queue_pgd_pin(unsigned long ptr)
    9.70 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.71  void __vms_queue_pgd_pin(unsigned long ptr)
    9.72 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.73  {
    9.74      int cpu = smp_processor_id();
    9.75      int idx;
    9.76      unsigned long flags;
    9.77      spin_lock_irqsave(&update_lock, flags);
    9.78      idx = per_cpu(mmu_update_queue_idx, cpu);
    9.79 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.80 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
    9.81 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.82      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
    9.83 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.84      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
    9.85      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L2_TABLE;
    9.86      increment_index();
    9.87      spin_unlock_irqrestore(&update_lock, flags);
    9.88  }
    9.89  
    9.90 +#ifndef CONFIG_XEN_SHADOW_MODE
    9.91 +void queue_pgd_unpin(unsigned long ptr)
    9.92 +#else /* CONFIG_XEN_SHADOW_MODE */
    9.93  void __vms_queue_pgd_unpin(unsigned long ptr)
    9.94 +#endif /* CONFIG_XEN_SHADOW_MODE */
    9.95  {
    9.96      int cpu = smp_processor_id();
    9.97      int idx;
    9.98      unsigned long flags;
    9.99      spin_lock_irqsave(&update_lock, flags);
   9.100      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.101 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.102 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.103 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.104      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.105 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.106      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.107      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
   9.108      increment_index();
   9.109      spin_unlock_irqrestore(&update_lock, flags);
   9.110  }
   9.111  
   9.112 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.113 +void queue_pte_pin(unsigned long ptr)
   9.114 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.115  void __vms_queue_pte_pin(unsigned long ptr)
   9.116 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.117  {
   9.118      int cpu = smp_processor_id();
   9.119      int idx;
   9.120      unsigned long flags;
   9.121      spin_lock_irqsave(&update_lock, flags);
   9.122      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.123 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.124 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.125 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.126      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.127 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.128      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.129      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L1_TABLE;
   9.130      increment_index();
   9.131      spin_unlock_irqrestore(&update_lock, flags);
   9.132  }
   9.133  
   9.134 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.135 +void queue_pte_unpin(unsigned long ptr)
   9.136 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.137  void __vms_queue_pte_unpin(unsigned long ptr)
   9.138 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.139  {
   9.140      int cpu = smp_processor_id();
   9.141      int idx;
   9.142      unsigned long flags;
   9.143      spin_lock_irqsave(&update_lock, flags);
   9.144      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.145 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.146 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.147 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.148      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.149 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.150      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.151      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
   9.152      increment_index();
   9.153 @@ -259,12 +323,36 @@ void queue_machphys_update(unsigned long
   9.154  /* queue and flush versions of the above */
   9.155  void xen_l1_entry_update(pte_t *ptr, unsigned long val)
   9.156  {
   9.157 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.158 +    int cpu = smp_processor_id();
   9.159 +    int idx;
   9.160 +    unsigned long flags;
   9.161 +    spin_lock_irqsave(&update_lock, flags);
   9.162 +    idx = per_cpu(mmu_update_queue_idx, cpu);
   9.163 +    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
   9.164 +    per_cpu(update_queue[idx], cpu).val = val;
   9.165 +    increment_index_and_flush();
   9.166 +    spin_unlock_irqrestore(&update_lock, flags);
   9.167 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.168      set_pte(ptr, __pte(val));
   9.169 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.170  }
   9.171  
   9.172  void xen_l2_entry_update(pmd_t *ptr, unsigned long val)
   9.173  {
   9.174 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.175 +    int cpu = smp_processor_id();
   9.176 +    int idx;
   9.177 +    unsigned long flags;
   9.178 +    spin_lock_irqsave(&update_lock, flags);
   9.179 +    idx = per_cpu(mmu_update_queue_idx, cpu);
   9.180 +    per_cpu(update_queue[idx], cpu).ptr = virt_to_machine(ptr);
   9.181 +    per_cpu(update_queue[idx], cpu).val = val;
   9.182 +    increment_index_and_flush();
   9.183 +    spin_unlock_irqrestore(&update_lock, flags);
   9.184 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.185      set_pmd(ptr, __pmd(val));
   9.186 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.187  }
   9.188  
   9.189  void xen_pt_switch(unsigned long ptr)
   9.190 @@ -274,7 +362,11 @@ void xen_pt_switch(unsigned long ptr)
   9.191      unsigned long flags;
   9.192      spin_lock_irqsave(&update_lock, flags);
   9.193      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.194 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.195 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.196 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.197      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.198 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.199      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.200      per_cpu(update_queue[idx], cpu).val  = MMUEXT_NEW_BASEPTR;
   9.201      increment_index_and_flush();
   9.202 @@ -308,56 +400,88 @@ void xen_invlpg(unsigned long ptr)
   9.203      spin_unlock_irqrestore(&update_lock, flags);
   9.204  }
   9.205  
   9.206 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.207 +void xen_pgd_pin(unsigned long ptr)
   9.208 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.209  void __vms_xen_pgd_pin(unsigned long ptr)
   9.210 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.211  {
   9.212      int cpu = smp_processor_id();
   9.213      int idx;
   9.214      unsigned long flags;
   9.215      spin_lock_irqsave(&update_lock, flags);
   9.216      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.217 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.218 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.219 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.220      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.221 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.222      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.223      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L2_TABLE;
   9.224      increment_index_and_flush();
   9.225      spin_unlock_irqrestore(&update_lock, flags);
   9.226  }
   9.227  
   9.228 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.229 +void xen_pgd_unpin(unsigned long ptr)
   9.230 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.231  void __vms_xen_pgd_unpin(unsigned long ptr)
   9.232 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.233  {
   9.234      int cpu = smp_processor_id();
   9.235      int idx;
   9.236      unsigned long flags;
   9.237      spin_lock_irqsave(&update_lock, flags);
   9.238      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.239 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.240 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.241 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.242      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.243 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.244      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.245      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
   9.246      increment_index_and_flush();
   9.247      spin_unlock_irqrestore(&update_lock, flags);
   9.248  }
   9.249  
   9.250 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.251 +void xen_pte_pin(unsigned long ptr)
   9.252 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.253  void __vms_xen_pte_pin(unsigned long ptr)
   9.254 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.255  {
   9.256      int cpu = smp_processor_id();
   9.257      int idx;
   9.258      unsigned long flags;
   9.259      spin_lock_irqsave(&update_lock, flags);
   9.260      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.261 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.262 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.263 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.264      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.265 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.266      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.267      per_cpu(update_queue[idx], cpu).val  = MMUEXT_PIN_L1_TABLE;
   9.268      increment_index_and_flush();
   9.269      spin_unlock_irqrestore(&update_lock, flags);
   9.270  }
   9.271  
   9.272 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.273 +void xen_pte_unpin(unsigned long ptr)
   9.274 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.275  void __vms_xen_pte_unpin(unsigned long ptr)
   9.276 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.277  {
   9.278      int cpu = smp_processor_id();
   9.279      int idx;
   9.280      unsigned long flags;
   9.281      spin_lock_irqsave(&update_lock, flags);
   9.282      idx = per_cpu(mmu_update_queue_idx, cpu);
   9.283 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.284 +    per_cpu(update_queue[idx], cpu).ptr  = phys_to_machine(ptr);
   9.285 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.286      per_cpu(update_queue[idx], cpu).ptr  = __vms_phys_to_machine(ptr);
   9.287 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.288      per_cpu(update_queue[idx], cpu).ptr |= MMU_EXTENDED_COMMAND;
   9.289      per_cpu(update_queue[idx], cpu).val  = MMUEXT_UNPIN_TABLE;
   9.290      increment_index_and_flush();
   9.291 @@ -419,7 +543,11 @@ unsigned long allocate_empty_lowmem_regi
   9.292          pte = pte_offset_kernel(pmd, (vstart + (i*PAGE_SIZE))); 
   9.293          pfn_array[i] = pte->pte_low >> PAGE_SHIFT;
   9.294          queue_l1_entry_update(pte, 0);
   9.295 +#ifndef CONFIG_XEN_SHADOW_MODE
   9.296 +        phys_to_machine_mapping[__pa(vstart)>>PAGE_SHIFT] = INVALID_P2M_ENTRY;
   9.297 +#else /* CONFIG_XEN_SHADOW_MODE */
   9.298          __vms_phys_to_machine_mapping[__pa(vstart)>>PAGE_SHIFT] = INVALID_P2M_ENTRY;
   9.299 +#endif /* CONFIG_XEN_SHADOW_MODE */
   9.300      }
   9.301  
   9.302      /* Flush updates through and flush the TLB. */
    10.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/init.c	Mon Mar 21 12:01:36 2005 +0000
    10.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/init.c	Mon Mar 21 13:23:44 2005 +0000
    10.3 @@ -77,7 +77,9 @@ static pte_t * __init one_page_table_ini
    10.4  {
    10.5  	if (pmd_none(*pmd)) {
    10.6  		pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
    10.7 -		//make_page_readonly(page_table);
    10.8 +#ifndef CONFIG_XEN_SHADOW_MODE
    10.9 +		make_page_readonly(page_table);
   10.10 +#endif /* CONFIG_XEN_SHADOW_MODE */
   10.11  		set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
   10.12  		if (page_table != pte_offset_kernel(pmd, 0))
   10.13  			BUG();	
   10.14 @@ -349,9 +351,18 @@ static void __init pagetable_init (void)
   10.15  	 * it. We clean up by write-enabling and then freeing the old page dir.
   10.16  	 */
   10.17  	memcpy(new_pgd, old_pgd, PTRS_PER_PGD_NO_HV*sizeof(pgd_t));
   10.18 +#ifndef CONFIG_XEN_SHADOW_MODE
   10.19 +	make_page_readonly(new_pgd);
   10.20 +	queue_pgd_pin(__pa(new_pgd));
   10.21 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   10.22  	load_cr3(new_pgd);
   10.23 +#ifndef CONFIG_XEN_SHADOW_MODE
   10.24 +	queue_pgd_unpin(__pa(old_pgd));
   10.25 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   10.26  	__flush_tlb_all(); /* implicit flush */
   10.27 -	//make_page_writable(old_pgd);
   10.28 +#ifndef CONFIG_XEN_SHADOW_MODE
   10.29 +	make_page_writable(old_pgd);
   10.30 +#endif /* CONFIG_XEN_SHADOW_MODE */
   10.31  	flush_page_update_queue();
   10.32  	free_bootmem(__pa(old_pgd), PAGE_SIZE);
   10.33  
   10.34 @@ -559,19 +570,31 @@ void __init paging_init(void)
   10.35  
   10.36  	/* Switch to the real shared_info page, and clear the dummy page. */
   10.37  	flush_page_update_queue();
   10.38 +#ifndef CONFIG_XEN_SHADOW_MODE
   10.39 +	set_fixmap_ma(FIX_SHARED_INFO, xen_start_info.shared_info);
   10.40 +#else /* CONFIG_XEN_SHADOW_MODE */
   10.41          printk("xen_start_info.shared_info=%x\n", xen_start_info.shared_info);
   10.42  	set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
   10.43 +#endif /* CONFIG_XEN_SHADOW_MODE */
   10.44  	HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   10.45  	memset(empty_zero_page, 0, sizeof(empty_zero_page));
   10.46  
   10.47  #ifdef CONFIG_XEN_PHYSDEV_ACCESS
   10.48  	/* Setup mapping of lower 1st MB */
   10.49  	for (i = 0; i < NR_FIX_ISAMAPS; i++)
   10.50 +#ifndef CONFIG_XEN_SHADOW_MODE
   10.51 +		if (xen_start_info.flags & SIF_PRIVILEGED)
   10.52 +			set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
   10.53 +		else
   10.54 +			set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i,
   10.55 +					 virt_to_machine(empty_zero_page));
   10.56 +#else /* CONFIG_XEN_SHADOW_MODE */
   10.57  		if (xen_start_info.flags & SIF_PRIVILEGED)
   10.58  			__vms_set_fixmap_ma(FIX_ISAMAP_BEGIN - i, i * PAGE_SIZE);
   10.59  		else
   10.60  			__vms_set_fixmap_ma_ro(FIX_ISAMAP_BEGIN - i,
   10.61  					 __vms_virt_to_machine(empty_zero_page));
   10.62 +#endif /* CONFIG_XEN_SHADOW_MODE */
   10.63  #endif
   10.64  }
   10.65  
    11.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Mar 21 12:01:36 2005 +0000
    11.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/ioremap.c	Mon Mar 21 13:23:44 2005 +0000
    11.3 @@ -56,8 +56,14 @@ void __init bt_iounmap(void *addr, unsig
    11.4  static inline int is_local_lowmem(unsigned long address)
    11.5  {
    11.6  	extern unsigned long max_low_pfn;
    11.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    11.8 +	unsigned long mfn = address >> PAGE_SHIFT;
    11.9 +	unsigned long pfn = mfn_to_pfn(mfn);
   11.10 +	return ((pfn < max_low_pfn) && (pfn_to_mfn(pfn) == mfn));
   11.11 +#else /* CONFIG_XEN_SHADOW_MODE */
   11.12  	unsigned long pfn = address >> PAGE_SHIFT;
   11.13  	return (pfn < max_low_pfn);
   11.14 +#endif /* CONFIG_XEN_SHADOW_MODE */
   11.15  }
   11.16  
   11.17  /*
   11.18 @@ -96,7 +102,7 @@ void __iomem * __ioremap(unsigned long p
   11.19  	/*
   11.20  	 * Don't allow anybody to remap normal RAM that we're using..
   11.21  	 */
   11.22 -#if 0
   11.23 +#ifndef CONFIG_XEN_SHADOW_MODE
   11.24  	if (is_local_lowmem(phys_addr)) {
   11.25  		char *t_addr, *t_end;
   11.26  		struct page *page;
   11.27 @@ -110,7 +116,7 @@ void __iomem * __ioremap(unsigned long p
   11.28  
   11.29  		domid = DOMID_LOCAL;
   11.30  	}
   11.31 -#endif
   11.32 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   11.33  
   11.34  	/*
   11.35  	 * Mappings have to be page-aligned
   11.36 @@ -256,7 +262,11 @@ void __init *bt_ioremap(unsigned long ph
   11.37  	 */
   11.38  	idx = FIX_BTMAP_BEGIN;
   11.39  	while (nrpages > 0) {
   11.40 +#ifndef CONFIG_XEN_SHADOW_MODE
   11.41 +		set_fixmap_ma(idx, phys_addr);
   11.42 +#else /* CONFIG_XEN_SHADOW_MODE */
   11.43  		__vms_set_fixmap_ma(idx, phys_addr);
   11.44 +#endif /* CONFIG_XEN_SHADOW_MODE */
   11.45  		phys_addr += PAGE_SIZE;
   11.46  		--idx;
   11.47  		--nrpages;
   11.48 @@ -313,7 +323,11 @@ static inline void direct_remap_area_pte
   11.49  		BUG();
   11.50  
   11.51  	do {
   11.52 +#ifndef CONFIG_XEN_SHADOW_MODE
   11.53 +		(*v)->ptr = virt_to_machine(pte);
   11.54 +#else /* CONFIG_XEN_SHADOW_MODE */
   11.55  		(*v)->ptr = __vms_virt_to_machine(pte);
   11.56 +#endif /* CONFIG_XEN_SHADOW_MODE */
   11.57  		(*v)++;
   11.58  		address += PAGE_SIZE;
   11.59  		pte++;
   11.60 @@ -387,12 +401,14 @@ int direct_remap_area_pages(struct mm_st
   11.61  	mmu_update_t u[MAX_DIRECTMAP_MMU_QUEUE], *w, *v;
   11.62  
   11.63  	v = w = &u[0];
   11.64 -	if (0 && domid != DOMID_LOCAL) {
   11.65 +#ifndef CONFIG_XEN_SHADOW_MODE
   11.66 +	if (domid != DOMID_LOCAL) {
   11.67  		u[0].ptr  = MMU_EXTENDED_COMMAND;
   11.68  		u[0].val  = MMUEXT_SET_FOREIGNDOM;
   11.69  		u[0].val |= (unsigned long)domid << 16;
   11.70  		v = w = &u[1];
   11.71  	}
   11.72 +#endif /* CONFIG_XEN_SHADOW_MODE */
   11.73  
   11.74  	start_address = address;
   11.75  
   11.76 @@ -416,6 +432,10 @@ int direct_remap_area_pages(struct mm_st
   11.77  		 * Fill in the machine address: PTE ptr is done later by
   11.78  		 * __direct_remap_area_pages(). 
   11.79  		 */
   11.80 +#ifndef CONFIG_XEN_SHADOW_MODE
   11.81 +		v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot);
   11.82 +
   11.83 +#else /* CONFIG_XEN_SHADOW_MODE */
   11.84          {
   11.85              mmu_update_t update;
   11.86              int success = 0;
   11.87 @@ -429,6 +449,7 @@ int direct_remap_area_pages(struct mm_st
   11.88                  
   11.89  		v->val = (ppfn << PAGE_SHIFT) | pgprot_val(prot);
   11.90          }
   11.91 +#endif /* CONFIG_XEN_SHADOW_MODE */
   11.92  		machine_addr += PAGE_SIZE;
   11.93  		address += PAGE_SIZE; 
   11.94  		v++;
    12.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pageattr.c	Mon Mar 21 12:01:36 2005 +0000
    12.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pageattr.c	Mon Mar 21 13:23:44 2005 +0000
    12.3 @@ -119,7 +119,11 @@ static int
    12.4  		if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
    12.5  			pte_t old = *kpte;
    12.6  			pte_t standard = mk_pte(page, PAGE_KERNEL); 
    12.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    12.8 +			set_pte_batched(kpte, mk_pte(page, prot)); 
    12.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   12.10  			set_pte_atomic(kpte, mk_pte(page, prot)); 
   12.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   12.12  			if (pte_same(old,standard))
   12.13  				get_page(kpte_page);
   12.14  		} else {
   12.15 @@ -130,7 +134,11 @@ static int
   12.16  			set_pmd_pte(kpte,address,mk_pte(split, PAGE_KERNEL));
   12.17  		}	
   12.18  	} else if ((pte_val(*kpte) & _PAGE_PSE) == 0) { 
   12.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   12.20 +		set_pte_batched(kpte, mk_pte(page, PAGE_KERNEL));
   12.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   12.22  		set_pte_atomic(kpte, mk_pte(page, PAGE_KERNEL));
   12.23 +#endif /* CONFIG_XEN_SHADOW_MODE */
   12.24  		__put_page(kpte_page);
   12.25  	}
   12.26  
   12.27 @@ -171,6 +179,9 @@ int change_page_attr(struct page *page, 
   12.28  		if (err) 
   12.29  			break; 
   12.30  	} 	
   12.31 +#ifndef CONFIG_XEN_SHADOW_MODE
   12.32 +	flush_page_update_queue();
   12.33 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   12.34  	spin_unlock_irqrestore(&cpa_lock, flags);
   12.35  	return err;
   12.36  }
    13.1 --- a/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Mar 21 12:01:36 2005 +0000
    13.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Mar 21 13:23:44 2005 +0000
    13.3 @@ -93,7 +93,11 @@ static void set_pte_pfn(unsigned long va
    13.4   * Associate a virtual page frame with a given physical page frame 
    13.5   * and protection flags for that frame.
    13.6   */ 
    13.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    13.8 +static void set_pte_pfn_ma(unsigned long vaddr, unsigned long pfn,
    13.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   13.10  static void __vms_set_pte_pfn_ma(unsigned long vaddr, unsigned long pfn,
   13.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   13.12  			   pgprot_t flags)
   13.13  {
   13.14  	pgd_t *pgd;
   13.15 @@ -112,6 +116,9 @@ static void __vms_set_pte_pfn_ma(unsigne
   13.16  	}
   13.17  	pte = pte_offset_kernel(pmd, vaddr);
   13.18  	/* <pfn,flags> stored as-is, to permit clearing entries */
   13.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.20 +	set_pte(pte, pfn_pte_ma(pfn, flags));
   13.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   13.22          {
   13.23              mmu_update_t update;
   13.24              int success = 0;
   13.25 @@ -124,6 +131,7 @@ static void __vms_set_pte_pfn_ma(unsigne
   13.26                  BUG();
   13.27              set_pte(pte, pfn_pte(ppfn, flags));
   13.28          }
   13.29 +#endif /* CONFIG_XEN_SHADOW_MODE */
   13.30  
   13.31  	/*
   13.32  	 * It's enough to flush this one mapping.
   13.33 @@ -176,7 +184,11 @@ void __set_fixmap (enum fixed_addresses 
   13.34  	set_pte_pfn(address, phys >> PAGE_SHIFT, flags);
   13.35  }
   13.36  
   13.37 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.38 +void __set_fixmap_ma (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
   13.39 +#else /* CONFIG_XEN_SHADOW_MODE */
   13.40  void __vms___set_fixmap_ma (enum fixed_addresses idx, unsigned long phys, pgprot_t flags)
   13.41 +#endif /* CONFIG_XEN_SHADOW_MODE */
   13.42  {
   13.43  	unsigned long address = __fix_to_virt(idx);
   13.44  
   13.45 @@ -184,7 +196,11 @@ void __vms___set_fixmap_ma (enum fixed_a
   13.46  		BUG();
   13.47  		return;
   13.48  	}
   13.49 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.50 +	set_pte_pfn_ma(address, phys >> PAGE_SHIFT, flags);
   13.51 +#else /* CONFIG_XEN_SHADOW_MODE */
   13.52  	__vms_set_pte_pfn_ma(address, phys >> PAGE_SHIFT, flags);
   13.53 +#endif /* CONFIG_XEN_SHADOW_MODE */
   13.54  }
   13.55  
   13.56  pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
   13.57 @@ -192,6 +208,10 @@ pte_t *pte_alloc_one_kernel(struct mm_st
   13.58  	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
   13.59  	if (pte) {
   13.60  		clear_page(pte);
   13.61 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.62 +		make_page_readonly(pte);
   13.63 +		xen_flush_page_update_queue();
   13.64 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   13.65  	}
   13.66  	return pte;
   13.67  }
   13.68 @@ -203,6 +223,11 @@ void pte_ctor(void *pte, kmem_cache_t *c
   13.69  	set_page_count(page, 1);
   13.70  
   13.71  	clear_page(pte);
   13.72 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.73 +	make_page_readonly(pte);
   13.74 +	queue_pte_pin(__pa(pte));
   13.75 +	flush_page_update_queue();
   13.76 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   13.77  }
   13.78  
   13.79  void pte_dtor(void *pte, kmem_cache_t *cache, unsigned long unused)
   13.80 @@ -210,6 +235,11 @@ void pte_dtor(void *pte, kmem_cache_t *c
   13.81  	struct page *page = virt_to_page(pte);
   13.82  	ClearPageForeign(page);
   13.83  
   13.84 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.85 +	queue_pte_unpin(__pa(pte));
   13.86 +	make_page_writable(pte);
   13.87 +	flush_page_update_queue();
   13.88 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   13.89  }
   13.90  
   13.91  struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
   13.92 @@ -242,7 +272,11 @@ void pte_free(struct page *pte)
   13.93  	if (pte < highmem_start_page)
   13.94  #endif
   13.95  		kmem_cache_free(pte_cache,
   13.96 +#ifndef CONFIG_XEN_SHADOW_MODE
   13.97 +				phys_to_virt(page_to_pseudophys(pte)));
   13.98 +#else /* CONFIG_XEN_SHADOW_MODE */
   13.99  				phys_to_virt(__vms_page_to_pseudophys(pte)));
  13.100 +#endif /* CONFIG_XEN_SHADOW_MODE */
  13.101  #ifdef CONFIG_HIGHPTE
  13.102  	else
  13.103  		__free_page(pte);
  13.104 @@ -307,7 +341,13 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
  13.105  	spin_unlock_irqrestore(&pgd_lock, flags);
  13.106  	memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
  13.107   out:
  13.108 +#ifndef CONFIG_XEN_SHADOW_MODE
  13.109 +	make_page_readonly(pgd);
  13.110 +	queue_pgd_pin(__pa(pgd));
  13.111 +	flush_page_update_queue();
  13.112 +#else /* CONFIG_XEN_SHADOW_MODE */
  13.113  	;
  13.114 +#endif /* CONFIG_XEN_SHADOW_MODE */
  13.115  }
  13.116  
  13.117  /* never called when PTRS_PER_PMD > 1 */
  13.118 @@ -315,6 +355,12 @@ void pgd_dtor(void *pgd, kmem_cache_t *c
  13.119  {
  13.120  	unsigned long flags; /* can be called from interrupt context */
  13.121  
  13.122 +#ifndef CONFIG_XEN_SHADOW_MODE
  13.123 +	queue_pgd_unpin(__pa(pgd));
  13.124 +	make_page_writable(pgd);
  13.125 +	flush_page_update_queue();
  13.126 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
  13.127 +
  13.128  	if (PTRS_PER_PMD > 1)
  13.129  		return;
  13.130  
  13.131 @@ -380,17 +426,17 @@ void make_page_readonly(void *va)
  13.132  	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
  13.133  	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
  13.134  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
  13.135 -#if 0
  13.136 +#ifndef CONFIG_XEN_SHADOW_MODE
  13.137  	if ( (unsigned long)va >= (unsigned long)high_memory )
  13.138  	{
  13.139  		unsigned long phys;
  13.140 -		phys = __vms_machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  13.141 +		phys = machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  13.142  #ifdef CONFIG_HIGHMEM
  13.143  		if ( (phys >> PAGE_SHIFT) < highstart_pfn )
  13.144  #endif
  13.145  			make_lowmem_page_readonly(phys_to_virt(phys));
  13.146  	}
  13.147 -#endif
  13.148 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
  13.149  }
  13.150  
  13.151  void make_page_writable(void *va)
  13.152 @@ -402,7 +448,11 @@ void make_page_writable(void *va)
  13.153  	if ( (unsigned long)va >= (unsigned long)high_memory )
  13.154  	{
  13.155  		unsigned long phys;
  13.156 +#ifndef CONFIG_XEN_SHADOW_MODE
  13.157 +		phys = machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  13.158 +#else /* CONFIG_XEN_SHADOW_MODE */
  13.159  		phys = __vms_machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
  13.160 +#endif /* CONFIG_XEN_SHADOW_MODE */
  13.161  #ifdef CONFIG_HIGHMEM
  13.162  		if ( (phys >> PAGE_SHIFT) < highstart_pfn )
  13.163  #endif
    14.1 --- a/linux-2.6.10-xen-sparse/arch/xen/kernel/reboot.c	Mon Mar 21 12:01:36 2005 +0000
    14.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/kernel/reboot.c	Mon Mar 21 13:23:44 2005 +0000
    14.3 @@ -80,7 +80,11 @@ static void __do_suspend(void)
    14.4      extern void time_suspend(void);
    14.5      extern void time_resume(void);
    14.6      extern unsigned long max_pfn;
    14.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    14.8 +    extern unsigned int *pfn_to_mfn_frame_list;
    14.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   14.10      extern unsigned int *__vms_pfn_to_mfn_frame_list;
   14.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   14.12  
   14.13      suspend_record = (suspend_record_t *)__get_free_page(GFP_KERNEL);
   14.14      if ( suspend_record == NULL )
   14.15 @@ -105,7 +109,11 @@ static void __do_suspend(void)
   14.16  
   14.17      memcpy(&suspend_record->resume_info, &xen_start_info, sizeof(xen_start_info));
   14.18  
   14.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   14.20 +    HYPERVISOR_suspend(virt_to_machine(suspend_record) >> PAGE_SHIFT);
   14.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   14.22      HYPERVISOR_suspend(__vms_virt_to_machine(suspend_record) >> PAGE_SHIFT);
   14.23 +#endif /* CONFIG_XEN_SHADOW_MODE */
   14.24  
   14.25      HYPERVISOR_vm_assist(VMASST_CMD_enable,
   14.26  			 VMASST_TYPE_4gb_segments);
   14.27 @@ -118,7 +126,11 @@ static void __do_suspend(void)
   14.28  
   14.29      memcpy(&xen_start_info, &suspend_record->resume_info, sizeof(xen_start_info));
   14.30  
   14.31 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && !defined(CONFIG_XEN_SHADOW_MODE)
   14.32 +    set_fixmap_ma(FIX_SHARED_INFO, xen_start_info.shared_info);
   14.33 +#else
   14.34      set_fixmap(FIX_SHARED_INFO, xen_start_info.shared_info);
   14.35 +#endif
   14.36  
   14.37      HYPERVISOR_shared_info = (shared_info_t *)fix_to_virt(FIX_SHARED_INFO);
   14.38  
   14.39 @@ -126,11 +138,20 @@ static void __do_suspend(void)
   14.40  
   14.41      for ( i=0, j=0; i < max_pfn; i+=(PAGE_SIZE/sizeof(unsigned long)), j++ )
   14.42      {
   14.43 +#ifndef CONFIG_XEN_SHADOW_MODE
   14.44 +        pfn_to_mfn_frame_list[j] = 
   14.45 +            virt_to_machine(&phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   14.46 +#else /* CONFIG_XEN_SHADOW_MODE */
   14.47          __vms_pfn_to_mfn_frame_list[j] = 
   14.48              __vms_virt_to_machine(&__vms_phys_to_machine_mapping[i]) >> PAGE_SHIFT;
   14.49 +#endif /* CONFIG_XEN_SHADOW_MODE */
   14.50      }
   14.51      HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list =
   14.52 +#ifndef CONFIG_XEN_SHADOW_MODE
   14.53 +        virt_to_machine(pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   14.54 +#else /* CONFIG_XEN_SHADOW_MODE */
   14.55          __vms_virt_to_machine(__vms_pfn_to_mfn_frame_list) >> PAGE_SHIFT;
   14.56 +#endif /* CONFIG_XEN_SHADOW_MODE */
   14.57  
   14.58  
   14.59      irq_resume();
    15.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/balloon/balloon.c	Mon Mar 21 12:01:36 2005 +0000
    15.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/balloon/balloon.c	Mon Mar 21 13:23:44 2005 +0000
    15.3 @@ -206,11 +206,19 @@ static void balloon_process(void *unused
    15.4                  BUG();
    15.5  
    15.6              pfn = page - mem_map;
    15.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    15.8 +            if ( phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
    15.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   15.10              if ( __vms_phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY )
   15.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   15.12                  BUG();
   15.13  
   15.14              /* Update P->M and M->P tables. */
   15.15 +#ifndef CONFIG_XEN_SHADOW_MODE
   15.16 +            phys_to_machine_mapping[pfn] = mfn_list[i];
   15.17 +#else /* CONFIG_XEN_SHADOW_MODE */
   15.18              __vms_phys_to_machine_mapping[pfn] = mfn_list[i];
   15.19 +#endif /* CONFIG_XEN_SHADOW_MODE */
   15.20              queue_machphys_update(mfn_list[i], pfn);
   15.21              
   15.22              /* Link back into the page tables if it's not a highmem page. */
   15.23 @@ -244,8 +252,13 @@ static void balloon_process(void *unused
   15.24              }
   15.25  
   15.26              pfn = page - mem_map;
   15.27 +#ifndef CONFIG_XEN_SHADOW_MODE
   15.28 +            mfn_list[i] = phys_to_machine_mapping[pfn];
   15.29 +            phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
   15.30 +#else /* CONFIG_XEN_SHADOW_MODE */
   15.31              mfn_list[i] = __vms_phys_to_machine_mapping[pfn];
   15.32              __vms_phys_to_machine_mapping[pfn] = INVALID_P2M_ENTRY;
   15.33 +#endif /* CONFIG_XEN_SHADOW_MODE */
   15.34  
   15.35              if ( !PageHighMem(page) )
   15.36              {
    16.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Mon Mar 21 12:01:36 2005 +0000
    16.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Mon Mar 21 13:23:44 2005 +0000
    16.3 @@ -444,7 +444,11 @@ static void dispatch_rw_block_io(blkif_t
    16.4  #else
    16.5          mcl[i].args[3] = blkif->domid;
    16.6  #endif
    16.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    16.8 +        phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
    16.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   16.10          __vms_phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx, i))>>PAGE_SHIFT] =
   16.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   16.12              FOREIGN_FRAME(phys_seg[i].buffer >> PAGE_SHIFT);
   16.13      }
   16.14  
    17.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Mar 21 12:01:36 2005 +0000
    17.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Mar 21 13:23:44 2005 +0000
    17.3 @@ -129,7 +129,11 @@ static inline void translate_req_to_pfn(
    17.4      xreq->sector_number = req->sector_number;
    17.5  
    17.6      for ( i = 0; i < req->nr_segments; i++ )
    17.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    17.8 +        xreq->frame_and_sects[i] = machine_to_phys(req->frame_and_sects[i]);
    17.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   17.10          xreq->frame_and_sects[i] = __vms_machine_to_phys(req->frame_and_sects[i]);
   17.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   17.12  }
   17.13  
   17.14  static inline void translate_req_to_mfn(blkif_request_t *xreq,
   17.15 @@ -144,7 +148,11 @@ static inline void translate_req_to_mfn(
   17.16      xreq->sector_number = req->sector_number;
   17.17  
   17.18      for ( i = 0; i < req->nr_segments; i++ )
   17.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   17.20 +        xreq->frame_and_sects[i] = phys_to_machine(req->frame_and_sects[i]);
   17.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   17.22          xreq->frame_and_sects[i] = __vms_phys_to_machine(req->frame_and_sects[i]);
   17.23 +#endif /* CONFIG_XEN_SHADOW_MODE */
   17.24  }
   17.25  
   17.26  
   17.27 @@ -1091,7 +1099,11 @@ static void blkif_send_interface_connect
   17.28      blkif_fe_interface_connect_t *msg = (void*)cmsg.msg;
   17.29      
   17.30      msg->handle      = 0;
   17.31 +#ifndef CONFIG_XEN_SHADOW_MODE
   17.32 +    msg->shmem_frame = (virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
   17.33 +#else /* CONFIG_XEN_SHADOW_MODE */
   17.34      msg->shmem_frame = (__vms_virt_to_machine(blk_ring.sring) >> PAGE_SHIFT);
   17.35 +#endif /* CONFIG_XEN_SHADOW_MODE */
   17.36      
   17.37      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   17.38  }
   17.39 @@ -1401,7 +1413,11 @@ void blkif_completion(blkif_request_t *r
   17.40          for ( i = 0; i < req->nr_segments; i++ )
   17.41          {
   17.42              unsigned long pfn = req->frame_and_sects[i] >> PAGE_SHIFT;
   17.43 +#ifndef CONFIG_XEN_SHADOW_MODE
   17.44 +            unsigned long mfn = phys_to_machine_mapping[pfn];
   17.45 +#else /* CONFIG_XEN_SHADOW_MODE */
   17.46              unsigned long mfn = __vms_phys_to_machine_mapping[pfn];
   17.47 +#endif /* CONFIG_XEN_SHADOW_MODE */
   17.48              xen_machphys_update(mfn, pfn);
   17.49          }
   17.50          break;
    18.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Mar 21 12:01:36 2005 +0000
    18.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Mar 21 13:23:44 2005 +0000
    18.3 @@ -112,7 +112,11 @@ static int xlvbd_get_vbd_info(vdisk_t *d
    18.4      memset(&req, 0, sizeof(req));
    18.5      req.operation   = BLKIF_OP_PROBE;
    18.6      req.nr_segments = 1;
    18.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    18.8 +    req.frame_and_sects[0] = virt_to_machine(buf) | 7;
    18.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   18.10      req.frame_and_sects[0] = __vms_virt_to_machine(buf) | 7;
   18.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   18.12  
   18.13      blkif_control_send(&req, &rsp);
   18.14  
    19.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/netback/netback.c	Mon Mar 21 12:01:36 2005 +0000
    19.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/netback/netback.c	Mon Mar 21 13:23:44 2005 +0000
    19.3 @@ -207,7 +207,11 @@ static void net_rx_action(unsigned long 
    19.4      {
    19.5          netif   = netdev_priv(skb->dev);
    19.6          vdata   = (unsigned long)skb->data;
    19.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    19.8 +        mdata   = virt_to_machine(vdata);
    19.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   19.10          mdata   = __vms_virt_to_machine(vdata);
   19.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   19.12  
   19.13          /* Memory squeeze? Back off for an arbitrary while. */
   19.14          if ( (new_mfn = alloc_mfn()) == 0 )
   19.15 @@ -223,7 +227,11 @@ static void net_rx_action(unsigned long 
   19.16           * Set the new P2M table entry before reassigning the old data page.
   19.17           * Heed the comment in pgtable-2level.h:pte_page(). :-)
   19.18           */
   19.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   19.20 +        phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] = new_mfn;
   19.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   19.22          __vms_phys_to_machine_mapping[__pa(skb->data) >> PAGE_SHIFT] = new_mfn;
   19.23 +#endif /* CONFIG_XEN_SHADOW_MODE */
   19.24          
   19.25          mmu[0].ptr  = (new_mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
   19.26          mmu[0].val  = __pa(vdata) >> PAGE_SHIFT;  
   19.27 @@ -590,7 +598,11 @@ static void net_tx_action(unsigned long 
   19.28              continue;
   19.29          }
   19.30  
   19.31 +#ifndef CONFIG_XEN_SHADOW_MODE
   19.32 +        phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
   19.33 +#else /* CONFIG_XEN_SHADOW_MODE */
   19.34          __vms_phys_to_machine_mapping[__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT] =
   19.35 +#endif /* CONFIG_XEN_SHADOW_MODE */
   19.36              FOREIGN_FRAME(txreq.addr >> PAGE_SHIFT);
   19.37  
   19.38          data_len = (txreq.size > PKT_PROT_LEN) ? PKT_PROT_LEN : txreq.size;
    20.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	Mon Mar 21 12:01:36 2005 +0000
    20.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/netfront/netfront.c	Mon Mar 21 13:23:44 2005 +0000
    20.3 @@ -375,10 +375,18 @@ static void network_alloc_rx_buffers(str
    20.4          
    20.5          np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id;
    20.6          
    20.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    20.8 +        rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
    20.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.10          rx_pfn_array[i] = __vms_virt_to_machine(skb->head) >> PAGE_SHIFT;
   20.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.12  
   20.13  	/* Remove this page from pseudo phys map before passing back to Xen. */
   20.14 +#ifndef CONFIG_XEN_SHADOW_MODE
   20.15 +	phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
   20.16 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.17  	__vms_phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] 
   20.18 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.19  	    = INVALID_P2M_ENTRY;
   20.20  
   20.21          rx_mcl[i].op = __HYPERVISOR_update_va_mapping;
   20.22 @@ -464,7 +472,11 @@ static int network_start_xmit(struct sk_
   20.23      tx = &np->tx->ring[MASK_NETIF_TX_IDX(i)].req;
   20.24  
   20.25      tx->id   = id;
   20.26 +#ifndef CONFIG_XEN_SHADOW_MODE
   20.27 +    tx->addr = virt_to_machine(skb->data);
   20.28 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.29      tx->addr = __vms_virt_to_machine(skb->data);
   20.30 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.31      tx->size = skb->len;
   20.32  
   20.33      wmb(); /* Ensure that backend will see the request. */
   20.34 @@ -579,7 +591,11 @@ static int netif_poll(struct net_device 
   20.35          mcl->args[2] = 0;
   20.36          mcl++;
   20.37  
   20.38 +#ifndef CONFIG_XEN_SHADOW_MODE
   20.39 +        phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
   20.40 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.41          __vms_phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
   20.42 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.43              rx->addr >> PAGE_SHIFT;
   20.44  
   20.45          __skb_queue_tail(&rxq, skb);
   20.46 @@ -736,7 +752,11 @@ static void network_connect(struct net_d
   20.47                  tx = &np->tx->ring[requeue_idx++].req;
   20.48                  
   20.49                  tx->id   = i;
   20.50 +#ifndef CONFIG_XEN_SHADOW_MODE
   20.51 +                tx->addr = virt_to_machine(skb->data);
   20.52 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.53                  tx->addr = __vms_virt_to_machine(skb->data);
   20.54 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.55                  tx->size = skb->len;
   20.56                  
   20.57                  np->stats.tx_bytes += skb->len;
   20.58 @@ -799,8 +819,13 @@ static void send_interface_connect(struc
   20.59      netif_fe_interface_connect_t *msg = (void*)cmsg.msg;
   20.60  
   20.61      msg->handle = np->handle;
   20.62 +#ifndef CONFIG_XEN_SHADOW_MODE
   20.63 +    msg->tx_shmem_frame = (virt_to_machine(np->tx) >> PAGE_SHIFT);
   20.64 +    msg->rx_shmem_frame = (virt_to_machine(np->rx) >> PAGE_SHIFT);
   20.65 +#else /* CONFIG_XEN_SHADOW_MODE */
   20.66      msg->tx_shmem_frame = (__vms_virt_to_machine(np->tx) >> PAGE_SHIFT);
   20.67      msg->rx_shmem_frame = (__vms_virt_to_machine(np->rx) >> PAGE_SHIFT);
   20.68 +#endif /* CONFIG_XEN_SHADOW_MODE */
   20.69          
   20.70      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   20.71  }
    21.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/privcmd/privcmd.c	Mon Mar 21 12:01:36 2005 +0000
    21.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/privcmd/privcmd.c	Mon Mar 21 13:23:44 2005 +0000
    21.3 @@ -174,7 +174,11 @@ static int privcmd_ioctl(struct inode *i
    21.4  
    21.5      case IOCTL_PRIVCMD_GET_MACH2PHYS_START_MFN:
    21.6      {
    21.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    21.8 +        unsigned long m2pv = (unsigned long)machine_to_phys_mapping;
    21.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   21.10          unsigned long m2pv = (unsigned long)__vms_machine_to_phys_mapping;
   21.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   21.12          pgd_t *pgd = pgd_offset_k(m2pv);
   21.13          pmd_t *pmd = pmd_offset(pgd, m2pv);
   21.14          unsigned long m2p_start_mfn = pmd_val(*pmd) >> PAGE_SHIFT;
    22.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h	Mon Mar 21 12:01:36 2005 +0000
    22.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/desc.h	Mon Mar 21 13:23:44 2005 +0000
    22.3 @@ -89,7 +89,11 @@ static inline void set_ldt_desc(unsigned
    22.4  
    22.5  static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
    22.6  {
    22.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    22.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])
    22.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   22.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])
   22.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   22.12  	C(0); C(1); C(2);
   22.13  #undef C
   22.14  }
    23.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Mon Mar 21 12:01:36 2005 +0000
    23.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/fixmap.h	Mon Mar 21 13:23:44 2005 +0000
    23.3 @@ -101,15 +101,26 @@ enum fixed_addresses {
    23.4  
    23.5  extern void __set_fixmap (enum fixed_addresses idx,
    23.6  					unsigned long phys, pgprot_t flags);
    23.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    23.8 +extern void __set_fixmap_ma (enum fixed_addresses idx,
    23.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   23.10  extern void __vms___set_fixmap_ma (enum fixed_addresses idx,
   23.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   23.12  					unsigned long mach, pgprot_t flags);
   23.13  
   23.14  #define set_fixmap(idx, phys) \
   23.15  		__set_fixmap(idx, phys, PAGE_KERNEL)
   23.16 +#ifndef CONFIG_XEN_SHADOW_MODE
   23.17 +#define set_fixmap_ma(idx, phys) \
   23.18 +		__set_fixmap_ma(idx, phys, PAGE_KERNEL)
   23.19 +#define set_fixmap_ma_ro(idx, phys) \
   23.20 +		__set_fixmap_ma(idx, phys, PAGE_KERNEL_RO)
   23.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   23.22  #define __vms_set_fixmap_ma(idx, phys) \
   23.23  		__vms___set_fixmap_ma(idx, phys, PAGE_KERNEL)
   23.24  #define __vms_set_fixmap_ma_ro(idx, phys) \
   23.25  		__vms___set_fixmap_ma(idx, phys, PAGE_KERNEL_RO)
   23.26 +#endif /* CONFIG_XEN_SHADOW_MODE */
   23.27  /*
   23.28   * Some hardware wants to get fixmapped without caching.
   23.29   */
    24.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/io.h	Mon Mar 21 12:01:36 2005 +0000
    24.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/io.h	Mon Mar 21 13:23:44 2005 +0000
    24.3 @@ -89,21 +89,44 @@ static inline void * phys_to_virt(unsign
    24.4  /*
    24.5   * Change "struct page" to physical address.
    24.6   */
    24.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    24.8 +#define page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
    24.9 +#define page_to_phys(page)	 (phys_to_machine(page_to_pseudophys(page)))
   24.10 +#else /* CONFIG_XEN_SHADOW_MODE */
   24.11  #define __vms_page_to_pseudophys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
   24.12  #define __vms_page_to_machphys(page) (__vms_phys_to_machine(__vms_page_to_pseudophys(page)))
   24.13  #define page_to_phys(page)	 (__vms_page_to_machphys(page))
   24.14 +#endif /* CONFIG_XEN_SHADOW_MODE */
   24.15  
   24.16 +#ifndef CONFIG_XEN_SHADOW_MODE
   24.17 +#define bio_to_pseudophys(bio)	 (page_to_pseudophys(bio_page((bio))) + \
   24.18 +				  (unsigned long) bio_offset((bio)))
   24.19 +#else /* CONFIG_XEN_SHADOW_MODE */
   24.20  #define __vms_bio_to_pseudophys(bio)	 (__vms_page_to_pseudophys(bio_page((bio))) + \
   24.21  				  (unsigned long) bio_offset((bio)))
   24.22 +#endif /* CONFIG_XEN_SHADOW_MODE */
   24.23 +
   24.24 +#ifndef CONFIG_XEN_SHADOW_MODE
   24.25 +#define bvec_to_pseudophys(bv)	 (page_to_pseudophys((bv)->bv_page) + \
   24.26 +				  (unsigned long) (bv)->bv_offset)
   24.27 +#else /* CONFIG_XEN_SHADOW_MODE */
   24.28  #define __vms_bvec_to_pseudophys(bv)	 (__vms_page_to_pseudophys((bv)->bv_page) + \
   24.29  				  (unsigned long) (bv)->bv_offset)
   24.30  #define __vms_bvec_to_machphys(bv)	 (__vms_page_to_machphys((bv)->bv_page) + \
   24.31  				  (unsigned long) (bv)->bv_offset)
   24.32 +#endif /* CONFIG_XEN_SHADOW_MODE */
   24.33  
   24.34 +#ifndef CONFIG_XEN_SHADOW_MODE
   24.35 +#define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
   24.36 +	(((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) && \
   24.37 +	 ((bvec_to_pseudophys((vec1)) + (vec1)->bv_len) == \
   24.38 +	  bvec_to_pseudophys((vec2))))
   24.39 +#else /* CONFIG_XEN_SHADOW_MODE */
   24.40  #define BIOVEC_PHYS_MERGEABLE(vec1, vec2)	\
   24.41  	(((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2))) && \
   24.42  	 ((__vms_bvec_to_machphys((vec1)) + (vec1)->bv_len) == \
   24.43  	  __vms_bvec_to_machphys((vec2))))
   24.44 +#endif /* CONFIG_XEN_SHADOW_MODE */
   24.45  
   24.46  extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
   24.47  
   24.48 @@ -152,8 +175,13 @@ extern void bt_iounmap(void *addr, unsig
   24.49   *
   24.50   * Allow them on x86 for legacy drivers, though.
   24.51   */
   24.52 +#ifndef CONFIG_XEN_SHADOW_MODE
   24.53 +#define virt_to_bus(_x) phys_to_machine(__pa(_x))
   24.54 +#define bus_to_virt(_x) __va(machine_to_phys(_x))
   24.55 +#else /* CONFIG_XEN_SHADOW_MODE */
   24.56  #define virt_to_bus(_x) __vms_phys_to_machine(__pa(_x))
   24.57  #define bus_to_virt(_x) ({ BUG(); __va((_x)); })
   24.58 +#endif /* CONFIG_XEN_SHADOW_MODE */
   24.59  
   24.60  /*
   24.61   * readX/writeX() are used to access memory mapped devices. On some
    25.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/page.h	Mon Mar 21 12:01:36 2005 +0000
    25.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/page.h	Mon Mar 21 13:23:44 2005 +0000
    25.3 @@ -12,9 +12,9 @@
    25.4  #ifdef __KERNEL__
    25.5  #ifndef __ASSEMBLY__
    25.6  
    25.7 -#ifndef BUG
    25.8 +#ifdef CONFIG_XEN_SHADOW_MODE
    25.9  #include <asm/bug.h>
   25.10 -#endif
   25.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.12  
   25.13  #include <linux/config.h>
   25.14  #include <linux/string.h>
   25.15 @@ -59,18 +59,37 @@
   25.16  #define copy_user_page(to, from, vaddr, pg)	copy_page(to, from)
   25.17  
   25.18  /**** MACHINE <-> PHYSICAL CONVERSION MACROS ****/
   25.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.20 +extern unsigned int *phys_to_machine_mapping;
   25.21 +#define pfn_to_mfn(_pfn) ((unsigned long)(phys_to_machine_mapping[(_pfn)]))
   25.22 +#define mfn_to_pfn(_mfn) ((unsigned long)(machine_to_phys_mapping[(_mfn)]))
   25.23 +static inline unsigned long phys_to_machine(unsigned long phys)
   25.24 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.25  extern unsigned int *__vms_phys_to_machine_mapping;
   25.26  #define __vms_pfn_to_mfn(_pfn) ((unsigned long)(__vms_phys_to_machine_mapping[(_pfn)]))
   25.27  #define __vms_mfn_to_pfn(_mfn) ({ BUG(); ((unsigned long)(__vms_machine_to_phys_mapping[(_mfn)])); })
   25.28  static inline unsigned long __vms_phys_to_machine(unsigned long phys)
   25.29 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.30  {
   25.31 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.32 +	unsigned long machine = pfn_to_mfn(phys >> PAGE_SHIFT);
   25.33 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.34  	unsigned long machine = __vms_pfn_to_mfn(phys >> PAGE_SHIFT);
   25.35 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.36  	machine = (machine << PAGE_SHIFT) | (phys & ~PAGE_MASK);
   25.37  	return machine;
   25.38  }
   25.39 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.40 +static inline unsigned long machine_to_phys(unsigned long machine)
   25.41 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.42  static inline unsigned long __vms_machine_to_phys(unsigned long machine)
   25.43 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.44  {
   25.45 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.46 +	unsigned long phys = mfn_to_pfn(machine >> PAGE_SHIFT);
   25.47 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.48  	unsigned long phys = __vms_mfn_to_pfn(machine >> PAGE_SHIFT);
   25.49 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.50  	phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
   25.51  	return phys;
   25.52  }
   25.53 @@ -93,8 +112,14 @@ typedef struct { unsigned long pmd; } pm
   25.54  typedef struct { unsigned long pgd; } pgd_t;
   25.55  typedef struct { unsigned long pgprot; } pgprot_t;
   25.56  #define boot_pte_t pte_t /* or would you rather have a typedef */
   25.57 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.58 +#define pte_val(x)	(((x).pte_low & 1) ? machine_to_phys((x).pte_low) : \
   25.59 +			 (x).pte_low)
   25.60 +#define pte_val_ma(x)	((x).pte_low)
   25.61 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.62  #define pte_val(x)	((x).pte_low)
   25.63  #define __vms_pte_val_ma(x)	((x).pte_low)
   25.64 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.65  #define HPAGE_SHIFT	22
   25.66  #endif
   25.67  #define PTE_MASK	PAGE_MASK
   25.68 @@ -109,17 +134,32 @@ typedef struct { unsigned long pgprot; }
   25.69  
   25.70  static inline unsigned long pmd_val(pmd_t x)
   25.71  {
   25.72 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.73 +	unsigned long ret = x.pmd;
   25.74 +	if (ret) ret = machine_to_phys(ret);
   25.75 +	return ret;
   25.76 +#else /* CONFIG_XEN_SHADOW_MODE */
   25.77  	return x.pmd;
   25.78 +#endif /* CONFIG_XEN_SHADOW_MODE */
   25.79  }
   25.80  #define pgd_val(x)	({ BUG(); (unsigned long)0; })
   25.81  #define pgprot_val(x)	((x).pgprot)
   25.82  
   25.83  static inline pte_t __pte(unsigned long x)
   25.84  {
   25.85 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.86 +	if (x & 1) x = phys_to_machine(x);
   25.87 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   25.88  	return ((pte_t) { (x) });
   25.89  }
   25.90 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.91 +#define __pte_ma(x)	((pte_t) { (x) } )
   25.92 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   25.93  static inline pmd_t __pmd(unsigned long x)
   25.94  {
   25.95 +#ifndef CONFIG_XEN_SHADOW_MODE
   25.96 +	if ((x & 1)) x = phys_to_machine(x);
   25.97 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   25.98  	return ((pmd_t) { (x) });
   25.99  }
  25.100  #define __pgd(x)	({ BUG(); (pgprot_t) { 0 }; })
  25.101 @@ -197,8 +237,13 @@ extern int sysctl_legacy_va_layout;
  25.102  		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  25.103  
  25.104  /* VIRT <-> MACHINE conversion */
  25.105 +#ifndef CONFIG_XEN_SHADOW_MODE
  25.106 +#define virt_to_machine(_a)	(phys_to_machine(__pa(_a)))
  25.107 +#define machine_to_virt(_m)	(__va(machine_to_phys(_m)))
  25.108 +#else /* CONFIG_XEN_SHADOW_MODE */
  25.109  #define __vms_virt_to_machine(_a)	(__vms_phys_to_machine(__pa(_a)))
  25.110  #define __vms_machine_to_virt(_m)	(__va(__vms_machine_to_phys(_m)))
  25.111 +#endif /* CONFIG_XEN_SHADOW_MODE */
  25.112  
  25.113  #endif /* __KERNEL__ */
  25.114  
    26.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Mon Mar 21 12:01:36 2005 +0000
    26.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Mon Mar 21 13:23:44 2005 +0000
    26.3 @@ -16,6 +16,9 @@ static inline void pmd_populate(struct m
    26.4  	set_pmd(pmd, __pmd(_PAGE_TABLE +
    26.5  		((unsigned long long)page_to_pfn(pte) <<
    26.6  			(unsigned long long) PAGE_SHIFT)));
    26.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    26.8 +	flush_page_update_queue();
    26.9 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   26.10  }
   26.11  /*
   26.12   * Allocate and free page tables.
   26.13 @@ -30,6 +33,10 @@ extern struct page *pte_alloc_one(struct
   26.14  static inline void pte_free_kernel(pte_t *pte)
   26.15  {
   26.16  	free_page((unsigned long)pte);
   26.17 +#ifndef CONFIG_XEN_SHADOW_MODE
   26.18 +	make_page_writable(pte);
   26.19 +	flush_page_update_queue();
   26.20 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   26.21  }
   26.22  
   26.23  extern void pte_free(struct page *pte);
    27.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Mon Mar 21 12:01:36 2005 +0000
    27.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Mon Mar 21 13:23:44 2005 +0000
    27.3 @@ -43,7 +43,11 @@ do { \
    27.4   * (pmds are folded into pgds so this doesn't get actually called,
    27.5   * but the define is needed for a generic inline function.)
    27.6   */
    27.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    27.8 +#define set_pmd(pmdptr, pmdval) xen_l2_entry_update((pmdptr), (pmdval).pmd)
    27.9 +#else /* CONFIG_XEN_SHADOW_MODE */
   27.10  #define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
   27.11 +#endif /* CONFIG_XEN_SHADOW_MODE */
   27.12  #define set_pgd(pgdptr, pgdval) ((void)0)
   27.13  
   27.14  #define pgd_page(pgd) \
   27.15 @@ -67,7 +71,11 @@ static inline pte_t ptep_get_and_clear(p
   27.16  {
   27.17  	pte_t pte = *xp;
   27.18  	if (pte.pte_low)
   27.19 +#ifndef CONFIG_XEN_SHADOW_MODE
   27.20 +		set_pte(xp, __pte_ma(0));
   27.21 +#else /* CONFIG_XEN_SHADOW_MODE */
   27.22  		set_pte(xp, __pte(0));
   27.23 +#endif /* CONFIG_XEN_SHADOW_MODE */
   27.24  	return pte;
   27.25  }
   27.26  
   27.27 @@ -94,12 +102,26 @@ static inline pte_t ptep_get_and_clear(p
   27.28   */
   27.29  #define INVALID_P2M_ENTRY (~0U)
   27.30  #define FOREIGN_FRAME(_m) ((_m) | (1UL<<((sizeof(unsigned long)*8)-1)))
   27.31 +#ifndef CONFIG_XEN_SHADOW_MODE
   27.32 +#define pte_pfn(_pte)							\
   27.33 +({									\
   27.34 +	unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;		\
   27.35 +	unsigned long pfn = mfn_to_pfn(mfn);				\
   27.36 +	if ((pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn))		\
   27.37 +		pfn = max_mapnr; /* special: force !pfn_valid() */	\
   27.38 +	pfn;								\
   27.39 +})
   27.40 +#else /* CONFIG_XEN_SHADOW_MODE */
   27.41  #define pte_pfn(_pte)		((_pte).pte_low >> PAGE_SHIFT)
   27.42 +#endif /* CONFIG_XEN_SHADOW_MODE */
   27.43  
   27.44  #define pte_page(_pte) pfn_to_page(pte_pfn(_pte))
   27.45  
   27.46  #define pte_none(x)		(!(x).pte_low)
   27.47  #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   27.48 +#ifndef CONFIG_XEN_SHADOW_MODE
   27.49 +#define pfn_pte_ma(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   27.50 +#endif /* ! CONFIG_XEN_SHADOW_MODE */
   27.51  #define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
   27.52  
   27.53  /*
    28.1 --- a/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Mar 21 12:01:36 2005 +0000
    28.2 +++ b/linux-2.6.10-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Mar 21 13:23:44 2005 +0000
    28.3 @@ -319,9 +319,16 @@ static inline pte_t pte_modify(pte_t pte
    28.4  #define pmd_page_kernel(pmd) \
    28.5  ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
    28.6  
    28.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    28.8 +#define pmd_clear(xp) do {					\
    28.9 +	set_pmd(xp, __pmd(0));					\
   28.10 +	xen_flush_page_update_queue();				\
   28.11 +} while (0)
   28.12 +#else /* CONFIG_XEN_SHADOW_MODE */
   28.13  #define pmd_clear(xp)	do {					\
   28.14  	set_pmd(xp, __pmd(0));					\
   28.15  } while (0)
   28.16 +#endif /* CONFIG_XEN_SHADOW_MODE */
   28.17  
   28.18  #ifndef CONFIG_DISCONTIGMEM
   28.19  #define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
   28.20 @@ -459,6 +466,16 @@ void make_page_writable(void *va);
   28.21  void make_pages_readonly(void *va, unsigned int nr);
   28.22  void make_pages_writable(void *va, unsigned int nr);
   28.23  
   28.24 +#ifndef CONFIG_XEN_SHADOW_MODE
   28.25 +#define arbitrary_virt_to_machine(__va)					\
   28.26 +({									\
   28.27 +	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   28.28 +	pmd_t *__pmd = pmd_offset(__pgd, (unsigned long)(__va));	\
   28.29 +	pte_t *__pte = pte_offset_kernel(__pmd, (unsigned long)(__va));	\
   28.30 +	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   28.31 +	__pa | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
   28.32 +})
   28.33 +#else /* CONFIG_XEN_SHADOW_MODE */
   28.34  #define __vms_arbitrary_virt_to_machine(__va)					\
   28.35  ({									\
   28.36  	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   28.37 @@ -467,7 +484,9 @@ void make_pages_writable(void *va, unsig
   28.38  	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   28.39  	__vms_phys_to_machine(__pa) | ((unsigned long)(__va) & (PAGE_SIZE-1)); \
   28.40  })
   28.41 +#endif /* CONFIG_XEN_SHADOW_MODE */
   28.42  
   28.43 +#ifdef CONFIG_XEN_SHADOW_MODE
   28.44  #define arbitrary_virt_to_phys(__va)					\
   28.45  ({									\
   28.46  	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
   28.47 @@ -476,6 +495,7 @@ void make_pages_writable(void *va, unsig
   28.48  	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
   28.49  	(__pa) | ((unsigned long)(__va) & (PAGE_SIZE-1));               \
   28.50  })
   28.51 +#endif /* CONFIG_XEN_SHADOW_MODE */
   28.52  
   28.53  #endif /* !__ASSEMBLY__ */
   28.54  
    29.1 --- a/xen/include/public/arch-x86_32.h	Mon Mar 21 12:01:36 2005 +0000
    29.2 +++ b/xen/include/public/arch-x86_32.h	Mon Mar 21 13:23:44 2005 +0000
    29.3 @@ -70,9 +70,15 @@
    29.4   * machine->physical mapping table starts at this address, read-only.
    29.5   */
    29.6  #define HYPERVISOR_VIRT_START (0xFC000000UL)
    29.7 +#ifndef CONFIG_XEN_SHADOW_MODE
    29.8 +#ifndef machine_to_phys_mapping
    29.9 +#define machine_to_phys_mapping ((u32 *)HYPERVISOR_VIRT_START)
   29.10 +#endif
   29.11 +#else /* CONFIG_XEN_SHADOW_MODE */
   29.12  #ifndef __vms_machine_to_phys_mapping
   29.13  #define __vms_machine_to_phys_mapping ((u32 *)HYPERVISOR_VIRT_START)
   29.14  #endif
   29.15 +#endif /* CONFIG_XEN_SHADOW_MODE */
   29.16  
   29.17  #ifndef __ASSEMBLY__
   29.18