ia64/xen-unstable

changeset 5277:984dc9d51248

bitkeeper revision 1.1642 (429f43a9Urbk2TjIlm7NZJ_Z8LDQQQ)

l?e_from_paddr() expects the physical address to already be page
aligned. Fix map_domain_mem() to do this, and add an assertion to the
macros to check for it in debug builds.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Jun 02 17:36:41 2005 +0000 (2005-06-02)
parents c1a4141f0cdc
children 7a15cc6f1147 fbb832f71d22
files xen/arch/x86/x86_32/domain_page.c xen/include/asm-x86/page.h
line diff
     1.1 --- a/xen/arch/x86/x86_32/domain_page.c	Thu Jun 02 17:00:40 2005 +0000
     1.2 +++ b/xen/arch/x86/x86_32/domain_page.c	Thu Jun 02 17:36:41 2005 +0000
     1.3 @@ -72,7 +72,7 @@ void *map_domain_mem(unsigned long pa)
     1.4      }
     1.5      while ( l1e_get_flags(cache[idx]) & _PAGE_PRESENT );
     1.6  
     1.7 -    cache[idx] = l1e_from_paddr(pa, __PAGE_HYPERVISOR);
     1.8 +    cache[idx] = l1e_from_paddr(pa & PAGE_MASK, __PAGE_HYPERVISOR);
     1.9  
    1.10      spin_unlock(&map_lock);
    1.11  
     2.1 --- a/xen/include/asm-x86/page.h	Thu Jun 02 17:00:40 2005 +0000
     2.2 +++ b/xen/include/asm-x86/page.h	Thu Jun 02 17:36:41 2005 +0000
     2.3 @@ -75,14 +75,32 @@
     2.4      ((l4_pgentry_t) { ((intpte_t)(pfn) << PAGE_SHIFT) | put_pte_flags(flags) })
     2.5  
     2.6  /* Construct a pte from a physical address and access flags. */
     2.7 -#define l1e_from_paddr(pa, flags)  \
     2.8 -    ((l1_pgentry_t) { (pa) | put_pte_flags(flags) })
     2.9 -#define l2e_from_paddr(pa, flags)  \
    2.10 -    ((l2_pgentry_t) { (pa) | put_pte_flags(flags) })
    2.11 -#define l3e_from_paddr(pa, flags)  \
    2.12 -    ((l3_pgentry_t) { (pa) | put_pte_flags(flags) })
    2.13 -#define l4e_from_paddr(pa, flags)  \
    2.14 -    ((l4_pgentry_t) { (pa) | put_pte_flags(flags) })
    2.15 +#ifndef __ASSEMBLY__
    2.16 +static inline l1_pgentry_t l1e_from_paddr(physaddr_t pa, unsigned int flags)
    2.17 +{
    2.18 +    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
    2.19 +    return (l1_pgentry_t) { pa | put_pte_flags(flags) };
    2.20 +}
    2.21 +static inline l2_pgentry_t l2e_from_paddr(physaddr_t pa, unsigned int flags)
    2.22 +{
    2.23 +    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
    2.24 +    return (l2_pgentry_t) { pa | put_pte_flags(flags) };
    2.25 +}
    2.26 +#if CONFIG_PAGING_LEVELS >= 3
    2.27 +static inline l3_pgentry_t l3e_from_paddr(physaddr_t pa, unsigned int flags)
    2.28 +{
    2.29 +    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
    2.30 +    return (l3_pgentry_t) { pa | put_pte_flags(flags) };
    2.31 +}
    2.32 +#endif
    2.33 +#if CONFIG_PAGING_LEVELS >= 4
    2.34 +static inline l4_pgentry_t l4e_from_paddr(physaddr_t pa, unsigned int flags)
    2.35 +{
    2.36 +    ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0);
    2.37 +    return (l4_pgentry_t) { pa | put_pte_flags(flags) };
    2.38 +}
    2.39 +#endif
    2.40 +#endif /* !__ASSEMBLY__ */
    2.41  
    2.42  /* Construct a pte from its direct integer representation. */
    2.43  #define l1e_from_intpte(intpte)    ((l1_pgentry_t) { (intpte_t)(intpte) })