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