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> |
Jeremy Fitzhardinge | b792c75 | 2008-06-16 14:54:49 -0700 | [diff] [blame] | 16 | #include <asm/acpi.h> |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 17 | #include <asm/xen/hypervisor.h> |
| 18 | #include <asm/xen/hypercall.h> |
| 19 | |
Jeremy Fitzhardinge | 8006ec3 | 2008-05-26 23:31:19 +0100 | [diff] [blame] | 20 | #include <xen/page.h> |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 21 | #include <xen/interface/callback.h> |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 22 | #include <xen/interface/memory.h> |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 23 | #include <xen/interface/physdev.h> |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 24 | #include <xen/interface/memory.h> |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 25 | #include <xen/features.h> |
| 26 | |
| 27 | #include "xen-ops.h" |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 28 | #include "vdso.h" |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 29 | |
| 30 | /* These are code, but not functions. Defined in entry.S */ |
| 31 | extern const char xen_hypervisor_callback[]; |
| 32 | extern const char xen_failsafe_callback[]; |
Tej | f63c2f2 | 2008-12-16 11:56:06 -0800 | [diff] [blame] | 33 | extern void xen_sysenter_target(void); |
| 34 | extern void xen_syscall_target(void); |
| 35 | extern void xen_syscall32_target(void); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 36 | |
Jeremy Fitzhardinge | 42ee147 | 2010-08-30 16:41:02 -0700 | [diff] [blame] | 37 | /* Amount of extra memory space we add to the e820 ranges */ |
| 38 | phys_addr_t xen_extra_mem_start, xen_extra_mem_size; |
| 39 | |
| 40 | static __init void xen_add_extra_mem(unsigned long pages) |
| 41 | { |
| 42 | u64 size = (u64)pages * PAGE_SIZE; |
| 43 | |
| 44 | if (!pages) |
| 45 | return; |
| 46 | |
| 47 | e820_add_region(xen_extra_mem_start + xen_extra_mem_size, size, E820_RAM); |
| 48 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
| 49 | |
| 50 | reserve_early(xen_extra_mem_start + xen_extra_mem_size, |
| 51 | xen_extra_mem_start + xen_extra_mem_size + size, |
| 52 | "XEN EXTRA"); |
| 53 | |
| 54 | xen_extra_mem_size += size; |
| 55 | } |
| 56 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 57 | static unsigned long __init xen_release_chunk(phys_addr_t start_addr, |
| 58 | phys_addr_t end_addr) |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 59 | { |
| 60 | struct xen_memory_reservation reservation = { |
| 61 | .address_bits = 0, |
| 62 | .extent_order = 0, |
| 63 | .domid = DOMID_SELF |
| 64 | }; |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 65 | unsigned long start, end; |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 66 | unsigned long len = 0; |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 67 | unsigned long pfn; |
| 68 | int ret; |
| 69 | |
| 70 | start = PFN_UP(start_addr); |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 71 | end = PFN_DOWN(end_addr); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 72 | |
| 73 | if (end <= start) |
| 74 | return 0; |
| 75 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 76 | printk(KERN_INFO "xen_release_chunk: looking at area pfn %lx-%lx: ", |
| 77 | start, end); |
| 78 | for(pfn = start; pfn < end; pfn++) { |
| 79 | unsigned long mfn = pfn_to_mfn(pfn); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 80 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 81 | /* Make sure pfn exists to start with */ |
| 82 | if (mfn == INVALID_P2M_ENTRY || mfn_to_pfn(mfn) != pfn) |
| 83 | continue; |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 84 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 85 | set_xen_guest_handle(reservation.extent_start, &mfn); |
| 86 | reservation.nr_extents = 1; |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 87 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 88 | ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation, |
| 89 | &reservation); |
| 90 | WARN(ret != 1, "Failed to release memory %lx-%lx err=%d\n", |
| 91 | start, end, ret); |
| 92 | if (ret == 1) { |
| 93 | set_phys_to_machine(pfn, INVALID_P2M_ENTRY); |
| 94 | len++; |
| 95 | } |
| 96 | } |
| 97 | printk(KERN_CONT "%ld pages freed\n", len); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 98 | |
| 99 | return len; |
| 100 | } |
| 101 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 102 | static unsigned long __init xen_return_unused_memory(unsigned long max_pfn, |
| 103 | const struct e820map *e820) |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 104 | { |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 105 | phys_addr_t max_addr = PFN_PHYS(max_pfn); |
| 106 | phys_addr_t last_end = 0; |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 107 | unsigned long released = 0; |
| 108 | int i; |
| 109 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 110 | for (i = 0; i < e820->nr_map && last_end < max_addr; i++) { |
| 111 | phys_addr_t end = e820->map[i].addr; |
| 112 | end = min(max_addr, end); |
| 113 | |
| 114 | released += xen_release_chunk(last_end, end); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 115 | last_end = e820->map[i].addr + e820->map[i].size; |
| 116 | } |
| 117 | |
Jeremy Fitzhardinge | f89e048 | 2009-09-16 12:38:33 -0700 | [diff] [blame] | 118 | if (last_end < max_addr) |
| 119 | released += xen_release_chunk(last_end, max_addr); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 120 | |
| 121 | printk(KERN_INFO "released %ld pages of unused memory\n", released); |
| 122 | return released; |
| 123 | } |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * machine_specific_memory_setup - Hook for machine specific memory setup. |
| 127 | **/ |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 128 | char * __init xen_memory_setup(void) |
| 129 | { |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 130 | static struct e820entry map[E820MAX] __initdata; |
| 131 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 132 | unsigned long max_pfn = xen_start_info->nr_pages; |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 133 | unsigned long long mem_end; |
| 134 | int rc; |
| 135 | struct xen_memory_map memmap; |
Jeremy Fitzhardinge | 42ee147 | 2010-08-30 16:41:02 -0700 | [diff] [blame] | 136 | unsigned long extra_pages = 0; |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 137 | int i; |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 138 | |
Jeremy Fitzhardinge | 8006ec3 | 2008-05-26 23:31:19 +0100 | [diff] [blame] | 139 | max_pfn = min(MAX_DOMAIN_PAGES, max_pfn); |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 140 | mem_end = PFN_PHYS(max_pfn); |
| 141 | |
| 142 | memmap.nr_entries = E820MAX; |
| 143 | set_xen_guest_handle(memmap.buffer, map); |
| 144 | |
| 145 | rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap); |
| 146 | if (rc == -ENOSYS) { |
| 147 | memmap.nr_entries = 1; |
| 148 | map[0].addr = 0ULL; |
| 149 | map[0].size = mem_end; |
| 150 | /* 8MB slack (to balance backend allocations). */ |
| 151 | map[0].size += 8ULL << 20; |
| 152 | map[0].type = E820_RAM; |
| 153 | rc = 0; |
| 154 | } |
| 155 | BUG_ON(rc); |
Jeremy Fitzhardinge | 8006ec3 | 2008-05-26 23:31:19 +0100 | [diff] [blame] | 156 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 157 | e820.nr_map = 0; |
Jeremy Fitzhardinge | 42ee147 | 2010-08-30 16:41:02 -0700 | [diff] [blame] | 158 | xen_extra_mem_start = mem_end; |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 159 | for (i = 0; i < memmap.nr_entries; i++) { |
| 160 | unsigned long long end = map[i].addr + map[i].size; |
Jeremy Fitzhardinge | b5b43ce | 2010-09-02 17:10:12 -0700 | [diff] [blame^] | 161 | |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 162 | if (map[i].type == E820_RAM) { |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 163 | if (end > mem_end) { |
| 164 | /* Truncate region to max_mem. */ |
| 165 | map[i].size -= end - mem_end; |
Jeremy Fitzhardinge | 42ee147 | 2010-08-30 16:41:02 -0700 | [diff] [blame] | 166 | |
| 167 | extra_pages += PFN_DOWN(end - mem_end); |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 168 | } |
Jeremy Fitzhardinge | 36bc251 | 2010-09-02 17:07:03 -0700 | [diff] [blame] | 169 | } else if (map[i].type != E820_RAM) |
| 170 | xen_extra_mem_start = end; |
Jeremy Fitzhardinge | b5b43ce | 2010-09-02 17:10:12 -0700 | [diff] [blame^] | 171 | |
| 172 | if ((map[i].type != E820_RAM || map[i].addr < mem_end) && |
| 173 | map[i].size > 0) |
Ian Campbell | 35ae11f | 2009-02-06 19:09:48 -0800 | [diff] [blame] | 174 | e820_add_region(map[i].addr, map[i].size, map[i].type); |
| 175 | } |
Jeremy Fitzhardinge | b792c75 | 2008-06-16 14:54:49 -0700 | [diff] [blame] | 176 | |
| 177 | /* |
| 178 | * Even though this is normal, usable memory under Xen, reserve |
| 179 | * ISA memory anyway because too many things think they can poke |
| 180 | * about in there. |
| 181 | */ |
| 182 | e820_add_region(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, |
| 183 | E820_RESERVED); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 184 | |
Jeremy Fitzhardinge | be5bf9f | 2008-06-16 14:54:46 -0700 | [diff] [blame] | 185 | /* |
| 186 | * Reserve Xen bits: |
| 187 | * - mfn_list |
| 188 | * - xen_start_info |
| 189 | * See comment above "struct start_info" in <xen/interface/xen.h> |
| 190 | */ |
Jeremy Fitzhardinge | 6b2e852 | 2009-05-07 11:56:49 -0700 | [diff] [blame] | 191 | reserve_early(__pa(xen_start_info->mfn_list), |
| 192 | __pa(xen_start_info->pt_base), |
| 193 | "XEN START INFO"); |
Jeremy Fitzhardinge | be5bf9f | 2008-06-16 14:54:46 -0700 | [diff] [blame] | 194 | |
| 195 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
| 196 | |
Jeremy Fitzhardinge | 42ee147 | 2010-08-30 16:41:02 -0700 | [diff] [blame] | 197 | extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820); |
| 198 | |
| 199 | xen_add_extra_mem(extra_pages); |
Miroslav Rezanina | 093d7b4 | 2009-09-16 03:56:17 -0400 | [diff] [blame] | 200 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 201 | return "Xen"; |
| 202 | } |
| 203 | |
| 204 | static void xen_idle(void) |
| 205 | { |
| 206 | local_irq_disable(); |
| 207 | |
| 208 | if (need_resched()) |
| 209 | local_irq_enable(); |
| 210 | else { |
| 211 | current_thread_info()->status &= ~TS_POLLING; |
| 212 | smp_mb__after_clear_bit(); |
| 213 | safe_halt(); |
| 214 | current_thread_info()->status |= TS_POLLING; |
| 215 | } |
| 216 | } |
| 217 | |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 218 | /* |
| 219 | * Set the bit indicating "nosegneg" library variants should be used. |
Jeremy Fitzhardinge | 6a52e4b | 2008-07-12 02:22:00 -0700 | [diff] [blame] | 220 | * We only need to bother in pure 32-bit mode; compat 32-bit processes |
| 221 | * can have un-truncated segments, so wrapping around is allowed. |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 222 | */ |
Sam Ravnborg | 08b6d29 | 2008-01-30 13:33:25 +0100 | [diff] [blame] | 223 | static void __init fiddle_vdso(void) |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 224 | { |
Jeremy Fitzhardinge | 6a52e4b | 2008-07-12 02:22:00 -0700 | [diff] [blame] | 225 | #ifdef CONFIG_X86_32 |
| 226 | u32 *mask; |
| 227 | mask = VDSO32_SYMBOL(&vdso32_int80_start, NOTE_MASK); |
| 228 | *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT; |
| 229 | mask = VDSO32_SYMBOL(&vdso32_sysenter_start, NOTE_MASK); |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 230 | *mask |= 1 << VDSO_NOTE_NONEGSEG_BIT; |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 231 | #endif |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Jeremy Fitzhardinge | 88459d4 | 2008-07-08 15:07:02 -0700 | [diff] [blame] | 234 | static __cpuinit int register_callback(unsigned type, const void *func) |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 235 | { |
Jeremy Fitzhardinge | 88459d4 | 2008-07-08 15:07:02 -0700 | [diff] [blame] | 236 | struct callback_register callback = { |
| 237 | .type = type, |
| 238 | .address = XEN_CALLBACK(__KERNEL_CS, func), |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 239 | .flags = CALLBACKF_mask_events, |
| 240 | }; |
| 241 | |
Jeremy Fitzhardinge | 88459d4 | 2008-07-08 15:07:02 -0700 | [diff] [blame] | 242 | return HYPERVISOR_callback_op(CALLBACKOP_register, &callback); |
| 243 | } |
| 244 | |
| 245 | void __cpuinit xen_enable_sysenter(void) |
| 246 | { |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 247 | int ret; |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 248 | unsigned sysenter_feature; |
Jeremy Fitzhardinge | 88459d4 | 2008-07-08 15:07:02 -0700 | [diff] [blame] | 249 | |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 250 | #ifdef CONFIG_X86_32 |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 251 | sysenter_feature = X86_FEATURE_SEP; |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 252 | #else |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 253 | sysenter_feature = X86_FEATURE_SYSENTER32; |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 254 | #endif |
| 255 | |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 256 | if (!boot_cpu_has(sysenter_feature)) |
| 257 | return; |
| 258 | |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 259 | ret = register_callback(CALLBACKTYPE_sysenter, xen_sysenter_target); |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 260 | if(ret != 0) |
| 261 | setup_clear_cpu_cap(sysenter_feature); |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 264 | void __cpuinit xen_enable_syscall(void) |
| 265 | { |
| 266 | #ifdef CONFIG_X86_64 |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 267 | int ret; |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 268 | |
| 269 | ret = register_callback(CALLBACKTYPE_syscall, xen_syscall_target); |
| 270 | if (ret != 0) { |
Jeremy Fitzhardinge | d5303b8 | 2008-07-12 02:22:06 -0700 | [diff] [blame] | 271 | printk(KERN_ERR "Failed to set syscall callback: %d\n", ret); |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 272 | /* Pretty fatal; 64-bit userspace has no other |
| 273 | mechanism for syscalls. */ |
| 274 | } |
| 275 | |
| 276 | if (boot_cpu_has(X86_FEATURE_SYSCALL32)) { |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 277 | ret = register_callback(CALLBACKTYPE_syscall32, |
| 278 | xen_syscall32_target); |
Jeremy Fitzhardinge | d5303b8 | 2008-07-12 02:22:06 -0700 | [diff] [blame] | 279 | if (ret != 0) |
Jeremy Fitzhardinge | 62541c3 | 2008-07-10 16:24:08 -0700 | [diff] [blame] | 280 | setup_clear_cpu_cap(X86_FEATURE_SYSCALL32); |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 281 | } |
| 282 | #endif /* CONFIG_X86_64 */ |
| 283 | } |
| 284 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 285 | void __init xen_arch_setup(void) |
| 286 | { |
| 287 | struct physdev_set_iopl set_iopl; |
| 288 | int rc; |
| 289 | |
Donald Dutile | f09f6d1 | 2010-07-15 14:56:49 -0400 | [diff] [blame] | 290 | xen_panic_handler_init(); |
| 291 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 292 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments); |
| 293 | HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_writable_pagetables); |
| 294 | |
| 295 | if (!xen_feature(XENFEAT_auto_translated_physmap)) |
Tej | f63c2f2 | 2008-12-16 11:56:06 -0800 | [diff] [blame] | 296 | HYPERVISOR_vm_assist(VMASST_CMD_enable, |
| 297 | VMASST_TYPE_pae_extended_cr3); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 298 | |
Jeremy Fitzhardinge | 88459d4 | 2008-07-08 15:07:02 -0700 | [diff] [blame] | 299 | if (register_callback(CALLBACKTYPE_event, xen_hypervisor_callback) || |
| 300 | register_callback(CALLBACKTYPE_failsafe, xen_failsafe_callback)) |
| 301 | BUG(); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 302 | |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 303 | xen_enable_sysenter(); |
Jeremy Fitzhardinge | 6fcac6d | 2008-07-08 15:07:14 -0700 | [diff] [blame] | 304 | xen_enable_syscall(); |
Jeremy Fitzhardinge | e2a81ba | 2008-03-17 16:37:17 -0700 | [diff] [blame] | 305 | |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 306 | set_iopl.iopl = 1; |
| 307 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl); |
| 308 | if (rc != 0) |
| 309 | printk(KERN_INFO "physdev_op failed %d\n", rc); |
| 310 | |
| 311 | #ifdef CONFIG_ACPI |
| 312 | if (!(xen_start_info->flags & SIF_INITDOMAIN)) { |
| 313 | printk(KERN_INFO "ACPI in unprivileged domain disabled\n"); |
| 314 | disable_acpi(); |
| 315 | } |
| 316 | #endif |
| 317 | |
| 318 | memcpy(boot_command_line, xen_start_info->cmd_line, |
| 319 | MAX_GUEST_CMDLINE > COMMAND_LINE_SIZE ? |
| 320 | COMMAND_LINE_SIZE : MAX_GUEST_CMDLINE); |
| 321 | |
| 322 | pm_idle = xen_idle; |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 323 | |
Jeremy Fitzhardinge | dfdcdd4 | 2007-07-17 18:37:07 -0700 | [diff] [blame] | 324 | paravirt_disable_iospace(); |
Roland McGrath | d2eea68 | 2007-07-20 00:31:43 -0700 | [diff] [blame] | 325 | |
| 326 | fiddle_vdso(); |
Jeremy Fitzhardinge | 5ead97c | 2007-07-17 18:37:04 -0700 | [diff] [blame] | 327 | } |