2 * Machine specific setup for xen
4 * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007
7 #include <linux/module.h>
8 #include <linux/sched.h>
15 #include <asm/setup.h>
17 #include <asm/xen/hypervisor.h>
18 #include <asm/xen/hypercall.h>
21 #include <xen/interface/callback.h>
22 #include <xen/interface/physdev.h>
23 #include <xen/features.h>
28 /* These are code, but not functions. Defined in entry.S */
29 extern const char xen_hypervisor_callback
[];
30 extern const char xen_failsafe_callback
[];
34 * machine_specific_memory_setup - Hook for machine specific memory setup.
37 char * __init
xen_memory_setup(void)
39 unsigned long max_pfn
= xen_start_info
->nr_pages
;
41 max_pfn
= min(MAX_DOMAIN_PAGES
, max_pfn
);
45 e820_add_region(0, PFN_PHYS(max_pfn
), E820_RAM
);
48 * Even though this is normal, usable memory under Xen, reserve
49 * ISA memory anyway because too many things think they can poke
52 e820_add_region(ISA_START_ADDRESS
, ISA_END_ADDRESS
- ISA_START_ADDRESS
,
59 * See comment above "struct start_info" in <xen/interface/xen.h>
61 e820_add_region(__pa(xen_start_info
->mfn_list
),
62 xen_start_info
->pt_base
- xen_start_info
->mfn_list
,
65 sanitize_e820_map(e820
.map
, ARRAY_SIZE(e820
.map
), &e820
.nr_map
);
70 static void xen_idle(void)
77 current_thread_info()->status
&= ~TS_POLLING
;
78 smp_mb__after_clear_bit();
80 current_thread_info()->status
|= TS_POLLING
;
85 * Set the bit indicating "nosegneg" library variants should be used.
87 static void __init
fiddle_vdso(void)
89 #if defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION)
90 extern const char vdso32_default_start
;
91 u32
*mask
= VDSO32_SYMBOL(&vdso32_default_start
, NOTE_MASK
);
92 *mask
|= 1 << VDSO_NOTE_NONEGSEG_BIT
;
96 static __cpuinit
int register_callback(unsigned type
, const void *func
)
98 struct callback_register callback
= {
100 .address
= XEN_CALLBACK(__KERNEL_CS
, func
),
101 .flags
= CALLBACKF_mask_events
,
104 return HYPERVISOR_callback_op(CALLBACKOP_register
, &callback
);
107 void __cpuinit
xen_enable_sysenter(void)
109 int cpu
= smp_processor_id();
110 extern void xen_sysenter_target(void);
114 if (!boot_cpu_has(X86_FEATURE_SEP
)) {
118 if (boot_cpu_data
.x86_vendor
!= X86_VENDOR_INTEL
&&
119 boot_cpu_data
.x86_vendor
!= X86_VENDOR_CENTAUR
) {
124 ret
= register_callback(CALLBACKTYPE_sysenter
, xen_sysenter_target
);
126 clear_cpu_cap(&cpu_data(cpu
), X86_FEATURE_SEP
);
127 clear_cpu_cap(&boot_cpu_data
, X86_FEATURE_SEP
);
131 void __cpuinit
xen_enable_syscall(void)
134 int cpu
= smp_processor_id();
136 extern void xen_syscall_target(void);
137 extern void xen_syscall32_target(void);
139 ret
= register_callback(CALLBACKTYPE_syscall
, xen_syscall_target
);
141 printk("failed to set syscall: %d\n", ret
);
142 clear_cpu_cap(&cpu_data(cpu
), X86_FEATURE_SYSCALL
);
143 clear_cpu_cap(&boot_cpu_data
, X86_FEATURE_SYSCALL
);
145 ret
= register_callback(CALLBACKTYPE_syscall32
,
146 xen_syscall32_target
);
148 printk("failed to set 32-bit syscall: %d\n", ret
);
150 #endif /* CONFIG_X86_64 */
153 void __init
xen_arch_setup(void)
155 struct physdev_set_iopl set_iopl
;
158 HYPERVISOR_vm_assist(VMASST_CMD_enable
, VMASST_TYPE_4gb_segments
);
159 HYPERVISOR_vm_assist(VMASST_CMD_enable
, VMASST_TYPE_writable_pagetables
);
161 if (!xen_feature(XENFEAT_auto_translated_physmap
))
162 HYPERVISOR_vm_assist(VMASST_CMD_enable
, VMASST_TYPE_pae_extended_cr3
);
164 if (register_callback(CALLBACKTYPE_event
, xen_hypervisor_callback
) ||
165 register_callback(CALLBACKTYPE_failsafe
, xen_failsafe_callback
))
168 xen_enable_sysenter();
169 xen_enable_syscall();
172 rc
= HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl
, &set_iopl
);
174 printk(KERN_INFO
"physdev_op failed %d\n", rc
);
177 if (!(xen_start_info
->flags
& SIF_INITDOMAIN
)) {
178 printk(KERN_INFO
"ACPI in unprivileged domain disabled\n");
183 memcpy(boot_command_line
, xen_start_info
->cmd_line
,
184 MAX_GUEST_CMDLINE
> COMMAND_LINE_SIZE
?
185 COMMAND_LINE_SIZE
: MAX_GUEST_CMDLINE
);
189 paravirt_disable_iospace();