| Linux kernel & device driver programming |
| [ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] |
1 /* 1
2 * Machine specific setup for xen
3 *
4 * Jeremy Fitzhardinge <jeremy@xensource.com>,
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>
13 #include <asm/vdso.h>
14 #include <asm/e820.h>
15 #include <asm/setup.h>
16 #include <asm/acpi.h>
17 #include <asm/xen/hypervisor.h>
18 #include <asm/xen/hypercall.h>
19
20 #include <xen/page.h>
21 #include <xen/interface/callback.h>
22 #include <xen/interface/physdev.h>
23 #include <xen/features.h>
24
25 #include "xen-ops.h"
26 #include "vdso.h"
27
28 /* These are code, but not functions. Defined
29 extern const char xen_hypervisor_callback[];
30 extern const char xen_failsafe_callback[];
31 extern void xen_sysenter_target(void);
32 extern void xen_syscall_target(void);
33 extern void xen_syscall32_target(void);
34
35
36 /**
37 * machine_specific_memory_setup - Hook for ma
38 **/
39
40 char * __init xen_memory_setup(void)
41 {
42 unsigned long max_pfn = xen_start_info
43
44 max_pfn = min(MAX_DOMAIN_PAGES, max_pf
45
46 e820.nr_map = 0;
47
48 e820_add_region(0, PFN_PHYS((u64)max_p
49
50 /*
51 * Even though this is normal, usable
52 * ISA memory anyway because too many
53 * about in there.
54 */
55 e820_add_region(ISA_START_ADDRESS, ISA
56 E820_RESERVED);
57
58 /*
59 * Reserve Xen bits:
60 * - mfn_list
61 * - xen_start_info
62 * See comment above "struct start_inf
63 */
64 reserve_early(__pa(xen_start_info->mfn
65 __pa(xen_start_info->pt_
66 "XEN START INFO");
67
68 sanitize_e820_map(e820.map, ARRAY_SIZE
69
70 return "Xen";
71 }
72
73 static void xen_idle(void)
74 {
75 local_irq_disable();
76
77 if (need_resched())
78 local_irq_enable();
79 else {
80 current_thread_info()->status
81 smp_mb__after_clear_bit();
82 safe_halt();
83 current_thread_info()->status
84 }
85 }
86
87 /*
88 * Set the bit indicating "nosegneg" library v
89 * We only need to bother in pure 32-bit mode;
90 * can have un-truncated segments, so wrapping
91 */
92 static void __init fiddle_vdso(void)
93 {
94 #ifdef CONFIG_X86_32
95 u32 *mask;
96 mask = VDSO32_SYMBOL(&vdso32_int80_sta
97 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
98 mask = VDSO32_SYMBOL(&vdso32_sysenter_
99 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
100 #endif
101 }
102
103 static __cpuinit int register_callback(unsigne
104 {
105 struct callback_register callback = {
106 .type = type,
107 .address = XEN_CALLBACK(__KERN
108 .flags = CALLBACKF_mask_events
109 };
110
111 return HYPERVISOR_callback_op(CALLBACK
112 }
113
114 void __cpuinit xen_enable_sysenter(void)
115 {
116 int ret;
117 unsigned sysenter_feature;
118
119 #ifdef CONFIG_X86_32
120 sysenter_feature = X86_FEATURE_SEP;
121 #else
122 sysenter_feature = X86_FEATURE_SYSENTE
123 #endif
124
125 if (!boot_cpu_has(sysenter_feature))
126 return;
127
128 ret = register_callback(CALLBACKTYPE_s
129 if(ret != 0)
130 setup_clear_cpu_cap(sysenter_f
131 }
132
133 void __cpuinit xen_enable_syscall(void)
134 {
135 #ifdef CONFIG_X86_64
136 int ret;
137
138 ret = register_callback(CALLBACKTYPE_s
139 if (ret != 0) {
140 printk(KERN_ERR "Failed to set
141 /* Pretty fatal; 64-bit usersp
142 mechanism for syscalls. */
143 }
144
145 if (boot_cpu_has(X86_FEATURE_SYSCALL32
146 ret = register_callback(CALLBA
147 xen_sy
148 if (ret != 0)
149 setup_clear_cpu_cap(X8
150 }
151 #endif /* CONFIG_X86_64 */
152 }
153
154 void __init xen_arch_setup(void)
155 {
156 struct physdev_set_iopl set_iopl;
157 int rc;
158
159 HYPERVISOR_vm_assist(VMASST_CMD_enable
160 HYPERVISOR_vm_assist(VMASST_CMD_enable
161
162 if (!xen_feature(XENFEAT_auto_translat
163 HYPERVISOR_vm_assist(VMASST_CM
164 VMASST_TY
165
166 if (register_callback(CALLBACKTYPE_eve
167 register_callback(CALLBACKTYPE_fai
168 BUG();
169
170 xen_enable_sysenter();
171 xen_enable_syscall();
172
173 set_iopl.iopl = 1;
174 rc = HYPERVISOR_physdev_op(PHYSDEVOP_s
175 if (rc != 0)
176 printk(KERN_INFO "physdev_op f
177
178 #ifdef CONFIG_ACPI
179 if (!(xen_start_info->flags & SIF_INIT
180 printk(KERN_INFO "ACPI in unpr
181 disable_acpi();
182 }
183 #endif
184
185 memcpy(boot_command_line, xen_start_in
186 MAX_GUEST_CMDLINE > COMMAND_LIN
187 COMMAND_LINE_SIZE : MAX_GUEST_C
188
189 pm_idle = xen_idle;
190
191 paravirt_disable_iospace();
192
193 fiddle_vdso();
194 }
195
| This page was automatically generated by the LXR engine. |