aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2010-08-31 17:06:22 -0400
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>2010-10-22 15:57:26 -0400
commitcfd8951e082a589637f9de3c33efd3218fdb3c03 (patch)
treee4b55dc7c0aa6dce4e022d1162abfd2633758720 /arch
parent33a847502b0338351cebd8fc0c68ac796cfadbbd (diff)
xen: don't map missing memory
When setting up a pte for a missing pfn (no matching mfn), just create an empty pte rather than a junk mapping. Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/xen/page.h9
-rw-r--r--arch/x86/xen/mmu.c15
2 files changed, 22 insertions, 2 deletions
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index e40ca6e67bb5..875f5a08a6c7 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -41,10 +41,17 @@ extern bool set_phys_to_machine(unsigned long pfn, unsigned long mfn);
41 41
42static inline unsigned long pfn_to_mfn(unsigned long pfn) 42static inline unsigned long pfn_to_mfn(unsigned long pfn)
43{ 43{
44 unsigned long mfn;
45
44 if (xen_feature(XENFEAT_auto_translated_physmap)) 46 if (xen_feature(XENFEAT_auto_translated_physmap))
45 return pfn; 47 return pfn;
46 48
47 return get_phys_to_machine(pfn) & ~FOREIGN_FRAME_BIT; 49 mfn = get_phys_to_machine(pfn);
50
51 if (mfn != INVALID_P2M_ENTRY)
52 mfn &= ~FOREIGN_FRAME_BIT;
53
54 return mfn;
48} 55}
49 56
50static inline int phys_to_machine_mapping_valid(unsigned long pfn) 57static inline int phys_to_machine_mapping_valid(unsigned long pfn)
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 9b43bb398d37..4c63b7f452dd 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -745,7 +745,20 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
745 if (val & _PAGE_PRESENT) { 745 if (val & _PAGE_PRESENT) {
746 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT; 746 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
747 pteval_t flags = val & PTE_FLAGS_MASK; 747 pteval_t flags = val & PTE_FLAGS_MASK;
748 val = ((pteval_t)pfn_to_mfn(pfn) << PAGE_SHIFT) | flags; 748 unsigned long mfn = pfn_to_mfn(pfn);
749
750 /*
751 * If there's no mfn for the pfn, then just create an
752 * empty non-present pte. Unfortunately this loses
753 * information about the original pfn, so
754 * pte_mfn_to_pfn is asymmetric.
755 */
756 if (unlikely(mfn == INVALID_P2M_ENTRY)) {
757 mfn = 0;
758 flags = 0;
759 }
760
761 val = ((pteval_t)mfn << PAGE_SHIFT) | flags;
749 } 762 }
750 763
751 return val; 764 return val;