ia64/xen-unstable

changeset 2034:ad46030c8989

bitkeeper revision 1.1108.33.32 (410e6153m76cWDqwoNiwLL3JboItbA)

fix zapping of pages mapped for/from other domains
author cl349@freefall.cl.cam.ac.uk
date Mon Aug 02 15:44:19 2004 +0000 (2004-08-02)
parents 67defb498ac1
children 0a0752383e51
files linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h
line diff
     1.1 --- a/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Mon Aug 02 14:58:10 2004 +0000
     1.2 +++ b/linux-2.6.7-xen-sparse/include/asm-xen/asm-i386/pgtable-2level.h	Mon Aug 02 15:44:19 2004 +0000
     1.3 @@ -75,10 +75,38 @@ static inline pte_t ptep_get_and_clear(p
     1.4  }
     1.5  
     1.6  #define pte_same(a, b)		((a).pte_low == (b).pte_low)
     1.7 -#define pte_page(x)		pfn_to_page(pte_pfn(x))
     1.8 +/*                                 
     1.9 + * We detect special mappings in one of two ways:
    1.10 + *  1. If the MFN is an I/O page then Xen will set the m2p entry
    1.11 + *     to be outside our maximum possible pseudophys range.
    1.12 + *  2. If the MFN belongs to a different domain then we will certainly
    1.13 + *     not have MFN in our p2m table. Conversely, if the page is ours,
    1.14 + *     then we'll have p2m(m2p(MFN))==MFN.
    1.15 + * If we detect a special mapping then it doesn't have a 'struct page'.
    1.16 + * We force !VALID_PAGE() by returning an out-of-range pointer.
    1.17 + */
    1.18 +#define pte_page(_pte)                                        \
    1.19 +({                                                            \
    1.20 +    unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;         \
    1.21 +    unsigned long pfn = mfn_to_pfn(mfn);                      \
    1.22 +    if ( (pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn) )     \
    1.23 +        pfn = max_mapnr; /* special: force !VALID_PAGE() */   \
    1.24 +    pfn_to_page(pfn);                                         \
    1.25 +})
    1.26 +
    1.27  #define pte_none(x)		(!(x).pte_low)
    1.28 -/* XXXcl check valid because msync.c:filemap_sync_pte calls without pte_present check */
    1.29 -#define pte_pfn(x)		((unsigned long)((((x).pte_low & 1 ? machine_to_phys((x).pte_low) : (x).pte_low) >> PAGE_SHIFT)))
    1.30 +/* See comments above pte_page */
    1.31 +/* XXXcl check pte_present because msync.c:filemap_sync_pte calls
    1.32 + * without pte_present check */
    1.33 +#define pte_pfn(_pte)                                                   \
    1.34 +({                                                                      \
    1.35 +    unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;                   \
    1.36 +    unsigned long pfn = pte_present(_pte) ? mfn_to_pfn(mfn) : mfn;      \
    1.37 +    if ( (pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn) )               \
    1.38 +        pfn = max_mapnr; /* special: force !pfn_valid() */              \
    1.39 +    pfn;                                                                \
    1.40 +})
    1.41 +
    1.42  #define pfn_pte(pfn, prot)	__pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
    1.43  #define pfn_pte_ma(pfn, prot)	__pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
    1.44  #define pfn_pmd(pfn, prot)	__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))