1 /* 2 * QEMU PC System Emulator 3 * 4 * Copyright (c) 2003-2004 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #include <glib.h> 26 27 #include "hw/hw.h" 28 #include "hw/loader.h" 29 #include "hw/i386/pc.h" 30 #include "hw/i386/apic.h" 31 #include "hw/i386/smbios.h" 32 #include "hw/pci/pci.h" 33 #include "hw/pci/pci_ids.h" 34 #include "hw/usb.h" 35 #include "net/net.h" 36 #include "hw/boards.h" 37 #include "hw/ide.h" 38 #include "sysemu/kvm.h" 39 #include "hw/kvm/clock.h" 40 #include "sysemu/sysemu.h" 41 #include "hw/sysbus.h" 42 #include "hw/cpu/icc_bus.h" 43 #include "sysemu/arch_init.h" 44 #include "sysemu/blockdev.h" 45 #include "hw/i2c/smbus.h" 46 #include "hw/xen/xen.h" 47 #include "exec/memory.h" 48 #include "exec/address-spaces.h" 49 #include "hw/acpi/acpi.h" 50 #include "cpu.h" 51 #include "qemu/error-report.h" 52 #ifdef CONFIG_XEN 53 # include <xen/hvm/hvm_info_table.h> 54 #endif 55 56 #define MAX_IDE_BUS 2 57 58 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; 59 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; 60 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; 61 62 static bool has_pci_info; 63 static bool has_acpi_build = true; 64 static int legacy_acpi_table_size; 65 static bool smbios_defaults = true; 66 static bool smbios_legacy_mode; 67 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to 68 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte 69 * pages in the host. 70 */ 71 static bool gigabyte_align = true; 72 static bool has_reserved_memory = true; 73 74 /* PC hardware initialisation */ 75 static void pc_init1(MachineState *machine, 76 int pci_enabled, 77 int kvmclock_enabled) 78 { 79 PCMachineState *pc_machine = PC_MACHINE(machine); 80 MemoryRegion *system_memory = get_system_memory(); 81 MemoryRegion *system_io = get_system_io(); 82 int i; 83 ram_addr_t below_4g_mem_size, above_4g_mem_size; 84 PCIBus *pci_bus; 85 ISABus *isa_bus; 86 PCII440FXState *i440fx_state; 87 int piix3_devfn = -1; 88 qemu_irq *cpu_irq; 89 qemu_irq *gsi; 90 qemu_irq *i8259; 91 qemu_irq *smi_irq; 92 GSIState *gsi_state; 93 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; 94 BusState *idebus[MAX_IDE_BUS]; 95 ISADevice *rtc_state; 96 ISADevice *floppy; 97 MemoryRegion *ram_memory; 98 MemoryRegion *pci_memory; 99 MemoryRegion *rom_memory; 100 DeviceState *icc_bridge; 101 FWCfgState *fw_cfg = NULL; 102 PcGuestInfo *guest_info; 103 ram_addr_t lowmem; 104 105 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory). 106 * If it doesn't, we need to split it in chunks below and above 4G. 107 * In any case, try to make sure that guest addresses aligned at 108 * 1G boundaries get mapped to host addresses aligned at 1G boundaries. 109 * For old machine types, use whatever split we used historically to avoid 110 * breaking migration. 111 */ 112 if (machine->ram_size >= 0xe0000000) { 113 lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000; 114 } else { 115 lowmem = 0xe0000000; 116 } 117 118 /* Handle the machine opt max-ram-below-4g. It is basically doing 119 * min(qemu limit, user limit). 120 */ 121 if (lowmem > pc_machine->max_ram_below_4g) { 122 lowmem = pc_machine->max_ram_below_4g; 123 if (machine->ram_size - lowmem > lowmem && 124 lowmem & ((1ULL << 30) - 1)) { 125 error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64 126 ") not a multiple of 1G; possible bad performance.", 127 pc_machine->max_ram_below_4g); 128 } 129 } 130 131 if (machine->ram_size >= lowmem) { 132 above_4g_mem_size = machine->ram_size - lowmem; 133 below_4g_mem_size = lowmem; 134 } else { 135 above_4g_mem_size = 0; 136 below_4g_mem_size = machine->ram_size; 137 } 138 139 if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size, 140 &ram_memory) != 0) { 141 fprintf(stderr, "xen hardware virtual machine initialisation failed\n"); 142 exit(1); 143 } 144 145 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE); 146 object_property_add_child(qdev_get_machine(), "icc-bridge", 147 OBJECT(icc_bridge), NULL); 148 149 pc_cpus_init(machine->cpu_model, icc_bridge); 150 151 if (kvm_enabled() && kvmclock_enabled) { 152 kvmclock_create(); 153 } 154 155 if (pci_enabled) { 156 pci_memory = g_new(MemoryRegion, 1); 157 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); 158 rom_memory = pci_memory; 159 } else { 160 pci_memory = NULL; 161 rom_memory = system_memory; 162 } 163 164 guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size); 165 166 guest_info->has_acpi_build = has_acpi_build; 167 guest_info->legacy_acpi_table_size = legacy_acpi_table_size; 168 169 guest_info->has_pci_info = has_pci_info; 170 guest_info->isapc_ram_fw = !pci_enabled; 171 guest_info->has_reserved_memory = has_reserved_memory; 172 173 if (smbios_defaults) { 174 MachineClass *mc = MACHINE_GET_CLASS(machine); 175 /* These values are guest ABI, do not change */ 176 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", 177 mc->name, smbios_legacy_mode); 178 } 179 180 /* allocate ram and load rom/bios */ 181 if (!xen_enabled()) { 182 fw_cfg = pc_memory_init(machine, system_memory, 183 below_4g_mem_size, above_4g_mem_size, 184 rom_memory, &ram_memory, guest_info); 185 } else if (machine->kernel_filename != NULL) { 186 /* For xen HVM direct kernel boot, load linux here */ 187 fw_cfg = xen_load_linux(machine->kernel_filename, 188 machine->kernel_cmdline, 189 machine->initrd_filename, 190 below_4g_mem_size, 191 guest_info); 192 } 193 194 gsi_state = g_malloc0(sizeof(*gsi_state)); 195 if (kvm_irqchip_in_kernel()) { 196 kvm_pc_setup_irq_routing(pci_enabled); 197 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, 198 GSI_NUM_PINS); 199 } else { 200 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); 201 } 202 203 if (pci_enabled) { 204 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, 205 system_memory, system_io, machine->ram_size, 206 below_4g_mem_size, 207 above_4g_mem_size, 208 pci_memory, ram_memory); 209 } else { 210 pci_bus = NULL; 211 i440fx_state = NULL; 212 isa_bus = isa_bus_new(NULL, system_io); 213 no_hpet = 1; 214 } 215 isa_bus_irqs(isa_bus, gsi); 216 217 if (kvm_irqchip_in_kernel()) { 218 i8259 = kvm_i8259_init(isa_bus); 219 } else if (xen_enabled()) { 220 i8259 = xen_interrupt_controller_init(); 221 } else { 222 cpu_irq = pc_allocate_cpu_irq(); 223 i8259 = i8259_init(isa_bus, cpu_irq[0]); 224 } 225 226 for (i = 0; i < ISA_NUM_IRQS; i++) { 227 gsi_state->i8259_irq[i] = i8259[i]; 228 } 229 if (pci_enabled) { 230 ioapic_init_gsi(gsi_state, "i440fx"); 231 } 232 qdev_init_nofail(icc_bridge); 233 234 pc_register_ferr_irq(gsi[13]); 235 236 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); 237 238 /* init basic PC hardware */ 239 pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(), 240 0x4); 241 242 pc_nic_init(isa_bus, pci_bus); 243 244 ide_drive_get(hd, MAX_IDE_BUS); 245 if (pci_enabled) { 246 PCIDevice *dev; 247 if (xen_enabled()) { 248 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); 249 } else { 250 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); 251 } 252 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); 253 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); 254 } else { 255 for(i = 0; i < MAX_IDE_BUS; i++) { 256 ISADevice *dev; 257 char busname[] = "ide.0"; 258 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], 259 ide_irq[i], 260 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); 261 /* 262 * The ide bus name is ide.0 for the first bus and ide.1 for the 263 * second one. 264 */ 265 busname[4] = '0' + i; 266 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); 267 } 268 } 269 270 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order, 271 floppy, idebus[0], idebus[1], rtc_state); 272 273 if (pci_enabled && usb_enabled(false)) { 274 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); 275 } 276 277 if (pci_enabled && acpi_enabled) { 278 DeviceState *piix4_pm; 279 I2CBus *smbus; 280 281 smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1); 282 /* TODO: Populate SPD eeprom data. */ 283 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, 284 gsi[9], *smi_irq, 285 kvm_enabled(), fw_cfg, &piix4_pm); 286 smbus_eeprom_init(smbus, 8, NULL, 0); 287 288 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 289 TYPE_HOTPLUG_HANDLER, 290 (Object **)&pc_machine->acpi_dev, 291 object_property_allow_set_link, 292 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); 293 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), 294 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); 295 } 296 297 if (pci_enabled) { 298 pc_pci_device_init(pci_bus); 299 } 300 } 301 302 static void pc_init_pci(MachineState *machine) 303 { 304 pc_init1(machine, 1, 1); 305 } 306 307 static void pc_compat_2_0(MachineState *machine) 308 { 309 /* This value depends on the actual DSDT and SSDT compiled into 310 * the source QEMU; unfortunately it depends on the binary and 311 * not on the machine type, so we cannot make pc-i440fx-1.7 work on 312 * both QEMU 1.7 and QEMU 2.0. 313 * 314 * Large variations cause migration to fail for more than one 315 * consecutive value of the "-smp" maxcpus option. 316 * 317 * For small variations of the kind caused by different iasl versions, 318 * the 4k rounding usually leaves slack. However, there could be still 319 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the 320 * slack is only ~10 bytes before one "-smp maxcpus" value breaks! 321 * 322 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on 323 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. 324 */ 325 legacy_acpi_table_size = 6652; 326 smbios_legacy_mode = true; 327 has_reserved_memory = false; 328 } 329 330 static void pc_compat_1_7(MachineState *machine) 331 { 332 pc_compat_2_0(machine); 333 smbios_defaults = false; 334 gigabyte_align = false; 335 option_rom_has_mr = true; 336 legacy_acpi_table_size = 6414; 337 x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC); 338 } 339 340 static void pc_compat_1_6(MachineState *machine) 341 { 342 pc_compat_1_7(machine); 343 has_pci_info = false; 344 rom_file_has_mr = false; 345 has_acpi_build = false; 346 } 347 348 static void pc_compat_1_5(MachineState *machine) 349 { 350 pc_compat_1_6(machine); 351 } 352 353 static void pc_compat_1_4(MachineState *machine) 354 { 355 pc_compat_1_5(machine); 356 x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); 357 x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); 358 } 359 360 static void pc_compat_1_3(MachineState *machine) 361 { 362 pc_compat_1_4(machine); 363 enable_compat_apic_id_mode(); 364 } 365 366 /* PC compat function for pc-0.14 to pc-1.2 */ 367 static void pc_compat_1_2(MachineState *machine) 368 { 369 pc_compat_1_3(machine); 370 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); 371 } 372 373 static void pc_init_pci_2_0(MachineState *machine) 374 { 375 pc_compat_2_0(machine); 376 pc_init_pci(machine); 377 } 378 379 static void pc_init_pci_1_7(MachineState *machine) 380 { 381 pc_compat_1_7(machine); 382 pc_init_pci(machine); 383 } 384 385 static void pc_init_pci_1_6(MachineState *machine) 386 { 387 pc_compat_1_6(machine); 388 pc_init_pci(machine); 389 } 390 391 static void pc_init_pci_1_5(MachineState *machine) 392 { 393 pc_compat_1_5(machine); 394 pc_init_pci(machine); 395 } 396 397 static void pc_init_pci_1_4(MachineState *machine) 398 { 399 pc_compat_1_4(machine); 400 pc_init_pci(machine); 401 } 402 403 static void pc_init_pci_1_3(MachineState *machine) 404 { 405 pc_compat_1_3(machine); 406 pc_init_pci(machine); 407 } 408 409 /* PC machine init function for pc-0.14 to pc-1.2 */ 410 static void pc_init_pci_1_2(MachineState *machine) 411 { 412 pc_compat_1_2(machine); 413 pc_init_pci(machine); 414 } 415 416 /* PC init function for pc-0.10 to pc-0.13 */ 417 static void pc_init_pci_no_kvmclock(MachineState *machine) 418 { 419 pc_compat_1_2(machine); 420 pc_init1(machine, 1, 0); 421 } 422 423 static void pc_init_isa(MachineState *machine) 424 { 425 has_pci_info = false; 426 has_acpi_build = false; 427 smbios_defaults = false; 428 gigabyte_align = false; 429 smbios_legacy_mode = true; 430 has_reserved_memory = false; 431 option_rom_has_mr = true; 432 rom_file_has_mr = false; 433 if (!machine->cpu_model) { 434 machine->cpu_model = "486"; 435 } 436 x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI); 437 enable_compat_apic_id_mode(); 438 pc_init1(machine, 0, 1); 439 } 440 441 #ifdef CONFIG_XEN 442 static void pc_xen_hvm_init(MachineState *machine) 443 { 444 PCIBus *bus; 445 446 pc_init_pci(machine); 447 448 bus = pci_find_primary_bus(); 449 if (bus != NULL) { 450 pci_create_simple(bus, -1, "xen-platform"); 451 } 452 } 453 #endif 454 455 #define PC_I440FX_MACHINE_OPTIONS \ 456 PC_DEFAULT_MACHINE_OPTIONS, \ 457 .desc = "Standard PC (i440FX + PIIX, 1996)", \ 458 .hot_add_cpu = pc_hot_add_cpu 459 460 #define PC_I440FX_2_1_MACHINE_OPTIONS \ 461 PC_I440FX_MACHINE_OPTIONS, \ 462 .default_machine_opts = "firmware=bios-256k.bin" 463 464 static QEMUMachine pc_i440fx_machine_v2_1 = { 465 PC_I440FX_2_1_MACHINE_OPTIONS, 466 .name = "pc-i440fx-2.1", 467 .alias = "pc", 468 .init = pc_init_pci, 469 .is_default = 1, 470 }; 471 472 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS 473 474 static QEMUMachine pc_i440fx_machine_v2_0 = { 475 PC_I440FX_2_0_MACHINE_OPTIONS, 476 .name = "pc-i440fx-2.0", 477 .init = pc_init_pci_2_0, 478 .compat_props = (GlobalProperty[]) { 479 PC_COMPAT_2_0, 480 { /* end of list */ } 481 }, 482 }; 483 484 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS 485 486 static QEMUMachine pc_i440fx_machine_v1_7 = { 487 PC_I440FX_1_7_MACHINE_OPTIONS, 488 .name = "pc-i440fx-1.7", 489 .init = pc_init_pci_1_7, 490 .compat_props = (GlobalProperty[]) { 491 PC_COMPAT_1_7, 492 { /* end of list */ } 493 }, 494 }; 495 496 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS 497 498 static QEMUMachine pc_i440fx_machine_v1_6 = { 499 PC_I440FX_1_6_MACHINE_OPTIONS, 500 .name = "pc-i440fx-1.6", 501 .init = pc_init_pci_1_6, 502 .compat_props = (GlobalProperty[]) { 503 PC_COMPAT_1_6, 504 { /* end of list */ } 505 }, 506 }; 507 508 static QEMUMachine pc_i440fx_machine_v1_5 = { 509 PC_I440FX_1_6_MACHINE_OPTIONS, 510 .name = "pc-i440fx-1.5", 511 .init = pc_init_pci_1_5, 512 .compat_props = (GlobalProperty[]) { 513 PC_COMPAT_1_5, 514 { /* end of list */ } 515 }, 516 }; 517 518 #define PC_I440FX_1_4_MACHINE_OPTIONS \ 519 PC_I440FX_1_6_MACHINE_OPTIONS, \ 520 .hot_add_cpu = NULL 521 522 static QEMUMachine pc_i440fx_machine_v1_4 = { 523 PC_I440FX_1_4_MACHINE_OPTIONS, 524 .name = "pc-i440fx-1.4", 525 .init = pc_init_pci_1_4, 526 .compat_props = (GlobalProperty[]) { 527 PC_COMPAT_1_4, 528 { /* end of list */ } 529 }, 530 }; 531 532 #define PC_COMPAT_1_3 \ 533 PC_COMPAT_1_4, \ 534 {\ 535 .driver = "usb-tablet",\ 536 .property = "usb_version",\ 537 .value = stringify(1),\ 538 },{\ 539 .driver = "virtio-net-pci",\ 540 .property = "ctrl_mac_addr",\ 541 .value = "off", \ 542 },{ \ 543 .driver = "virtio-net-pci", \ 544 .property = "mq", \ 545 .value = "off", \ 546 }, {\ 547 .driver = "e1000",\ 548 .property = "autonegotiation",\ 549 .value = "off",\ 550 } 551 552 static QEMUMachine pc_machine_v1_3 = { 553 PC_I440FX_1_4_MACHINE_OPTIONS, 554 .name = "pc-1.3", 555 .init = pc_init_pci_1_3, 556 .compat_props = (GlobalProperty[]) { 557 PC_COMPAT_1_3, 558 { /* end of list */ } 559 }, 560 }; 561 562 #define PC_COMPAT_1_2 \ 563 PC_COMPAT_1_3,\ 564 {\ 565 .driver = "nec-usb-xhci",\ 566 .property = "msi",\ 567 .value = "off",\ 568 },{\ 569 .driver = "nec-usb-xhci",\ 570 .property = "msix",\ 571 .value = "off",\ 572 },{\ 573 .driver = "ivshmem",\ 574 .property = "use64",\ 575 .value = "0",\ 576 },{\ 577 .driver = "qxl",\ 578 .property = "revision",\ 579 .value = stringify(3),\ 580 },{\ 581 .driver = "qxl-vga",\ 582 .property = "revision",\ 583 .value = stringify(3),\ 584 },{\ 585 .driver = "VGA",\ 586 .property = "mmio",\ 587 .value = "off",\ 588 } 589 590 #define PC_I440FX_1_2_MACHINE_OPTIONS \ 591 PC_I440FX_1_4_MACHINE_OPTIONS, \ 592 .init = pc_init_pci_1_2 593 594 static QEMUMachine pc_machine_v1_2 = { 595 PC_I440FX_1_2_MACHINE_OPTIONS, 596 .name = "pc-1.2", 597 .compat_props = (GlobalProperty[]) { 598 PC_COMPAT_1_2, 599 { /* end of list */ } 600 }, 601 }; 602 603 #define PC_COMPAT_1_1 \ 604 PC_COMPAT_1_2,\ 605 {\ 606 .driver = "virtio-scsi-pci",\ 607 .property = "hotplug",\ 608 .value = "off",\ 609 },{\ 610 .driver = "virtio-scsi-pci",\ 611 .property = "param_change",\ 612 .value = "off",\ 613 },{\ 614 .driver = "VGA",\ 615 .property = "vgamem_mb",\ 616 .value = stringify(8),\ 617 },{\ 618 .driver = "vmware-svga",\ 619 .property = "vgamem_mb",\ 620 .value = stringify(8),\ 621 },{\ 622 .driver = "qxl-vga",\ 623 .property = "vgamem_mb",\ 624 .value = stringify(8),\ 625 },{\ 626 .driver = "qxl",\ 627 .property = "vgamem_mb",\ 628 .value = stringify(8),\ 629 },{\ 630 .driver = "virtio-blk-pci",\ 631 .property = "config-wce",\ 632 .value = "off",\ 633 } 634 635 static QEMUMachine pc_machine_v1_1 = { 636 PC_I440FX_1_2_MACHINE_OPTIONS, 637 .name = "pc-1.1", 638 .compat_props = (GlobalProperty[]) { 639 PC_COMPAT_1_1, 640 { /* end of list */ } 641 }, 642 }; 643 644 #define PC_COMPAT_1_0 \ 645 PC_COMPAT_1_1,\ 646 {\ 647 .driver = TYPE_ISA_FDC,\ 648 .property = "check_media_rate",\ 649 .value = "off",\ 650 }, {\ 651 .driver = "virtio-balloon-pci",\ 652 .property = "class",\ 653 .value = stringify(PCI_CLASS_MEMORY_RAM),\ 654 },{\ 655 .driver = "apic",\ 656 .property = "vapic",\ 657 .value = "off",\ 658 },{\ 659 .driver = TYPE_USB_DEVICE,\ 660 .property = "full-path",\ 661 .value = "no",\ 662 } 663 664 static QEMUMachine pc_machine_v1_0 = { 665 PC_I440FX_1_2_MACHINE_OPTIONS, 666 .name = "pc-1.0", 667 .compat_props = (GlobalProperty[]) { 668 PC_COMPAT_1_0, 669 { /* end of list */ } 670 }, 671 .hw_version = "1.0", 672 }; 673 674 #define PC_COMPAT_0_15 \ 675 PC_COMPAT_1_0 676 677 static QEMUMachine pc_machine_v0_15 = { 678 PC_I440FX_1_2_MACHINE_OPTIONS, 679 .name = "pc-0.15", 680 .compat_props = (GlobalProperty[]) { 681 PC_COMPAT_0_15, 682 { /* end of list */ } 683 }, 684 .hw_version = "0.15", 685 }; 686 687 #define PC_COMPAT_0_14 \ 688 PC_COMPAT_0_15,\ 689 {\ 690 .driver = "virtio-blk-pci",\ 691 .property = "event_idx",\ 692 .value = "off",\ 693 },{\ 694 .driver = "virtio-serial-pci",\ 695 .property = "event_idx",\ 696 .value = "off",\ 697 },{\ 698 .driver = "virtio-net-pci",\ 699 .property = "event_idx",\ 700 .value = "off",\ 701 },{\ 702 .driver = "virtio-balloon-pci",\ 703 .property = "event_idx",\ 704 .value = "off",\ 705 } 706 707 static QEMUMachine pc_machine_v0_14 = { 708 PC_I440FX_1_2_MACHINE_OPTIONS, 709 .name = "pc-0.14", 710 .compat_props = (GlobalProperty[]) { 711 PC_COMPAT_0_14, 712 { 713 .driver = "qxl", 714 .property = "revision", 715 .value = stringify(2), 716 },{ 717 .driver = "qxl-vga", 718 .property = "revision", 719 .value = stringify(2), 720 }, 721 { /* end of list */ } 722 }, 723 .hw_version = "0.14", 724 }; 725 726 #define PC_COMPAT_0_13 \ 727 PC_COMPAT_0_14,\ 728 {\ 729 .driver = TYPE_PCI_DEVICE,\ 730 .property = "command_serr_enable",\ 731 .value = "off",\ 732 },{\ 733 .driver = "AC97",\ 734 .property = "use_broken_id",\ 735 .value = stringify(1),\ 736 } 737 738 #define PC_I440FX_0_13_MACHINE_OPTIONS \ 739 PC_I440FX_1_2_MACHINE_OPTIONS, \ 740 .init = pc_init_pci_no_kvmclock 741 742 static QEMUMachine pc_machine_v0_13 = { 743 PC_I440FX_0_13_MACHINE_OPTIONS, 744 .name = "pc-0.13", 745 .compat_props = (GlobalProperty[]) { 746 PC_COMPAT_0_13, 747 { 748 .driver = "virtio-9p-pci", 749 .property = "vectors", 750 .value = stringify(0), 751 },{ 752 .driver = "VGA", 753 .property = "rombar", 754 .value = stringify(0), 755 },{ 756 .driver = "vmware-svga", 757 .property = "rombar", 758 .value = stringify(0), 759 }, 760 { /* end of list */ } 761 }, 762 .hw_version = "0.13", 763 }; 764 765 #define PC_COMPAT_0_12 \ 766 PC_COMPAT_0_13,\ 767 {\ 768 .driver = "virtio-serial-pci",\ 769 .property = "max_ports",\ 770 .value = stringify(1),\ 771 },{\ 772 .driver = "virtio-serial-pci",\ 773 .property = "vectors",\ 774 .value = stringify(0),\ 775 },{\ 776 .driver = "usb-mouse",\ 777 .property = "serial",\ 778 .value = "1",\ 779 },{\ 780 .driver = "usb-tablet",\ 781 .property = "serial",\ 782 .value = "1",\ 783 },{\ 784 .driver = "usb-kbd",\ 785 .property = "serial",\ 786 .value = "1",\ 787 } 788 789 static QEMUMachine pc_machine_v0_12 = { 790 PC_I440FX_0_13_MACHINE_OPTIONS, 791 .name = "pc-0.12", 792 .compat_props = (GlobalProperty[]) { 793 PC_COMPAT_0_12, 794 { 795 .driver = "VGA", 796 .property = "rombar", 797 .value = stringify(0), 798 },{ 799 .driver = "vmware-svga", 800 .property = "rombar", 801 .value = stringify(0), 802 }, 803 { /* end of list */ } 804 }, 805 .hw_version = "0.12", 806 }; 807 808 #define PC_COMPAT_0_11 \ 809 PC_COMPAT_0_12,\ 810 {\ 811 .driver = "virtio-blk-pci",\ 812 .property = "vectors",\ 813 .value = stringify(0),\ 814 },{\ 815 .driver = TYPE_PCI_DEVICE,\ 816 .property = "rombar",\ 817 .value = stringify(0),\ 818 } 819 820 static QEMUMachine pc_machine_v0_11 = { 821 PC_I440FX_0_13_MACHINE_OPTIONS, 822 .name = "pc-0.11", 823 .compat_props = (GlobalProperty[]) { 824 PC_COMPAT_0_11, 825 { 826 .driver = "ide-drive", 827 .property = "ver", 828 .value = "0.11", 829 },{ 830 .driver = "scsi-disk", 831 .property = "ver", 832 .value = "0.11", 833 }, 834 { /* end of list */ } 835 }, 836 .hw_version = "0.11", 837 }; 838 839 static QEMUMachine pc_machine_v0_10 = { 840 PC_I440FX_0_13_MACHINE_OPTIONS, 841 .name = "pc-0.10", 842 .compat_props = (GlobalProperty[]) { 843 PC_COMPAT_0_11, 844 { 845 .driver = "virtio-blk-pci", 846 .property = "class", 847 .value = stringify(PCI_CLASS_STORAGE_OTHER), 848 },{ 849 .driver = "virtio-serial-pci", 850 .property = "class", 851 .value = stringify(PCI_CLASS_DISPLAY_OTHER), 852 },{ 853 .driver = "virtio-net-pci", 854 .property = "vectors", 855 .value = stringify(0), 856 },{ 857 .driver = "ide-drive", 858 .property = "ver", 859 .value = "0.10", 860 },{ 861 .driver = "scsi-disk", 862 .property = "ver", 863 .value = "0.10", 864 }, 865 { /* end of list */ } 866 }, 867 .hw_version = "0.10", 868 }; 869 870 static QEMUMachine isapc_machine = { 871 PC_COMMON_MACHINE_OPTIONS, 872 .name = "isapc", 873 .desc = "ISA-only PC", 874 .init = pc_init_isa, 875 .max_cpus = 1, 876 .compat_props = (GlobalProperty[]) { 877 { /* end of list */ } 878 }, 879 }; 880 881 #ifdef CONFIG_XEN 882 static QEMUMachine xenfv_machine = { 883 PC_COMMON_MACHINE_OPTIONS, 884 .name = "xenfv", 885 .desc = "Xen Fully-virtualized PC", 886 .init = pc_xen_hvm_init, 887 .max_cpus = HVM_MAX_VCPUS, 888 .default_machine_opts = "accel=xen", 889 .hot_add_cpu = pc_hot_add_cpu, 890 .compat_props = (GlobalProperty[]) { 891 /* xenfv has no fwcfg and so does not load acpi from QEMU. 892 * as such new acpi features don't work. 893 */ 894 { 895 .driver = "PIIX4_PM", 896 .property = "acpi-pci-hotplug-with-bridge-support", 897 .value = "off", 898 }, 899 { /* end of list */ } 900 }, 901 }; 902 #endif 903 904 static void pc_machine_init(void) 905 { 906 qemu_register_pc_machine(&pc_i440fx_machine_v2_1); 907 qemu_register_pc_machine(&pc_i440fx_machine_v2_0); 908 qemu_register_pc_machine(&pc_i440fx_machine_v1_7); 909 qemu_register_pc_machine(&pc_i440fx_machine_v1_6); 910 qemu_register_pc_machine(&pc_i440fx_machine_v1_5); 911 qemu_register_pc_machine(&pc_i440fx_machine_v1_4); 912 qemu_register_pc_machine(&pc_machine_v1_3); 913 qemu_register_pc_machine(&pc_machine_v1_2); 914 qemu_register_pc_machine(&pc_machine_v1_1); 915 qemu_register_pc_machine(&pc_machine_v1_0); 916 qemu_register_pc_machine(&pc_machine_v0_15); 917 qemu_register_pc_machine(&pc_machine_v0_14); 918 qemu_register_pc_machine(&pc_machine_v0_13); 919 qemu_register_pc_machine(&pc_machine_v0_12); 920 qemu_register_pc_machine(&pc_machine_v0_11); 921 qemu_register_pc_machine(&pc_machine_v0_10); 922 qemu_register_pc_machine(&isapc_machine); 923 #ifdef CONFIG_XEN 924 qemu_register_pc_machine(&xenfv_machine); 925 #endif 926 } 927 928 machine_init(pc_machine_init); 929