xref: /openbmc/qemu/hw/i386/pc_piix.c (revision becaeb72)
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     global_state_set_optional();
315     savevm_skip_configuration();
316 }
317 
318 static void pc_compat_2_2(MachineState *machine)
319 {
320     pc_compat_2_3(machine);
321     rsdp_in_ram = false;
322     x86_cpu_compat_set_features("kvm64", FEAT_1_EDX, 0, CPUID_VME);
323     x86_cpu_compat_set_features("kvm32", FEAT_1_EDX, 0, CPUID_VME);
324     x86_cpu_compat_set_features("Conroe", FEAT_1_EDX, 0, CPUID_VME);
325     x86_cpu_compat_set_features("Penryn", FEAT_1_EDX, 0, CPUID_VME);
326     x86_cpu_compat_set_features("Nehalem", FEAT_1_EDX, 0, CPUID_VME);
327     x86_cpu_compat_set_features("Westmere", FEAT_1_EDX, 0, CPUID_VME);
328     x86_cpu_compat_set_features("SandyBridge", FEAT_1_EDX, 0, CPUID_VME);
329     x86_cpu_compat_set_features("Haswell", FEAT_1_EDX, 0, CPUID_VME);
330     x86_cpu_compat_set_features("Broadwell", FEAT_1_EDX, 0, CPUID_VME);
331     x86_cpu_compat_set_features("Opteron_G1", FEAT_1_EDX, 0, CPUID_VME);
332     x86_cpu_compat_set_features("Opteron_G2", FEAT_1_EDX, 0, CPUID_VME);
333     x86_cpu_compat_set_features("Opteron_G3", FEAT_1_EDX, 0, CPUID_VME);
334     x86_cpu_compat_set_features("Opteron_G4", FEAT_1_EDX, 0, CPUID_VME);
335     x86_cpu_compat_set_features("Opteron_G5", FEAT_1_EDX, 0, CPUID_VME);
336     x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
337     x86_cpu_compat_set_features("Haswell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
338     x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_F16C);
339     x86_cpu_compat_set_features("Broadwell", FEAT_1_ECX, 0, CPUID_EXT_RDRAND);
340     machine->suppress_vmdesc = true;
341 }
342 
343 static void pc_compat_2_1(MachineState *machine)
344 {
345     PCMachineState *pcms = PC_MACHINE(machine);
346 
347     pc_compat_2_2(machine);
348     smbios_uuid_encoded = false;
349     x86_cpu_compat_set_features("coreduo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
350     x86_cpu_compat_set_features("core2duo", FEAT_1_ECX, CPUID_EXT_VMX, 0);
351     x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
352     pcms->enforce_aligned_dimm = false;
353 }
354 
355 static void pc_compat_2_0(MachineState *machine)
356 {
357     pc_compat_2_1(machine);
358     /* This value depends on the actual DSDT and SSDT compiled into
359      * the source QEMU; unfortunately it depends on the binary and
360      * not on the machine type, so we cannot make pc-i440fx-1.7 work on
361      * both QEMU 1.7 and QEMU 2.0.
362      *
363      * Large variations cause migration to fail for more than one
364      * consecutive value of the "-smp" maxcpus option.
365      *
366      * For small variations of the kind caused by different iasl versions,
367      * the 4k rounding usually leaves slack.  However, there could be still
368      * one or two values that break.  For QEMU 1.7 and QEMU 2.0 the
369      * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
370      *
371      * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
372      * QEMU 1.7 it is 6414.  For RHEL/CentOS 7.0 it is 6418.
373      */
374     legacy_acpi_table_size = 6652;
375     smbios_legacy_mode = true;
376     has_reserved_memory = false;
377     pc_set_legacy_acpi_data_size();
378 }
379 
380 static void pc_compat_1_7(MachineState *machine)
381 {
382     pc_compat_2_0(machine);
383     smbios_defaults = false;
384     gigabyte_align = false;
385     option_rom_has_mr = true;
386     legacy_acpi_table_size = 6414;
387     x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
388 }
389 
390 static void pc_compat_1_6(MachineState *machine)
391 {
392     pc_compat_1_7(machine);
393     rom_file_has_mr = false;
394     has_acpi_build = false;
395 }
396 
397 static void pc_compat_1_5(MachineState *machine)
398 {
399     pc_compat_1_6(machine);
400 }
401 
402 static void pc_compat_1_4(MachineState *machine)
403 {
404     pc_compat_1_5(machine);
405     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
406     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
407 }
408 
409 static void pc_compat_1_3(MachineState *machine)
410 {
411     pc_compat_1_4(machine);
412     enable_compat_apic_id_mode();
413 }
414 
415 /* PC compat function for pc-0.14 to pc-1.2 */
416 static void pc_compat_1_2(MachineState *machine)
417 {
418     pc_compat_1_3(machine);
419     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
420 }
421 
422 /* PC compat function for pc-0.10 to pc-0.13 */
423 static void pc_compat_0_13(MachineState *machine)
424 {
425     pc_compat_1_2(machine);
426     kvmclock_enabled = false;
427 }
428 
429 static void pc_init_isa(MachineState *machine)
430 {
431     pci_enabled = false;
432     has_acpi_build = false;
433     smbios_defaults = false;
434     gigabyte_align = false;
435     smbios_legacy_mode = true;
436     has_reserved_memory = false;
437     option_rom_has_mr = true;
438     rom_file_has_mr = false;
439     if (!machine->cpu_model) {
440         machine->cpu_model = "486";
441     }
442     x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
443     enable_compat_apic_id_mode();
444     pc_init1(machine);
445 }
446 
447 #ifdef CONFIG_XEN
448 static void pc_xen_hvm_init(MachineState *machine)
449 {
450     PCIBus *bus;
451 
452     pc_init1(machine);
453 
454     bus = pci_find_primary_bus();
455     if (bus != NULL) {
456         pci_create_simple(bus, -1, "xen-platform");
457     }
458 }
459 #endif
460 
461 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
462     static void pc_init_##suffix(MachineState *machine) \
463     { \
464         void (*compat)(MachineState *m) = (compatfn); \
465         if (compat) { \
466             compat(machine); \
467         } \
468         pc_init1(machine); \
469     } \
470     DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
471 
472 static void pc_i440fx_machine_options(MachineClass *m)
473 {
474     pc_default_machine_options(m);
475     m->family = "pc_piix";
476     m->desc = "Standard PC (i440FX + PIIX, 1996)";
477     m->hot_add_cpu = pc_hot_add_cpu;
478 }
479 
480 static void pc_i440fx_2_4_machine_options(MachineClass *m)
481 {
482     pc_i440fx_machine_options(m);
483     m->default_machine_opts = "firmware=bios-256k.bin";
484     m->default_display = "std";
485     m->alias = "pc";
486     m->is_default = 1;
487 }
488 
489 DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
490                       pc_i440fx_2_4_machine_options)
491 
492 
493 static void pc_i440fx_2_3_machine_options(MachineClass *m)
494 {
495     pc_i440fx_2_4_machine_options(m);
496     m->alias = NULL;
497     m->is_default = 0;
498     SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
499 }
500 
501 DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
502                       pc_i440fx_2_3_machine_options);
503 
504 
505 static void pc_i440fx_2_2_machine_options(MachineClass *m)
506 {
507     pc_i440fx_2_3_machine_options(m);
508     SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
509 }
510 
511 DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
512                       pc_i440fx_2_2_machine_options);
513 
514 
515 static void pc_i440fx_2_1_machine_options(MachineClass *m)
516 {
517     pc_i440fx_2_2_machine_options(m);
518     m->default_display = NULL;
519     SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
520 }
521 
522 DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
523                       pc_i440fx_2_1_machine_options);
524 
525 
526 
527 static void pc_i440fx_2_0_machine_options(MachineClass *m)
528 {
529     pc_i440fx_2_1_machine_options(m);
530     SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
531 }
532 
533 DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
534                       pc_i440fx_2_0_machine_options);
535 
536 
537 static void pc_i440fx_1_7_machine_options(MachineClass *m)
538 {
539     pc_i440fx_2_0_machine_options(m);
540     m->default_machine_opts = NULL;
541     SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
542 }
543 
544 DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
545                       pc_i440fx_1_7_machine_options);
546 
547 
548 static void pc_i440fx_1_6_machine_options(MachineClass *m)
549 {
550     pc_i440fx_1_7_machine_options(m);
551     SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
552 }
553 
554 DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
555                       pc_i440fx_1_6_machine_options);
556 
557 
558 static void pc_i440fx_1_5_machine_options(MachineClass *m)
559 {
560     pc_i440fx_1_6_machine_options(m);
561     SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
562 }
563 
564 DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
565                       pc_i440fx_1_5_machine_options);
566 
567 
568 static void pc_i440fx_1_4_machine_options(MachineClass *m)
569 {
570     pc_i440fx_1_5_machine_options(m);
571     m->hot_add_cpu = NULL;
572     SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
573 }
574 
575 DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
576                       pc_i440fx_1_4_machine_options);
577 
578 
579 #define PC_COMPAT_1_3 \
580         PC_COMPAT_1_4 \
581         {\
582             .driver   = "usb-tablet",\
583             .property = "usb_version",\
584             .value    = stringify(1),\
585         },{\
586             .driver   = "virtio-net-pci",\
587             .property = "ctrl_mac_addr",\
588             .value    = "off",      \
589         },{ \
590             .driver   = "virtio-net-pci", \
591             .property = "mq", \
592             .value    = "off", \
593         }, {\
594             .driver   = "e1000",\
595             .property = "autonegotiation",\
596             .value    = "off",\
597         },
598 
599 
600 static void pc_i440fx_1_3_machine_options(MachineClass *m)
601 {
602     pc_i440fx_1_4_machine_options(m);
603     SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
604 }
605 
606 DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
607                       pc_i440fx_1_3_machine_options);
608 
609 
610 #define PC_COMPAT_1_2 \
611         PC_COMPAT_1_3 \
612         {\
613             .driver   = "nec-usb-xhci",\
614             .property = "msi",\
615             .value    = "off",\
616         },{\
617             .driver   = "nec-usb-xhci",\
618             .property = "msix",\
619             .value    = "off",\
620         },{\
621             .driver   = "ivshmem",\
622             .property = "use64",\
623             .value    = "0",\
624         },{\
625             .driver   = "qxl",\
626             .property = "revision",\
627             .value    = stringify(3),\
628         },{\
629             .driver   = "qxl-vga",\
630             .property = "revision",\
631             .value    = stringify(3),\
632         },{\
633             .driver   = "VGA",\
634             .property = "mmio",\
635             .value    = "off",\
636         },
637 
638 static void pc_i440fx_1_2_machine_options(MachineClass *m)
639 {
640     pc_i440fx_1_3_machine_options(m);
641     SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
642 }
643 
644 DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
645                       pc_i440fx_1_2_machine_options);
646 
647 
648 #define PC_COMPAT_1_1 \
649         PC_COMPAT_1_2 \
650         {\
651             .driver   = "virtio-scsi-pci",\
652             .property = "hotplug",\
653             .value    = "off",\
654         },{\
655             .driver   = "virtio-scsi-pci",\
656             .property = "param_change",\
657             .value    = "off",\
658         },{\
659             .driver   = "VGA",\
660             .property = "vgamem_mb",\
661             .value    = stringify(8),\
662         },{\
663             .driver   = "vmware-svga",\
664             .property = "vgamem_mb",\
665             .value    = stringify(8),\
666         },{\
667             .driver   = "qxl-vga",\
668             .property = "vgamem_mb",\
669             .value    = stringify(8),\
670         },{\
671             .driver   = "qxl",\
672             .property = "vgamem_mb",\
673             .value    = stringify(8),\
674         },{\
675             .driver   = "virtio-blk-pci",\
676             .property = "config-wce",\
677             .value    = "off",\
678         },
679 
680 static void pc_i440fx_1_1_machine_options(MachineClass *m)
681 {
682     pc_i440fx_1_2_machine_options(m);
683     SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
684 }
685 
686 DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
687                       pc_i440fx_1_1_machine_options);
688 
689 
690 #define PC_COMPAT_1_0 \
691         PC_COMPAT_1_1 \
692         {\
693             .driver   = TYPE_ISA_FDC,\
694             .property = "check_media_rate",\
695             .value    = "off",\
696         }, {\
697             .driver   = "virtio-balloon-pci",\
698             .property = "class",\
699             .value    = stringify(PCI_CLASS_MEMORY_RAM),\
700         },{\
701             .driver   = "apic-common",\
702             .property = "vapic",\
703             .value    = "off",\
704         },{\
705             .driver   = TYPE_USB_DEVICE,\
706             .property = "full-path",\
707             .value    = "no",\
708         },
709 
710 static void pc_i440fx_1_0_machine_options(MachineClass *m)
711 {
712     pc_i440fx_1_1_machine_options(m);
713     m->hw_version = "1.0";
714     SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
715 }
716 
717 DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
718                       pc_i440fx_1_0_machine_options);
719 
720 
721 #define PC_COMPAT_0_15 \
722         PC_COMPAT_1_0
723 
724 static void pc_i440fx_0_15_machine_options(MachineClass *m)
725 {
726     pc_i440fx_1_0_machine_options(m);
727     m->hw_version = "0.15";
728     SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
729 }
730 
731 DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
732                       pc_i440fx_0_15_machine_options);
733 
734 
735 #define PC_COMPAT_0_14 \
736         PC_COMPAT_0_15 \
737         {\
738             .driver   = "virtio-blk-pci",\
739             .property = "event_idx",\
740             .value    = "off",\
741         },{\
742             .driver   = "virtio-serial-pci",\
743             .property = "event_idx",\
744             .value    = "off",\
745         },{\
746             .driver   = "virtio-net-pci",\
747             .property = "event_idx",\
748             .value    = "off",\
749         },{\
750             .driver   = "virtio-balloon-pci",\
751             .property = "event_idx",\
752             .value    = "off",\
753         },{\
754             .driver   = "qxl",\
755             .property = "revision",\
756             .value    = stringify(2),\
757         },{\
758             .driver   = "qxl-vga",\
759             .property = "revision",\
760             .value    = stringify(2),\
761         },
762 
763 static void pc_i440fx_0_14_machine_options(MachineClass *m)
764 {
765     pc_i440fx_0_15_machine_options(m);
766     m->hw_version = "0.14";
767     SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
768 }
769 
770 DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
771                       pc_i440fx_0_14_machine_options);
772 
773 
774 #define PC_COMPAT_0_13 \
775         PC_COMPAT_0_14 \
776         {\
777             .driver   = TYPE_PCI_DEVICE,\
778             .property = "command_serr_enable",\
779             .value    = "off",\
780         },{\
781             .driver   = "AC97",\
782             .property = "use_broken_id",\
783             .value    = stringify(1),\
784         },{\
785             .driver   = "virtio-9p-pci",\
786             .property = "vectors",\
787             .value    = stringify(0),\
788         },{\
789             .driver   = "VGA",\
790             .property = "rombar",\
791             .value    = stringify(0),\
792         },{\
793             .driver   = "vmware-svga",\
794             .property = "rombar",\
795             .value    = stringify(0),\
796         },
797 
798 static void pc_i440fx_0_13_machine_options(MachineClass *m)
799 {
800     pc_i440fx_0_14_machine_options(m);
801     m->hw_version = "0.13";
802     SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
803 }
804 
805 DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
806                       pc_i440fx_0_13_machine_options);
807 
808 
809 #define PC_COMPAT_0_12 \
810         PC_COMPAT_0_13 \
811         {\
812             .driver   = "virtio-serial-pci",\
813             .property = "max_ports",\
814             .value    = stringify(1),\
815         },{\
816             .driver   = "virtio-serial-pci",\
817             .property = "vectors",\
818             .value    = stringify(0),\
819         },{\
820             .driver   = "usb-mouse",\
821             .property = "serial",\
822             .value    = "1",\
823         },{\
824             .driver   = "usb-tablet",\
825             .property = "serial",\
826             .value    = "1",\
827         },{\
828             .driver   = "usb-kbd",\
829             .property = "serial",\
830             .value    = "1",\
831         },
832 
833 static void pc_i440fx_0_12_machine_options(MachineClass *m)
834 {
835     pc_i440fx_0_13_machine_options(m);
836     m->hw_version = "0.12";
837     SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
838 }
839 
840 DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
841                       pc_i440fx_0_12_machine_options);
842 
843 
844 #define PC_COMPAT_0_11 \
845         PC_COMPAT_0_12 \
846         {\
847             .driver   = "virtio-blk-pci",\
848             .property = "vectors",\
849             .value    = stringify(0),\
850         },{\
851             .driver   = TYPE_PCI_DEVICE,\
852             .property = "rombar",\
853             .value    = stringify(0),\
854         },{\
855             .driver   = "ide-drive",\
856             .property = "ver",\
857             .value    = "0.11",\
858         },{\
859             .driver   = "scsi-disk",\
860             .property = "ver",\
861             .value    = "0.11",\
862         },
863 
864 static void pc_i440fx_0_11_machine_options(MachineClass *m)
865 {
866     pc_i440fx_0_12_machine_options(m);
867     m->hw_version = "0.11";
868     SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
869 }
870 
871 DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
872                       pc_i440fx_0_11_machine_options);
873 
874 
875 #define PC_COMPAT_0_10 \
876     PC_COMPAT_0_11 \
877     {\
878         .driver   = "virtio-blk-pci",\
879         .property = "class",\
880         .value    = stringify(PCI_CLASS_STORAGE_OTHER),\
881     },{\
882         .driver   = "virtio-serial-pci",\
883         .property = "class",\
884         .value    = stringify(PCI_CLASS_DISPLAY_OTHER),\
885     },{\
886         .driver   = "virtio-net-pci",\
887         .property = "vectors",\
888         .value    = stringify(0),\
889     },{\
890         .driver   = "ide-drive",\
891         .property = "ver",\
892         .value    = "0.10",\
893     },{\
894         .driver   = "scsi-disk",\
895         .property = "ver",\
896         .value    = "0.10",\
897     },
898 
899 static void pc_i440fx_0_10_machine_options(MachineClass *m)
900 {
901     pc_i440fx_0_11_machine_options(m);
902     m->hw_version = "0.10";
903     SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
904 }
905 
906 DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
907                       pc_i440fx_0_10_machine_options);
908 
909 
910 static void isapc_machine_options(MachineClass *m)
911 {
912     pc_common_machine_options(m);
913     m->desc = "ISA-only PC";
914     m->max_cpus = 1;
915 }
916 
917 DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
918                   isapc_machine_options);
919 
920 
921 #ifdef CONFIG_XEN
922 static void xenfv_machine_options(MachineClass *m)
923 {
924     pc_common_machine_options(m);
925     m->desc = "Xen Fully-virtualized PC";
926     m->max_cpus = HVM_MAX_VCPUS;
927     m->default_machine_opts = "accel=xen";
928     m->hot_add_cpu = pc_hot_add_cpu;
929 }
930 
931 DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,
932                   xenfv_machine_options);
933 #endif
934