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>
16 #include <asm/xen/hypervisor.h>
17 #include <asm/xen/hypercall.h>
19 #include <xen/interface/callback.h>
20 #include <xen/interface/physdev.h>
21 #include <xen/features.h>
26 /* These are code, but not functions. Defined in entry.S */
27 extern const char xen_hypervisor_callback[];
28 extern const char xen_failsafe_callback[];
32 * machine_specific_memory_setup - Hook for machine specific memory setup.
35 char * __init xen_memory_setup(void)
37 unsigned long max_pfn = xen_start_info->nr_pages;
40 add_memory_region(0, LOWMEMSIZE(), E820_RAM);
41 add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
46 static void xen_idle(void)
53 current_thread_info()->status &= ~TS_POLLING;
54 smp_mb__after_clear_bit();
56 current_thread_info()->status |= TS_POLLING;
61 * Set the bit indicating "nosegneg" library variants should be used.
63 static void __init fiddle_vdso(void)
65 extern const char vdso32_default_start;
66 u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK);
67 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
70 void xen_enable_sysenter(void)
72 int cpu = smp_processor_id();
73 extern void xen_sysenter_target(void);
74 /* Mask events on entry, even though they get enabled immediately */
75 static struct callback_register sysenter = {
76 .type = CALLBACKTYPE_sysenter,
77 .address = { __KERNEL_CS, (unsigned long)xen_sysenter_target },
78 .flags = CALLBACKF_mask_events,
81 if (!boot_cpu_has(X86_FEATURE_SEP) ||
82 HYPERVISOR_callback_op(CALLBACKOP_register, &sysenter) != 0) {
83 clear_cpu_cap(&cpu_data(cpu), X86_FEATURE_SEP);
84 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_SEP);
88 void __init xen_arch_setup(void)
90 struct physdev_set_iopl set_iopl;
93 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
94 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
96 if (!xen_feature(XENFEAT_auto_translated_physmap))
97 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
99 HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
100 __KERNEL_CS, (unsigned long)xen_failsafe_callback);
102 xen_enable_sysenter();
105 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
107 printk(KERN_INFO "physdev_op failed %d\n", rc);
110 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
111 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
116 memcpy(boot_command_line, xen_start_info->cmd_line,
117 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
118 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
123 /* fill cpus_possible with all available cpus */
124 xen_fill_possible_map();
127 paravirt_disable_iospace();