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>
20 #include <xen/interface/callback.h>
21 #include <xen/interface/physdev.h>
22 #include <xen/features.h>
27 /* These are code, but not functions. Defined in entry.S */
28 extern const char xen_hypervisor_callback[];
29 extern const char xen_failsafe_callback[];
33 * machine_specific_memory_setup - Hook for machine specific memory setup.
36 char * __init xen_memory_setup(void)
38 unsigned long max_pfn = xen_start_info->nr_pages;
40 max_pfn = min(MAX_DOMAIN_PAGES, max_pfn);
44 e820_add_region(0, LOWMEMSIZE(), E820_RAM);
45 e820_add_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM);
51 * See comment above "struct start_info" in <xen/interface/xen.h>
53 e820_add_region(__pa(xen_start_info->mfn_list),
54 xen_start_info->pt_base - xen_start_info->mfn_list,
57 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
62 static void xen_idle(void)
69 current_thread_info()->status &= ~TS_POLLING;
70 smp_mb__after_clear_bit();
72 current_thread_info()->status |= TS_POLLING;
77 * Set the bit indicating "nosegneg" library variants should be used.
79 static void __init fiddle_vdso(void)
81 extern const char vdso32_default_start;
82 u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK);
83 *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT;
86 void xen_enable_sysenter(void)
88 int cpu = smp_processor_id();
89 extern void xen_sysenter_target(void);
90 /* Mask events on entry, even though they get enabled immediately */
91 static struct callback_register sysenter = {
92 .type = CALLBACKTYPE_sysenter,
93 .address = { __KERNEL_CS, (unsigned long)xen_sysenter_target },
94 .flags = CALLBACKF_mask_events,
97 if (!boot_cpu_has(X86_FEATURE_SEP) ||
98 HYPERVISOR_callback_op(CALLBACKOP_register, &sysenter) != 0) {
99 clear_cpu_cap(&cpu_data(cpu), X86_FEATURE_SEP);
100 clear_cpu_cap(&boot_cpu_data, X86_FEATURE_SEP);
104 void __init xen_arch_setup(void)
106 struct physdev_set_iopl set_iopl;
109 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
110 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables);
112 if (!xen_feature(XENFEAT_auto_translated_physmap))
113 HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3);
115 HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback,
116 __KERNEL_CS, (unsigned long)xen_failsafe_callback);
118 xen_enable_sysenter();
121 rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
123 printk(KERN_INFO "physdev_op failed %d\n", rc);
126 if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
127 printk(KERN_INFO "ACPI in unprivileged domain disabled\n");
132 memcpy(boot_command_line, xen_start_info->cmd_line,
133 MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ?
134 COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE);
139 /* fill cpus_possible with all available cpus */
140 xen_fill_possible_map();
143 paravirt_disable_iospace();