xen: fix address truncation in pte mfn<->pfn conversion
authorJeremy Fitzhardinge <jeremy@goop.org>
Fri, 4 Jul 2008 05:10:18 +0000 (22:10 -0700)
committerIngo Molnar <mingo@elte.hu>
Fri, 4 Jul 2008 09:31:20 +0000 (11:31 +0200)
When converting the page number in a pte/pmd/pud/pgd between
machine and pseudo-physical addresses, the converted result was
being truncated at 32-bits.  This caused failures on machines
with more than 4G of physical memory.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: "Christopher S. Aker" <caker@theshore.net>
Cc: Ian Campbell <Ian.Campbell@eu.citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/xen/mmu.c

index df40bf74ea751da4a0556a5b6603af1f3989a39b..4e527e7893a8c134481aac1c3e7ed621882745ad 100644 (file)
@@ -185,7 +185,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
        if (val & _PAGE_PRESENT) {
                unsigned long mfn = (val & PTE_MASK) >> PAGE_SHIFT;
                pteval_t flags = val & ~PTE_MASK;
-               val = (mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
+               val = ((pteval_t)mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
        }
 
        return val;
@@ -196,7 +196,7 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
        if (val & _PAGE_PRESENT) {
                unsigned long pfn = (val & PTE_MASK) >> PAGE_SHIFT;
                pteval_t flags = val & ~PTE_MASK;
-               val = (pfn_to_mfn(pfn) << PAGE_SHIFT) | flags;
+               val = ((pteval_t)pfn_to_mfn(pfn) << PAGE_SHIFT) | flags;
        }
 
        return val;