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