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