aboutsummaryrefslogtreecommitdiffstats
path: root/xen/include/asm-x86/mm.h
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2009-09-22 08:16:49 +0100
committerKeir Fraser <keir.fraser@citrix.com>2009-09-22 08:16:49 +0100
commitbac2000063ba239d33b631f6edda48cc6b57425b (patch)
tree1202e917a4903bdf3975f4ba018c8a4233c80973 /xen/include/asm-x86/mm.h
parent615588563e99a23aaf37037c3fee0c413b051f4d (diff)
downloadxen-bac2000063ba239d33b631f6edda48cc6b57425b.tar.gz
xen-bac2000063ba239d33b631f6edda48cc6b57425b.tar.bz2
xen-bac2000063ba239d33b631f6edda48cc6b57425b.zip
x86-64: reduce range spanned by 1:1 mapping and frame table indexes
Introduces a virtual space conserving transformation on the MFN thus far used to index 1:1 mapping and frame table, removing the largest range of contiguous bits (below the most significant one) which are zero for all valid MFNs from the MFN representation, to be used to index into those arrays, thereby cutting the virtual range these tables must cover approximately by half with each bit removed. Since this should account for hotpluggable memory (in order to not requiring a re-write when that gets supported), the determination of which bits are candidates for removal must not be based on the E820 information, but instead has to use the SRAT. That in turn requires a change to the ordering of steps done during early boot. Signed-off-by: Jan Beulich <jbeulich@novell.com>
Diffstat (limited to 'xen/include/asm-x86/mm.h')
-rw-r--r--xen/include/asm-x86/mm.h46
1 files changed, 36 insertions, 10 deletions
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index 2d346629c4..f8c1e01313 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -22,13 +22,12 @@
* wants to support more than 16TB.
* 'unsigned long' should be used for MFNs everywhere else.
*/
-#define __mfn_t unsigned int
-#define PRpgmfn "08x"
+#define __pdx_t unsigned int
#undef page_list_entry
struct page_list_entry
{
- __mfn_t next, prev;
+ __pdx_t next, prev;
};
struct page_info
@@ -77,14 +76,14 @@ struct page_info
/* Page is in use, but not as a shadow. */
struct {
- /* Owner of this page (NULL if page is anonymous). */
- u32 _domain; /* pickled format */
+ /* Owner of this page (zero if page is anonymous). */
+ __pdx_t _domain;
} inuse;
/* Page is in use as a shadow. */
struct {
/* GMFN of guest page we're a shadow of. */
- __mfn_t back;
+ __pdx_t back;
} sh;
/* Page is on a free list (including shadow code free lists). */
@@ -146,11 +145,11 @@ struct page_info
u32 shadow_flags;
/* When in use as a shadow, next shadow in this hash chain. */
- __mfn_t next_shadow;
+ __pdx_t next_shadow;
};
};
-#undef __mfn_t
+#undef __pdx_t
#define PG_shift(idx) (BITS_PER_LONG - (idx))
#define PG_mask(x, idx) (x ## UL << PG_shift(idx))
@@ -245,9 +244,9 @@ struct page_info
#define page_get_owner(_p) \
((struct domain *)((_p)->v.inuse._domain ? \
- mfn_to_virt((_p)->v.inuse._domain) : NULL))
+ pdx_to_virt((_p)->v.inuse._domain) : NULL))
#define page_set_owner(_p,_d) \
- ((_p)->v.inuse._domain = (_d) ? virt_to_mfn(_d) : 0)
+ ((_p)->v.inuse._domain = (_d) ? virt_to_pdx(_d) : 0)
#define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma))))
#define vaddr_get_owner(va) (page_get_owner(virt_to_page((va))))
@@ -264,6 +263,33 @@ extern unsigned long max_page;
extern unsigned long total_pages;
void init_frametable(void);
+/* Convert between Xen-heap virtual addresses and page-info structures. */
+static inline struct page_info *__virt_to_page(const void *v)
+{
+ unsigned long va = (unsigned long)v;
+
+#ifdef __x86_64__
+ ASSERT(va >= XEN_VIRT_START);
+ ASSERT(va < DIRECTMAP_VIRT_END);
+ if ( va < XEN_VIRT_END )
+ va += DIRECTMAP_VIRT_START - XEN_VIRT_START + xen_phys_start;
+ else
+ ASSERT(va >= DIRECTMAP_VIRT_START);
+#else
+ ASSERT(va - DIRECTMAP_VIRT_START < DIRECTMAP_VIRT_END);
+#endif
+ return frame_table + ((va - DIRECTMAP_VIRT_START) >> PAGE_SHIFT);
+}
+
+static inline void *__page_to_virt(const struct page_info *pg)
+{
+ ASSERT((unsigned long)pg - FRAMETABLE_VIRT_START < FRAMETABLE_VIRT_END);
+ return (void *)(DIRECTMAP_VIRT_START +
+ ((unsigned long)pg - FRAMETABLE_VIRT_START) /
+ (sizeof(*pg) / (sizeof(*pg) & -sizeof(*pg))) *
+ (PAGE_SIZE / (sizeof(*pg) & -sizeof(*pg))));
+}
+
int free_page_type(struct page_info *page, unsigned long type,
int preemptible);
int _shadow_mode_refcounts(struct domain *d);