blob: af7216128d93ac4949e574b52d45f91079f6898f [file] [log] [blame]
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -07001/*
2 * Machine specific setup for xen
3 *
4 * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
5 */
6
7#include <linux/module.h>
8#include <linux/sched.h>
9#include <linux/mm.h>
10#include <linux/pm.h>
Yinghai Lua9ce6bc2010-08-25 13:39:17 -070011#include <linux/memblock.h>
Len Brownd91ee582011-04-01 18:28:35 -040012#include <linux/cpuidle.h>
Konrad Rzeszutek Wilk48cdd822012-03-13 20:06:57 -040013#include <linux/cpufreq.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070014
15#include <asm/elf.h>
Roland McGrath6c3652e2008-01-30 13:30:42 +010016#include <asm/vdso.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070017#include <asm/e820.h>
18#include <asm/setup.h>
Jeremy Fitzhardingeb792c752008-06-16 14:54:49 -070019#include <asm/acpi.h>
Konrad Rzeszutek Wilk8d54db792012-08-17 10:22:37 -040020#include <asm/numa.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070021#include <asm/xen/hypervisor.h>
22#include <asm/xen/hypercall.h>
23
Ian Campbell45263cb2010-10-25 16:32:29 -070024#include <xen/xen.h>
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +010025#include <xen/page.h>
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -070026#include <xen/interface/callback.h>
Ian Campbell35ae11f2009-02-06 19:09:48 -080027#include <xen/interface/memory.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070028#include <xen/interface/physdev.h>
29#include <xen/features.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070030#include "xen-ops.h"
Roland McGrathd2eea682007-07-20 00:31:43 -070031#include "vdso.h"
Matt Rushton4fbb67e32014-08-11 11:57:57 -070032#include "p2m.h"
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070033
34/* These are code, but not functions. Defined in entry.S */
35extern const char xen_hypervisor_callback[];
36extern const char xen_failsafe_callback[];
Konrad Rzeszutek Wilk6efa20e2013-07-19 11:51:31 -040037#ifdef CONFIG_X86_64
Andi Kleen07ba06d2013-10-22 09:07:59 -070038extern asmlinkage void nmi(void);
Konrad Rzeszutek Wilk6efa20e2013-07-19 11:51:31 -040039#endif
Tejf63c2f22008-12-16 11:56:06 -080040extern void xen_sysenter_target(void);
41extern void xen_syscall_target(void);
42extern void xen_syscall32_target(void);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070043
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070044/* Amount of extra memory space we add to the e820 ranges */
David Vrabel8b5d44a2011-09-28 17:46:34 +010045struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070046
David Vrabelaa244112011-09-28 17:46:32 +010047/* Number of pages released from the initial allocation. */
48unsigned long xen_released_pages;
49
Matt Rushton4fbb67e32014-08-11 11:57:57 -070050/* Buffer used to remap identity mapped pages */
51unsigned long xen_remap_buf[P2M_PER_PAGE] __initdata;
52
Jeremy Fitzhardinge698bb8d2010-09-14 10:19:14 -070053/*
54 * The maximum amount of extra memory compared to the base size. The
55 * main scaling factor is the size of struct page. At extreme ratios
56 * of base:extra, all the base memory can be filled with page
57 * structures for the extra memory, leaving no space for anything
58 * else.
59 *
60 * 10x seems like a reasonable balance between scaling flexibility and
61 * leaving a practically usable system.
62 */
63#define EXTRA_MEM_RATIO (10)
64
David Vrabeldc91c722011-09-29 12:26:19 +010065static void __init xen_add_extra_mem(u64 start, u64 size)
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070066{
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050067 unsigned long pfn;
David Vrabeldc91c722011-09-29 12:26:19 +010068 int i;
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050069
David Vrabeldc91c722011-09-29 12:26:19 +010070 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
71 /* Add new region. */
72 if (xen_extra_mem[i].size == 0) {
73 xen_extra_mem[i].start = start;
74 xen_extra_mem[i].size = size;
75 break;
76 }
77 /* Append to existing region. */
78 if (xen_extra_mem[i].start + xen_extra_mem[i].size == start) {
79 xen_extra_mem[i].size += size;
80 break;
81 }
82 }
83 if (i == XEN_EXTRA_MEM_MAX_REGIONS)
84 printk(KERN_WARNING "Warning: not enough extra memory regions\n");
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070085
Tejun Heod4bbf7e2011-11-28 09:46:22 -080086 memblock_reserve(start, size);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070087
David Vrabeldc91c722011-09-29 12:26:19 +010088 xen_max_p2m_pfn = PFN_DOWN(start + size);
Konrad Rzeszutek Wilkc96aae12012-08-17 16:43:28 -040089 for (pfn = PFN_DOWN(start); pfn < xen_max_p2m_pfn; pfn++) {
90 unsigned long mfn = pfn_to_mfn(pfn);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070091
David Vrabel2dcc9a32014-01-07 11:36:53 +000092 if (WARN_ONCE(mfn == pfn, "Trying to over-write 1-1 mapping (pfn: %lx)\n", pfn))
Konrad Rzeszutek Wilkc96aae12012-08-17 16:43:28 -040093 continue;
David Vrabel2dcc9a32014-01-07 11:36:53 +000094 WARN_ONCE(mfn != INVALID_P2M_ENTRY, "Trying to remove %lx which has %lx mfn!\n",
95 pfn, mfn);
Konrad Rzeszutek Wilkc96aae12012-08-17 16:43:28 -040096
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050097 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
Konrad Rzeszutek Wilkc96aae12012-08-17 16:43:28 -040098 }
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070099}
100
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400101static unsigned long __init xen_do_chunk(unsigned long start,
102 unsigned long end, bool release)
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400103{
104 struct xen_memory_reservation reservation = {
105 .address_bits = 0,
106 .extent_order = 0,
107 .domid = DOMID_SELF
108 };
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700109 unsigned long len = 0;
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400110 unsigned long pfn;
111 int ret;
112
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400113 for (pfn = start; pfn < end; pfn++) {
114 unsigned long frame;
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400115 unsigned long mfn = pfn_to_mfn(pfn);
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400116
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400117 if (release) {
118 /* Make sure pfn exists to start with */
119 if (mfn == INVALID_P2M_ENTRY || mfn_to_pfn(mfn) != pfn)
120 continue;
121 frame = mfn;
122 } else {
David Vrabel562658f2014-06-02 17:53:06 +0100123 if (mfn != INVALID_P2M_ENTRY)
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400124 continue;
125 frame = pfn;
126 }
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400127 set_xen_guest_handle(reservation.extent_start, &frame);
128 reservation.nr_extents = 1;
129
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400130 ret = HYPERVISOR_memory_op(release ? XENMEM_decrease_reservation : XENMEM_populate_physmap,
131 &reservation);
132 WARN(ret != 1, "Failed to %s pfn %lx err=%d\n",
133 release ? "release" : "populate", pfn, ret);
134
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400135 if (ret == 1) {
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400136 if (!early_set_phys_to_machine(pfn, release ? INVALID_P2M_ENTRY : frame)) {
137 if (release)
138 break;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400139 set_xen_guest_handle(reservation.extent_start, &frame);
140 reservation.nr_extents = 1;
141 ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400142 &reservation);
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400143 break;
144 }
145 len++;
146 } else
147 break;
148 }
149 if (len)
Konrad Rzeszutek Wilk96dc08b2012-04-06 16:10:20 -0400150 printk(KERN_INFO "%s %lx-%lx pfn range: %lu pages %s\n",
151 release ? "Freeing" : "Populating",
152 start, end, len,
153 release ? "freed" : "added");
154
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400155 return len;
156}
David Vrabel83d51ab2012-05-03 16:15:42 +0100157
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700158/*
159 * Finds the next RAM pfn available in the E820 map after min_pfn.
160 * This function updates min_pfn with the pfn found and returns
161 * the size of that range or zero if not found.
162 */
163static unsigned long __init xen_find_pfn_range(
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400164 const struct e820entry *list, size_t map_size,
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700165 unsigned long *min_pfn)
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400166{
167 const struct e820entry *entry;
168 unsigned int i;
169 unsigned long done = 0;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400170
171 for (i = 0, entry = list; i < map_size; i++, entry++) {
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400172 unsigned long s_pfn;
173 unsigned long e_pfn;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400174
175 if (entry->type != E820_RAM)
176 continue;
177
zhenzhong.duanc3d93f82012-07-18 13:06:39 +0800178 e_pfn = PFN_DOWN(entry->addr + entry->size);
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400179
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700180 /* We only care about E820 after this */
181 if (e_pfn < *min_pfn)
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400182 continue;
183
zhenzhong.duanc3d93f82012-07-18 13:06:39 +0800184 s_pfn = PFN_UP(entry->addr);
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700185
186 /* If min_pfn falls within the E820 entry, we want to start
187 * at the min_pfn PFN.
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400188 */
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700189 if (s_pfn <= *min_pfn) {
190 done = e_pfn - *min_pfn;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400191 } else {
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700192 done = e_pfn - s_pfn;
193 *min_pfn = s_pfn;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400194 }
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700195 break;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400196 }
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700197
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400198 return done;
199}
David Vrabel83d51ab2012-05-03 16:15:42 +0100200
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700201/*
202 * This releases a chunk of memory and then does the identity map. It's used as
203 * as a fallback if the remapping fails.
204 */
205static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn,
206 unsigned long end_pfn, unsigned long nr_pages, unsigned long *identity,
207 unsigned long *released)
David Vrabel83d51ab2012-05-03 16:15:42 +0100208{
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700209 WARN_ON(start_pfn > end_pfn);
David Vrabel83d51ab2012-05-03 16:15:42 +0100210
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700211 /* Need to release pages first */
212 *released += xen_do_chunk(start_pfn, min(end_pfn, nr_pages), true);
David Vrabel83d51ab2012-05-03 16:15:42 +0100213 *identity += set_phys_range_identity(start_pfn, end_pfn);
214}
215
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700216/*
217 * Helper function to update both the p2m and m2p tables.
218 */
219static unsigned long __init xen_update_mem_tables(unsigned long pfn,
220 unsigned long mfn)
221{
222 struct mmu_update update = {
223 .ptr = ((unsigned long long)mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
224 .val = pfn
225 };
226
227 /* Update p2m */
228 if (!early_set_phys_to_machine(pfn, mfn)) {
229 WARN(1, "Failed to set p2m mapping for pfn=%ld mfn=%ld\n",
230 pfn, mfn);
231 return false;
232 }
233
234 /* Update m2p */
235 if (HYPERVISOR_mmu_update(&update, 1, NULL, DOMID_SELF) < 0) {
236 WARN(1, "Failed to set m2p mapping for mfn=%ld pfn=%ld\n",
237 mfn, pfn);
238 return false;
239 }
240
241 return true;
242}
243
244/*
245 * This function updates the p2m and m2p tables with an identity map from
246 * start_pfn to start_pfn+size and remaps the underlying RAM of the original
247 * allocation at remap_pfn. It must do so carefully in P2M_PER_PAGE sized blocks
248 * to not exhaust the reserved brk space. Doing it in properly aligned blocks
249 * ensures we only allocate the minimum required leaf pages in the p2m table. It
250 * copies the existing mfns from the p2m table under the 1:1 map, overwrites
251 * them with the identity map and then updates the p2m and m2p tables with the
252 * remapped memory.
253 */
254static unsigned long __init xen_do_set_identity_and_remap_chunk(
255 unsigned long start_pfn, unsigned long size, unsigned long remap_pfn)
256{
257 unsigned long ident_pfn_iter, remap_pfn_iter;
258 unsigned long ident_start_pfn_align, remap_start_pfn_align;
259 unsigned long ident_end_pfn_align, remap_end_pfn_align;
260 unsigned long ident_boundary_pfn, remap_boundary_pfn;
261 unsigned long ident_cnt = 0;
262 unsigned long remap_cnt = 0;
263 unsigned long left = size;
264 unsigned long mod;
265 int i;
266
267 WARN_ON(size == 0);
268
269 BUG_ON(xen_feature(XENFEAT_auto_translated_physmap));
270
271 /*
272 * Determine the proper alignment to remap memory in P2M_PER_PAGE sized
273 * blocks. We need to keep track of both the existing pfn mapping and
274 * the new pfn remapping.
275 */
276 mod = start_pfn % P2M_PER_PAGE;
277 ident_start_pfn_align =
278 mod ? (start_pfn - mod + P2M_PER_PAGE) : start_pfn;
279 mod = remap_pfn % P2M_PER_PAGE;
280 remap_start_pfn_align =
281 mod ? (remap_pfn - mod + P2M_PER_PAGE) : remap_pfn;
282 mod = (start_pfn + size) % P2M_PER_PAGE;
283 ident_end_pfn_align = start_pfn + size - mod;
284 mod = (remap_pfn + size) % P2M_PER_PAGE;
285 remap_end_pfn_align = remap_pfn + size - mod;
286
287 /* Iterate over each p2m leaf node in each range */
288 for (ident_pfn_iter = ident_start_pfn_align, remap_pfn_iter = remap_start_pfn_align;
289 ident_pfn_iter < ident_end_pfn_align && remap_pfn_iter < remap_end_pfn_align;
290 ident_pfn_iter += P2M_PER_PAGE, remap_pfn_iter += P2M_PER_PAGE) {
291 /* Check we aren't past the end */
292 BUG_ON(ident_pfn_iter + P2M_PER_PAGE > start_pfn + size);
293 BUG_ON(remap_pfn_iter + P2M_PER_PAGE > remap_pfn + size);
294
295 /* Save p2m mappings */
296 for (i = 0; i < P2M_PER_PAGE; i++)
297 xen_remap_buf[i] = pfn_to_mfn(ident_pfn_iter + i);
298
299 /* Set identity map which will free a p2m leaf */
300 ident_cnt += set_phys_range_identity(ident_pfn_iter,
301 ident_pfn_iter + P2M_PER_PAGE);
302
303#ifdef DEBUG
304 /* Helps verify a p2m leaf has been freed */
305 for (i = 0; i < P2M_PER_PAGE; i++) {
306 unsigned int pfn = ident_pfn_iter + i;
307 BUG_ON(pfn_to_mfn(pfn) != pfn);
308 }
309#endif
310 /* Now remap memory */
311 for (i = 0; i < P2M_PER_PAGE; i++) {
312 unsigned long mfn = xen_remap_buf[i];
313
314 /* This will use the p2m leaf freed above */
315 if (!xen_update_mem_tables(remap_pfn_iter + i, mfn)) {
316 WARN(1, "Failed to update mem mapping for pfn=%ld mfn=%ld\n",
317 remap_pfn_iter + i, mfn);
318 return 0;
319 }
320
321 remap_cnt++;
322 }
323
324 left -= P2M_PER_PAGE;
325 }
326
327 /* Max boundary space possible */
328 BUG_ON(left > (P2M_PER_PAGE - 1) * 2);
329
330 /* Now handle the boundary conditions */
331 ident_boundary_pfn = start_pfn;
332 remap_boundary_pfn = remap_pfn;
333 for (i = 0; i < left; i++) {
334 unsigned long mfn;
335
336 /* These two checks move from the start to end boundaries */
337 if (ident_boundary_pfn == ident_start_pfn_align)
338 ident_boundary_pfn = ident_pfn_iter;
339 if (remap_boundary_pfn == remap_start_pfn_align)
340 remap_boundary_pfn = remap_pfn_iter;
341
342 /* Check we aren't past the end */
343 BUG_ON(ident_boundary_pfn >= start_pfn + size);
344 BUG_ON(remap_boundary_pfn >= remap_pfn + size);
345
346 mfn = pfn_to_mfn(ident_boundary_pfn);
347
348 if (!xen_update_mem_tables(remap_boundary_pfn, mfn)) {
349 WARN(1, "Failed to update mem mapping for pfn=%ld mfn=%ld\n",
350 remap_pfn_iter + i, mfn);
351 return 0;
352 }
353 remap_cnt++;
354
355 ident_boundary_pfn++;
356 remap_boundary_pfn++;
357 }
358
359 /* Finish up the identity map */
360 if (ident_start_pfn_align >= ident_end_pfn_align) {
361 /*
362 * In this case we have an identity range which does not span an
363 * aligned block so everything needs to be identity mapped here.
364 * If we didn't check this we might remap too many pages since
365 * the align boundaries are not meaningful in this case.
366 */
367 ident_cnt += set_phys_range_identity(start_pfn,
368 start_pfn + size);
369 } else {
370 /* Remapped above so check each end of the chunk */
371 if (start_pfn < ident_start_pfn_align)
372 ident_cnt += set_phys_range_identity(start_pfn,
373 ident_start_pfn_align);
374 if (start_pfn + size > ident_pfn_iter)
375 ident_cnt += set_phys_range_identity(ident_pfn_iter,
376 start_pfn + size);
377 }
378
379 BUG_ON(ident_cnt != size);
380 BUG_ON(remap_cnt != size);
381
382 return size;
383}
384
385/*
386 * This function takes a contiguous pfn range that needs to be identity mapped
387 * and:
388 *
389 * 1) Finds a new range of pfns to use to remap based on E820 and remap_pfn.
390 * 2) Calls the do_ function to actually do the mapping/remapping work.
391 *
392 * The goal is to not allocate additional memory but to remap the existing
393 * pages. In the case of an error the underlying memory is simply released back
394 * to Xen and not remapped.
395 */
396static unsigned long __init xen_set_identity_and_remap_chunk(
397 const struct e820entry *list, size_t map_size, unsigned long start_pfn,
398 unsigned long end_pfn, unsigned long nr_pages, unsigned long remap_pfn,
399 unsigned long *identity, unsigned long *remapped,
400 unsigned long *released)
401{
402 unsigned long pfn;
403 unsigned long i = 0;
404 unsigned long n = end_pfn - start_pfn;
405
406 while (i < n) {
407 unsigned long cur_pfn = start_pfn + i;
408 unsigned long left = n - i;
409 unsigned long size = left;
410 unsigned long remap_range_size;
411
412 /* Do not remap pages beyond the current allocation */
413 if (cur_pfn >= nr_pages) {
414 /* Identity map remaining pages */
415 *identity += set_phys_range_identity(cur_pfn,
416 cur_pfn + size);
417 break;
418 }
419 if (cur_pfn + size > nr_pages)
420 size = nr_pages - cur_pfn;
421
422 remap_range_size = xen_find_pfn_range(list, map_size,
423 &remap_pfn);
424 if (!remap_range_size) {
425 pr_warning("Unable to find available pfn range, not remapping identity pages\n");
426 xen_set_identity_and_release_chunk(cur_pfn,
427 cur_pfn + left, nr_pages, identity, released);
428 break;
429 }
430 /* Adjust size to fit in current e820 RAM region */
431 if (size > remap_range_size)
432 size = remap_range_size;
433
434 if (!xen_do_set_identity_and_remap_chunk(cur_pfn, size, remap_pfn)) {
435 WARN(1, "Failed to remap 1:1 memory cur_pfn=%ld size=%ld remap_pfn=%ld\n",
436 cur_pfn, size, remap_pfn);
437 xen_set_identity_and_release_chunk(cur_pfn,
438 cur_pfn + left, nr_pages, identity, released);
439 break;
440 }
441
442 /* Update variables to reflect new mappings. */
443 i += size;
444 remap_pfn += size;
445 *identity += size;
446 *remapped += size;
447 }
448
449 /*
450 * If the PFNs are currently mapped, the VA mapping also needs
451 * to be updated to be 1:1.
452 */
453 for (pfn = start_pfn; pfn <= max_pfn_mapped && pfn < end_pfn; pfn++)
454 (void)HYPERVISOR_update_va_mapping(
455 (unsigned long)__va(pfn << PAGE_SHIFT),
456 mfn_pte(pfn, PAGE_KERNEL_IO), 0);
457
458 return remap_pfn;
459}
460
461static unsigned long __init xen_set_identity_and_remap(
462 const struct e820entry *list, size_t map_size, unsigned long nr_pages,
463 unsigned long *released)
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400464{
David Vrabelf3f436e2011-09-28 17:46:36 +0100465 phys_addr_t start = 0;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500466 unsigned long identity = 0;
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700467 unsigned long remapped = 0;
468 unsigned long last_pfn = nr_pages;
David Vrabelf3f436e2011-09-28 17:46:36 +0100469 const struct e820entry *entry;
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700470 unsigned long num_released = 0;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500471 int i;
472
David Vrabelf3f436e2011-09-28 17:46:36 +0100473 /*
474 * Combine non-RAM regions and gaps until a RAM region (or the
475 * end of the map) is reached, then set the 1:1 map and
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700476 * remap the memory in those non-RAM regions.
David Vrabelf3f436e2011-09-28 17:46:36 +0100477 *
478 * The combined non-RAM regions are rounded to a whole number
479 * of pages so any partial pages are accessible via the 1:1
480 * mapping. This is needed for some BIOSes that put (for
481 * example) the DMI tables in a reserved region that begins on
482 * a non-page boundary.
483 */
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500484 for (i = 0, entry = list; i < map_size; i++, entry++) {
David Vrabelf3f436e2011-09-28 17:46:36 +0100485 phys_addr_t end = entry->addr + entry->size;
David Vrabelf3f436e2011-09-28 17:46:36 +0100486 if (entry->type == E820_RAM || i == map_size - 1) {
487 unsigned long start_pfn = PFN_DOWN(start);
488 unsigned long end_pfn = PFN_UP(end);
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500489
David Vrabelf3f436e2011-09-28 17:46:36 +0100490 if (entry->type == E820_RAM)
491 end_pfn = PFN_UP(entry->addr);
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500492
David Vrabel83d51ab2012-05-03 16:15:42 +0100493 if (start_pfn < end_pfn)
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700494 last_pfn = xen_set_identity_and_remap_chunk(
495 list, map_size, start_pfn,
496 end_pfn, nr_pages, last_pfn,
497 &identity, &remapped,
498 &num_released);
David Vrabelf3f436e2011-09-28 17:46:36 +0100499 start = end;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500500 }
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500501 }
David Vrabelf3f436e2011-09-28 17:46:36 +0100502
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700503 *released = num_released;
David Vrabelf3f436e2011-09-28 17:46:36 +0100504
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700505 pr_info("Set %ld page(s) to 1-1 mapping\n", identity);
506 pr_info("Remapped %ld page(s), last_pfn=%ld\n", remapped,
507 last_pfn);
508 pr_info("Released %ld page(s)\n", num_released);
509
510 return last_pfn;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500511}
David Vrabeld312ae872011-08-19 15:57:16 +0100512static unsigned long __init xen_get_max_pages(void)
513{
514 unsigned long max_pages = MAX_DOMAIN_PAGES;
515 domid_t domid = DOMID_SELF;
516 int ret;
517
Ian Campbelld3db7282011-12-14 12:16:08 +0000518 /*
519 * For the initial domain we use the maximum reservation as
520 * the maximum page.
521 *
522 * For guest domains the current maximum reservation reflects
523 * the current maximum rather than the static maximum. In this
524 * case the e820 map provided to us will cover the static
525 * maximum region.
526 */
527 if (xen_initial_domain()) {
528 ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
529 if (ret > 0)
530 max_pages = ret;
531 }
532
David Vrabeld312ae872011-08-19 15:57:16 +0100533 return min(max_pages, MAX_DOMAIN_PAGES);
534}
535
David Vrabeldc91c722011-09-29 12:26:19 +0100536static void xen_align_and_add_e820_region(u64 start, u64 size, int type)
537{
538 u64 end = start + size;
539
540 /* Align RAM regions to page boundaries. */
541 if (type == E820_RAM) {
542 start = PAGE_ALIGN(start);
543 end &= ~((u64)PAGE_SIZE - 1);
544 }
545
546 e820_add_region(start, end - start, type);
547}
548
David Vrabel3bc38cb2013-08-16 15:42:55 +0100549void xen_ignore_unusable(struct e820entry *list, size_t map_size)
550{
551 struct e820entry *entry;
552 unsigned int i;
553
554 for (i = 0, entry = list; i < map_size; i++, entry++) {
555 if (entry->type == E820_UNUSABLE)
556 entry->type = E820_RAM;
557 }
558}
559
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700560/**
561 * machine_specific_memory_setup - Hook for machine specific memory setup.
562 **/
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700563char * __init xen_memory_setup(void)
564{
Ian Campbell35ae11f2009-02-06 19:09:48 -0800565 static struct e820entry map[E820MAX] __initdata;
566
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700567 unsigned long max_pfn = xen_start_info->nr_pages;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800568 unsigned long long mem_end;
569 int rc;
570 struct xen_memory_map memmap;
David Vrabeldc91c722011-09-29 12:26:19 +0100571 unsigned long max_pages;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400572 unsigned long last_pfn = 0;
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -0700573 unsigned long extra_pages = 0;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800574 int i;
Ian Campbell9e9a5fc2010-09-02 16:16:00 +0100575 int op;
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700576
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +0100577 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
Ian Campbell35ae11f2009-02-06 19:09:48 -0800578 mem_end = PFN_PHYS(max_pfn);
579
580 memmap.nr_entries = E820MAX;
581 set_xen_guest_handle(memmap.buffer, map);
582
Ian Campbell9e9a5fc2010-09-02 16:16:00 +0100583 op = xen_initial_domain() ?
584 XENMEM_machine_memory_map :
585 XENMEM_memory_map;
586 rc = HYPERVISOR_memory_op(op, &memmap);
Ian Campbell35ae11f2009-02-06 19:09:48 -0800587 if (rc == -ENOSYS) {
Ian Campbell9ec23a7f2010-10-28 11:32:29 -0700588 BUG_ON(xen_initial_domain());
Ian Campbell35ae11f2009-02-06 19:09:48 -0800589 memmap.nr_entries = 1;
590 map[0].addr = 0ULL;
591 map[0].size = mem_end;
592 /* 8MB slack (to balance backend allocations). */
593 map[0].size += 8ULL << 20;
594 map[0].type = E820_RAM;
595 rc = 0;
596 }
597 BUG_ON(rc);
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +0100598
David Vrabel3bc38cb2013-08-16 15:42:55 +0100599 /*
600 * Xen won't allow a 1:1 mapping to be created to UNUSABLE
601 * regions, so if we're using the machine memory map leave the
602 * region as RAM as it is in the pseudo-physical map.
603 *
604 * UNUSABLE regions in domUs are not handled and will need
605 * a patch in the future.
606 */
607 if (xen_initial_domain())
608 xen_ignore_unusable(map, memmap.nr_entries);
609
David Vrabeldc91c722011-09-29 12:26:19 +0100610 /* Make sure the Xen-supplied memory map is well-ordered. */
611 sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700612
David Vrabeldc91c722011-09-29 12:26:19 +0100613 max_pages = xen_get_max_pages();
614 if (max_pages > max_pfn)
615 extra_pages += max_pages - max_pfn;
Stefano Stabellini7cb31b72011-01-27 10:13:25 -0500616
David Vrabelf3f436e2011-09-28 17:46:36 +0100617 /*
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700618 * Set identity map on non-RAM pages and remap the underlying RAM.
David Vrabelf3f436e2011-09-28 17:46:36 +0100619 */
Matt Rushton4fbb67e32014-08-11 11:57:57 -0700620 last_pfn = xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn,
621 &xen_released_pages);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -0700622
Konrad Rzeszutek Wilk58b7b532012-05-29 12:36:43 -0400623 extra_pages += xen_released_pages;
Konrad Rzeszutek Wilk2e2fb752012-04-06 10:07:11 -0400624
625 if (last_pfn > max_pfn) {
626 max_pfn = min(MAX_DOMAIN_PAGES, last_pfn);
627 mem_end = PFN_PHYS(max_pfn);
628 }
629 /*
David Vrabeldc91c722011-09-29 12:26:19 +0100630 * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
631 * factor the base size. On non-highmem systems, the base
632 * size is the full initial memory allocation; on highmem it
633 * is limited to the max size of lowmem, so that it doesn't
634 * get completely filled.
635 *
636 * In principle there could be a problem in lowmem systems if
637 * the initial memory is also very large with respect to
638 * lowmem, but we won't try to deal with that here.
639 */
640 extra_pages = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
641 extra_pages);
David Vrabeldc91c722011-09-29 12:26:19 +0100642 i = 0;
643 while (i < memmap.nr_entries) {
644 u64 addr = map[i].addr;
645 u64 size = map[i].size;
646 u32 type = map[i].type;
647
648 if (type == E820_RAM) {
649 if (addr < mem_end) {
650 size = min(size, mem_end - addr);
651 } else if (extra_pages) {
652 size = min(size, (u64)extra_pages * PAGE_SIZE);
653 extra_pages -= size / PAGE_SIZE;
654 xen_add_extra_mem(addr, size);
655 } else
656 type = E820_UNUSABLE;
Jeremy Fitzhardinge36545812010-09-29 16:54:33 -0700657 }
658
David Vrabeldc91c722011-09-29 12:26:19 +0100659 xen_align_and_add_e820_region(addr, size, type);
Jeremy Fitzhardingeb5b43ce2010-09-02 17:10:12 -0700660
David Vrabeldc91c722011-09-29 12:26:19 +0100661 map[i].addr += size;
662 map[i].size -= size;
663 if (map[i].size == 0)
664 i++;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800665 }
Jeremy Fitzhardingeb792c752008-06-16 14:54:49 -0700666
667 /*
David Vrabel25b884a2014-01-03 15:46:10 +0000668 * Set the rest as identity mapped, in case PCI BARs are
669 * located here.
670 *
671 * PFNs above MAX_P2M_PFN are considered identity mapped as
672 * well.
673 */
674 set_phys_range_identity(map[i-1].addr / PAGE_SIZE, ~0ul);
675
676 /*
Ian Campbell9ec23a7f2010-10-28 11:32:29 -0700677 * In domU, the ISA region is normal, usable memory, but we
678 * reserve ISA memory anyway because too many things poke
Jeremy Fitzhardingeb792c752008-06-16 14:54:49 -0700679 * about in there.
680 */
681 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
682 E820_RESERVED);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700683
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700684 /*
685 * Reserve Xen bits:
686 * - mfn_list
687 * - xen_start_info
688 * See comment above "struct start_info" in <xen/interface/xen.h>
Konrad Rzeszutek Wilk51faaf22012-08-22 13:00:10 -0400689 * We tried to make the the memblock_reserve more selective so
690 * that it would be clear what region is reserved. Sadly we ran
691 * in the problem wherein on a 64-bit hypervisor with a 32-bit
692 * initial domain, the pt_base has the cr3 value which is not
693 * neccessarily where the pagetable starts! As Jan put it: "
694 * Actually, the adjustment turns out to be correct: The page
695 * tables for a 32-on-64 dom0 get allocated in the order "first L1",
696 * "first L2", "first L3", so the offset to the page table base is
697 * indeed 2. When reading xen/include/public/xen.h's comment
698 * very strictly, this is not a violation (since there nothing is said
699 * that the first thing in the page table space is pointed to by
700 * pt_base; I admit that this seems to be implied though, namely
701 * do I think that it is implied that the page table space is the
702 * range [pt_base, pt_base + nt_pt_frames), whereas that
703 * range here indeed is [pt_base - 2, pt_base - 2 + nt_pt_frames),
704 * which - without a priori knowledge - the kernel would have
705 * difficulty to figure out)." - so lets just fall back to the
706 * easy way and reserve the whole region.
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700707 */
Tejun Heo24aa0782011-07-12 11:16:06 +0200708 memblock_reserve(__pa(xen_start_info->mfn_list),
709 xen_start_info->pt_base - xen_start_info->mfn_list);
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700710
711 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
712
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700713 return "Xen";
714}
715
Roland McGrathd2eea682007-07-20 00:31:43 -0700716/*
David Vrabelabacaad2014-06-02 17:58:01 +0100717 * Machine specific memory setup for auto-translated guests.
718 */
719char * __init xen_auto_xlated_memory_setup(void)
720{
721 static struct e820entry map[E820MAX] __initdata;
722
723 struct xen_memory_map memmap;
724 int i;
725 int rc;
726
727 memmap.nr_entries = E820MAX;
728 set_xen_guest_handle(memmap.buffer, map);
729
730 rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
731 if (rc < 0)
732 panic("No memory map (%d)\n", rc);
733
734 sanitize_e820_map(map, ARRAY_SIZE(map), &memmap.nr_entries);
735
736 for (i = 0; i < memmap.nr_entries; i++)
737 e820_add_region(map[i].addr, map[i].size, map[i].type);
738
739 memblock_reserve(__pa(xen_start_info->mfn_list),
740 xen_start_info->pt_base - xen_start_info->mfn_list);
741
742 return "Xen";
743}
744
745/*
Roland McGrathd2eea682007-07-20 00:31:43 -0700746 * Set the bit indicating "nosegneg" library variants should be used.
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700747 * We only need to bother in pure 32-bit mode; compat 32-bit processes
748 * can have un-truncated segments, so wrapping around is allowed.
Roland McGrathd2eea682007-07-20 00:31:43 -0700749 */
Sam Ravnborg08b6d292008-01-30 13:33:25 +0100750static void __init fiddle_vdso(void)
Roland McGrathd2eea682007-07-20 00:31:43 -0700751{
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700752#ifdef CONFIG_X86_32
Andy Lutomirski6f121e52014-05-05 12:19:34 -0700753 /*
754 * This could be called before selected_vdso32 is initialized, so
755 * just fiddle with both possible images. vdso_image_32_syscall
756 * can't be selected, since it only exists on 64-bit systems.
757 */
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700758 u32 *mask;
Andy Lutomirski6f121e52014-05-05 12:19:34 -0700759 mask = vdso_image_32_int80.data +
760 vdso_image_32_int80.sym_VDSO32_NOTE_MASK;
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700761 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
Andy Lutomirski6f121e52014-05-05 12:19:34 -0700762 mask = vdso_image_32_sysenter.data +
763 vdso_image_32_sysenter.sym_VDSO32_NOTE_MASK;
Roland McGrathd2eea682007-07-20 00:31:43 -0700764 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700765#endif
Roland McGrathd2eea682007-07-20 00:31:43 -0700766}
767
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400768static int register_callback(unsigned type, const void *func)
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700769{
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700770 struct callback_register callback = {
771 .type = type,
772 .address = XEN_CALLBACK(__KERNEL_CS, func),
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700773 .flags = CALLBACKF_mask_events,
774 };
775
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700776 return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
777}
778
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400779void xen_enable_sysenter(void)
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700780{
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700781 int ret;
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700782 unsigned sysenter_feature;
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700783
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700784#ifdef CONFIG_X86_32
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700785 sysenter_feature = X86_FEATURE_SEP;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700786#else
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700787 sysenter_feature = X86_FEATURE_SYSENTER32;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700788#endif
789
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700790 if (!boot_cpu_has(sysenter_feature))
791 return;
792
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700793 ret = register_callback(CALLBACKTYPE_sysenter, xen_sysenter_target);
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700794 if(ret != 0)
795 setup_clear_cpu_cap(sysenter_feature);
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700796}
797
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400798void xen_enable_syscall(void)
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700799{
800#ifdef CONFIG_X86_64
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700801 int ret;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700802
803 ret = register_callback(CALLBACKTYPE_syscall, xen_syscall_target);
804 if (ret != 0) {
Jeremy Fitzhardinged5303b82008-07-12 02:22:06 -0700805 printk(KERN_ERR "Failed to set syscall callback: %d\n", ret);
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700806 /* Pretty fatal; 64-bit userspace has no other
807 mechanism for syscalls. */
808 }
809
810 if (boot_cpu_has(X86_FEATURE_SYSCALL32)) {
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700811 ret = register_callback(CALLBACKTYPE_syscall32,
812 xen_syscall32_target);
Jeremy Fitzhardinged5303b82008-07-12 02:22:06 -0700813 if (ret != 0)
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700814 setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700815 }
816#endif /* CONFIG_X86_64 */
817}
David Vrabelea9f9272014-06-16 13:07:00 +0200818
Mukesh Rathord285d682013-12-13 12:45:31 -0500819void __init xen_pvmmu_arch_setup(void)
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700820{
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700821 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
822 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
823
Mukesh Rathord285d682013-12-13 12:45:31 -0500824 HYPERVISOR_vm_assist(VMASST_CMD_enable,
825 VMASST_TYPE_pae_extended_cr3);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700826
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700827 if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) ||
828 register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
829 BUG();
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700830
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700831 xen_enable_sysenter();
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700832 xen_enable_syscall();
Mukesh Rathord285d682013-12-13 12:45:31 -0500833}
834
835/* This function is not called for HVM domains */
836void __init xen_arch_setup(void)
837{
838 xen_panic_handler_init();
839 if (!xen_feature(XENFEAT_auto_translated_physmap))
840 xen_pvmmu_arch_setup();
841
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700842#ifdef CONFIG_ACPI
843 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
844 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
845 disable_acpi();
846 }
847#endif
848
849 memcpy(boot_command_line, xen_start_info->cmd_line,
850 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
851 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
852
Jeremy Fitzhardingebc15fde2010-11-22 17:17:50 -0800853 /* Set up idle, making sure it calls safe_halt() pvop */
Len Brownd91ee582011-04-01 18:28:35 -0400854 disable_cpuidle();
Konrad Rzeszutek Wilk48cdd822012-03-13 20:06:57 -0400855 disable_cpufreq();
Len Brown6a377dd2013-02-09 23:08:07 -0500856 WARN_ON(xen_set_default_idle());
Roland McGrathd2eea682007-07-20 00:31:43 -0700857 fiddle_vdso();
Konrad Rzeszutek Wilk8d54db792012-08-17 10:22:37 -0400858#ifdef CONFIG_NUMA
859 numa_off = 1;
860#endif
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700861}