diff options
author | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-06-02 17:36:41 +0000 |
---|---|---|
committer | kaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk> | 2005-06-02 17:36:41 +0000 |
commit | bf6fe7ee2ef5c1a2e1b16e8548e7b94b356430c8 (patch) | |
tree | 47a794ef503519c5b4f807723e276010fc4fa179 | |
parent | 31d46bd2a132a7e58d41c0748b1f04d7fe2ac425 (diff) | |
download | xen-bf6fe7ee2ef5c1a2e1b16e8548e7b94b356430c8.tar.gz xen-bf6fe7ee2ef5c1a2e1b16e8548e7b94b356430c8.tar.bz2 xen-bf6fe7ee2ef5c1a2e1b16e8548e7b94b356430c8.zip |
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>
-rw-r--r-- | xen/arch/x86/x86_32/domain_page.c | 2 | ||||
-rw-r--r-- | xen/include/asm-x86/page.h | 34 |
2 files changed, 27 insertions, 9 deletions
diff --git a/xen/arch/x86/x86_32/domain_page.c b/xen/arch/x86/x86_32/domain_page.c index 4ede10b055..08673b2986 100644 --- a/xen/arch/x86/x86_32/domain_page.c +++ b/xen/arch/x86/x86_32/domain_page.c @@ -72,7 +72,7 @@ void *map_domain_mem(unsigned long pa) } while ( l1e_get_flags(cache[idx]) & _PAGE_PRESENT ); - cache[idx] = l1e_from_paddr(pa, __PAGE_HYPERVISOR); + cache[idx] = l1e_from_paddr(pa & PAGE_MASK, __PAGE_HYPERVISOR); spin_unlock(&map_lock); diff --git a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h index 258ec2df85..126f3591ab 100644 --- a/xen/include/asm-x86/page.h +++ b/xen/include/asm-x86/page.h @@ -75,14 +75,32 @@ ((l4_pgentry_t) { ((intpte_t)(pfn) << PAGE_SHIFT) | put_pte_flags(flags) }) /* Construct a pte from a physical address and access flags. */ -#define l1e_from_paddr(pa, flags) \ - ((l1_pgentry_t) { (pa) | put_pte_flags(flags) }) -#define l2e_from_paddr(pa, flags) \ - ((l2_pgentry_t) { (pa) | put_pte_flags(flags) }) -#define l3e_from_paddr(pa, flags) \ - ((l3_pgentry_t) { (pa) | put_pte_flags(flags) }) -#define l4e_from_paddr(pa, flags) \ - ((l4_pgentry_t) { (pa) | put_pte_flags(flags) }) +#ifndef __ASSEMBLY__ +static inline l1_pgentry_t l1e_from_paddr(physaddr_t pa, unsigned int flags) +{ + ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0); + return (l1_pgentry_t) { pa | put_pte_flags(flags) }; +} +static inline l2_pgentry_t l2e_from_paddr(physaddr_t pa, unsigned int flags) +{ + ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0); + return (l2_pgentry_t) { pa | put_pte_flags(flags) }; +} +#if CONFIG_PAGING_LEVELS >= 3 +static inline l3_pgentry_t l3e_from_paddr(physaddr_t pa, unsigned int flags) +{ + ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0); + return (l3_pgentry_t) { pa | put_pte_flags(flags) }; +} +#endif +#if CONFIG_PAGING_LEVELS >= 4 +static inline l4_pgentry_t l4e_from_paddr(physaddr_t pa, unsigned int flags) +{ + ASSERT((pa & ~(PADDR_MASK & PAGE_MASK)) == 0); + return (l4_pgentry_t) { pa | put_pte_flags(flags) }; +} +#endif +#endif /* !__ASSEMBLY__ */ /* Construct a pte from its direct integer representation. */ #define l1e_from_intpte(intpte) ((l1_pgentry_t) { (intpte_t)(intpte) }) |