]>
Commit | Line | Data |
---|---|---|
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 | ||
b6a0aa05 | 25 | #include "qemu/osdep.h" |
ae0a5466 | 26 | |
d471bf3e | 27 | #include "qemu/units.h" |
83c9f4ca | 28 | #include "hw/hw.h" |
04920fc0 | 29 | #include "hw/loader.h" |
0d09e41a PB |
30 | #include "hw/i386/pc.h" |
31 | #include "hw/i386/apic.h" | |
94692dcd | 32 | #include "hw/display/ramfb.h" |
a2eb5c0c | 33 | #include "hw/firmware/smbios.h" |
83c9f4ca PB |
34 | #include "hw/pci/pci.h" |
35 | #include "hw/pci/pci_ids.h" | |
36 | #include "hw/usb.h" | |
1422e32d | 37 | #include "net/net.h" |
83c9f4ca PB |
38 | #include "hw/boards.h" |
39 | #include "hw/ide.h" | |
9c17d615 | 40 | #include "sysemu/kvm.h" |
83c9f4ca | 41 | #include "hw/kvm/clock.h" |
9c17d615 | 42 | #include "sysemu/sysemu.h" |
83c9f4ca | 43 | #include "hw/sysbus.h" |
9c17d615 | 44 | #include "sysemu/arch_init.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" |
e688df6b | 51 | #include "qapi/error.h" |
c87b1520 | 52 | #include "qemu/error-report.h" |
29d3ccde | 53 | #ifdef CONFIG_XEN |
998250e9 TC |
54 | #include <xen/hvm/hvm_info_table.h> |
55 | #include "hw/xen/xen_pt.h" | |
29d3ccde | 56 | #endif |
84a899de | 57 | #include "migration/global_state.h" |
c4b63b7c | 58 | #include "migration/misc.h" |
32c18a2d | 59 | #include "kvm_i386.h" |
3bfe5716 | 60 | #include "sysemu/numa.h" |
845773ab IY |
61 | |
62 | #define MAX_IDE_BUS 2 | |
63 | ||
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 }; | |
67 | ||
68 | /* PC hardware initialisation */ | |
76d39ab4 TC |
69 | static void pc_init1(MachineState *machine, |
70 | const char *host_type, const char *pci_type) | |
845773ab | 71 | { |
ec68007a | 72 | PCMachineState *pcms = PC_MACHINE(machine); |
7102fa70 | 73 | PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); |
1e099556 EH |
74 | MemoryRegion *system_memory = get_system_memory(); |
75 | MemoryRegion *system_io = get_system_io(); | |
845773ab | 76 | int i; |
845773ab | 77 | PCIBus *pci_bus; |
48a18b3c | 78 | ISABus *isa_bus; |
845773ab IY |
79 | PCII440FXState *i440fx_state; |
80 | int piix3_devfn = -1; | |
845773ab | 81 | qemu_irq *i8259; |
2ba154cf | 82 | qemu_irq smi_irq; |
b881fbe9 | 83 | GSIState *gsi_state; |
845773ab | 84 | DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; |
c0897e0c | 85 | BusState *idebus[MAX_IDE_BUS]; |
1d914fa0 | 86 | ISADevice *rtc_state; |
ae0a5466 AK |
87 | MemoryRegion *ram_memory; |
88 | MemoryRegion *pci_memory; | |
4463aee6 | 89 | MemoryRegion *rom_memory; |
c87b1520 | 90 | ram_addr_t lowmem; |
845773ab | 91 | |
8156d480 GH |
92 | /* |
93 | * Calculate ram split, for memory below and above 4G. It's a bit | |
94 | * complicated for backward compatibility reasons ... | |
95 | * | |
96 | * - Traditional split is 3.5G (lowmem = 0xe0000000). This is the | |
97 | * default value for max_ram_below_4g now. | |
98 | * | |
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. | |
104 | * | |
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. | |
109 | * | |
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. | |
113 | * | |
5ec7d098 GH |
114 | * - Note that Xen has its own ram setp code in xen_ram_init(), |
115 | * called via xen_hvm_init(). | |
116 | * | |
8156d480 GH |
117 | * Examples: |
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) | |
ecdbfceb | 122 | */ |
5ec7d098 GH |
123 | if (xen_enabled()) { |
124 | xen_hvm_init(pcms, &ram_memory); | |
125 | } else { | |
126 | if (!pcms->max_ram_below_4g) { | |
127 | pcms->max_ram_below_4g = 0xe0000000; /* default: 3.5G */ | |
128 | } | |
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) { | |
133 | lowmem = 0xc0000000; | |
134 | } | |
d471bf3e | 135 | if (lowmem & (1 * GiB - 1)) { |
3dc6f869 AF |
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); | |
5ec7d098 | 140 | } |
8156d480 | 141 | } |
c87b1520 | 142 | } |
c87b1520 | 143 | |
5ec7d098 GH |
144 | if (machine->ram_size >= lowmem) { |
145 | pcms->above_4g_mem_size = machine->ram_size - lowmem; | |
146 | pcms->below_4g_mem_size = lowmem; | |
147 | } else { | |
148 | pcms->above_4g_mem_size = 0; | |
149 | pcms->below_4g_mem_size = machine->ram_size; | |
150 | } | |
3c2a9669 DS |
151 | } |
152 | ||
4884b7bf | 153 | pc_cpus_init(pcms); |
3c2a9669 | 154 | |
7102fa70 | 155 | if (kvm_enabled() && pcmc->kvmclock_enabled) { |
3c2a9669 DS |
156 | kvmclock_create(); |
157 | } | |
158 | ||
7102fa70 | 159 | if (pcmc->pci_enabled) { |
4463aee6 | 160 | pci_memory = g_new(MemoryRegion, 1); |
286690e3 | 161 | memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); |
4463aee6 JK |
162 | rom_memory = pci_memory; |
163 | } else { | |
164 | pci_memory = NULL; | |
165 | rom_memory = system_memory; | |
166 | } | |
ae0a5466 | 167 | |
5db3f0de | 168 | pc_guest_info_init(pcms); |
3459a625 | 169 | |
7102fa70 | 170 | if (pcmc->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)", |
7102fa70 EH |
174 | mc->name, pcmc->smbios_legacy_mode, |
175 | pcmc->smbios_uuid_encoded, | |
86299120 | 176 | SMBIOS_ENTRY_POINT_21); |
b29ad07e MA |
177 | } |
178 | ||
845773ab | 179 | /* allocate ram and load rom/bios */ |
29d3ccde | 180 | if (!xen_enabled()) { |
62b160c0 | 181 | pc_memory_init(pcms, system_memory, |
5934e216 | 182 | rom_memory, &ram_memory); |
b33a5bbf CL |
183 | } else if (machine->kernel_filename != NULL) { |
184 | /* For xen HVM direct kernel boot, load linux here */ | |
7bc35e0f | 185 | xen_load_linux(pcms); |
29d3ccde | 186 | } |
845773ab | 187 | |
b881fbe9 | 188 | gsi_state = g_malloc0(sizeof(*gsi_state)); |
15eafc2e | 189 | if (kvm_ioapic_in_kernel()) { |
7102fa70 | 190 | kvm_pc_setup_irq_routing(pcmc->pci_enabled); |
3e6c0c4c MAL |
191 | pcms->gsi = qemu_allocate_irqs(kvm_pc_gsi_handler, gsi_state, |
192 | GSI_NUM_PINS); | |
10b61882 | 193 | } else { |
3e6c0c4c | 194 | pcms->gsi = qemu_allocate_irqs(gsi_handler, gsi_state, GSI_NUM_PINS); |
10b61882 | 195 | } |
845773ab | 196 | |
7102fa70 | 197 | if (pcmc->pci_enabled) { |
76d39ab4 TC |
198 | pci_bus = i440fx_init(host_type, |
199 | pci_type, | |
3e6c0c4c | 200 | &i440fx_state, &piix3_devfn, &isa_bus, pcms->gsi, |
3ef96221 | 201 | system_memory, system_io, machine->ram_size, |
c0aa4e1e EH |
202 | pcms->below_4g_mem_size, |
203 | pcms->above_4g_mem_size, | |
ae0a5466 | 204 | pci_memory, ram_memory); |
81ed6482 | 205 | pcms->bus = pci_bus; |
845773ab IY |
206 | } else { |
207 | pci_bus = NULL; | |
02a89b21 | 208 | i440fx_state = NULL; |
d10e5432 MA |
209 | isa_bus = isa_bus_new(NULL, get_system_memory(), system_io, |
210 | &error_abort); | |
57285cc3 | 211 | no_hpet = 1; |
845773ab | 212 | } |
3e6c0c4c | 213 | isa_bus_irqs(isa_bus, pcms->gsi); |
845773ab | 214 | |
15eafc2e | 215 | if (kvm_pic_in_kernel()) { |
10b61882 JK |
216 | i8259 = kvm_i8259_init(isa_bus); |
217 | } else if (xen_enabled()) { | |
218 | i8259 = xen_interrupt_controller_init(); | |
219 | } else { | |
0b0cc076 | 220 | i8259 = i8259_init(isa_bus, pc_allocate_cpu_irq()); |
4bae1efe RH |
221 | } |
222 | ||
43a0db35 JK |
223 | for (i = 0; i < ISA_NUM_IRQS; i++) { |
224 | gsi_state->i8259_irq[i] = i8259[i]; | |
225 | } | |
2ba154cf | 226 | g_free(i8259); |
7102fa70 | 227 | if (pcmc->pci_enabled) { |
a39e3564 | 228 | ioapic_init_gsi(gsi_state, "i440fx"); |
4bae1efe RH |
229 | } |
230 | ||
3e6c0c4c | 231 | pc_register_ferr_irq(pcms->gsi[13]); |
845773ab | 232 | |
7102fa70 | 233 | pc_vga_init(isa_bus, pcmc->pci_enabled ? pci_bus : NULL); |
01195b73 | 234 | |
7fb1cf16 | 235 | assert(pcms->vmport != ON_OFF_AUTO__MAX); |
ec68007a EH |
236 | if (pcms->vmport == ON_OFF_AUTO_AUTO) { |
237 | pcms->vmport = xen_enabled() ? ON_OFF_AUTO_OFF : ON_OFF_AUTO_ON; | |
d1048bef DS |
238 | } |
239 | ||
845773ab | 240 | /* init basic PC hardware */ |
3e6c0c4c | 241 | pc_basic_device_init(isa_bus, pcms->gsi, &rtc_state, true, |
f5878b03 CM |
242 | (pcms->vmport != ON_OFF_AUTO_ON), pcms->pit_enabled, |
243 | 0x4); | |
845773ab | 244 | |
4b9c264b | 245 | pc_nic_init(pcmc, isa_bus, pci_bus); |
845773ab | 246 | |
d8f94e1b | 247 | ide_drive_get(hd, ARRAY_SIZE(hd)); |
7102fa70 | 248 | if (pcmc->pci_enabled) { |
c0897e0c | 249 | PCIDevice *dev; |
679f4f8b SS |
250 | if (xen_enabled()) { |
251 | dev = pci_piix3_xen_ide_init(pci_bus, hd, piix3_devfn + 1); | |
252 | } else { | |
253 | dev = pci_piix3_ide_init(pci_bus, hd, piix3_devfn + 1); | |
254 | } | |
c0897e0c MA |
255 | idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); |
256 | idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); | |
845773ab IY |
257 | } else { |
258 | for(i = 0; i < MAX_IDE_BUS; i++) { | |
c0897e0c | 259 | ISADevice *dev; |
61de3676 | 260 | char busname[] = "ide.0"; |
48a18b3c HP |
261 | dev = isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], |
262 | ide_irq[i], | |
c0897e0c | 263 | hd[MAX_IDE_DEVS * i], hd[MAX_IDE_DEVS * i + 1]); |
61de3676 AG |
264 | /* |
265 | * The ide bus name is ide.0 for the first bus and ide.1 for the | |
266 | * second one. | |
267 | */ | |
268 | busname[4] = '0' + i; | |
269 | idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); | |
845773ab IY |
270 | } |
271 | } | |
272 | ||
88076854 | 273 | pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); |
845773ab | 274 | |
4bcbe0b6 | 275 | if (pcmc->pci_enabled && machine_usb(machine)) { |
afb9a60e | 276 | pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); |
845773ab IY |
277 | } |
278 | ||
7102fa70 | 279 | if (pcmc->pci_enabled && acpi_enabled) { |
781bbd6b | 280 | DeviceState *piix4_pm; |
a5c82852 | 281 | I2CBus *smbus; |
845773ab | 282 | |
2ba154cf | 283 | smi_irq = qemu_allocate_irq(pc_acpi_smi_interrupt, first_cpu, 0); |
845773ab IY |
284 | /* TODO: Populate SPD eeprom data. */ |
285 | smbus = piix4_pm_init(pci_bus, piix3_devfn + 3, 0xb100, | |
3e6c0c4c | 286 | pcms->gsi[9], smi_irq, |
ec68007a | 287 | pc_machine_is_smm_enabled(pcms), |
355023f2 | 288 | &piix4_pm); |
a88df0b9 | 289 | smbus_eeprom_init(smbus, 8, NULL, 0); |
781bbd6b IM |
290 | |
291 | object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP, | |
292 | TYPE_HOTPLUG_HANDLER, | |
ec68007a | 293 | (Object **)&pcms->acpi_dev, |
781bbd6b | 294 | object_property_allow_set_link, |
265b578c | 295 | OBJ_PROP_LINK_STRONG, &error_abort); |
781bbd6b IM |
296 | object_property_set_link(OBJECT(machine), OBJECT(piix4_pm), |
297 | PC_MACHINE_ACPI_DEVICE_PROP, &error_abort); | |
845773ab IY |
298 | } |
299 | ||
5fe79386 XG |
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)); | |
303 | } | |
845773ab IY |
304 | } |
305 | ||
79859507 EH |
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(). | |
311 | */ | |
312 | ||
5cb50e0a JW |
313 | static void pc_compat_2_3(MachineState *machine) |
314 | { | |
355023f2 | 315 | PCMachineState *pcms = PC_MACHINE(machine); |
355023f2 PB |
316 | if (kvm_enabled()) { |
317 | pcms->smm = ON_OFF_AUTO_OFF; | |
318 | } | |
5cb50e0a JW |
319 | } |
320 | ||
64bbd372 PB |
321 | static void pc_compat_2_2(MachineState *machine) |
322 | { | |
5cb50e0a | 323 | pc_compat_2_3(machine); |
64bbd372 PB |
324 | } |
325 | ||
2cad57c7 EH |
326 | static void pc_compat_2_1(MachineState *machine) |
327 | { | |
64bbd372 | 328 | pc_compat_2_2(machine); |
5114e842 | 329 | x86_cpu_change_kvm_default("svm", NULL); |
2cad57c7 EH |
330 | } |
331 | ||
3ef96221 | 332 | static void pc_compat_2_0(MachineState *machine) |
3458b2b0 | 333 | { |
2cad57c7 | 334 | pc_compat_2_1(machine); |
3458b2b0 MT |
335 | } |
336 | ||
3ef96221 | 337 | static void pc_compat_1_7(MachineState *machine) |
b29ad07e | 338 | { |
3ef96221 | 339 | pc_compat_2_0(machine); |
5114e842 | 340 | x86_cpu_change_kvm_default("x2apic", NULL); |
b29ad07e MA |
341 | } |
342 | ||
3ef96221 | 343 | static void pc_compat_1_6(MachineState *machine) |
f8c457b8 | 344 | { |
3ef96221 | 345 | pc_compat_1_7(machine); |
f8c457b8 MT |
346 | } |
347 | ||
3ef96221 | 348 | static void pc_compat_1_5(MachineState *machine) |
9604f70f | 349 | { |
3ef96221 | 350 | pc_compat_1_6(machine); |
9604f70f MT |
351 | } |
352 | ||
3ef96221 | 353 | static void pc_compat_1_4(MachineState *machine) |
9953f882 | 354 | { |
3ef96221 | 355 | pc_compat_1_5(machine); |
9953f882 MA |
356 | } |
357 | ||
3ef96221 | 358 | static void pc_compat_1_3(MachineState *machine) |
8932cfdf | 359 | { |
3ef96221 | 360 | pc_compat_1_4(machine); |
8932cfdf | 361 | enable_compat_apic_id_mode(); |
89b439f3 EH |
362 | } |
363 | ||
364 | /* PC compat function for pc-0.14 to pc-1.2 */ | |
3ef96221 | 365 | static void pc_compat_1_2(MachineState *machine) |
89b439f3 | 366 | { |
3ef96221 | 367 | pc_compat_1_3(machine); |
5114e842 | 368 | x86_cpu_change_kvm_default("kvm-pv-eoi", NULL); |
89b439f3 EH |
369 | } |
370 | ||
72d164aa EH |
371 | /* PC compat function for pc-0.10 to pc-0.13 */ |
372 | static void pc_compat_0_13(MachineState *machine) | |
373 | { | |
374 | pc_compat_1_2(machine); | |
72d164aa EH |
375 | } |
376 | ||
3ef96221 | 377 | static void pc_init_isa(MachineState *machine) |
845773ab | 378 | { |
76d39ab4 | 379 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, TYPE_I440FX_PCI_DEVICE); |
845773ab IY |
380 | } |
381 | ||
29d3ccde | 382 | #ifdef CONFIG_XEN |
998250e9 TC |
383 | static void pc_xen_hvm_init_pci(MachineState *machine) |
384 | { | |
385 | const char *pci_type = has_igd_gfx_passthru ? | |
386 | TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE : TYPE_I440FX_PCI_DEVICE; | |
387 | ||
388 | pc_init1(machine, | |
389 | TYPE_I440FX_PCI_HOST_BRIDGE, | |
390 | pci_type); | |
391 | } | |
392 | ||
3ef96221 | 393 | static void pc_xen_hvm_init(MachineState *machine) |
29d3ccde | 394 | { |
e492dc5a | 395 | PCMachineState *pcms = PC_MACHINE(machine); |
39ae4972 | 396 | |
a88ae0d4 EH |
397 | if (!xen_enabled()) { |
398 | error_report("xenfv machine requires the xen accelerator"); | |
399 | exit(1); | |
400 | } | |
401 | ||
998250e9 | 402 | pc_xen_hvm_init_pci(machine); |
e492dc5a | 403 | pci_create_simple(pcms->bus, -1, "xen-platform"); |
29d3ccde AP |
404 | } |
405 | #endif | |
406 | ||
99fbeafe EH |
407 | #define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ |
408 | static void pc_init_##suffix(MachineState *machine) \ | |
409 | { \ | |
410 | void (*compat)(MachineState *m) = (compatfn); \ | |
411 | if (compat) { \ | |
412 | compat(machine); \ | |
413 | } \ | |
76d39ab4 TC |
414 | pc_init1(machine, TYPE_I440FX_PCI_HOST_BRIDGE, \ |
415 | TYPE_I440FX_PCI_DEVICE); \ | |
99fbeafe EH |
416 | } \ |
417 | DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) | |
fddd179a | 418 | |
865906f7 | 419 | static void pc_i440fx_machine_options(MachineClass *m) |
fddd179a | 420 | { |
4b9c264b PB |
421 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
422 | pcmc->default_nic_model = "e1000"; | |
423 | ||
fddd179a EH |
424 | m->family = "pc_piix"; |
425 | m->desc = "Standard PC (i440FX + PIIX, 1996)"; | |
254bdb1c EH |
426 | m->default_machine_opts = "firmware=bios-256k.bin"; |
427 | m->default_display = "std"; | |
94692dcd | 428 | machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); |
fddd179a EH |
429 | } |
430 | ||
84e060bf | 431 | static void pc_i440fx_4_0_machine_options(MachineClass *m) |
fddd179a EH |
432 | { |
433 | pc_i440fx_machine_options(m); | |
fddd179a EH |
434 | m->alias = "pc"; |
435 | m->is_default = 1; | |
436 | } | |
aeca6e8d | 437 | |
84e060bf AW |
438 | DEFINE_I440FX_MACHINE(v4_0, "pc-i440fx-4.0", NULL, |
439 | pc_i440fx_4_0_machine_options); | |
440 | ||
441 | static void pc_i440fx_3_1_machine_options(MachineClass *m) | |
442 | { | |
443 | pc_i440fx_4_0_machine_options(m); | |
444 | m->is_default = 0; | |
445 | m->alias = NULL; | |
446 | SET_MACHINE_COMPAT(m, PC_COMPAT_3_1); | |
447 | } | |
448 | ||
4a93722f MAL |
449 | DEFINE_I440FX_MACHINE(v3_1, "pc-i440fx-3.1", NULL, |
450 | pc_i440fx_3_1_machine_options); | |
451 | ||
452 | static void pc_i440fx_3_0_machine_options(MachineClass *m) | |
453 | { | |
454 | pc_i440fx_3_1_machine_options(m); | |
4a93722f MAL |
455 | SET_MACHINE_COMPAT(m, PC_COMPAT_3_0); |
456 | } | |
457 | ||
aa78a16d PM |
458 | DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL, |
459 | pc_i440fx_3_0_machine_options); | |
968ee4ad BM |
460 | |
461 | static void pc_i440fx_2_12_machine_options(MachineClass *m) | |
462 | { | |
aa78a16d | 463 | pc_i440fx_3_0_machine_options(m); |
968ee4ad BM |
464 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_12); |
465 | } | |
466 | ||
df47ce8a HZ |
467 | DEFINE_I440FX_MACHINE(v2_12, "pc-i440fx-2.12", NULL, |
468 | pc_i440fx_2_12_machine_options); | |
469 | ||
470 | static void pc_i440fx_2_11_machine_options(MachineClass *m) | |
471 | { | |
472 | pc_i440fx_2_12_machine_options(m); | |
df47ce8a HZ |
473 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_11); |
474 | } | |
475 | ||
a6fd5b0e MA |
476 | DEFINE_I440FX_MACHINE(v2_11, "pc-i440fx-2.11", NULL, |
477 | pc_i440fx_2_11_machine_options); | |
478 | ||
479 | static void pc_i440fx_2_10_machine_options(MachineClass *m) | |
480 | { | |
481 | pc_i440fx_2_11_machine_options(m); | |
a6fd5b0e | 482 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_10); |
7b8be49d | 483 | m->auto_enable_numa_with_memhp = false; |
a6fd5b0e MA |
484 | } |
485 | ||
465238d9 PX |
486 | DEFINE_I440FX_MACHINE(v2_10, "pc-i440fx-2.10", NULL, |
487 | pc_i440fx_2_10_machine_options); | |
488 | ||
489 | static void pc_i440fx_2_9_machine_options(MachineClass *m) | |
490 | { | |
491 | pc_i440fx_2_10_machine_options(m); | |
465238d9 | 492 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_9); |
3da2bd8c | 493 | m->numa_auto_assign_ram = numa_legacy_auto_assign_ram; |
465238d9 PX |
494 | } |
495 | ||
d580bd4b EH |
496 | DEFINE_I440FX_MACHINE(v2_9, "pc-i440fx-2.9", NULL, |
497 | pc_i440fx_2_9_machine_options); | |
498 | ||
499 | static void pc_i440fx_2_8_machine_options(MachineClass *m) | |
500 | { | |
501 | pc_i440fx_2_9_machine_options(m); | |
d580bd4b EH |
502 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_8); |
503 | } | |
504 | ||
a4d3c834 LM |
505 | DEFINE_I440FX_MACHINE(v2_8, "pc-i440fx-2.8", NULL, |
506 | pc_i440fx_2_8_machine_options); | |
507 | ||
508 | ||
509 | static void pc_i440fx_2_7_machine_options(MachineClass *m) | |
510 | { | |
511 | pc_i440fx_2_8_machine_options(m); | |
a4d3c834 LM |
512 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_7); |
513 | } | |
514 | ||
d86c1451 IM |
515 | DEFINE_I440FX_MACHINE(v2_7, "pc-i440fx-2.7", NULL, |
516 | pc_i440fx_2_7_machine_options); | |
517 | ||
518 | ||
519 | static void pc_i440fx_2_6_machine_options(MachineClass *m) | |
520 | { | |
679dd1a9 | 521 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
d86c1451 | 522 | pc_i440fx_2_7_machine_options(m); |
679dd1a9 | 523 | pcmc->legacy_cpu_hotplug = true; |
98e753a6 | 524 | pcmc->linuxboot_dma_enabled = false; |
d86c1451 IM |
525 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_6); |
526 | } | |
527 | ||
240240d5 EH |
528 | DEFINE_I440FX_MACHINE(v2_6, "pc-i440fx-2.6", NULL, |
529 | pc_i440fx_2_6_machine_options); | |
530 | ||
531 | ||
532 | static void pc_i440fx_2_5_machine_options(MachineClass *m) | |
533 | { | |
36f96c4b | 534 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
240240d5 | 535 | pc_i440fx_2_6_machine_options(m); |
36f96c4b | 536 | pcmc->save_tsc_khz = false; |
bab47d9a | 537 | m->legacy_fw_cfg_order = 1; |
240240d5 EH |
538 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_5); |
539 | } | |
540 | ||
87e896ab EH |
541 | DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL, |
542 | pc_i440fx_2_5_machine_options); | |
543 | ||
544 | ||
545 | static void pc_i440fx_2_4_machine_options(MachineClass *m) | |
546 | { | |
547 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); | |
548 | pc_i440fx_2_5_machine_options(m); | |
de796d93 | 549 | m->hw_version = "2.4.0"; |
87e896ab EH |
550 | pcmc->broken_reserved_end = true; |
551 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_4); | |
552 | } | |
553 | ||
99fbeafe EH |
554 | DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, |
555 | pc_i440fx_2_4_machine_options) | |
5cb50e0a | 556 | |
f9f21873 | 557 | |
865906f7 | 558 | static void pc_i440fx_2_3_machine_options(MachineClass *m) |
fddd179a | 559 | { |
4421c6a3 | 560 | pc_i440fx_2_4_machine_options(m); |
de796d93 | 561 | m->hw_version = "2.3.0"; |
25519b06 | 562 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); |
fddd179a | 563 | } |
5cb50e0a | 564 | |
99fbeafe EH |
565 | DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, |
566 | pc_i440fx_2_3_machine_options); | |
61f219df | 567 | |
5cb50e0a | 568 | |
865906f7 | 569 | static void pc_i440fx_2_2_machine_options(MachineClass *m) |
fddd179a | 570 | { |
7102fa70 | 571 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 572 | pc_i440fx_2_3_machine_options(m); |
de796d93 | 573 | m->hw_version = "2.2.0"; |
112394af | 574 | m->default_machine_opts = "firmware=bios-256k.bin,suppress-vmdesc=on"; |
25519b06 | 575 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); |
7102fa70 | 576 | pcmc->rsdp_in_ram = false; |
fddd179a | 577 | } |
64bbd372 | 578 | |
99fbeafe EH |
579 | DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, |
580 | pc_i440fx_2_2_machine_options); | |
61f219df | 581 | |
64bbd372 | 582 | |
865906f7 | 583 | static void pc_i440fx_2_1_machine_options(MachineClass *m) |
fddd179a | 584 | { |
7102fa70 | 585 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 586 | pc_i440fx_2_2_machine_options(m); |
de796d93 | 587 | m->hw_version = "2.1.0"; |
fddd179a | 588 | m->default_display = NULL; |
25519b06 | 589 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); |
7102fa70 | 590 | pcmc->smbios_uuid_encoded = false; |
16a9e8a5 | 591 | pcmc->enforce_aligned_dimm = false; |
fddd179a | 592 | } |
f9f21873 | 593 | |
99fbeafe EH |
594 | DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, |
595 | pc_i440fx_2_1_machine_options); | |
61f219df | 596 | |
aeca6e8d | 597 | |
fddd179a | 598 | |
865906f7 | 599 | static void pc_i440fx_2_0_machine_options(MachineClass *m) |
fddd179a | 600 | { |
7102fa70 | 601 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 602 | pc_i440fx_2_1_machine_options(m); |
de796d93 | 603 | m->hw_version = "2.0.0"; |
25519b06 | 604 | SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); |
7102fa70 EH |
605 | pcmc->smbios_legacy_mode = true; |
606 | pcmc->has_reserved_memory = false; | |
2b0ddf66 EH |
607 | /* This value depends on the actual DSDT and SSDT compiled into |
608 | * the source QEMU; unfortunately it depends on the binary and | |
609 | * not on the machine type, so we cannot make pc-i440fx-1.7 work on | |
610 | * both QEMU 1.7 and QEMU 2.0. | |
611 | * | |
612 | * Large variations cause migration to fail for more than one | |
613 | * consecutive value of the "-smp" maxcpus option. | |
614 | * | |
615 | * For small variations of the kind caused by different iasl versions, | |
616 | * the 4k rounding usually leaves slack. However, there could be still | |
617 | * one or two values that break. For QEMU 1.7 and QEMU 2.0 the | |
618 | * slack is only ~10 bytes before one "-smp maxcpus" value breaks! | |
619 | * | |
620 | * 6652 is valid for QEMU 2.0, the right value for pc-i440fx-1.7 on | |
621 | * QEMU 1.7 it is 6414. For RHEL/CentOS 7.0 it is 6418. | |
622 | */ | |
623 | pcmc->legacy_acpi_table_size = 6652; | |
cd4040ec | 624 | pcmc->acpi_data_size = 0x10000; |
fddd179a | 625 | } |
3458b2b0 | 626 | |
99fbeafe EH |
627 | DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, |
628 | pc_i440fx_2_0_machine_options); | |
61f219df | 629 | |
3458b2b0 | 630 | |
865906f7 | 631 | static void pc_i440fx_1_7_machine_options(MachineClass *m) |
fddd179a | 632 | { |
7102fa70 | 633 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 634 | pc_i440fx_2_0_machine_options(m); |
de796d93 | 635 | m->hw_version = "1.7.0"; |
fddd179a | 636 | m->default_machine_opts = NULL; |
71ae9e94 | 637 | m->option_rom_has_mr = true; |
25519b06 | 638 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); |
7102fa70 EH |
639 | pcmc->smbios_defaults = false; |
640 | pcmc->gigabyte_align = false; | |
2b0ddf66 | 641 | pcmc->legacy_acpi_table_size = 6414; |
fddd179a | 642 | } |
aeca6e8d | 643 | |
99fbeafe EH |
644 | DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, |
645 | pc_i440fx_1_7_machine_options); | |
61f219df | 646 | |
e9845f09 | 647 | |
865906f7 | 648 | static void pc_i440fx_1_6_machine_options(MachineClass *m) |
fddd179a | 649 | { |
7102fa70 | 650 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a | 651 | pc_i440fx_1_7_machine_options(m); |
de796d93 | 652 | m->hw_version = "1.6.0"; |
71ae9e94 | 653 | m->rom_file_has_mr = false; |
25519b06 | 654 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); |
7102fa70 | 655 | pcmc->has_acpi_build = false; |
fddd179a | 656 | } |
a0dba644 | 657 | |
99fbeafe EH |
658 | DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, |
659 | pc_i440fx_1_6_machine_options); | |
61f219df | 660 | |
845773ab | 661 | |
865906f7 | 662 | static void pc_i440fx_1_5_machine_options(MachineClass *m) |
fddd179a EH |
663 | { |
664 | pc_i440fx_1_6_machine_options(m); | |
de796d93 | 665 | m->hw_version = "1.5.0"; |
25519b06 | 666 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); |
fddd179a | 667 | } |
b6b5c8e4 | 668 | |
99fbeafe EH |
669 | DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, |
670 | pc_i440fx_1_5_machine_options); | |
61f219df | 671 | |
45053fde | 672 | |
865906f7 | 673 | static void pc_i440fx_1_4_machine_options(MachineClass *m) |
fddd179a EH |
674 | { |
675 | pc_i440fx_1_5_machine_options(m); | |
de796d93 | 676 | m->hw_version = "1.4.0"; |
fddd179a | 677 | m->hot_add_cpu = NULL; |
25519b06 | 678 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); |
fddd179a | 679 | } |
a0dba644 | 680 | |
99fbeafe EH |
681 | DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, |
682 | pc_i440fx_1_4_machine_options); | |
61f219df | 683 | |
bf3caa3d | 684 | |
427e3aa1 | 685 | #define PC_COMPAT_1_3 \ |
cd6c1b70 | 686 | PC_CPU_MODEL_IDS("1.3.0") \ |
427e3aa1 HG |
687 | {\ |
688 | .driver = "usb-tablet",\ | |
689 | .property = "usb_version",\ | |
690 | .value = stringify(1),\ | |
c1943a3f AK |
691 | },{\ |
692 | .driver = "virtio-net-pci",\ | |
693 | .property = "ctrl_mac_addr",\ | |
694 | .value = "off", \ | |
a9c87c58 JW |
695 | },{ \ |
696 | .driver = "virtio-net-pci", \ | |
697 | .property = "mq", \ | |
698 | .value = "off", \ | |
2af234e6 MT |
699 | }, {\ |
700 | .driver = "e1000",\ | |
701 | .property = "autonegotiation",\ | |
702 | .value = "off",\ | |
a7cde24d | 703 | }, |
427e3aa1 | 704 | |
fddd179a | 705 | |
865906f7 | 706 | static void pc_i440fx_1_3_machine_options(MachineClass *m) |
fddd179a EH |
707 | { |
708 | pc_i440fx_1_4_machine_options(m); | |
de796d93 | 709 | m->hw_version = "1.3.0"; |
25519b06 | 710 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); |
fddd179a | 711 | } |
b6b5c8e4 | 712 | |
99fbeafe EH |
713 | DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, |
714 | pc_i440fx_1_3_machine_options); | |
61f219df | 715 | |
f1ae2e38 | 716 | |
183c5eaa | 717 | #define PC_COMPAT_1_2 \ |
cd6c1b70 | 718 | PC_CPU_MODEL_IDS("1.2.0") \ |
183c5eaa GH |
719 | {\ |
720 | .driver = "nec-usb-xhci",\ | |
721 | .property = "msi",\ | |
722 | .value = "off",\ | |
723 | },{\ | |
724 | .driver = "nec-usb-xhci",\ | |
725 | .property = "msix",\ | |
726 | .value = "off",\ | |
c08ba66f GH |
727 | },{\ |
728 | .driver = "ivshmem",\ | |
729 | .property = "use64",\ | |
730 | .value = "0",\ | |
591af143 GH |
731 | },{\ |
732 | .driver = "qxl",\ | |
733 | .property = "revision",\ | |
734 | .value = stringify(3),\ | |
735 | },{\ | |
736 | .driver = "qxl-vga",\ | |
737 | .property = "revision",\ | |
738 | .value = stringify(3),\ | |
803ff052 GH |
739 | },{\ |
740 | .driver = "VGA",\ | |
741 | .property = "mmio",\ | |
742 | .value = "off",\ | |
a7cde24d | 743 | }, |
183c5eaa | 744 | |
865906f7 | 745 | static void pc_i440fx_1_2_machine_options(MachineClass *m) |
fddd179a EH |
746 | { |
747 | pc_i440fx_1_3_machine_options(m); | |
de796d93 | 748 | m->hw_version = "1.2.0"; |
25519b06 | 749 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); |
fddd179a | 750 | } |
a0dba644 | 751 | |
99fbeafe EH |
752 | DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, |
753 | pc_i440fx_1_2_machine_options); | |
61f219df | 754 | |
f4306941 | 755 | |
9e56edcf | 756 | #define PC_COMPAT_1_1 \ |
cd6c1b70 | 757 | PC_CPU_MODEL_IDS("1.1.0") \ |
9e56edcf | 758 | {\ |
07a5298c PB |
759 | .driver = "virtio-scsi-pci",\ |
760 | .property = "hotplug",\ | |
761 | .value = "off",\ | |
762 | },{\ | |
763 | .driver = "virtio-scsi-pci",\ | |
764 | .property = "param_change",\ | |
765 | .value = "off",\ | |
766 | },{\ | |
9e56edcf GH |
767 | .driver = "VGA",\ |
768 | .property = "vgamem_mb",\ | |
769 | .value = stringify(8),\ | |
770 | },{\ | |
771 | .driver = "vmware-svga",\ | |
772 | .property = "vgamem_mb",\ | |
773 | .value = stringify(8),\ | |
774 | },{\ | |
775 | .driver = "qxl-vga",\ | |
776 | .property = "vgamem_mb",\ | |
777 | .value = stringify(8),\ | |
778 | },{\ | |
779 | .driver = "qxl",\ | |
780 | .property = "vgamem_mb",\ | |
781 | .value = stringify(8),\ | |
ea776abc SH |
782 | },{\ |
783 | .driver = "virtio-blk-pci",\ | |
784 | .property = "config-wce",\ | |
785 | .value = "off",\ | |
a7cde24d | 786 | }, |
9e56edcf | 787 | |
865906f7 | 788 | static void pc_i440fx_1_1_machine_options(MachineClass *m) |
fddd179a EH |
789 | { |
790 | pc_i440fx_1_2_machine_options(m); | |
de796d93 | 791 | m->hw_version = "1.1.0"; |
25519b06 | 792 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); |
fddd179a | 793 | } |
b6b5c8e4 | 794 | |
99fbeafe EH |
795 | DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, |
796 | pc_i440fx_1_1_machine_options); | |
61f219df | 797 | |
f1dacf1c | 798 | |
d6c73008 | 799 | #define PC_COMPAT_1_0 \ |
cd6c1b70 | 800 | PC_CPU_MODEL_IDS("1.0") \ |
d6c73008 | 801 | {\ |
020c8e76 | 802 | .driver = TYPE_ISA_FDC,\ |
d6c73008 MT |
803 | .property = "check_media_rate",\ |
804 | .value = "off",\ | |
2ba1d381 DG |
805 | }, {\ |
806 | .driver = "virtio-balloon-pci",\ | |
807 | .property = "class",\ | |
808 | .value = stringify(PCI_CLASS_MEMORY_RAM),\ | |
fc34e77b | 809 | },{\ |
df1fd4b5 | 810 | .driver = "apic-common",\ |
fc34e77b AL |
811 | .property = "vapic",\ |
812 | .value = "off",\ | |
eeb0cf9a | 813 | },{\ |
bce54474 | 814 | .driver = TYPE_USB_DEVICE,\ |
eeb0cf9a GH |
815 | .property = "full-path",\ |
816 | .value = "no",\ | |
a7cde24d | 817 | }, |
d6c73008 | 818 | |
865906f7 | 819 | static void pc_i440fx_1_0_machine_options(MachineClass *m) |
fddd179a EH |
820 | { |
821 | pc_i440fx_1_1_machine_options(m); | |
822 | m->hw_version = "1.0"; | |
25519b06 | 823 | SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); |
fddd179a | 824 | } |
b6b5c8e4 | 825 | |
99fbeafe EH |
826 | DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, |
827 | pc_i440fx_1_0_machine_options); | |
61f219df | 828 | |
382b3a68 | 829 | |
cd6c1b70 EH |
830 | #define PC_COMPAT_0_15 \ |
831 | PC_CPU_MODEL_IDS("0.15") | |
832 | ||
865906f7 | 833 | static void pc_i440fx_0_15_machine_options(MachineClass *m) |
fddd179a EH |
834 | { |
835 | pc_i440fx_1_0_machine_options(m); | |
836 | m->hw_version = "0.15"; | |
cd6c1b70 | 837 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); |
fddd179a | 838 | } |
b6b5c8e4 | 839 | |
99fbeafe EH |
840 | DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, |
841 | pc_i440fx_0_15_machine_options); | |
61f219df | 842 | |
ce01a508 | 843 | |
d6c73008 | 844 | #define PC_COMPAT_0_14 \ |
cd6c1b70 | 845 | PC_CPU_MODEL_IDS("0.14") \ |
d6c73008 MT |
846 | {\ |
847 | .driver = "virtio-blk-pci",\ | |
848 | .property = "event_idx",\ | |
849 | .value = "off",\ | |
850 | },{\ | |
851 | .driver = "virtio-serial-pci",\ | |
852 | .property = "event_idx",\ | |
853 | .value = "off",\ | |
854 | },{\ | |
855 | .driver = "virtio-net-pci",\ | |
856 | .property = "event_idx",\ | |
857 | .value = "off",\ | |
858 | },{\ | |
859 | .driver = "virtio-balloon-pci",\ | |
860 | .property = "event_idx",\ | |
861 | .value = "off",\ | |
bb08d882 EH |
862 | },{\ |
863 | .driver = "qxl",\ | |
864 | .property = "revision",\ | |
865 | .value = stringify(2),\ | |
866 | },{\ | |
867 | .driver = "qxl-vga",\ | |
868 | .property = "revision",\ | |
869 | .value = stringify(2),\ | |
a7cde24d | 870 | }, |
d6c73008 | 871 | |
865906f7 | 872 | static void pc_i440fx_0_14_machine_options(MachineClass *m) |
fddd179a EH |
873 | { |
874 | pc_i440fx_0_15_machine_options(m); | |
875 | m->hw_version = "0.14"; | |
25519b06 | 876 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); |
fddd179a | 877 | } |
b6b5c8e4 | 878 | |
99fbeafe EH |
879 | DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, |
880 | pc_i440fx_0_14_machine_options); | |
61f219df | 881 | |
19857e62 | 882 | |
d6c73008 | 883 | #define PC_COMPAT_0_13 \ |
cd6c1b70 | 884 | PC_CPU_MODEL_IDS("0.13") \ |
d6c73008 | 885 | {\ |
bce54474 | 886 | .driver = TYPE_PCI_DEVICE,\ |
d6c73008 MT |
887 | .property = "command_serr_enable",\ |
888 | .value = "off",\ | |
889 | },{\ | |
890 | .driver = "AC97",\ | |
891 | .property = "use_broken_id",\ | |
892 | .value = stringify(1),\ | |
d765519b EH |
893 | },{\ |
894 | .driver = "virtio-9p-pci",\ | |
895 | .property = "vectors",\ | |
896 | .value = stringify(0),\ | |
faf7e425 EH |
897 | },{\ |
898 | .driver = "VGA",\ | |
899 | .property = "rombar",\ | |
900 | .value = stringify(0),\ | |
901 | },{\ | |
902 | .driver = "vmware-svga",\ | |
903 | .property = "rombar",\ | |
904 | .value = stringify(0),\ | |
a7cde24d | 905 | }, |
d6c73008 | 906 | |
865906f7 | 907 | static void pc_i440fx_0_13_machine_options(MachineClass *m) |
fddd179a | 908 | { |
7102fa70 | 909 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
910 | pc_i440fx_0_14_machine_options(m); |
911 | m->hw_version = "0.13"; | |
25519b06 | 912 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); |
7102fa70 | 913 | pcmc->kvmclock_enabled = false; |
fddd179a | 914 | } |
a0dba644 | 915 | |
99fbeafe EH |
916 | DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, |
917 | pc_i440fx_0_13_machine_options); | |
61f219df | 918 | |
b903a0f7 | 919 | |
d6c73008 | 920 | #define PC_COMPAT_0_12 \ |
cd6c1b70 | 921 | PC_CPU_MODEL_IDS("0.12") \ |
d6c73008 MT |
922 | {\ |
923 | .driver = "virtio-serial-pci",\ | |
924 | .property = "max_ports",\ | |
925 | .value = stringify(1),\ | |
926 | },{\ | |
927 | .driver = "virtio-serial-pci",\ | |
928 | .property = "vectors",\ | |
929 | .value = stringify(0),\ | |
93c8e4dc GH |
930 | },{\ |
931 | .driver = "usb-mouse",\ | |
932 | .property = "serial",\ | |
933 | .value = "1",\ | |
934 | },{\ | |
935 | .driver = "usb-tablet",\ | |
936 | .property = "serial",\ | |
937 | .value = "1",\ | |
938 | },{\ | |
939 | .driver = "usb-kbd",\ | |
940 | .property = "serial",\ | |
941 | .value = "1",\ | |
a7cde24d | 942 | }, |
d6c73008 | 943 | |
865906f7 | 944 | static void pc_i440fx_0_12_machine_options(MachineClass *m) |
fddd179a EH |
945 | { |
946 | pc_i440fx_0_13_machine_options(m); | |
947 | m->hw_version = "0.12"; | |
25519b06 | 948 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); |
fddd179a | 949 | } |
b6b5c8e4 | 950 | |
99fbeafe EH |
951 | DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, |
952 | pc_i440fx_0_12_machine_options); | |
61f219df | 953 | |
845773ab | 954 | |
d6c73008 | 955 | #define PC_COMPAT_0_11 \ |
cd6c1b70 | 956 | PC_CPU_MODEL_IDS("0.11") \ |
d6c73008 MT |
957 | {\ |
958 | .driver = "virtio-blk-pci",\ | |
959 | .property = "vectors",\ | |
960 | .value = stringify(0),\ | |
c115cd65 | 961 | },{\ |
bce54474 | 962 | .driver = TYPE_PCI_DEVICE,\ |
c115cd65 PB |
963 | .property = "rombar",\ |
964 | .value = stringify(0),\ | |
d5303df7 EH |
965 | },{\ |
966 | .driver = "ide-drive",\ | |
967 | .property = "ver",\ | |
968 | .value = "0.11",\ | |
969 | },{\ | |
970 | .driver = "scsi-disk",\ | |
971 | .property = "ver",\ | |
972 | .value = "0.11",\ | |
a7cde24d | 973 | }, |
d6c73008 | 974 | |
865906f7 | 975 | static void pc_i440fx_0_11_machine_options(MachineClass *m) |
fddd179a EH |
976 | { |
977 | pc_i440fx_0_12_machine_options(m); | |
978 | m->hw_version = "0.11"; | |
08fe6824 | 979 | m->deprecation_reason = "use a newer machine type instead"; |
25519b06 | 980 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); |
fddd179a | 981 | } |
b6b5c8e4 | 982 | |
99fbeafe EH |
983 | DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, |
984 | pc_i440fx_0_11_machine_options); | |
61f219df | 985 | |
845773ab | 986 | |
f6d5a0ba | 987 | #define PC_COMPAT_0_10 \ |
cd6c1b70 | 988 | PC_CPU_MODEL_IDS("0.10") \ |
f6d5a0ba EH |
989 | {\ |
990 | .driver = "virtio-blk-pci",\ | |
991 | .property = "class",\ | |
992 | .value = stringify(PCI_CLASS_STORAGE_OTHER),\ | |
993 | },{\ | |
994 | .driver = "virtio-serial-pci",\ | |
995 | .property = "class",\ | |
996 | .value = stringify(PCI_CLASS_DISPLAY_OTHER),\ | |
997 | },{\ | |
998 | .driver = "virtio-net-pci",\ | |
999 | .property = "vectors",\ | |
1000 | .value = stringify(0),\ | |
1001 | },{\ | |
1002 | .driver = "ide-drive",\ | |
1003 | .property = "ver",\ | |
1004 | .value = "0.10",\ | |
1005 | },{\ | |
1006 | .driver = "scsi-disk",\ | |
1007 | .property = "ver",\ | |
1008 | .value = "0.10",\ | |
1009 | }, | |
1010 | ||
865906f7 | 1011 | static void pc_i440fx_0_10_machine_options(MachineClass *m) |
fddd179a EH |
1012 | { |
1013 | pc_i440fx_0_11_machine_options(m); | |
1014 | m->hw_version = "0.10"; | |
25519b06 | 1015 | SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); |
fddd179a | 1016 | } |
b6b5c8e4 | 1017 | |
99fbeafe EH |
1018 | DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, |
1019 | pc_i440fx_0_10_machine_options); | |
61f219df | 1020 | |
bd8107d7 TC |
1021 | typedef struct { |
1022 | uint16_t gpu_device_id; | |
1023 | uint16_t pch_device_id; | |
1024 | uint8_t pch_revision_id; | |
1025 | } IGDDeviceIDInfo; | |
1026 | ||
1027 | /* In real world different GPU should have different PCH. But actually | |
1028 | * the different PCH DIDs likely map to different PCH SKUs. We do the | |
1029 | * same thing for the GPU. For PCH, the different SKUs are going to be | |
1030 | * all the same silicon design and implementation, just different | |
1031 | * features turn on and off with fuses. The SW interfaces should be | |
1032 | * consistent across all SKUs in a given family (eg LPT). But just same | |
1033 | * features may not be supported. | |
1034 | * | |
1035 | * Most of these different PCH features probably don't matter to the | |
1036 | * Gfx driver, but obviously any difference in display port connections | |
1037 | * will so it should be fine with any PCH in case of passthrough. | |
1038 | * | |
1039 | * So currently use one PCH version, 0x8c4e, to cover all HSW(Haswell) | |
1040 | * scenarios, 0x9cc3 for BDW(Broadwell). | |
1041 | */ | |
1042 | static const IGDDeviceIDInfo igd_combo_id_infos[] = { | |
1043 | /* HSW Classic */ | |
1044 | {0x0402, 0x8c4e, 0x04}, /* HSWGT1D, HSWD_w7 */ | |
1045 | {0x0406, 0x8c4e, 0x04}, /* HSWGT1M, HSWM_w7 */ | |
1046 | {0x0412, 0x8c4e, 0x04}, /* HSWGT2D, HSWD_w7 */ | |
1047 | {0x0416, 0x8c4e, 0x04}, /* HSWGT2M, HSWM_w7 */ | |
1048 | {0x041E, 0x8c4e, 0x04}, /* HSWGT15D, HSWD_w7 */ | |
1049 | /* HSW ULT */ | |
1050 | {0x0A06, 0x8c4e, 0x04}, /* HSWGT1UT, HSWM_w7 */ | |
1051 | {0x0A16, 0x8c4e, 0x04}, /* HSWGT2UT, HSWM_w7 */ | |
1052 | {0x0A26, 0x8c4e, 0x06}, /* HSWGT3UT, HSWM_w7 */ | |
1053 | {0x0A2E, 0x8c4e, 0x04}, /* HSWGT3UT28W, HSWM_w7 */ | |
1054 | {0x0A1E, 0x8c4e, 0x04}, /* HSWGT2UX, HSWM_w7 */ | |
1055 | {0x0A0E, 0x8c4e, 0x04}, /* HSWGT1ULX, HSWM_w7 */ | |
1056 | /* HSW CRW */ | |
1057 | {0x0D26, 0x8c4e, 0x04}, /* HSWGT3CW, HSWM_w7 */ | |
1058 | {0x0D22, 0x8c4e, 0x04}, /* HSWGT3CWDT, HSWD_w7 */ | |
1059 | /* HSW Server */ | |
1060 | {0x041A, 0x8c4e, 0x04}, /* HSWSVGT2, HSWD_w7 */ | |
1061 | /* HSW SRVR */ | |
1062 | {0x040A, 0x8c4e, 0x04}, /* HSWSVGT1, HSWD_w7 */ | |
1063 | /* BSW */ | |
1064 | {0x1606, 0x9cc3, 0x03}, /* BDWULTGT1, BDWM_w7 */ | |
1065 | {0x1616, 0x9cc3, 0x03}, /* BDWULTGT2, BDWM_w7 */ | |
1066 | {0x1626, 0x9cc3, 0x03}, /* BDWULTGT3, BDWM_w7 */ | |
1067 | {0x160E, 0x9cc3, 0x03}, /* BDWULXGT1, BDWM_w7 */ | |
1068 | {0x161E, 0x9cc3, 0x03}, /* BDWULXGT2, BDWM_w7 */ | |
1069 | {0x1602, 0x9cc3, 0x03}, /* BDWHALOGT1, BDWM_w7 */ | |
1070 | {0x1612, 0x9cc3, 0x03}, /* BDWHALOGT2, BDWM_w7 */ | |
1071 | {0x1622, 0x9cc3, 0x03}, /* BDWHALOGT3, BDWM_w7 */ | |
1072 | {0x162B, 0x9cc3, 0x03}, /* BDWHALO28W, BDWM_w7 */ | |
1073 | {0x162A, 0x9cc3, 0x03}, /* BDWGT3WRKS, BDWM_w7 */ | |
1074 | {0x162D, 0x9cc3, 0x03}, /* BDWGT3SRVR, BDWM_w7 */ | |
1075 | }; | |
1076 | ||
1077 | static void isa_bridge_class_init(ObjectClass *klass, void *data) | |
1078 | { | |
1079 | DeviceClass *dc = DEVICE_CLASS(klass); | |
1080 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
1081 | ||
1082 | dc->desc = "ISA bridge faked to support IGD PT"; | |
1083 | k->vendor_id = PCI_VENDOR_ID_INTEL; | |
1084 | k->class_id = PCI_CLASS_BRIDGE_ISA; | |
1085 | }; | |
1086 | ||
1087 | static TypeInfo isa_bridge_info = { | |
1088 | .name = "igd-passthrough-isa-bridge", | |
1089 | .parent = TYPE_PCI_DEVICE, | |
1090 | .instance_size = sizeof(PCIDevice), | |
1091 | .class_init = isa_bridge_class_init, | |
fd3b02c8 EH |
1092 | .interfaces = (InterfaceInfo[]) { |
1093 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | |
1094 | { }, | |
1095 | }, | |
bd8107d7 TC |
1096 | }; |
1097 | ||
1098 | static void pt_graphics_register_types(void) | |
1099 | { | |
1100 | type_register_static(&isa_bridge_info); | |
1101 | } | |
1102 | type_init(pt_graphics_register_types) | |
1103 | ||
1104 | void igd_passthrough_isa_bridge_create(PCIBus *bus, uint16_t gpu_dev_id) | |
1105 | { | |
1106 | struct PCIDevice *bridge_dev; | |
1107 | int i, num; | |
1108 | uint16_t pch_dev_id = 0xffff; | |
1109 | uint8_t pch_rev_id; | |
1110 | ||
1111 | num = ARRAY_SIZE(igd_combo_id_infos); | |
1112 | for (i = 0; i < num; i++) { | |
1113 | if (gpu_dev_id == igd_combo_id_infos[i].gpu_device_id) { | |
1114 | pch_dev_id = igd_combo_id_infos[i].pch_device_id; | |
1115 | pch_rev_id = igd_combo_id_infos[i].pch_revision_id; | |
1116 | } | |
1117 | } | |
1118 | ||
1119 | if (pch_dev_id == 0xffff) { | |
1120 | return; | |
1121 | } | |
1122 | ||
1123 | /* Currently IGD drivers always need to access PCH by 1f.0. */ | |
1124 | bridge_dev = pci_create_simple(bus, PCI_DEVFN(0x1f, 0), | |
1125 | "igd-passthrough-isa-bridge"); | |
1126 | ||
1127 | /* | |
1128 | * Note that vendor id is always PCI_VENDOR_ID_INTEL. | |
1129 | */ | |
1130 | if (!bridge_dev) { | |
1131 | fprintf(stderr, "set igd-passthrough-isa-bridge failed!\n"); | |
1132 | return; | |
1133 | } | |
1134 | pci_config_set_device_id(bridge_dev->config, pch_dev_id); | |
1135 | pci_config_set_revision(bridge_dev->config, pch_rev_id); | |
1136 | } | |
845773ab | 1137 | |
865906f7 | 1138 | static void isapc_machine_options(MachineClass *m) |
fddd179a | 1139 | { |
7102fa70 | 1140 | PCMachineClass *pcmc = PC_MACHINE_CLASS(m); |
fddd179a EH |
1141 | m->desc = "ISA-only PC"; |
1142 | m->max_cpus = 1; | |
71ae9e94 EH |
1143 | m->option_rom_has_mr = true; |
1144 | m->rom_file_has_mr = false; | |
7102fa70 EH |
1145 | pcmc->pci_enabled = false; |
1146 | pcmc->has_acpi_build = false; | |
1147 | pcmc->smbios_defaults = false; | |
1148 | pcmc->gigabyte_align = false; | |
1149 | pcmc->smbios_legacy_mode = true; | |
1150 | pcmc->has_reserved_memory = false; | |
4b9c264b | 1151 | pcmc->default_nic_model = "ne2k_isa"; |
311ca98d | 1152 | m->default_cpu_type = X86_CPU_TYPE_NAME("486"); |
fddd179a | 1153 | } |
b6b5c8e4 | 1154 | |
61f219df | 1155 | DEFINE_PC_MACHINE(isapc, "isapc", pc_init_isa, |
25519b06 | 1156 | isapc_machine_options); |
61f219df | 1157 | |
845773ab | 1158 | |
29d3ccde | 1159 | #ifdef CONFIG_XEN |
865906f7 | 1160 | static void xenfv_machine_options(MachineClass *m) |
fddd179a | 1161 | { |
fddd179a EH |
1162 | m->desc = "Xen Fully-virtualized PC"; |
1163 | m->max_cpus = HVM_MAX_VCPUS; | |
1164 | m->default_machine_opts = "accel=xen"; | |
fddd179a | 1165 | } |
b6b5c8e4 | 1166 | |
61f219df | 1167 | DEFINE_PC_MACHINE(xenfv, "xenfv", pc_xen_hvm_init, |
25519b06 | 1168 | xenfv_machine_options); |
29d3ccde | 1169 | #endif |