diff options
-rw-r--r-- | arch/x86/include/asm/xen/page.h | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h index 195707060493..c61934fbf22a 100644 --- a/arch/x86/include/asm/xen/page.h +++ b/arch/x86/include/asm/xen/page.h | |||
@@ -81,6 +81,7 @@ static inline int phys_to_machine_mapping_valid(unsigned long pfn) | |||
81 | static inline unsigned long mfn_to_pfn(unsigned long mfn) | 81 | static inline unsigned long mfn_to_pfn(unsigned long mfn) |
82 | { | 82 | { |
83 | unsigned long pfn; | 83 | unsigned long pfn; |
84 | int ret = 0; | ||
84 | 85 | ||
85 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 86 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
86 | return mfn; | 87 | return mfn; |
@@ -95,15 +96,29 @@ static inline unsigned long mfn_to_pfn(unsigned long mfn) | |||
95 | * In such cases it doesn't matter what we return (we return garbage), | 96 | * In such cases it doesn't matter what we return (we return garbage), |
96 | * but we must handle the fault without crashing! | 97 | * but we must handle the fault without crashing! |
97 | */ | 98 | */ |
98 | __get_user(pfn, &machine_to_phys_mapping[mfn]); | 99 | ret = __get_user(pfn, &machine_to_phys_mapping[mfn]); |
99 | try_override: | 100 | try_override: |
100 | /* | 101 | /* ret might be < 0 if there are no entries in the m2p for mfn */ |
101 | * If this appears to be a foreign mfn (because the pfn | 102 | if (ret < 0) |
102 | * doesn't map back to the mfn), then check the local override | 103 | pfn = ~0; |
103 | * table to see if there's a better pfn to use. | 104 | else if (get_phys_to_machine(pfn) != mfn) |
105 | /* | ||
106 | * If this appears to be a foreign mfn (because the pfn | ||
107 | * doesn't map back to the mfn), then check the local override | ||
108 | * table to see if there's a better pfn to use. | ||
109 | * | ||
110 | * m2p_find_override_pfn returns ~0 if it doesn't find anything. | ||
111 | */ | ||
112 | pfn = m2p_find_override_pfn(mfn, ~0); | ||
113 | |||
114 | /* | ||
115 | * pfn is ~0 if there are no entries in the m2p for mfn or if the | ||
116 | * entry doesn't map back to the mfn and m2p_override doesn't have a | ||
117 | * valid entry for it. | ||
104 | */ | 118 | */ |
105 | if (get_phys_to_machine(pfn) != mfn) | 119 | if (pfn == ~0 && |
106 | pfn = m2p_find_override_pfn(mfn, pfn); | 120 | get_phys_to_machine(mfn) == IDENTITY_FRAME(mfn)) |
121 | pfn = mfn; | ||
107 | 122 | ||
108 | return pfn; | 123 | return pfn; |
109 | } | 124 | } |