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/block-backend.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 pci_enabled = true; 63 static bool has_acpi_build = true; 64 static bool rsdp_in_ram = true; 65 static int legacy_acpi_table_size; 66 static bool smbios_defaults = true; 67 static bool smbios_legacy_mode; 68 static bool smbios_uuid_encoded = true; 69 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to 70 * host addresses aligned at 1Gbyte boundaries. This way we can use 1GByte 71 * pages in the host. 72 */ 73 static bool gigabyte_align = true; 74 static bool has_reserved_memory = true; 75 static bool kvmclock_enabled = true; 76 77 /* PC hardware initialisation */ 78 static void pc_init1(MachineState *machine) 79 { 80 PCMachineState *pc_machine = PC_MACHINE(machine); 81 MemoryRegion *system_memory = get_system_memory(); 82 MemoryRegion *system_io = get_system_io(); 83 int i; 84 ram_addr_t below_4g_mem_size, above_4g_mem_size; 85 PCIBus *pci_bus; 86 ISABus *isa_bus; 87 PCII440FXState *i440fx_state; 88 int piix3_devfn = -1; 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 PcGuestInfo *guest_info; 102 ram_addr_t lowmem; 103 104 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory). 105 * If it doesn't, we need to split it in chunks below and above 4G. 106 * In any case, try to make sure that guest addresses aligned at 107 * 1G boundaries get mapped to host addresses aligned at 1G boundaries. 108 * For old machine types, use whatever split we used historically to avoid 109 * breaking migration. 110 */ 111 if (machine->ram_size >= 0xe0000000) { 112 lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000; 113 } else { 114 lowmem = 0xe0000000; 115 } 116 117 /* Handle the machine opt max-ram-below-4g. It is basically doing 118 * min(qemu limit, user limit). 119 */ 120 if (lowmem > pc_machine->max_ram_below_4g) { 121 lowmem = pc_machine->max_ram_below_4g; 122 if (machine->ram_size - lowmem > lowmem && 123 lowmem & ((1ULL << 30) - 1)) { 124 error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64 125 ") not a multiple of 1G; possible bad performance.", 126 pc_machine->max_ram_below_4g); 127 } 128 } 129 130 if (machine->ram_size >= lowmem) { 131 above_4g_mem_size = machine->ram_size - lowmem; 132 below_4g_mem_size = lowmem; 133 } else { 134 above_4g_mem_size = 0; 135 below_4g_mem_size = machine->ram_size; 136 } 137 138 if (xen_enabled() && xen_hvm_init(&below_4g_mem_size, &above_4g_mem_size, 139 &ram_memory) != 0) { 140 fprintf(stderr, "xen hardware virtual machine initialisation failed\n"); 141 exit(1); 142 } 143 144 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE); 145 object_property_add_child(qdev_get_machine(), "icc-bridge", 146 OBJECT(icc_bridge), NULL); 147 148 pc_cpus_init(machine->cpu_model, icc_bridge); 149 150 if (kvm_enabled() && kvmclock_enabled) { 151 kvmclock_create(); 152 } 153 154 if (pci_enabled) { 155 pci_memory = g_new(MemoryRegion, 1); 156 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); 157 rom_memory = pci_memory; 158 } else { 159 pci_memory = NULL; 160 rom_memory = system_memory; 161 } 162 163 guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size); 164 165 guest_info->has_acpi_build = has_acpi_build; 166 guest_info->legacy_acpi_table_size = legacy_acpi_table_size; 167 168 guest_info->isapc_ram_fw = !pci_enabled; 169 guest_info->has_reserved_memory = has_reserved_memory; 170 guest_info->rsdp_in_ram = rsdp_in_ram; 171 172 if (smbios_defaults) { 173 MachineClass *mc = MACHINE_GET_CLASS(machine); 174 /* These values are guest ABI, do not change */ 175 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)", 176 mc->name, smbios_legacy_mode, smbios_uuid_encoded); 177 } 178 179 /* allocate ram and load rom/bios */ 180 if (!xen_enabled()) { 181 pc_memory_init(machine, system_memory, 182 below_4g_mem_size, above_4g_mem_size, 183 rom_memory, &ram_memory, guest_info); 184 } else if (machine->kernel_filename != NULL) { 185 /* For xen HVM direct kernel boot, load linux here */ 186 xen_load_linux(machine->kernel_filename, 187 machine->kernel_cmdline, 188 machine->initrd_filename, 189 below_4g_mem_size, 190 guest_info); 191 } 192 193 gsi_state = g_malloc0(sizeof(*gsi_state)); 194 if (kvm_irqchip_in_kernel()) { 195 kvm_pc_setup_irq_routing(pci_enabled); 196 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, 197 GSI_NUM_PINS); 198 } else { 199 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); 200 } 201 202 if (pci_enabled) { 203 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi, 204 system_memory, system_io, machine->ram_size, 205 below_4g_mem_size, 206 above_4g_mem_size, 207 pci_memory, ram_memory); 208 } else { 209 pci_bus = NULL; 210 i440fx_state = NULL; 211 isa_bus = isa_bus_new(NULL, get_system_memory(), system_io); 212 no_hpet = 1; 213 } 214 isa_bus_irqs(isa_bus, gsi); 215 216 if (kvm_irqchip_in_kernel()) { 217 i8259 = kvm_i8259_init(isa_bus); 218 } else if (xen_enabled()) { 219 i8259 = xen_interrupt_controller_init(); 220 } else { 221 i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq()); 222 } 223 224 for (i = 0; i < ISA_NUM_IRQS; i++) { 225 gsi_state->i8259_irq[i] = i8259[i]; 226 } 227 g_free(i8259); 228 if (pci_enabled) { 229 ioapic_init_gsi(gsi_state, "i440fx"); 230 } 231 qdev_init_nofail(icc_bridge); 232 233 pc_register_ferr_irq(gsi[13]); 234 235 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL); 236 237 assert(pc_machine->vmport != ON_OFF_AUTO_MAX); 238 if (pc_machine->vmport == ON_OFF_AUTO_AUTO) { 239 pc_machine->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; 240 } 241 242 /* init basic PC hardware */ 243 pc_basic_device_init(isa_bus, gsi, &rtc_state, true, &floppy, 244 (pc_machine->vmport != ON_OFF_AUTO_ON), 0x4); 245 246 pc_nic_init(isa_bus, pci_bus); 247 248 ide_drive_get(hd, ARRAY_SIZE(hd)); 249 if (pci_enabled) { 250 PCIDevice *dev; 251 if (xen_enabled()) { 252 dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); 253 } else { 254 dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); 255 } 256 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); 257 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); 258 } else { 259 for(i = 0; i < MAX_IDE_BUS; i++) { 260 ISADevice *dev; 261 char busname[] = "ide.0"; 262 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], 263 ide_irq[i], 264 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); 265 /* 266 * The ide bus name is ide.0 for the first bus and ide.1 for the 267 * second one. 268 */ 269 busname[4] = '0' + i; 270 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); 271 } 272 } 273 274 pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order, 275 machine, floppy, idebus[0], idebus[1], rtc_state); 276 277 if (pci_enabled && usb_enabled()) { 278 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); 279 } 280 281 if (pci_enabled && acpi_enabled) { 282 DeviceState *piix4_pm; 283 I2CBus *smbus; 284 285 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); 286 /* TODO: Populate SPD eeprom data. */ 287 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, 288 gsi[9], smi_irq, 289 kvm_enabled(), &piix4_pm); 290 smbus_eeprom_init(smbus, 8, NULL, 0); 291 292 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 293 TYPE_HOTPLUG_HANDLER, 294 (Object **)&pc_machine->acpi_dev, 295 object_property_allow_set_link, 296 OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort); 297 object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), 298 PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); 299 } 300 301 if (pci_enabled) { 302 pc_pci_device_init(pci_bus); 303 } 304 } 305 306 static void pc_compat_2_3(MachineState *machine) 307 { 308 } 309 310 static void pc_compat_2_2(MachineState *machine) 311 { 312 pc_compat_2_3(machine); 313 rsdp_in_ram = false; 314 x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME); 315 x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME); 316 x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME); 317 x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME); 318 x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME); 319 x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME); 320 x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME); 321 x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME); 322 x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME); 323 x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME); 324 x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME); 325 x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME); 326 x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME); 327 x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME); 328 x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C); 329 x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND); 330 x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C); 331 x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND); 332 machine->suppress_vmdesc = true; 333 } 334 335 static void pc_compat_2_1(MachineState *machine) 336 { 337 PCMachineState *pcms = PC_MACHINE(machine); 338 339 pc_compat_2_2(machine); 340 smbios_uuid_encoded = false; 341 x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0); 342 x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0); 343 x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM); 344 pcms->enforce_aligned_dimm = false; 345 } 346 347 static void pc_compat_2_0(MachineState *machine) 348 { 349 pc_compat_2_1(machine); 350 /* This value depends on the actual DSDT and SSDT compiled into 351 * the source QEMU; unfortunately it depends on the binary and 352 * not on the machine type, so we cannot make pc-i440fx-1.7 work on 353 * both QEMU 1.7 and QEMU 2.0. 354 * 355 * Large variations cause migration to fail for more than one 356 * consecutive value of the "-smp" maxcpus option. 357 * 358 * For small variations of the kind caused by different iasl versions, 359 * the 4k rounding usually leaves slack. However, there could be still 360 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the 361 * slack is only ~10 bytes before one "-smp maxcpus" value breaks! 362 * 363 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on 364 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. 365 */ 366 legacy_acpi_table_size = 6652; 367 smbios_legacy_mode = true; 368 has_reserved_memory = false; 369 pc_set_legacy_acpi_data_size(); 370 } 371 372 static void pc_compat_1_7(MachineState *machine) 373 { 374 pc_compat_2_0(machine); 375 smbios_defaults = false; 376 gigabyte_align = false; 377 option_rom_has_mr = true; 378 legacy_acpi_table_size = 6414; 379 x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC); 380 } 381 382 static void pc_compat_1_6(MachineState *machine) 383 { 384 pc_compat_1_7(machine); 385 rom_file_has_mr = false; 386 has_acpi_build = false; 387 } 388 389 static void pc_compat_1_5(MachineState *machine) 390 { 391 pc_compat_1_6(machine); 392 } 393 394 static void pc_compat_1_4(MachineState *machine) 395 { 396 pc_compat_1_5(machine); 397 x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE); 398 x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); 399 } 400 401 static void pc_compat_1_3(MachineState *machine) 402 { 403 pc_compat_1_4(machine); 404 enable_compat_apic_id_mode(); 405 } 406 407 /* PC compat function for pc-0.14 to pc-1.2 */ 408 static void pc_compat_1_2(MachineState *machine) 409 { 410 pc_compat_1_3(machine); 411 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI); 412 } 413 414 /* PC compat function for pc-0.10 to pc-0.13 */ 415 static void pc_compat_0_13(MachineState *machine) 416 { 417 pc_compat_1_2(machine); 418 kvmclock_enabled = false; 419 } 420 421 static void pc_init_isa(MachineState *machine) 422 { 423 pci_enabled = false; 424 has_acpi_build = false; 425 smbios_defaults = false; 426 gigabyte_align = false; 427 smbios_legacy_mode = true; 428 has_reserved_memory = false; 429 option_rom_has_mr = true; 430 rom_file_has_mr = false; 431 if (!machine->cpu_model) { 432 machine->cpu_model = "486"; 433 } 434 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI); 435 enable_compat_apic_id_mode(); 436 pc_init1(machine); 437 } 438 439 #ifdef CONFIG_XEN 440 static void pc_xen_hvm_init(MachineState *machine) 441 { 442 PCIBus *bus; 443 444 pc_init1(machine); 445 446 bus = pci_find_primary_bus(); 447 if (bus != NULL) { 448 pci_create_simple(bus, -1, "xen-platform"); 449 } 450 } 451 #endif 452 453 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ 454 static void pc_init_##suffix(MachineState *machine) \ 455 { \ 456 void (*compat)(MachineState *m) = (compatfn); \ 457 if (compat) { \ 458 compat(machine); \ 459 } \ 460 pc_init1(machine); \ 461 } \ 462 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) 463 464 static void pc_i440fx_machine_options(MachineClass *m) 465 { 466 pc_default_machine_options(m); 467 m->family = "pc_piix"; 468 m->desc = "Standard PC (i440FX + PIIX, 1996)"; 469 m->hot_add_cpu = pc_hot_add_cpu; 470 } 471 472 static void pc_i440fx_2_4_machine_options(MachineClass *m) 473 { 474 pc_i440fx_machine_options(m); 475 m->default_machine_opts = "firmware=bios-256k.bin"; 476 m->default_display = "std"; 477 m->alias = "pc"; 478 m->is_default = 1; 479 } 480 481 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, 482 pc_i440fx_2_4_machine_options) 483 484 485 static void pc_i440fx_2_3_machine_options(MachineClass *m) 486 { 487 pc_i440fx_machine_options(m); 488 m->alias = NULL; 489 m->is_default = 0; 490 SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); 491 } 492 493 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, 494 pc_i440fx_2_3_machine_options); 495 496 497 static void pc_i440fx_2_2_machine_options(MachineClass *m) 498 { 499 pc_i440fx_2_3_machine_options(m); 500 SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); 501 } 502 503 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, 504 pc_i440fx_2_2_machine_options); 505 506 507 static void pc_i440fx_2_1_machine_options(MachineClass *m) 508 { 509 pc_i440fx_2_2_machine_options(m); 510 m->default_display = NULL; 511 SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); 512 } 513 514 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, 515 pc_i440fx_2_1_machine_options); 516 517 518 519 static void pc_i440fx_2_0_machine_options(MachineClass *m) 520 { 521 pc_i440fx_2_1_machine_options(m); 522 SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); 523 } 524 525 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, 526 pc_i440fx_2_0_machine_options); 527 528 529 static void pc_i440fx_1_7_machine_options(MachineClass *m) 530 { 531 pc_i440fx_2_0_machine_options(m); 532 m->default_machine_opts = NULL; 533 SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); 534 } 535 536 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, 537 pc_i440fx_1_7_machine_options); 538 539 540 static void pc_i440fx_1_6_machine_options(MachineClass *m) 541 { 542 pc_i440fx_1_7_machine_options(m); 543 SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); 544 } 545 546 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, 547 pc_i440fx_1_6_machine_options); 548 549 550 static void pc_i440fx_1_5_machine_options(MachineClass *m) 551 { 552 pc_i440fx_1_6_machine_options(m); 553 SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); 554 } 555 556 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, 557 pc_i440fx_1_5_machine_options); 558 559 560 static void pc_i440fx_1_4_machine_options(MachineClass *m) 561 { 562 pc_i440fx_1_5_machine_options(m); 563 m->hot_add_cpu = NULL; 564 SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); 565 } 566 567 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, 568 pc_i440fx_1_4_machine_options); 569 570 571 #define PC_COMPAT_1_3 \ 572 PC_COMPAT_1_4 \ 573 {\ 574 .driver = "usb-tablet",\ 575 .property = "usb_version",\ 576 .value = stringify(1),\ 577 },{\ 578 .driver = "virtio-net-pci",\ 579 .property = "ctrl_mac_addr",\ 580 .value = "off", \ 581 },{ \ 582 .driver = "virtio-net-pci", \ 583 .property = "mq", \ 584 .value = "off", \ 585 }, {\ 586 .driver = "e1000",\ 587 .property = "autonegotiation",\ 588 .value = "off",\ 589 }, 590 591 592 static void pc_i440fx_1_3_machine_options(MachineClass *m) 593 { 594 pc_i440fx_1_4_machine_options(m); 595 SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); 596 } 597 598 DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, 599 pc_i440fx_1_3_machine_options); 600 601 602 #define PC_COMPAT_1_2 \ 603 PC_COMPAT_1_3 \ 604 {\ 605 .driver = "nec-usb-xhci",\ 606 .property = "msi",\ 607 .value = "off",\ 608 },{\ 609 .driver = "nec-usb-xhci",\ 610 .property = "msix",\ 611 .value = "off",\ 612 },{\ 613 .driver = "ivshmem",\ 614 .property = "use64",\ 615 .value = "0",\ 616 },{\ 617 .driver = "qxl",\ 618 .property = "revision",\ 619 .value = stringify(3),\ 620 },{\ 621 .driver = "qxl-vga",\ 622 .property = "revision",\ 623 .value = stringify(3),\ 624 },{\ 625 .driver = "VGA",\ 626 .property = "mmio",\ 627 .value = "off",\ 628 }, 629 630 static void pc_i440fx_1_2_machine_options(MachineClass *m) 631 { 632 pc_i440fx_1_3_machine_options(m); 633 SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); 634 } 635 636 DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, 637 pc_i440fx_1_2_machine_options); 638 639 640 #define PC_COMPAT_1_1 \ 641 PC_COMPAT_1_2 \ 642 {\ 643 .driver = "virtio-scsi-pci",\ 644 .property = "hotplug",\ 645 .value = "off",\ 646 },{\ 647 .driver = "virtio-scsi-pci",\ 648 .property = "param_change",\ 649 .value = "off",\ 650 },{\ 651 .driver = "VGA",\ 652 .property = "vgamem_mb",\ 653 .value = stringify(8),\ 654 },{\ 655 .driver = "vmware-svga",\ 656 .property = "vgamem_mb",\ 657 .value = stringify(8),\ 658 },{\ 659 .driver = "qxl-vga",\ 660 .property = "vgamem_mb",\ 661 .value = stringify(8),\ 662 },{\ 663 .driver = "qxl",\ 664 .property = "vgamem_mb",\ 665 .value = stringify(8),\ 666 },{\ 667 .driver = "virtio-blk-pci",\ 668 .property = "config-wce",\ 669 .value = "off",\ 670 }, 671 672 static void pc_i440fx_1_1_machine_options(MachineClass *m) 673 { 674 pc_i440fx_1_2_machine_options(m); 675 SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); 676 } 677 678 DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, 679 pc_i440fx_1_1_machine_options); 680 681 682 #define PC_COMPAT_1_0 \ 683 PC_COMPAT_1_1 \ 684 {\ 685 .driver = TYPE_ISA_FDC,\ 686 .property = "check_media_rate",\ 687 .value = "off",\ 688 }, {\ 689 .driver = "virtio-balloon-pci",\ 690 .property = "class",\ 691 .value = stringify(PCI_CLASS_MEMORY_RAM),\ 692 },{\ 693 .driver = "apic-common",\ 694 .property = "vapic",\ 695 .value = "off",\ 696 },{\ 697 .driver = TYPE_USB_DEVICE,\ 698 .property = "full-path",\ 699 .value = "no",\ 700 }, 701 702 static void pc_i440fx_1_0_machine_options(MachineClass *m) 703 { 704 pc_i440fx_1_1_machine_options(m); 705 m->hw_version = "1.0"; 706 SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); 707 } 708 709 DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, 710 pc_i440fx_1_0_machine_options); 711 712 713 #define PC_COMPAT_0_15 \ 714 PC_COMPAT_1_0 715 716 static void pc_i440fx_0_15_machine_options(MachineClass *m) 717 { 718 pc_i440fx_1_0_machine_options(m); 719 m->hw_version = "0.15"; 720 SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); 721 } 722 723 DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, 724 pc_i440fx_0_15_machine_options); 725 726 727 #define PC_COMPAT_0_14 \ 728 PC_COMPAT_0_15 \ 729 {\ 730 .driver = "virtio-blk-pci",\ 731 .property = "event_idx",\ 732 .value = "off",\ 733 },{\ 734 .driver = "virtio-serial-pci",\ 735 .property = "event_idx",\ 736 .value = "off",\ 737 },{\ 738 .driver = "virtio-net-pci",\ 739 .property = "event_idx",\ 740 .value = "off",\ 741 },{\ 742 .driver = "virtio-balloon-pci",\ 743 .property = "event_idx",\ 744 .value = "off",\ 745 },{\ 746 .driver = "qxl",\ 747 .property = "revision",\ 748 .value = stringify(2),\ 749 },{\ 750 .driver = "qxl-vga",\ 751 .property = "revision",\ 752 .value = stringify(2),\ 753 }, 754 755 static void pc_i440fx_0_14_machine_options(MachineClass *m) 756 { 757 pc_i440fx_0_15_machine_options(m); 758 m->hw_version = "0.14"; 759 SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); 760 } 761 762 DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, 763 pc_i440fx_0_14_machine_options); 764 765 766 #define PC_COMPAT_0_13 \ 767 PC_COMPAT_0_14 \ 768 {\ 769 .driver = TYPE_PCI_DEVICE,\ 770 .property = "command_serr_enable",\ 771 .value = "off",\ 772 },{\ 773 .driver = "AC97",\ 774 .property = "use_broken_id",\ 775 .value = stringify(1),\ 776 },{\ 777 .driver = "virtio-9p-pci",\ 778 .property = "vectors",\ 779 .value = stringify(0),\ 780 },{\ 781 .driver = "VGA",\ 782 .property = "rombar",\ 783 .value = stringify(0),\ 784 },{\ 785 .driver = "vmware-svga",\ 786 .property = "rombar",\ 787 .value = stringify(0),\ 788 }, 789 790 static void pc_i440fx_0_13_machine_options(MachineClass *m) 791 { 792 pc_i440fx_0_14_machine_options(m); 793 m->hw_version = "0.13"; 794 SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); 795 } 796 797 DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, 798 pc_i440fx_0_13_machine_options); 799 800 801 #define PC_COMPAT_0_12 \ 802 PC_COMPAT_0_13 \ 803 {\ 804 .driver = "virtio-serial-pci",\ 805 .property = "max_ports",\ 806 .value = stringify(1),\ 807 },{\ 808 .driver = "virtio-serial-pci",\ 809 .property = "vectors",\ 810 .value = stringify(0),\ 811 },{\ 812 .driver = "usb-mouse",\ 813 .property = "serial",\ 814 .value = "1",\ 815 },{\ 816 .driver = "usb-tablet",\ 817 .property = "serial",\ 818 .value = "1",\ 819 },{\ 820 .driver = "usb-kbd",\ 821 .property = "serial",\ 822 .value = "1",\ 823 }, 824 825 static void pc_i440fx_0_12_machine_options(MachineClass *m) 826 { 827 pc_i440fx_0_13_machine_options(m); 828 m->hw_version = "0.12"; 829 SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); 830 } 831 832 DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, 833 pc_i440fx_0_12_machine_options); 834 835 836 #define PC_COMPAT_0_11 \ 837 PC_COMPAT_0_12 \ 838 {\ 839 .driver = "virtio-blk-pci",\ 840 .property = "vectors",\ 841 .value = stringify(0),\ 842 },{\ 843 .driver = TYPE_PCI_DEVICE,\ 844 .property = "rombar",\ 845 .value = stringify(0),\ 846 },{\ 847 .driver = "ide-drive",\ 848 .property = "ver",\ 849 .value = "0.11",\ 850 },{\ 851 .driver = "scsi-disk",\ 852 .property = "ver",\ 853 .value = "0.11",\ 854 }, 855 856 static void pc_i440fx_0_11_machine_options(MachineClass *m) 857 { 858 pc_i440fx_0_12_machine_options(m); 859 m->hw_version = "0.11"; 860 SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); 861 } 862 863 DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, 864 pc_i440fx_0_11_machine_options); 865 866 867 #define PC_COMPAT_0_10 \ 868 PC_COMPAT_0_11 \ 869 {\ 870 .driver = "virtio-blk-pci",\ 871 .property = "class",\ 872 .value = stringify(PCI_CLASS_STORAGE_OTHER),\ 873 },{\ 874 .driver = "virtio-serial-pci",\ 875 .property = "class",\ 876 .value = stringify(PCI_CLASS_DISPLAY_OTHER),\ 877 },{\ 878 .driver = "virtio-net-pci",\ 879 .property = "vectors",\ 880 .value = stringify(0),\ 881 },{\ 882 .driver = "ide-drive",\ 883 .property = "ver",\ 884 .value = "0.10",\ 885 },{\ 886 .driver = "scsi-disk",\ 887 .property = "ver",\ 888 .value = "0.10",\ 889 }, 890 891 static void pc_i440fx_0_10_machine_options(MachineClass *m) 892 { 893 pc_i440fx_0_11_machine_options(m); 894 m->hw_version = "0.10"; 895 SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); 896 } 897 898 DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, 899 pc_i440fx_0_10_machine_options); 900 901 902 static void isapc_machine_options(MachineClass *m) 903 { 904 pc_common_machine_options(m); 905 m->desc = "ISA-only PC"; 906 m->max_cpus = 1; 907 } 908 909 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, 910 isapc_machine_options); 911 912 913 #ifdef CONFIG_XEN 914 static void xenfv_machine_options(MachineClass *m) 915 { 916 pc_common_machine_options(m); 917 m->desc = "Xen Fully-virtualized PC"; 918 m->max_cpus = HVM_MAX_VCPUS; 919 m->default_machine_opts = "accel=xen"; 920 m->hot_add_cpu = pc_hot_add_cpu; 921 } 922 923 DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, 924 xenfv_machine_options); 925 #endif 926