diff options
Diffstat (limited to 'include/asm-x86/xen/page.h')
-rw-r--r-- | include/asm-x86/xen/page.h | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/include/asm-x86/xen/page.h b/include/asm-x86/xen/page.h index e11f24038b1d..7b3835d3b77d 100644 --- a/include/asm-x86/xen/page.h +++ b/include/asm-x86/xen/page.h | |||
@@ -26,15 +26,20 @@ typedef struct xpaddr { | |||
26 | #define FOREIGN_FRAME_BIT (1UL<<31) | 26 | #define FOREIGN_FRAME_BIT (1UL<<31) |
27 | #define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT) | 27 | #define FOREIGN_FRAME(m) ((m) | FOREIGN_FRAME_BIT) |
28 | 28 | ||
29 | extern unsigned long *phys_to_machine_mapping; | 29 | /* Maximum amount of memory we can handle in a domain in pages */ |
30 | #define MAX_DOMAIN_PAGES \ | ||
31 | ((unsigned long)((u64)CONFIG_XEN_MAX_DOMAIN_MEMORY * 1024 * 1024 * 1024 / PAGE_SIZE)) | ||
32 | |||
33 | |||
34 | extern unsigned long get_phys_to_machine(unsigned long pfn); | ||
35 | extern void set_phys_to_machine(unsigned long pfn, unsigned long mfn); | ||
30 | 36 | ||
31 | static inline unsigned long pfn_to_mfn(unsigned long pfn) | 37 | static inline unsigned long pfn_to_mfn(unsigned long pfn) |
32 | { | 38 | { |
33 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 39 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
34 | return pfn; | 40 | return pfn; |
35 | 41 | ||
36 | return phys_to_machine_mapping[(unsigned int)(pfn)] & | 42 | return get_phys_to_machine(pfn) & ~FOREIGN_FRAME_BIT; |
37 | ~FOREIGN_FRAME_BIT; | ||
38 | } | 43 | } |
39 | 44 | ||
40 | static inline int phys_to_machine_mapping_valid(unsigned long pfn) | 45 | static inline int phys_to_machine_mapping_valid(unsigned long pfn) |
@@ -42,7 +47,7 @@ static inline int phys_to_machine_mapping_valid(unsigned long pfn) | |||
42 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 47 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
43 | return 1; | 48 | return 1; |
44 | 49 | ||
45 | return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); | 50 | return get_phys_to_machine(pfn) != INVALID_P2M_ENTRY; |
46 | } | 51 | } |
47 | 52 | ||
48 | static inline unsigned long mfn_to_pfn(unsigned long mfn) | 53 | static inline unsigned long mfn_to_pfn(unsigned long mfn) |
@@ -106,20 +111,12 @@ static inline unsigned long mfn_to_local_pfn(unsigned long mfn) | |||
106 | unsigned long pfn = mfn_to_pfn(mfn); | 111 | unsigned long pfn = mfn_to_pfn(mfn); |
107 | if ((pfn < max_mapnr) | 112 | if ((pfn < max_mapnr) |
108 | && !xen_feature(XENFEAT_auto_translated_physmap) | 113 | && !xen_feature(XENFEAT_auto_translated_physmap) |
109 | && (phys_to_machine_mapping[pfn] != mfn)) | 114 | && (get_phys_to_machine(pfn) != mfn)) |
110 | return max_mapnr; /* force !pfn_valid() */ | 115 | return max_mapnr; /* force !pfn_valid() */ |
116 | /* XXX fixme; not true with sparsemem */ | ||
111 | return pfn; | 117 | return pfn; |
112 | } | 118 | } |
113 | 119 | ||
114 | static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) | ||
115 | { | ||
116 | if (xen_feature(XENFEAT_auto_translated_physmap)) { | ||
117 | BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY); | ||
118 | return; | ||
119 | } | ||
120 | phys_to_machine_mapping[pfn] = mfn; | ||
121 | } | ||
122 | |||
123 | /* VIRT <-> MACHINE conversion */ | 120 | /* VIRT <-> MACHINE conversion */ |
124 | #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v)))) | 121 | #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v)))) |
125 | #define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v)))) | 122 | #define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v)))) |
@@ -127,7 +124,7 @@ static inline void set_phys_to_machine(unsigned long pfn, unsigned long mfn) | |||
127 | 124 | ||
128 | static inline unsigned long pte_mfn(pte_t pte) | 125 | static inline unsigned long pte_mfn(pte_t pte) |
129 | { | 126 | { |
130 | return (pte.pte & PTE_MASK) >> PAGE_SHIFT; | 127 | return (pte.pte & PTE_PFN_MASK) >> PAGE_SHIFT; |
131 | } | 128 | } |
132 | 129 | ||
133 | static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot) | 130 | static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot) |
@@ -151,13 +148,17 @@ static inline pte_t __pte_ma(pteval_t x) | |||
151 | } | 148 | } |
152 | 149 | ||
153 | #define pmd_val_ma(v) ((v).pmd) | 150 | #define pmd_val_ma(v) ((v).pmd) |
151 | #ifdef __PAGETABLE_PUD_FOLDED | ||
154 | #define pud_val_ma(v) ((v).pgd.pgd) | 152 | #define pud_val_ma(v) ((v).pgd.pgd) |
153 | #else | ||
154 | #define pud_val_ma(v) ((v).pud) | ||
155 | #endif | ||
155 | #define __pmd_ma(x) ((pmd_t) { (x) } ) | 156 | #define __pmd_ma(x) ((pmd_t) { (x) } ) |
156 | 157 | ||
157 | #define pgd_val_ma(x) ((x).pgd) | 158 | #define pgd_val_ma(x) ((x).pgd) |
158 | 159 | ||
159 | 160 | ||
160 | xmaddr_t arbitrary_virt_to_machine(unsigned long address); | 161 | xmaddr_t arbitrary_virt_to_machine(void *address); |
161 | void make_lowmem_page_readonly(void *vaddr); | 162 | void make_lowmem_page_readonly(void *vaddr); |
162 | void make_lowmem_page_readwrite(void *vaddr); | 163 | void make_lowmem_page_readwrite(void *vaddr); |
163 | 164 | ||