]>
Commit | Line | Data |
---|---|---|
a5c95808 CH |
1 | /* |
2 | * virtio ccw machine | |
3 | * | |
c3347ed0 | 4 | * Copyright 2012, 2020 IBM Corp. |
6286b419 | 5 | * Copyright (c) 2009 Alexander Graf <agraf@suse.de> |
a5c95808 | 6 | * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> |
c3347ed0 | 7 | * Janosch Frank <frankja@linux.ibm.com> |
a5c95808 CH |
8 | * |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or (at | |
10 | * your option) any later version. See the COPYING file in the top-level | |
11 | * directory. | |
12 | */ | |
13 | ||
9615495a | 14 | #include "qemu/osdep.h" |
da34e65c | 15 | #include "qapi/error.h" |
4771d756 | 16 | #include "cpu.h" |
a5c95808 CH |
17 | #include "hw/boards.h" |
18 | #include "exec/address-spaces.h" | |
9138977b | 19 | #include "exec/ram_addr.h" |
7d577546 | 20 | #include "hw/s390x/s390-virtio-hcall.h" |
83c9f4ca | 21 | #include "hw/s390x/sclp.h" |
3a553fc6 | 22 | #include "hw/s390x/s390_flic.h" |
bd3f16ac PB |
23 | #include "hw/s390x/ioinst.h" |
24 | #include "hw/s390x/css.h" | |
a5c95808 | 25 | #include "virtio-ccw.h" |
b6fe0124 | 26 | #include "qemu/config-file.h" |
856dfd8a | 27 | #include "qemu/ctype.h" |
b5684cd8 | 28 | #include "qemu/error-report.h" |
922a01a0 | 29 | #include "qemu/option.h" |
5c30ef93 | 30 | #include "qemu/qemu-print.h" |
408b55db | 31 | #include "hw/s390x/s390-pci-bus.h" |
71e8a915 | 32 | #include "sysemu/reset.h" |
0f5f6691 | 33 | #include "hw/s390x/storage-keys.h" |
903fd80b | 34 | #include "hw/s390x/storage-attributes.h" |
bc61c8c6 | 35 | #include "hw/s390x/event-facility.h" |
04ca4b92 | 36 | #include "ipl.h" |
8b8a61ad | 37 | #include "hw/s390x/s390-virtio-ccw.h" |
dd70bd0d | 38 | #include "hw/s390x/css-bridge.h" |
a51b3153 | 39 | #include "hw/s390x/ap-bridge.h" |
f2a8f0a6 | 40 | #include "migration/register.h" |
7223bcce | 41 | #include "cpu_models.h" |
6286b419 | 42 | #include "hw/nmi.h" |
a27bd6c7 | 43 | #include "hw/qdev-properties.h" |
8046f374 | 44 | #include "hw/s390x/tod.h" |
2f780b6a | 45 | #include "sysemu/sysemu.h" |
c3347ed0 | 46 | #include "hw/s390x/pv.h" |
0141e1b4 JF |
47 | #include "migration/blocker.h" |
48 | ||
49 | static Error *pv_mig_blocker; | |
6286b419 | 50 | |
6286b419 DH |
51 | S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) |
52 | { | |
2b44178d DH |
53 | static MachineState *ms; |
54 | ||
55 | if (!ms) { | |
56 | ms = MACHINE(qdev_get_machine()); | |
57 | g_assert(ms->possible_cpus); | |
6286b419 DH |
58 | } |
59 | ||
2b44178d DH |
60 | /* CPU address corresponds to the core_id and the index */ |
61 | if (cpu_addr >= ms->possible_cpus->len) { | |
62 | return NULL; | |
63 | } | |
64 | return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu); | |
6286b419 DH |
65 | } |
66 | ||
32dc6aa0 IM |
67 | static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, |
68 | Error **errp) | |
69 | { | |
70 | S390CPU *cpu = S390_CPU(object_new(typename)); | |
f07ad48d | 71 | S390CPU *ret = NULL; |
32dc6aa0 | 72 | |
992861fb | 73 | if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, errp)) { |
32dc6aa0 IM |
74 | goto out; |
75 | } | |
992861fb | 76 | if (!qdev_realize(DEVICE(cpu), NULL, errp)) { |
f07ad48d MA |
77 | goto out; |
78 | } | |
79 | ret = cpu; | |
32dc6aa0 IM |
80 | |
81 | out: | |
82 | object_unref(OBJECT(cpu)); | |
f07ad48d | 83 | return ret; |
32dc6aa0 IM |
84 | } |
85 | ||
6286b419 DH |
86 | static void s390_init_cpus(MachineState *machine) |
87 | { | |
4dc3b151 | 88 | MachineClass *mc = MACHINE_GET_CLASS(machine); |
6286b419 | 89 | int i; |
6286b419 | 90 | |
4dc3b151 DH |
91 | /* initialize possible_cpus */ |
92 | mc->possible_cpu_arch_ids(machine); | |
93 | ||
ae71ed86 | 94 | for (i = 0; i < machine->smp.cpus; i++) { |
b6805e12 | 95 | s390x_new_cpu(machine->cpu_type, i, &error_fatal); |
6286b419 DH |
96 | } |
97 | } | |
2eb1cd07 | 98 | |
09c7f58c | 99 | static const char *const reset_dev_types[] = { |
3f9e4859 | 100 | TYPE_VIRTUAL_CSS_BRIDGE, |
09c7f58c DH |
101 | "s390-sclp-event-facility", |
102 | "s390-flic", | |
103 | "diag288", | |
db08244a | 104 | TYPE_S390_PCI_HOST_BRIDGE, |
09c7f58c DH |
105 | }; |
106 | ||
a30fb811 | 107 | static void subsystem_reset(void) |
4e872a3f | 108 | { |
09c7f58c DH |
109 | DeviceState *dev; |
110 | int i; | |
4e872a3f | 111 | |
09c7f58c DH |
112 | for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) { |
113 | dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL)); | |
114 | if (dev) { | |
115 | qdev_reset_all(dev); | |
116 | } | |
0c7322cf | 117 | } |
4e872a3f CB |
118 | } |
119 | ||
a5c95808 CH |
120 | static int virtio_ccw_hcall_notify(const uint64_t *args) |
121 | { | |
122 | uint64_t subch_id = args[0]; | |
123 | uint64_t queue = args[1]; | |
124 | SubchDev *sch; | |
125 | int cssid, ssid, schid, m; | |
126 | ||
127 | if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) { | |
128 | return -EINVAL; | |
129 | } | |
130 | sch = css_find_subch(m, cssid, ssid, schid); | |
131 | if (!sch || !css_subch_visible(sch)) { | |
132 | return -EINVAL; | |
133 | } | |
b1914b82 | 134 | if (queue >= VIRTIO_QUEUE_MAX) { |
b57ed9bf CH |
135 | return -EINVAL; |
136 | } | |
a5c95808 CH |
137 | virtio_queue_notify(virtio_ccw_get_vdev(sch), queue); |
138 | return 0; | |
139 | ||
140 | } | |
141 | ||
142 | static int virtio_ccw_hcall_early_printk(const uint64_t *args) | |
143 | { | |
144 | uint64_t mem = args[0]; | |
145 | ||
146 | if (mem < ram_size) { | |
147 | /* Early printk */ | |
148 | return 0; | |
149 | } | |
150 | return -EINVAL; | |
151 | } | |
152 | ||
153 | static void virtio_ccw_register_hcalls(void) | |
154 | { | |
155 | s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY, | |
156 | virtio_ccw_hcall_notify); | |
157 | /* Tolerate early printk. */ | |
158 | s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY, | |
159 | virtio_ccw_hcall_early_printk); | |
160 | } | |
161 | ||
3a12fc61 | 162 | static void s390_memory_init(MemoryRegion *ram) |
a5c95808 | 163 | { |
a5c95808 | 164 | MemoryRegion *sysmem = get_system_memory(); |
80d23275 DH |
165 | |
166 | /* allocate RAM for core */ | |
fb1fc5a8 | 167 | memory_region_add_subregion(sysmem, 0, ram); |
80d23275 | 168 | |
9138977b DH |
169 | /* |
170 | * Configure the maximum page size. As no memory devices were created | |
171 | * yet, this is the page size of initial memory only. | |
172 | */ | |
805d4496 | 173 | s390_set_max_pagesize(qemu_maxrampagesize(), &error_fatal); |
80d23275 DH |
174 | /* Initialize storage key device */ |
175 | s390_skeys_init(); | |
903fd80b CI |
176 | /* Initialize storage attributes device */ |
177 | s390_stattrib_init(); | |
80d23275 DH |
178 | } |
179 | ||
6286b419 DH |
180 | static void s390_init_ipl_dev(const char *kernel_filename, |
181 | const char *kernel_cmdline, | |
182 | const char *initrd_filename, const char *firmware, | |
183 | const char *netboot_fw, bool enforce_bios) | |
184 | { | |
185 | Object *new = object_new(TYPE_S390_IPL); | |
186 | DeviceState *dev = DEVICE(new); | |
d9b06db8 | 187 | char *netboot_fw_prop; |
6286b419 DH |
188 | |
189 | if (kernel_filename) { | |
190 | qdev_prop_set_string(dev, "kernel", kernel_filename); | |
191 | } | |
192 | if (initrd_filename) { | |
193 | qdev_prop_set_string(dev, "initrd", initrd_filename); | |
194 | } | |
195 | qdev_prop_set_string(dev, "cmdline", kernel_cmdline); | |
196 | qdev_prop_set_string(dev, "firmware", firmware); | |
6286b419 | 197 | qdev_prop_set_bit(dev, "enforce_bios", enforce_bios); |
d9b06db8 GK |
198 | netboot_fw_prop = object_property_get_str(new, "netboot_fw", &error_abort); |
199 | if (!strlen(netboot_fw_prop)) { | |
3c4e9baa TH |
200 | qdev_prop_set_string(dev, "netboot_fw", netboot_fw); |
201 | } | |
d9b06db8 | 202 | g_free(netboot_fw_prop); |
6286b419 | 203 | object_property_add_child(qdev_get_machine(), TYPE_S390_IPL, |
d2623129 | 204 | new); |
6286b419 | 205 | object_unref(new); |
ce189ab2 | 206 | qdev_realize(dev, NULL, &error_fatal); |
6286b419 DH |
207 | } |
208 | ||
209 | static void s390_create_virtio_net(BusState *bus, const char *name) | |
210 | { | |
211 | int i; | |
212 | ||
213 | for (i = 0; i < nb_nics; i++) { | |
214 | NICInfo *nd = &nd_table[i]; | |
215 | DeviceState *dev; | |
216 | ||
217 | if (!nd->model) { | |
218 | nd->model = g_strdup("virtio"); | |
219 | } | |
220 | ||
221 | qemu_check_nic_model(nd, "virtio"); | |
222 | ||
3e80f690 | 223 | dev = qdev_new(name); |
6286b419 | 224 | qdev_set_nic_properties(dev, nd); |
3e80f690 | 225 | qdev_realize_and_unref(dev, bus, &error_fatal); |
6286b419 DH |
226 | } |
227 | } | |
228 | ||
052888f0 TH |
229 | static void s390_create_sclpconsole(const char *type, Chardev *chardev) |
230 | { | |
231 | DeviceState *dev; | |
232 | ||
3e80f690 | 233 | dev = qdev_new(type); |
052888f0 | 234 | qdev_prop_set_chr(dev, "chardev", chardev); |
3e80f690 | 235 | qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal); |
052888f0 TH |
236 | } |
237 | ||
80d23275 DH |
238 | static void ccw_init(MachineState *machine) |
239 | { | |
a5c95808 CH |
240 | int ret; |
241 | VirtualCssBus *css_bus; | |
c1843e20 | 242 | DeviceState *dev; |
b6fe0124 | 243 | |
1cf065fb | 244 | s390_sclp_init(); |
9138977b | 245 | /* init memory + setup max page size. Required for the CPU model */ |
3a12fc61 | 246 | s390_memory_init(machine->ram); |
a5c95808 | 247 | |
d32bd032 | 248 | /* init CPUs (incl. CPU model) early so s390_has_feature() works */ |
3720d335 YMZ |
249 | s390_init_cpus(machine); |
250 | ||
c572d3f3 FL |
251 | s390_flic_init(); |
252 | ||
74b4c74d DH |
253 | /* init the SIGP facility */ |
254 | s390_init_sigp(); | |
255 | ||
a51b3153 TK |
256 | /* create AP bridge and bus(es) */ |
257 | s390_init_ap(); | |
258 | ||
a5c95808 CH |
259 | /* get a BUS */ |
260 | css_bus = virtual_css_bus_init(); | |
3ef96221 | 261 | s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, |
f0344395 PB |
262 | machine->initrd_filename, |
263 | machine->firmware ?: "s390-ccw.img", | |
5f31ade0 | 264 | "s390-netboot.img", true); |
a5c95808 | 265 | |
3e80f690 | 266 | dev = qdev_new(TYPE_S390_PCI_HOST_BRIDGE); |
c1843e20 | 267 | object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE, |
d2623129 | 268 | OBJECT(dev)); |
3c6ef471 | 269 | sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); |
8cba80c3 | 270 | |
a5c95808 CH |
271 | /* register hypercalls */ |
272 | virtio_ccw_register_hcalls(); | |
273 | ||
5e7164c5 | 274 | s390_enable_css_support(s390_cpu_addr2state(0)); |
36699ab4 CH |
275 | |
276 | ret = css_create_css_image(VIRTUAL_CSSID, true); | |
d69969e5 | 277 | |
a5c95808 | 278 | assert(ret == 0); |
489c909f HP |
279 | if (css_migration_enabled()) { |
280 | css_register_vmstate(); | |
281 | } | |
a5c95808 CH |
282 | |
283 | /* Create VirtIO network adapters */ | |
284 | s390_create_virtio_net(BUS(css_bus), "virtio-net-ccw"); | |
3f9e59bb | 285 | |
052888f0 TH |
286 | /* init consoles */ |
287 | if (serial_hd(0)) { | |
288 | s390_create_sclpconsole("sclpconsole", serial_hd(0)); | |
289 | } | |
290 | if (serial_hd(1)) { | |
291 | s390_create_sclpconsole("sclplmconsole", serial_hd(1)); | |
292 | } | |
293 | ||
8046f374 DH |
294 | /* init the TOD clock */ |
295 | s390_init_tod(); | |
a5c95808 CH |
296 | } |
297 | ||
502edbf8 MR |
298 | static void s390_cpu_plug(HotplugHandler *hotplug_dev, |
299 | DeviceState *dev, Error **errp) | |
300 | { | |
4dc3b151 | 301 | MachineState *ms = MACHINE(hotplug_dev); |
502edbf8 | 302 | S390CPU *cpu = S390_CPU(dev); |
4dc3b151 DH |
303 | |
304 | g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); | |
305 | ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev); | |
c5b93430 DH |
306 | |
307 | if (dev->hotplugged) { | |
308 | raise_irq_cpu_hotplug(); | |
309 | } | |
502edbf8 MR |
310 | } |
311 | ||
a30fb811 DH |
312 | static inline void s390_do_cpu_ipl(CPUState *cs, run_on_cpu_data arg) |
313 | { | |
314 | S390CPU *cpu = S390_CPU(cs); | |
315 | ||
316 | s390_ipl_prepare_cpu(cpu); | |
317 | s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); | |
318 | } | |
319 | ||
c3347ed0 JF |
320 | static void s390_machine_unprotect(S390CcwMachineState *ms) |
321 | { | |
322 | s390_pv_vm_disable(); | |
323 | ms->pv = false; | |
0141e1b4 JF |
324 | migrate_del_blocker(pv_mig_blocker); |
325 | error_free_or_abort(&pv_mig_blocker); | |
b030958c | 326 | ram_block_discard_disable(false); |
c3347ed0 JF |
327 | } |
328 | ||
329 | static int s390_machine_protect(S390CcwMachineState *ms) | |
330 | { | |
0141e1b4 | 331 | Error *local_err = NULL; |
c3347ed0 JF |
332 | int rc; |
333 | ||
b1697f63 | 334 | /* |
b030958c DH |
335 | * Discarding of memory in RAM blocks does not work as expected with |
336 | * protected VMs. Sharing and unsharing pages would be required. Disable | |
337 | * it for now, until until we have a solution to make at least Linux | |
338 | * guests either support it (e.g., virtio-balloon) or fail gracefully. | |
b1697f63 | 339 | */ |
b030958c DH |
340 | rc = ram_block_discard_disable(true); |
341 | if (rc) { | |
342 | error_report("protected VMs: cannot disable RAM discard"); | |
343 | return rc; | |
344 | } | |
345 | ||
0141e1b4 JF |
346 | error_setg(&pv_mig_blocker, |
347 | "protected VMs are currently not migrateable."); | |
348 | rc = migrate_add_blocker(pv_mig_blocker, &local_err); | |
349 | if (rc) { | |
b030958c | 350 | ram_block_discard_disable(false); |
0141e1b4 JF |
351 | error_report_err(local_err); |
352 | error_free_or_abort(&pv_mig_blocker); | |
353 | return rc; | |
354 | } | |
355 | ||
c3347ed0 JF |
356 | /* Create SE VM */ |
357 | rc = s390_pv_vm_enable(); | |
358 | if (rc) { | |
b030958c | 359 | ram_block_discard_disable(false); |
0141e1b4 JF |
360 | migrate_del_blocker(pv_mig_blocker); |
361 | error_free_or_abort(&pv_mig_blocker); | |
c3347ed0 JF |
362 | return rc; |
363 | } | |
364 | ||
365 | ms->pv = true; | |
366 | ||
367 | /* Set SE header and unpack */ | |
368 | rc = s390_ipl_prepare_pv_header(); | |
369 | if (rc) { | |
370 | goto out_err; | |
371 | } | |
372 | ||
373 | /* Decrypt image */ | |
374 | rc = s390_ipl_pv_unpack(); | |
375 | if (rc) { | |
376 | goto out_err; | |
377 | } | |
378 | ||
379 | /* Verify integrity */ | |
380 | rc = s390_pv_verify(); | |
381 | if (rc) { | |
382 | goto out_err; | |
383 | } | |
384 | return rc; | |
385 | ||
386 | out_err: | |
387 | s390_machine_unprotect(ms); | |
388 | return rc; | |
389 | } | |
390 | ||
c3347ed0 JF |
391 | static void s390_pv_prepare_reset(S390CcwMachineState *ms) |
392 | { | |
393 | CPUState *cs; | |
394 | ||
395 | if (!s390_is_pv()) { | |
396 | return; | |
397 | } | |
398 | /* Unsharing requires all cpus to be stopped */ | |
399 | CPU_FOREACH(cs) { | |
400 | s390_cpu_set_state(S390_CPU_STATE_STOPPED, S390_CPU(cs)); | |
401 | } | |
402 | s390_pv_unshare(); | |
9a432597 | 403 | s390_pv_prep_reset(); |
c3347ed0 JF |
404 | } |
405 | ||
a0628599 | 406 | static void s390_machine_reset(MachineState *machine) |
6286b419 | 407 | { |
c3347ed0 | 408 | S390CcwMachineState *ms = S390_CCW_MACHINE(machine); |
a30fb811 DH |
409 | enum s390_reset reset_type; |
410 | CPUState *cs, *t; | |
c3347ed0 | 411 | S390CPU *cpu; |
6286b419 | 412 | |
a30fb811 DH |
413 | /* get the reset parameters, reset them once done */ |
414 | s390_ipl_get_reset_request(&cs, &reset_type); | |
415 | ||
416 | /* all CPUs are paused and synchronized at this point */ | |
6286b419 | 417 | s390_cmma_reset(); |
6286b419 | 418 | |
c3347ed0 JF |
419 | cpu = S390_CPU(cs); |
420 | ||
a30fb811 DH |
421 | switch (reset_type) { |
422 | case S390_RESET_EXTERNAL: | |
423 | case S390_RESET_REIPL: | |
c3347ed0 JF |
424 | if (s390_is_pv()) { |
425 | s390_machine_unprotect(ms); | |
426 | } | |
427 | ||
a30fb811 DH |
428 | qemu_devices_reset(); |
429 | s390_crypto_reset(); | |
430 | ||
431 | /* configure and start the ipl CPU only */ | |
432 | run_on_cpu(cs, s390_do_cpu_ipl, RUN_ON_CPU_NULL); | |
433 | break; | |
434 | case S390_RESET_MODIFIED_CLEAR: | |
c3347ed0 JF |
435 | /* |
436 | * Susbsystem reset needs to be done before we unshare memory | |
437 | * and lose access to VIRTIO structures in guest memory. | |
438 | */ | |
439 | subsystem_reset(); | |
440 | s390_crypto_reset(); | |
441 | s390_pv_prepare_reset(ms); | |
a30fb811 DH |
442 | CPU_FOREACH(t) { |
443 | run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); | |
444 | } | |
a30fb811 DH |
445 | run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); |
446 | break; | |
447 | case S390_RESET_LOAD_NORMAL: | |
c3347ed0 JF |
448 | /* |
449 | * Susbsystem reset needs to be done before we unshare memory | |
450 | * and lose access to VIRTIO structures in guest memory. | |
451 | */ | |
452 | subsystem_reset(); | |
453 | s390_pv_prepare_reset(ms); | |
a30fb811 | 454 | CPU_FOREACH(t) { |
ec922733 JF |
455 | if (t == cs) { |
456 | continue; | |
457 | } | |
a30fb811 DH |
458 | run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL); |
459 | } | |
a30fb811 | 460 | run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL); |
c3347ed0 JF |
461 | run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); |
462 | break; | |
463 | case S390_RESET_PV: /* Subcode 10 */ | |
464 | subsystem_reset(); | |
465 | s390_crypto_reset(); | |
466 | ||
467 | CPU_FOREACH(t) { | |
468 | if (t == cs) { | |
469 | continue; | |
470 | } | |
471 | run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); | |
472 | } | |
473 | run_on_cpu(cs, s390_do_cpu_reset, RUN_ON_CPU_NULL); | |
474 | ||
475 | if (s390_machine_protect(ms)) { | |
fbc1384c | 476 | s390_pv_inject_reset_error(cs); |
c3347ed0 JF |
477 | /* |
478 | * Continue after the diag308 so the guest knows something | |
479 | * went wrong. | |
480 | */ | |
481 | s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu); | |
482 | return; | |
483 | } | |
484 | ||
a30fb811 DH |
485 | run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL); |
486 | break; | |
487 | default: | |
488 | g_assert_not_reached(); | |
489 | } | |
e2c6cd56 CW |
490 | |
491 | CPU_FOREACH(t) { | |
492 | run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(0)); | |
493 | } | |
a30fb811 | 494 | s390_ipl_clear_reset_request(); |
6286b419 DH |
495 | } |
496 | ||
502edbf8 MR |
497 | static void s390_machine_device_plug(HotplugHandler *hotplug_dev, |
498 | DeviceState *dev, Error **errp) | |
499 | { | |
500 | if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { | |
501 | s390_cpu_plug(hotplug_dev, dev, errp); | |
502 | } | |
503 | } | |
504 | ||
f2f3beb0 DH |
505 | static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev, |
506 | DeviceState *dev, Error **errp) | |
507 | { | |
508 | if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { | |
509 | error_setg(errp, "CPU hot unplug not supported on this machine"); | |
510 | return; | |
511 | } | |
512 | } | |
513 | ||
81ce6aa5 | 514 | static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms, |
4dc3b151 DH |
515 | unsigned cpu_index) |
516 | { | |
81ce6aa5 DH |
517 | MachineClass *mc = MACHINE_GET_CLASS(ms); |
518 | const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms); | |
4dc3b151 | 519 | |
81ce6aa5 DH |
520 | assert(cpu_index < possible_cpus->len); |
521 | return possible_cpus->cpus[cpu_index].props; | |
4dc3b151 DH |
522 | } |
523 | ||
524 | static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms) | |
525 | { | |
526 | int i; | |
ae71ed86 | 527 | unsigned int max_cpus = ms->smp.max_cpus; |
4dc3b151 DH |
528 | |
529 | if (ms->possible_cpus) { | |
530 | g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus); | |
531 | return ms->possible_cpus; | |
532 | } | |
533 | ||
534 | ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + | |
535 | sizeof(CPUArchId) * max_cpus); | |
536 | ms->possible_cpus->len = max_cpus; | |
537 | for (i = 0; i < ms->possible_cpus->len; i++) { | |
d342eb76 | 538 | ms->possible_cpus->cpus[i].type = ms->cpu_type; |
4dc3b151 DH |
539 | ms->possible_cpus->cpus[i].vcpus_count = 1; |
540 | ms->possible_cpus->cpus[i].arch_id = i; | |
541 | ms->possible_cpus->cpus[i].props.has_core_id = true; | |
542 | ms->possible_cpus->cpus[i].props.core_id = i; | |
543 | } | |
544 | ||
545 | return ms->possible_cpus; | |
546 | } | |
547 | ||
502edbf8 MR |
548 | static HotplugHandler *s390_get_hotplug_handler(MachineState *machine, |
549 | DeviceState *dev) | |
550 | { | |
551 | if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { | |
552 | return HOTPLUG_HANDLER(machine); | |
553 | } | |
554 | return NULL; | |
555 | } | |
556 | ||
6286b419 DH |
557 | static void s390_nmi(NMIState *n, int cpu_index, Error **errp) |
558 | { | |
559 | CPUState *cs = qemu_get_cpu(cpu_index); | |
560 | ||
0fc60ca5 | 561 | s390_cpu_restart(S390_CPU(cs)); |
6286b419 DH |
562 | } |
563 | ||
5c30ef93 CB |
564 | static ram_addr_t s390_fixup_ram_size(ram_addr_t sz) |
565 | { | |
566 | /* same logic as in sclp.c */ | |
567 | int increment_size = 20; | |
568 | ram_addr_t newsz; | |
569 | ||
570 | while ((sz >> increment_size) > MAX_STORAGE_INCREMENTS) { | |
571 | increment_size++; | |
572 | } | |
573 | newsz = sz >> increment_size << increment_size; | |
574 | ||
575 | if (sz != newsz) { | |
576 | qemu_printf("Ram size %" PRIu64 "MB was fixed up to %" PRIu64 | |
577 | "MB to match machine restrictions. Consider updating " | |
578 | "the guest definition.\n", (uint64_t) (sz / MiB), | |
579 | (uint64_t) (newsz / MiB)); | |
580 | } | |
581 | return newsz; | |
582 | } | |
583 | ||
d07aa7c7 AK |
584 | static void ccw_machine_class_init(ObjectClass *oc, void *data) |
585 | { | |
586 | MachineClass *mc = MACHINE_CLASS(oc); | |
3dd7852f | 587 | NMIClass *nc = NMI_CLASS(oc); |
502edbf8 | 588 | HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); |
b1af5872 | 589 | S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); |
d07aa7c7 | 590 | |
9700230b | 591 | s390mc->ri_allowed = true; |
e73316d5 | 592 | s390mc->cpu_model_allowed = true; |
e996583e | 593 | s390mc->css_migration_enabled = true; |
28221f9c | 594 | s390mc->hpage_1m_allowed = true; |
d07aa7c7 | 595 | mc->init = ccw_init; |
db3b2566 | 596 | mc->reset = s390_machine_reset; |
d07aa7c7 AK |
597 | mc->block_default_type = IF_VIRTIO; |
598 | mc->no_cdrom = 1; | |
599 | mc->no_floppy = 1; | |
d07aa7c7 AK |
600 | mc->no_parallel = 1; |
601 | mc->no_sdcard = 1; | |
f42dc44a | 602 | mc->max_cpus = S390_MAX_CPUS; |
4dc3b151 | 603 | mc->has_hotpluggable_cpus = true; |
debbdc00 | 604 | assert(!mc->get_hotplug_handler); |
502edbf8 | 605 | mc->get_hotplug_handler = s390_get_hotplug_handler; |
4dc3b151 DH |
606 | mc->cpu_index_to_instance_props = s390_cpu_index_to_props; |
607 | mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids; | |
b6805e12 IM |
608 | /* it is overridden with 'host' cpu *in kvm_arch_init* */ |
609 | mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu"); | |
502edbf8 | 610 | hc->plug = s390_machine_device_plug; |
f2f3beb0 | 611 | hc->unplug_request = s390_machine_device_unplug_request; |
3dd7852f | 612 | nc->nmi_monitor_handler = s390_nmi; |
3a12fc61 | 613 | mc->default_ram_id = "s390.ram"; |
d07aa7c7 AK |
614 | } |
615 | ||
2eb1cd07 TK |
616 | static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) |
617 | { | |
618 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
619 | ||
620 | return ms->aes_key_wrap; | |
621 | } | |
622 | ||
623 | static inline void machine_set_aes_key_wrap(Object *obj, bool value, | |
624 | Error **errp) | |
625 | { | |
626 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
627 | ||
628 | ms->aes_key_wrap = value; | |
629 | } | |
630 | ||
631 | static inline bool machine_get_dea_key_wrap(Object *obj, Error **errp) | |
632 | { | |
633 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
634 | ||
635 | return ms->dea_key_wrap; | |
636 | } | |
637 | ||
638 | static inline void machine_set_dea_key_wrap(Object *obj, bool value, | |
639 | Error **errp) | |
640 | { | |
641 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
642 | ||
643 | ms->dea_key_wrap = value; | |
644 | } | |
645 | ||
cec8bbf7 | 646 | static S390CcwMachineClass *current_mc; |
9700230b | 647 | |
3e0209bb TH |
648 | /* |
649 | * Get the class of the s390-ccw-virtio machine that is currently in use. | |
650 | * Note: libvirt is using the "none" machine to probe for the features of the | |
651 | * host CPU, so in case this is called with the "none" machine, the function | |
652 | * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the | |
653 | * various "*_allowed" variables are enabled, so that the *_allowed() wrappers | |
654 | * below return the correct default value for the "none" machine. | |
655 | * | |
656 | * Attention! Do *not* add additional new wrappers for CPU features (e.g. like | |
657 | * the ri_allowed() wrapper) via this mechanism anymore. CPU features should | |
658 | * be handled via the CPU models, i.e. checking with cpu_model_allowed() during | |
659 | * CPU initialization and s390_has_feat() later should be sufficient. | |
660 | */ | |
cec8bbf7 HP |
661 | static S390CcwMachineClass *get_machine_class(void) |
662 | { | |
663 | if (unlikely(!current_mc)) { | |
392529cb | 664 | /* |
cec8bbf7 HP |
665 | * No s390 ccw machine was instantiated, we are likely to |
666 | * be called for the 'none' machine. The properties will | |
667 | * have their after-initialization values. | |
668 | */ | |
b1af5872 | 669 | current_mc = S390_CCW_MACHINE_CLASS( |
cec8bbf7 | 670 | object_class_by_name(TYPE_S390_CCW_MACHINE)); |
9700230b | 671 | } |
cec8bbf7 | 672 | return current_mc; |
9700230b FZ |
673 | } |
674 | ||
cec8bbf7 | 675 | bool ri_allowed(void) |
e73316d5 | 676 | { |
cec8bbf7 HP |
677 | return get_machine_class()->ri_allowed; |
678 | } | |
679 | ||
680 | bool cpu_model_allowed(void) | |
681 | { | |
cec8bbf7 | 682 | return get_machine_class()->cpu_model_allowed; |
e73316d5 CB |
683 | } |
684 | ||
28221f9c JF |
685 | bool hpage_1m_allowed(void) |
686 | { | |
28221f9c JF |
687 | return get_machine_class()->hpage_1m_allowed; |
688 | } | |
689 | ||
7104bae9 FA |
690 | static char *machine_get_loadparm(Object *obj, Error **errp) |
691 | { | |
692 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
693 | ||
d6645483 | 694 | /* make a NUL-terminated string */ |
148d25e0 | 695 | return g_strndup((char *) ms->loadparm, sizeof(ms->loadparm)); |
7104bae9 FA |
696 | } |
697 | ||
698 | static void machine_set_loadparm(Object *obj, const char *val, Error **errp) | |
699 | { | |
700 | S390CcwMachineState *ms = S390_CCW_MACHINE(obj); | |
701 | int i; | |
702 | ||
703 | for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) { | |
95a5befc | 704 | uint8_t c = qemu_toupper(val[i]); /* mimic HMC */ |
7104bae9 FA |
705 | |
706 | if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') || | |
707 | (c == ' ')) { | |
708 | ms->loadparm[i] = c; | |
709 | } else { | |
710 | error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%02x)", | |
711 | c, c); | |
712 | return; | |
713 | } | |
714 | } | |
715 | ||
716 | for (; i < sizeof(ms->loadparm); i++) { | |
717 | ms->loadparm[i] = ' '; /* pad right with spaces */ | |
718 | } | |
719 | } | |
2eb1cd07 TK |
720 | static inline void s390_machine_initfn(Object *obj) |
721 | { | |
722 | object_property_add_bool(obj, "aes-key-wrap", | |
723 | machine_get_aes_key_wrap, | |
d2623129 | 724 | machine_set_aes_key_wrap); |
2eb1cd07 | 725 | object_property_set_description(obj, "aes-key-wrap", |
7eecec7d | 726 | "enable/disable AES key wrapping using the CPACF wrapping key"); |
5325cc34 | 727 | object_property_set_bool(obj, "aes-key-wrap", true, NULL); |
2eb1cd07 TK |
728 | |
729 | object_property_add_bool(obj, "dea-key-wrap", | |
730 | machine_get_dea_key_wrap, | |
d2623129 | 731 | machine_set_dea_key_wrap); |
2eb1cd07 | 732 | object_property_set_description(obj, "dea-key-wrap", |
7eecec7d | 733 | "enable/disable DEA key wrapping using the CPACF wrapping key"); |
5325cc34 | 734 | object_property_set_bool(obj, "dea-key-wrap", true, NULL); |
7104bae9 | 735 | object_property_add_str(obj, "loadparm", |
d2623129 | 736 | machine_get_loadparm, machine_set_loadparm); |
7104bae9 FA |
737 | object_property_set_description(obj, "loadparm", |
738 | "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted" | |
739 | " to upper case) to pass to machine loader, boot manager," | |
7eecec7d | 740 | " and guest kernel"); |
2eb1cd07 TK |
741 | } |
742 | ||
d07aa7c7 AK |
743 | static const TypeInfo ccw_machine_info = { |
744 | .name = TYPE_S390_CCW_MACHINE, | |
745 | .parent = TYPE_MACHINE, | |
c4d3c0a2 | 746 | .abstract = true, |
2eb1cd07 TK |
747 | .instance_size = sizeof(S390CcwMachineState), |
748 | .instance_init = s390_machine_initfn, | |
9700230b | 749 | .class_size = sizeof(S390CcwMachineClass), |
d07aa7c7 | 750 | .class_init = ccw_machine_class_init, |
3dd7852f AK |
751 | .interfaces = (InterfaceInfo[]) { |
752 | { TYPE_NMI }, | |
502edbf8 | 753 | { TYPE_HOTPLUG_HANDLER}, |
3dd7852f AK |
754 | { } |
755 | }, | |
a5c95808 CH |
756 | }; |
757 | ||
52629b3b HP |
758 | bool css_migration_enabled(void) |
759 | { | |
760 | return get_machine_class()->css_migration_enabled; | |
761 | } | |
762 | ||
4fca6548 JF |
763 | #define DEFINE_CCW_MACHINE(suffix, verstr, latest) \ |
764 | static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \ | |
765 | void *data) \ | |
766 | { \ | |
767 | MachineClass *mc = MACHINE_CLASS(oc); \ | |
768 | ccw_machine_##suffix##_class_options(mc); \ | |
769 | mc->desc = "VirtIO-ccw based S390 machine v" verstr; \ | |
770 | if (latest) { \ | |
771 | mc->alias = "s390-ccw-virtio"; \ | |
ea0ac7f6 | 772 | mc->is_default = true; \ |
4fca6548 JF |
773 | } \ |
774 | } \ | |
775 | static void ccw_machine_##suffix##_instance_init(Object *obj) \ | |
776 | { \ | |
777 | MachineState *machine = MACHINE(obj); \ | |
b1af5872 | 778 | current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \ |
4fca6548 JF |
779 | ccw_machine_##suffix##_instance_options(machine); \ |
780 | } \ | |
781 | static const TypeInfo ccw_machine_##suffix##_info = { \ | |
782 | .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \ | |
783 | .parent = TYPE_S390_CCW_MACHINE, \ | |
784 | .class_init = ccw_machine_##suffix##_class_init, \ | |
785 | .instance_init = ccw_machine_##suffix##_instance_init, \ | |
786 | }; \ | |
787 | static void ccw_machine_register_##suffix(void) \ | |
788 | { \ | |
789 | type_register_static(&ccw_machine_##suffix##_info); \ | |
790 | } \ | |
0e6aac87 | 791 | type_init(ccw_machine_register_##suffix) |
4fca6548 | 792 | |
576a00bd CH |
793 | static void ccw_machine_6_0_instance_options(MachineState *machine) |
794 | { | |
795 | } | |
796 | ||
797 | static void ccw_machine_6_0_class_options(MachineClass *mc) | |
798 | { | |
799 | } | |
800 | DEFINE_CCW_MACHINE(6_0, "6.0", true); | |
801 | ||
3ff3c5d3 CH |
802 | static void ccw_machine_5_2_instance_options(MachineState *machine) |
803 | { | |
576a00bd | 804 | ccw_machine_6_0_instance_options(machine); |
3ff3c5d3 CH |
805 | } |
806 | ||
807 | static void ccw_machine_5_2_class_options(MachineClass *mc) | |
808 | { | |
576a00bd CH |
809 | ccw_machine_6_0_class_options(mc); |
810 | compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); | |
3ff3c5d3 | 811 | } |
576a00bd | 812 | DEFINE_CCW_MACHINE(5_2, "5.2", false); |
3ff3c5d3 | 813 | |
541aaa1d CH |
814 | static void ccw_machine_5_1_instance_options(MachineState *machine) |
815 | { | |
3ff3c5d3 | 816 | ccw_machine_5_2_instance_options(machine); |
541aaa1d CH |
817 | } |
818 | ||
819 | static void ccw_machine_5_1_class_options(MachineClass *mc) | |
820 | { | |
3ff3c5d3 CH |
821 | ccw_machine_5_2_class_options(mc); |
822 | compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len); | |
541aaa1d | 823 | } |
3ff3c5d3 | 824 | DEFINE_CCW_MACHINE(5_1, "5.1", false); |
541aaa1d | 825 | |
3eb74d20 CH |
826 | static void ccw_machine_5_0_instance_options(MachineState *machine) |
827 | { | |
541aaa1d | 828 | ccw_machine_5_1_instance_options(machine); |
3eb74d20 CH |
829 | } |
830 | ||
831 | static void ccw_machine_5_0_class_options(MachineClass *mc) | |
832 | { | |
541aaa1d CH |
833 | ccw_machine_5_1_class_options(mc); |
834 | compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len); | |
3eb74d20 | 835 | } |
541aaa1d | 836 | DEFINE_CCW_MACHINE(5_0, "5.0", false); |
3eb74d20 | 837 | |
9aec2e52 CH |
838 | static void ccw_machine_4_2_instance_options(MachineState *machine) |
839 | { | |
3eb74d20 | 840 | ccw_machine_5_0_instance_options(machine); |
9aec2e52 CH |
841 | } |
842 | ||
843 | static void ccw_machine_4_2_class_options(MachineClass *mc) | |
844 | { | |
3eb74d20 | 845 | ccw_machine_5_0_class_options(mc); |
5c30ef93 | 846 | mc->fixup_ram_size = s390_fixup_ram_size; |
5f258577 | 847 | compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len); |
9aec2e52 | 848 | } |
3eb74d20 | 849 | DEFINE_CCW_MACHINE(4_2, "4.2", false); |
9aec2e52 | 850 | |
9bf2650b CH |
851 | static void ccw_machine_4_1_instance_options(MachineState *machine) |
852 | { | |
faa40177 | 853 | static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_1 }; |
9aec2e52 | 854 | ccw_machine_4_2_instance_options(machine); |
faa40177 | 855 | s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat); |
9bf2650b CH |
856 | } |
857 | ||
858 | static void ccw_machine_4_1_class_options(MachineClass *mc) | |
859 | { | |
9aec2e52 CH |
860 | ccw_machine_4_2_class_options(mc); |
861 | compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); | |
9bf2650b | 862 | } |
9aec2e52 | 863 | DEFINE_CCW_MACHINE(4_1, "4.1", false); |
9bf2650b | 864 | |
8c7b0c73 CH |
865 | static void ccw_machine_4_0_instance_options(MachineState *machine) |
866 | { | |
08ef92d5 | 867 | static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_0 }; |
9bf2650b | 868 | ccw_machine_4_1_instance_options(machine); |
08ef92d5 | 869 | s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat); |
8c7b0c73 CH |
870 | } |
871 | ||
872 | static void ccw_machine_4_0_class_options(MachineClass *mc) | |
873 | { | |
9bf2650b CH |
874 | ccw_machine_4_1_class_options(mc); |
875 | compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len); | |
8c7b0c73 | 876 | } |
9bf2650b | 877 | DEFINE_CCW_MACHINE(4_0, "4.0", false); |
8c7b0c73 | 878 | |
9ca056d6 CH |
879 | static void ccw_machine_3_1_instance_options(MachineState *machine) |
880 | { | |
d646b16b | 881 | static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 }; |
8c7b0c73 | 882 | ccw_machine_4_0_instance_options(machine); |
84176c79 CW |
883 | s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH); |
884 | s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF); | |
d646b16b | 885 | s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat); |
9ca056d6 CH |
886 | } |
887 | ||
888 | static void ccw_machine_3_1_class_options(MachineClass *mc) | |
889 | { | |
8c7b0c73 | 890 | ccw_machine_4_0_class_options(mc); |
abd93cc7 | 891 | compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); |
9ca056d6 | 892 | } |
8c7b0c73 | 893 | DEFINE_CCW_MACHINE(3_1, "3.1", false); |
9ca056d6 | 894 | |
2c5a2eef | 895 | static void ccw_machine_3_0_instance_options(MachineState *machine) |
7a9cb3ad | 896 | { |
9ca056d6 | 897 | ccw_machine_3_1_instance_options(machine); |
7a9cb3ad CH |
898 | } |
899 | ||
2c5a2eef | 900 | static void ccw_machine_3_0_class_options(MachineClass *mc) |
7a9cb3ad | 901 | { |
b1af5872 | 902 | S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); |
28221f9c JF |
903 | |
904 | s390mc->hpage_1m_allowed = false; | |
9ca056d6 | 905 | ccw_machine_3_1_class_options(mc); |
ddb3235d | 906 | compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len); |
7a9cb3ad | 907 | } |
9ca056d6 | 908 | DEFINE_CCW_MACHINE(3_0, "3.0", false); |
7a9cb3ad | 909 | |
67ee0cef CH |
910 | static void ccw_machine_2_12_instance_options(MachineState *machine) |
911 | { | |
2c5a2eef | 912 | ccw_machine_3_0_instance_options(machine); |
87273151 CB |
913 | s390_cpudef_featoff_greater(11, 1, S390_FEAT_PPA15); |
914 | s390_cpudef_featoff_greater(11, 1, S390_FEAT_BPB); | |
67ee0cef CH |
915 | } |
916 | ||
917 | static void ccw_machine_2_12_class_options(MachineClass *mc) | |
918 | { | |
2c5a2eef | 919 | ccw_machine_3_0_class_options(mc); |
0d47310b | 920 | compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len); |
67ee0cef | 921 | } |
7a9cb3ad | 922 | DEFINE_CCW_MACHINE(2_12, "2.12", false); |
67ee0cef | 923 | |
70d8d9a0 CH |
924 | static void ccw_machine_2_11_instance_options(MachineState *machine) |
925 | { | |
35b4df64 | 926 | static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_11 }; |
67ee0cef | 927 | ccw_machine_2_12_instance_options(machine); |
35b4df64 DH |
928 | |
929 | /* before 2.12 we emulated the very first z900 */ | |
930 | s390_set_qemu_cpu_model(0x2064, 7, 1, qemu_cpu_feat); | |
70d8d9a0 CH |
931 | } |
932 | ||
933 | static void ccw_machine_2_11_class_options(MachineClass *mc) | |
934 | { | |
88cbe073 | 935 | static GlobalProperty compat[] = { |
6c36bddf | 936 | { TYPE_SCLP_EVENT_FACILITY, "allow_all_mask_sizes", "off", }, |
88cbe073 MAL |
937 | }; |
938 | ||
67ee0cef | 939 | ccw_machine_2_12_class_options(mc); |
43df70a9 | 940 | compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len); |
88cbe073 | 941 | compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); |
70d8d9a0 | 942 | } |
67ee0cef | 943 | DEFINE_CCW_MACHINE(2_11, "2.11", false); |
70d8d9a0 | 944 | |
10890873 CH |
945 | static void ccw_machine_2_10_instance_options(MachineState *machine) |
946 | { | |
70d8d9a0 | 947 | ccw_machine_2_11_instance_options(machine); |
10890873 CH |
948 | } |
949 | ||
950 | static void ccw_machine_2_10_class_options(MachineClass *mc) | |
951 | { | |
70d8d9a0 | 952 | ccw_machine_2_11_class_options(mc); |
503224f4 | 953 | compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len); |
10890873 | 954 | } |
70d8d9a0 | 955 | DEFINE_CCW_MACHINE(2_10, "2.10", false); |
10890873 | 956 | |
113725a6 CH |
957 | static void ccw_machine_2_9_instance_options(MachineState *machine) |
958 | { | |
10890873 | 959 | ccw_machine_2_10_instance_options(machine); |
7223bcce JH |
960 | s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP); |
961 | s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2); | |
3b00f702 YMZ |
962 | s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI); |
963 | s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION); | |
964 | s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION); | |
113725a6 CH |
965 | } |
966 | ||
967 | static void ccw_machine_2_9_class_options(MachineClass *mc) | |
968 | { | |
b1af5872 | 969 | S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); |
88cbe073 | 970 | static GlobalProperty compat[] = { |
6c36bddf | 971 | { TYPE_S390_STATTRIB, "migration-enabled", "off", }, |
88cbe073 | 972 | }; |
52629b3b | 973 | |
10890873 | 974 | ccw_machine_2_10_class_options(mc); |
3e803152 | 975 | compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len); |
88cbe073 | 976 | compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); |
52629b3b | 977 | s390mc->css_migration_enabled = false; |
113725a6 | 978 | } |
10890873 | 979 | DEFINE_CCW_MACHINE(2_9, "2.9", false); |
113725a6 | 980 | |
61823988 CH |
981 | static void ccw_machine_2_8_instance_options(MachineState *machine) |
982 | { | |
113725a6 | 983 | ccw_machine_2_9_instance_options(machine); |
61823988 CH |
984 | } |
985 | ||
986 | static void ccw_machine_2_8_class_options(MachineClass *mc) | |
987 | { | |
88cbe073 | 988 | static GlobalProperty compat[] = { |
6c36bddf | 989 | { TYPE_S390_FLIC_COMMON, "adapter_routes_max_batch", "64", }, |
88cbe073 MAL |
990 | }; |
991 | ||
113725a6 | 992 | ccw_machine_2_9_class_options(mc); |
edc24ccd | 993 | compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len); |
88cbe073 | 994 | compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); |
61823988 | 995 | } |
113725a6 | 996 | DEFINE_CCW_MACHINE(2_8, "2.8", false); |
61823988 | 997 | |
946e55f3 CH |
998 | static void ccw_machine_2_7_instance_options(MachineState *machine) |
999 | { | |
61823988 | 1000 | ccw_machine_2_8_instance_options(machine); |
946e55f3 CH |
1001 | } |
1002 | ||
1003 | static void ccw_machine_2_7_class_options(MachineClass *mc) | |
1004 | { | |
b1af5872 | 1005 | S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); |
e73316d5 CB |
1006 | |
1007 | s390mc->cpu_model_allowed = false; | |
61823988 | 1008 | ccw_machine_2_8_class_options(mc); |
5a995064 | 1009 | compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len); |
946e55f3 | 1010 | } |
61823988 | 1011 | DEFINE_CCW_MACHINE(2_7, "2.7", false); |
946e55f3 | 1012 | |
4fca6548 | 1013 | static void ccw_machine_2_6_instance_options(MachineState *machine) |
c4d3c0a2 | 1014 | { |
946e55f3 | 1015 | ccw_machine_2_7_instance_options(machine); |
c4d3c0a2 CB |
1016 | } |
1017 | ||
4fca6548 | 1018 | static void ccw_machine_2_6_class_options(MachineClass *mc) |
84b48ad6 | 1019 | { |
b1af5872 | 1020 | S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc); |
88cbe073 | 1021 | static GlobalProperty compat[] = { |
6c36bddf EH |
1022 | { TYPE_S390_IPL, "iplbext_migration", "off", }, |
1023 | { TYPE_VIRTUAL_CSS_BRIDGE, "css_dev_path", "off", }, | |
88cbe073 | 1024 | }; |
9700230b FZ |
1025 | |
1026 | s390mc->ri_allowed = false; | |
946e55f3 | 1027 | ccw_machine_2_7_class_options(mc); |
ff8f261f | 1028 | compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len); |
88cbe073 | 1029 | compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); |
84b48ad6 | 1030 | } |
946e55f3 | 1031 | DEFINE_CCW_MACHINE(2_6, "2.6", false); |
84b48ad6 | 1032 | |
4fca6548 JF |
1033 | static void ccw_machine_2_5_instance_options(MachineState *machine) |
1034 | { | |
946e55f3 | 1035 | ccw_machine_2_6_instance_options(machine); |
4fca6548 | 1036 | } |
84b48ad6 | 1037 | |
4fca6548 | 1038 | static void ccw_machine_2_5_class_options(MachineClass *mc) |
b21b7598 | 1039 | { |
946e55f3 | 1040 | ccw_machine_2_6_class_options(mc); |
fe759610 | 1041 | compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len); |
4fca6548 JF |
1042 | } |
1043 | DEFINE_CCW_MACHINE(2_5, "2.5", false); | |
b21b7598 | 1044 | |
4fca6548 JF |
1045 | static void ccw_machine_2_4_instance_options(MachineState *machine) |
1046 | { | |
1047 | ccw_machine_2_5_instance_options(machine); | |
b21b7598 CH |
1048 | } |
1049 | ||
4fca6548 JF |
1050 | static void ccw_machine_2_4_class_options(MachineClass *mc) |
1051 | { | |
88cbe073 | 1052 | static GlobalProperty compat[] = { |
6c36bddf EH |
1053 | { TYPE_S390_SKEYS, "migration-enabled", "off", }, |
1054 | { "virtio-blk-ccw", "max_revision", "0", }, | |
1055 | { "virtio-balloon-ccw", "max_revision", "0", }, | |
1056 | { "virtio-serial-ccw", "max_revision", "0", }, | |
1057 | { "virtio-9p-ccw", "max_revision", "0", }, | |
1058 | { "virtio-rng-ccw", "max_revision", "0", }, | |
1059 | { "virtio-net-ccw", "max_revision", "0", }, | |
1060 | { "virtio-scsi-ccw", "max_revision", "0", }, | |
1061 | { "vhost-scsi-ccw", "max_revision", "0", }, | |
88cbe073 MAL |
1062 | }; |
1063 | ||
946e55f3 | 1064 | ccw_machine_2_5_class_options(mc); |
2f99b9c2 | 1065 | compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len); |
88cbe073 | 1066 | compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); |
4fca6548 JF |
1067 | } |
1068 | DEFINE_CCW_MACHINE(2_4, "2.4", false); | |
b21b7598 | 1069 | |
d07aa7c7 | 1070 | static void ccw_machine_register_types(void) |
a5c95808 | 1071 | { |
d07aa7c7 | 1072 | type_register_static(&ccw_machine_info); |
a5c95808 CH |
1073 | } |
1074 | ||
d07aa7c7 | 1075 | type_init(ccw_machine_register_types) |