diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2007-12-19 10:10:37 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2007-12-19 10:10:37 +0000 |
commit | faaa844f73ecc1acad0858ed71ae31cc7d9ed063 (patch) | |
tree | 0dc2465c83ff285e017efba01c960432bf14812c | |
parent | 2fa391823baa5055b180d947879f4d7cde71e6ea (diff) | |
download | xen-faaa844f73ecc1acad0858ed71ae31cc7d9ed063.tar.gz xen-faaa844f73ecc1acad0858ed71ae31cc7d9ed063.tar.bz2 xen-faaa844f73ecc1acad0858ed71ae31cc7d9ed063.zip |
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>
-rw-r--r-- | xen/arch/x86/mm/shadow/types.h | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/xen/arch/x86/mm/shadow/types.h b/xen/arch/x86/mm/shadow/types.h index d00eb486ce..2ca3611edb 100644 --- a/xen/arch/x86/mm/shadow/types.h +++ b/xen/arch/x86/mm/shadow/types.h @@ -233,6 +233,29 @@ static inline shadow_l4e_t shadow_l4e_from_mfn(mfn_t mfn, u32 flags) }) #endif + +/* Type of the guest's frame numbers */ +TYPE_SAFE(unsigned long,gfn) +#define SH_PRI_gfn "05lx" + +#define VALID_GFN(m) (m != INVALID_GFN) + +static inline int +valid_gfn(gfn_t m) +{ + return VALID_GFN(gfn_x(m)); +} + +static inline paddr_t +gfn_to_paddr(gfn_t gfn) +{ + return ((paddr_t)gfn_x(gfn)) << PAGE_SHIFT; +} + +/* Override gfn_to_mfn to work with gfn_t */ +#undef gfn_to_mfn +#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), gfn_x(g), (t)) + #if GUEST_PAGING_LEVELS == 2 #include "../page-guest32.h" @@ -242,12 +265,6 @@ static inline shadow_l4e_t shadow_l4e_from_mfn(mfn_t mfn, u32 flags) #define GUEST_L1_PAGETABLE_SHIFT 12 #define GUEST_L2_PAGETABLE_SHIFT 22 -/* Type of the guest's frame numbers */ -TYPE_SAFE(u32,gfn) -#undef INVALID_GFN -#define INVALID_GFN ((u32)(-1u)) -#define SH_PRI_gfn "05x" - /* Types of the guest's page tables */ typedef l1_pgentry_32_t guest_l1e_t; typedef l2_pgentry_32_t guest_l2e_t; @@ -307,12 +324,6 @@ static inline guest_l2e_t guest_l2e_from_gfn(gfn_t gfn, u32 flags) #define GUEST_L4_PAGETABLE_SHIFT 39 #endif -/* Type of the guest's frame numbers */ -TYPE_SAFE(unsigned long,gfn) -#undef INVALID_GFN -#define INVALID_GFN ((unsigned long)(-1ul)) -#define SH_PRI_gfn "05lx" - /* Types of the guest's page tables */ typedef l1_pgentry_t guest_l1e_t; typedef l2_pgentry_t guest_l2e_t; @@ -400,24 +411,6 @@ static inline guest_l4e_t guest_l4e_from_gfn(gfn_t gfn, u32 flags) #endif /* GUEST_PAGING_LEVELS != 2 */ -#define VALID_GFN(m) (m != INVALID_GFN) - -static inline int -valid_gfn(gfn_t m) -{ - return VALID_GFN(gfn_x(m)); -} - -static inline paddr_t -gfn_to_paddr(gfn_t gfn) -{ - return ((paddr_t)gfn_x(gfn)) << PAGE_SHIFT; -} - -/* Override gfn_to_mfn to work with gfn_t */ -#undef gfn_to_mfn -#define gfn_to_mfn(d, g, t) _gfn_to_mfn((d), gfn_x(g), (t)) - /* Type used for recording a walk through guest pagetables. It is * filled in by the pagetable walk function, and also used as a cache |