blob: 1ba8dff26753fb99460a3c33b17feab0ce11ed81 [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>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070020#include <asm/xen/hypervisor.h>
21#include <asm/xen/hypercall.h>
22
Ian Campbell45263cb2010-10-25 16:32:29 -070023#include <xen/xen.h>
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +010024#include <xen/page.h>
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -070025#include <xen/interface/callback.h>
Ian Campbell35ae11f2009-02-06 19:09:48 -080026#include <xen/interface/memory.h>
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070027#include <xen/interface/physdev.h>
28#include <xen/features.h>
29
30#include "xen-ops.h"
Roland McGrathd2eea682007-07-20 00:31:43 -070031#include "vdso.h"
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070032
33/* These are code, but not functions. Defined in entry.S */
34extern const char xen_hypervisor_callback[];
35extern const char xen_failsafe_callback[];
Tejf63c2f22008-12-16 11:56:06 -080036extern void xen_sysenter_target(void);
37extern void xen_syscall_target(void);
38extern void xen_syscall32_target(void);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -070039
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070040/* Amount of extra memory space we add to the e820 ranges */
David Vrabel8b5d44a2011-09-28 17:46:34 +010041struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070042
David Vrabelaa244112011-09-28 17:46:32 +010043/* Number of pages released from the initial allocation. */
44unsigned long xen_released_pages;
45
Jeremy Fitzhardinge698bb8d2010-09-14 10:19:14 -070046/*
47 * The maximum amount of extra memory compared to the base size. The
48 * main scaling factor is the size of struct page. At extreme ratios
49 * of base:extra, all the base memory can be filled with page
50 * structures for the extra memory, leaving no space for anything
51 * else.
52 *
53 * 10x seems like a reasonable balance between scaling flexibility and
54 * leaving a practically usable system.
55 */
56#define EXTRA_MEM_RATIO (10)
57
David Vrabeldc91c722011-09-29 12:26:19 +010058static void __init xen_add_extra_mem(u64 start, u64 size)
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070059{
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050060 unsigned long pfn;
David Vrabeldc91c722011-09-29 12:26:19 +010061 int i;
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050062
David Vrabeldc91c722011-09-29 12:26:19 +010063 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
64 /* Add new region. */
65 if (xen_extra_mem[i].size == 0) {
66 xen_extra_mem[i].start = start;
67 xen_extra_mem[i].size = size;
68 break;
69 }
70 /* Append to existing region. */
71 if (xen_extra_mem[i].start + xen_extra_mem[i].size == start) {
72 xen_extra_mem[i].size += size;
73 break;
74 }
75 }
76 if (i == XEN_EXTRA_MEM_MAX_REGIONS)
77 printk(KERN_WARNING "Warning: not enough extra memory regions\n");
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070078
Tejun Heod4bbf7e2011-11-28 09:46:22 -080079 memblock_reserve(start, size);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070080
David Vrabeldc91c722011-09-29 12:26:19 +010081 xen_max_p2m_pfn = PFN_DOWN(start + size);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070082
David Vrabeldc91c722011-09-29 12:26:19 +010083 for (pfn = PFN_DOWN(start); pfn <= xen_max_p2m_pfn; pfn++)
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -050084 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -070085}
86
David Vrabelf3f436e2011-09-28 17:46:36 +010087static unsigned long __init xen_release_chunk(unsigned long start,
88 unsigned long end)
Miroslav Rezanina093d7b42009-09-16 03:56:17 -040089{
90 struct xen_memory_reservation reservation = {
91 .address_bits = 0,
92 .extent_order = 0,
93 .domid = DOMID_SELF
94 };
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -070095 unsigned long len = 0;
Miroslav Rezanina093d7b42009-09-16 03:56:17 -040096 unsigned long pfn;
97 int ret;
98
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -070099 for(pfn = start; pfn < end; pfn++) {
100 unsigned long mfn = pfn_to_mfn(pfn);
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400101
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700102 /* Make sure pfn exists to start with */
103 if (mfn == INVALID_P2M_ENTRY || mfn_to_pfn(mfn) != pfn)
104 continue;
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400105
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700106 set_xen_guest_handle(reservation.extent_start, &mfn);
107 reservation.nr_extents = 1;
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400108
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700109 ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
110 &reservation);
Igor Mammedov98f531d2011-08-02 11:45:25 +0200111 WARN(ret != 1, "Failed to release pfn %lx err=%d\n", pfn, ret);
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700112 if (ret == 1) {
Konrad Rzeszutek Wilk6eaa4122011-01-18 20:09:41 -0500113 __set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
Jeremy Fitzhardingef89e0482009-09-16 12:38:33 -0700114 len++;
115 }
116 }
Igor Mammedov98f531d2011-08-02 11:45:25 +0200117 printk(KERN_INFO "Freeing %lx-%lx pfn range: %lu pages freed\n",
118 start, end, len);
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400119
120 return len;
121}
122
David Vrabelf3f436e2011-09-28 17:46:36 +0100123static unsigned long __init xen_set_identity_and_release(
124 const struct e820entry *list, size_t map_size, unsigned long nr_pages)
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400125{
David Vrabelf3f436e2011-09-28 17:46:36 +0100126 phys_addr_t start = 0;
Miroslav Rezanina093d7b42009-09-16 03:56:17 -0400127 unsigned long released = 0;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500128 unsigned long identity = 0;
David Vrabelf3f436e2011-09-28 17:46:36 +0100129 const struct e820entry *entry;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500130 int i;
131
David Vrabelf3f436e2011-09-28 17:46:36 +0100132 /*
133 * Combine non-RAM regions and gaps until a RAM region (or the
134 * end of the map) is reached, then set the 1:1 map and
135 * release the pages (if available) in those non-RAM regions.
136 *
137 * The combined non-RAM regions are rounded to a whole number
138 * of pages so any partial pages are accessible via the 1:1
139 * mapping. This is needed for some BIOSes that put (for
140 * example) the DMI tables in a reserved region that begins on
141 * a non-page boundary.
142 */
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500143 for (i = 0, entry = list; i < map_size; i++, entry++) {
David Vrabelf3f436e2011-09-28 17:46:36 +0100144 phys_addr_t end = entry->addr + entry->size;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500145
David Vrabelf3f436e2011-09-28 17:46:36 +0100146 if (entry->type == E820_RAM || i == map_size - 1) {
147 unsigned long start_pfn = PFN_DOWN(start);
148 unsigned long end_pfn = PFN_UP(end);
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500149
David Vrabelf3f436e2011-09-28 17:46:36 +0100150 if (entry->type == E820_RAM)
151 end_pfn = PFN_UP(entry->addr);
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500152
David Vrabelf3f436e2011-09-28 17:46:36 +0100153 if (start_pfn < end_pfn) {
154 if (start_pfn < nr_pages)
155 released += xen_release_chunk(
156 start_pfn, min(end_pfn, nr_pages));
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500157
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500158 identity += set_phys_range_identity(
David Vrabelf3f436e2011-09-28 17:46:36 +0100159 start_pfn, end_pfn);
160 }
161 start = end;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500162 }
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500163 }
David Vrabelf3f436e2011-09-28 17:46:36 +0100164
165 printk(KERN_INFO "Released %lu pages of unused memory\n", released);
166 printk(KERN_INFO "Set %ld page(s) to 1-1 mapping\n", identity);
167
168 return released;
Konrad Rzeszutek Wilk68df0da2011-02-01 17:15:30 -0500169}
David Vrabeld312ae872011-08-19 15:57:16 +0100170
171static unsigned long __init xen_get_max_pages(void)
172{
173 unsigned long max_pages = MAX_DOMAIN_PAGES;
174 domid_t domid = DOMID_SELF;
175 int ret;
176
Ian Campbelld3db7282011-12-14 12:16:08 +0000177 /*
178 * For the initial domain we use the maximum reservation as
179 * the maximum page.
180 *
181 * For guest domains the current maximum reservation reflects
182 * the current maximum rather than the static maximum. In this
183 * case the e820 map provided to us will cover the static
184 * maximum region.
185 */
186 if (xen_initial_domain()) {
187 ret = HYPERVISOR_memory_op(XENMEM_maximum_reservation, &domid);
188 if (ret > 0)
189 max_pages = ret;
190 }
191
David Vrabeld312ae872011-08-19 15:57:16 +0100192 return min(max_pages, MAX_DOMAIN_PAGES);
193}
194
David Vrabeldc91c722011-09-29 12:26:19 +0100195static void xen_align_and_add_e820_region(u64 start, u64 size, int type)
196{
197 u64 end = start + size;
198
199 /* Align RAM regions to page boundaries. */
200 if (type == E820_RAM) {
201 start = PAGE_ALIGN(start);
202 end &= ~((u64)PAGE_SIZE - 1);
203 }
204
205 e820_add_region(start, end - start, type);
206}
207
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700208/**
209 * machine_specific_memory_setup - Hook for machine specific memory setup.
210 **/
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700211char * __init xen_memory_setup(void)
212{
Ian Campbell35ae11f2009-02-06 19:09:48 -0800213 static struct e820entry map[E820MAX] __initdata;
214
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700215 unsigned long max_pfn = xen_start_info->nr_pages;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800216 unsigned long long mem_end;
217 int rc;
218 struct xen_memory_map memmap;
David Vrabeldc91c722011-09-29 12:26:19 +0100219 unsigned long max_pages;
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -0700220 unsigned long extra_pages = 0;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800221 int i;
Ian Campbell9e9a5fc2010-09-02 16:16:00 +0100222 int op;
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700223
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +0100224 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
Ian Campbell35ae11f2009-02-06 19:09:48 -0800225 mem_end = PFN_PHYS(max_pfn);
226
227 memmap.nr_entries = E820MAX;
228 set_xen_guest_handle(memmap.buffer, map);
229
Ian Campbell9e9a5fc2010-09-02 16:16:00 +0100230 op = xen_initial_domain() ?
231 XENMEM_machine_memory_map :
232 XENMEM_memory_map;
233 rc = HYPERVISOR_memory_op(op, &memmap);
Ian Campbell35ae11f2009-02-06 19:09:48 -0800234 if (rc == -ENOSYS) {
Ian Campbell9ec23a7f2010-10-28 11:32:29 -0700235 BUG_ON(xen_initial_domain());
Ian Campbell35ae11f2009-02-06 19:09:48 -0800236 memmap.nr_entries = 1;
237 map[0].addr = 0ULL;
238 map[0].size = mem_end;
239 /* 8MB slack (to balance backend allocations). */
240 map[0].size += 8ULL << 20;
241 map[0].type = E820_RAM;
242 rc = 0;
243 }
244 BUG_ON(rc);
Jeremy Fitzhardinge8006ec32008-05-26 23:31:19 +0100245
David Vrabeldc91c722011-09-29 12:26:19 +0100246 /* Make sure the Xen-supplied memory map is well-ordered. */
247 sanitize_e820_map(map, memmap.nr_entries, &memmap.nr_entries);
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700248
David Vrabeldc91c722011-09-29 12:26:19 +0100249 max_pages = xen_get_max_pages();
250 if (max_pages > max_pfn)
251 extra_pages += max_pages - max_pfn;
Stefano Stabellini7cb31b72011-01-27 10:13:25 -0500252
David Vrabelf3f436e2011-09-28 17:46:36 +0100253 /*
254 * Set P2M for all non-RAM pages and E820 gaps to be identity
255 * type PFNs. Any RAM pages that would be made inaccesible by
256 * this are first released.
257 */
258 xen_released_pages = xen_set_identity_and_release(
259 map, memmap.nr_entries, max_pfn);
David Vrabeldc91c722011-09-29 12:26:19 +0100260 extra_pages += xen_released_pages;
Jeremy Fitzhardinge42ee1472010-08-30 16:41:02 -0700261
David Vrabeldc91c722011-09-29 12:26:19 +0100262 /*
263 * Clamp the amount of extra memory to a EXTRA_MEM_RATIO
264 * factor the base size. On non-highmem systems, the base
265 * size is the full initial memory allocation; on highmem it
266 * is limited to the max size of lowmem, so that it doesn't
267 * get completely filled.
268 *
269 * In principle there could be a problem in lowmem systems if
270 * the initial memory is also very large with respect to
271 * lowmem, but we won't try to deal with that here.
272 */
273 extra_pages = min(EXTRA_MEM_RATIO * min(max_pfn, PFN_DOWN(MAXMEM)),
274 extra_pages);
Jeremy Fitzhardinge36545812010-09-29 16:54:33 -0700275
David Vrabeldc91c722011-09-29 12:26:19 +0100276 i = 0;
277 while (i < memmap.nr_entries) {
278 u64 addr = map[i].addr;
279 u64 size = map[i].size;
280 u32 type = map[i].type;
281
282 if (type == E820_RAM) {
283 if (addr < mem_end) {
284 size = min(size, mem_end - addr);
285 } else if (extra_pages) {
286 size = min(size, (u64)extra_pages * PAGE_SIZE);
287 extra_pages -= size / PAGE_SIZE;
288 xen_add_extra_mem(addr, size);
289 } else
290 type = E820_UNUSABLE;
Jeremy Fitzhardinge36545812010-09-29 16:54:33 -0700291 }
292
David Vrabeldc91c722011-09-29 12:26:19 +0100293 xen_align_and_add_e820_region(addr, size, type);
Jeremy Fitzhardingeb5b43ce2010-09-02 17:10:12 -0700294
David Vrabeldc91c722011-09-29 12:26:19 +0100295 map[i].addr += size;
296 map[i].size -= size;
297 if (map[i].size == 0)
298 i++;
Ian Campbell35ae11f2009-02-06 19:09:48 -0800299 }
Jeremy Fitzhardingeb792c752008-06-16 14:54:49 -0700300
301 /*
Ian Campbell9ec23a7f2010-10-28 11:32:29 -0700302 * In domU, the ISA region is normal, usable memory, but we
303 * reserve ISA memory anyway because too many things poke
Jeremy Fitzhardingeb792c752008-06-16 14:54:49 -0700304 * about in there.
305 */
306 e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS,
307 E820_RESERVED);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700308
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700309 /*
310 * Reserve Xen bits:
311 * - mfn_list
312 * - xen_start_info
313 * See comment above "struct start_info" in <xen/interface/xen.h>
314 */
Tejun Heo24aa0782011-07-12 11:16:06 +0200315 memblock_reserve(__pa(xen_start_info->mfn_list),
316 xen_start_info->pt_base - xen_start_info->mfn_list);
Jeremy Fitzhardingebe5bf9f2008-06-16 14:54:46 -0700317
318 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
319
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700320 return "Xen";
321}
322
Roland McGrathd2eea682007-07-20 00:31:43 -0700323/*
324 * Set the bit indicating "nosegneg" library variants should be used.
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700325 * We only need to bother in pure 32-bit mode; compat 32-bit processes
326 * can have un-truncated segments, so wrapping around is allowed.
Roland McGrathd2eea682007-07-20 00:31:43 -0700327 */
Sam Ravnborg08b6d292008-01-30 13:33:25 +0100328static void __init fiddle_vdso(void)
Roland McGrathd2eea682007-07-20 00:31:43 -0700329{
Jeremy Fitzhardinge6a52e4b2008-07-12 02:22:00 -0700330#ifdef CONFIG_X86_32
331 u32 *mask;
332 mask = VDSO32_SYMBOL(&vdso32_int80_start, NOTE_MASK);
333 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
334 mask = VDSO32_SYMBOL(&vdso32_sysenter_start, NOTE_MASK);
Roland McGrathd2eea682007-07-20 00:31:43 -0700335 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700336#endif
Roland McGrathd2eea682007-07-20 00:31:43 -0700337}
338
Daniel Kiperae15a3b2011-05-04 20:17:21 +0200339static int __cpuinit register_callback(unsigned type, const void *func)
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700340{
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700341 struct callback_register callback = {
342 .type = type,
343 .address = XEN_CALLBACK(__KERNEL_CS, func),
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700344 .flags = CALLBACKF_mask_events,
345 };
346
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700347 return HYPERVISOR_callback_op(CALLBACKOP_register, &callback);
348}
349
350void __cpuinit xen_enable_sysenter(void)
351{
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700352 int ret;
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700353 unsigned sysenter_feature;
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700354
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700355#ifdef CONFIG_X86_32
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700356 sysenter_feature = X86_FEATURE_SEP;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700357#else
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700358 sysenter_feature = X86_FEATURE_SYSENTER32;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700359#endif
360
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700361 if (!boot_cpu_has(sysenter_feature))
362 return;
363
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700364 ret = register_callback(CALLBACKTYPE_sysenter, xen_sysenter_target);
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700365 if(ret != 0)
366 setup_clear_cpu_cap(sysenter_feature);
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700367}
368
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700369void __cpuinit xen_enable_syscall(void)
370{
371#ifdef CONFIG_X86_64
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700372 int ret;
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700373
374 ret = register_callback(CALLBACKTYPE_syscall, xen_syscall_target);
375 if (ret != 0) {
Jeremy Fitzhardinged5303b82008-07-12 02:22:06 -0700376 printk(KERN_ERR "Failed to set syscall callback: %d\n", ret);
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700377 /* Pretty fatal; 64-bit userspace has no other
378 mechanism for syscalls. */
379 }
380
381 if (boot_cpu_has(X86_FEATURE_SYSCALL32)) {
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700382 ret = register_callback(CALLBACKTYPE_syscall32,
383 xen_syscall32_target);
Jeremy Fitzhardinged5303b82008-07-12 02:22:06 -0700384 if (ret != 0)
Jeremy Fitzhardinge62541c32008-07-10 16:24:08 -0700385 setup_clear_cpu_cap(X86_FEATURE_SYSCALL32);
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700386 }
387#endif /* CONFIG_X86_64 */
388}
389
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700390void __init xen_arch_setup(void)
391{
Donald Dutilef09f6d12010-07-15 14:56:49 -0400392 xen_panic_handler_init();
393
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700394 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
395 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
396
397 if (!xen_feature(XENFEAT_auto_translated_physmap))
Tejf63c2f22008-12-16 11:56:06 -0800398 HYPERVISOR_vm_assist(VMASST_CMD_enable,
399 VMASST_TYPE_pae_extended_cr3);
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700400
Jeremy Fitzhardinge88459d42008-07-08 15:07:02 -0700401 if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) ||
402 register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback))
403 BUG();
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700404
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700405 xen_enable_sysenter();
Jeremy Fitzhardinge6fcac6d2008-07-08 15:07:14 -0700406 xen_enable_syscall();
Jeremy Fitzhardingee2a81ba2008-03-17 16:37:17 -0700407
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700408#ifdef CONFIG_ACPI
409 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
410 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
411 disable_acpi();
412 }
413#endif
414
415 memcpy(boot_command_line, xen_start_info->cmd_line,
416 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
417 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
418
Jeremy Fitzhardingebc15fde2010-11-22 17:17:50 -0800419 /* Set up idle, making sure it calls safe_halt() pvop */
420#ifdef CONFIG_X86_32
421 boot_cpu_data.hlt_works_ok = 1;
422#endif
Len Brownd91ee582011-04-01 18:28:35 -0400423 disable_cpuidle();
Konrad Rzeszutek Wilk48cdd822012-03-13 20:06:57 -0400424 disable_cpufreq();
Konrad Rzeszutek Wilke5fd47b2011-11-21 18:02:02 -0500425 WARN_ON(set_pm_idle_to_default());
Roland McGrathd2eea682007-07-20 00:31:43 -0700426 fiddle_vdso();
Jeremy Fitzhardinge5ead97c2007-07-17 18:37:04 -0700427}