]> git.proxmox.com Git - mirror_qemu.git/blame - hw/i386/pc_piix.c
pc: memhotplug: fix incorrectly set reserved-memory-end
[mirror_qemu.git] / hw / i386 / pc_piix.c
CommitLineData
845773ab
IY
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
ae0a5466
AK
25#include <glib.h>
26
83c9f4ca 27#include "hw/hw.h"
04920fc0 28#include "hw/loader.h"
0d09e41a
PB
29#include "hw/i386/pc.h"
30#include "hw/i386/apic.h"
60d8f328 31#include "hw/smbios/smbios.h"
83c9f4ca
PB
32#include "hw/pci/pci.h"
33#include "hw/pci/pci_ids.h"
34#include "hw/usb.h"
1422e32d 35#include "net/net.h"
83c9f4ca
PB
36#include "hw/boards.h"
37#include "hw/ide.h"
9c17d615 38#include "sysemu/kvm.h"
83c9f4ca 39#include "hw/kvm/clock.h"
9c17d615 40#include "sysemu/sysemu.h"
83c9f4ca 41#include "hw/sysbus.h"
f0513d2c 42#include "hw/cpu/icc_bus.h"
9c17d615 43#include "sysemu/arch_init.h"
4be74634 44#include "sysemu/block-backend.h"
0d09e41a
PB
45#include "hw/i2c/smbus.h"
46#include "hw/xen/xen.h"
022c62cb
PB
47#include "exec/memory.h"
48#include "exec/address-spaces.h"
0445259b 49#include "hw/acpi/acpi.h"
dc59944b 50#include "cpu.h"
c87b1520 51#include "qemu/error-report.h"
29d3ccde
AP
52#ifdef CONFIG_XEN
53# include <xen/hvm/hvm_info_table.h>
54#endif
37fb569c 55#include "migration/migration.h"
845773ab
IY
56
57#define MAX_IDE_BUS 2
58
59static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 };
60static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
61static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
62
72d164aa 63static bool pci_enabled = true;
72c194f7 64static bool has_acpi_build = true;
384fb32e 65static bool rsdp_in_ram = true;
07fb6176 66static int legacy_acpi_table_size;
e6667f71 67static bool smbios_defaults = true;
c97294ec 68static bool smbios_legacy_mode;
caad057b 69static bool smbios_uuid_encoded = true;
ecdbfceb
MT
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 */
bb43d383 74static bool gigabyte_align = true;
de268e13 75static bool has_reserved_memory = true;
72d164aa 76static bool kvmclock_enabled = true;
3ab135f3 77
845773ab 78/* PC hardware initialisation */
72d164aa 79static void pc_init1(MachineState *machine)
845773ab 80{
ec68007a 81 PCMachineState *pcms = PC_MACHINE(machine);
1e099556
EH
82 MemoryRegion *system_memory = get_system_memory();
83 MemoryRegion *system_io = get_system_io();
845773ab 84 int i;
845773ab 85 PCIBus *pci_bus;
48a18b3c 86 ISABus *isa_bus;
845773ab
IY
87 PCII440FXState *i440fx_state;
88 int piix3_devfn = -1;
b881fbe9 89 qemu_irq *gsi;
845773ab 90 qemu_irq *i8259;
2ba154cf 91 qemu_irq smi_irq;
b881fbe9 92 GSIState *gsi_state;
845773ab 93 DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
c0897e0c 94 BusState *idebus[MAX_IDE_BUS];
1d914fa0 95 ISADevice *rtc_state;
ae0a5466
AK
96 MemoryRegion *ram_memory;
97 MemoryRegion *pci_memory;
4463aee6 98 MemoryRegion *rom_memory;
f0513d2c 99 DeviceState *icc_bridge;
3459a625 100 PcGuestInfo *guest_info;
c87b1520 101 ram_addr_t lowmem;
845773ab 102
ecdbfceb
MT
103 /* Check whether RAM fits below 4G (leaving 1/2 GByte for IO memory).
104 * If it doesn't, we need to split it in chunks below and above 4G.
105 * In any case, try to make sure that guest addresses aligned at
106 * 1G boundaries get mapped to host addresses aligned at 1G boundaries.
107 * For old machine types, use whatever split we used historically to avoid
108 * breaking migration.
109 */
3ef96221 110 if (machine->ram_size >= 0xe0000000) {
c87b1520
DS
111 lowmem = gigabyte_align ? 0xc0000000 : 0xe0000000;
112 } else {
113 lowmem = 0xe0000000;
114 }
115
a9dd38db 116 /* Handle the machine opt max-ram-below-4g. It is basically doing
c87b1520
DS
117 * min(qemu limit, user limit).
118 */
ec68007a
EH
119 if (lowmem > pcms->max_ram_below_4g) {
120 lowmem = pcms->max_ram_below_4g;
c87b1520
DS
121 if (machine->ram_size - lowmem > lowmem &&
122 lowmem & ((1ULL << 30) - 1)) {
123 error_report("Warning: Large machine and max_ram_below_4g(%"PRIu64
124 ") not a multiple of 1G; possible bad performance.",
ec68007a 125 pcms->max_ram_below_4g);
c87b1520
DS
126 }
127 }
128
129 if (machine->ram_size >= lowmem) {
c0aa4e1e
EH
130 pcms->above_4g_mem_size = machine->ram_size - lowmem;
131 pcms->below_4g_mem_size = lowmem;
e0e7e67b 132 } else {
c0aa4e1e
EH
133 pcms->above_4g_mem_size = 0;
134 pcms->below_4g_mem_size = machine->ram_size;
e0e7e67b
AP
135 }
136
91176e31 137 if (xen_enabled() && xen_hvm_init(pcms, &ram_memory) != 0) {
3c2a9669
DS
138 fprintf(stderr, "xen hardware virtual machine initialisation failed\n");
139 exit(1);
140 }
141
142 icc_bridge = qdev_create(NULL, TYPE_ICC_BRIDGE);
143 object_property_add_child(qdev_get_machine(), "icc-bridge",
144 OBJECT(icc_bridge), NULL);
145
146 pc_cpus_init(machine->cpu_model, icc_bridge);
147
148 if (kvm_enabled() && kvmclock_enabled) {
149 kvmclock_create();
150 }
151
4463aee6
JK
152 if (pci_enabled) {
153 pci_memory = g_new(MemoryRegion, 1);
286690e3 154 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
4463aee6
JK
155 rom_memory = pci_memory;
156 } else {
157 pci_memory = NULL;
158 rom_memory = system_memory;
159 }
ae0a5466 160
b9cfc918 161 guest_info = pc_guest_info_init(pcms);
72c194f7
MT
162
163 guest_info->has_acpi_build = has_acpi_build;
07fb6176 164 guest_info->legacy_acpi_table_size = legacy_acpi_table_size;
72c194f7 165
6dd2a5c9 166 guest_info->isapc_ram_fw = !pci_enabled;
de268e13 167 guest_info->has_reserved_memory = has_reserved_memory;
384fb32e 168 guest_info->rsdp_in_ram = rsdp_in_ram;
3459a625 169
e6667f71 170 if (smbios_defaults) {
3ef96221 171 MachineClass *mc = MACHINE_GET_CLASS(machine);
b29ad07e 172 /* These values are guest ABI, do not change */
e6667f71 173 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
86299120
WH
174 mc->name, smbios_legacy_mode, smbios_uuid_encoded,
175 SMBIOS_ENTRY_POINT_21);
b29ad07e
MA
176 }
177
845773ab 178 /* allocate ram and load rom/bios */
29d3ccde 179 if (!xen_enabled()) {
62b160c0 180 pc_memory_init(pcms, system_memory,
6e7d8249 181 rom_memory, &ram_memory, guest_info);
b33a5bbf
CL
182 } else if (machine->kernel_filename != NULL) {
183 /* For xen HVM direct kernel boot, load linux here */
df1f79fd 184 xen_load_linux(pcms, guest_info);
29d3ccde 185 }
845773ab 186
b881fbe9 187 gsi_state = g_malloc0(sizeof(*gsi_state));
3d4b2649 188 if (kvm_irqchip_in_kernel()) {
d8ee0384
JB
189 kvm_pc_setup_irq_routing(pci_enabled);
190 gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state,
10b61882
JK
191 GSI_NUM_PINS);
192 } else {
193 gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS);
194 }
845773ab
IY
195
196 if (pci_enabled) {
60573079 197 pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, &isa_bus, gsi,
3ef96221 198 system_memory, system_io, machine->ram_size,
c0aa4e1e
EH
199 pcms->below_4g_mem_size,
200 pcms->above_4g_mem_size,
ae0a5466 201 pci_memory, ram_memory);
845773ab
IY
202 } else {
203 pci_bus = NULL;
02a89b21 204 i440fx_state = NULL;
bb2ed009 205 isa_bus = isa_bus_new(NULL, get_system_memory(), system_io);
57285cc3 206 no_hpet = 1;
845773ab 207 }
48a18b3c 208 isa_bus_irqs(isa_bus, gsi);
845773ab 209
3d4b2649 210 if (kvm_irqchip_in_kernel()) {
10b61882
JK
211 i8259 = kvm_i8259_init(isa_bus);
212 } else if (xen_enabled()) {
213 i8259 = xen_interrupt_controller_init();
214 } else {
0b0cc076 215 i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq());
4bae1efe
RH
216 }
217
43a0db35
JK
218 for (i = 0; i < ISA_NUM_IRQS; i++) {
219 gsi_state->i8259_irq[i] = i8259[i];
220 }
2ba154cf 221 g_free(i8259);
4bae1efe 222 if (pci_enabled) {
a39e3564 223 ioapic_init_gsi(gsi_state, "i440fx");
4bae1efe 224 }
f0513d2c 225 qdev_init_nofail(icc_bridge);
4bae1efe 226
b881fbe9 227 pc_register_ferr_irq(gsi[13]);
845773ab 228
f424d5c4 229 pc_vga_init(isa_bus, pci_enabled ? pci_bus : NULL);
01195b73 230
ec68007a
EH
231 assert(pcms->vmport != ON_OFF_AUTO_MAX);
232 if (pcms->vmport == ON_OFF_AUTO_AUTO) {
233 pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON;
d1048bef
DS
234 }
235
845773ab 236 /* init basic PC hardware */
220a8846 237 pc_basic_device_init(isa_bus, gsi, &rtc_state, true,
ec68007a 238 (pcms->vmport != ON_OFF_AUTO_ON), 0x4);
845773ab 239
9011a1a7 240 pc_nic_init(isa_bus, pci_bus);
845773ab 241
d8f94e1b 242 ide_drive_get(hd, ARRAY_SIZE(hd));
845773ab 243 if (pci_enabled) {
c0897e0c 244 PCIDevice *dev;
679f4f8b
SS
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 }
c0897e0c
MA
250 idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
251 idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
845773ab
IY
252 } else {
253 for(i = 0; i < MAX_IDE_BUS; i++) {
c0897e0c 254 ISADevice *dev;
61de3676 255 char busname[] = "ide.0";
48a18b3c
HP
256 dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i],
257 ide_irq[i],
c0897e0c 258 hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]);
61de3676
AG
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);
845773ab
IY
265 }
266 }
267
88076854 268 pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state);
845773ab 269
de77a243 270 if (pci_enabled && usb_enabled()) {
afb9a60e 271 pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci");
845773ab
IY
272 }
273
274 if (pci_enabled && acpi_enabled) {
781bbd6b 275 DeviceState *piix4_pm;
a5c82852 276 I2CBus *smbus;
845773ab 277
2ba154cf 278 smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0);
845773ab
IY
279 /* TODO: Populate SPD eeprom data. */
280 smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100,
2ba154cf 281 gsi[9], smi_irq,
ec68007a 282 pc_machine_is_smm_enabled(pcms),
355023f2 283 &piix4_pm);
a88df0b9 284 smbus_eeprom_init(smbus, 8, NULL, 0);
781bbd6b
IM
285
286 object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
287 TYPE_HOTPLUG_HANDLER,
ec68007a 288 (Object **)&pcms->acpi_dev,
781bbd6b
IM
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);
845773ab
IY
293 }
294
845773ab
IY
295 if (pci_enabled) {
296 pc_pci_device_init(pci_bus);
297 }
298}
299
5cb50e0a
JW
300static void pc_compat_2_3(MachineState *machine)
301{
355023f2 302 PCMachineState *pcms = PC_MACHINE(machine);
37fb569c 303 savevm_skip_section_footers();
355023f2
PB
304 if (kvm_enabled()) {
305 pcms->smm = ON_OFF_AUTO_OFF;
306 }
13d16814 307 global_state_set_optional();
61964c23 308 savevm_skip_configuration();
5cb50e0a
JW
309}
310
64bbd372
PB
311static void pc_compat_2_2(MachineState *machine)
312{
5cb50e0a 313 pc_compat_2_3(machine);
384fb32e 314 rsdp_in_ram = false;
54ed388b 315 machine->suppress_vmdesc = true;
64bbd372
PB
316}
317
2cad57c7
EH
318static void pc_compat_2_1(MachineState *machine)
319{
91aa70ab 320 PCMachineState *pcms = PC_MACHINE(machine);
64bbd372
PB
321
322 pc_compat_2_2(machine);
caad057b 323 smbios_uuid_encoded = false;
75d373ef 324 x86_cpu_compat_kvm_no_autodisable(FEAT_8000_0001_ECX, CPUID_EXT3_SVM);
91aa70ab 325 pcms->enforce_aligned_dimm = false;
2cad57c7
EH
326}
327
3ef96221 328static void pc_compat_2_0(MachineState *machine)
3458b2b0 329{
2cad57c7 330 pc_compat_2_1(machine);
07fb6176
PB
331 /* This value depends on the actual DSDT and SSDT compiled into
332 * the source QEMU; unfortunately it depends on the binary and
333 * not on the machine type, so we cannot make pc-i440fx-1.7 work on
334 * both QEMU 1.7 and QEMU 2.0.
335 *
336 * Large variations cause migration to fail for more than one
337 * consecutive value of the "-smp" maxcpus option.
338 *
339 * For small variations of the kind caused by different iasl versions,
340 * the 4k rounding usually leaves slack. However, there could be still
341 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
342 * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
343 *
344 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
345 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
346 */
347 legacy_acpi_table_size = 6652;
c97294ec 348 smbios_legacy_mode = true;
de268e13 349 has_reserved_memory = false;
927766c7 350 pc_set_legacy_acpi_data_size();
3458b2b0
MT
351}
352
3ef96221 353static void pc_compat_1_7(MachineState *machine)
b29ad07e 354{
3ef96221 355 pc_compat_2_0(machine);
e6667f71 356 smbios_defaults = false;
bb43d383 357 gigabyte_align = false;
ac41881b 358 option_rom_has_mr = true;
f47337cb 359 legacy_acpi_table_size = 6414;
1cadaa94 360 x86_cpu_compat_kvm_no_autoenable(FEAT_1_ECX, CPUID_EXT_X2APIC);
b29ad07e
MA
361}
362
3ef96221 363static void pc_compat_1_6(MachineState *machine)
f8c457b8 364{
3ef96221 365 pc_compat_1_7(machine);
98bc3ab0 366 rom_file_has_mr = false;
72c194f7 367 has_acpi_build = false;
f8c457b8
MT
368}
369
3ef96221 370static void pc_compat_1_5(MachineState *machine)
9604f70f 371{
3ef96221 372 pc_compat_1_6(machine);
9604f70f
MT
373}
374
3ef96221 375static void pc_compat_1_4(MachineState *machine)
9953f882 376{
3ef96221 377 pc_compat_1_5(machine);
9953f882
MA
378}
379
3ef96221 380static void pc_compat_1_3(MachineState *machine)
8932cfdf 381{
3ef96221 382 pc_compat_1_4(machine);
8932cfdf 383 enable_compat_apic_id_mode();
89b439f3
EH
384}
385
386/* PC compat function for pc-0.14 to pc-1.2 */
3ef96221 387static void pc_compat_1_2(MachineState *machine)
89b439f3 388{
3ef96221 389 pc_compat_1_3(machine);
0034a0f2 390 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
89b439f3
EH
391}
392
72d164aa
EH
393/* PC compat function for pc-0.10 to pc-0.13 */
394static void pc_compat_0_13(MachineState *machine)
395{
396 pc_compat_1_2(machine);
397 kvmclock_enabled = false;
398}
399
3ef96221 400static void pc_init_isa(MachineState *machine)
845773ab 401{
72d164aa 402 pci_enabled = false;
98af2ac9 403 has_acpi_build = false;
e6667f71 404 smbios_defaults = false;
5f8632d3
DS
405 gigabyte_align = false;
406 smbios_legacy_mode = true;
407 has_reserved_memory = false;
408 option_rom_has_mr = true;
409 rom_file_has_mr = false;
3ef96221
MA
410 if (!machine->cpu_model) {
411 machine->cpu_model = "486";
5650f5f4 412 }
0034a0f2 413 x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI);
8932cfdf 414 enable_compat_apic_id_mode();
72d164aa 415 pc_init1(machine);
845773ab
IY
416}
417
29d3ccde 418#ifdef CONFIG_XEN
3ef96221 419static void pc_xen_hvm_init(MachineState *machine)
29d3ccde 420{
39ae4972
PD
421 PCIBus *bus;
422
211b5b1d 423 pc_init1(machine);
39ae4972 424
1ef7a2a2 425 bus = pci_find_primary_bus();
39ae4972
PD
426 if (bus != NULL) {
427 pci_create_simple(bus, -1, "xen-platform");
428 }
29d3ccde
AP
429}
430#endif
431
99fbeafe
EH
432#define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
433 static void pc_init_##suffix(MachineState *machine) \
434 { \
435 void (*compat)(MachineState *m) = (compatfn); \
436 if (compat) { \
437 compat(machine); \
438 } \
439 pc_init1(machine); \
440 } \
441 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
fddd179a 442
865906f7 443static void pc_i440fx_machine_options(MachineClass *m)
fddd179a 444{
fddd179a
EH
445 m->family = "pc_piix";
446 m->desc = "Standard PC (i440FX + PIIX, 1996)";
447 m->hot_add_cpu = pc_hot_add_cpu;
448}
449
865906f7 450static void pc_i440fx_2_4_machine_options(MachineClass *m)
fddd179a
EH
451{
452 pc_i440fx_machine_options(m);
453 m->default_machine_opts = "firmware=bios-256k.bin";
454 m->default_display = "std";
455 m->alias = "pc";
456 m->is_default = 1;
457}
aeca6e8d 458
99fbeafe
EH
459DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
460 pc_i440fx_2_4_machine_options)
5cb50e0a 461
f9f21873 462
865906f7 463static void pc_i440fx_2_3_machine_options(MachineClass *m)
fddd179a 464{
4421c6a3 465 pc_i440fx_2_4_machine_options(m);
fddd179a
EH
466 m->alias = NULL;
467 m->is_default = 0;
25519b06 468 SET_MACHINE_COMPAT(m, PC_COMPAT_2_3);
fddd179a 469}
5cb50e0a 470
99fbeafe
EH
471DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
472 pc_i440fx_2_3_machine_options);
61f219df 473
5cb50e0a 474
865906f7 475static void pc_i440fx_2_2_machine_options(MachineClass *m)
fddd179a
EH
476{
477 pc_i440fx_2_3_machine_options(m);
25519b06 478 SET_MACHINE_COMPAT(m, PC_COMPAT_2_2);
fddd179a 479}
64bbd372 480
99fbeafe
EH
481DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2,
482 pc_i440fx_2_2_machine_options);
61f219df 483
64bbd372 484
865906f7 485static void pc_i440fx_2_1_machine_options(MachineClass *m)
fddd179a
EH
486{
487 pc_i440fx_2_2_machine_options(m);
488 m->default_display = NULL;
25519b06 489 SET_MACHINE_COMPAT(m, PC_COMPAT_2_1);
fddd179a 490}
f9f21873 491
99fbeafe
EH
492DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1,
493 pc_i440fx_2_1_machine_options);
61f219df 494
aeca6e8d 495
fddd179a 496
865906f7 497static void pc_i440fx_2_0_machine_options(MachineClass *m)
fddd179a
EH
498{
499 pc_i440fx_2_1_machine_options(m);
25519b06 500 SET_MACHINE_COMPAT(m, PC_COMPAT_2_0);
fddd179a 501}
3458b2b0 502
99fbeafe
EH
503DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0,
504 pc_i440fx_2_0_machine_options);
61f219df 505
3458b2b0 506
865906f7 507static void pc_i440fx_1_7_machine_options(MachineClass *m)
fddd179a
EH
508{
509 pc_i440fx_2_0_machine_options(m);
510 m->default_machine_opts = NULL;
25519b06 511 SET_MACHINE_COMPAT(m, PC_COMPAT_1_7);
fddd179a 512}
aeca6e8d 513
99fbeafe
EH
514DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7,
515 pc_i440fx_1_7_machine_options);
61f219df 516
e9845f09 517
865906f7 518static void pc_i440fx_1_6_machine_options(MachineClass *m)
fddd179a
EH
519{
520 pc_i440fx_1_7_machine_options(m);
25519b06 521 SET_MACHINE_COMPAT(m, PC_COMPAT_1_6);
fddd179a 522}
a0dba644 523
99fbeafe
EH
524DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6,
525 pc_i440fx_1_6_machine_options);
61f219df 526
845773ab 527
865906f7 528static void pc_i440fx_1_5_machine_options(MachineClass *m)
fddd179a
EH
529{
530 pc_i440fx_1_6_machine_options(m);
25519b06 531 SET_MACHINE_COMPAT(m, PC_COMPAT_1_5);
fddd179a 532}
b6b5c8e4 533
99fbeafe
EH
534DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5,
535 pc_i440fx_1_5_machine_options);
61f219df 536
45053fde 537
865906f7 538static void pc_i440fx_1_4_machine_options(MachineClass *m)
fddd179a
EH
539{
540 pc_i440fx_1_5_machine_options(m);
541 m->hot_add_cpu = NULL;
25519b06 542 SET_MACHINE_COMPAT(m, PC_COMPAT_1_4);
fddd179a 543}
a0dba644 544
99fbeafe
EH
545DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4,
546 pc_i440fx_1_4_machine_options);
61f219df 547
bf3caa3d 548
427e3aa1 549#define PC_COMPAT_1_3 \
a7cde24d 550 PC_COMPAT_1_4 \
427e3aa1
HG
551 {\
552 .driver = "usb-tablet",\
553 .property = "usb_version",\
554 .value = stringify(1),\
c1943a3f
AK
555 },{\
556 .driver = "virtio-net-pci",\
557 .property = "ctrl_mac_addr",\
558 .value = "off", \
a9c87c58
JW
559 },{ \
560 .driver = "virtio-net-pci", \
561 .property = "mq", \
562 .value = "off", \
2af234e6
MT
563 }, {\
564 .driver = "e1000",\
565 .property = "autonegotiation",\
566 .value = "off",\
a7cde24d 567 },
427e3aa1 568
fddd179a 569
865906f7 570static void pc_i440fx_1_3_machine_options(MachineClass *m)
fddd179a
EH
571{
572 pc_i440fx_1_4_machine_options(m);
25519b06 573 SET_MACHINE_COMPAT(m, PC_COMPAT_1_3);
fddd179a 574}
b6b5c8e4 575
99fbeafe
EH
576DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3,
577 pc_i440fx_1_3_machine_options);
61f219df 578
f1ae2e38 579
183c5eaa 580#define PC_COMPAT_1_2 \
a7cde24d 581 PC_COMPAT_1_3 \
183c5eaa
GH
582 {\
583 .driver = "nec-usb-xhci",\
584 .property = "msi",\
585 .value = "off",\
586 },{\
587 .driver = "nec-usb-xhci",\
588 .property = "msix",\
589 .value = "off",\
c08ba66f
GH
590 },{\
591 .driver = "ivshmem",\
592 .property = "use64",\
593 .value = "0",\
591af143
GH
594 },{\
595 .driver = "qxl",\
596 .property = "revision",\
597 .value = stringify(3),\
598 },{\
599 .driver = "qxl-vga",\
600 .property = "revision",\
601 .value = stringify(3),\
803ff052
GH
602 },{\
603 .driver = "VGA",\
604 .property = "mmio",\
605 .value = "off",\
a7cde24d 606 },
183c5eaa 607
865906f7 608static void pc_i440fx_1_2_machine_options(MachineClass *m)
fddd179a
EH
609{
610 pc_i440fx_1_3_machine_options(m);
25519b06 611 SET_MACHINE_COMPAT(m, PC_COMPAT_1_2);
fddd179a 612}
a0dba644 613
99fbeafe
EH
614DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2,
615 pc_i440fx_1_2_machine_options);
61f219df 616
f4306941 617
9e56edcf 618#define PC_COMPAT_1_1 \
a7cde24d 619 PC_COMPAT_1_2 \
9e56edcf 620 {\
07a5298c
PB
621 .driver = "virtio-scsi-pci",\
622 .property = "hotplug",\
623 .value = "off",\
624 },{\
625 .driver = "virtio-scsi-pci",\
626 .property = "param_change",\
627 .value = "off",\
628 },{\
9e56edcf
GH
629 .driver = "VGA",\
630 .property = "vgamem_mb",\
631 .value = stringify(8),\
632 },{\
633 .driver = "vmware-svga",\
634 .property = "vgamem_mb",\
635 .value = stringify(8),\
636 },{\
637 .driver = "qxl-vga",\
638 .property = "vgamem_mb",\
639 .value = stringify(8),\
640 },{\
641 .driver = "qxl",\
642 .property = "vgamem_mb",\
643 .value = stringify(8),\
ea776abc
SH
644 },{\
645 .driver = "virtio-blk-pci",\
646 .property = "config-wce",\
647 .value = "off",\
a7cde24d 648 },
9e56edcf 649
865906f7 650static void pc_i440fx_1_1_machine_options(MachineClass *m)
fddd179a
EH
651{
652 pc_i440fx_1_2_machine_options(m);
25519b06 653 SET_MACHINE_COMPAT(m, PC_COMPAT_1_1);
fddd179a 654}
b6b5c8e4 655
99fbeafe
EH
656DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2,
657 pc_i440fx_1_1_machine_options);
61f219df 658
f1dacf1c 659
d6c73008 660#define PC_COMPAT_1_0 \
a7cde24d 661 PC_COMPAT_1_1 \
d6c73008 662 {\
020c8e76 663 .driver = TYPE_ISA_FDC,\
d6c73008
MT
664 .property = "check_media_rate",\
665 .value = "off",\
2ba1d381
DG
666 }, {\
667 .driver = "virtio-balloon-pci",\
668 .property = "class",\
669 .value = stringify(PCI_CLASS_MEMORY_RAM),\
fc34e77b 670 },{\
df1fd4b5 671 .driver = "apic-common",\
fc34e77b
AL
672 .property = "vapic",\
673 .value = "off",\
eeb0cf9a 674 },{\
bce54474 675 .driver = TYPE_USB_DEVICE,\
eeb0cf9a
GH
676 .property = "full-path",\
677 .value = "no",\
a7cde24d 678 },
d6c73008 679
865906f7 680static void pc_i440fx_1_0_machine_options(MachineClass *m)
fddd179a
EH
681{
682 pc_i440fx_1_1_machine_options(m);
683 m->hw_version = "1.0";
25519b06 684 SET_MACHINE_COMPAT(m, PC_COMPAT_1_0);
fddd179a 685}
b6b5c8e4 686
99fbeafe
EH
687DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2,
688 pc_i440fx_1_0_machine_options);
61f219df 689
382b3a68 690
d6c73008
MT
691#define PC_COMPAT_0_15 \
692 PC_COMPAT_1_0
693
865906f7 694static void pc_i440fx_0_15_machine_options(MachineClass *m)
fddd179a
EH
695{
696 pc_i440fx_1_0_machine_options(m);
697 m->hw_version = "0.15";
25519b06 698 SET_MACHINE_COMPAT(m, PC_COMPAT_0_15);
fddd179a 699}
b6b5c8e4 700
99fbeafe
EH
701DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2,
702 pc_i440fx_0_15_machine_options);
61f219df 703
ce01a508 704
d6c73008 705#define PC_COMPAT_0_14 \
a7cde24d 706 PC_COMPAT_0_15 \
d6c73008
MT
707 {\
708 .driver = "virtio-blk-pci",\
709 .property = "event_idx",\
710 .value = "off",\
711 },{\
712 .driver = "virtio-serial-pci",\
713 .property = "event_idx",\
714 .value = "off",\
715 },{\
716 .driver = "virtio-net-pci",\
717 .property = "event_idx",\
718 .value = "off",\
719 },{\
720 .driver = "virtio-balloon-pci",\
721 .property = "event_idx",\
722 .value = "off",\
bb08d882
EH
723 },{\
724 .driver = "qxl",\
725 .property = "revision",\
726 .value = stringify(2),\
727 },{\
728 .driver = "qxl-vga",\
729 .property = "revision",\
730 .value = stringify(2),\
a7cde24d 731 },
d6c73008 732
865906f7 733static void pc_i440fx_0_14_machine_options(MachineClass *m)
fddd179a
EH
734{
735 pc_i440fx_0_15_machine_options(m);
736 m->hw_version = "0.14";
25519b06 737 SET_MACHINE_COMPAT(m, PC_COMPAT_0_14);
fddd179a 738}
b6b5c8e4 739
99fbeafe
EH
740DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2,
741 pc_i440fx_0_14_machine_options);
61f219df 742
19857e62 743
d6c73008 744#define PC_COMPAT_0_13 \
a7cde24d 745 PC_COMPAT_0_14 \
d6c73008 746 {\
bce54474 747 .driver = TYPE_PCI_DEVICE,\
d6c73008
MT
748 .property = "command_serr_enable",\
749 .value = "off",\
750 },{\
751 .driver = "AC97",\
752 .property = "use_broken_id",\
753 .value = stringify(1),\
d765519b
EH
754 },{\
755 .driver = "virtio-9p-pci",\
756 .property = "vectors",\
757 .value = stringify(0),\
faf7e425
EH
758 },{\
759 .driver = "VGA",\
760 .property = "rombar",\
761 .value = stringify(0),\
762 },{\
763 .driver = "vmware-svga",\
764 .property = "rombar",\
765 .value = stringify(0),\
a7cde24d 766 },
d6c73008 767
865906f7 768static void pc_i440fx_0_13_machine_options(MachineClass *m)
fddd179a
EH
769{
770 pc_i440fx_0_14_machine_options(m);
771 m->hw_version = "0.13";
25519b06 772 SET_MACHINE_COMPAT(m, PC_COMPAT_0_13);
fddd179a 773}
a0dba644 774
99fbeafe
EH
775DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13,
776 pc_i440fx_0_13_machine_options);
61f219df 777
b903a0f7 778
d6c73008 779#define PC_COMPAT_0_12 \
a7cde24d 780 PC_COMPAT_0_13 \
d6c73008
MT
781 {\
782 .driver = "virtio-serial-pci",\
783 .property = "max_ports",\
784 .value = stringify(1),\
785 },{\
786 .driver = "virtio-serial-pci",\
787 .property = "vectors",\
788 .value = stringify(0),\
93c8e4dc
GH
789 },{\
790 .driver = "usb-mouse",\
791 .property = "serial",\
792 .value = "1",\
793 },{\
794 .driver = "usb-tablet",\
795 .property = "serial",\
796 .value = "1",\
797 },{\
798 .driver = "usb-kbd",\
799 .property = "serial",\
800 .value = "1",\
a7cde24d 801 },
d6c73008 802
865906f7 803static void pc_i440fx_0_12_machine_options(MachineClass *m)
fddd179a
EH
804{
805 pc_i440fx_0_13_machine_options(m);
806 m->hw_version = "0.12";
25519b06 807 SET_MACHINE_COMPAT(m, PC_COMPAT_0_12);
fddd179a 808}
b6b5c8e4 809
99fbeafe
EH
810DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13,
811 pc_i440fx_0_12_machine_options);
61f219df 812
845773ab 813
d6c73008 814#define PC_COMPAT_0_11 \
a7cde24d 815 PC_COMPAT_0_12 \
d6c73008
MT
816 {\
817 .driver = "virtio-blk-pci",\
818 .property = "vectors",\
819 .value = stringify(0),\
c115cd65 820 },{\
bce54474 821 .driver = TYPE_PCI_DEVICE,\
c115cd65
PB
822 .property = "rombar",\
823 .value = stringify(0),\
d5303df7
EH
824 },{\
825 .driver = "ide-drive",\
826 .property = "ver",\
827 .value = "0.11",\
828 },{\
829 .driver = "scsi-disk",\
830 .property = "ver",\
831 .value = "0.11",\
a7cde24d 832 },
d6c73008 833
865906f7 834static void pc_i440fx_0_11_machine_options(MachineClass *m)
fddd179a
EH
835{
836 pc_i440fx_0_12_machine_options(m);
837 m->hw_version = "0.11";
25519b06 838 SET_MACHINE_COMPAT(m, PC_COMPAT_0_11);
fddd179a 839}
b6b5c8e4 840
99fbeafe
EH
841DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13,
842 pc_i440fx_0_11_machine_options);
61f219df 843
845773ab 844
f6d5a0ba
EH
845#define PC_COMPAT_0_10 \
846 PC_COMPAT_0_11 \
847 {\
848 .driver = "virtio-blk-pci",\
849 .property = "class",\
850 .value = stringify(PCI_CLASS_STORAGE_OTHER),\
851 },{\
852 .driver = "virtio-serial-pci",\
853 .property = "class",\
854 .value = stringify(PCI_CLASS_DISPLAY_OTHER),\
855 },{\
856 .driver = "virtio-net-pci",\
857 .property = "vectors",\
858 .value = stringify(0),\
859 },{\
860 .driver = "ide-drive",\
861 .property = "ver",\
862 .value = "0.10",\
863 },{\
864 .driver = "scsi-disk",\
865 .property = "ver",\
866 .value = "0.10",\
867 },
868
865906f7 869static void pc_i440fx_0_10_machine_options(MachineClass *m)
fddd179a
EH
870{
871 pc_i440fx_0_11_machine_options(m);
872 m->hw_version = "0.10";
25519b06 873 SET_MACHINE_COMPAT(m, PC_COMPAT_0_10);
fddd179a 874}
b6b5c8e4 875
99fbeafe
EH
876DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13,
877 pc_i440fx_0_10_machine_options);
61f219df 878
845773ab 879
865906f7 880static void isapc_machine_options(MachineClass *m)
fddd179a 881{
fddd179a
EH
882 m->desc = "ISA-only PC";
883 m->max_cpus = 1;
884}
b6b5c8e4 885
61f219df 886DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa,
25519b06 887 isapc_machine_options);
61f219df 888
845773ab 889
29d3ccde 890#ifdef CONFIG_XEN
865906f7 891static void xenfv_machine_options(MachineClass *m)
fddd179a 892{
fddd179a
EH
893 m->desc = "Xen Fully-virtualized PC";
894 m->max_cpus = HVM_MAX_VCPUS;
895 m->default_machine_opts = "accel=xen";
896 m->hot_add_cpu = pc_hot_add_cpu;
897}
b6b5c8e4 898
61f219df 899DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init,
25519b06 900 xenfv_machine_options);
29d3ccde 901#endif