xref: /qemu/hw/i386/pc_q35.c (revision 4884b7bfe962e659c0e20c1d0de6f307d58f09be)
1df2d8b3eSIsaku Yamahata /*
2df2d8b3eSIsaku Yamahata  * Q35 chipset based pc system emulator
3df2d8b3eSIsaku Yamahata  *
4df2d8b3eSIsaku Yamahata  * Copyright (c) 2003-2004 Fabrice Bellard
5df2d8b3eSIsaku Yamahata  * Copyright (c) 2009, 2010
6df2d8b3eSIsaku Yamahata  *               Isaku Yamahata <yamahata at valinux co jp>
7df2d8b3eSIsaku Yamahata  *               VA Linux Systems Japan K.K.
8df2d8b3eSIsaku Yamahata  * Copyright (C) 2012 Jason Baron <jbaron@redhat.com>
9df2d8b3eSIsaku Yamahata  *
10df2d8b3eSIsaku Yamahata  * This is based on pc.c, but heavily modified.
11df2d8b3eSIsaku Yamahata  *
12df2d8b3eSIsaku Yamahata  * Permission is hereby granted, free of charge, to any person obtaining a copy
13df2d8b3eSIsaku Yamahata  * of this software and associated documentation files (the "Software"), to deal
14df2d8b3eSIsaku Yamahata  * in the Software without restriction, including without limitation the rights
15df2d8b3eSIsaku Yamahata  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16df2d8b3eSIsaku Yamahata  * copies of the Software, and to permit persons to whom the Software is
17df2d8b3eSIsaku Yamahata  * furnished to do so, subject to the following conditions:
18df2d8b3eSIsaku Yamahata  *
19df2d8b3eSIsaku Yamahata  * The above copyright notice and this permission notice shall be included in
20df2d8b3eSIsaku Yamahata  * all copies or substantial portions of the Software.
21df2d8b3eSIsaku Yamahata  *
22df2d8b3eSIsaku Yamahata  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23df2d8b3eSIsaku Yamahata  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24df2d8b3eSIsaku Yamahata  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25df2d8b3eSIsaku Yamahata  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26df2d8b3eSIsaku Yamahata  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27df2d8b3eSIsaku Yamahata  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28df2d8b3eSIsaku Yamahata  * THE SOFTWARE.
29df2d8b3eSIsaku Yamahata  */
3083c9f4caSPaolo Bonzini #include "hw/hw.h"
3104920fc0SMichael S. Tsirkin #include "hw/loader.h"
329c17d615SPaolo Bonzini #include "sysemu/arch_init.h"
330d09e41aSPaolo Bonzini #include "hw/i2c/smbus.h"
3483c9f4caSPaolo Bonzini #include "hw/boards.h"
350d09e41aSPaolo Bonzini #include "hw/timer/mc146818rtc.h"
360d09e41aSPaolo Bonzini #include "hw/xen/xen.h"
379c17d615SPaolo Bonzini #include "sysemu/kvm.h"
3883c9f4caSPaolo Bonzini #include "hw/kvm/clock.h"
390d09e41aSPaolo Bonzini #include "hw/pci-host/q35.h"
40022c62cbSPaolo Bonzini #include "exec/address-spaces.h"
410d09e41aSPaolo Bonzini #include "hw/i386/ich9.h"
4260d8f328SWei Huang #include "hw/smbios/smbios.h"
43df2d8b3eSIsaku Yamahata #include "hw/ide/pci.h"
44df2d8b3eSIsaku Yamahata #include "hw/ide/ahci.h"
45df2d8b3eSIsaku Yamahata #include "hw/usb.h"
46c87b1520SDon Slutz #include "qemu/error-report.h"
4737fb569cSDr. David Alan Gilbert #include "migration/migration.h"
48df2d8b3eSIsaku Yamahata 
49df2d8b3eSIsaku Yamahata /* ICH9 AHCI has 6 ports */
50df2d8b3eSIsaku Yamahata #define MAX_SATA_PORTS     6
51df2d8b3eSIsaku Yamahata 
5272c194f7SMichael S. Tsirkin static bool has_acpi_build = true;
53384fb32eSMichael S. Tsirkin static bool rsdp_in_ram = true;
54e6667f71SGabriel L. Somlo static bool smbios_defaults = true;
55c97294ecSGabriel L. Somlo static bool smbios_legacy_mode;
56caad057bSEduardo Habkost static bool smbios_uuid_encoded = true;
574e17997dSMichael S. Tsirkin /* Make sure that guest addresses aligned at 1Gbyte boundaries get mapped to
584e17997dSMichael S. Tsirkin  * host addresses aligned at 1Gbyte boundaries.  This way we can use 1GByte
594e17997dSMichael S. Tsirkin  * pages in the host.
604e17997dSMichael S. Tsirkin  */
619a305c8fSGerd Hoffmann static bool gigabyte_align = true;
62de268e13SIgor Mammedov static bool has_reserved_memory = true;
633ab135f3SHu Tao 
64df2d8b3eSIsaku Yamahata /* PC hardware initialisation */
653ef96221SMarcel Apfelbaum static void pc_q35_init(MachineState *machine)
66df2d8b3eSIsaku Yamahata {
67ec68007aSEduardo Habkost     PCMachineState *pcms = PC_MACHINE(machine);
68df2d8b3eSIsaku Yamahata     Q35PCIHost *q35_host;
69ce88812fSHu Tao     PCIHostState *phb;
70df2d8b3eSIsaku Yamahata     PCIBus *host_bus;
71df2d8b3eSIsaku Yamahata     PCIDevice *lpc;
72df2d8b3eSIsaku Yamahata     BusState *idebus[MAX_SATA_PORTS];
73df2d8b3eSIsaku Yamahata     ISADevice *rtc_state;
74df2d8b3eSIsaku Yamahata     MemoryRegion *pci_memory;
75df2d8b3eSIsaku Yamahata     MemoryRegion *rom_memory;
76df2d8b3eSIsaku Yamahata     MemoryRegion *ram_memory;
77df2d8b3eSIsaku Yamahata     GSIState *gsi_state;
78df2d8b3eSIsaku Yamahata     ISABus *isa_bus;
79df2d8b3eSIsaku Yamahata     int pci_enabled = 1;
80df2d8b3eSIsaku Yamahata     qemu_irq *gsi;
81df2d8b3eSIsaku Yamahata     qemu_irq *i8259;
82df2d8b3eSIsaku Yamahata     int i;
83df2d8b3eSIsaku Yamahata     ICH9LPCState *ich9_lpc;
84df2d8b3eSIsaku Yamahata     PCIDevice *ahci;
853459a625SMichael S. Tsirkin     PcGuestInfo *guest_info;
86c87b1520SDon Slutz     ram_addr_t lowmem;
87d93162e1SJohn Snow     DriveInfo *hd[MAX_SATA_PORTS];
886cd2234cSLaszlo Ersek     MachineClass *mc = MACHINE_GET_CLASS(machine);
89f0513d2cSIgor Mammedov 
904e17997dSMichael S. Tsirkin     /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory
914e17997dSMichael S. Tsirkin      * and 256 Mbytes for PCI Express Enhanced Configuration Access Mapping
924e17997dSMichael S. Tsirkin      * also known as MMCFG).
934e17997dSMichael S. Tsirkin      * If it doesn't, we need to split it in chunks below and above 4G.
944e17997dSMichael S. Tsirkin      * In any case, try to make sure that guest addresses aligned at
954e17997dSMichael S. Tsirkin      * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
964e17997dSMichael S. Tsirkin      * For old machine types, use whatever split we used historically to avoid
974e17997dSMichael S. Tsirkin      * breaking migration.
984e17997dSMichael S. Tsirkin      */
993ef96221SMarcel Apfelbaum     if (machine->ram_size >= 0xb0000000) {
100c87b1520SDon Slutz         lowmem = gigabyte_align ? 0x80000000 : 0xb0000000;
101c87b1520SDon Slutz     } else {
102c87b1520SDon Slutz         lowmem = 0xb0000000;
103c87b1520SDon Slutz     }
104c87b1520SDon Slutz 
105a9dd38dbSStefan Weil     /* Handle the machine opt max-ram-below-4g.  It is basically doing
106c87b1520SDon Slutz      * min(qemu limit, user limit).
107c87b1520SDon Slutz      */
108ec68007aSEduardo Habkost     if (lowmem > pcms->max_ram_below_4g) {
109ec68007aSEduardo Habkost         lowmem = pcms->max_ram_below_4g;
110c87b1520SDon Slutz         if (machine->ram_size - lowmem > lowmem &&
111c87b1520SDon Slutz             lowmem & ((1ULL << 30) - 1)) {
112c87b1520SDon Slutz             error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
113c87b1520SDon Slutz                          ") not a multiple of 1G; possible bad performance.",
114ec68007aSEduardo Habkost                          pcms->max_ram_below_4g);
115c87b1520SDon Slutz         }
116c87b1520SDon Slutz     }
117c87b1520SDon Slutz 
118c87b1520SDon Slutz     if (machine->ram_size >= lowmem) {
119c0aa4e1eSEduardo Habkost         pcms->above_4g_mem_size = machine->ram_size - lowmem;
120c0aa4e1eSEduardo Habkost         pcms->below_4g_mem_size = lowmem;
121df2d8b3eSIsaku Yamahata     } else {
122c0aa4e1eSEduardo Habkost         pcms->above_4g_mem_size = 0;
123c0aa4e1eSEduardo Habkost         pcms->below_4g_mem_size = machine->ram_size;
124df2d8b3eSIsaku Yamahata     }
125df2d8b3eSIsaku Yamahata 
12691176e31SEduardo Habkost     if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
1273c2a9669SDon Slutz         fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
1283c2a9669SDon Slutz         exit(1);
1293c2a9669SDon Slutz     }
1303c2a9669SDon Slutz 
131*4884b7bfSZhu Guihua     pc_cpus_init(pcms);
1323c2a9669SDon Slutz     pc_acpi_init("q35-acpi-dsdt.aml");
1333c2a9669SDon Slutz 
1343c2a9669SDon Slutz     kvmclock_create();
1353c2a9669SDon Slutz 
136df2d8b3eSIsaku Yamahata     /* pci enabled */
137df2d8b3eSIsaku Yamahata     if (pci_enabled) {
138df2d8b3eSIsaku Yamahata         pci_memory = g_new(MemoryRegion, 1);
139286690e3SPaolo Bonzini         memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
140df2d8b3eSIsaku Yamahata         rom_memory = pci_memory;
141df2d8b3eSIsaku Yamahata     } else {
142df2d8b3eSIsaku Yamahata         pci_memory = NULL;
143df2d8b3eSIsaku Yamahata         rom_memory = get_system_memory();
144df2d8b3eSIsaku Yamahata     }
145df2d8b3eSIsaku Yamahata 
146b9cfc918SEduardo Habkost     guest_info = pc_guest_info_init(pcms);
1476dd2a5c9SPaolo Bonzini     guest_info->isapc_ram_fw = false;
14872c194f7SMichael S. Tsirkin     guest_info->has_acpi_build = has_acpi_build;
149de268e13SIgor Mammedov     guest_info->has_reserved_memory = has_reserved_memory;
150384fb32eSMichael S. Tsirkin     guest_info->rsdp_in_ram = rsdp_in_ram;
1513459a625SMichael S. Tsirkin 
15207fb6176SPaolo Bonzini     /* Migration was not supported in 2.0 for Q35, so do not bother
15307fb6176SPaolo Bonzini      * with this hack (see hw/i386/acpi-build.c).
15407fb6176SPaolo Bonzini      */
15507fb6176SPaolo Bonzini     guest_info->legacy_acpi_table_size = 0;
15607fb6176SPaolo Bonzini 
157e6667f71SGabriel L. Somlo     if (smbios_defaults) {
158b29ad07eSMarkus Armbruster         /* These values are guest ABI, do not change */
159e6667f71SGabriel L. Somlo         smbios_set_defaults("QEMU", "Standard PC (Q35 + ICH9, 2009)",
16086299120SWei Huang                             mc->name, smbios_legacy_mode, smbios_uuid_encoded,
16186299120SWei Huang                             SMBIOS_ENTRY_POINT_21);
162b29ad07eSMarkus Armbruster     }
163b29ad07eSMarkus Armbruster 
164df2d8b3eSIsaku Yamahata     /* allocate ram and load rom/bios */
165df2d8b3eSIsaku Yamahata     if (!xen_enabled()) {
16662b160c0SEduardo Habkost         pc_memory_init(pcms, get_system_memory(),
1673459a625SMichael S. Tsirkin                        rom_memory, &ram_memory, guest_info);
168df2d8b3eSIsaku Yamahata     }
169df2d8b3eSIsaku Yamahata 
170df2d8b3eSIsaku Yamahata     /* irq lines */
171df2d8b3eSIsaku Yamahata     gsi_state = g_malloc0(sizeof(*gsi_state));
172df2d8b3eSIsaku Yamahata     if (kvm_irqchip_in_kernel()) {
173df2d8b3eSIsaku Yamahata         kvm_pc_setup_irq_routing(pci_enabled);
174df2d8b3eSIsaku Yamahata         gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
175df2d8b3eSIsaku Yamahata                                  GSI_NUM_PINS);
176df2d8b3eSIsaku Yamahata     } else {
177df2d8b3eSIsaku Yamahata         gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
178df2d8b3eSIsaku Yamahata     }
179df2d8b3eSIsaku Yamahata 
180df2d8b3eSIsaku Yamahata     /* create pci host bus */
181df2d8b3eSIsaku Yamahata     q35_host = Q35_HOST_DEVICE(qdev_create(NULL, TYPE_Q35_HOST_DEVICE));
182df2d8b3eSIsaku Yamahata 
183c52dc697SIgor Mammedov     object_property_add_child(qdev_get_machine(), "q35", OBJECT(q35_host), NULL);
184df2d8b3eSIsaku Yamahata     q35_host->mch.ram_memory = ram_memory;
185df2d8b3eSIsaku Yamahata     q35_host->mch.pci_address_space = pci_memory;
186df2d8b3eSIsaku Yamahata     q35_host->mch.system_memory = get_system_memory();
187c7e775e4SDong Xu Wang     q35_host->mch.address_space_io = get_system_io();
188c0aa4e1eSEduardo Habkost     q35_host->mch.below_4g_mem_size = pcms->below_4g_mem_size;
189c0aa4e1eSEduardo Habkost     q35_host->mch.above_4g_mem_size = pcms->above_4g_mem_size;
1903459a625SMichael S. Tsirkin     q35_host->mch.guest_info = guest_info;
191df2d8b3eSIsaku Yamahata     /* pci */
192df2d8b3eSIsaku Yamahata     qdev_init_nofail(DEVICE(q35_host));
193ce88812fSHu Tao     phb = PCI_HOST_BRIDGE(q35_host);
194ce88812fSHu Tao     host_bus = phb->bus;
195df2d8b3eSIsaku Yamahata     /* create ISA bus */
196df2d8b3eSIsaku Yamahata     lpc = pci_create_simple_multifunction(host_bus, PCI_DEVFN(ICH9_LPC_DEV,
197df2d8b3eSIsaku Yamahata                                           ICH9_LPC_FUNC), true,
198df2d8b3eSIsaku Yamahata                                           TYPE_ICH9_LPC_DEVICE);
199781bbd6bSIgor Mammedov 
200781bbd6bSIgor Mammedov     object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
201781bbd6bSIgor Mammedov                              TYPE_HOTPLUG_HANDLER,
202ec68007aSEduardo Habkost                              (Object **)&pcms->acpi_dev,
203781bbd6bSIgor Mammedov                              object_property_allow_set_link,
204781bbd6bSIgor Mammedov                              OBJ_PROP_LINK_UNREF_ON_RELEASE, &error_abort);
205781bbd6bSIgor Mammedov     object_property_set_link(OBJECT(machine), OBJECT(lpc),
206781bbd6bSIgor Mammedov                              PC_MACHINE_ACPI_DEVICE_PROP, &error_abort);
207781bbd6bSIgor Mammedov 
208df2d8b3eSIsaku Yamahata     ich9_lpc = ICH9_LPC_DEVICE(lpc);
209df2d8b3eSIsaku Yamahata     ich9_lpc->pic = gsi;
210df2d8b3eSIsaku Yamahata     ich9_lpc->ioapic = gsi_state->ioapic_irq;
211df2d8b3eSIsaku Yamahata     pci_bus_irqs(host_bus, ich9_lpc_set_irq, ich9_lpc_map_irq, ich9_lpc,
212df2d8b3eSIsaku Yamahata                  ICH9_LPC_NB_PIRQS);
21391c3f2f0SJason Baron     pci_bus_set_route_irq_fn(host_bus, ich9_route_intx_pin_to_irq);
214df2d8b3eSIsaku Yamahata     isa_bus = ich9_lpc->isa_bus;
215df2d8b3eSIsaku Yamahata 
216df2d8b3eSIsaku Yamahata     /*end early*/
217df2d8b3eSIsaku Yamahata     isa_bus_irqs(isa_bus, gsi);
218df2d8b3eSIsaku Yamahata 
219df2d8b3eSIsaku Yamahata     if (kvm_irqchip_in_kernel()) {
220df2d8b3eSIsaku Yamahata         i8259 = kvm_i8259_init(isa_bus);
221df2d8b3eSIsaku Yamahata     } else if (xen_enabled()) {
222df2d8b3eSIsaku Yamahata         i8259 = xen_interrupt_controller_init();
223df2d8b3eSIsaku Yamahata     } else {
2240b0cc076SShannon Zhao         i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
225df2d8b3eSIsaku Yamahata     }
226df2d8b3eSIsaku Yamahata 
227df2d8b3eSIsaku Yamahata     for (i = 0; i < ISA_NUM_IRQS; i++) {
228df2d8b3eSIsaku Yamahata         gsi_state->i8259_irq[i] = i8259[i];
229df2d8b3eSIsaku Yamahata     }
230df2d8b3eSIsaku Yamahata     if (pci_enabled) {
231552b48f4SJohn Snow         ioapic_init_gsi(gsi_state, "q35");
232df2d8b3eSIsaku Yamahata     }
233df2d8b3eSIsaku Yamahata 
234df2d8b3eSIsaku Yamahata     pc_register_ferr_irq(gsi[13]);
235df2d8b3eSIsaku Yamahata 
236ec68007aSEduardo Habkost     assert(pcms->vmport != ON_OFF_AUTO_MAX);
237ec68007aSEduardo Habkost     if (pcms->vmport == ON_OFF_AUTO_AUTO) {
238ec68007aSEduardo Habkost         pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
239d1048befSDon Slutz     }
240d1048befSDon Slutz 
241df2d8b3eSIsaku Yamahata     /* init basic PC hardware */
242220a8846SLaszlo Ersek     pc_basic_device_init(isa_bus, gsi, &rtc_state, !mc->no_floppy,
243ec68007aSEduardo Habkost                          (pcms->vmport != ON_OFF_AUTO_ON), 0xff0104);
244df2d8b3eSIsaku Yamahata 
245df2d8b3eSIsaku Yamahata     /* connect pm stuff to lpc */
246ec68007aSEduardo Habkost     ich9_lpc_pm_init(lpc, pc_machine_is_smm_enabled(pcms), !mc->no_tco);
247df2d8b3eSIsaku Yamahata 
248df2d8b3eSIsaku Yamahata     /* ahci and SATA device, for q35 1 ahci controller is built-in */
249df2d8b3eSIsaku Yamahata     ahci = pci_create_simple_multifunction(host_bus,
250df2d8b3eSIsaku Yamahata                                            PCI_DEVFN(ICH9_SATA1_DEV,
251df2d8b3eSIsaku Yamahata                                                      ICH9_SATA1_FUNC),
252df2d8b3eSIsaku Yamahata                                            true, "ich9-ahci");
253df2d8b3eSIsaku Yamahata     idebus[0] = qdev_get_child_bus(&ahci->qdev, "ide.0");
254df2d8b3eSIsaku Yamahata     idebus[1] = qdev_get_child_bus(&ahci->qdev, "ide.1");
25501a2050fSPeter Maydell     g_assert(MAX_SATA_PORTS == ICH_AHCI(ahci)->ahci.ports);
256d93162e1SJohn Snow     ide_drive_get(hd, ICH_AHCI(ahci)->ahci.ports);
257d93162e1SJohn Snow     ahci_ide_create_devs(ahci, hd);
258df2d8b3eSIsaku Yamahata 
259de77a243SMarcel Apfelbaum     if (usb_enabled()) {
260df2d8b3eSIsaku Yamahata         /* Should we create 6 UHCI according to ich9 spec? */
261df2d8b3eSIsaku Yamahata         ehci_create_ich9_with_companions(host_bus, 0x1d);
262df2d8b3eSIsaku Yamahata     }
263df2d8b3eSIsaku Yamahata 
264df2d8b3eSIsaku Yamahata     /* TODO: Populate SPD eeprom data.  */
265df2d8b3eSIsaku Yamahata     smbus_eeprom_init(ich9_smb_init(host_bus,
266df2d8b3eSIsaku Yamahata                                     PCI_DEVFN(ICH9_SMB_DEV, ICH9_SMB_FUNC),
267df2d8b3eSIsaku Yamahata                                     0xb100),
268df2d8b3eSIsaku Yamahata                       8, NULL, 0);
269df2d8b3eSIsaku Yamahata 
27088076854SEduardo Habkost     pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
271df2d8b3eSIsaku Yamahata 
272df2d8b3eSIsaku Yamahata     /* the rest devices to which pci devfn is automatically assigned */
273df2d8b3eSIsaku Yamahata     pc_vga_init(isa_bus, host_bus);
274df2d8b3eSIsaku Yamahata     pc_nic_init(isa_bus, host_bus);
275df2d8b3eSIsaku Yamahata     if (pci_enabled) {
276df2d8b3eSIsaku Yamahata         pc_pci_device_init(host_bus);
277df2d8b3eSIsaku Yamahata     }
278df2d8b3eSIsaku Yamahata }
279df2d8b3eSIsaku Yamahata 
28079859507SEduardo Habkost /* Looking for a pc_compat_2_4() function? It doesn't exist.
28179859507SEduardo Habkost  * pc_compat_*() functions that run on machine-init time and
28279859507SEduardo Habkost  * change global QEMU state are deprecated. Please don't create
28379859507SEduardo Habkost  * one, and implement any pc-*-2.4 (and newer) compat code in
28479859507SEduardo Habkost  * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().
28579859507SEduardo Habkost  */
28679859507SEduardo Habkost 
2875cb50e0aSJason Wang static void pc_compat_2_3(MachineState *machine)
2885cb50e0aSJason Wang {
289355023f2SPaolo Bonzini     PCMachineState *pcms = PC_MACHINE(machine);
29037fb569cSDr. David Alan Gilbert     savevm_skip_section_footers();
291355023f2SPaolo Bonzini     if (kvm_enabled()) {
292355023f2SPaolo Bonzini         pcms->smm = ON_OFF_AUTO_OFF;
293355023f2SPaolo Bonzini     }
29413d16814SJuan Quintela     global_state_set_optional();
29561964c23SJuan Quintela     savevm_skip_configuration();
2965cb50e0aSJason Wang }
2975cb50e0aSJason Wang 
29864bbd372SPaolo Bonzini static void pc_compat_2_2(MachineState *machine)
29964bbd372SPaolo Bonzini {
3005cb50e0aSJason Wang     pc_compat_2_3(machine);
301384fb32eSMichael S. Tsirkin     rsdp_in_ram = false;
30254ed388bSAlexander Graf     machine->suppress_vmdesc = true;
30364bbd372SPaolo Bonzini }
30464bbd372SPaolo Bonzini 
3052cad57c7SEduardo Habkost static void pc_compat_2_1(MachineState *machine)
3062cad57c7SEduardo Habkost {
30791aa70abSIgor Mammedov     PCMachineState *pcms = PC_MACHINE(machine);
30891aa70abSIgor Mammedov 
30964bbd372SPaolo Bonzini     pc_compat_2_2(machine);
31091aa70abSIgor Mammedov     pcms->enforce_aligned_dimm = false;
311caad057bSEduardo Habkost     smbios_uuid_encoded = false;
3125114e842SEduardo Habkost     x86_cpu_change_kvm_default("svm", NULL);
3132cad57c7SEduardo Habkost }
3142cad57c7SEduardo Habkost 
3153ef96221SMarcel Apfelbaum static void pc_compat_2_0(MachineState *machine)
3163458b2b0SMichael S. Tsirkin {
3172cad57c7SEduardo Habkost     pc_compat_2_1(machine);
318c97294ecSGabriel L. Somlo     smbios_legacy_mode = true;
319de268e13SIgor Mammedov     has_reserved_memory = false;
320927766c7SMichael S. Tsirkin     pc_set_legacy_acpi_data_size();
3213458b2b0SMichael S. Tsirkin }
3223458b2b0SMichael S. Tsirkin 
3233ef96221SMarcel Apfelbaum static void pc_compat_1_7(MachineState *machine)
324b29ad07eSMarkus Armbruster {
3253ef96221SMarcel Apfelbaum     pc_compat_2_0(machine);
326e6667f71SGabriel L. Somlo     smbios_defaults = false;
3279a305c8fSGerd Hoffmann     gigabyte_align = false;
328ac41881bSMichael S. Tsirkin     option_rom_has_mr = true;
3295114e842SEduardo Habkost     x86_cpu_change_kvm_default("x2apic", NULL);
330b29ad07eSMarkus Armbruster }
331b29ad07eSMarkus Armbruster 
3323ef96221SMarcel Apfelbaum static void pc_compat_1_6(MachineState *machine)
333f8c457b8SMichael S. Tsirkin {
3343ef96221SMarcel Apfelbaum     pc_compat_1_7(machine);
33598bc3ab0SMichael S. Tsirkin     rom_file_has_mr = false;
33672c194f7SMichael S. Tsirkin     has_acpi_build = false;
33789b439f3SEduardo Habkost }
33889b439f3SEduardo Habkost 
3393ef96221SMarcel Apfelbaum static void pc_compat_1_5(MachineState *machine)
34089b439f3SEduardo Habkost {
3413ef96221SMarcel Apfelbaum     pc_compat_1_6(machine);
34289b439f3SEduardo Habkost }
34389b439f3SEduardo Habkost 
3443ef96221SMarcel Apfelbaum static void pc_compat_1_4(MachineState *machine)
34589b439f3SEduardo Habkost {
3463ef96221SMarcel Apfelbaum     pc_compat_1_5(machine);
34789b439f3SEduardo Habkost }
34889b439f3SEduardo Habkost 
34999fbeafeSEduardo Habkost #define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \
35099fbeafeSEduardo Habkost     static void pc_init_##suffix(MachineState *machine) \
35199fbeafeSEduardo Habkost     { \
35299fbeafeSEduardo Habkost         void (*compat)(MachineState *m) = (compatfn); \
35399fbeafeSEduardo Habkost         if (compat) { \
35499fbeafeSEduardo Habkost             compat(machine); \
35599fbeafeSEduardo Habkost         } \
35699fbeafeSEduardo Habkost         pc_q35_init(machine); \
35799fbeafeSEduardo Habkost     } \
35899fbeafeSEduardo Habkost     DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
3595cb50e0aSJason Wang 
3609953f882SMarkus Armbruster 
361865906f7SEduardo Habkost static void pc_q35_machine_options(MachineClass *m)
362fddd179aSEduardo Habkost {
363fddd179aSEduardo Habkost     m->family = "pc_q35";
364fddd179aSEduardo Habkost     m->desc = "Standard PC (Q35 + ICH9, 2009)";
365fddd179aSEduardo Habkost     m->hot_add_cpu = pc_hot_add_cpu;
366fddd179aSEduardo Habkost     m->units_per_default_bus = 1;
3670b7783a7SEduardo Habkost     m->default_machine_opts = "firmware=bios-256k.bin";
3680b7783a7SEduardo Habkost     m->default_display = "std";
3690b7783a7SEduardo Habkost     m->no_floppy = 1;
3700b7783a7SEduardo Habkost     m->no_tco = 0;
371fddd179aSEduardo Habkost }
372a0dba644SMichael S. Tsirkin 
37387e896abSEduardo Habkost static void pc_q35_2_5_machine_options(MachineClass *m)
37487e896abSEduardo Habkost {
37587e896abSEduardo Habkost     pc_q35_machine_options(m);
37687e896abSEduardo Habkost     m->alias = "q35";
37787e896abSEduardo Habkost }
37887e896abSEduardo Habkost 
37987e896abSEduardo Habkost DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
38087e896abSEduardo Habkost                    pc_q35_2_5_machine_options);
38187e896abSEduardo Habkost 
382865906f7SEduardo Habkost static void pc_q35_2_4_machine_options(MachineClass *m)
383fddd179aSEduardo Habkost {
3842f8b5008SIgor Mammedov     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
38587e896abSEduardo Habkost     pc_q35_2_5_machine_options(m);
38687e896abSEduardo Habkost     m->alias = NULL;
3872f8b5008SIgor Mammedov     pcmc->broken_reserved_end = true;
388aa8580cdSIgor Mammedov     pcmc->inter_dimm_gap = false;
38987e896abSEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
390fddd179aSEduardo Habkost }
391aeca6e8dSGerd Hoffmann 
39299fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
39325519b06SEduardo Habkost                    pc_q35_2_4_machine_options);
39461f219dfSEduardo Habkost 
3955cb50e0aSJason Wang 
396865906f7SEduardo Habkost static void pc_q35_2_3_machine_options(MachineClass *m)
397fddd179aSEduardo Habkost {
398fddd179aSEduardo Habkost     pc_q35_2_4_machine_options(m);
399473a4946SEduardo Habkost     m->no_floppy = 0;
40092055797SPaulo Alcantara     m->no_tco = 1;
401fddd179aSEduardo Habkost     m->alias = NULL;
40225519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
403fddd179aSEduardo Habkost }
4045cb50e0aSJason Wang 
40599fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v2_3, "pc-q35-2.3", pc_compat_2_3,
40625519b06SEduardo Habkost                    pc_q35_2_3_machine_options);
40761f219dfSEduardo Habkost 
40864bbd372SPaolo Bonzini 
409865906f7SEduardo Habkost static void pc_q35_2_2_machine_options(MachineClass *m)
410fddd179aSEduardo Habkost {
411fddd179aSEduardo Habkost     pc_q35_2_3_machine_options(m);
41225519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
413fddd179aSEduardo Habkost }
41464bbd372SPaolo Bonzini 
41599fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v2_2, "pc-q35-2.2", pc_compat_2_2,
41625519b06SEduardo Habkost                    pc_q35_2_2_machine_options);
41761f219dfSEduardo Habkost 
418f9f21873SJan Kiszka 
419865906f7SEduardo Habkost static void pc_q35_2_1_machine_options(MachineClass *m)
420fddd179aSEduardo Habkost {
421fddd179aSEduardo Habkost     pc_q35_2_2_machine_options(m);
422fddd179aSEduardo Habkost     m->default_display = NULL;
42325519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
424fddd179aSEduardo Habkost }
425f9f21873SJan Kiszka 
42699fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v2_1, "pc-q35-2.1", pc_compat_2_1,
42725519b06SEduardo Habkost                    pc_q35_2_1_machine_options);
42861f219dfSEduardo Habkost 
4293458b2b0SMichael S. Tsirkin 
430865906f7SEduardo Habkost static void pc_q35_2_0_machine_options(MachineClass *m)
431fddd179aSEduardo Habkost {
432fddd179aSEduardo Habkost     pc_q35_2_1_machine_options(m);
43325519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
434fddd179aSEduardo Habkost }
4353458b2b0SMichael S. Tsirkin 
43699fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0,
43725519b06SEduardo Habkost                    pc_q35_2_0_machine_options);
43861f219dfSEduardo Habkost 
439aeca6e8dSGerd Hoffmann 
440865906f7SEduardo Habkost static void pc_q35_1_7_machine_options(MachineClass *m)
441fddd179aSEduardo Habkost {
442fddd179aSEduardo Habkost     pc_q35_2_0_machine_options(m);
443fddd179aSEduardo Habkost     m->default_machine_opts = NULL;
44425519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
445fddd179aSEduardo Habkost }
446e9845f09SVincenzo Maffione 
44799fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v1_7, "pc-q35-1.7", pc_compat_1_7,
44825519b06SEduardo Habkost                    pc_q35_1_7_machine_options);
44961f219dfSEduardo Habkost 
450e9845f09SVincenzo Maffione 
451865906f7SEduardo Habkost static void pc_q35_1_6_machine_options(MachineClass *m)
452fddd179aSEduardo Habkost {
453fddd179aSEduardo Habkost     pc_q35_machine_options(m);
45425519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
455fddd179aSEduardo Habkost }
456a0dba644SMichael S. Tsirkin 
45799fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v1_6, "pc-q35-1.6", pc_compat_1_6,
45825519b06SEduardo Habkost                    pc_q35_1_6_machine_options);
45961f219dfSEduardo Habkost 
46045053fdeSEduardo Habkost 
461865906f7SEduardo Habkost static void pc_q35_1_5_machine_options(MachineClass *m)
462fddd179aSEduardo Habkost {
463fddd179aSEduardo Habkost     pc_q35_1_6_machine_options(m);
46425519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
465fddd179aSEduardo Habkost }
466b6b5c8e4SEduardo Habkost 
46799fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v1_5, "pc-q35-1.5", pc_compat_1_5,
46825519b06SEduardo Habkost                    pc_q35_1_5_machine_options);
46961f219dfSEduardo Habkost 
470df2d8b3eSIsaku Yamahata 
471865906f7SEduardo Habkost static void pc_q35_1_4_machine_options(MachineClass *m)
472fddd179aSEduardo Habkost {
473fddd179aSEduardo Habkost     pc_q35_1_5_machine_options(m);
474fddd179aSEduardo Habkost     m->hot_add_cpu = NULL;
47525519b06SEduardo Habkost     SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
476fddd179aSEduardo Habkost }
477a0dba644SMichael S. Tsirkin 
47899fbeafeSEduardo Habkost DEFINE_Q35_MACHINE(v1_4, "pc-q35-1.4", pc_compat_1_4,
47925519b06SEduardo Habkost                    pc_q35_1_4_machine_options);
480