Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 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> |
Roland McGrath | 6c3652e | 2008-01-30 13:30:42 +0100 | [diff] [blame] | 13 | #include <asm/vdso.h> |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 14 | #include <asm/e820.h> |
| 15 | #include <asm/setup.h> |
| 16 | #include <asm/xen/hypervisor.h> |
| 17 | #include <asm/xen/hypercall.h> |
| 18 | |
| 19 | #include <xen/interface/physdev.h> |
| 20 | #include <xen/features.h> |
| 21 | |
| 22 | #include "xen-ops.h" |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 23 | #include "vdso.h" |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 24 | |
| 25 | /* These are code, but not functions. Defined in entry.S */ |
| 26 | extern const char xen_hypervisor_callback[]; |
| 27 | extern const char xen_failsafe_callback[]; |
| 28 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 29 | unsigned long *phys_to_machine_mapping; |
| 30 | EXPORT_SYMBOL(phys_to_machine_mapping); |
| 31 | |
| 32 | /** |
| 33 | * machine_specific_memory_setup - Hook for machine specific memory setup. |
| 34 | **/ |
| 35 | |
| 36 | char * __init xen_memory_setup(void) |
| 37 | { |
| 38 | unsigned long max_pfn = xen_start_info->nr_pages; |
| 39 | |
| 40 | e820.nr_map = 0; |
Ian Campbell | 87d034f | 2008-02-28 23:16:49 +0000 | [diff] [blame] | 41 | add_memory_region(0, LOWMEMSIZE(), E820_RAM); |
| 42 | add_memory_region(HIGH_MEMORY, PFN_PHYS(max_pfn)-HIGH_MEMORY, E820_RAM); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 43 | |
| 44 | return "Xen"; |
| 45 | } |
| 46 | |
| 47 | static void xen_idle(void) |
| 48 | { |
| 49 | local_irq_disable(); |
| 50 | |
| 51 | if (need_resched()) |
| 52 | local_irq_enable(); |
| 53 | else { |
| 54 | current_thread_info()->status &= ~TS_POLLING; |
| 55 | smp_mb__after_clear_bit(); |
| 56 | safe_halt(); |
| 57 | current_thread_info()->status |= TS_POLLING; |
| 58 | } |
| 59 | } |
| 60 | |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 61 | /* |
| 62 | * Set the bit indicating "nosegneg" library variants should be used. |
| 63 | */ |
Sam Ravnborg | 08b6d29 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 64 | static void __init fiddle_vdso(void) |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 65 | { |
Roland McGrath | af65d64 | 2008-01-30 13:30:43 +0100 | [diff] [blame] | 66 | extern const char vdso32_default_start; |
| 67 | u32 *mask = VDSO32_SYMBOL(&vdso32_default_start, NOTE_MASK); |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 68 | *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT; |
| 69 | } |
| 70 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 71 | void __init xen_arch_setup(void) |
| 72 | { |
| 73 | struct physdev_set_iopl set_iopl; |
| 74 | int rc; |
| 75 | |
| 76 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); |
| 77 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables); |
| 78 | |
| 79 | if (!xen_feature(XENFEAT_auto_translated_physmap)) |
| 80 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_pae_extended_cr3); |
| 81 | |
| 82 | HYPERVISOR_set_callbacks(__KERNEL_CS, (unsigned long)xen_hypervisor_callback, |
| 83 | __KERNEL_CS, (unsigned long)xen_failsafe_callback); |
| 84 | |
| 85 | set_iopl.iopl = 1; |
| 86 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); |
| 87 | if (rc != 0) |
| 88 | printk(KERN_INFO "physdev_op failed %d\n", rc); |
| 89 | |
| 90 | #ifdef CONFIG_ACPI |
| 91 | if (!(xen_start_info->flags & SIF_INITDOMAIN)) { |
| 92 | printk(KERN_INFO "ACPI in unprivileged domain disabled\n"); |
| 93 | disable_acpi(); |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | memcpy(boot_command_line, xen_start_info->cmd_line, |
| 98 | MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ? |
| 99 | COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE); |
| 100 | |
| 101 | pm_idle = xen_idle; |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 102 | |
| 103 | #ifdef CONFIG_SMP |
| 104 | /* fill cpus_possible with all available cpus */ |
| 105 | xen_fill_possible_map(); |
| 106 | #endif |
Jeremy Fitzhardinge | dfdcdd4 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 107 | |
| 108 | paravirt_disable_iospace(); |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 109 | |
| 110 | fiddle_vdso(); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 111 | } |