Merge branches 'x86/numa-fixes', 'x86/apic', 'x86/apm', 'x86/bitops', 'x86/build...
[deliverable/linux.git] / arch / x86 / xen / setup.c
CommitLineData
5ead97c8
JF
1/*
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>
11
12#include <asm/elf.h>
6c3652ef 13#include <asm/vdso.h>
5ead97c8
JF
14#include <asm/e820.h>
15#include <asm/setup.h>
16#include <asm/xen/hypervisor.h>
17#include <asm/xen/hypercall.h>
18
8006ec3e 19#include <xen/page.h>
e2a81baf 20#include <xen/interface/callback.h>
5ead97c8
JF
21#include <xen/interface/physdev.h>
22#include <xen/features.h>
23
24#include "xen-ops.h"
d2eea68e 25#include "vdso.h"
5ead97c8
JF
26
27/* These are code, but not functions. Defined in entry.S */
28extern const char xen_hypervisor_callback[];
29extern const char xen_failsafe_callback[];
30
5ead97c8
JF
31
32/**
33 * machine_specific_memory_setup - Hook for machine specific memory setup.
34 **/
35
36char * __init xen_memory_setup(void)
37{
38 unsigned long max_pfn = xen_start_info->nr_pages;
39
8006ec3e
JF
40 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
41
5ead97c8 42 e820.nr_map = 0;
87d034f3
IC
43 add_memory_region(0, LOWMEMSIZE(), E820_RAM);
44 add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
5ead97c8
JF
45
46 return "Xen";
47}
48
49static void xen_idle(void)
50{
51 local_irq_disable();
52
53 if (need_resched())
54 local_irq_enable();
55 else {
56 current_thread_info()->status &= ~TS_POLLING;
57 smp_mb__after_clear_bit();
58 safe_halt();
59 current_thread_info()->status |= TS_POLLING;
60 }
61}
62
d2eea68e
RM
63/*
64 * Set the bit indicating "nosegneg" library variants should be used.
65 */
08b6d290 66static void __init fiddle_vdso(void)
d2eea68e 67{
af65d648
RM
68 extern const char vdso32_default_start;
69 u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK);
d2eea68e
RM
70 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
71}
72
e2a81baf
JF
73void xen_enable_sysenter(void)
74{
75 int cpu = smp_processor_id();
76 extern void xen_sysenter_target(void);
77 /* Mask events on entry, even though they get enabled immediately */
78 static struct callback_register sysenter = {
79 .type = CALLBACKTYPE_sysenter,
80 .address = { __KERNEL_CS, (unsigned long)xen_sysenter_target },
81 .flags = CALLBACKF_mask_events,
82 };
83
84 if (!boot_cpu_has(X86_FEATURE_SEP) ||
85 HYPERVISOR_callback_op(CALLBACKOP_register, &sysenter) != 0) {
86 clear_cpu_cap(&cpu_data(cpu), X86_FEATURE_SEP);
87 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_SEP);
88 }
89}
90
5ead97c8
JF
91void __init xen_arch_setup(void)
92{
93 struct physdev_set_iopl set_iopl;
94 int rc;
95
96 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
97 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
98
99 if (!xen_feature(XENFEAT_auto_translated_physmap))
100 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
101
102 HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
103 __KERNEL_CS, (unsigned long)xen_failsafe_callback);
104
e2a81baf
JF
105 xen_enable_sysenter();
106
5ead97c8
JF
107 set_iopl.iopl = 1;
108 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
109 if (rc != 0)
110 printk(KERN_INFO "physdev_op failed %d\n", rc);
111
112#ifdef CONFIG_ACPI
113 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
114 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
115 disable_acpi();
116 }
117#endif
118
119 memcpy(boot_command_line, xen_start_info->cmd_line,
120 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
121 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
122
123 pm_idle = xen_idle;
f87e4cac
JF
124
125#ifdef CONFIG_SMP
126 /* fill cpus_possible with all available cpus */
127 xen_fill_possible_map();
128#endif
dfdcdd42
JF
129
130 paravirt_disable_iospace();
d2eea68e
RM
131
132 fiddle_vdso();
5ead97c8 133}
This page took 0.13641 seconds and 5 git commands to generate.