aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/xen/mmu.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 644232aa7bfb..da7b45b05066 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -57,8 +57,17 @@
57#include "mmu.h" 57#include "mmu.h"
58 58
59#define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) 59#define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long))
60#define TOP_ENTRIES (MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE)
60 61
61static unsigned long *p2m_top[MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE]; 62/* Placeholder for holes in the address space */
63static unsigned long p2m_missing[P2M_ENTRIES_PER_PAGE]
64 __attribute__((section(".data.page_aligned"))) =
65 { [ 0 ... P2M_ENTRIES_PER_PAGE-1 ] = ~0UL };
66
67 /* Array of pointers to pages containing p2m entries */
68static unsigned long *p2m_top[TOP_ENTRIES]
69 __attribute__((section(".data.page_aligned"))) =
70 { [ 0 ... TOP_ENTRIES - 1] = &p2m_missing[0] };
62 71
63static inline unsigned p2m_top_index(unsigned long pfn) 72static inline unsigned p2m_top_index(unsigned long pfn)
64{ 73{
@@ -92,9 +101,6 @@ unsigned long get_phys_to_machine(unsigned long pfn)
92 return INVALID_P2M_ENTRY; 101 return INVALID_P2M_ENTRY;
93 102
94 topidx = p2m_top_index(pfn); 103 topidx = p2m_top_index(pfn);
95 if (p2m_top[topidx] == NULL)
96 return INVALID_P2M_ENTRY;
97
98 idx = p2m_index(pfn); 104 idx = p2m_index(pfn);
99 return p2m_top[topidx][idx]; 105 return p2m_top[topidx][idx];
100} 106}
@@ -110,7 +116,7 @@ static void alloc_p2m(unsigned long **pp)
110 for(i = 0; i < P2M_ENTRIES_PER_PAGE; i++) 116 for(i = 0; i < P2M_ENTRIES_PER_PAGE; i++)
111 p[i] = INVALID_P2M_ENTRY; 117 p[i] = INVALID_P2M_ENTRY;
112 118
113 if (cmpxchg(pp, NULL, p) != NULL) 119 if (cmpxchg(pp, p2m_missing, p) != p2m_missing)
114 free_page((unsigned long)p); 120 free_page((unsigned long)p);
115} 121}
116 122
@@ -129,7 +135,7 @@ void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
129 } 135 }
130 136
131 topidx = p2m_top_index(pfn); 137 topidx = p2m_top_index(pfn);
132 if (p2m_top[topidx] == NULL) { 138 if (p2m_top[topidx] == p2m_missing) {
133 /* no need to allocate a page to store an invalid entry */ 139 /* no need to allocate a page to store an invalid entry */
134 if (mfn == INVALID_P2M_ENTRY) 140 if (mfn == INVALID_P2M_ENTRY)
135 return; 141 return;