ia64/linux-2.6.18-xen.hg

changeset 553:c6e36a53cf05

linux/x86: utilize lookup_address() for virt_to_ptep()
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 15 15:14:31 2008 +0100 (2008-05-15)
parents c3f9cc7789af
children 12e74c1433a6
files arch/x86_64/mm/pageattr-xen.c include/asm-i386/mach-xen/asm/pgtable.h include/asm-x86_64/mach-xen/asm/pgtable.h
line diff
     1.1 --- a/arch/x86_64/mm/pageattr-xen.c	Thu May 15 10:03:29 2008 +0100
     1.2 +++ b/arch/x86_64/mm/pageattr-xen.c	Thu May 15 15:14:31 2008 +0100
     1.3 @@ -276,7 +276,7 @@ void pte_free(struct page *pte)
     1.4  }
     1.5  #endif	/* CONFIG_XEN */
     1.6  
     1.7 -static inline pte_t *lookup_address(unsigned long address) 
     1.8 +pte_t *lookup_address(unsigned long address) 
     1.9  { 
    1.10  	pgd_t *pgd = pgd_offset_k(address);
    1.11  	pud_t *pud;
     2.1 --- a/include/asm-i386/mach-xen/asm/pgtable.h	Thu May 15 10:03:29 2008 +0100
     2.2 +++ b/include/asm-i386/mach-xen/asm/pgtable.h	Thu May 15 15:14:31 2008 +0100
     2.3 @@ -477,19 +477,16 @@ void make_page_writable(void *va, unsign
     2.4  void make_pages_readonly(void *va, unsigned int nr, unsigned int feature);
     2.5  void make_pages_writable(void *va, unsigned int nr, unsigned int feature);
     2.6  
     2.7 -#define virt_to_ptep(__va)						\
     2.8 +#define virt_to_ptep(va)						\
     2.9  ({									\
    2.10 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
    2.11 -	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
    2.12 -	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
    2.13 -	pte_offset_kernel(__pmd, (unsigned long)(__va));		\
    2.14 +	pte_t *__ptep = lookup_address((unsigned long)(va));		\
    2.15 +	BUG_ON(!__ptep || !pte_present(*__ptep));			\
    2.16 +	__ptep;								\
    2.17  })
    2.18  
    2.19 -#define arbitrary_virt_to_machine(__va)					\
    2.20 -({									\
    2.21 -	maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
    2.22 -	m | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
    2.23 -})
    2.24 +#define arbitrary_virt_to_machine(va)					\
    2.25 +	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
    2.26 +	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
    2.27  
    2.28  #endif /* !__ASSEMBLY__ */
    2.29  
     3.1 --- a/include/asm-x86_64/mach-xen/asm/pgtable.h	Thu May 15 10:03:29 2008 +0100
     3.2 +++ b/include/asm-x86_64/mach-xen/asm/pgtable.h	Thu May 15 15:14:31 2008 +0100
     3.3 @@ -18,19 +18,18 @@ extern pud_t level3_user_pgt[512];
     3.4  
     3.5  extern void xen_init_pt(void);
     3.6  
     3.7 -#define virt_to_ptep(__va)						\
     3.8 +extern pte_t *lookup_address(unsigned long address);
     3.9 +
    3.10 +#define virt_to_ptep(va)						\
    3.11  ({									\
    3.12 -	pgd_t *__pgd = pgd_offset_k((unsigned long)(__va));		\
    3.13 -	pud_t *__pud = pud_offset(__pgd, (unsigned long)(__va));	\
    3.14 -	pmd_t *__pmd = pmd_offset(__pud, (unsigned long)(__va));	\
    3.15 -	pte_offset_kernel(__pmd, (unsigned long)(__va));		\
    3.16 +	pte_t *__ptep = lookup_address((unsigned long)(va));		\
    3.17 +	BUG_ON(!__ptep || !pte_present(*__ptep));			\
    3.18 +	__ptep;								\
    3.19  })
    3.20  
    3.21 -#define arbitrary_virt_to_machine(__va)					\
    3.22 -({									\
    3.23 -	maddr_t m = (maddr_t)pte_mfn(*virt_to_ptep(__va)) << PAGE_SHIFT;\
    3.24 -	m | ((unsigned long)(__va) & (PAGE_SIZE-1));			\
    3.25 -})
    3.26 +#define arbitrary_virt_to_machine(va)					\
    3.27 +	(((maddr_t)pte_mfn(*virt_to_ptep(va)) << PAGE_SHIFT)		\
    3.28 +	 | ((unsigned long)(va) & (PAGE_SIZE - 1)))
    3.29  #endif
    3.30  
    3.31  extern pud_t level3_kernel_pgt[512];