aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/xen/page.h26
-rw-r--r--arch/x86/xen/mmu.c2
-rw-r--r--arch/x86/xen/p2m.c6
3 files changed, 24 insertions, 10 deletions
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
index a4a265fcab17..57aba6ba6f92 100644
--- a/arch/x86/include/asm/xen/page.h
+++ b/arch/x86/include/asm/xen/page.h
@@ -59,6 +59,21 @@ extern int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
59 struct page **pages, unsigned int count); 59 struct page **pages, unsigned int count);
60extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn); 60extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
61 61
62/*
63 * When to use pfn_to_mfn(), __pfn_to_mfn() or get_phys_to_machine():
64 * - pfn_to_mfn() returns either INVALID_P2M_ENTRY or the mfn. No indicator
65 * bits (identity or foreign) are set.
66 * - __pfn_to_mfn() returns the found entry of the p2m table. A possibly set
67 * identity or foreign indicator will be still set. __pfn_to_mfn() is
68 * encapsulating get_phys_to_machine().
69 * - get_phys_to_machine() is to be called by __pfn_to_mfn() only to allow
70 * for future optimizations.
71 */
72static inline unsigned long __pfn_to_mfn(unsigned long pfn)
73{
74 return get_phys_to_machine(pfn);
75}
76
62static inline unsigned long pfn_to_mfn(unsigned long pfn) 77static inline unsigned long pfn_to_mfn(unsigned long pfn)
63{ 78{
64 unsigned long mfn; 79 unsigned long mfn;
@@ -66,7 +81,7 @@ static inline unsigned long pfn_to_mfn(unsigned long pfn)
66 if (xen_feature(XENFEAT_auto_translated_physmap)) 81 if (xen_feature(XENFEAT_auto_translated_physmap))
67 return pfn; 82 return pfn;
68 83
69 mfn = get_phys_to_machine(pfn); 84 mfn = __pfn_to_mfn(pfn);
70 85
71 if (mfn != INVALID_P2M_ENTRY) 86 if (mfn != INVALID_P2M_ENTRY)
72 mfn &= ~(FOREIGN_FRAME_BIT | IDENTITY_FRAME_BIT); 87 mfn &= ~(FOREIGN_FRAME_BIT | IDENTITY_FRAME_BIT);
@@ -79,7 +94,7 @@ static inline int phys_to_machine_mapping_valid(unsigned long pfn)
79 if (xen_feature(XENFEAT_auto_translated_physmap)) 94 if (xen_feature(XENFEAT_auto_translated_physmap))
80 return 1; 95 return 1;
81 96
82 return get_phys_to_machine(pfn) != INVALID_P2M_ENTRY; 97 return __pfn_to_mfn(pfn) != INVALID_P2M_ENTRY;
83} 98}
84 99
85static inline unsigned long mfn_to_pfn_no_overrides(unsigned long mfn) 100static inline unsigned long mfn_to_pfn_no_overrides(unsigned long mfn)
@@ -113,7 +128,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
113 return mfn; 128 return mfn;
114 129
115 pfn = mfn_to_pfn_no_overrides(mfn); 130 pfn = mfn_to_pfn_no_overrides(mfn);
116 if (get_phys_to_machine(pfn) != mfn) { 131 if (__pfn_to_mfn(pfn) != mfn) {
117 /* 132 /*
118 * If this appears to be a foreign mfn (because the pfn 133 * If this appears to be a foreign mfn (because the pfn
119 * doesn't map back to the mfn), then check the local override 134 * doesn't map back to the mfn), then check the local override
@@ -129,8 +144,7 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn)
129 * entry doesn't map back to the mfn and m2p_override doesn't have a 144 * entry doesn't map back to the mfn and m2p_override doesn't have a
130 * valid entry for it. 145 * valid entry for it.
131 */ 146 */
132 if (pfn == ~0 && 147 if (pfn == ~0 && __pfn_to_mfn(mfn) == IDENTITY_FRAME(mfn))
133 get_phys_to_machine(mfn) == IDENTITY_FRAME(mfn))
134 pfn = mfn; 148 pfn = mfn;
135 149
136 return pfn; 150 return pfn;
@@ -176,7 +190,7 @@ static inline unsigned long mfn_to_local_pfn(unsigned long mfn)
176 return mfn; 190 return mfn;
177 191
178 pfn = mfn_to_pfn(mfn); 192 pfn = mfn_to_pfn(mfn);
179 if (get_phys_to_machine(pfn) != mfn) 193 if (__pfn_to_mfn(pfn) != mfn)
180 return -1; /* force !pfn_valid() */ 194 return -1; /* force !pfn_valid() */
181 return pfn; 195 return pfn;
182} 196}
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 601914d2b0a8..3e3f8f8c3a30 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -387,7 +387,7 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
387 unsigned long mfn; 387 unsigned long mfn;
388 388
389 if (!xen_feature(XENFEAT_auto_translated_physmap)) 389 if (!xen_feature(XENFEAT_auto_translated_physmap))
390 mfn = get_phys_to_machine(pfn); 390 mfn = __pfn_to_mfn(pfn);
391 else 391 else
392 mfn = pfn; 392 mfn = pfn;
393 /* 393 /*
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index eddec40a4c20..8c3d8fbbba93 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -787,7 +787,7 @@ static int m2p_add_override(unsigned long mfn, struct page *page,
787 * because mfn_to_pfn (that ends up being called by GUPF) will 787 * because mfn_to_pfn (that ends up being called by GUPF) will
788 * return the backend pfn rather than the frontend pfn. */ 788 * return the backend pfn rather than the frontend pfn. */
789 pfn = mfn_to_pfn_no_overrides(mfn); 789 pfn = mfn_to_pfn_no_overrides(mfn);
790 if (get_phys_to_machine(pfn) == mfn) 790 if (__pfn_to_mfn(pfn) == mfn)
791 set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)); 791 set_phys_to_machine(pfn, FOREIGN_FRAME(mfn));
792 792
793 return 0; 793 return 0;
@@ -967,7 +967,7 @@ static int m2p_remove_override(struct page *page,
967 * pfn again. */ 967 * pfn again. */
968 mfn &= ~FOREIGN_FRAME_BIT; 968 mfn &= ~FOREIGN_FRAME_BIT;
969 pfn = mfn_to_pfn_no_overrides(mfn); 969 pfn = mfn_to_pfn_no_overrides(mfn);
970 if (get_phys_to_machine(pfn) == FOREIGN_FRAME(mfn) && 970 if (__pfn_to_mfn(pfn) == FOREIGN_FRAME(mfn) &&
971 m2p_find_override(mfn) == NULL) 971 m2p_find_override(mfn) == NULL)
972 set_phys_to_machine(pfn, mfn); 972 set_phys_to_machine(pfn, mfn);
973 973
@@ -992,7 +992,7 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops,
992 } 992 }
993 993
994 for (i = 0; i < count; i++) { 994 for (i = 0; i < count; i++) {
995 unsigned long mfn = get_phys_to_machine(page_to_pfn(pages[i])); 995 unsigned long mfn = __pfn_to_mfn(page_to_pfn(pages[i]));
996 unsigned long pfn = page_to_pfn(pages[i]); 996 unsigned long pfn = page_to_pfn(pages[i]);
997 997
998 if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT)) { 998 if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT)) {