ia64/xen-unstable

changeset 8701:a0a59beb6596

Split XENFEAT_writable_mmu_structures into
XENFEAT_writable_page_tables/XENFEAT_writable_descriptor_tables.

Name the make_readonly/writable functions back to their old
names, and they now accept a feature flag that they test
before performing their operation.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jan 30 12:49:31 2006 +0100 (2006-01-30)
parents 1712b52e0074
children 58d6a94cd163
files linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c linux-2.6-xen-sparse/arch/xen/i386/mm/init.c linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6-xen-sparse/arch/xen/kernel/features.c linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ldt.c linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgalloc.h linux-2.6-xen-sparse/include/asm-xen/features.h xen/include/public/version.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Jan 30 11:23:32 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Mon Jan 30 12:49:31 2006 +0100
     1.3 @@ -572,7 +572,8 @@ void __cpuinit cpu_gdt_init(struct Xgt_d
     1.4  	     va < gdt_descr->address + gdt_descr->size;
     1.5  	     va += PAGE_SIZE, f++) {
     1.6  		frames[f] = virt_to_mfn(va);
     1.7 -		make_lowmem_mmu_page_readonly((void *)va);
     1.8 +		make_lowmem_page_readonly(
     1.9 +			(void *)va, XENFEAT_writable_descriptor_tables);
    1.10  	}
    1.11  	if (HYPERVISOR_set_gdt(frames, gdt_descr->size / 8))
    1.12  		BUG();
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c	Mon Jan 30 11:23:32 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/ldt.c	Mon Jan 30 12:49:31 2006 +0100
     2.3 @@ -59,8 +59,10 @@ static int alloc_ldt(mm_context_t *pc, i
     2.4  		cpumask_t mask;
     2.5  		preempt_disable();
     2.6  #endif
     2.7 -		make_mmu_pages_readonly(pc->ldt, (pc->size * LDT_ENTRY_SIZE) /
     2.8 -					PAGE_SIZE);
     2.9 +		make_pages_readonly(
    2.10 +			pc->ldt,
    2.11 +			(pc->size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    2.12 +			XENFEAT_writable_descriptor_tables);
    2.13  		load_LDT(pc);
    2.14  #ifdef CONFIG_SMP
    2.15  		mask = cpumask_of_cpu(smp_processor_id());
    2.16 @@ -70,8 +72,10 @@ static int alloc_ldt(mm_context_t *pc, i
    2.17  #endif
    2.18  	}
    2.19  	if (oldsize) {
    2.20 -		make_mmu_pages_writable(oldldt, (oldsize * LDT_ENTRY_SIZE) /
    2.21 -			PAGE_SIZE);
    2.22 +		make_pages_writable(
    2.23 +			oldldt,
    2.24 +			(oldsize * LDT_ENTRY_SIZE) / PAGE_SIZE,
    2.25 +			XENFEAT_writable_descriptor_tables);
    2.26  		if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
    2.27  			vfree(oldldt);
    2.28  		else
    2.29 @@ -86,8 +90,10 @@ static inline int copy_ldt(mm_context_t 
    2.30  	if (err < 0)
    2.31  		return err;
    2.32  	memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
    2.33 -	make_mmu_pages_readonly(new->ldt, (new->size * LDT_ENTRY_SIZE) /
    2.34 -				PAGE_SIZE);
    2.35 +	make_pages_readonly(
    2.36 +		new->ldt,
    2.37 +		(new->size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    2.38 +		XENFEAT_writable_descriptor_tables);
    2.39  	return 0;
    2.40  }
    2.41  
    2.42 @@ -119,9 +125,10 @@ void destroy_context(struct mm_struct *m
    2.43  	if (mm->context.size) {
    2.44  		if (mm == current->active_mm)
    2.45  			clear_LDT();
    2.46 -		make_mmu_pages_writable(mm->context.ldt,
    2.47 -					(mm->context.size * LDT_ENTRY_SIZE) /
    2.48 -					PAGE_SIZE);
    2.49 +		make_pages_writable(
    2.50 +			mm->context.ldt,
    2.51 +			(mm->context.size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    2.52 +			XENFEAT_writable_descriptor_tables);
    2.53  		if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
    2.54  			vfree(mm->context.ldt);
    2.55  		else
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Mon Jan 30 11:23:32 2006 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/traps.c	Mon Jan 30 12:49:31 2006 +0100
     3.3 @@ -995,7 +995,8 @@ void __init trap_init(void)
     3.4  	 * default LDT is a single-entry callgate to lcall7 for iBCS
     3.5  	 * and a callgate to lcall27 for Solaris/x86 binaries
     3.6  	 */
     3.7 -	make_lowmem_mmu_page_readonly(&default_ldt[0]);
     3.8 +	make_lowmem_page_readonly(
     3.9 +		&default_ldt[0], XENFEAT_writable_descriptor_tables);
    3.10  
    3.11  	/*
    3.12  	 * Should be a barrier for any external CPU state.
     4.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Mon Jan 30 11:23:32 2006 +0100
     4.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/init.c	Mon Jan 30 12:49:31 2006 +0100
     4.3 @@ -68,7 +68,7 @@ static pmd_t * __init one_md_table_init(
     4.4  		
     4.5  #ifdef CONFIG_X86_PAE
     4.6  	pmd_table = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
     4.7 -	make_lowmem_mmu_page_readonly(pmd_table);
     4.8 +	make_lowmem_page_readonly(pmd_table, XENFEAT_writable_page_tables);
     4.9  	set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
    4.10  	pud = pud_offset(pgd, 0);
    4.11  	if (pmd_table != pmd_offset(pud, 0)) 
    4.12 @@ -89,7 +89,8 @@ static pte_t * __init one_page_table_ini
    4.13  {
    4.14  	if (pmd_none(*pmd)) {
    4.15  		pte_t *page_table = (pte_t *) alloc_bootmem_low_pages(PAGE_SIZE);
    4.16 -		make_lowmem_mmu_page_readonly(page_table);
    4.17 +		make_lowmem_page_readonly(page_table,
    4.18 +					  XENFEAT_writable_page_tables);
    4.19  		set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
    4.20  		if (page_table != pte_offset_kernel(pmd, 0))
    4.21  			BUG();	
     5.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Jan 30 11:23:32 2006 +0100
     5.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/mm/pgtable.c	Mon Jan 30 12:49:31 2006 +0100
     5.3 @@ -199,7 +199,7 @@ pte_t *pte_alloc_one_kernel(struct mm_st
     5.4  {
     5.5  	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO);
     5.6  	if (pte)
     5.7 -		make_lowmem_mmu_page_readonly(pte);
     5.8 +		make_lowmem_page_readonly(pte, XENFEAT_writable_page_tables);
     5.9  	return pte;
    5.10  }
    5.11  
    5.12 @@ -345,7 +345,8 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
    5.13  			pmd_t *kpmd = pmd_offset(kpud, v);
    5.14  			pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    5.15  			memcpy(pmd, kpmd, PAGE_SIZE);
    5.16 -			make_lowmem_mmu_page_readonly(pmd);
    5.17 +			make_lowmem_page_readonly(
    5.18 +				pmd, XENFEAT_writable_page_tables);
    5.19  		}
    5.20  		pgd_list_add(pgd);
    5.21  		spin_unlock_irqrestore(&pgd_lock, flags);
    5.22 @@ -379,7 +380,8 @@ void pgd_free(pgd_t *pgd)
    5.23  			spin_unlock_irqrestore(&pgd_lock, flags);
    5.24  			for (i = USER_PTRS_PER_PGD; i < PTRS_PER_PGD; i++) {
    5.25  				pmd_t *pmd = (void *)__va(pgd_val(pgd[i])-1);
    5.26 -				make_lowmem_mmu_page_writable(pmd);
    5.27 +				make_lowmem_page_writable(
    5.28 +					pmd, XENFEAT_writable_page_tables);
    5.29  				memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
    5.30  				kmem_cache_free(pmd_cache, pmd);
    5.31  			}
    5.32 @@ -390,12 +392,12 @@ void pgd_free(pgd_t *pgd)
    5.33  }
    5.34  
    5.35  #ifndef CONFIG_XEN_SHADOW_MODE
    5.36 -void make_lowmem_mmu_page_readonly(void *va)
    5.37 +void make_lowmem_page_readonly(void *va, unsigned int feature)
    5.38  {
    5.39  	pte_t *pte;
    5.40  	int rc;
    5.41  
    5.42 -	if (xen_feature(writable_mmu_structures))
    5.43 +	if (xen_feature(feature))
    5.44  		return;
    5.45  
    5.46  	pte = virt_to_ptep(va);
    5.47 @@ -404,12 +406,12 @@ void make_lowmem_mmu_page_readonly(void 
    5.48  	BUG_ON(rc);
    5.49  }
    5.50  
    5.51 -void make_lowmem_mmu_page_writable(void *va)
    5.52 +void make_lowmem_page_writable(void *va, unsigned int feature)
    5.53  {
    5.54  	pte_t *pte;
    5.55  	int rc;
    5.56  
    5.57 -	if (xen_feature(writable_mmu_structures))
    5.58 +	if (xen_feature(feature))
    5.59  		return;
    5.60  
    5.61  	pte = virt_to_ptep(va);
    5.62 @@ -418,12 +420,12 @@ void make_lowmem_mmu_page_writable(void 
    5.63  	BUG_ON(rc);
    5.64  }
    5.65  
    5.66 -void make_mmu_page_readonly(void *va)
    5.67 +void make_page_readonly(void *va, unsigned int feature)
    5.68  {
    5.69  	pte_t *pte;
    5.70  	int rc;
    5.71  
    5.72 -	if (xen_feature(writable_mmu_structures))
    5.73 +	if (xen_feature(feature))
    5.74  		return;
    5.75  
    5.76  	pte = virt_to_ptep(va);
    5.77 @@ -438,17 +440,17 @@ void make_mmu_page_readonly(void *va)
    5.78  			kmap_flush_unused(); /* flush stale writable kmaps */
    5.79  		else
    5.80  #endif
    5.81 -			make_lowmem_mmu_page_readonly(
    5.82 -				phys_to_virt(pfn << PAGE_SHIFT)); 
    5.83 +			make_lowmem_page_readonly(
    5.84 +				phys_to_virt(pfn << PAGE_SHIFT), feature); 
    5.85  	}
    5.86  }
    5.87  
    5.88 -void make_mmu_page_writable(void *va)
    5.89 +void make_page_writable(void *va, unsigned int feature)
    5.90  {
    5.91  	pte_t *pte;
    5.92  	int rc;
    5.93  
    5.94 -	if (xen_feature(writable_mmu_structures))
    5.95 +	if (xen_feature(feature))
    5.96  		return;
    5.97  
    5.98  	pte = virt_to_ptep(va);
    5.99 @@ -461,28 +463,29 @@ void make_mmu_page_writable(void *va)
   5.100  #ifdef CONFIG_HIGHMEM
   5.101  		if (pfn < highstart_pfn)
   5.102  #endif
   5.103 -			make_lowmem_mmu_page_writable(
   5.104 -				phys_to_virt(pfn << PAGE_SHIFT)); 
   5.105 +			make_lowmem_page_writable(
   5.106 +				phys_to_virt(pfn << PAGE_SHIFT), feature);
   5.107  	}
   5.108  }
   5.109  
   5.110 -void make_mmu_pages_readonly(void *va, unsigned int nr)
   5.111 +void make_pages_readonly(void *va, unsigned int nr, unsigned int feature)
   5.112  {
   5.113 -	if (xen_feature(writable_mmu_structures))
   5.114 +	if (xen_feature(feature))
   5.115  		return;
   5.116  
   5.117  	while (nr-- != 0) {
   5.118 -		make_mmu_page_readonly(va);
   5.119 +		make_page_readonly(va, feature);
   5.120  		va = (void *)((unsigned long)va + PAGE_SIZE);
   5.121  	}
   5.122  }
   5.123  
   5.124 -void make_mmu_pages_writable(void *va, unsigned int nr)
   5.125 +void make_pages_writable(void *va, unsigned int nr, unsigned int feature)
   5.126  {
   5.127 -	if (xen_feature(writable_mmu_structures))
   5.128 +	if (xen_feature(feature))
   5.129  		return;
   5.130 +
   5.131  	while (nr-- != 0) {
   5.132 -		make_mmu_page_writable(va);
   5.133 +		make_page_writable(va, feature);
   5.134  		va = (void *)((unsigned long)va + PAGE_SIZE);
   5.135  	}
   5.136  }
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/features.c	Mon Jan 30 11:23:32 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/features.c	Mon Jan 30 12:49:31 2006 +0100
     6.3 @@ -3,27 +3,36 @@
     6.4   *
     6.5   * Xen feature flags.
     6.6   *
     6.7 - * Copyright (c) 2006, Ian Campbell
     6.8 + * Copyright (c) 2006, Ian Campbell, XenSource Inc.
     6.9   */
    6.10  #include <linux/types.h>
    6.11  #include <linux/cache.h>
    6.12  #include <asm/hypervisor.h>
    6.13  #include <asm-xen/features.h>
    6.14  
    6.15 -/* When we rebase to a more recent version of Linux we can use __read_mostly here. */
    6.16 +/* When we rebase to a more recent Linux we can use __read_mostly here. */
    6.17  unsigned long xen_features[XENFEAT_NR_SUBMAPS] __cacheline_aligned;
    6.18  
    6.19  void setup_xen_features(void)
    6.20  {
    6.21 -     uint32_t *flags = (uint32_t *)&xen_features[0];
    6.22 -     xen_feature_info_t fi;
    6.23 -     int i;
    6.24 +	uint32_t *flags = (uint32_t *)&xen_features[0];
    6.25 +	xen_feature_info_t fi;
    6.26 +	int i;
    6.27  
    6.28 -     for (i=0; i<XENFEAT_NR_SUBMAPS; i++) {
    6.29 -	  fi.submap_idx = i;
    6.30 -	  if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
    6.31 -	       break;
    6.32 -	  flags[i] = fi.submap;
    6.33 -     }
    6.34 +	for (i=0; i<XENFEAT_NR_SUBMAPS; i++) {
    6.35 +		fi.submap_idx = i;
    6.36 +		if (HYPERVISOR_xen_version(XENVER_get_features, &fi) < 0)
    6.37 +			break;
    6.38 +		flags[i] = fi.submap;
    6.39 +	}
    6.40  }
    6.41  
    6.42 +/*
    6.43 + * Local variables:
    6.44 + *  c-file-style: "linux"
    6.45 + *  indent-tabs-mode: t
    6.46 + *  c-indent-level: 8
    6.47 + *  c-basic-offset: 8
    6.48 + *  tab-width: 8
    6.49 + * End:
    6.50 + */
     7.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Mon Jan 30 11:23:32 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Mon Jan 30 12:49:31 2006 +0100
     7.3 @@ -239,7 +239,9 @@ void __init smp_prepare_cpus(unsigned in
     7.4  		memcpy((void *)cpu_gdt_descr[cpu].address,
     7.5  		       (void *)cpu_gdt_descr[0].address,
     7.6  		       cpu_gdt_descr[0].size);
     7.7 -		make_mmu_page_readonly((void *)cpu_gdt_descr[cpu].address);
     7.8 +		make_page_readonly(
     7.9 +			(void *)cpu_gdt_descr[cpu].address,
    7.10 +			XENFEAT_writable_descriptor_tables);
    7.11  
    7.12  		cpu_set(cpu, cpu_possible_map);
    7.13  #ifdef CONFIG_HOTPLUG_CPU
     8.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ldt.c	Mon Jan 30 11:23:32 2006 +0100
     8.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/ldt.c	Mon Jan 30 12:49:31 2006 +0100
     8.3 @@ -65,8 +65,10 @@ static int alloc_ldt(mm_context_t *pc, u
     8.4  
     8.5  		preempt_disable();
     8.6  #endif
     8.7 -		make_mmu_pages_readonly(pc->ldt, (pc->size * LDT_ENTRY_SIZE) /
     8.8 -					PAGE_SIZE);
     8.9 +		make_pages_readonly(
    8.10 +			pc->ldt,
    8.11 +			(pc->size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    8.12 +			XENFEAT_writable_descriptor_tables);
    8.13  		load_LDT(pc);
    8.14  #ifdef CONFIG_SMP
    8.15  		mask = cpumask_of_cpu(smp_processor_id());
    8.16 @@ -76,8 +78,10 @@ static int alloc_ldt(mm_context_t *pc, u
    8.17  #endif
    8.18  	}
    8.19  	if (oldsize) {
    8.20 -		make_mmu_pages_writable(oldldt, (oldsize * LDT_ENTRY_SIZE) /
    8.21 -			PAGE_SIZE);
    8.22 +		make_pages_writable(
    8.23 +			oldldt,
    8.24 +			(oldsize * LDT_ENTRY_SIZE) / PAGE_SIZE,
    8.25 +			XENFEAT_writable_descriptor_tables);
    8.26  		if (oldsize*LDT_ENTRY_SIZE > PAGE_SIZE)
    8.27  			vfree(oldldt);
    8.28  		else
    8.29 @@ -92,8 +96,10 @@ static inline int copy_ldt(mm_context_t 
    8.30  	if (err < 0)
    8.31  		return err;
    8.32  	memcpy(new->ldt, old->ldt, old->size*LDT_ENTRY_SIZE);
    8.33 -	make_mmu_pages_readonly(new->ldt, (new->size * LDT_ENTRY_SIZE) /
    8.34 -				PAGE_SIZE);
    8.35 +	make_pages_readonly(
    8.36 +		new->ldt,
    8.37 +		(new->size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    8.38 +		XENFEAT_writable_descriptor_tables);
    8.39  	return 0;
    8.40  }
    8.41  
    8.42 @@ -131,9 +137,10 @@ void destroy_context(struct mm_struct *m
    8.43  	if (mm->context.size) {
    8.44  		if (mm == current->active_mm)
    8.45  			clear_LDT();
    8.46 -		make_mmu_pages_writable(mm->context.ldt,
    8.47 -					(mm->context.size * LDT_ENTRY_SIZE) /
    8.48 -					PAGE_SIZE);
    8.49 +		make_pages_writable(
    8.50 +			mm->context.ldt,
    8.51 +			(mm->context.size * LDT_ENTRY_SIZE) / PAGE_SIZE,
    8.52 +			XENFEAT_writable_descriptor_tables);
    8.53  		if (mm->context.size*LDT_ENTRY_SIZE > PAGE_SIZE)
    8.54  			vfree(mm->context.ldt);
    8.55  		else
     9.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Mon Jan 30 11:23:32 2006 +0100
     9.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Mon Jan 30 12:49:31 2006 +0100
     9.3 @@ -141,7 +141,8 @@ void __cpuinit cpu_gdt_init(struct desc_
     9.4  	     va < gdt_descr->address + gdt_descr->size;
     9.5  	     va += PAGE_SIZE, f++) {
     9.6  		frames[f] = virt_to_mfn(va);
     9.7 -		make_mmu_page_readonly((void *)va);
     9.8 +		make_page_readonly(
     9.9 +			(void *)va, XENFEAT_writable_descriptor_tables);
    9.10  	}
    9.11  	if (HYPERVISOR_set_gdt(frames, gdt_descr->size /
    9.12                                 sizeof (struct desc_struct)))
    10.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Mon Jan 30 11:23:32 2006 +0100
    10.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/mm/init.c	Mon Jan 30 12:49:31 2006 +0100
    10.3 @@ -68,13 +68,13 @@ extern unsigned long start_pfn;
    10.4  	(((mfn_to_pfn((addr) >> PAGE_SHIFT)) << PAGE_SHIFT) +	\
    10.5  	__START_KERNEL_map)))
    10.6  
    10.7 -static void early_make_mmu_page_readonly(void *va)
    10.8 +static void early_make_page_readonly(void *va, unsigned int feature)
    10.9  {
   10.10  	unsigned long addr, _va = (unsigned long)va;
   10.11  	pte_t pte, *ptep;
   10.12  	unsigned long *page = (unsigned long *) init_level4_pgt;
   10.13  
   10.14 -	if (xen_feature(writable_mmu_structures))
   10.15 +	if (xen_feature(feature))
   10.16  		return;
   10.17  
   10.18  	addr = (unsigned long) page[pgd_index(_va)];
   10.19 @@ -93,12 +93,12 @@ static void early_make_mmu_page_readonly
   10.20  		BUG();
   10.21  }
   10.22  
   10.23 -void make_mmu_page_readonly(void *va)
   10.24 +void make_page_readonly(void *va, unsigned int feature)
   10.25  {
   10.26  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
   10.27  	unsigned long addr = (unsigned long) va;
   10.28  
   10.29 -	if (xen_feature(writable_mmu_structures))
   10.30 +	if (xen_feature(feature))
   10.31  		return;
   10.32  
   10.33  	pgd = pgd_offset_k(addr);
   10.34 @@ -111,15 +111,15 @@ void make_mmu_page_readonly(void *va)
   10.35  		xen_l1_entry_update(ptep, pte); /* fallback */
   10.36  
   10.37  	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
   10.38 -		make_mmu_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT));
   10.39 +		make_page_readonly(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
   10.40  }
   10.41  
   10.42 -void make_mmu_page_writable(void *va)
   10.43 +void make_page_writable(void *va, unsigned int feature)
   10.44  {
   10.45  	pgd_t *pgd; pud_t *pud; pmd_t *pmd; pte_t pte, *ptep;
   10.46  	unsigned long addr = (unsigned long) va;
   10.47  
   10.48 -	if (xen_feature(writable_mmu_structures))
   10.49 +	if (xen_feature(feature))
   10.50  		return;
   10.51  
   10.52  	pgd = pgd_offset_k(addr);
   10.53 @@ -132,26 +132,27 @@ void make_mmu_page_writable(void *va)
   10.54  		xen_l1_entry_update(ptep, pte); /* fallback */
   10.55  
   10.56  	if ((addr >= VMALLOC_START) && (addr < VMALLOC_END))
   10.57 -		make_mmu_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT));
   10.58 +		make_page_writable(__va(pte_pfn(pte) << PAGE_SHIFT), feature);
   10.59  }
   10.60  
   10.61 -void make_mmu_pages_readonly(void *va, unsigned nr)
   10.62 +void make_pages_readonly(void *va, unsigned nr, unsigned int feature)
   10.63  {
   10.64 -	if (xen_feature(writable_mmu_structures))
   10.65 +	if (xen_feature(feature))
   10.66  		return;
   10.67  
   10.68  	while (nr-- != 0) {
   10.69 -		make_mmu_page_readonly(va);
   10.70 +		make_page_readonly(va, feature);
   10.71  		va = (void*)((unsigned long)va + PAGE_SIZE);
   10.72  	}
   10.73  }
   10.74  
   10.75 -void make_mmu_pages_writable(void *va, unsigned nr)
   10.76 +void make_pages_writable(void *va, unsigned nr, unsigned int feature)
   10.77  {
   10.78 -	if (xen_feature(writable_mmu_structures))
   10.79 +	if (xen_feature(feature))
   10.80  		return;
   10.81 +
   10.82  	while (nr-- != 0) {
   10.83 -		make_mmu_page_writable(va);
   10.84 +		make_page_writable(va, feature);
   10.85  		va = (void*)((unsigned long)va + PAGE_SIZE);
   10.86  	}
   10.87  }
   10.88 @@ -239,7 +240,7 @@ static void set_pte_phys(unsigned long v
   10.89  	pud = (user_mode ? pud_offset_u(vaddr) : pud_offset(pgd, vaddr));
   10.90  	if (pud_none(*pud)) {
   10.91  		pmd = (pmd_t *) spp_getpage(); 
   10.92 -		make_mmu_page_readonly(pmd);
   10.93 +		make_page_readonly(pmd, XENFEAT_writable_page_tables);
   10.94  		xen_pmd_pin(__pa(pmd));
   10.95  		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
   10.96  		if (pmd != pmd_offset(pud, 0)) {
   10.97 @@ -250,7 +251,7 @@ static void set_pte_phys(unsigned long v
   10.98  	pmd = pmd_offset(pud, vaddr);
   10.99  	if (pmd_none(*pmd)) {
  10.100  		pte = (pte_t *) spp_getpage();
  10.101 -		make_mmu_page_readonly(pte);
  10.102 +		make_page_readonly(pte, XENFEAT_writable_page_tables);
  10.103  		xen_pte_pin(__pa(pte));
  10.104  		set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
  10.105  		if (pte != pte_offset_kernel(pmd, 0)) {
  10.106 @@ -292,7 +293,7 @@ static void set_pte_phys_ma(unsigned lon
  10.107  	if (pud_none(*pud)) {
  10.108  
  10.109  		pmd = (pmd_t *) spp_getpage(); 
  10.110 -		make_mmu_page_readonly(pmd);
  10.111 +		make_page_readonly(pmd, XENFEAT_writable_page_tables);
  10.112  		xen_pmd_pin(__pa(pmd));
  10.113  
  10.114  		set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
  10.115 @@ -306,7 +307,7 @@ static void set_pte_phys_ma(unsigned lon
  10.116  
  10.117  	if (pmd_none(*pmd)) {
  10.118  		pte = (pte_t *) spp_getpage();
  10.119 -		make_mmu_page_readonly(pte);
  10.120 +		make_page_readonly(pte, XENFEAT_writable_page_tables);
  10.121  		xen_pte_pin(__pa(pte));
  10.122  
  10.123  		set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
  10.124 @@ -401,11 +402,9 @@ static inline int make_readonly(unsigned
  10.125  {
  10.126  	int readonly = 0;
  10.127  
  10.128 -	if (xen_feature(writable_mmu_structures))
  10.129 -		return 0;
  10.130 -
  10.131  	/* Make old and new page tables read-only. */
  10.132 -	if ((paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
  10.133 +	if (!xen_feature(XENFEAT_writable_page_tables)
  10.134 +	    && (paddr >= (xen_start_info->pt_base - __START_KERNEL_map))
  10.135  	    && (paddr < ((table_start << PAGE_SHIFT) + tables_space)))
  10.136  		readonly = 1;
  10.137  	/*
  10.138 @@ -438,7 +437,7 @@ static void __init phys_pud_init(pud_t *
  10.139  		} 
  10.140  
  10.141  		pmd = alloc_static_page(&pmd_phys);
  10.142 -		early_make_mmu_page_readonly(pmd);
  10.143 +		early_make_page_readonly(pmd, XENFEAT_writable_page_tables);
  10.144  		xen_pmd_pin(pmd_phys);
  10.145  		set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
  10.146        		for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
  10.147 @@ -467,7 +466,8 @@ static void __init phys_pud_init(pud_t *
  10.148  				__set_pte(pte, __pte(paddr | _KERNPG_TABLE));
  10.149  			}
  10.150  			pte = pte_save;
  10.151 -			early_make_mmu_page_readonly(pte);
  10.152 +			early_make_page_readonly(
  10.153 +				pte, XENFEAT_writable_page_tables);
  10.154  			xen_pte_pin(pte_phys);
  10.155  			set_pmd(pmd, __pmd(pte_phys | _KERNPG_TABLE));
  10.156  		}
  10.157 @@ -516,11 +516,16 @@ void __init xen_init_pt(void)
  10.158  		      _KERNPG_TABLE | _PAGE_USER);
  10.159  	memcpy((void *)level2_kernel_pgt, page, PAGE_SIZE);
  10.160  
  10.161 -	early_make_mmu_page_readonly(init_level4_pgt);
  10.162 -	early_make_mmu_page_readonly(init_level4_user_pgt);
  10.163 -	early_make_mmu_page_readonly(level3_kernel_pgt);
  10.164 -	early_make_mmu_page_readonly(level3_user_pgt);
  10.165 -	early_make_mmu_page_readonly(level2_kernel_pgt);
  10.166 +	early_make_page_readonly(init_level4_pgt,
  10.167 +				 XENFEAT_writable_page_tables);
  10.168 +	early_make_page_readonly(init_level4_user_pgt,
  10.169 +				 XENFEAT_writable_page_tables));
  10.170 +	early_make_page_readonly(level3_kernel_pgt,
  10.171 +				 XENFEAT_writable_page_tables));
  10.172 +	early_make_page_readonly(level3_user_pgt,
  10.173 +				 XENFEAT_writable_page_tables));
  10.174 +	early_make_page_readonly(level2_kernel_pgt,
  10.175 +				 XENFEAT_writable_page_tables));
  10.176  
  10.177  	xen_pgd_pin(__pa_symbol(init_level4_pgt));
  10.178  	xen_pgd_pin(__pa_symbol(init_level4_user_pgt));
  10.179 @@ -558,7 +563,8 @@ void __init extend_init_mapping(void)
  10.180  		pmd = (pmd_t *)&page[pmd_index(va)];
  10.181  		if (pmd_none(*pmd)) {
  10.182  			pte_page = alloc_static_page(&phys);
  10.183 -			early_make_mmu_page_readonly(pte_page);
  10.184 +			early_make_page_readonly(
  10.185 +				pte_page, XENFEAT_writable_page_tables);
  10.186  			xen_pte_pin(phys);
  10.187  			set_pmd(pmd, __pmd(phys | _KERNPG_TABLE | _PAGE_USER));
  10.188  		} else {
  10.189 @@ -605,7 +611,7 @@ void __init init_memory_mapping(unsigned
  10.190  	for (; start < end; start = next) {
  10.191  		unsigned long pud_phys; 
  10.192  		pud_t *pud = alloc_static_page(&pud_phys);
  10.193 -		early_make_mmu_page_readonly(pud);
  10.194 +		early_make_page_readonly(pud, XENFEAT_writable_page_tables);
  10.195  		xen_pud_pin(pud_phys);
  10.196  		next = start + PGDIR_SIZE;
  10.197  		if (next > end) 
  10.198 @@ -810,11 +816,13 @@ void free_initmem(void)
  10.199  		set_page_count(virt_to_page(addr), 1);
  10.200  		memset((void *)(addr & ~(PAGE_SIZE-1)), 0xcc, PAGE_SIZE); 
  10.201  		xen_pte_unpin(__pa(addr));
  10.202 -		make_mmu_page_writable(__va(__pa(addr)));
  10.203 +		make_page_writable(
  10.204 +			__va(__pa(addr)), XENFEAT_writable_page_tables);
  10.205  		/*
  10.206  		 * Make pages from __PAGE_OFFSET address as well
  10.207  		 */
  10.208 -		make_mmu_page_writable((void *)addr);
  10.209 +		make_page_writable(
  10.210 +			(void *)addr, XENFEAT_writable_page_tables);
  10.211  		free_page(addr);
  10.212  		totalram_pages++;
  10.213  	}
    11.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Mon Jan 30 11:23:32 2006 +0100
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Mon Jan 30 12:49:31 2006 +0100
    11.3 @@ -42,7 +42,7 @@ extern struct page *pte_alloc_one(struct
    11.4  static inline void pte_free_kernel(pte_t *pte)
    11.5  {
    11.6  	free_page((unsigned long)pte);
    11.7 -	make_mmu_page_writable(pte);
    11.8 +	make_page_writable(pte, XENFEAT_writable_page_tables);
    11.9  }
   11.10  
   11.11  extern void pte_free(struct page *pte);
    12.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Jan 30 11:23:32 2006 +0100
    12.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Mon Jan 30 12:49:31 2006 +0100
    12.3 @@ -412,21 +412,13 @@ do {				  					\
    12.4  	ptep_set_access_flags(__vma, __address, __ptep, __entry, 1);	\
    12.5  } while (0)
    12.6  
    12.7 -#ifndef CONFIG_XEN_SHADOW_MODE
    12.8 -void make_lowmem_mmu_page_readonly(void *va);
    12.9 -void make_lowmem_mmu_page_writable(void *va);
   12.10 -void make_mmu_page_readonly(void *va);
   12.11 -void make_mmu_page_writable(void *va);
   12.12 -void make_mmu_pages_readonly(void *va, unsigned int nr);
   12.13 -void make_mmu_pages_writable(void *va, unsigned int nr);
   12.14 -#else
   12.15 -#define make_lowmem_mmu_page_readonly(_va) ((void)0)
   12.16 -#define make_lowmem_mmu_page_writable(_va)     ((void)0)
   12.17 -#define make_mmu_page_readonly(_va)        ((void)0)
   12.18 -#define make_mmu_page_writable(_va)            ((void)0)
   12.19 -#define make_mmu_pages_readonly(_va, _nr)  ((void)0)
   12.20 -#define make_mmu_pages_writable(_va, _nr)      ((void)0)
   12.21 -#endif
   12.22 +#include <asm-xen/features.h>
   12.23 +void make_lowmem_page_readonly(void *va, unsigned int feature);
   12.24 +void make_lowmem_page_writable(void *va, unsigned int feature);
   12.25 +void make_page_readonly(void *va, unsigned int feature);
   12.26 +void make_page_writable(void *va, unsigned int feature);
   12.27 +void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
   12.28 +void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
   12.29  
   12.30  #define virt_to_ptep(__va)						\
   12.31  ({									\
    13.1 --- a/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgalloc.h	Mon Jan 30 11:23:32 2006 +0100
    13.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/asm-x86_64/pgalloc.h	Mon Jan 30 12:49:31 2006 +0100
    13.3 @@ -7,10 +7,11 @@
    13.4  #include <linux/mm.h>
    13.5  #include <asm/io.h>		/* for phys_to_virt and page_to_pseudophys */
    13.6  
    13.7 -void make_mmu_page_readonly(void *va);
    13.8 -void make_mmu_page_writable(void *va);
    13.9 -void make_mmu_pages_readonly(void *va, unsigned int nr);
   13.10 -void make_mmu_pages_writable(void *va, unsigned int nr);
   13.11 +#include <asm-xen/features.h>
   13.12 +void make_page_readonly(void *va, unsigned int feature);
   13.13 +void make_page_writable(void *va, unsigned int feature);
   13.14 +void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
   13.15 +void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
   13.16  
   13.17  #define __user_pgd(pgd) ((pgd) + PTRS_PER_PGD)
   13.18  
   13.19 @@ -161,7 +162,7 @@ static inline pte_t *pte_alloc_one_kerne
   13.20  {
   13.21          pte_t *pte = (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
   13.22          if (pte)
   13.23 -		make_mmu_page_readonly(pte);
   13.24 +		make_page_readonly(pte, XENFEAT_writable_page_tables);
   13.25  
   13.26  	return pte;
   13.27  }
   13.28 @@ -181,7 +182,7 @@ extern __inline__ void pte_free_kernel(p
   13.29  {
   13.30  	BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
   13.31          xen_pte_unpin(__pa(pte));
   13.32 -        make_mmu_page_writable(pte);
   13.33 +        make_page_writable(pte, XENFEAT_writable_page_tables);
   13.34  	free_page((unsigned long)pte); 
   13.35  }
   13.36  
    14.1 --- a/linux-2.6-xen-sparse/include/asm-xen/features.h	Mon Jan 30 11:23:32 2006 +0100
    14.2 +++ b/linux-2.6-xen-sparse/include/asm-xen/features.h	Mon Jan 30 12:49:31 2006 +0100
    14.3 @@ -15,6 +15,6 @@ extern void setup_xen_features(void);
    14.4  
    14.5  extern unsigned long xen_features[XENFEAT_NR_SUBMAPS];
    14.6  
    14.7 -#define xen_feature(flag)	(test_bit(_XENFEAT_ ## flag, xen_features))
    14.8 +#define xen_feature(flag)	(test_bit(flag, xen_features))
    14.9  
   14.10 -#endif
   14.11 +#endif /* __ASM_XEN_FEATURES_H__ */
    15.1 --- a/xen/include/public/version.h	Mon Jan 30 11:23:32 2006 +0100
    15.2 +++ b/xen/include/public/version.h	Mon Jan 30 12:49:31 2006 +0100
    15.3 @@ -45,8 +45,8 @@ typedef struct xen_feature_info {
    15.4      uint32_t     submap;        /* OUT: 32-bit submap */
    15.5  } xen_feature_info_t;
    15.6  
    15.7 -#define _XENFEAT_writable_mmu_structures 0
    15.8 -#define XENFEAT_writable_mmu_structures (1UL<<_XENFEAT_writable_mmu_structures)
    15.9 +#define XENFEAT_writable_page_tables       0
   15.10 +#define XENFEAT_writable_descriptor_tables 1
   15.11  
   15.12  #define XENFEAT_NR_SUBMAPS 1
   15.13