diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2008-05-26 18:31:19 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-27 04:11:37 -0400 |
commit | 8006ec3e911f93d702e1d4a4e387e244ab434924 (patch) | |
tree | 87c4a8648ff2f559ce039bf606fa40e033c48b3c /arch/x86/xen/mmu.c | |
parent | d451bb7aa852627bdf7be7937dc3d9d9f261b235 (diff) |
xen: add configurable max domain size
Add a config option to set the max size of a Xen domain. This is used
to scale the size of the physical-to-machine array; it ends up using
around 1 page/GByte, so there's no reason to be very restrictive.
For a 32-bit guest, the default value of 8GB is probably sufficient;
there's not much point in giving a 32-bit machine much more memory
than that.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/xen/mmu.c')
-rw-r--r-- | arch/x86/xen/mmu.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index c3b27dec6f03..644232aa7bfb 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -56,19 +56,13 @@ | |||
56 | #include "multicalls.h" | 56 | #include "multicalls.h" |
57 | #include "mmu.h" | 57 | #include "mmu.h" |
58 | 58 | ||
59 | /* | ||
60 | * This should probably be a config option. On 32-bit, it costs 1 | ||
61 | * page/gig of memory; on 64-bit its 2 pages/gig. If we want it to be | ||
62 | * completely unbounded we can add another level to the p2m structure. | ||
63 | */ | ||
64 | #define MAX_GUEST_PAGES (16ull * 1024*1024*1024 / PAGE_SIZE) | ||
65 | #define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) | 59 | #define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) |
66 | 60 | ||
67 | static unsigned long *p2m_top[MAX_GUEST_PAGES / P2M_ENTRIES_PER_PAGE]; | 61 | static unsigned long *p2m_top[MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE]; |
68 | 62 | ||
69 | static inline unsigned p2m_top_index(unsigned long pfn) | 63 | static inline unsigned p2m_top_index(unsigned long pfn) |
70 | { | 64 | { |
71 | BUG_ON(pfn >= MAX_GUEST_PAGES); | 65 | BUG_ON(pfn >= MAX_DOMAIN_PAGES); |
72 | return pfn / P2M_ENTRIES_PER_PAGE; | 66 | return pfn / P2M_ENTRIES_PER_PAGE; |
73 | } | 67 | } |
74 | 68 | ||
@@ -81,12 +75,9 @@ void __init xen_build_dynamic_phys_to_machine(void) | |||
81 | { | 75 | { |
82 | unsigned pfn; | 76 | unsigned pfn; |
83 | unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list; | 77 | unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list; |
78 | unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages); | ||
84 | 79 | ||
85 | BUG_ON(xen_start_info->nr_pages >= MAX_GUEST_PAGES); | 80 | for(pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { |
86 | |||
87 | for(pfn = 0; | ||
88 | pfn < xen_start_info->nr_pages; | ||
89 | pfn += P2M_ENTRIES_PER_PAGE) { | ||
90 | unsigned topidx = p2m_top_index(pfn); | 81 | unsigned topidx = p2m_top_index(pfn); |
91 | 82 | ||
92 | p2m_top[topidx] = &mfn_list[pfn]; | 83 | p2m_top[topidx] = &mfn_list[pfn]; |
@@ -97,6 +88,9 @@ unsigned long get_phys_to_machine(unsigned long pfn) | |||
97 | { | 88 | { |
98 | unsigned topidx, idx; | 89 | unsigned topidx, idx; |
99 | 90 | ||
91 | if (unlikely(pfn >= MAX_DOMAIN_PAGES)) | ||
92 | return INVALID_P2M_ENTRY; | ||
93 | |||
100 | topidx = p2m_top_index(pfn); | 94 | topidx = p2m_top_index(pfn); |
101 | if (p2m_top[topidx] == NULL) | 95 | if (p2m_top[topidx] == NULL) |
102 | return INVALID_P2M_ENTRY; | 96 | return INVALID_P2M_ENTRY; |
@@ -129,6 +123,11 @@ void set_phys_to_machine(unsigned long pfn, unsigned long mfn) | |||
129 | return; | 123 | return; |
130 | } | 124 | } |
131 | 125 | ||
126 | if (unlikely(pfn >= MAX_DOMAIN_PAGES)) { | ||
127 | BUG_ON(mfn != INVALID_P2M_ENTRY); | ||
128 | return; | ||
129 | } | ||
130 | |||
132 | topidx = p2m_top_index(pfn); | 131 | topidx = p2m_top_index(pfn); |
133 | if (p2m_top[topidx] == NULL) { | 132 | if (p2m_top[topidx] == NULL) { |
134 | /* no need to allocate a page to store an invalid entry */ | 133 | /* no need to allocate a page to store an invalid entry */ |