ia64/xen-unstable

annotate xen/arch/x86/setup.c @ 8459:fe039c5fd127

Reset the stack pointer on every cpu early during bootstrap.
Ensures we do not overlap with the cpu_info structure.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 29 17:53:22 2005 +0100 (2005-12-29)
parents b54e981957eb
children 4299f983e8fe
rev   line source
kaf24@1452 1
kaf24@1452 2 #include <xen/config.h>
kaf24@1452 3 #include <xen/init.h>
kaf24@1452 4 #include <xen/lib.h>
kaf24@1452 5 #include <xen/sched.h>
cl349@5247 6 #include <xen/domain.h>
kaf24@1452 7 #include <xen/serial.h>
kaf24@1506 8 #include <xen/softirq.h>
kaf24@1452 9 #include <xen/acpi.h>
kaf24@3338 10 #include <xen/console.h>
iap10@4287 11 #include <xen/serial.h>
kaf24@3338 12 #include <xen/trace.h>
kaf24@3338 13 #include <xen/multiboot.h>
kaf24@5356 14 #include <xen/domain_page.h>
iap10@6721 15 #include <xen/compile.h>
iap10@6721 16 #include <public/version.h>
kaf24@1452 17 #include <asm/bitops.h>
kaf24@1452 18 #include <asm/smp.h>
kaf24@1452 19 #include <asm/processor.h>
kaf24@1452 20 #include <asm/mpspec.h>
kaf24@1452 21 #include <asm/apic.h>
kaf24@1452 22 #include <asm/desc.h>
kaf24@3338 23 #include <asm/shadow.h>
kaf24@3344 24 #include <asm/e820.h>
kaf24@5536 25 #include <acm/acm_hooks.h>
kaf24@3338 26
kaf24@5157 27 extern void dmi_scan_machine(void);
kaf24@5211 28 extern void generic_apic_probe(void);
kaf24@5157 29
kaf24@3338 30 /*
kaf24@3338 31 * opt_xenheap_megabytes: Size of Xen heap in megabytes, excluding the
kaf24@3338 32 * pfn_info table and allocation bitmap.
kaf24@3338 33 */
kaf24@3338 34 static unsigned int opt_xenheap_megabytes = XENHEAP_DEFAULT_MB;
kaf24@4950 35 #if defined(CONFIG_X86_64)
kaf24@3338 36 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
kaf24@3354 37 #endif
kaf24@1452 38
kaf24@5146 39 /* opt_nosmp: If true, secondary processors are ignored. */
kaf24@5900 40 static int opt_nosmp = 0;
kaf24@5146 41 boolean_param("nosmp", opt_nosmp);
kaf24@5146 42
kaf24@5146 43 /* maxcpus: maximum number of CPUs to activate. */
kaf24@5146 44 static unsigned int max_cpus = NR_CPUS;
kaf24@5146 45 integer_param("maxcpus", max_cpus);
kaf24@5146 46
kaf24@3334 47 /* opt_watchdog: If true, run a watchdog NMI on each processor. */
kaf24@3334 48 static int opt_watchdog = 0;
kaf24@3334 49 boolean_param("watchdog", opt_watchdog);
kaf24@3334 50
kaf24@4850 51 /* **** Linux config option: propagated to domain0. */
kaf24@4850 52 /* "acpi=off": Sisables both ACPI table parsing and interpreter. */
kaf24@4850 53 /* "acpi=force": Override the disable blacklist. */
kaf24@4850 54 /* "acpi=strict": Disables out-of-spec workarounds. */
kaf24@4850 55 /* "acpi=ht": Limit ACPI just to boot-time to enable HT. */
kaf24@4850 56 /* "acpi=noirq": Disables ACPI interrupt routing. */
kaf24@4850 57 static void parse_acpi_param(char *s);
kaf24@4850 58 custom_param("acpi", parse_acpi_param);
kaf24@4850 59
kaf24@4850 60 /* **** Linux config option: propagated to domain0. */
kaf24@4850 61 /* acpi_skip_timer_override: Skip IRQ0 overrides. */
kaf24@4850 62 extern int acpi_skip_timer_override;
kaf24@4850 63 boolean_param("acpi_skip_timer_override", acpi_skip_timer_override);
kaf24@4850 64
kaf24@4850 65 /* **** Linux config option: propagated to domain0. */
kaf24@4850 66 /* noapic: Disable IOAPIC setup. */
kaf24@4850 67 extern int skip_ioapic_setup;
kaf24@4850 68 boolean_param("noapic", skip_ioapic_setup);
kaf24@4850 69
kaf24@3594 70 int early_boot = 1;
kaf24@3594 71
kaf24@5146 72 cpumask_t cpu_present_map;
kaf24@5146 73
kaf24@5003 74 /* Limits of Xen heap, used to initialise the allocator. */
kaf24@5003 75 unsigned long xenheap_phys_start, xenheap_phys_end;
kaf24@3338 76
kaf24@2298 77 extern void arch_init_memory(void);
kaf24@1589 78 extern void init_IRQ(void);
kaf24@1589 79 extern void trap_init(void);
kaf24@5604 80 extern void early_time_init(void);
kaf24@5167 81 extern void initialize_keytable(void);
kaf24@5167 82 extern void early_cpu_init(void);
kaf24@1589 83
kaf24@5011 84 extern unsigned long cpu0_stack[];
kaf24@5011 85
kaf24@5214 86 struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
kaf24@1452 87
kaf24@5237 88 #if CONFIG_PAGING_LEVELS > 2
kaf24@1670 89 unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE;
kaf24@1670 90 #else
kaf24@5593 91 unsigned long mmu_cr4_features = X86_CR4_PSE;
kaf24@1670 92 #endif
kaf24@1452 93 EXPORT_SYMBOL(mmu_cr4_features);
kaf24@1452 94
kaf24@5289 95 struct vcpu *idle_task[NR_CPUS] = { &idle0_vcpu };
kaf24@1452 96
kaf24@4818 97 int acpi_disabled;
kaf24@1452 98
kaf24@4850 99 int acpi_force;
kaf24@4850 100 char acpi_param[10] = "";
kaf24@4850 101 static void parse_acpi_param(char *s)
kaf24@4850 102 {
kaf24@4850 103 /* Save the parameter so it can be propagated to domain0. */
kaf24@4850 104 strncpy(acpi_param, s, sizeof(acpi_param));
kaf24@4850 105 acpi_param[sizeof(acpi_param)-1] = '\0';
kaf24@4850 106
kaf24@4850 107 /* Interpret the parameter for use within Xen. */
kaf24@4850 108 if ( !strcmp(s, "off") )
kaf24@4850 109 {
kaf24@4850 110 disable_acpi();
kaf24@4850 111 }
kaf24@4850 112 else if ( !strcmp(s, "force") )
kaf24@4850 113 {
kaf24@4850 114 acpi_force = 1;
kaf24@4850 115 acpi_ht = 1;
kaf24@4850 116 acpi_disabled = 0;
kaf24@4850 117 }
kaf24@4850 118 else if ( !strcmp(s, "strict") )
kaf24@4850 119 {
kaf24@4850 120 acpi_strict = 1;
kaf24@4850 121 }
kaf24@4850 122 else if ( !strcmp(s, "ht") )
kaf24@4850 123 {
kaf24@4850 124 if ( !acpi_force )
kaf24@4850 125 disable_acpi();
kaf24@4850 126 acpi_ht = 1;
kaf24@4850 127 }
kaf24@4850 128 else if ( !strcmp(s, "noirq") )
kaf24@4850 129 {
kaf24@4850 130 acpi_noirq_set();
kaf24@4850 131 }
kaf24@4850 132 }
kaf24@4850 133
kaf24@1452 134 static void __init do_initcalls(void)
kaf24@1452 135 {
kaf24@1452 136 initcall_t *call;
kaf24@1452 137 for ( call = &__initcall_start; call < &__initcall_end; call++ )
kaf24@1452 138 (*call)();
kaf24@1452 139 }
kaf24@1452 140
kaf24@8459 141 #define EARLY_FAIL() for ( ; ; ) __asm__ __volatile__ ( "hlt" )
kaf24@8459 142
kaf24@8459 143 static struct e820entry e820_raw[E820MAX];
kaf24@8459 144
kaf24@8457 145 static multiboot_info_t *mbi;
kaf24@8457 146
kaf24@8457 147 void __init start_of_day(void)
kaf24@1452 148 {
kaf24@7462 149 unsigned long vgdt, gdt_pfn;
kaf24@8457 150 char *cmdline;
kaf24@8457 151 unsigned long _initrd_start = 0, _initrd_len = 0;
kaf24@8457 152 unsigned int initrdidx = 1;
kaf24@8457 153 module_t *mod = (module_t *)__va(mbi->mods_addr);
kaf24@6111 154 unsigned long nr_pages, modules_length;
kaf24@8459 155 unsigned long initial_images_start, initial_images_end;
kaf24@6111 156 physaddr_t s, e;
kaf24@8402 157 int i, e820_warn = 0, e820_raw_nr = 0, bytes = 0;
kaf24@5776 158 struct ns16550_defaults ns16550 = {
kaf24@5776 159 .data_bits = 8,
kaf24@5776 160 .parity = 'n',
kaf24@5776 161 .stop_bits = 1
kaf24@5776 162 };
kaf24@3338 163
kaf24@3338 164 /* Parse the command-line options. */
kaf24@3344 165 if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
kaf24@5211 166 cmdline_parse(__va(mbi->cmdline));
kaf24@3338 167
kaf24@3338 168 /* Must do this early -- e.g., spinlocks rely on get_current(). */
kaf24@5289 169 set_current(&idle0_vcpu);
kaf24@4986 170 set_processor_id(0);
kaf24@3338 171
kaf24@5146 172 smp_prepare_boot_cpu();
kaf24@5146 173
kaf24@3338 174 /* We initialise the serial devices very early so we can get debugging. */
kaf24@5776 175 ns16550.io_base = 0x3f8;
kaf24@5776 176 ns16550.irq = 4;
kaf24@5776 177 ns16550_init(0, &ns16550);
kaf24@5776 178 ns16550.io_base = 0x2f8;
kaf24@5776 179 ns16550.irq = 3;
kaf24@5776 180 ns16550_init(1, &ns16550);
kaf24@5195 181 serial_init_preirq();
kaf24@3338 182
kaf24@3338 183 init_console();
kaf24@3338 184
kaf24@3344 185 /* Check that we have at least one Multiboot module. */
kaf24@3344 186 if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
kaf24@3338 187 {
kaf24@5542 188 printk("FATAL ERROR: dom0 kernel not specified."
kaf24@5542 189 " Check bootloader configuration.\n");
kaf24@5011 190 EARLY_FAIL();
kaf24@5011 191 }
kaf24@5011 192
kaf24@5011 193 if ( ((unsigned long)cpu0_stack & (STACK_SIZE-1)) != 0 )
kaf24@5011 194 {
kaf24@5011 195 printk("FATAL ERROR: Misaligned CPU0 stack.\n");
kaf24@5011 196 EARLY_FAIL();
kaf24@3338 197 }
kaf24@3338 198
kaf24@3338 199 xenheap_phys_end = opt_xenheap_megabytes << 20;
kaf24@3338 200
kaf24@3344 201 if ( mbi->flags & MBI_MEMMAP )
kaf24@3344 202 {
kaf24@3344 203 while ( bytes < mbi->mmap_length )
kaf24@3344 204 {
kaf24@3344 205 memory_map_t *map = __va(mbi->mmap_addr + bytes);
kaf24@8402 206
kaf24@8402 207 /*
kaf24@8403 208 * This is a gross workaround for a BIOS bug. Some bootloaders do
kaf24@8402 209 * not write e820 map entries into pre-zeroed memory. This is
kaf24@8402 210 * okay if the BIOS fills in all fields of the map entry, but
kaf24@8402 211 * some broken BIOSes do not bother to write the high word of
kaf24@8402 212 * the length field if the length is smaller than 4GB. We
kaf24@8402 213 * detect and fix this by flagging sections below 4GB that
kaf24@8403 214 * appear to be larger than 4GB in size.
kaf24@8402 215 */
kaf24@8403 216 if ( (map->base_addr_high == 0) && (map->length_high != 0) )
kaf24@8402 217 {
kaf24@8402 218 e820_warn = 1;
kaf24@8402 219 map->length_high = 0;
kaf24@8402 220 }
kaf24@8402 221
kaf24@3344 222 e820_raw[e820_raw_nr].addr =
kaf24@3344 223 ((u64)map->base_addr_high << 32) | (u64)map->base_addr_low;
kaf24@3344 224 e820_raw[e820_raw_nr].size =
kaf24@3344 225 ((u64)map->length_high << 32) | (u64)map->length_low;
kaf24@3344 226 e820_raw[e820_raw_nr].type =
kaf24@3346 227 (map->type > E820_SHARED_PAGE) ? E820_RESERVED : map->type;
kaf24@3344 228 e820_raw_nr++;
kaf24@8402 229
kaf24@3344 230 bytes += map->size + 4;
kaf24@3344 231 }
kaf24@3344 232 }
kaf24@3344 233 else if ( mbi->flags & MBI_MEMLIMITS )
kaf24@3344 234 {
kaf24@3344 235 e820_raw[0].addr = 0;
kaf24@3344 236 e820_raw[0].size = mbi->mem_lower << 10;
kaf24@3344 237 e820_raw[0].type = E820_RAM;
kaf24@3354 238 e820_raw[1].addr = 0x100000;
kaf24@3354 239 e820_raw[1].size = mbi->mem_upper << 10;
kaf24@3354 240 e820_raw[1].type = E820_RAM;
kaf24@3344 241 e820_raw_nr = 2;
kaf24@3344 242 }
kaf24@3344 243 else
kaf24@3344 244 {
kaf24@3344 245 printk("FATAL ERROR: Bootloader provided no memory information.\n");
kaf24@3344 246 for ( ; ; ) ;
kaf24@3344 247 }
kaf24@3344 248
kaf24@8402 249 if ( e820_warn )
kaf24@8402 250 printk("WARNING: Buggy e820 map detected and fixed "
kaf24@8402 251 "(truncated length fields).\n");
kaf24@8402 252
kaf24@4950 253 max_page = init_e820(e820_raw, &e820_raw_nr);
kaf24@3338 254
kaf24@6111 255 modules_length = mod[mbi->mods_count-1].mod_end - mod[0].mod_start;
kaf24@3338 256
kaf24@6111 257 /* Find a large enough RAM extent to stash the DOM0 modules. */
kaf24@6111 258 for ( i = 0; ; i++ )
kaf24@3338 259 {
kaf24@6111 260 if ( i == e820.nr_map )
kaf24@6111 261 {
kaf24@6111 262 printk("Not enough memory to stash the DOM0 kernel image.\n");
kaf24@6111 263 for ( ; ; ) ;
kaf24@6111 264 }
kaf24@6134 265
kaf24@6134 266 if ( (e820.map[i].type == E820_RAM) &&
kaf24@6134 267 (e820.map[i].size >= modules_length) &&
kaf24@6134 268 ((e820.map[i].addr + e820.map[i].size) >=
kaf24@6134 269 (xenheap_phys_end + modules_length)) )
kaf24@6134 270 break;
kaf24@3338 271 }
kaf24@6111 272
kaf24@6134 273 /* Stash as near as possible to the beginning of the RAM extent. */
kaf24@6134 274 initial_images_start = e820.map[i].addr;
kaf24@6134 275 if ( initial_images_start < xenheap_phys_end )
kaf24@6134 276 initial_images_start = xenheap_phys_end;
kaf24@6134 277 initial_images_end = initial_images_start + modules_length;
kaf24@6134 278
kaf24@4950 279 #if defined(CONFIG_X86_32)
kaf24@3338 280 memmove((void *)initial_images_start, /* use low mapping */
kaf24@3338 281 (void *)mod[0].mod_start, /* use low mapping */
kaf24@3338 282 mod[mbi->mods_count-1].mod_end - mod[0].mod_start);
kaf24@4950 283 #elif defined(CONFIG_X86_64)
kaf24@3338 284 memmove(__va(initial_images_start),
kaf24@3338 285 __va(mod[0].mod_start),
kaf24@3338 286 mod[mbi->mods_count-1].mod_end - mod[0].mod_start);
kaf24@3338 287 #endif
kaf24@3338 288
kaf24@3354 289 /* Initialise boot-time allocator with all RAM situated after modules. */
kaf24@5003 290 xenheap_phys_start = init_boot_allocator(__pa(&_end));
kaf24@6111 291 nr_pages = 0;
kaf24@3354 292 for ( i = 0; i < e820.nr_map; i++ )
kaf24@3354 293 {
kaf24@3354 294 if ( e820.map[i].type != E820_RAM )
kaf24@3354 295 continue;
kaf24@6111 296
kaf24@3354 297 nr_pages += e820.map[i].size >> PAGE_SHIFT;
kaf24@6111 298
kaf24@6111 299 /* Initialise boot heap, skipping Xen heap and dom0 modules. */
kaf24@6111 300 s = e820.map[i].addr;
kaf24@6111 301 e = s + e820.map[i].size;
kaf24@6111 302 if ( s < xenheap_phys_end )
kaf24@6111 303 s = xenheap_phys_end;
kaf24@6111 304 if ( (s < initial_images_end) && (e > initial_images_start) )
kaf24@6111 305 s = initial_images_end;
kaf24@6111 306 init_boot_pages(s, e);
kaf24@6111 307
kaf24@5003 308 #if defined (CONFIG_X86_64)
kaf24@5003 309 /*
kaf24@5003 310 * x86/64 maps all registered RAM. Points to note:
kaf24@5003 311 * 1. The initial pagetable already maps low 64MB, so skip that.
kaf24@5003 312 * 2. We must map *only* RAM areas, taking care to avoid I/O holes.
kaf24@5003 313 * Failure to do this can cause coherency problems and deadlocks
kaf24@5003 314 * due to cache-attribute mismatches (e.g., AMD/AGP Linux bug).
kaf24@5003 315 */
kaf24@5003 316 {
kaf24@5004 317 /* Calculate page-frame range, discarding partial frames. */
kaf24@5004 318 unsigned long start, end;
kaf24@5005 319 start = PFN_UP(e820.map[i].addr);
kaf24@5005 320 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
kaf24@5004 321 /* Clip the range to above 64MB. */
kaf24@5004 322 if ( end < (64UL << (20-PAGE_SHIFT)) )
kaf24@5004 323 continue;
kaf24@5004 324 if ( start < (64UL << (20-PAGE_SHIFT)) )
kaf24@5004 325 start = 64UL << (20-PAGE_SHIFT);
kaf24@5004 326 /* Request the mapping. */
kaf24@5003 327 map_pages_to_xen(
kaf24@5004 328 PAGE_OFFSET + (start << PAGE_SHIFT),
kaf24@5004 329 start, end-start, PAGE_HYPERVISOR);
kaf24@5003 330 }
kaf24@5003 331 #endif
kaf24@3354 332 }
kaf24@3354 333
kaf24@5003 334 memguard_init();
kaf24@4950 335
kaf24@3354 336 printk("System RAM: %luMB (%lukB)\n",
kaf24@3354 337 nr_pages >> (20 - PAGE_SHIFT),
kaf24@3354 338 nr_pages << (PAGE_SHIFT - 10));
kaf24@7220 339 total_pages = nr_pages;
kaf24@3354 340
kaf24@7388 341 /* Sanity check for unwanted bloat of dom0_op_t structure. */
kaf24@7388 342 BUG_ON(sizeof(((dom0_op_t *)0)->u) != sizeof(((dom0_op_t *)0)->u.pad));
kaf24@7388 343
kaf24@7744 344 BUG_ON(sizeof(start_info_t) > PAGE_SIZE);
kaf24@7744 345 BUG_ON(sizeof(shared_info_t) > PAGE_SIZE);
kaf24@8108 346 BUG_ON(sizeof(vcpu_info_t) != 64);
kaf24@7744 347
kaf24@3354 348 init_frametable();
kaf24@3338 349
kaf24@3354 350 end_boot_allocator();
kaf24@3354 351
kaf24@6111 352 /* Initialise the Xen heap, skipping RAM holes. */
kaf24@6111 353 nr_pages = 0;
kaf24@6111 354 for ( i = 0; i < e820.nr_map; i++ )
kaf24@6111 355 {
kaf24@6111 356 if ( e820.map[i].type != E820_RAM )
kaf24@6111 357 continue;
kaf24@6111 358
kaf24@6111 359 s = e820.map[i].addr;
kaf24@6111 360 e = s + e820.map[i].size;
kaf24@6111 361 if ( s < xenheap_phys_start )
kaf24@6111 362 s = xenheap_phys_start;
kaf24@6111 363 if ( e > xenheap_phys_end )
kaf24@6111 364 e = xenheap_phys_end;
kaf24@6111 365
kaf24@6111 366 if ( s < e )
kaf24@6111 367 {
kaf24@6111 368 nr_pages += (e - s) >> PAGE_SHIFT;
kaf24@6111 369 init_xenheap_pages(s, e);
kaf24@6111 370 }
kaf24@6111 371 }
kaf24@6111 372
kaf24@6111 373 printk("Xen heap: %luMB (%lukB)\n",
kaf24@6111 374 nr_pages >> (20 - PAGE_SHIFT),
kaf24@6111 375 nr_pages << (PAGE_SHIFT - 10));
kaf24@3338 376
kaf24@3594 377 early_boot = 0;
kaf24@3338 378
kaf24@8459 379 early_cpu_init();
kaf24@8459 380
kaf24@8459 381 paging_init();
kaf24@8459 382
kaf24@8459 383 /* Unmap the first page of CPU0's stack. */
kaf24@8459 384 memguard_guard_stack(cpu0_stack);
kaf24@8459 385
kaf24@8459 386 open_softirq(NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ, new_tlbflush_clock_period);
kaf24@8459 387
kaf24@8459 388 if ( opt_watchdog )
kaf24@8459 389 nmi_watchdog = NMI_LOCAL_APIC;
kaf24@8459 390
kaf24@8459 391 sort_exception_tables();
kaf24@8459 392
kaf24@8459 393 arch_do_createdomain(current);
kaf24@8459 394
kaf24@8459 395 /*
kaf24@8459 396 * Map default GDT into its final positions in the idle page table. As
kaf24@8459 397 * noted in arch_do_createdomain(), we must map for every possible VCPU#.
kaf24@8459 398 */
kaf24@8459 399 vgdt = GDT_VIRT_START(current) + FIRST_RESERVED_GDT_BYTE;
kaf24@8459 400 gdt_pfn = virt_to_phys(gdt_table) >> PAGE_SHIFT;
kaf24@8459 401 for ( i = 0; i < MAX_VIRT_CPUS; i++ )
kaf24@8459 402 {
kaf24@8459 403 map_pages_to_xen(vgdt, gdt_pfn, 1, PAGE_HYPERVISOR);
kaf24@8459 404 vgdt += 1 << PDPT_VCPU_VA_SHIFT;
kaf24@8459 405 }
kaf24@8459 406
kaf24@8459 407 find_smp_config();
kaf24@8459 408
kaf24@8459 409 smp_alloc_memory();
kaf24@8459 410
kaf24@8459 411 dmi_scan_machine();
kaf24@8459 412
kaf24@8459 413 generic_apic_probe();
kaf24@8459 414
kaf24@8459 415 acpi_boot_table_init();
kaf24@8459 416 acpi_boot_init();
kaf24@8459 417
kaf24@8459 418 if ( smp_found_config )
kaf24@8459 419 get_smp_config();
kaf24@8459 420
kaf24@8459 421 init_apic_mappings();
kaf24@8459 422
kaf24@8459 423 init_IRQ();
kaf24@8459 424
kaf24@8459 425 trap_init();
kaf24@8459 426
kaf24@8459 427 ac_timer_init();
kaf24@8459 428
kaf24@8459 429 early_time_init();
kaf24@8459 430
kaf24@8459 431 arch_init_memory();
kaf24@8459 432
kaf24@8459 433 scheduler_init();
kaf24@8459 434
kaf24@8459 435 identify_cpu(&boot_cpu_data);
kaf24@8459 436 if ( cpu_has_fxsr )
kaf24@8459 437 set_in_cr4(X86_CR4_OSFXSR);
kaf24@8459 438 if ( cpu_has_xmm )
kaf24@8459 439 set_in_cr4(X86_CR4_OSXMMEXCPT);
kaf24@8459 440
kaf24@8459 441 if ( opt_nosmp )
kaf24@8459 442 {
kaf24@8459 443 max_cpus = 0;
kaf24@8459 444 smp_num_siblings = 1;
kaf24@8459 445 boot_cpu_data.x86_num_cores = 1;
kaf24@8459 446 }
kaf24@8459 447
kaf24@8459 448 smp_prepare_cpus(max_cpus);
kaf24@8459 449
kaf24@8459 450 /* We aren't hotplug-capable yet. */
kaf24@8459 451 BUG_ON(!cpus_empty(cpu_present_map));
kaf24@8459 452 for_each_cpu ( i )
kaf24@8459 453 cpu_set(i, cpu_present_map);
kaf24@8459 454
kaf24@8459 455 /*
kaf24@8459 456 * Initialise higher-level timer functions. We do this fairly late
kaf24@8459 457 * (post-SMP) because the time bases and scale factors need to be updated
kaf24@8459 458 * regularly, and SMP initialisation can cause a long delay with
kaf24@8459 459 * interrupts not yet enabled.
kaf24@8459 460 */
kaf24@8459 461 init_xen_time();
kaf24@8459 462
kaf24@8459 463 initialize_keytable();
kaf24@8459 464
kaf24@8459 465 serial_init_postirq();
kaf24@8459 466
kaf24@8459 467 BUG_ON(!local_irq_is_enabled());
kaf24@8459 468
kaf24@8459 469 for_each_present_cpu ( i )
kaf24@8459 470 {
kaf24@8459 471 if ( num_online_cpus() >= max_cpus )
kaf24@8459 472 break;
kaf24@8459 473 if ( !cpu_online(i) )
kaf24@8459 474 __cpu_up(i);
kaf24@8459 475 }
kaf24@8459 476
kaf24@8459 477 printk("Brought up %ld CPUs\n", (long)num_online_cpus());
kaf24@8459 478 smp_cpus_done(max_cpus);
kaf24@8459 479
kaf24@8459 480 do_initcalls();
kaf24@8459 481
kaf24@8459 482 schedulers_start();
kaf24@8459 483
kaf24@8459 484 watchdog_enable();
kaf24@8459 485
kaf24@8459 486 shadow_mode_init();
kaf24@8459 487
kaf24@8459 488 /* initialize access control security module */
kaf24@8459 489 acm_init(&initrdidx, mbi, initial_images_start);
kaf24@8459 490
kaf24@8459 491 /* Create initial domain 0. */
kaf24@8459 492 dom0 = do_createdomain(0, 0);
kaf24@8459 493 if ( dom0 == NULL )
kaf24@8459 494 panic("Error creating domain 0\n");
kaf24@8459 495
kaf24@8459 496 set_bit(_DOMF_privileged, &dom0->domain_flags);
kaf24@8459 497 /* post-create hooks sets security label */
kaf24@8459 498 acm_post_domain0_create(dom0->domain_id);
kaf24@8459 499
kaf24@8459 500 /* Grab the DOM0 command line. */
kaf24@8459 501 cmdline = (char *)(mod[0].string ? __va(mod[0].string) : NULL);
kaf24@8459 502 if ( cmdline != NULL )
kaf24@8459 503 {
kaf24@8459 504 static char dom0_cmdline[MAX_GUEST_CMDLINE];
kaf24@8459 505
kaf24@8459 506 /* Skip past the image name and copy to a local buffer. */
kaf24@8459 507 while ( *cmdline == ' ' ) cmdline++;
kaf24@8459 508 if ( (cmdline = strchr(cmdline, ' ')) != NULL )
kaf24@8459 509 {
kaf24@8459 510 while ( *cmdline == ' ' ) cmdline++;
kaf24@8459 511 strcpy(dom0_cmdline, cmdline);
kaf24@8459 512 }
kaf24@8459 513
kaf24@8459 514 cmdline = dom0_cmdline;
kaf24@8459 515
kaf24@8459 516 /* Append any extra parameters. */
kaf24@8459 517 if ( skip_ioapic_setup && !strstr(cmdline, "noapic") )
kaf24@8459 518 strcat(cmdline, " noapic");
kaf24@8459 519 if ( acpi_skip_timer_override &&
kaf24@8459 520 !strstr(cmdline, "acpi_skip_timer_override") )
kaf24@8459 521 strcat(cmdline, " acpi_skip_timer_override");
kaf24@8459 522 if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") )
kaf24@8459 523 {
kaf24@8459 524 strcat(cmdline, " acpi=");
kaf24@8459 525 strcat(cmdline, acpi_param);
kaf24@8459 526 }
kaf24@8459 527 }
kaf24@8459 528
kaf24@8459 529 if ( (initrdidx > 0) && (initrdidx < mbi->mods_count) )
kaf24@8459 530 {
kaf24@8459 531 _initrd_start = initial_images_start +
kaf24@8459 532 (mod[initrdidx].mod_start - mod[0].mod_start);
kaf24@8459 533 _initrd_len = mod[initrdidx].mod_end - mod[initrdidx].mod_start;
kaf24@8459 534 }
kaf24@8459 535
kaf24@8459 536 /*
kaf24@8459 537 * We're going to setup domain0 using the module(s) that we stashed safely
kaf24@8459 538 * above our heap. The second module, if present, is an initrd ramdisk.
kaf24@8459 539 */
kaf24@8459 540 if ( construct_dom0(dom0,
kaf24@8459 541 initial_images_start,
kaf24@8459 542 mod[0].mod_end-mod[0].mod_start,
kaf24@8459 543 _initrd_start,
kaf24@8459 544 _initrd_len,
kaf24@8459 545 cmdline) != 0)
kaf24@8459 546 panic("Could not set up DOM0 guest OS\n");
kaf24@8459 547
kaf24@8459 548 /* Scrub RAM that is still free and so may go to an unprivileged domain. */
kaf24@8459 549 scrub_heap_pages();
kaf24@8459 550
kaf24@8459 551 init_trace_bufs();
kaf24@8459 552
kaf24@8459 553 /* Give up the VGA console if DOM0 is configured to grab it. */
kaf24@8459 554 console_endboot(cmdline && strstr(cmdline, "tty0"));
kaf24@8459 555
kaf24@8459 556 /* Hide UART from DOM0 if we're using it */
kaf24@8459 557 serial_endboot();
kaf24@8459 558
kaf24@8459 559 domain_unpause_by_systemcontroller(dom0);
kaf24@8459 560
kaf24@8459 561 startup_cpu_idle_loop();
kaf24@8459 562 }
kaf24@8459 563
kaf24@8459 564 void __init __start_xen(multiboot_info_t *__mbi)
kaf24@8459 565 {
kaf24@8459 566 mbi = __mbi;
kaf24@8457 567 reset_stack_and_jump(start_of_day);
kaf24@3338 568 }
kaf24@3914 569
kaf24@6725 570 void arch_get_xen_caps(xen_capabilities_info_t info)
iap10@6721 571 {
kaf24@6725 572 char *p = info;
iap10@6721 573
kaf24@6725 574 #if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
kaf24@6725 575
smh22@7709 576 p += sprintf(p, "xen-%d.%d-x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 577 if ( hvm_enabled )
smh22@7709 578 p += sprintf(p, "hvm-%d.%d-x86_32 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 579
kaf24@6725 580 #elif defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
kaf24@6725 581
smh22@7709 582 p += sprintf(p, "xen-%d.%d-x86_32p ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 583 if ( hvm_enabled )
iap10@6721 584 {
smh22@7709 585 //p += sprintf(p, "hvm-%d.%d-x86_32 ", XEN_VERSION, XEN_SUBVERSION);
smh22@7709 586 //p += sprintf(p, "hvm-%d.%d-x86_32p ", XEN_VERSION, XEN_SUBVERSION);
iap10@6721 587 }
iap10@6721 588
kaf24@6725 589 #elif defined(CONFIG_X86_64)
iap10@6721 590
smh22@7709 591 p += sprintf(p, "xen-%d.%d-x86_64 ", XEN_VERSION, XEN_SUBVERSION);
kaf24@6725 592 if ( hvm_enabled )
iap10@6721 593 {
kaf24@8246 594 p += sprintf(p, "hvm-%d.%d-x86_32 ", XEN_VERSION, XEN_SUBVERSION);
smh22@7709 595 //p += sprintf(p, "hvm-%d.%d-x86_32p ", XEN_VERSION, XEN_SUBVERSION);
smh22@7709 596 p += sprintf(p, "hvm-%d.%d-x86_64 ", XEN_VERSION, XEN_SUBVERSION);
iap10@6721 597 }
kaf24@6725 598
kaf24@6725 599 #else
kaf24@6725 600
kaf24@6725 601 p++;
kaf24@6725 602
iap10@6721 603 #endif
kaf24@8246 604
kaf24@6725 605 *(p-1) = 0;
iap10@6721 606
shand@6734 607 BUG_ON((p - info) > sizeof(xen_capabilities_info_t));
iap10@6721 608 }
iap10@6721 609
kaf24@3914 610 /*
kaf24@3914 611 * Local variables:
kaf24@3914 612 * mode: C
kaf24@3914 613 * c-set-style: "BSD"
kaf24@3914 614 * c-basic-offset: 4
kaf24@3914 615 * tab-width: 4
kaf24@3914 616 * indent-tabs-mode: nil
kaf24@3988 617 * End:
kaf24@3914 618 */