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 "qemu/osdep.h" 26 #include CONFIG_DEVICES 27 28 #include "qemu/units.h" 29 #include "hw/char/parallel-isa.h" 30 #include "hw/dma/i8257.h" 31 #include "hw/loader.h" 32 #include "hw/i386/x86.h" 33 #include "hw/i386/pc.h" 34 #include "hw/i386/apic.h" 35 #include "hw/pci-host/i440fx.h" 36 #include "hw/rtc/mc146818rtc.h" 37 #include "hw/southbridge/piix.h" 38 #include "hw/display/ramfb.h" 39 #include "hw/firmware/smbios.h" 40 #include "hw/pci/pci.h" 41 #include "hw/pci/pci_ids.h" 42 #include "hw/usb.h" 43 #include "net/net.h" 44 #include "hw/ide/isa.h" 45 #include "hw/ide/pci.h" 46 #include "hw/irq.h" 47 #include "sysemu/kvm.h" 48 #include "hw/i386/kvm/clock.h" 49 #include "hw/sysbus.h" 50 #include "hw/i2c/smbus_eeprom.h" 51 #include "exec/memory.h" 52 #include "hw/acpi/acpi.h" 53 #include "qapi/error.h" 54 #include "qemu/error-report.h" 55 #include "sysemu/xen.h" 56 #ifdef CONFIG_XEN 57 #include <xen/hvm/hvm_info_table.h> 58 #include "hw/xen/xen_pt.h" 59 #endif 60 #include "hw/xen/xen-x86.h" 61 #include "hw/xen/xen.h" 62 #include "migration/global_state.h" 63 #include "migration/misc.h" 64 #include "sysemu/numa.h" 65 #include "hw/hyperv/vmbus-bridge.h" 66 #include "hw/mem/nvdimm.h" 67 #include "hw/i386/acpi-build.h" 68 #include "kvm/kvm-cpu.h" 69 #include "target/i386/cpu.h" 70 71 #define MAX_IDE_BUS 2 72 #define XEN_IOAPIC_NUM_PIRQS 128ULL 73 74 #ifdef CONFIG_IDE_ISA 75 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; 76 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; 77 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; 78 #endif 79 80 /* 81 * Return the global irq number corresponding to a given device irq 82 * pin. We could also use the bus number to have a more precise mapping. 83 */ 84 static int pc_pci_slot_get_pirq(PCIDevice *pci_dev, int pci_intx) 85 { 86 int slot_addend; 87 slot_addend = PCI_SLOT(pci_dev->devfn) - 1; 88 return (pci_intx + slot_addend) & 3; 89 } 90 91 static void piix_intx_routing_notifier_xen(PCIDevice *dev) 92 { 93 int i; 94 95 /* Scan for updates to PCI link routes. */ 96 for (i = 0; i < PIIX_NUM_PIRQS; i++) { 97 const PCIINTxRoute route = pci_device_route_intx_to_irq(dev, i); 98 const uint8_t v = route.mode == PCI_INTX_ENABLED ? route.irq : 0; 99 xen_set_pci_link_route(i, v); 100 } 101 } 102 103 /* PC hardware initialisation */ 104 static void pc_init1(MachineState *machine, 105 const char *host_type, const char *pci_type) 106 { 107 PCMachineState *pcms = PC_MACHINE(machine); 108 PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); 109 X86MachineState *x86ms = X86_MACHINE(machine); 110 MemoryRegion *system_memory = get_system_memory(); 111 MemoryRegion *system_io = get_system_io(); 112 PCIBus *pci_bus = NULL; 113 ISABus *isa_bus; 114 Object *piix4_pm = NULL; 115 qemu_irq smi_irq; 116 GSIState *gsi_state; 117 BusState *idebus[MAX_IDE_BUS]; 118 ISADevice *rtc_state; 119 MemoryRegion *ram_memory; 120 MemoryRegion *pci_memory = NULL; 121 MemoryRegion *rom_memory = system_memory; 122 ram_addr_t lowmem; 123 uint64_t hole64_size = 0; 124 125 /* 126 * Calculate ram split, for memory below and above 4G. It's a bit 127 * complicated for backward compatibility reasons ... 128 * 129 * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the 130 * default value for max_ram_below_4g now. 131 * 132 * - Then, to gigabyte align the memory, we move the split to 3G 133 * (lowmem = 0xc0000000). But only in case we have to split in 134 * the first place, i.e. ram_size is larger than (traditional) 135 * lowmem. And for new machine types (gigabyte_align = true) 136 * only, for live migration compatibility reasons. 137 * 138 * - Next the max-ram-below-4g option was added, which allowed to 139 * reduce lowmem to a smaller value, to allow a larger PCI I/O 140 * window below 4G. qemu doesn't enforce gigabyte alignment here, 141 * but prints a warning. 142 * 143 * - Finally max-ram-below-4g got updated to also allow raising lowmem, 144 * so legacy non-PAE guests can get as much memory as possible in 145 * the 32bit address space below 4G. 146 * 147 * - Note that Xen has its own ram setup code in xen_ram_init(), 148 * called via xen_hvm_init_pc(). 149 * 150 * Examples: 151 * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high 152 * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high 153 * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high 154 * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M) 155 */ 156 if (xen_enabled()) { 157 xen_hvm_init_pc(pcms, &ram_memory); 158 } else { 159 ram_memory = machine->ram; 160 if (!pcms->max_ram_below_4g) { 161 pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ 162 } 163 lowmem = pcms->max_ram_below_4g; 164 if (machine->ram_size >= pcms->max_ram_below_4g) { 165 if (pcmc->gigabyte_align) { 166 if (lowmem > 0xc0000000) { 167 lowmem = 0xc0000000; 168 } 169 if (lowmem & (1 * GiB - 1)) { 170 warn_report("Large machine and max_ram_below_4g " 171 "(%" PRIu64 ") not a multiple of 1G; " 172 "possible bad performance.", 173 pcms->max_ram_below_4g); 174 } 175 } 176 } 177 178 if (machine->ram_size >= lowmem) { 179 x86ms->above_4g_mem_size = machine->ram_size - lowmem; 180 x86ms->below_4g_mem_size = lowmem; 181 } else { 182 x86ms->above_4g_mem_size = 0; 183 x86ms->below_4g_mem_size = machine->ram_size; 184 } 185 } 186 187 pc_machine_init_sgx_epc(pcms); 188 x86_cpus_init(x86ms, pcmc->default_cpu_version); 189 190 if (kvm_enabled() && pcmc->kvmclock_enabled) { 191 kvmclock_create(pcmc->kvmclock_create_always); 192 } 193 194 if (pcmc->pci_enabled) { 195 Object *phb; 196 197 pci_memory = g_new(MemoryRegion, 1); 198 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); 199 rom_memory = pci_memory; 200 201 phb = OBJECT(qdev_new(host_type)); 202 object_property_add_child(OBJECT(machine), "i440fx", phb); 203 object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, 204 OBJECT(ram_memory), &error_fatal); 205 object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, 206 OBJECT(pci_memory), &error_fatal); 207 object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, 208 OBJECT(system_memory), &error_fatal); 209 object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, 210 OBJECT(system_io), &error_fatal); 211 object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE, 212 x86ms->below_4g_mem_size, &error_fatal); 213 object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, 214 x86ms->above_4g_mem_size, &error_fatal); 215 object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, pci_type, 216 &error_fatal); 217 sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); 218 219 pci_bus = PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); 220 pci_bus_map_irqs(pci_bus, 221 xen_enabled() ? xen_pci_slot_get_pirq 222 : pc_pci_slot_get_pirq); 223 pcms->bus = pci_bus; 224 225 hole64_size = object_property_get_uint(phb, 226 PCI_HOST_PROP_PCI_HOLE64_SIZE, 227 &error_abort); 228 } 229 230 pc_guest_info_init(pcms); 231 232 if (pcmc->smbios_defaults) { 233 MachineClass *mc = MACHINE_GET_CLASS(machine); 234 /* These values are guest ABI, do not change */ 235 smbios_set_defaults("QEMU", mc->desc, 236 mc->name, pcmc->smbios_legacy_mode, 237 pcmc->smbios_uuid_encoded, 238 pcms->smbios_entry_point_type); 239 } 240 241 /* allocate ram and load rom/bios */ 242 if (!xen_enabled()) { 243 pc_memory_init(pcms, system_memory, rom_memory, hole64_size); 244 } else { 245 assert(machine->ram_size == x86ms->below_4g_mem_size + 246 x86ms->above_4g_mem_size); 247 248 pc_system_flash_cleanup_unused(pcms); 249 if (machine->kernel_filename != NULL) { 250 /* For xen HVM direct kernel boot, load linux here */ 251 xen_load_linux(pcms); 252 } 253 } 254 255 gsi_state = pc_gsi_create(&x86ms->gsi, pcmc->pci_enabled); 256 257 if (pcmc->pci_enabled) { 258 PCIDevice *pci_dev; 259 DeviceState *dev; 260 size_t i; 261 262 pci_dev = pci_new_multifunction(-1, pcms->south_bridge); 263 object_property_set_bool(OBJECT(pci_dev), "has-usb", 264 machine_usb(machine), &error_abort); 265 object_property_set_bool(OBJECT(pci_dev), "has-acpi", 266 x86_machine_is_acpi_enabled(x86ms), 267 &error_abort); 268 object_property_set_bool(OBJECT(pci_dev), "has-pic", false, 269 &error_abort); 270 object_property_set_bool(OBJECT(pci_dev), "has-pit", false, 271 &error_abort); 272 qdev_prop_set_uint32(DEVICE(pci_dev), "smb_io_base", 0xb100); 273 object_property_set_bool(OBJECT(pci_dev), "smm-enabled", 274 x86_machine_is_smm_enabled(x86ms), 275 &error_abort); 276 dev = DEVICE(pci_dev); 277 for (i = 0; i < ISA_NUM_IRQS; i++) { 278 qdev_connect_gpio_out_named(dev, "isa-irqs", i, x86ms->gsi[i]); 279 } 280 pci_realize_and_unref(pci_dev, pci_bus, &error_fatal); 281 282 if (xen_enabled()) { 283 pci_device_set_intx_routing_notifier( 284 pci_dev, piix_intx_routing_notifier_xen); 285 286 /* 287 * Xen supports additional interrupt routes from the PCI devices to 288 * the IOAPIC: the four pins of each PCI device on the bus are also 289 * connected to the IOAPIC directly. 290 * These additional routes can be discovered through ACPI. 291 */ 292 pci_bus_irqs(pci_bus, xen_intx_set_irq, pci_dev, 293 XEN_IOAPIC_NUM_PIRQS); 294 } 295 296 isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci_dev), "isa.0")); 297 rtc_state = ISA_DEVICE(object_resolve_path_component(OBJECT(pci_dev), 298 "rtc")); 299 piix4_pm = object_resolve_path_component(OBJECT(pci_dev), "pm"); 300 dev = DEVICE(object_resolve_path_component(OBJECT(pci_dev), "ide")); 301 pci_ide_create_devs(PCI_DEVICE(dev)); 302 idebus[0] = qdev_get_child_bus(dev, "ide.0"); 303 idebus[1] = qdev_get_child_bus(dev, "ide.1"); 304 } else { 305 isa_bus = isa_bus_new(NULL, system_memory, system_io, 306 &error_abort); 307 isa_bus_register_input_irqs(isa_bus, x86ms->gsi); 308 309 rtc_state = isa_new(TYPE_MC146818_RTC); 310 qdev_prop_set_int32(DEVICE(rtc_state), "base_year", 2000); 311 isa_realize_and_unref(rtc_state, isa_bus, &error_fatal); 312 313 i8257_dma_init(isa_bus, 0); 314 pcms->hpet_enabled = false; 315 idebus[0] = NULL; 316 idebus[1] = NULL; 317 } 318 319 if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) { 320 pc_i8259_create(isa_bus, gsi_state->i8259_irq); 321 } 322 323 if (pcmc->pci_enabled) { 324 ioapic_init_gsi(gsi_state, "i440fx"); 325 } 326 327 if (tcg_enabled()) { 328 x86_register_ferr_irq(x86ms->gsi[13]); 329 } 330 331 pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); 332 333 assert(pcms->vmport != ON_OFF_AUTO__MAX); 334 if (pcms->vmport == ON_OFF_AUTO_AUTO) { 335 pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; 336 } 337 338 /* init basic PC hardware */ 339 pc_basic_device_init(pcms, isa_bus, x86ms->gsi, rtc_state, true, 340 0x4); 341 342 pc_nic_init(pcmc, isa_bus, pci_bus); 343 344 if (pcmc->pci_enabled) { 345 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); 346 } 347 #ifdef CONFIG_IDE_ISA 348 else { 349 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; 350 int i; 351 352 ide_drive_get(hd, ARRAY_SIZE(hd)); 353 for (i = 0; i < MAX_IDE_BUS; i++) { 354 ISADevice *dev; 355 char busname[] = "ide.0"; 356 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], 357 ide_irq[i], 358 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); 359 /* 360 * The ide bus name is ide.0 for the first bus and ide.1 for the 361 * second one. 362 */ 363 busname[4] = '0' + i; 364 idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); 365 } 366 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); 367 } 368 #endif 369 370 if (piix4_pm) { 371 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); 372 373 qdev_connect_gpio_out_named(DEVICE(piix4_pm), "smi-irq", 0, smi_irq); 374 pcms->smbus = I2C_BUS(qdev_get_child_bus(DEVICE(piix4_pm), "i2c")); 375 /* TODO: Populate SPD eeprom data. */ 376 smbus_eeprom_init(pcms->smbus, 8, NULL, 0); 377 378 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 379 TYPE_HOTPLUG_HANDLER, 380 (Object **)&x86ms->acpi_dev, 381 object_property_allow_set_link, 382 OBJ_PROP_LINK_STRONG); 383 object_property_set_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, 384 piix4_pm, &error_abort); 385 } 386 387 if (machine->nvdimms_state->is_enabled) { 388 nvdimm_init_acpi_state(machine->nvdimms_state, system_io, 389 x86_nvdimm_acpi_dsmio, 390 x86ms->fw_cfg, OBJECT(pcms)); 391 } 392 } 393 394 typedef enum PCSouthBridgeOption { 395 PC_SOUTH_BRIDGE_OPTION_PIIX3, 396 PC_SOUTH_BRIDGE_OPTION_PIIX4, 397 PC_SOUTH_BRIDGE_OPTION_MAX, 398 } PCSouthBridgeOption; 399 400 static const QEnumLookup PCSouthBridgeOption_lookup = { 401 .array = (const char *const[]) { 402 [PC_SOUTH_BRIDGE_OPTION_PIIX3] = TYPE_PIIX3_DEVICE, 403 [PC_SOUTH_BRIDGE_OPTION_PIIX4] = TYPE_PIIX4_PCI_DEVICE, 404 }, 405 .size = PC_SOUTH_BRIDGE_OPTION_MAX 406 }; 407 408 #define NotifyVmexitOption_str(val) \ 409 qapi_enum_lookup(&NotifyVmexitOption_lookup, (val)) 410 411 static int pc_get_south_bridge(Object *obj, Error **errp) 412 { 413 PCMachineState *pcms = PC_MACHINE(obj); 414 int i; 415 416 for (i = 0; i < PCSouthBridgeOption_lookup.size; i++) { 417 if (g_strcmp0(PCSouthBridgeOption_lookup.array[i], 418 pcms->south_bridge) == 0) { 419 return i; 420 } 421 } 422 423 error_setg(errp, "Invalid south bridge value set"); 424 return 0; 425 } 426 427 static void pc_set_south_bridge(Object *obj, int value, Error **errp) 428 { 429 PCMachineState *pcms = PC_MACHINE(obj); 430 431 if (value < 0) { 432 error_setg(errp, "Value can't be negative"); 433 return; 434 } 435 436 if (value >= PCSouthBridgeOption_lookup.size) { 437 error_setg(errp, "Value too big"); 438 return; 439 } 440 441 pcms->south_bridge = PCSouthBridgeOption_lookup.array[value]; 442 } 443 444 /* Looking for a pc_compat_2_4() function? It doesn't exist. 445 * pc_compat_*() functions that run on machine-init time and 446 * change global QEMU state are deprecated. Please don't create 447 * one, and implement any pc-*-2.4 (and newer) compat code in 448 * hw_compat_*, pc_compat_*, or * pc_*_machine_options(). 449 */ 450 451 static void pc_compat_2_3_fn(MachineState *machine) 452 { 453 X86MachineState *x86ms = X86_MACHINE(machine); 454 if (kvm_enabled()) { 455 x86ms->smm = ON_OFF_AUTO_OFF; 456 } 457 } 458 459 static void pc_compat_2_2_fn(MachineState *machine) 460 { 461 pc_compat_2_3_fn(machine); 462 } 463 464 static void pc_compat_2_1_fn(MachineState *machine) 465 { 466 pc_compat_2_2_fn(machine); 467 x86_cpu_change_kvm_default("svm", NULL); 468 } 469 470 static void pc_compat_2_0_fn(MachineState *machine) 471 { 472 pc_compat_2_1_fn(machine); 473 } 474 475 #ifdef CONFIG_ISAPC 476 static void pc_init_isa(MachineState *machine) 477 { 478 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); 479 } 480 #endif 481 482 #ifdef CONFIG_XEN 483 static void pc_xen_hvm_init_pci(MachineState *machine) 484 { 485 const char *pci_type = xen_igd_gfx_pt_enabled() ? 486 TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE; 487 488 pc_init1(machine, 489 TYPE_I440FX_PCI_HOST_BRIDGE, 490 pci_type); 491 } 492 493 static void pc_xen_hvm_init(MachineState *machine) 494 { 495 PCMachineState *pcms = PC_MACHINE(machine); 496 497 if (!xen_enabled()) { 498 error_report("xenfv machine requires the xen accelerator"); 499 exit(1); 500 } 501 502 pc_xen_hvm_init_pci(machine); 503 xen_igd_reserve_slot(pcms->bus); 504 pci_create_simple(pcms->bus, -1, "xen-platform"); 505 } 506 #endif 507 508 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ 509 static void pc_init_##suffix(MachineState *machine) \ 510 { \ 511 void (*compat)(MachineState *m) = (compatfn); \ 512 if (compat) { \ 513 compat(machine); \ 514 } \ 515 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \ 516 TYPE_I440FX_PCI_DEVICE); \ 517 } \ 518 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) 519 520 static void pc_i440fx_machine_options(MachineClass *m) 521 { 522 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 523 ObjectClass *oc = OBJECT_CLASS(m); 524 pcmc->default_south_bridge = TYPE_PIIX3_DEVICE; 525 pcmc->pci_root_uid = 0; 526 pcmc->default_cpu_version = 1; 527 528 m->family = "pc_piix"; 529 m->desc = "Standard PC (i440FX + PIIX, 1996)"; 530 m->default_machine_opts = "firmware=bios-256k.bin"; 531 m->default_display = "std"; 532 m->default_nic = "e1000"; 533 m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL); 534 machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); 535 machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); 536 537 object_class_property_add_enum(oc, "x-south-bridge", "PCSouthBridgeOption", 538 &PCSouthBridgeOption_lookup, 539 pc_get_south_bridge, 540 pc_set_south_bridge); 541 object_class_property_set_description(oc, "x-south-bridge", 542 "Use a different south bridge than PIIX3"); 543 } 544 545 static void pc_i440fx_9_0_machine_options(MachineClass *m) 546 { 547 pc_i440fx_machine_options(m); 548 m->alias = "pc"; 549 m->is_default = true; 550 } 551 552 DEFINE_I440FX_MACHINE(v9_0, "pc-i440fx-9.0", NULL, 553 pc_i440fx_9_0_machine_options); 554 555 static void pc_i440fx_8_2_machine_options(MachineClass *m) 556 { 557 pc_i440fx_9_0_machine_options(m); 558 m->alias = NULL; 559 m->is_default = false; 560 561 compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len); 562 compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len); 563 } 564 565 DEFINE_I440FX_MACHINE(v8_2, "pc-i440fx-8.2", NULL, 566 pc_i440fx_8_2_machine_options); 567 568 static void pc_i440fx_8_1_machine_options(MachineClass *m) 569 { 570 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 571 572 pc_i440fx_8_2_machine_options(m); 573 pcmc->broken_32bit_mem_addr_check = true; 574 575 compat_props_add(m->compat_props, hw_compat_8_1, hw_compat_8_1_len); 576 compat_props_add(m->compat_props, pc_compat_8_1, pc_compat_8_1_len); 577 } 578 579 DEFINE_I440FX_MACHINE(v8_1, "pc-i440fx-8.1", NULL, 580 pc_i440fx_8_1_machine_options); 581 582 static void pc_i440fx_8_0_machine_options(MachineClass *m) 583 { 584 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 585 586 pc_i440fx_8_1_machine_options(m); 587 compat_props_add(m->compat_props, hw_compat_8_0, hw_compat_8_0_len); 588 compat_props_add(m->compat_props, pc_compat_8_0, pc_compat_8_0_len); 589 590 /* For pc-i44fx-8.0 and older, use SMBIOS 2.8 by default */ 591 pcmc->default_smbios_ep_type = SMBIOS_ENTRY_POINT_TYPE_32; 592 } 593 594 DEFINE_I440FX_MACHINE(v8_0, "pc-i440fx-8.0", NULL, 595 pc_i440fx_8_0_machine_options); 596 597 static void pc_i440fx_7_2_machine_options(MachineClass *m) 598 { 599 pc_i440fx_8_0_machine_options(m); 600 compat_props_add(m->compat_props, hw_compat_7_2, hw_compat_7_2_len); 601 compat_props_add(m->compat_props, pc_compat_7_2, pc_compat_7_2_len); 602 } 603 604 DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL, 605 pc_i440fx_7_2_machine_options); 606 607 static void pc_i440fx_7_1_machine_options(MachineClass *m) 608 { 609 pc_i440fx_7_2_machine_options(m); 610 compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len); 611 compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len); 612 } 613 614 DEFINE_I440FX_MACHINE(v7_1, "pc-i440fx-7.1", NULL, 615 pc_i440fx_7_1_machine_options); 616 617 static void pc_i440fx_7_0_machine_options(MachineClass *m) 618 { 619 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 620 pc_i440fx_7_1_machine_options(m); 621 pcmc->enforce_amd_1tb_hole = false; 622 compat_props_add(m->compat_props, hw_compat_7_0, hw_compat_7_0_len); 623 compat_props_add(m->compat_props, pc_compat_7_0, pc_compat_7_0_len); 624 } 625 626 DEFINE_I440FX_MACHINE(v7_0, "pc-i440fx-7.0", NULL, 627 pc_i440fx_7_0_machine_options); 628 629 static void pc_i440fx_6_2_machine_options(MachineClass *m) 630 { 631 pc_i440fx_7_0_machine_options(m); 632 compat_props_add(m->compat_props, hw_compat_6_2, hw_compat_6_2_len); 633 compat_props_add(m->compat_props, pc_compat_6_2, pc_compat_6_2_len); 634 } 635 636 DEFINE_I440FX_MACHINE(v6_2, "pc-i440fx-6.2", NULL, 637 pc_i440fx_6_2_machine_options); 638 639 static void pc_i440fx_6_1_machine_options(MachineClass *m) 640 { 641 pc_i440fx_6_2_machine_options(m); 642 compat_props_add(m->compat_props, hw_compat_6_1, hw_compat_6_1_len); 643 compat_props_add(m->compat_props, pc_compat_6_1, pc_compat_6_1_len); 644 m->smp_props.prefer_sockets = true; 645 } 646 647 DEFINE_I440FX_MACHINE(v6_1, "pc-i440fx-6.1", NULL, 648 pc_i440fx_6_1_machine_options); 649 650 static void pc_i440fx_6_0_machine_options(MachineClass *m) 651 { 652 pc_i440fx_6_1_machine_options(m); 653 compat_props_add(m->compat_props, hw_compat_6_0, hw_compat_6_0_len); 654 compat_props_add(m->compat_props, pc_compat_6_0, pc_compat_6_0_len); 655 } 656 657 DEFINE_I440FX_MACHINE(v6_0, "pc-i440fx-6.0", NULL, 658 pc_i440fx_6_0_machine_options); 659 660 static void pc_i440fx_5_2_machine_options(MachineClass *m) 661 { 662 pc_i440fx_6_0_machine_options(m); 663 compat_props_add(m->compat_props, hw_compat_5_2, hw_compat_5_2_len); 664 compat_props_add(m->compat_props, pc_compat_5_2, pc_compat_5_2_len); 665 } 666 667 DEFINE_I440FX_MACHINE(v5_2, "pc-i440fx-5.2", NULL, 668 pc_i440fx_5_2_machine_options); 669 670 static void pc_i440fx_5_1_machine_options(MachineClass *m) 671 { 672 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 673 674 pc_i440fx_5_2_machine_options(m); 675 compat_props_add(m->compat_props, hw_compat_5_1, hw_compat_5_1_len); 676 compat_props_add(m->compat_props, pc_compat_5_1, pc_compat_5_1_len); 677 pcmc->kvmclock_create_always = false; 678 pcmc->pci_root_uid = 1; 679 } 680 681 DEFINE_I440FX_MACHINE(v5_1, "pc-i440fx-5.1", NULL, 682 pc_i440fx_5_1_machine_options); 683 684 static void pc_i440fx_5_0_machine_options(MachineClass *m) 685 { 686 pc_i440fx_5_1_machine_options(m); 687 m->numa_mem_supported = true; 688 compat_props_add(m->compat_props, hw_compat_5_0, hw_compat_5_0_len); 689 compat_props_add(m->compat_props, pc_compat_5_0, pc_compat_5_0_len); 690 m->auto_enable_numa_with_memdev = false; 691 } 692 693 DEFINE_I440FX_MACHINE(v5_0, "pc-i440fx-5.0", NULL, 694 pc_i440fx_5_0_machine_options); 695 696 static void pc_i440fx_4_2_machine_options(MachineClass *m) 697 { 698 pc_i440fx_5_0_machine_options(m); 699 compat_props_add(m->compat_props, hw_compat_4_2, hw_compat_4_2_len); 700 compat_props_add(m->compat_props, pc_compat_4_2, pc_compat_4_2_len); 701 } 702 703 DEFINE_I440FX_MACHINE(v4_2, "pc-i440fx-4.2", NULL, 704 pc_i440fx_4_2_machine_options); 705 706 static void pc_i440fx_4_1_machine_options(MachineClass *m) 707 { 708 pc_i440fx_4_2_machine_options(m); 709 compat_props_add(m->compat_props, hw_compat_4_1, hw_compat_4_1_len); 710 compat_props_add(m->compat_props, pc_compat_4_1, pc_compat_4_1_len); 711 } 712 713 DEFINE_I440FX_MACHINE(v4_1, "pc-i440fx-4.1", NULL, 714 pc_i440fx_4_1_machine_options); 715 716 static void pc_i440fx_4_0_machine_options(MachineClass *m) 717 { 718 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 719 pc_i440fx_4_1_machine_options(m); 720 pcmc->default_cpu_version = CPU_VERSION_LEGACY; 721 compat_props_add(m->compat_props, hw_compat_4_0, hw_compat_4_0_len); 722 compat_props_add(m->compat_props, pc_compat_4_0, pc_compat_4_0_len); 723 } 724 725 DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL, 726 pc_i440fx_4_0_machine_options); 727 728 static void pc_i440fx_3_1_machine_options(MachineClass *m) 729 { 730 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 731 732 pc_i440fx_4_0_machine_options(m); 733 m->smbus_no_migration_support = true; 734 pcmc->pvh_enabled = false; 735 compat_props_add(m->compat_props, hw_compat_3_1, hw_compat_3_1_len); 736 compat_props_add(m->compat_props, pc_compat_3_1, pc_compat_3_1_len); 737 } 738 739 DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL, 740 pc_i440fx_3_1_machine_options); 741 742 static void pc_i440fx_3_0_machine_options(MachineClass *m) 743 { 744 pc_i440fx_3_1_machine_options(m); 745 compat_props_add(m->compat_props, hw_compat_3_0, hw_compat_3_0_len); 746 compat_props_add(m->compat_props, pc_compat_3_0, pc_compat_3_0_len); 747 } 748 749 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, 750 pc_i440fx_3_0_machine_options); 751 752 static void pc_i440fx_2_12_machine_options(MachineClass *m) 753 { 754 pc_i440fx_3_0_machine_options(m); 755 compat_props_add(m->compat_props, hw_compat_2_12, hw_compat_2_12_len); 756 compat_props_add(m->compat_props, pc_compat_2_12, pc_compat_2_12_len); 757 } 758 759 DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL, 760 pc_i440fx_2_12_machine_options); 761 762 static void pc_i440fx_2_11_machine_options(MachineClass *m) 763 { 764 pc_i440fx_2_12_machine_options(m); 765 compat_props_add(m->compat_props, hw_compat_2_11, hw_compat_2_11_len); 766 compat_props_add(m->compat_props, pc_compat_2_11, pc_compat_2_11_len); 767 } 768 769 DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, 770 pc_i440fx_2_11_machine_options); 771 772 static void pc_i440fx_2_10_machine_options(MachineClass *m) 773 { 774 pc_i440fx_2_11_machine_options(m); 775 compat_props_add(m->compat_props, hw_compat_2_10, hw_compat_2_10_len); 776 compat_props_add(m->compat_props, pc_compat_2_10, pc_compat_2_10_len); 777 m->auto_enable_numa_with_memhp = false; 778 } 779 780 DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, 781 pc_i440fx_2_10_machine_options); 782 783 static void pc_i440fx_2_9_machine_options(MachineClass *m) 784 { 785 pc_i440fx_2_10_machine_options(m); 786 compat_props_add(m->compat_props, hw_compat_2_9, hw_compat_2_9_len); 787 compat_props_add(m->compat_props, pc_compat_2_9, pc_compat_2_9_len); 788 } 789 790 DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, 791 pc_i440fx_2_9_machine_options); 792 793 static void pc_i440fx_2_8_machine_options(MachineClass *m) 794 { 795 pc_i440fx_2_9_machine_options(m); 796 compat_props_add(m->compat_props, hw_compat_2_8, hw_compat_2_8_len); 797 compat_props_add(m->compat_props, pc_compat_2_8, pc_compat_2_8_len); 798 } 799 800 DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL, 801 pc_i440fx_2_8_machine_options); 802 803 static void pc_i440fx_2_7_machine_options(MachineClass *m) 804 { 805 pc_i440fx_2_8_machine_options(m); 806 compat_props_add(m->compat_props, hw_compat_2_7, hw_compat_2_7_len); 807 compat_props_add(m->compat_props, pc_compat_2_7, pc_compat_2_7_len); 808 } 809 810 DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL, 811 pc_i440fx_2_7_machine_options); 812 813 static void pc_i440fx_2_6_machine_options(MachineClass *m) 814 { 815 X86MachineClass *x86mc = X86_MACHINE_CLASS(m); 816 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 817 818 pc_i440fx_2_7_machine_options(m); 819 pcmc->legacy_cpu_hotplug = true; 820 x86mc->fwcfg_dma_enabled = false; 821 compat_props_add(m->compat_props, hw_compat_2_6, hw_compat_2_6_len); 822 compat_props_add(m->compat_props, pc_compat_2_6, pc_compat_2_6_len); 823 } 824 825 DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, 826 pc_i440fx_2_6_machine_options); 827 828 static void pc_i440fx_2_5_machine_options(MachineClass *m) 829 { 830 X86MachineClass *x86mc = X86_MACHINE_CLASS(m); 831 832 pc_i440fx_2_6_machine_options(m); 833 x86mc->save_tsc_khz = false; 834 m->legacy_fw_cfg_order = 1; 835 compat_props_add(m->compat_props, hw_compat_2_5, hw_compat_2_5_len); 836 compat_props_add(m->compat_props, pc_compat_2_5, pc_compat_2_5_len); 837 } 838 839 DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, 840 pc_i440fx_2_5_machine_options); 841 842 static void pc_i440fx_2_4_machine_options(MachineClass *m) 843 { 844 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 845 846 pc_i440fx_2_5_machine_options(m); 847 m->hw_version = "2.4.0"; 848 pcmc->broken_reserved_end = true; 849 compat_props_add(m->compat_props, hw_compat_2_4, hw_compat_2_4_len); 850 compat_props_add(m->compat_props, pc_compat_2_4, pc_compat_2_4_len); 851 } 852 853 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, 854 pc_i440fx_2_4_machine_options) 855 856 static void pc_i440fx_2_3_machine_options(MachineClass *m) 857 { 858 pc_i440fx_2_4_machine_options(m); 859 m->hw_version = "2.3.0"; 860 m->deprecation_reason = "old and unattended - use a newer version instead"; 861 compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len); 862 compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len); 863 } 864 865 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn, 866 pc_i440fx_2_3_machine_options); 867 868 static void pc_i440fx_2_2_machine_options(MachineClass *m) 869 { 870 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 871 872 pc_i440fx_2_3_machine_options(m); 873 m->hw_version = "2.2.0"; 874 m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on"; 875 compat_props_add(m->compat_props, hw_compat_2_2, hw_compat_2_2_len); 876 compat_props_add(m->compat_props, pc_compat_2_2, pc_compat_2_2_len); 877 pcmc->rsdp_in_ram = false; 878 pcmc->resizable_acpi_blob = false; 879 } 880 881 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2_fn, 882 pc_i440fx_2_2_machine_options); 883 884 static void pc_i440fx_2_1_machine_options(MachineClass *m) 885 { 886 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 887 888 pc_i440fx_2_2_machine_options(m); 889 m->hw_version = "2.1.0"; 890 m->default_display = NULL; 891 compat_props_add(m->compat_props, hw_compat_2_1, hw_compat_2_1_len); 892 compat_props_add(m->compat_props, pc_compat_2_1, pc_compat_2_1_len); 893 pcmc->smbios_uuid_encoded = false; 894 pcmc->enforce_aligned_dimm = false; 895 } 896 897 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1_fn, 898 pc_i440fx_2_1_machine_options); 899 900 static void pc_i440fx_2_0_machine_options(MachineClass *m) 901 { 902 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 903 904 pc_i440fx_2_1_machine_options(m); 905 m->hw_version = "2.0.0"; 906 compat_props_add(m->compat_props, pc_compat_2_0, pc_compat_2_0_len); 907 pcmc->smbios_legacy_mode = true; 908 pcmc->has_reserved_memory = false; 909 /* This value depends on the actual DSDT and SSDT compiled into 910 * the source QEMU; unfortunately it depends on the binary and 911 * not on the machine type, so we cannot make pc-i440fx-1.7 work on 912 * both QEMU 1.7 and QEMU 2.0. 913 * 914 * Large variations cause migration to fail for more than one 915 * consecutive value of the "-smp" maxcpus option. 916 * 917 * For small variations of the kind caused by different iasl versions, 918 * the 4k rounding usually leaves slack. However, there could be still 919 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the 920 * slack is only ~10 bytes before one "-smp maxcpus" value breaks! 921 * 922 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on 923 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. 924 */ 925 pcmc->legacy_acpi_table_size = 6652; 926 pcmc->acpi_data_size = 0x10000; 927 } 928 929 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0_fn, 930 pc_i440fx_2_0_machine_options); 931 932 #ifdef CONFIG_ISAPC 933 static void isapc_machine_options(MachineClass *m) 934 { 935 PCMachineClass *pcmc = PC_MACHINE_CLASS(m); 936 m->desc = "ISA-only PC"; 937 m->max_cpus = 1; 938 m->option_rom_has_mr = true; 939 m->rom_file_has_mr = false; 940 pcmc->pci_enabled = false; 941 pcmc->has_acpi_build = false; 942 pcmc->smbios_defaults = false; 943 pcmc->gigabyte_align = false; 944 pcmc->smbios_legacy_mode = true; 945 pcmc->has_reserved_memory = false; 946 m->default_nic = "ne2k_isa"; 947 m->default_cpu_type = X86_CPU_TYPE_NAME("486"); 948 m->no_parallel = !module_object_class_by_name(TYPE_ISA_PARALLEL); 949 } 950 951 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, 952 isapc_machine_options); 953 #endif 954 955 #ifdef CONFIG_XEN 956 static void xenfv_4_2_machine_options(MachineClass *m) 957 { 958 pc_i440fx_4_2_machine_options(m); 959 m->desc = "Xen Fully-virtualized PC"; 960 m->max_cpus = HVM_MAX_VCPUS; 961 m->default_machine_opts = "accel=xen,suppress-vmdesc=on"; 962 } 963 964 DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init, 965 xenfv_4_2_machine_options); 966 967 static void xenfv_3_1_machine_options(MachineClass *m) 968 { 969 pc_i440fx_3_1_machine_options(m); 970 m->desc = "Xen Fully-virtualized PC"; 971 m->alias = "xenfv"; 972 m->max_cpus = HVM_MAX_VCPUS; 973 m->default_machine_opts = "accel=xen,suppress-vmdesc=on"; 974 } 975 976 DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init, 977 xenfv_3_1_machine_options); 978 #endif 979