ia64/xen-unstable

changeset 2990:6a8961902567

bitkeeper revision 1.1159.170.29 (419a0009K2EoexbNZXY_leDTaivx2w)

Fix make_page_{readonly,writable} to deal properly with highmem.
author kaf24@freefall.cl.cam.ac.uk
date Tue Nov 16 13:26:33 2004 +0000 (2004-11-16)
parents 6a8849c4b647
children 00823b8a8bfb
files linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c linux-2.6.9-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgalloc.h linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgtable.h
line diff
     1.1 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c	Tue Nov 16 12:58:33 2004 +0000
     1.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/kernel/traps.c	Tue Nov 16 13:26:33 2004 +0000
     1.3 @@ -1064,7 +1064,7 @@ void __init trap_init(void)
     1.4  	clear_page(&default_ldt[0]);
     1.5  	set_call_gate(&default_ldt[0],lcall7);
     1.6  	set_call_gate(&default_ldt[4],lcall27);
     1.7 -	__make_page_readonly(&default_ldt[0]);
     1.8 +	make_lowmem_page_readonly(&default_ldt[0]);
     1.9  	xen_flush_page_update_queue();
    1.10  
    1.11  	/*
     2.1 --- a/linux-2.6.9-xen-sparse/arch/xen/i386/mm/pgtable.c	Tue Nov 16 12:58:33 2004 +0000
     2.2 +++ b/linux-2.6.9-xen-sparse/arch/xen/i386/mm/pgtable.c	Tue Nov 16 13:26:33 2004 +0000
     2.3 @@ -179,7 +179,7 @@ pte_t *pte_alloc_one_kernel(struct mm_st
     2.4  	pte_t *pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT);
     2.5  	if (pte) {
     2.6  		clear_page(pte);
     2.7 -		__make_page_readonly(pte);
     2.8 +		make_page_readonly(pte);
     2.9  		xen_flush_page_update_queue();
    2.10  	}
    2.11  	return pte;
    2.12 @@ -192,7 +192,7 @@ void pte_ctor(void *pte, kmem_cache_t *c
    2.13  	set_page_count(page, 1);
    2.14  
    2.15  	clear_page(pte);
    2.16 -	__make_page_readonly(pte);
    2.17 +	make_page_readonly(pte);
    2.18  	queue_pte_pin(virt_to_phys(pte));
    2.19  	flush_page_update_queue();
    2.20  }
    2.21 @@ -203,7 +203,7 @@ void pte_dtor(void *pte, kmem_cache_t *c
    2.22  	ClearPageForeign(page);
    2.23  
    2.24  	queue_pte_unpin(virt_to_phys(pte));
    2.25 -	__make_page_writable(pte);
    2.26 +	make_page_writable(pte);
    2.27  	flush_page_update_queue();
    2.28  }
    2.29  
    2.30 @@ -304,7 +304,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *c
    2.31  	spin_unlock_irqrestore(&pgd_lock, flags);
    2.32  	memset(pgd, 0, USER_PTRS_PER_PGD*sizeof(pgd_t));
    2.33   out:
    2.34 -	__make_page_readonly(pgd);
    2.35 +	make_page_readonly(pgd);
    2.36  	queue_pgd_pin(__pa(pgd));
    2.37  	flush_page_update_queue();
    2.38  }
    2.39 @@ -315,7 +315,7 @@ void pgd_dtor(void *pgd, kmem_cache_t *c
    2.40  	unsigned long flags; /* can be called from interrupt context */
    2.41  
    2.42  	queue_pgd_unpin(__pa(pgd));
    2.43 -	__make_page_writable(pgd);
    2.44 +	make_page_writable(pgd);
    2.45  	flush_page_update_queue();
    2.46  
    2.47  	if (PTRS_PER_PMD > 1)
    2.48 @@ -360,3 +360,71 @@ void pgd_free(pgd_t *pgd)
    2.49  	/* in the non-PAE case, clear_page_tables() clears user pgd entries */
    2.50  	kmem_cache_free(pgd_cache, pgd);
    2.51  }
    2.52 +
    2.53 +void make_lowmem_page_readonly(void *va)
    2.54 +{
    2.55 +	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    2.56 +	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    2.57 +	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    2.58 +	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    2.59 +}
    2.60 +
    2.61 +void make_lowmem_page_writable(void *va)
    2.62 +{
    2.63 +	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    2.64 +	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    2.65 +	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    2.66 +	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    2.67 +}
    2.68 +
    2.69 +void make_page_readonly(void *va)
    2.70 +{
    2.71 +	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    2.72 +	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    2.73 +	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    2.74 +	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    2.75 +	if ( (unsigned long)va >= (unsigned long)high_memory )
    2.76 +	{
    2.77 +		unsigned long phys;
    2.78 +		phys = machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
    2.79 +#ifdef CONFIG_HIGHMEM
    2.80 +		if ( (phys >> PAGE_SHIFT) < highstart_pfn )
    2.81 +#endif
    2.82 +			make_lowmem_page_readonly(phys_to_virt(phys));
    2.83 +	}
    2.84 +}
    2.85 +
    2.86 +void make_page_writable(void *va)
    2.87 +{
    2.88 +	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    2.89 +	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    2.90 +	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    2.91 +	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    2.92 +	if ( (unsigned long)va >= (unsigned long)high_memory )
    2.93 +	{
    2.94 +		unsigned long phys;
    2.95 +		phys = machine_to_phys(*(unsigned long *)pte & PAGE_MASK);
    2.96 +#ifdef CONFIG_HIGHMEM
    2.97 +		if ( (phys >> PAGE_SHIFT) < highstart_pfn )
    2.98 +#endif
    2.99 +			make_lowmem_page_writable(phys_to_virt(phys));
   2.100 +	}
   2.101 +}
   2.102 +
   2.103 +void make_pages_readonly(void *va, unsigned int nr)
   2.104 +{
   2.105 +	while ( nr-- != 0 )
   2.106 +	{
   2.107 +		make_page_readonly(va);
   2.108 +		va = (void *)((unsigned long)va + PAGE_SIZE);
   2.109 +	}
   2.110 +}
   2.111 +
   2.112 +void make_pages_writable(void *va, unsigned int nr)
   2.113 +{
   2.114 +	while ( nr-- != 0 )
   2.115 +	{
   2.116 +		make_page_writable(va);
   2.117 +		va = (void *)((unsigned long)va + PAGE_SIZE);
   2.118 +	}
   2.119 +}
     3.1 --- a/linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Tue Nov 16 12:58:33 2004 +0000
     3.2 +++ b/linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgalloc.h	Tue Nov 16 13:26:33 2004 +0000
     3.3 @@ -32,7 +32,7 @@ extern struct page *pte_alloc_one(struct
     3.4  static inline void pte_free_kernel(pte_t *pte)
     3.5  {
     3.6  	free_page((unsigned long)pte);
     3.7 -	__make_page_writable(pte);
     3.8 +	make_page_writable(pte);
     3.9  	flush_page_update_queue();
    3.10  }
    3.11  
     4.1 --- a/linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Tue Nov 16 12:58:33 2004 +0000
     4.2 +++ b/linux-2.6.9-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Tue Nov 16 13:26:33 2004 +0000
     4.3 @@ -465,61 +465,12 @@ do {				  					\
     4.4  } while (0)
     4.5  
     4.6  /* NOTE: make_page* callers must call flush_page_update_queue() */
     4.7 -static inline void __make_page_readonly(void *va)
     4.8 -{
     4.9 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    4.10 -	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    4.11 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    4.12 -	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    4.13 -}
    4.14 -
    4.15 -static inline void __make_page_writable(void *va)
    4.16 -{
    4.17 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    4.18 -	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    4.19 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    4.20 -	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    4.21 -}
    4.22 -
    4.23 -static inline void make_page_readonly(void *va)
    4.24 -{
    4.25 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    4.26 -	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    4.27 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    4.28 -	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    4.29 -	if ( (unsigned long)va >= VMALLOC_START )
    4.30 -		__make_page_readonly(machine_to_virt(
    4.31 -			*(unsigned long *)pte&PAGE_MASK));
    4.32 -}
    4.33 -
    4.34 -static inline void make_page_writable(void *va)
    4.35 -{
    4.36 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    4.37 -	pmd_t *pmd = pmd_offset(pgd, (unsigned long)va);
    4.38 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    4.39 -	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    4.40 -	if ( (unsigned long)va >= VMALLOC_START )
    4.41 -		__make_page_writable(machine_to_virt(
    4.42 -			*(unsigned long *)pte&PAGE_MASK));
    4.43 -}
    4.44 -
    4.45 -static inline void make_pages_readonly(void *va, unsigned int nr)
    4.46 -{
    4.47 -	while ( nr-- != 0 )
    4.48 -	{
    4.49 -		make_page_readonly(va);
    4.50 -		va = (void *)((unsigned long)va + PAGE_SIZE);
    4.51 -	}
    4.52 -}
    4.53 -
    4.54 -static inline void make_pages_writable(void *va, unsigned int nr)
    4.55 -{
    4.56 -	while ( nr-- != 0 )
    4.57 -	{
    4.58 -		make_page_writable(va);
    4.59 -		va = (void *)((unsigned long)va + PAGE_SIZE);
    4.60 -	}
    4.61 -}
    4.62 +void make_lowmem_page_readonly(void *va);
    4.63 +void make_lowmem_page_writable(void *va);
    4.64 +void make_page_readonly(void *va);
    4.65 +void make_page_writable(void *va);
    4.66 +void make_pages_readonly(void *va, unsigned int nr);
    4.67 +void make_pages_writable(void *va, unsigned int nr);
    4.68  
    4.69  static inline unsigned long arbitrary_virt_to_phys(void *va)
    4.70  {