ia64/xen-unstable

changeset 16634:0335b9fe2f10

Shadow: Make gfn_t always an unsigned long. GFNs are passed around
outside the shadow code, and although a 32-bit gfn_t is guaranteed to
hold all GFNs that can be found in a 32-bit pagetable, comparisons
with INVALID_GFN aren't safe when (-1UL) != (u32)(-1).
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Dec 19 10:10:37 2007 +0000 (2007-12-19)
parents 7c98b9177b15
children 9d447ba0c99a
files xen/arch/x86/mm/shadow/types.h
line diff
     1.1 --- a/xen/arch/x86/mm/shadow/types.h	Wed Dec 19 09:51:35 2007 +0000
     1.2 +++ b/xen/arch/x86/mm/shadow/types.h	Wed Dec 19 10:10:37 2007 +0000
     1.3 @@ -233,6 +233,29 @@ static inline shadow_l4e_t shadow_l4e_fr
     1.4  })
     1.5  #endif
     1.6  
     1.7 +
     1.8 +/* Type of the guest's frame numbers */
     1.9 +TYPE_SAFE(unsigned long,gfn)
    1.10 +#define SH_PRI_gfn "05lx"
    1.11 +
    1.12 +#define VALID_GFN(m) (m != INVALID_GFN)
    1.13 +
    1.14 +static inline int
    1.15 +valid_gfn(gfn_t m)
    1.16 +{
    1.17 +    return VALID_GFN(gfn_x(m));
    1.18 +}
    1.19 +
    1.20 +static inline paddr_t
    1.21 +gfn_to_paddr(gfn_t gfn)
    1.22 +{
    1.23 +    return ((paddr_t)gfn_x(gfn)) << PAGE_SHIFT;
    1.24 +}
    1.25 +
    1.26 +/* Override gfn_to_mfn to work with gfn_t */
    1.27 +#undef gfn_to_mfn
    1.28 +#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), gfn_x(g), (t))
    1.29 +
    1.30  #if GUEST_PAGING_LEVELS == 2
    1.31  
    1.32  #include "../page-guest32.h"
    1.33 @@ -242,12 +265,6 @@ static inline shadow_l4e_t shadow_l4e_fr
    1.34  #define GUEST_L1_PAGETABLE_SHIFT         12
    1.35  #define GUEST_L2_PAGETABLE_SHIFT         22
    1.36  
    1.37 -/* Type of the guest's frame numbers */
    1.38 -TYPE_SAFE(u32,gfn)
    1.39 -#undef INVALID_GFN
    1.40 -#define INVALID_GFN ((u32)(-1u))
    1.41 -#define SH_PRI_gfn "05x"
    1.42 -
    1.43  /* Types of the guest's page tables */
    1.44  typedef l1_pgentry_32_t guest_l1e_t;
    1.45  typedef l2_pgentry_32_t guest_l2e_t;
    1.46 @@ -307,12 +324,6 @@ static inline guest_l2e_t guest_l2e_from
    1.47  #define GUEST_L4_PAGETABLE_SHIFT         39
    1.48  #endif
    1.49  
    1.50 -/* Type of the guest's frame numbers */
    1.51 -TYPE_SAFE(unsigned long,gfn)
    1.52 -#undef INVALID_GFN
    1.53 -#define INVALID_GFN ((unsigned long)(-1ul))
    1.54 -#define SH_PRI_gfn "05lx"
    1.55 -
    1.56  /* Types of the guest's page tables */
    1.57  typedef l1_pgentry_t guest_l1e_t;
    1.58  typedef l2_pgentry_t guest_l2e_t;
    1.59 @@ -400,24 +411,6 @@ static inline guest_l4e_t guest_l4e_from
    1.60  
    1.61  #endif /* GUEST_PAGING_LEVELS != 2 */
    1.62  
    1.63 -#define VALID_GFN(m) (m != INVALID_GFN)
    1.64 -
    1.65 -static inline int
    1.66 -valid_gfn(gfn_t m)
    1.67 -{
    1.68 -    return VALID_GFN(gfn_x(m));
    1.69 -}
    1.70 -
    1.71 -static inline paddr_t
    1.72 -gfn_to_paddr(gfn_t gfn)
    1.73 -{
    1.74 -    return ((paddr_t)gfn_x(gfn)) << PAGE_SHIFT;
    1.75 -}
    1.76 -
    1.77 -/* Override gfn_to_mfn to work with gfn_t */
    1.78 -#undef gfn_to_mfn
    1.79 -#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), gfn_x(g), (t))
    1.80 -
    1.81  
    1.82  /* Type used for recording a walk through guest pagetables.  It is
    1.83   * filled in by the pagetable walk function, and also used as a cache