diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-05-26 18:31:18 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-27 04:11:37 -0400 |
commit | d451bb7aa852627bdf7be7937dc3d9d9f261b235 (patch) | |
tree | 2a92b5e271fb2ae7a869f0f2b4f5bb390cac99cc /include/asm-x86/xen/page.h | |
parent | 955d6f1778da5a9795f2dfb07f760006f194609a (diff) |
xen: make phys_to_machine structure dynamic
We now support the use of memory hotplug, so the physical to machine
page mapping structure must be dynamic. This is implemented as a
two-level radix tree structure, which allows us to efficiently
incrementally allocate memory for the p2m table as new pages are
added.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include/asm-x86/xen/page.h')
-rw-r--r-- | include/asm-x86/xen/page.h | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/include/asm-x86/xen/page.h b/include/asm-x86/xen/page.h index e11f24038b1d..293344f8102e 100644 --- a/include/asm-x86/xen/page.h +++ b/include/asm-x86/xen/page.h | |||
@@ -26,15 +26,15 @@ 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 | extern unsigned long get_phys_to_machine(unsigned long pfn); |
30 | extern void set_phys_to_machine(unsigned long pfn, unsigned long mfn); | ||
30 | 31 | ||
31 | static inline unsigned long pfn_to_mfn(unsigned long pfn) | 32 | static inline unsigned long pfn_to_mfn(unsigned long pfn) |
32 | { | 33 | { |
33 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 34 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
34 | return pfn; | 35 | return pfn; |
35 | 36 | ||
36 | return phys_to_machine_mapping[(unsigned int)(pfn)] & | 37 | return get_phys_to_machine(pfn) & ~FOREIGN_FRAME_BIT; |
37 | ~FOREIGN_FRAME_BIT; | ||
38 | } | 38 | } |
39 | 39 | ||
40 | static inline int phys_to_machine_mapping_valid(unsigned long pfn) | 40 | static inline int phys_to_machine_mapping_valid(unsigned long pfn) |
@@ -42,7 +42,7 @@ static inline int phys_to_machine_mapping_valid(unsigned long pfn) | |||
42 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 42 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
43 | return 1; | 43 | return 1; |
44 | 44 | ||
45 | return (phys_to_machine_mapping[pfn] != INVALID_P2M_ENTRY); | 45 | return get_phys_to_machine(pfn) != INVALID_P2M_ENTRY; |
46 | } | 46 | } |
47 | 47 | ||
48 | static inline unsigned long mfn_to_pfn(unsigned long mfn) | 48 | static inline unsigned long mfn_to_pfn(unsigned long mfn) |
@@ -106,20 +106,12 @@ static inline unsigned long mfn_to_local_pfn(unsigned long mfn) | |||
106 | unsigned long pfn = mfn_to_pfn(mfn); | 106 | unsigned long pfn = mfn_to_pfn(mfn); |
107 | if ((pfn < max_mapnr) | 107 | if ((pfn < max_mapnr) |
108 | && !xen_feature(XENFEAT_auto_translated_physmap) | 108 | && !xen_feature(XENFEAT_auto_translated_physmap) |
109 | && (phys_to_machine_mapping[pfn] != mfn)) | 109 | && (get_phys_to_machine(pfn) != mfn)) |
110 | return max_mapnr; /* force !pfn_valid() */ | 110 | return max_mapnr; /* force !pfn_valid() */ |
111 | /* XXX fixme; not true with sparsemem */ | ||
111 | return pfn; | 112 | return pfn; |
112 | } | 113 | } |
113 | 114 | ||
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 */ | 115 | /* VIRT <-> MACHINE conversion */ |
124 | #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v)))) | 116 | #define virt_to_machine(v) (phys_to_machine(XPADDR(__pa(v)))) |
125 | #define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v)))) | 117 | #define virt_to_mfn(v) (pfn_to_mfn(PFN_DOWN(__pa(v)))) |