2 * QEMU PC System Emulator
4 * Copyright (c) 2003-2004 Fabrice Bellard
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
25 #include "qemu/osdep.h"
27 #include "qemu/units.h"
29 #include "hw/loader.h"
30 #include "hw/i386/pc.h"
31 #include "hw/i386/apic.h"
32 #include "hw/display/ramfb.h"
33 #include "hw/firmware/smbios.h"
34 #include "hw/pci/pci.h"
35 #include "hw/pci/pci_ids.h"
38 #include "hw/boards.h"
40 #include "sysemu/kvm.h"
41 #include "hw/kvm/clock.h"
42 #include "sysemu/sysemu.h"
43 #include "hw/sysbus.h"
44 #include "sysemu/arch_init.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"
51 #include "qapi/error.h"
52 #include "qemu/error-report.h"
54 #include <xen/hvm/hvm_info_table.h>
55 #include "hw/xen/xen_pt.h"
57 #include "migration/global_state.h"
58 #include "migration/misc.h"
60 #include "sysemu/numa.h"
64 static const int ide_iobase
[MAX_IDE_BUS
] = { 0x1f0, 0x170 };
65 static const int ide_iobase2
[MAX_IDE_BUS
] = { 0x3f6, 0x376 };
66 static const int ide_irq
[MAX_IDE_BUS
] = { 14, 15 };
68 /* PC hardware initialisation */
69 static void pc_init1(MachineState
*machine
,
70 const char *host_type
, const char *pci_type
)
72 PCMachineState
*pcms
= PC_MACHINE(machine
);
73 PCMachineClass
*pcmc
= PC_MACHINE_GET_CLASS(pcms
);
74 MemoryRegion
*system_memory
= get_system_memory();
75 MemoryRegion
*system_io
= get_system_io();
79 PCII440FXState
*i440fx_state
;
84 DriveInfo
*hd
[MAX_IDE_BUS
* MAX_IDE_DEVS
];
85 BusState
*idebus
[MAX_IDE_BUS
];
87 MemoryRegion
*ram_memory
;
88 MemoryRegion
*pci_memory
;
89 MemoryRegion
*rom_memory
;
93 * Calculate ram split, for memory below and above 4G. It's a bit
94 * complicated for backward compatibility reasons ...
96 * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the
97 * default value for max_ram_below_4g now.
99 * - Then, to gigabyte align the memory, we move the split to 3G
100 * (lowmem = 0xc0000000). But only in case we have to split in
101 * the first place, i.e. ram_size is larger than (traditional)
102 * lowmem. And for new machine types (gigabyte_align = true)
103 * only, for live migration compatibility reasons.
105 * - Next the max-ram-below-4g option was added, which allowed to
106 * reduce lowmem to a smaller value, to allow a larger PCI I/O
107 * window below 4G. qemu doesn't enforce gigabyte alignment here,
108 * but prints a warning.
110 * - Finally max-ram-below-4g got updated to also allow raising lowmem,
111 * so legacy non-PAE guests can get as much memory as possible in
112 * the 32bit address space below 4G.
114 * - Note that Xen has its own ram setp code in xen_ram_init(),
115 * called via xen_hvm_init().
118 * qemu -M pc-1.7 -m 4G (old default) -> 3584M low, 512M high
119 * qemu -M pc -m 4G (new default) -> 3072M low, 1024M high
120 * qemu -M pc,max-ram-below-4g=2G -m 4G -> 2048M low, 2048M high
121 * qemu -M pc,max-ram-below-4g=4G -m 3968M -> 3968M low (=4G-128M)
124 xen_hvm_init(pcms
, &ram_memory
);
126 if (!pcms
->max_ram_below_4g
) {
127 pcms
->max_ram_below_4g
= 0xe0000000; /* default: 3.5G */
129 lowmem
= pcms
->max_ram_below_4g
;
130 if (machine
->ram_size
>= pcms
->max_ram_below_4g
) {
131 if (pcmc
->gigabyte_align
) {
132 if (lowmem
> 0xc0000000) {
135 if (lowmem
& (1 * GiB
- 1)) {
136 warn_report("Large machine and max_ram_below_4g "
137 "(%" PRIu64
") not a multiple of 1G; "
138 "possible bad performance.",
139 pcms
->max_ram_below_4g
);
144 if (machine
->ram_size
>= lowmem
) {
145 pcms
->above_4g_mem_size
= machine
->ram_size
- lowmem
;
146 pcms
->below_4g_mem_size
= lowmem
;
148 pcms
->above_4g_mem_size
= 0;
149 pcms
->below_4g_mem_size
= machine
->ram_size
;
155 if (kvm_enabled() && pcmc
->kvmclock_enabled
) {
159 if (pcmc
->pci_enabled
) {
160 pci_memory
= g_new(MemoryRegion
, 1);
161 memory_region_init(pci_memory
, NULL
, "pci", UINT64_MAX
);
162 rom_memory
= pci_memory
;
165 rom_memory
= system_memory
;
168 pc_guest_info_init(pcms
);
170 if (pcmc
->smbios_defaults
) {
171 MachineClass
*mc
= MACHINE_GET_CLASS(machine
);
172 /* These values are guest ABI, do not change */
173 smbios_set_defaults("QEMU", "Standard PC (i440FX + PIIX, 1996)",
174 mc
->name
, pcmc
->smbios_legacy_mode
,
175 pcmc
->smbios_uuid_encoded
,
176 SMBIOS_ENTRY_POINT_21
);
179 /* allocate ram and load rom/bios */
180 if (!xen_enabled()) {
181 pc_memory_init(pcms
, system_memory
,
182 rom_memory
, &ram_memory
);
183 } else if (machine
->kernel_filename
!= NULL
) {
184 /* For xen HVM direct kernel boot, load linux here */
185 xen_load_linux(pcms
);
188 gsi_state
= g_malloc0(sizeof(*gsi_state
));
189 if (kvm_ioapic_in_kernel()) {
190 kvm_pc_setup_irq_routing(pcmc
->pci_enabled
);
191 pcms
->gsi
= qemu_allocate_irqs(kvm_pc_gsi_handler
, gsi_state
,
194 pcms
->gsi
= qemu_allocate_irqs(gsi_handler
, gsi_state
, GSI_NUM_PINS
);
197 if (pcmc
->pci_enabled
) {
198 pci_bus
= i440fx_init(host_type
,
200 &i440fx_state
, &piix3_devfn
, &isa_bus
, pcms
->gsi
,
201 system_memory
, system_io
, machine
->ram_size
,
202 pcms
->below_4g_mem_size
,
203 pcms
->above_4g_mem_size
,
204 pci_memory
, ram_memory
);
209 isa_bus
= isa_bus_new(NULL
, get_system_memory(), system_io
,
213 isa_bus_irqs(isa_bus
, pcms
->gsi
);
215 if (kvm_pic_in_kernel()) {
216 i8259
= kvm_i8259_init(isa_bus
);
217 } else if (xen_enabled()) {
218 i8259
= xen_interrupt_controller_init();
220 i8259
= i8259_init(isa_bus
, pc_allocate_cpu_irq());
223 for (i
= 0; i
< ISA_NUM_IRQS
; i
++) {
224 gsi_state
->i8259_irq
[i
] = i8259
[i
];
227 if (pcmc
->pci_enabled
) {
228 ioapic_init_gsi(gsi_state
, "i440fx");
231 pc_register_ferr_irq(pcms
->gsi
[13]);
233 pc_vga_init(isa_bus
, pcmc
->pci_enabled
? pci_bus
: NULL
);
235 assert(pcms
->vmport
!= ON_OFF_AUTO__MAX
);
236 if (pcms
->vmport
== ON_OFF_AUTO_AUTO
) {
237 pcms
->vmport
= xen_enabled() ? ON_OFF_AUTO_OFF
: ON_OFF_AUTO_ON
;
240 /* init basic PC hardware */
241 pc_basic_device_init(isa_bus
, pcms
->gsi
, &rtc_state
, true,
242 (pcms
->vmport
!= ON_OFF_AUTO_ON
), pcms
->pit_enabled
,
245 pc_nic_init(pcmc
, isa_bus
, pci_bus
);
247 ide_drive_get(hd
, ARRAY_SIZE(hd
));
248 if (pcmc
->pci_enabled
) {
251 dev
= pci_piix3_xen_ide_init(pci_bus
, hd
, piix3_devfn
+ 1);
253 dev
= pci_piix3_ide_init(pci_bus
, hd
, piix3_devfn
+ 1);
255 idebus
[0] = qdev_get_child_bus(&dev
->qdev
, "ide.0");
256 idebus
[1] = qdev_get_child_bus(&dev
->qdev
, "ide.1");
258 for(i
= 0; i
< MAX_IDE_BUS
; i
++) {
260 char busname
[] = "ide.0";
261 dev
= isa_ide_init(isa_bus
, ide_iobase
[i
], ide_iobase2
[i
],
263 hd
[MAX_IDE_DEVS
* i
], hd
[MAX_IDE_DEVS
* i
+ 1]);
265 * The ide bus name is ide.0 for the first bus and ide.1 for the
268 busname
[4] = '0' + i
;
269 idebus
[i
] = qdev_get_child_bus(DEVICE(dev
), busname
);
273 pc_cmos_init(pcms
, idebus
[0], idebus
[1], rtc_state
);
275 if (pcmc
->pci_enabled
&& machine_usb(machine
)) {
276 pci_create_simple(pci_bus
, piix3_devfn
+ 2, "piix3-usb-uhci");
279 if (pcmc
->pci_enabled
&& acpi_enabled
) {
280 DeviceState
*piix4_pm
;
283 smi_irq
= qemu_allocate_irq(pc_acpi_smi_interrupt
, first_cpu
, 0);
284 /* TODO: Populate SPD eeprom data. */
285 smbus
= piix4_pm_init(pci_bus
, piix3_devfn
+ 3, 0xb100,
286 pcms
->gsi
[9], smi_irq
,
287 pc_machine_is_smm_enabled(pcms
),
289 smbus_eeprom_init(smbus
, 8, NULL
, 0);
291 object_property_add_link(OBJECT(machine
), PC_MACHINE_ACPI_DEVICE_PROP
,
292 TYPE_HOTPLUG_HANDLER
,
293 (Object
**)&pcms
->acpi_dev
,
294 object_property_allow_set_link
,
295 OBJ_PROP_LINK_STRONG
, &error_abort
);
296 object_property_set_link(OBJECT(machine
), OBJECT(piix4_pm
),
297 PC_MACHINE_ACPI_DEVICE_PROP
, &error_abort
);
300 if (pcms
->acpi_nvdimm_state
.is_enabled
) {
301 nvdimm_init_acpi_state(&pcms
->acpi_nvdimm_state
, system_io
,
302 pcms
->fw_cfg
, OBJECT(pcms
));
306 /* Looking for a pc_compat_2_4() function? It doesn't exist.
307 * pc_compat_*() functions that run on machine-init time and
308 * change global QEMU state are deprecated. Please don't create
309 * one, and implement any pc-*-2.4 (and newer) compat code in
310 * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().
313 static void pc_compat_2_3_fn(MachineState
*machine
)
315 PCMachineState
*pcms
= PC_MACHINE(machine
);
317 pcms
->smm
= ON_OFF_AUTO_OFF
;
321 static void pc_compat_2_2_fn(MachineState
*machine
)
323 pc_compat_2_3_fn(machine
);
326 static void pc_compat_2_1_fn(MachineState
*machine
)
328 pc_compat_2_2_fn(machine
);
329 x86_cpu_change_kvm_default("svm", NULL
);
332 static void pc_compat_2_0_fn(MachineState
*machine
)
334 pc_compat_2_1_fn(machine
);
337 static void pc_compat_1_7_fn(MachineState
*machine
)
339 pc_compat_2_0_fn(machine
);
340 x86_cpu_change_kvm_default("x2apic", NULL
);
343 static void pc_compat_1_6_fn(MachineState
*machine
)
345 pc_compat_1_7_fn(machine
);
348 static void pc_compat_1_5_fn(MachineState
*machine
)
350 pc_compat_1_6_fn(machine
);
353 static void pc_compat_1_4_fn(MachineState
*machine
)
355 pc_compat_1_5_fn(machine
);
358 static void pc_compat_1_3(MachineState
*machine
)
360 pc_compat_1_4_fn(machine
);
361 enable_compat_apic_id_mode();
364 /* PC compat function for pc-0.14 to pc-1.2 */
365 static void pc_compat_1_2(MachineState
*machine
)
367 pc_compat_1_3(machine
);
368 x86_cpu_change_kvm_default("kvm-pv-eoi", NULL
);
371 /* PC compat function for pc-0.12 and pc-0.13 */
372 static void pc_compat_0_13(MachineState
*machine
)
374 pc_compat_1_2(machine
);
377 static void pc_init_isa(MachineState
*machine
)
379 pc_init1(machine
, TYPE_I440FX_PCI_HOST_BRIDGE
, TYPE_I440FX_PCI_DEVICE
);
383 static void pc_xen_hvm_init_pci(MachineState
*machine
)
385 const char *pci_type
= has_igd_gfx_passthru
?
386 TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE
: TYPE_I440FX_PCI_DEVICE
;
389 TYPE_I440FX_PCI_HOST_BRIDGE
,
393 static void pc_xen_hvm_init(MachineState
*machine
)
395 PCMachineState
*pcms
= PC_MACHINE(machine
);
397 if (!xen_enabled()) {
398 error_report("xenfv machine requires the xen accelerator");
402 pc_xen_hvm_init_pci(machine
);
403 pci_create_simple(pcms
->bus
, -1, "xen-platform");
407 #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \
408 static void pc_init_##suffix(MachineState *machine) \
410 void (*compat)(MachineState *m) = (compatfn); \
414 pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \
415 TYPE_I440FX_PCI_DEVICE); \
417 DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn)
419 static void pc_i440fx_machine_options(MachineClass
*m
)
421 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
422 pcmc
->default_nic_model
= "e1000";
424 m
->family
= "pc_piix";
425 m
->desc
= "Standard PC (i440FX + PIIX, 1996)";
426 m
->default_machine_opts
= "firmware=bios-256k.bin";
427 m
->default_display
= "std";
428 machine_class_allow_dynamic_sysbus_dev(m
, TYPE_RAMFB_DEVICE
);
431 static void pc_i440fx_4_0_machine_options(MachineClass
*m
)
433 pc_i440fx_machine_options(m
);
438 DEFINE_I440FX_MACHINE(v4_0
, "pc-i440fx-4.0", NULL
,
439 pc_i440fx_4_0_machine_options
);
441 static void pc_i440fx_3_1_machine_options(MachineClass
*m
)
443 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
445 pc_i440fx_4_0_machine_options(m
);
448 pcmc
->pvh_enabled
= false;
449 compat_props_add(m
->compat_props
, hw_compat_3_1
, hw_compat_3_1_len
);
450 compat_props_add(m
->compat_props
, pc_compat_3_1
, pc_compat_3_1_len
);
453 DEFINE_I440FX_MACHINE(v3_1
, "pc-i440fx-3.1", NULL
,
454 pc_i440fx_3_1_machine_options
);
456 static void pc_i440fx_3_0_machine_options(MachineClass
*m
)
458 pc_i440fx_3_1_machine_options(m
);
459 compat_props_add(m
->compat_props
, hw_compat_3_0
, hw_compat_3_0_len
);
460 compat_props_add(m
->compat_props
, pc_compat_3_0
, pc_compat_3_0_len
);
463 DEFINE_I440FX_MACHINE(v3_0
, "pc-i440fx-3.0", NULL
,
464 pc_i440fx_3_0_machine_options
);
466 static void pc_i440fx_2_12_machine_options(MachineClass
*m
)
468 pc_i440fx_3_0_machine_options(m
);
469 compat_props_add(m
->compat_props
, hw_compat_2_12
, hw_compat_2_12_len
);
470 compat_props_add(m
->compat_props
, pc_compat_2_12
, pc_compat_2_12_len
);
473 DEFINE_I440FX_MACHINE(v2_12
, "pc-i440fx-2.12", NULL
,
474 pc_i440fx_2_12_machine_options
);
476 static void pc_i440fx_2_11_machine_options(MachineClass
*m
)
478 pc_i440fx_2_12_machine_options(m
);
479 compat_props_add(m
->compat_props
, hw_compat_2_11
, hw_compat_2_11_len
);
480 compat_props_add(m
->compat_props
, pc_compat_2_11
, pc_compat_2_11_len
);
483 DEFINE_I440FX_MACHINE(v2_11
, "pc-i440fx-2.11", NULL
,
484 pc_i440fx_2_11_machine_options
);
486 static void pc_i440fx_2_10_machine_options(MachineClass
*m
)
488 pc_i440fx_2_11_machine_options(m
);
489 compat_props_add(m
->compat_props
, hw_compat_2_10
, hw_compat_2_10_len
);
490 compat_props_add(m
->compat_props
, pc_compat_2_10
, pc_compat_2_10_len
);
491 m
->auto_enable_numa_with_memhp
= false;
494 DEFINE_I440FX_MACHINE(v2_10
, "pc-i440fx-2.10", NULL
,
495 pc_i440fx_2_10_machine_options
);
497 static void pc_i440fx_2_9_machine_options(MachineClass
*m
)
499 pc_i440fx_2_10_machine_options(m
);
500 compat_props_add(m
->compat_props
, hw_compat_2_9
, hw_compat_2_9_len
);
501 compat_props_add(m
->compat_props
, pc_compat_2_9
, pc_compat_2_9_len
);
502 m
->numa_auto_assign_ram
= numa_legacy_auto_assign_ram
;
505 DEFINE_I440FX_MACHINE(v2_9
, "pc-i440fx-2.9", NULL
,
506 pc_i440fx_2_9_machine_options
);
508 static void pc_i440fx_2_8_machine_options(MachineClass
*m
)
510 pc_i440fx_2_9_machine_options(m
);
511 compat_props_add(m
->compat_props
, hw_compat_2_8
, hw_compat_2_8_len
);
512 compat_props_add(m
->compat_props
, pc_compat_2_8
, pc_compat_2_8_len
);
515 DEFINE_I440FX_MACHINE(v2_8
, "pc-i440fx-2.8", NULL
,
516 pc_i440fx_2_8_machine_options
);
518 static void pc_i440fx_2_7_machine_options(MachineClass
*m
)
520 pc_i440fx_2_8_machine_options(m
);
521 compat_props_add(m
->compat_props
, hw_compat_2_7
, hw_compat_2_7_len
);
522 compat_props_add(m
->compat_props
, pc_compat_2_7
, pc_compat_2_7_len
);
525 DEFINE_I440FX_MACHINE(v2_7
, "pc-i440fx-2.7", NULL
,
526 pc_i440fx_2_7_machine_options
);
528 static void pc_i440fx_2_6_machine_options(MachineClass
*m
)
530 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
532 pc_i440fx_2_7_machine_options(m
);
533 pcmc
->legacy_cpu_hotplug
= true;
534 pcmc
->linuxboot_dma_enabled
= false;
535 compat_props_add(m
->compat_props
, hw_compat_2_6
, hw_compat_2_6_len
);
536 compat_props_add(m
->compat_props
, pc_compat_2_6
, pc_compat_2_6_len
);
539 DEFINE_I440FX_MACHINE(v2_6
, "pc-i440fx-2.6", NULL
,
540 pc_i440fx_2_6_machine_options
);
542 static void pc_i440fx_2_5_machine_options(MachineClass
*m
)
544 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
546 pc_i440fx_2_6_machine_options(m
);
547 pcmc
->save_tsc_khz
= false;
548 m
->legacy_fw_cfg_order
= 1;
549 compat_props_add(m
->compat_props
, hw_compat_2_5
, hw_compat_2_5_len
);
550 compat_props_add(m
->compat_props
, pc_compat_2_5
, pc_compat_2_5_len
);
553 DEFINE_I440FX_MACHINE(v2_5
, "pc-i440fx-2.5", NULL
,
554 pc_i440fx_2_5_machine_options
);
556 static void pc_i440fx_2_4_machine_options(MachineClass
*m
)
558 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
560 pc_i440fx_2_5_machine_options(m
);
561 m
->hw_version
= "2.4.0";
562 pcmc
->broken_reserved_end
= true;
563 compat_props_add(m
->compat_props
, hw_compat_2_4
, hw_compat_2_4_len
);
564 compat_props_add(m
->compat_props
, pc_compat_2_4
, pc_compat_2_4_len
);
567 DEFINE_I440FX_MACHINE(v2_4
, "pc-i440fx-2.4", NULL
,
568 pc_i440fx_2_4_machine_options
)
570 static void pc_i440fx_2_3_machine_options(MachineClass
*m
)
572 pc_i440fx_2_4_machine_options(m
);
573 m
->hw_version
= "2.3.0";
574 compat_props_add(m
->compat_props
, hw_compat_2_3
, hw_compat_2_3_len
);
575 compat_props_add(m
->compat_props
, pc_compat_2_3
, pc_compat_2_3_len
);
578 DEFINE_I440FX_MACHINE(v2_3
, "pc-i440fx-2.3", pc_compat_2_3_fn
,
579 pc_i440fx_2_3_machine_options
);
581 static void pc_i440fx_2_2_machine_options(MachineClass
*m
)
583 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
585 pc_i440fx_2_3_machine_options(m
);
586 m
->hw_version
= "2.2.0";
587 m
->default_machine_opts
= "firmware=bios-256k.bin,suppress-vmdesc=on";
588 compat_props_add(m
->compat_props
, hw_compat_2_2
, hw_compat_2_2_len
);
589 compat_props_add(m
->compat_props
, pc_compat_2_2
, pc_compat_2_2_len
);
590 pcmc
->rsdp_in_ram
= false;
593 DEFINE_I440FX_MACHINE(v2_2
, "pc-i440fx-2.2", pc_compat_2_2_fn
,
594 pc_i440fx_2_2_machine_options
);
596 static void pc_i440fx_2_1_machine_options(MachineClass
*m
)
598 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
600 pc_i440fx_2_2_machine_options(m
);
601 m
->hw_version
= "2.1.0";
602 m
->default_display
= NULL
;
603 compat_props_add(m
->compat_props
, hw_compat_2_1
, hw_compat_2_1_len
);
604 compat_props_add(m
->compat_props
, pc_compat_2_1
, pc_compat_2_1_len
);
605 pcmc
->smbios_uuid_encoded
= false;
606 pcmc
->enforce_aligned_dimm
= false;
609 DEFINE_I440FX_MACHINE(v2_1
, "pc-i440fx-2.1", pc_compat_2_1_fn
,
610 pc_i440fx_2_1_machine_options
);
612 static void pc_i440fx_2_0_machine_options(MachineClass
*m
)
614 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
616 pc_i440fx_2_1_machine_options(m
);
617 m
->hw_version
= "2.0.0";
618 compat_props_add(m
->compat_props
, pc_compat_2_0
, pc_compat_2_0_len
);
619 pcmc
->smbios_legacy_mode
= true;
620 pcmc
->has_reserved_memory
= false;
621 /* This value depends on the actual DSDT and SSDT compiled into
622 * the source QEMU; unfortunately it depends on the binary and
623 * not on the machine type, so we cannot make pc-i440fx-1.7 work on
624 * both QEMU 1.7 and QEMU 2.0.
626 * Large variations cause migration to fail for more than one
627 * consecutive value of the "-smp" maxcpus option.
629 * For small variations of the kind caused by different iasl versions,
630 * the 4k rounding usually leaves slack. However, there could be still
631 * one or two values that break. For QEMU 1.7 and QEMU 2.0 the
632 * slack is only ~10 bytes before one "-smp maxcpus" value breaks!
634 * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on
635 * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418.
637 pcmc
->legacy_acpi_table_size
= 6652;
638 pcmc
->acpi_data_size
= 0x10000;
641 DEFINE_I440FX_MACHINE(v2_0
, "pc-i440fx-2.0", pc_compat_2_0_fn
,
642 pc_i440fx_2_0_machine_options
);
644 static void pc_i440fx_1_7_machine_options(MachineClass
*m
)
646 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
648 pc_i440fx_2_0_machine_options(m
);
649 m
->hw_version
= "1.7.0";
650 m
->default_machine_opts
= NULL
;
651 m
->option_rom_has_mr
= true;
652 compat_props_add(m
->compat_props
, pc_compat_1_7
, pc_compat_1_7_len
);
653 pcmc
->smbios_defaults
= false;
654 pcmc
->gigabyte_align
= false;
655 pcmc
->legacy_acpi_table_size
= 6414;
658 DEFINE_I440FX_MACHINE(v1_7
, "pc-i440fx-1.7", pc_compat_1_7_fn
,
659 pc_i440fx_1_7_machine_options
);
661 static void pc_i440fx_1_6_machine_options(MachineClass
*m
)
663 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
665 pc_i440fx_1_7_machine_options(m
);
666 m
->hw_version
= "1.6.0";
667 m
->rom_file_has_mr
= false;
668 compat_props_add(m
->compat_props
, pc_compat_1_6
, pc_compat_1_6_len
);
669 pcmc
->has_acpi_build
= false;
672 DEFINE_I440FX_MACHINE(v1_6
, "pc-i440fx-1.6", pc_compat_1_6_fn
,
673 pc_i440fx_1_6_machine_options
);
675 static void pc_i440fx_1_5_machine_options(MachineClass
*m
)
677 pc_i440fx_1_6_machine_options(m
);
678 m
->hw_version
= "1.5.0";
679 compat_props_add(m
->compat_props
, pc_compat_1_5
, pc_compat_1_5_len
);
682 DEFINE_I440FX_MACHINE(v1_5
, "pc-i440fx-1.5", pc_compat_1_5_fn
,
683 pc_i440fx_1_5_machine_options
);
685 static void pc_i440fx_1_4_machine_options(MachineClass
*m
)
687 pc_i440fx_1_5_machine_options(m
);
688 m
->hw_version
= "1.4.0";
689 m
->hot_add_cpu
= NULL
;
690 compat_props_add(m
->compat_props
, pc_compat_1_4
, pc_compat_1_4_len
);
693 DEFINE_I440FX_MACHINE(v1_4
, "pc-i440fx-1.4", pc_compat_1_4_fn
,
694 pc_i440fx_1_4_machine_options
);
696 static void pc_i440fx_1_3_machine_options(MachineClass
*m
)
698 static GlobalProperty compat
[] = {
699 PC_CPU_MODEL_IDS("1.3.0")
700 { "usb-tablet", "usb_version", "1" },
701 { "virtio-net-pci", "ctrl_mac_addr", "off" },
702 { "virtio-net-pci", "mq", "off" },
703 { "e1000", "autonegotiation", "off" },
706 pc_i440fx_1_4_machine_options(m
);
707 m
->hw_version
= "1.3.0";
708 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
711 DEFINE_I440FX_MACHINE(v1_3
, "pc-1.3", pc_compat_1_3
,
712 pc_i440fx_1_3_machine_options
);
715 static void pc_i440fx_1_2_machine_options(MachineClass
*m
)
717 static GlobalProperty compat
[] = {
718 PC_CPU_MODEL_IDS("1.2.0")
719 { "nec-usb-xhci", "msi", "off" },
720 { "nec-usb-xhci", "msix", "off" },
721 { "qxl", "revision", "3" },
722 { "qxl-vga", "revision", "3" },
723 { "VGA", "mmio", "off" },
726 pc_i440fx_1_3_machine_options(m
);
727 m
->hw_version
= "1.2.0";
728 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
731 DEFINE_I440FX_MACHINE(v1_2
, "pc-1.2", pc_compat_1_2
,
732 pc_i440fx_1_2_machine_options
);
735 static void pc_i440fx_1_1_machine_options(MachineClass
*m
)
737 static GlobalProperty compat
[] = {
738 PC_CPU_MODEL_IDS("1.1.0")
739 { "virtio-scsi-pci", "hotplug", "off" },
740 { "virtio-scsi-pci", "param_change", "off" },
741 { "VGA", "vgamem_mb", "8" },
742 { "vmware-svga", "vgamem_mb", "8" },
743 { "qxl-vga", "vgamem_mb", "8" },
744 { "qxl", "vgamem_mb", "8" },
745 { "virtio-blk-pci", "config-wce", "off" },
748 pc_i440fx_1_2_machine_options(m
);
749 m
->hw_version
= "1.1.0";
750 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
753 DEFINE_I440FX_MACHINE(v1_1
, "pc-1.1", pc_compat_1_2
,
754 pc_i440fx_1_1_machine_options
);
756 static void pc_i440fx_1_0_machine_options(MachineClass
*m
)
758 static GlobalProperty compat
[] = {
759 PC_CPU_MODEL_IDS("1.0")
760 { TYPE_ISA_FDC
, "check_media_rate", "off" },
761 { "virtio-balloon-pci", "class", stringify(PCI_CLASS_MEMORY_RAM
) },
762 { "apic-common", "vapic", "off" },
763 { TYPE_USB_DEVICE
, "full-path", "no" },
766 pc_i440fx_1_1_machine_options(m
);
767 m
->hw_version
= "1.0";
768 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
771 DEFINE_I440FX_MACHINE(v1_0
, "pc-1.0", pc_compat_1_2
,
772 pc_i440fx_1_0_machine_options
);
775 static void pc_i440fx_0_15_machine_options(MachineClass
*m
)
777 static GlobalProperty compat
[] = {
778 PC_CPU_MODEL_IDS("0.15")
781 pc_i440fx_1_0_machine_options(m
);
782 m
->hw_version
= "0.15";
783 m
->deprecation_reason
= "use a newer machine type instead";
784 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
787 DEFINE_I440FX_MACHINE(v0_15
, "pc-0.15", pc_compat_1_2
,
788 pc_i440fx_0_15_machine_options
);
791 static void pc_i440fx_0_14_machine_options(MachineClass
*m
)
793 static GlobalProperty compat
[] = {
794 PC_CPU_MODEL_IDS("0.14")
795 { "virtio-blk-pci", "event_idx", "off" },
796 { "virtio-serial-pci", "event_idx", "off" },
797 { "virtio-net-pci", "event_idx", "off" },
798 { "virtio-balloon-pci", "event_idx", "off" },
799 { "qxl", "revision", "2" },
800 { "qxl-vga", "revision", "2" },
803 pc_i440fx_0_15_machine_options(m
);
804 m
->hw_version
= "0.14";
805 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
808 DEFINE_I440FX_MACHINE(v0_14
, "pc-0.14", pc_compat_1_2
,
809 pc_i440fx_0_14_machine_options
);
811 static void pc_i440fx_0_13_machine_options(MachineClass
*m
)
813 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
814 static GlobalProperty compat
[] = {
815 PC_CPU_MODEL_IDS("0.13")
816 { TYPE_PCI_DEVICE
, "command_serr_enable", "off" },
817 { "AC97", "use_broken_id", "1" },
818 { "virtio-9p-pci", "vectors", "0" },
819 { "VGA", "rombar", "0" },
820 { "vmware-svga", "rombar", "0" },
823 pc_i440fx_0_14_machine_options(m
);
824 m
->hw_version
= "0.13";
825 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
826 pcmc
->kvmclock_enabled
= false;
829 DEFINE_I440FX_MACHINE(v0_13
, "pc-0.13", pc_compat_0_13
,
830 pc_i440fx_0_13_machine_options
);
832 static void pc_i440fx_0_12_machine_options(MachineClass
*m
)
834 static GlobalProperty compat
[] = {
835 PC_CPU_MODEL_IDS("0.12")
836 { "virtio-serial-pci", "max_ports", "1" },
837 { "virtio-serial-pci", "vectors", "0" },
838 { "usb-mouse", "serial", "1" },
839 { "usb-tablet", "serial", "1" },
840 { "usb-kbd", "serial", "1" },
843 pc_i440fx_0_13_machine_options(m
);
844 m
->hw_version
= "0.12";
845 compat_props_add(m
->compat_props
, compat
, G_N_ELEMENTS(compat
));
848 DEFINE_I440FX_MACHINE(v0_12
, "pc-0.12", pc_compat_0_13
,
849 pc_i440fx_0_12_machine_options
);
852 uint16_t gpu_device_id
;
853 uint16_t pch_device_id
;
854 uint8_t pch_revision_id
;
857 /* In real world different GPU should have different PCH. But actually
858 * the different PCH DIDs likely map to different PCH SKUs. We do the
859 * same thing for the GPU. For PCH, the different SKUs are going to be
860 * all the same silicon design and implementation, just different
861 * features turn on and off with fuses. The SW interfaces should be
862 * consistent across all SKUs in a given family (eg LPT). But just same
863 * features may not be supported.
865 * Most of these different PCH features probably don't matter to the
866 * Gfx driver, but obviously any difference in display port connections
867 * will so it should be fine with any PCH in case of passthrough.
869 * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell)
870 * scenarios, 0x9cc3 for BDW(Broadwell).
872 static const IGDDeviceIDInfo igd_combo_id_infos
[] = {
874 {0x0402, 0x8c4e, 0x04}, /* HSWGT1D, HSWD_w7 */
875 {0x0406, 0x8c4e, 0x04}, /* HSWGT1M, HSWM_w7 */
876 {0x0412, 0x8c4e, 0x04}, /* HSWGT2D, HSWD_w7 */
877 {0x0416, 0x8c4e, 0x04}, /* HSWGT2M, HSWM_w7 */
878 {0x041E, 0x8c4e, 0x04}, /* HSWGT15D, HSWD_w7 */
880 {0x0A06, 0x8c4e, 0x04}, /* HSWGT1UT, HSWM_w7 */
881 {0x0A16, 0x8c4e, 0x04}, /* HSWGT2UT, HSWM_w7 */
882 {0x0A26, 0x8c4e, 0x06}, /* HSWGT3UT, HSWM_w7 */
883 {0x0A2E, 0x8c4e, 0x04}, /* HSWGT3UT28W, HSWM_w7 */
884 {0x0A1E, 0x8c4e, 0x04}, /* HSWGT2UX, HSWM_w7 */
885 {0x0A0E, 0x8c4e, 0x04}, /* HSWGT1ULX, HSWM_w7 */
887 {0x0D26, 0x8c4e, 0x04}, /* HSWGT3CW, HSWM_w7 */
888 {0x0D22, 0x8c4e, 0x04}, /* HSWGT3CWDT, HSWD_w7 */
890 {0x041A, 0x8c4e, 0x04}, /* HSWSVGT2, HSWD_w7 */
892 {0x040A, 0x8c4e, 0x04}, /* HSWSVGT1, HSWD_w7 */
894 {0x1606, 0x9cc3, 0x03}, /* BDWULTGT1, BDWM_w7 */
895 {0x1616, 0x9cc3, 0x03}, /* BDWULTGT2, BDWM_w7 */
896 {0x1626, 0x9cc3, 0x03}, /* BDWULTGT3, BDWM_w7 */
897 {0x160E, 0x9cc3, 0x03}, /* BDWULXGT1, BDWM_w7 */
898 {0x161E, 0x9cc3, 0x03}, /* BDWULXGT2, BDWM_w7 */
899 {0x1602, 0x9cc3, 0x03}, /* BDWHALOGT1, BDWM_w7 */
900 {0x1612, 0x9cc3, 0x03}, /* BDWHALOGT2, BDWM_w7 */
901 {0x1622, 0x9cc3, 0x03}, /* BDWHALOGT3, BDWM_w7 */
902 {0x162B, 0x9cc3, 0x03}, /* BDWHALO28W, BDWM_w7 */
903 {0x162A, 0x9cc3, 0x03}, /* BDWGT3WRKS, BDWM_w7 */
904 {0x162D, 0x9cc3, 0x03}, /* BDWGT3SRVR, BDWM_w7 */
907 static void isa_bridge_class_init(ObjectClass
*klass
, void *data
)
909 DeviceClass
*dc
= DEVICE_CLASS(klass
);
910 PCIDeviceClass
*k
= PCI_DEVICE_CLASS(klass
);
912 dc
->desc
= "ISA bridge faked to support IGD PT";
913 k
->vendor_id
= PCI_VENDOR_ID_INTEL
;
914 k
->class_id
= PCI_CLASS_BRIDGE_ISA
;
917 static TypeInfo isa_bridge_info
= {
918 .name
= "igd-passthrough-isa-bridge",
919 .parent
= TYPE_PCI_DEVICE
,
920 .instance_size
= sizeof(PCIDevice
),
921 .class_init
= isa_bridge_class_init
,
922 .interfaces
= (InterfaceInfo
[]) {
923 { INTERFACE_CONVENTIONAL_PCI_DEVICE
},
928 static void pt_graphics_register_types(void)
930 type_register_static(&isa_bridge_info
);
932 type_init(pt_graphics_register_types
)
934 void igd_passthrough_isa_bridge_create(PCIBus
*bus
, uint16_t gpu_dev_id
)
936 struct PCIDevice
*bridge_dev
;
938 uint16_t pch_dev_id
= 0xffff;
941 num
= ARRAY_SIZE(igd_combo_id_infos
);
942 for (i
= 0; i
< num
; i
++) {
943 if (gpu_dev_id
== igd_combo_id_infos
[i
].gpu_device_id
) {
944 pch_dev_id
= igd_combo_id_infos
[i
].pch_device_id
;
945 pch_rev_id
= igd_combo_id_infos
[i
].pch_revision_id
;
949 if (pch_dev_id
== 0xffff) {
953 /* Currently IGD drivers always need to access PCH by 1f.0. */
954 bridge_dev
= pci_create_simple(bus
, PCI_DEVFN(0x1f, 0),
955 "igd-passthrough-isa-bridge");
958 * Note that vendor id is always PCI_VENDOR_ID_INTEL.
961 fprintf(stderr
, "set igd-passthrough-isa-bridge failed!\n");
964 pci_config_set_device_id(bridge_dev
->config
, pch_dev_id
);
965 pci_config_set_revision(bridge_dev
->config
, pch_rev_id
);
968 static void isapc_machine_options(MachineClass
*m
)
970 PCMachineClass
*pcmc
= PC_MACHINE_CLASS(m
);
971 m
->desc
= "ISA-only PC";
973 m
->option_rom_has_mr
= true;
974 m
->rom_file_has_mr
= false;
975 pcmc
->pci_enabled
= false;
976 pcmc
->has_acpi_build
= false;
977 pcmc
->smbios_defaults
= false;
978 pcmc
->gigabyte_align
= false;
979 pcmc
->smbios_legacy_mode
= true;
980 pcmc
->has_reserved_memory
= false;
981 pcmc
->default_nic_model
= "ne2k_isa";
982 m
->default_cpu_type
= X86_CPU_TYPE_NAME("486");
985 DEFINE_PC_MACHINE(isapc
, "isapc", pc_init_isa
,
986 isapc_machine_options
);
990 static void xenfv_machine_options(MachineClass
*m
)
992 m
->desc
= "Xen Fully-virtualized PC";
993 m
->max_cpus
= HVM_MAX_VCPUS
;
994 m
->default_machine_opts
= "accel=xen";
997 DEFINE_PC_MACHINE(xenfv
, "xenfv", pc_xen_hvm_init
,
998 xenfv_machine_options
);