ia64/xen-unstable

changeset 19443:b8d2f08f98d0

x86: virt_to_mfn() fixes.

Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 31 11:21:14 2009 +0100 (2009-03-31)
parents 687376c92188
children b89a9e97bd39
files xen/common/page_alloc.c xen/include/asm-x86/x86_32/page.h xen/include/asm-x86/x86_64/page.h
line diff
     1.1 --- a/xen/common/page_alloc.c	Tue Mar 31 11:19:56 2009 +0100
     1.2 +++ b/xen/common/page_alloc.c	Tue Mar 31 11:21:14 2009 +0100
     1.3 @@ -302,7 +302,8 @@ static unsigned long init_node_heap(int 
     1.4                (mfn + needed) <= (virt_to_mfn(DIRECTMAP_VIRT_END - 1) + 1) )
     1.5      {
     1.6          _heap[node] = mfn_to_virt(mfn);
     1.7 -        avail[node] = mfn_to_virt(mfn + needed) - sizeof(**avail) * NR_ZONES;
     1.8 +        avail[node] = mfn_to_virt(mfn + needed - 1) +
     1.9 +                      PAGE_SIZE - sizeof(**avail) * NR_ZONES;
    1.10      }
    1.11  #endif
    1.12      else if ( get_order_from_bytes(sizeof(**_heap)) ==
     2.1 --- a/xen/include/asm-x86/x86_32/page.h	Tue Mar 31 11:19:56 2009 +0100
     2.2 +++ b/xen/include/asm-x86/x86_32/page.h	Tue Mar 31 11:21:14 2009 +0100
     2.3 @@ -27,9 +27,6 @@
     2.4  #define __PAGE_OFFSET           (0xFF000000)
     2.5  #define __XEN_VIRT_START        __PAGE_OFFSET
     2.6  
     2.7 -#define virt_to_maddr(va) ((unsigned long)(va)-DIRECTMAP_VIRT_START)
     2.8 -#define maddr_to_virt(ma) ((void *)((unsigned long)(ma)+DIRECTMAP_VIRT_START))
     2.9 -
    2.10  #define VADDR_BITS              32
    2.11  #define VADDR_MASK              (~0UL)
    2.12  
    2.13 @@ -44,6 +41,22 @@
    2.14  #include <xen/config.h>
    2.15  #include <asm/types.h>
    2.16  
    2.17 +static inline unsigned long __virt_to_maddr(unsigned long va)
    2.18 +{
    2.19 +    ASSERT(va >= DIRECTMAP_VIRT_START && va < DIRECTMAP_VIRT_END);
    2.20 +    return va - DIRECTMAP_VIRT_START;
    2.21 +}
    2.22 +#define virt_to_maddr(va)       \
    2.23 +    (__virt_to_maddr((unsigned long)(va)))
    2.24 +
    2.25 +static inline void *__maddr_to_virt(unsigned long ma)
    2.26 +{
    2.27 +    ASSERT(ma < DIRECTMAP_VIRT_END - DIRECTMAP_VIRT_START);
    2.28 +    return (void *)(ma + DIRECTMAP_VIRT_START);
    2.29 +}
    2.30 +#define maddr_to_virt(ma)       \
    2.31 +    (__maddr_to_virt((unsigned long)(ma)))
    2.32 +
    2.33  /* read access (should only be used for debug printk's) */
    2.34  typedef u64 intpte_t;
    2.35  #define PRIpte "016llx"
     3.1 --- a/xen/include/asm-x86/x86_64/page.h	Tue Mar 31 11:19:56 2009 +0100
     3.2 +++ b/xen/include/asm-x86/x86_64/page.h	Tue Mar 31 11:21:14 2009 +0100
     3.3 @@ -46,8 +46,14 @@ static inline unsigned long __virt_to_ma
     3.4  }
     3.5  #define virt_to_maddr(va)       \
     3.6      (__virt_to_maddr((unsigned long)(va)))
     3.7 +
     3.8 +static inline void *__maddr_to_virt(unsigned long ma)
     3.9 +{
    3.10 +    ASSERT(ma < DIRECTMAP_VIRT_END - DIRECTMAP_VIRT_START);
    3.11 +    return (void *)(ma + DIRECTMAP_VIRT_START);
    3.12 +}
    3.13  #define maddr_to_virt(ma)       \
    3.14 -    ((void *)((unsigned long)(ma)+DIRECTMAP_VIRT_START))
    3.15 +    (__maddr_to_virt((unsigned long)(ma)))
    3.16  
    3.17  /* read access (should only be used for debug printk's) */
    3.18  typedef u64 intpte_t;