ia64/xen-unstable

changeset 4687:0f620bc56828

bitkeeper revision 1.1159.258.108 (4270fff77uXrP6ebmHEte60f5WLI-w)

pgtable.c:
Use virt_to_ptep.
pgtable.h:
add virt_to_ptep.
author cl349@firebug.cl.cam.ac.uk
date Thu Apr 28 15:23:35 2005 +0000 (2005-04-28)
parents a71203a12503
children c9edf0896f07 5ca208755ef2
files linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Apr 28 15:08:57 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/i386/mm/pgtable.c	Thu Apr 28 15:23:35 2005 +0000
     1.3 @@ -374,28 +374,19 @@ void pgd_free(pgd_t *pgd)
     1.4  
     1.5  void make_lowmem_page_readonly(void *va)
     1.6  {
     1.7 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
     1.8 -	pud_t *pud = pud_offset(pgd, (unsigned long)va);
     1.9 -	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
    1.10 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    1.11 +	pte_t *pte = virt_to_ptep(va);
    1.12  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    1.13  }
    1.14  
    1.15  void make_lowmem_page_writable(void *va)
    1.16  {
    1.17 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    1.18 -	pud_t *pud = pud_offset(pgd, (unsigned long)va);
    1.19 -	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
    1.20 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    1.21 +	pte_t *pte = virt_to_ptep(va);
    1.22  	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    1.23  }
    1.24  
    1.25  void make_page_readonly(void *va)
    1.26  {
    1.27 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    1.28 -	pud_t *pud = pud_offset(pgd, (unsigned long)va);
    1.29 -	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
    1.30 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    1.31 +	pte_t *pte = virt_to_ptep(va);
    1.32  	queue_l1_entry_update(pte, (*(unsigned long *)pte)&~_PAGE_RW);
    1.33  	if ( (unsigned long)va >= (unsigned long)high_memory )
    1.34  	{
    1.35 @@ -410,10 +401,7 @@ void make_page_readonly(void *va)
    1.36  
    1.37  void make_page_writable(void *va)
    1.38  {
    1.39 -	pgd_t *pgd = pgd_offset_k((unsigned long)va);
    1.40 -	pud_t *pud = pud_offset(pgd, (unsigned long)va);
    1.41 -	pmd_t *pmd = pmd_offset(pud, (unsigned long)va);
    1.42 -	pte_t *pte = pte_offset_kernel(pmd, (unsigned long)va);
    1.43 +	pte_t *pte = virt_to_ptep(va);
    1.44  	queue_l1_entry_update(pte, (*(unsigned long *)pte)|_PAGE_RW);
    1.45  	if ( (unsigned long)va >= (unsigned long)high_memory )
    1.46  	{
     2.1 --- a/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Apr 28 15:08:57 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/pgtable.h	Thu Apr 28 15:23:35 2005 +0000
     2.3 @@ -276,6 +276,7 @@ static inline void ptep_set_wrprotect(pt
     2.4  	if (pte_write(pte))
     2.5  		set_pte(ptep, pte_wrprotect(pte));
     2.6  }
     2.7 +
     2.8  static inline void ptep_mkdirty(pte_t *ptep)
     2.9  {
    2.10  	pte_t pte = *ptep;
    2.11 @@ -455,12 +456,17 @@ void make_page_writable(void *va);
    2.12  void make_pages_readonly(void *va, unsigned int nr);
    2.13  void make_pages_writable(void *va, unsigned int nr);
    2.14  
    2.15 -#define arbitrary_virt_to_machine(__va)					\
    2.16 +#define virt_to_ptep(__va)						\
    2.17  ({									\
    2.18  	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
    2.19  	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
    2.20  	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
    2.21 -	pte_t *__pte = pte_offset_kernel(__pmd, (unsigned long)(__va));	\
    2.22 +	pte_offset_kernel(__pmd, (unsigned long)(__va));		\
    2.23 +})
    2.24 +
    2.25 +#define arbitrary_virt_to_machine(__va)					\
    2.26 +({									\
    2.27 +	pte_t *__pte = virt_to_ptep(__va);				\
    2.28  	unsigned long __pa = (*(unsigned long *)__pte) & PAGE_MASK;	\
    2.29  	__pa | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
    2.30  })