xref: /openbmc/qemu/hw/i386/pc_piix.c (revision a1857ad1)
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/blockdev.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 
56 #define MAX_IDE_BUS 2
57 
58 static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
59 static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
60 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
61 
62 static bool has_acpi_build = true;
63 static int legacy_acpi_table_size;
64 static bool smbios_defaults = true;
65 static bool smbios_legacy_mode;
66 /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
67  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
68  * pages in the host.
69  */
70 static bool gigabyte_align = true;
71 static bool has_reserved_memory = true;
72 
73 /* PC hardware initialisation */
74 static void pc_init1(MachineState *machine,
75                      int pci_enabled,
76                      int kvmclock_enabled)
77 {
78     PCMachineState *pc_machine = PC_MACHINE(machine);
79     MemoryRegion *system_memory = get_system_memory();
80     MemoryRegion *system_io = get_system_io();
81     int i;
82     ram_addr_t below_4g_mem_size, above_4g_mem_size;
83     PCIBus *pci_bus;
84     ISABus *isa_bus;
85     PCII440FXState *i440fx_state;
86     int piix3_devfn = -1;
87     qemu_irq *cpu_irq;
88     qemu_irq *gsi;
89     qemu_irq *i8259;
90     qemu_irq *smi_irq;
91     GSIState *gsi_state;
92     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
93     BusState *idebus[MAX_IDE_BUS];
94     ISADevice *rtc_state;
95     ISADevice *floppy;
96     MemoryRegion *ram_memory;
97     MemoryRegion *pci_memory;
98     MemoryRegion *rom_memory;
99     DeviceState *icc_bridge;
100     FWCfgState *fw_cfg = NULL;
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 
171     if (smbios_defaults) {
172         MachineClass *mc = MACHINE_GET_CLASS(machine);
173         /* These values are guest ABI, do not change */
174         smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
175                             mc->name, smbios_legacy_mode);
176     }
177 
178     /* allocate ram and load rom/bios */
179     if (!xen_enabled()) {
180         fw_cfg = pc_memory_init(machine, system_memory,
181                                 below_4g_mem_size, above_4g_mem_size,
182                                 rom_memory, &ram_memory, guest_info);
183     } else if (machine->kernel_filename != NULL) {
184         /* For xen HVM direct kernel boot, load linux here */
185         fw_cfg = xen_load_linux(machine->kernel_filename,
186                                 machine->kernel_cmdline,
187                                 machine->initrd_filename,
188                                 below_4g_mem_size,
189                                 guest_info);
190     }
191 
192     gsi_state = g_malloc0(sizeof(*gsi_state));
193     if (kvm_irqchip_in_kernel()) {
194         kvm_pc_setup_irq_routing(pci_enabled);
195         gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
196                                  GSI_NUM_PINS);
197     } else {
198         gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
199     }
200 
201     if (pci_enabled) {
202         pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
203                               system_memory, system_io, machine->ram_size,
204                               below_4g_mem_size,
205                               above_4g_mem_size,
206                               pci_memory, ram_memory);
207     } else {
208         pci_bus = NULL;
209         i440fx_state = NULL;
210         isa_bus = isa_bus_new(NULL, system_io);
211         no_hpet = 1;
212     }
213     isa_bus_irqs(isa_bus, gsi);
214 
215     if (kvm_irqchip_in_kernel()) {
216         i8259 = kvm_i8259_init(isa_bus);
217     } else if (xen_enabled()) {
218         i8259 = xen_interrupt_controller_init();
219     } else {
220         cpu_irq = pc_allocate_cpu_irq();
221         i8259 = i8259_init(isa_bus, cpu_irq[0]);
222     }
223 
224     for (i = 0; i < ISA_NUM_IRQS; i++) {
225         gsi_state->i8259_irq[i] = i8259[i];
226     }
227     if (pci_enabled) {
228         ioapic_init_gsi(gsi_state, "i440fx");
229     }
230     qdev_init_nofail(icc_bridge);
231 
232     pc_register_ferr_irq(gsi[13]);
233 
234     pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
235 
236     /* init basic PC hardware */
237     pc_basic_device_init(isa_bus, gsi, &rtc_state, &floppy, xen_enabled(),
238         0x4);
239 
240     pc_nic_init(isa_bus, pci_bus);
241 
242     ide_drive_get(hd, MAX_IDE_BUS);
243     if (pci_enabled) {
244         PCIDevice *dev;
245         if (xen_enabled()) {
246             dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1);
247         } else {
248             dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1);
249         }
250         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
251         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
252     } else {
253         for(i = 0; i < MAX_IDE_BUS; i++) {
254             ISADevice *dev;
255             char busname[] = "ide.0";
256             dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
257                                ide_irq[i],
258                                hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
259             /*
260              * The ide bus name is ide.0 for the first bus and ide.1 for the
261              * second one.
262              */
263             busname[4] = '0' + i;
264             idebus[i] = qdev_get_child_bus(DEVICE(dev), busname);
265         }
266     }
267 
268     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, machine->boot_order,
269                  floppy, idebus[0], idebus[1], rtc_state);
270 
271     if (pci_enabled && usb_enabled(false)) {
272         pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
273     }
274 
275     if (pci_enabled && acpi_enabled) {
276         DeviceState *piix4_pm;
277         I2CBus *smbus;
278 
279         smi_irq = qemu_allocate_irqs(pc_acpi_smi_interrupt, first_cpu, 1);
280         /* TODO: Populate SPD eeprom data.  */
281         smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
282                               gsi[9], *smi_irq,
283                               kvm_enabled(), fw_cfg, &piix4_pm);
284         smbus_eeprom_init(smbus, 8, NULL, 0);
285 
286         object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
287                                  TYPE_HOTPLUG_HANDLER,
288                                  (Object **)&pc_machine->acpi_dev,
289                                  object_property_allow_set_link,
290                                  OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
291         object_property_set_link(OBJECT(machine), OBJECT(piix4_pm),
292                                  PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
293     }
294 
295     if (pci_enabled) {
296         pc_pci_device_init(pci_bus);
297     }
298 }
299 
300 static void pc_init_pci(MachineState *machine)
301 {
302     pc_init1(machine, 1, 1);
303 }
304 
305 static void pc_compat_2_0(MachineState *machine)
306 {
307     /* This value depends on the actual DSDT and SSDT compiled into
308      * the source QEMU; unfortunately it depends on the binary and
309      * not on the machine type, so we cannot make pc-i440fx-1.7 work on
310      * both QEMU 1.7 and QEMU 2.0.
311      *
312      * Large variations cause migration to fail for more than one
313      * consecutive value of the "-smp" maxcpus option.
314      *
315      * For small variations of the kind caused by different iasl versions,
316      * the 4k rounding usually leaves slack.  However, there could be still
317      * one or two values that break.  For QEMU 1.7 and QEMU 2.0 the
318      * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
319      *
320      * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
321      * QEMU 1.7 it is 6414.  For RHEL/CentOS 7.0 it is 6418.
322      */
323     legacy_acpi_table_size = 6652;
324     smbios_legacy_mode = true;
325     has_reserved_memory = false;
326 }
327 
328 static void pc_compat_1_7(MachineState *machine)
329 {
330     pc_compat_2_0(machine);
331     smbios_defaults = false;
332     gigabyte_align = false;
333     option_rom_has_mr = true;
334     legacy_acpi_table_size = 6414;
335     x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
336 }
337 
338 static void pc_compat_1_6(MachineState *machine)
339 {
340     pc_compat_1_7(machine);
341     rom_file_has_mr = false;
342     has_acpi_build = false;
343 }
344 
345 static void pc_compat_1_5(MachineState *machine)
346 {
347     pc_compat_1_6(machine);
348 }
349 
350 static void pc_compat_1_4(MachineState *machine)
351 {
352     pc_compat_1_5(machine);
353     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
354     x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
355 }
356 
357 static void pc_compat_1_3(MachineState *machine)
358 {
359     pc_compat_1_4(machine);
360     enable_compat_apic_id_mode();
361 }
362 
363 /* PC compat function for pc-0.14 to pc-1.2 */
364 static void pc_compat_1_2(MachineState *machine)
365 {
366     pc_compat_1_3(machine);
367     x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
368 }
369 
370 static void pc_init_pci_2_0(MachineState *machine)
371 {
372     pc_compat_2_0(machine);
373     pc_init_pci(machine);
374 }
375 
376 static void pc_init_pci_1_7(MachineState *machine)
377 {
378     pc_compat_1_7(machine);
379     pc_init_pci(machine);
380 }
381 
382 static void pc_init_pci_1_6(MachineState *machine)
383 {
384     pc_compat_1_6(machine);
385     pc_init_pci(machine);
386 }
387 
388 static void pc_init_pci_1_5(MachineState *machine)
389 {
390     pc_compat_1_5(machine);
391     pc_init_pci(machine);
392 }
393 
394 static void pc_init_pci_1_4(MachineState *machine)
395 {
396     pc_compat_1_4(machine);
397     pc_init_pci(machine);
398 }
399 
400 static void pc_init_pci_1_3(MachineState *machine)
401 {
402     pc_compat_1_3(machine);
403     pc_init_pci(machine);
404 }
405 
406 /* PC machine init function for pc-0.14 to pc-1.2 */
407 static void pc_init_pci_1_2(MachineState *machine)
408 {
409     pc_compat_1_2(machine);
410     pc_init_pci(machine);
411 }
412 
413 /* PC init function for pc-0.10 to pc-0.13 */
414 static void pc_init_pci_no_kvmclock(MachineState *machine)
415 {
416     pc_compat_1_2(machine);
417     pc_init1(machine, 1, 0);
418 }
419 
420 static void pc_init_isa(MachineState *machine)
421 {
422     has_acpi_build = false;
423     smbios_defaults = false;
424     gigabyte_align = false;
425     smbios_legacy_mode = true;
426     has_reserved_memory = false;
427     option_rom_has_mr = true;
428     rom_file_has_mr = false;
429     if (!machine->cpu_model) {
430         machine->cpu_model = "486";
431     }
432     x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
433     enable_compat_apic_id_mode();
434     pc_init1(machine, 0, 1);
435 }
436 
437 #ifdef CONFIG_XEN
438 static void pc_xen_hvm_init(MachineState *machine)
439 {
440     PCIBus *bus;
441 
442     pc_init_pci(machine);
443 
444     bus = pci_find_primary_bus();
445     if (bus != NULL) {
446         pci_create_simple(bus, -1, "xen-platform");
447     }
448 }
449 #endif
450 
451 #define PC_I440FX_MACHINE_OPTIONS \
452     PC_DEFAULT_MACHINE_OPTIONS, \
453     .desc = "Standard PC (i440FX + PIIX, 1996)", \
454     .hot_add_cpu = pc_hot_add_cpu
455 
456 #define PC_I440FX_2_2_MACHINE_OPTIONS                           \
457     PC_I440FX_MACHINE_OPTIONS,                                  \
458     .default_machine_opts = "firmware=bios-256k.bin"
459 
460 static QEMUMachine pc_i440fx_machine_v2_2 = {
461     PC_I440FX_2_2_MACHINE_OPTIONS,
462     .name = "pc-i440fx-2.2",
463     .alias = "pc",
464     .init = pc_init_pci,
465     .is_default = 1,
466 };
467 
468 #define PC_I440FX_2_1_MACHINE_OPTIONS PC_I440FX_2_2_MACHINE_OPTIONS
469 
470 static QEMUMachine pc_i440fx_machine_v2_1 = {
471     PC_I440FX_2_1_MACHINE_OPTIONS,
472     .name = "pc-i440fx-2.1",
473     .init = pc_init_pci,
474     .compat_props = (GlobalProperty[]) {
475         PC_COMPAT_2_1,
476         { /* end of list */ }
477     },
478 };
479 
480 #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS
481 
482 static QEMUMachine pc_i440fx_machine_v2_0 = {
483     PC_I440FX_2_0_MACHINE_OPTIONS,
484     .name = "pc-i440fx-2.0",
485     .init = pc_init_pci_2_0,
486     .compat_props = (GlobalProperty[]) {
487         PC_COMPAT_2_0,
488         { /* end of list */ }
489     },
490 };
491 
492 #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
493 
494 static QEMUMachine pc_i440fx_machine_v1_7 = {
495     PC_I440FX_1_7_MACHINE_OPTIONS,
496     .name = "pc-i440fx-1.7",
497     .init = pc_init_pci_1_7,
498     .compat_props = (GlobalProperty[]) {
499         PC_COMPAT_1_7,
500         { /* end of list */ }
501     },
502 };
503 
504 #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS
505 
506 static QEMUMachine pc_i440fx_machine_v1_6 = {
507     PC_I440FX_1_6_MACHINE_OPTIONS,
508     .name = "pc-i440fx-1.6",
509     .init = pc_init_pci_1_6,
510     .compat_props = (GlobalProperty[]) {
511         PC_COMPAT_1_6,
512         { /* end of list */ }
513     },
514 };
515 
516 static QEMUMachine pc_i440fx_machine_v1_5 = {
517     PC_I440FX_1_6_MACHINE_OPTIONS,
518     .name = "pc-i440fx-1.5",
519     .init = pc_init_pci_1_5,
520     .compat_props = (GlobalProperty[]) {
521         PC_COMPAT_1_5,
522         { /* end of list */ }
523     },
524 };
525 
526 #define PC_I440FX_1_4_MACHINE_OPTIONS \
527     PC_I440FX_1_6_MACHINE_OPTIONS, \
528     .hot_add_cpu = NULL
529 
530 static QEMUMachine pc_i440fx_machine_v1_4 = {
531     PC_I440FX_1_4_MACHINE_OPTIONS,
532     .name = "pc-i440fx-1.4",
533     .init = pc_init_pci_1_4,
534     .compat_props = (GlobalProperty[]) {
535         PC_COMPAT_1_4,
536         { /* end of list */ }
537     },
538 };
539 
540 #define PC_COMPAT_1_3 \
541 	PC_COMPAT_1_4, \
542         {\
543             .driver   = "usb-tablet",\
544             .property = "usb_version",\
545             .value    = stringify(1),\
546         },{\
547             .driver   = "virtio-net-pci",\
548             .property = "ctrl_mac_addr",\
549             .value    = "off",      \
550         },{ \
551             .driver   = "virtio-net-pci", \
552             .property = "mq", \
553             .value    = "off", \
554         }, {\
555             .driver   = "e1000",\
556             .property = "autonegotiation",\
557             .value    = "off",\
558         }
559 
560 static QEMUMachine pc_machine_v1_3 = {
561     PC_I440FX_1_4_MACHINE_OPTIONS,
562     .name = "pc-1.3",
563     .init = pc_init_pci_1_3,
564     .compat_props = (GlobalProperty[]) {
565         PC_COMPAT_1_3,
566         { /* end of list */ }
567     },
568 };
569 
570 #define PC_COMPAT_1_2 \
571         PC_COMPAT_1_3,\
572         {\
573             .driver   = "nec-usb-xhci",\
574             .property = "msi",\
575             .value    = "off",\
576         },{\
577             .driver   = "nec-usb-xhci",\
578             .property = "msix",\
579             .value    = "off",\
580         },{\
581             .driver   = "ivshmem",\
582             .property = "use64",\
583             .value    = "0",\
584         },{\
585             .driver   = "qxl",\
586             .property = "revision",\
587             .value    = stringify(3),\
588         },{\
589             .driver   = "qxl-vga",\
590             .property = "revision",\
591             .value    = stringify(3),\
592         },{\
593             .driver   = "VGA",\
594             .property = "mmio",\
595             .value    = "off",\
596         }
597 
598 #define PC_I440FX_1_2_MACHINE_OPTIONS \
599     PC_I440FX_1_4_MACHINE_OPTIONS, \
600     .init = pc_init_pci_1_2
601 
602 static QEMUMachine pc_machine_v1_2 = {
603     PC_I440FX_1_2_MACHINE_OPTIONS,
604     .name = "pc-1.2",
605     .compat_props = (GlobalProperty[]) {
606         PC_COMPAT_1_2,
607         { /* end of list */ }
608     },
609 };
610 
611 #define PC_COMPAT_1_1 \
612         PC_COMPAT_1_2,\
613         {\
614             .driver   = "virtio-scsi-pci",\
615             .property = "hotplug",\
616             .value    = "off",\
617         },{\
618             .driver   = "virtio-scsi-pci",\
619             .property = "param_change",\
620             .value    = "off",\
621         },{\
622             .driver   = "VGA",\
623             .property = "vgamem_mb",\
624             .value    = stringify(8),\
625         },{\
626             .driver   = "vmware-svga",\
627             .property = "vgamem_mb",\
628             .value    = stringify(8),\
629         },{\
630             .driver   = "qxl-vga",\
631             .property = "vgamem_mb",\
632             .value    = stringify(8),\
633         },{\
634             .driver   = "qxl",\
635             .property = "vgamem_mb",\
636             .value    = stringify(8),\
637         },{\
638             .driver   = "virtio-blk-pci",\
639             .property = "config-wce",\
640             .value    = "off",\
641         }
642 
643 static QEMUMachine pc_machine_v1_1 = {
644     PC_I440FX_1_2_MACHINE_OPTIONS,
645     .name = "pc-1.1",
646     .compat_props = (GlobalProperty[]) {
647         PC_COMPAT_1_1,
648         { /* end of list */ }
649     },
650 };
651 
652 #define PC_COMPAT_1_0 \
653         PC_COMPAT_1_1,\
654         {\
655             .driver   = TYPE_ISA_FDC,\
656             .property = "check_media_rate",\
657             .value    = "off",\
658         }, {\
659             .driver   = "virtio-balloon-pci",\
660             .property = "class",\
661             .value    = stringify(PCI_CLASS_MEMORY_RAM),\
662         },{\
663             .driver   = "apic",\
664             .property = "vapic",\
665             .value    = "off",\
666         },{\
667             .driver   = TYPE_USB_DEVICE,\
668             .property = "full-path",\
669             .value    = "no",\
670         }
671 
672 static QEMUMachine pc_machine_v1_0 = {
673     PC_I440FX_1_2_MACHINE_OPTIONS,
674     .name = "pc-1.0",
675     .compat_props = (GlobalProperty[]) {
676         PC_COMPAT_1_0,
677         { /* end of list */ }
678     },
679     .hw_version = "1.0",
680 };
681 
682 #define PC_COMPAT_0_15 \
683         PC_COMPAT_1_0
684 
685 static QEMUMachine pc_machine_v0_15 = {
686     PC_I440FX_1_2_MACHINE_OPTIONS,
687     .name = "pc-0.15",
688     .compat_props = (GlobalProperty[]) {
689         PC_COMPAT_0_15,
690         { /* end of list */ }
691     },
692     .hw_version = "0.15",
693 };
694 
695 #define PC_COMPAT_0_14 \
696         PC_COMPAT_0_15,\
697         {\
698             .driver   = "virtio-blk-pci",\
699             .property = "event_idx",\
700             .value    = "off",\
701         },{\
702             .driver   = "virtio-serial-pci",\
703             .property = "event_idx",\
704             .value    = "off",\
705         },{\
706             .driver   = "virtio-net-pci",\
707             .property = "event_idx",\
708             .value    = "off",\
709         },{\
710             .driver   = "virtio-balloon-pci",\
711             .property = "event_idx",\
712             .value    = "off",\
713         }
714 
715 static QEMUMachine pc_machine_v0_14 = {
716     PC_I440FX_1_2_MACHINE_OPTIONS,
717     .name = "pc-0.14",
718     .compat_props = (GlobalProperty[]) {
719         PC_COMPAT_0_14,
720         {
721             .driver   = "qxl",
722             .property = "revision",
723             .value    = stringify(2),
724         },{
725             .driver   = "qxl-vga",
726             .property = "revision",
727             .value    = stringify(2),
728         },
729         { /* end of list */ }
730     },
731     .hw_version = "0.14",
732 };
733 
734 #define PC_COMPAT_0_13 \
735         PC_COMPAT_0_14,\
736         {\
737             .driver   = TYPE_PCI_DEVICE,\
738             .property = "command_serr_enable",\
739             .value    = "off",\
740         },{\
741             .driver   = "AC97",\
742             .property = "use_broken_id",\
743             .value    = stringify(1),\
744         }
745 
746 #define PC_I440FX_0_13_MACHINE_OPTIONS \
747     PC_I440FX_1_2_MACHINE_OPTIONS, \
748     .init = pc_init_pci_no_kvmclock
749 
750 static QEMUMachine pc_machine_v0_13 = {
751     PC_I440FX_0_13_MACHINE_OPTIONS,
752     .name = "pc-0.13",
753     .compat_props = (GlobalProperty[]) {
754         PC_COMPAT_0_13,
755         {
756             .driver   = "virtio-9p-pci",
757             .property = "vectors",
758             .value    = stringify(0),
759         },{
760             .driver   = "VGA",
761             .property = "rombar",
762             .value    = stringify(0),
763         },{
764             .driver   = "vmware-svga",
765             .property = "rombar",
766             .value    = stringify(0),
767         },
768         { /* end of list */ }
769     },
770     .hw_version = "0.13",
771 };
772 
773 #define PC_COMPAT_0_12 \
774         PC_COMPAT_0_13,\
775         {\
776             .driver   = "virtio-serial-pci",\
777             .property = "max_ports",\
778             .value    = stringify(1),\
779         },{\
780             .driver   = "virtio-serial-pci",\
781             .property = "vectors",\
782             .value    = stringify(0),\
783         },{\
784             .driver   = "usb-mouse",\
785             .property = "serial",\
786             .value    = "1",\
787         },{\
788             .driver   = "usb-tablet",\
789             .property = "serial",\
790             .value    = "1",\
791         },{\
792             .driver   = "usb-kbd",\
793             .property = "serial",\
794             .value    = "1",\
795         }
796 
797 static QEMUMachine pc_machine_v0_12 = {
798     PC_I440FX_0_13_MACHINE_OPTIONS,
799     .name = "pc-0.12",
800     .compat_props = (GlobalProperty[]) {
801         PC_COMPAT_0_12,
802         {
803             .driver   = "VGA",
804             .property = "rombar",
805             .value    = stringify(0),
806         },{
807             .driver   = "vmware-svga",
808             .property = "rombar",
809             .value    = stringify(0),
810         },
811         { /* end of list */ }
812     },
813     .hw_version = "0.12",
814 };
815 
816 #define PC_COMPAT_0_11 \
817         PC_COMPAT_0_12,\
818         {\
819             .driver   = "virtio-blk-pci",\
820             .property = "vectors",\
821             .value    = stringify(0),\
822         },{\
823             .driver   = TYPE_PCI_DEVICE,\
824             .property = "rombar",\
825             .value    = stringify(0),\
826         }
827 
828 static QEMUMachine pc_machine_v0_11 = {
829     PC_I440FX_0_13_MACHINE_OPTIONS,
830     .name = "pc-0.11",
831     .compat_props = (GlobalProperty[]) {
832         PC_COMPAT_0_11,
833         {
834             .driver   = "ide-drive",
835             .property = "ver",
836             .value    = "0.11",
837         },{
838             .driver   = "scsi-disk",
839             .property = "ver",
840             .value    = "0.11",
841         },
842         { /* end of list */ }
843     },
844     .hw_version = "0.11",
845 };
846 
847 static QEMUMachine pc_machine_v0_10 = {
848     PC_I440FX_0_13_MACHINE_OPTIONS,
849     .name = "pc-0.10",
850     .compat_props = (GlobalProperty[]) {
851         PC_COMPAT_0_11,
852         {
853             .driver   = "virtio-blk-pci",
854             .property = "class",
855             .value    = stringify(PCI_CLASS_STORAGE_OTHER),
856         },{
857             .driver   = "virtio-serial-pci",
858             .property = "class",
859             .value    = stringify(PCI_CLASS_DISPLAY_OTHER),
860         },{
861             .driver   = "virtio-net-pci",
862             .property = "vectors",
863             .value    = stringify(0),
864         },{
865             .driver   = "ide-drive",
866             .property = "ver",
867             .value    = "0.10",
868         },{
869             .driver   = "scsi-disk",
870             .property = "ver",
871             .value    = "0.10",
872         },
873         { /* end of list */ }
874     },
875     .hw_version = "0.10",
876 };
877 
878 static QEMUMachine isapc_machine = {
879     PC_COMMON_MACHINE_OPTIONS,
880     .name = "isapc",
881     .desc = "ISA-only PC",
882     .init = pc_init_isa,
883     .max_cpus = 1,
884     .compat_props = (GlobalProperty[]) {
885         { /* end of list */ }
886     },
887 };
888 
889 #ifdef CONFIG_XEN
890 static QEMUMachine xenfv_machine = {
891     PC_COMMON_MACHINE_OPTIONS,
892     .name = "xenfv",
893     .desc = "Xen Fully-virtualized PC",
894     .init = pc_xen_hvm_init,
895     .max_cpus = HVM_MAX_VCPUS,
896     .default_machine_opts = "accel=xen",
897     .hot_add_cpu = pc_hot_add_cpu,
898     .compat_props = (GlobalProperty[]) {
899         /* xenfv has no fwcfg and so does not load acpi from QEMU.
900          * as such new acpi features don't work.
901          */
902         {
903             .driver   = "PIIX4_PM",
904             .property = "acpi-pci-hotplug-with-bridge-support",
905             .value    = "off",
906         },
907         { /* end of list */ }
908     },
909 };
910 #endif
911 
912 static void pc_machine_init(void)
913 {
914     qemu_register_pc_machine(&pc_i440fx_machine_v2_2);
915     qemu_register_pc_machine(&pc_i440fx_machine_v2_1);
916     qemu_register_pc_machine(&pc_i440fx_machine_v2_0);
917     qemu_register_pc_machine(&pc_i440fx_machine_v1_7);
918     qemu_register_pc_machine(&pc_i440fx_machine_v1_6);
919     qemu_register_pc_machine(&pc_i440fx_machine_v1_5);
920     qemu_register_pc_machine(&pc_i440fx_machine_v1_4);
921     qemu_register_pc_machine(&pc_machine_v1_3);
922     qemu_register_pc_machine(&pc_machine_v1_2);
923     qemu_register_pc_machine(&pc_machine_v1_1);
924     qemu_register_pc_machine(&pc_machine_v1_0);
925     qemu_register_pc_machine(&pc_machine_v0_15);
926     qemu_register_pc_machine(&pc_machine_v0_14);
927     qemu_register_pc_machine(&pc_machine_v0_13);
928     qemu_register_pc_machine(&pc_machine_v0_12);
929     qemu_register_pc_machine(&pc_machine_v0_11);
930     qemu_register_pc_machine(&pc_machine_v0_10);
931     qemu_register_pc_machine(&isapc_machine);
932 #ifdef CONFIG_XEN
933     qemu_register_pc_machine(&xenfv_machine);
934 #endif
935 }
936 
937 machine_init(pc_machine_init);
938