Bug Summary

File:hw/s390x/s390-virtio-bus.c
Location:line 400, column 5
Description:Value stored to 'cur_offs' is never read

Annotated Source Code

1/*
2 * QEMU S390 virtio target
3 *
4 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "hw/hw.h"
21#include "block/block.h"
22#include "sysemu/sysemu.h"
23#include "hw/boards.h"
24#include "monitor/monitor.h"
25#include "hw/loader.h"
26#include "elf.h"
27#include "hw/virtio/virtio.h"
28#include "hw/virtio/virtio-rng.h"
29#include "hw/virtio/virtio-serial.h"
30#include "hw/virtio/virtio-net.h"
31#include "hw/virtio/vhost-scsi.h"
32#include "hw/sysbus.h"
33#include "sysemu/kvm.h"
34
35#include "hw/s390x/s390-virtio-bus.h"
36#include "hw/virtio/virtio-bus.h"
37
38/* #define DEBUG_S390 */
39
40#ifdef DEBUG_S390
41#define DPRINTF(fmt, ...)do { } while (0) \
42 do { fprintf(stderrstderr, fmt, ## __VA_ARGS__); } while (0)
43#else
44#define DPRINTF(fmt, ...)do { } while (0) \
45 do { } while (0)
46#endif
47
48#define VIRTIO_EXT_CODE0x2603 0x2603
49
50static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
51 VirtIOS390Device *dev);
52
53static const TypeInfo s390_virtio_bus_info = {
54 .name = TYPE_S390_VIRTIO_BUS"s390-virtio-bus",
55 .parent = TYPE_BUS"bus",
56 .instance_size = sizeof(VirtIOS390Bus),
57};
58
59static ram_addr_t s390_virtio_device_num_vq(VirtIOS390Device *dev);
60
61/* length of VirtIO device pages */
62const hwaddr virtio_size = S390_DEVICE_PAGES512 * TARGET_PAGE_SIZE(1 << 12);
63
64static void s390_virtio_bus_reset(void *opaque)
65{
66 VirtIOS390Bus *bus = opaque;
67 bus->next_ring = bus->dev_page + TARGET_PAGE_SIZE(1 << 12);
68}
69
70void s390_virtio_reset_idx(VirtIOS390Device *dev)
71{
72 int i;
73 hwaddr idx_addr;
74 uint8_t num_vq;
75
76 num_vq = s390_virtio_device_num_vq(dev);
77 for (i = 0; i < num_vq; i++) {
78 idx_addr = virtio_queue_get_avail_addr(dev->vdev, i) +
79 VIRTIO_VRING_AVAIL_IDX_OFFS2;
80 stw_phys(idx_addr, 0);
81 idx_addr = virtio_queue_get_used_addr(dev->vdev, i) +
82 VIRTIO_VRING_USED_IDX_OFFS2;
83 stw_phys(idx_addr, 0);
84 }
85}
86
87VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size)
88{
89 VirtIOS390Bus *bus;
90 BusState *_bus;
91 DeviceState *dev;
92
93 /* Create bridge device */
94 dev = qdev_create(NULL((void*)0), "s390-virtio-bridge");
95 qdev_init_nofail(dev);
96
97 /* Create bus on bridge device */
98
99 _bus = qbus_create(TYPE_S390_VIRTIO_BUS"s390-virtio-bus", dev, "s390-virtio");
100 bus = DO_UPCAST(VirtIOS390Bus, bus, _bus)( __extension__ ( { char __attribute__((unused)) offset_must_be_zero
[ -__builtin_offsetof(VirtIOS390Bus, bus)]; ({ const typeof((
(VirtIOS390Bus *) 0)->bus) *__mptr = (_bus); (VirtIOS390Bus
*) ((char *) __mptr - __builtin_offsetof(VirtIOS390Bus, bus)
);});}))
;
101
102 bus->dev_page = *ram_size;
103 bus->dev_offs = bus->dev_page;
104 bus->next_ring = bus->dev_page + TARGET_PAGE_SIZE(1 << 12);
105
106 /* Enable hotplugging */
107 _bus->allow_hotplug = 1;
108
109 /* Allocate RAM for VirtIO device pages (descriptors, queues, rings) */
110 *ram_size += S390_DEVICE_PAGES512 * TARGET_PAGE_SIZE(1 << 12);
111
112 qemu_register_reset(s390_virtio_bus_reset, bus);
113 return bus;
114}
115
116static void s390_virtio_irq(S390CPU *cpu, int config_change, uint64_t token)
117{
118 if (kvm_enabled()(0)) {
119 kvm_s390_virtio_irq(cpu, config_change, token);
120 } else {
121 cpu_inject_ext(cpu, VIRTIO_EXT_CODE0x2603, config_change, token);
122 }
123}
124
125static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
126{
127 VirtIOS390Bus *bus;
128 int dev_len;
129
130 bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus)( __extension__ ( { char __attribute__((unused)) offset_must_be_zero
[ -__builtin_offsetof(VirtIOS390Bus, bus)]; ({ const typeof((
(VirtIOS390Bus *) 0)->bus) *__mptr = (dev->qdev.parent_bus
); (VirtIOS390Bus *) ((char *) __mptr - __builtin_offsetof(VirtIOS390Bus
, bus));});}))
;
131 dev->vdev = vdev;
132 dev->dev_offs = bus->dev_offs;
133 dev->feat_len = sizeof(uint32_t); /* always keep 32 bits features */
134
135 dev_len = VIRTIO_DEV_OFFS_CONFIG5;
136 dev_len += s390_virtio_device_num_vq(dev) * VIRTIO_VQCONFIG_LEN24;
137 dev_len += dev->feat_len * 2;
138 dev_len += virtio_bus_get_vdev_config_len(&dev->bus);
139
140 bus->dev_offs += dev_len;
141
142 dev->host_features = virtio_bus_get_vdev_features(&dev->bus,
143 dev->host_features);
144 s390_virtio_device_sync(dev);
145 s390_virtio_reset_idx(dev);
146 if (dev->qdev.hotplugged) {
147 S390CPU *cpu = s390_cpu_addr2state(0);
148 s390_virtio_irq(cpu, VIRTIO_PARAM_DEV_ADD0x2, dev->dev_offs);
149 }
150
151 return 0;
152}
153
154static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
155{
156 DeviceState *qdev = DEVICE(s390_dev)((DeviceState *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 156, __func__))
;
157 VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev)((VirtIONetS390 *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("virtio-net-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 157, __func__))
;
158 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 158, __func__))
;
159
160 virtio_net_set_config_size(&dev->vdev, s390_dev->host_features);
161 virtio_net_set_netclient_name(&dev->vdev, qdev->id,
162 object_get_typename(OBJECT(qdev)((Object *)(qdev))));
163 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 163, __func__))
);
164 if (qdev_init(vdev) < 0) {
165 return -1;
166 }
167
168 return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 168, __func__))
);
169}
170
171static void s390_virtio_net_instance_init(Object *obj)
172{
173 VirtIONetS390 *dev = VIRTIO_NET_S390(obj)((VirtIONetS390 *)object_dynamic_cast_assert(((Object *)((obj
))), ("virtio-net-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 173, __func__))
;
174 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET"virtio-net-device");
175 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
176}
177
178static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
179{
180 VirtIOBlkS390 *dev = VIRTIO_BLK_S390(s390_dev)((VirtIOBlkS390 *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("virtio-blk-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 180, __func__))
;
181 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 181, __func__))
;
182 virtio_blk_set_conf(vdev, &(dev->blk));
183 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 183, __func__))
);
184 if (qdev_init(vdev) < 0) {
185 return -1;
186 }
187 return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 187, __func__))
);
188}
189
190static void s390_virtio_blk_instance_init(Object *obj)
191{
192 VirtIOBlkS390 *dev = VIRTIO_BLK_S390(obj)((VirtIOBlkS390 *)object_dynamic_cast_assert(((Object *)((obj
))), ("virtio-blk-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 192, __func__))
;
193 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK"virtio-blk-device");
194 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
195}
196
197static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
198{
199 VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(s390_dev)((VirtIOSerialS390 *)object_dynamic_cast_assert(((Object *)((
s390_dev))), ("virtio-serial-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 199, __func__))
;
200 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 200, __func__))
;
201 DeviceState *qdev = DEVICE(s390_dev)((DeviceState *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 201, __func__))
;
202 VirtIOS390Bus *bus;
203 int r;
204 char *bus_name;
205
206 bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus)( __extension__ ( { char __attribute__((unused)) offset_must_be_zero
[ -__builtin_offsetof(VirtIOS390Bus, bus)]; ({ const typeof((
(VirtIOS390Bus *) 0)->bus) *__mptr = (qdev->parent_bus)
; (VirtIOS390Bus *) ((char *) __mptr - __builtin_offsetof(VirtIOS390Bus
, bus));});}))
;
207
208 /*
209 * For command line compatibility, this sets the virtio-serial-device bus
210 * name as before.
211 */
212 if (qdev->id) {
213 bus_name = g_strdup_printf("%s.0", qdev->id);
214 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 214, __func__))
, bus_name);
215 g_free(bus_name);
216 }
217
218 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 218, __func__))
);
219 if (qdev_init(vdev) < 0) {
220 return -1;
221 }
222
223 r = s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 223, __func__))
);
224 if (!r) {
225 bus->console = s390_dev;
226 }
227
228 return r;
229}
230
231static void s390_virtio_serial_instance_init(Object *obj)
232{
233 VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(obj)((VirtIOSerialS390 *)object_dynamic_cast_assert(((Object *)((
obj))), ("virtio-serial-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 233, __func__))
;
234 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL"virtio-serial-device");
235 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
236}
237
238static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
239{
240 VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(s390_dev)((VirtIOSCSIS390 *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("virtio-scsi-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 240, __func__))
;
241 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 241, __func__))
;
242 DeviceState *qdev = DEVICE(s390_dev)((DeviceState *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 242, __func__))
;
243 char *bus_name;
244
245 /*
246 * For command line compatibility, this sets the virtio-scsi-device bus
247 * name as before.
248 */
249 if (qdev->id) {
250 bus_name = g_strdup_printf("%s.0", qdev->id);
251 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 251, __func__))
, bus_name);
252 g_free(bus_name);
253 }
254
255 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 255, __func__))
);
256 if (qdev_init(vdev) < 0) {
257 return -1;
258 }
259
260 return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 260, __func__))
);
261}
262
263static void s390_virtio_scsi_instance_init(Object *obj)
264{
265 VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(obj)((VirtIOSCSIS390 *)object_dynamic_cast_assert(((Object *)((obj
))), ("virtio-scsi-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 265, __func__))
;
266 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI"virtio-scsi-device");
267 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
268}
269
270#ifdef CONFIG_VHOST_SCSI1
271static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev)
272{
273 VHostSCSIS390 *dev = VHOST_SCSI_S390(s390_dev)((VHostSCSIS390 *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("vhost-scsi-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 273, __func__))
;
274 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 274, __func__))
;
275
276 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 276, __func__))
);
277 if (qdev_init(vdev) < 0) {
278 return -1;
279 }
280
281 return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 281, __func__))
);
282}
283
284static void s390_vhost_scsi_instance_init(Object *obj)
285{
286 VHostSCSIS390 *dev = VHOST_SCSI_S390(obj)((VHostSCSIS390 *)object_dynamic_cast_assert(((Object *)((obj
))), ("vhost-scsi-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 286, __func__))
;
287 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI"vhost-scsi");
288 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
289}
290#endif
291
292
293static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
294{
295 VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev)((VirtIORNGS390 *)object_dynamic_cast_assert(((Object *)((s390_dev
))), ("virtio-rng-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 295, __func__))
;
296 DeviceState *vdev = DEVICE(&dev->vdev)((DeviceState *)object_dynamic_cast_assert(((Object *)((&
dev->vdev))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 296, __func__))
;
297
298 qdev_set_parent_bus(vdev, BUS(&s390_dev->bus)((BusState *)object_dynamic_cast_assert(((Object *)((&s390_dev
->bus))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 298, __func__))
);
299 if (qdev_init(vdev) < 0) {
300 return -1;
301 }
302
303 object_property_set_link(OBJECT(dev)((Object *)(dev)),
304 OBJECT(dev->vdev.conf.rng)((Object *)(dev->vdev.conf.rng)), "rng",
305 NULL((void*)0));
306
307 return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev)((VirtIODevice *)object_dynamic_cast_assert(((Object *)((vdev
))), ("virtio-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 307, __func__))
);
308}
309
310static void s390_virtio_rng_instance_init(Object *obj)
311{
312 VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj)((VirtIORNGS390 *)object_dynamic_cast_assert(((Object *)((obj
))), ("virtio-rng-s390"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 312, __func__))
;
313 object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG"virtio-rng-device");
314 object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev)((Object *)(&dev->vdev)), NULL((void*)0));
315 object_property_add_link(obj, "rng", TYPE_RNG_BACKEND"rng-backend",
316 (Object **)&dev->vdev.conf.rng, NULL((void*)0));
317}
318
319static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq)
320{
321 ram_addr_t token_off;
322
323 token_off = (dev->dev_offs + VIRTIO_DEV_OFFS_CONFIG5) +
324 (vq * VIRTIO_VQCONFIG_LEN24) +
325 VIRTIO_VQCONFIG_OFFS_TOKEN0;
326
327 return ldq_be_phys(token_off);
328}
329
330static ram_addr_t s390_virtio_device_num_vq(VirtIOS390Device *dev)
331{
332 VirtIODevice *vdev = dev->vdev;
333 int num_vq;
334
335 for (num_vq = 0; num_vq < VIRTIO_PCI_QUEUE_MAX64; num_vq++) {
336 if (!virtio_queue_get_num(vdev, num_vq)) {
337 break;
338 }
339 }
340
341 return num_vq;
342}
343
344static ram_addr_t s390_virtio_next_ring(VirtIOS390Bus *bus)
345{
346 ram_addr_t r = bus->next_ring;
347
348 bus->next_ring += VIRTIO_RING_LEN((1 << 12) * 3);
349 return r;
350}
351
352void s390_virtio_device_sync(VirtIOS390Device *dev)
353{
354 VirtIOS390Bus *bus = DO_UPCAST(VirtIOS390Bus, bus, dev->qdev.parent_bus)( __extension__ ( { char __attribute__((unused)) offset_must_be_zero
[ -__builtin_offsetof(VirtIOS390Bus, bus)]; ({ const typeof((
(VirtIOS390Bus *) 0)->bus) *__mptr = (dev->qdev.parent_bus
); (VirtIOS390Bus *) ((char *) __mptr - __builtin_offsetof(VirtIOS390Bus
, bus));});}))
;
355 ram_addr_t cur_offs;
356 uint8_t num_vq;
357 int i;
358
359 virtio_reset(dev->vdev);
360
361 /* Sync dev space */
362 stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_TYPE0, dev->vdev->device_id);
363
364 stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ1, s390_virtio_device_num_vq(dev));
365 stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_FEATURE_LEN2, dev->feat_len);
366
367 stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_CONFIG_LEN3, dev->vdev->config_len);
368
369 num_vq = s390_virtio_device_num_vq(dev);
370 stb_phys(dev->dev_offs + VIRTIO_DEV_OFFS_NUM_VQ1, num_vq);
371
372 /* Sync virtqueues */
373 for (i = 0; i < num_vq; i++) {
374 ram_addr_t vq = (dev->dev_offs + VIRTIO_DEV_OFFS_CONFIG5) +
375 (i * VIRTIO_VQCONFIG_LEN24);
376 ram_addr_t vring;
377
378 vring = s390_virtio_next_ring(bus);
379 virtio_queue_set_addr(dev->vdev, i, vring);
380 virtio_queue_set_vector(dev->vdev, i, i);
381 stq_be_phys(vq + VIRTIO_VQCONFIG_OFFS_ADDRESS8, vring);
382 stw_be_phys(vq + VIRTIO_VQCONFIG_OFFS_NUM16, virtio_queue_get_num(dev->vdev, i));
383 }
384
385 cur_offs = dev->dev_offs;
386 cur_offs += VIRTIO_DEV_OFFS_CONFIG5;
387 cur_offs += num_vq * VIRTIO_VQCONFIG_LEN24;
388
389 /* Sync feature bitmap */
390 stl_le_phys(cur_offs, dev->host_features);
391
392 dev->feat_offs = cur_offs + dev->feat_len;
393 cur_offs += dev->feat_len * 2;
394
395 /* Sync config space */
396 virtio_bus_get_vdev_config(&dev->bus, dev->vdev->config);
397
398 cpu_physical_memory_write(cur_offs,
399 dev->vdev->config, dev->vdev->config_len);
400 cur_offs += dev->vdev->config_len;
Value stored to 'cur_offs' is never read
401}
402
403void s390_virtio_device_update_status(VirtIOS390Device *dev)
404{
405 VirtIODevice *vdev = dev->vdev;
406 uint32_t features;
407
408 virtio_set_status(vdev, ldub_phys(dev->dev_offs + VIRTIO_DEV_OFFS_STATUS4));
409
410 /* Update guest supported feature bitmap */
411
412 features = bswap32(ldl_be_phys(dev->feat_offs));
413 virtio_set_features(vdev, features);
414}
415
416VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus)
417{
418 return bus->console;
419}
420
421/* Find a device by vring address */
422VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
423 ram_addr_t mem,
424 int *vq_num)
425{
426 BusChild *kid;
427 int i;
428
429 QTAILQ_FOREACH(kid, &bus->bus.children, sibling)for ((kid) = ((&bus->bus.children)->tqh_first); (kid
); (kid) = ((kid)->sibling.tqe_next))
{
430 VirtIOS390Device *dev = (VirtIOS390Device *)kid->child;
431
432 for(i = 0; i < VIRTIO_PCI_QUEUE_MAX64; i++) {
433 if (!virtio_queue_get_addr(dev->vdev, i))
434 break;
435 if (virtio_queue_get_addr(dev->vdev, i) == mem) {
436 if (vq_num) {
437 *vq_num = i;
438 }
439 return dev;
440 }
441 }
442 }
443
444 return NULL((void*)0);
445}
446
447/* Find a device by device descriptor location */
448VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem)
449{
450 BusChild *kid;
451
452 QTAILQ_FOREACH(kid, &bus->bus.children, sibling)for ((kid) = ((&bus->bus.children)->tqh_first); (kid
); (kid) = ((kid)->sibling.tqe_next))
{
453 VirtIOS390Device *dev = (VirtIOS390Device *)kid->child;
454 if (dev->dev_offs == mem) {
455 return dev;
456 }
457 }
458
459 return NULL((void*)0);
460}
461
462/* DeviceState to VirtIOS390Device. Note: used on datapath,
463 * be careful and test performance if you change this.
464 */
465static inline VirtIOS390Device *to_virtio_s390_device_fast(DeviceState *d)
466{
467 return container_of(d, VirtIOS390Device, qdev)({ const typeof(((VirtIOS390Device *) 0)->qdev) *__mptr = (
d); (VirtIOS390Device *) ((char *) __mptr - __builtin_offsetof
(VirtIOS390Device, qdev));})
;
468}
469
470/* DeviceState to VirtIOS390Device. TODO: use QOM. */
471static inline VirtIOS390Device *to_virtio_s390_device(DeviceState *d)
472{
473 return container_of(d, VirtIOS390Device, qdev)({ const typeof(((VirtIOS390Device *) 0)->qdev) *__mptr = (
d); (VirtIOS390Device *) ((char *) __mptr - __builtin_offsetof
(VirtIOS390Device, qdev));})
;
474}
475
476static void virtio_s390_notify(DeviceState *d, uint16_t vector)
477{
478 VirtIOS390Device *dev = to_virtio_s390_device_fast(d);
479 uint64_t token = s390_virtio_device_vq_token(dev, vector);
480 S390CPU *cpu = s390_cpu_addr2state(0);
481
482 s390_virtio_irq(cpu, 0, token);
483}
484
485static unsigned virtio_s390_get_features(DeviceState *d)
486{
487 VirtIOS390Device *dev = to_virtio_s390_device(d);
488 return dev->host_features;
489}
490
491/**************** S390 Virtio Bus Device Descriptions *******************/
492
493static Property s390_virtio_net_properties[] = {
494 DEFINE_NIC_PROPERTIES(VirtIONetS390, vdev.nic_conf){ .name = ("mac"), .info = &(qdev_prop_macaddr), .offset =
__builtin_offsetof(VirtIONetS390, vdev.nic_conf.macaddr) + (
(MACAddr*)0 - (typeof(((VirtIONetS390 *)0)->vdev.nic_conf.
macaddr)*)0), }, { .name = ("vlan"), .info = &(qdev_prop_vlan
), .offset = __builtin_offsetof(VirtIONetS390, vdev.nic_conf.
peers) + ((NICPeers*)0 - (typeof(((VirtIONetS390 *)0)->vdev
.nic_conf.peers)*)0), }, { .name = ("netdev"), .info = &(
qdev_prop_netdev), .offset = __builtin_offsetof(VirtIONetS390
, vdev.nic_conf.peers) + ((NICPeers*)0 - (typeof(((VirtIONetS390
*)0)->vdev.nic_conf.peers)*)0), }, { .name = ("bootindex"
), .info = &(qdev_prop_int32), .offset = __builtin_offsetof
(VirtIONetS390, vdev.nic_conf.bootindex) + ((int32_t*)0 - (typeof
(((VirtIONetS390 *)0)->vdev.nic_conf.bootindex)*)0), .qtype
= QTYPE_QINT, .defval = (int32_t)-1, }
,
495 DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device, host_features){ .name = ("indirect_desc"), .info = &(qdev_prop_bit), .bitnr
= (28), .offset = __builtin_offsetof(VirtIOS390Device, host_features
) + ((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("event_idx"), .info = &(qdev_prop_bit), .bitnr = (29), .
offset = __builtin_offsetof(VirtIOS390Device, host_features) +
((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("any_layout"), .info = &(qdev_prop_bit), .bitnr = (27),
.offset = __builtin_offsetof(VirtIOS390Device, host_features
) + ((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("csum"), .info = &(qdev_prop_bit), .bitnr = (0), .offset
= __builtin_offsetof(VirtIOS390Device, host_features) + ((uint32_t
*)0 - (typeof(((VirtIOS390Device *)0)->host_features)*)0),
.qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name = ("guest_csum"
), .info = &(qdev_prop_bit), .bitnr = (1), .offset = __builtin_offsetof
(VirtIOS390Device, host_features) + ((uint32_t*)0 - (typeof((
(VirtIOS390Device *)0)->host_features)*)0), .qtype = QTYPE_QBOOL
, .defval = (_Bool)1, }, { .name = ("gso"), .info = &(qdev_prop_bit
), .bitnr = (6), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("guest_tso4"), .info = &(qdev_prop_bit
), .bitnr = (7), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("guest_tso6"), .info = &(qdev_prop_bit
), .bitnr = (8), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("guest_ecn"), .info = &(qdev_prop_bit
), .bitnr = (9), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("guest_ufo"), .info = &(qdev_prop_bit
), .bitnr = (10), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("host_tso4"), .info = &(qdev_prop_bit
), .bitnr = (11), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("host_tso6"), .info = &(qdev_prop_bit
), .bitnr = (12), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("host_ecn"), .info = &(qdev_prop_bit
), .bitnr = (13), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("host_ufo"), .info = &(qdev_prop_bit
), .bitnr = (14), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("mrg_rxbuf"), .info = &(qdev_prop_bit
), .bitnr = (15), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("status"), .info = &(qdev_prop_bit
), .bitnr = (16), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_vq"), .info = &(qdev_prop_bit
), .bitnr = (17), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_rx"), .info = &(qdev_prop_bit
), .bitnr = (18), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_vlan"), .info = &(qdev_prop_bit
), .bitnr = (19), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_rx_extra"), .info = &(qdev_prop_bit
), .bitnr = (20), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_mac_addr"), .info = &(qdev_prop_bit
), .bitnr = (23), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("ctrl_guest_offloads"), .info = &
(qdev_prop_bit), .bitnr = (2), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)1, }, { .name = ("mq"), .info = &(qdev_prop_bit),
.bitnr = (22), .offset = __builtin_offsetof(VirtIOS390Device
, host_features) + ((uint32_t*)0 - (typeof(((VirtIOS390Device
*)0)->host_features)*)0), .qtype = QTYPE_QBOOL, .defval =
(_Bool)0, }
,
496 DEFINE_VIRTIO_NET_PROPERTIES(VirtIONetS390, vdev.net_conf){ .name = ("x-txtimer"), .info = &(qdev_prop_uint32), .offset
= __builtin_offsetof(VirtIONetS390, vdev.net_conf.txtimer) +
((uint32_t*)0 - (typeof(((VirtIONetS390 *)0)->vdev.net_conf
.txtimer)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)150000
, }, { .name = ("x-txburst"), .info = &(qdev_prop_int32),
.offset = __builtin_offsetof(VirtIONetS390, vdev.net_conf.txburst
) + ((int32_t*)0 - (typeof(((VirtIONetS390 *)0)->vdev.net_conf
.txburst)*)0), .qtype = QTYPE_QINT, .defval = (int32_t)256, }
, { .name = ("tx"), .info = &(qdev_prop_string), .offset =
__builtin_offsetof(VirtIONetS390, vdev.net_conf.tx) + ((char
**)0 - (typeof(((VirtIONetS390 *)0)->vdev.net_conf.tx)*)0)
, }
,
497 DEFINE_PROP_END_OF_LIST(){},
498};
499
500static void s390_virtio_net_class_init(ObjectClass *klass, void *data)
501{
502 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 502, __func__))
;
503 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 503, __func__))
;
504
505 k->init = s390_virtio_net_init;
506 dc->props = s390_virtio_net_properties;
507}
508
509static const TypeInfo s390_virtio_net = {
510 .name = TYPE_VIRTIO_NET_S390"virtio-net-s390",
511 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
512 .instance_size = sizeof(VirtIONetS390),
513 .instance_init = s390_virtio_net_instance_init,
514 .class_init = s390_virtio_net_class_init,
515};
516
517static Property s390_virtio_blk_properties[] = {
518 DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOBlkS390, blk){ .name = ("drive"), .info = &(qdev_prop_drive), .offset =
__builtin_offsetof(VirtIOBlkS390, blk.conf.bs) + ((BlockDriverState
**)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf.bs)*)0), },
{ .name = ("logical_block_size"), .info = &(qdev_prop_blocksize
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.logical_block_size
) + ((uint16_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf
.logical_block_size)*)0), .qtype = QTYPE_QINT, .defval = (uint16_t
)512, }, { .name = ("physical_block_size"), .info = &(qdev_prop_blocksize
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.physical_block_size
) + ((uint16_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf
.physical_block_size)*)0), .qtype = QTYPE_QINT, .defval = (uint16_t
)512, }, { .name = ("min_io_size"), .info = &(qdev_prop_uint16
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.min_io_size
) + ((uint16_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf
.min_io_size)*)0), .qtype = QTYPE_QINT, .defval = (uint16_t)0
, }, { .name = ("opt_io_size"), .info = &(qdev_prop_uint32
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.opt_io_size
) + ((uint32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf
.opt_io_size)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)0
, }, { .name = ("bootindex"), .info = &(qdev_prop_int32),
.offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.bootindex
) + ((int32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf.
bootindex)*)0), .qtype = QTYPE_QINT, .defval = (int32_t)-1, }
, { .name = ("discard_granularity"), .info = &(qdev_prop_uint32
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.discard_granularity
) + ((uint32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf
.discard_granularity)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t
)-1, }, { .name = ("cyls"), .info = &(qdev_prop_uint32), .
offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.cyls) + (
(uint32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf.cyls
)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)0, }, { .name
= ("heads"), .info = &(qdev_prop_uint32), .offset = __builtin_offsetof
(VirtIOBlkS390, blk.conf.heads) + ((uint32_t*)0 - (typeof(((VirtIOBlkS390
*)0)->blk.conf.heads)*)0), .qtype = QTYPE_QINT, .defval =
(uint32_t)0, }, { .name = ("secs"), .info = &(qdev_prop_uint32
), .offset = __builtin_offsetof(VirtIOBlkS390, blk.conf.secs)
+ ((uint32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.conf.
secs)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)0, }, { .
name = ("serial"), .info = &(qdev_prop_string), .offset =
__builtin_offsetof(VirtIOBlkS390, blk.serial) + ((char**)0 -
(typeof(((VirtIOBlkS390 *)0)->blk.serial)*)0), }, { .name
= ("config-wce"), .info = &(qdev_prop_bit), .bitnr = (0)
, .offset = __builtin_offsetof(VirtIOBlkS390, blk.config_wce)
+ ((uint32_t*)0 - (typeof(((VirtIOBlkS390 *)0)->blk.config_wce
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("scsi"), .info = &(qdev_prop_bit), .bitnr = (0), .offset
= __builtin_offsetof(VirtIOBlkS390, blk.scsi) + ((uint32_t*)
0 - (typeof(((VirtIOBlkS390 *)0)->blk.scsi)*)0), .qtype = QTYPE_QBOOL
, .defval = (_Bool)1, }
,
519 DEFINE_PROP_END_OF_LIST(){},
520};
521
522static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
523{
524 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 524, __func__))
;
525 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 525, __func__))
;
526
527 k->init = s390_virtio_blk_init;
528 dc->props = s390_virtio_blk_properties;
529}
530
531static const TypeInfo s390_virtio_blk = {
532 .name = "virtio-blk-s390",
533 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
534 .instance_size = sizeof(VirtIOBlkS390),
535 .instance_init = s390_virtio_blk_instance_init,
536 .class_init = s390_virtio_blk_class_init,
537};
538
539static Property s390_virtio_serial_properties[] = {
540 DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOSerialS390, vdev.serial){ .name = ("max_ports"), .info = &(qdev_prop_uint32), .offset
= __builtin_offsetof(VirtIOSerialS390, vdev.serial.max_virtserial_ports
) + ((uint32_t*)0 - (typeof(((VirtIOSerialS390 *)0)->vdev.
serial.max_virtserial_ports)*)0), .qtype = QTYPE_QINT, .defval
= (uint32_t)31, }
,
541 DEFINE_PROP_END_OF_LIST(){},
542};
543
544static void s390_virtio_serial_class_init(ObjectClass *klass, void *data)
545{
546 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 546, __func__))
;
547 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 547, __func__))
;
548
549 k->init = s390_virtio_serial_init;
550 dc->props = s390_virtio_serial_properties;
551}
552
553static const TypeInfo s390_virtio_serial = {
554 .name = TYPE_VIRTIO_SERIAL_S390"virtio-serial-s390",
555 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
556 .instance_size = sizeof(VirtIOSerialS390),
557 .instance_init = s390_virtio_serial_instance_init,
558 .class_init = s390_virtio_serial_class_init,
559};
560
561static Property s390_virtio_rng_properties[] = {
562 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features){ .name = ("indirect_desc"), .info = &(qdev_prop_bit), .bitnr
= (28), .offset = __builtin_offsetof(VirtIOS390Device, host_features
) + ((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("event_idx"), .info = &(qdev_prop_bit), .bitnr = (29), .
offset = __builtin_offsetof(VirtIOS390Device, host_features) +
((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }
,
563 DEFINE_VIRTIO_RNG_PROPERTIES(VirtIORNGS390, vdev.conf){ .name = ("max-bytes"), .info = &(qdev_prop_uint64), .offset
= __builtin_offsetof(VirtIORNGS390, vdev.conf.max_bytes) + (
(uint64_t*)0 - (typeof(((VirtIORNGS390 *)0)->vdev.conf.max_bytes
)*)0), .qtype = QTYPE_QINT, .defval = (uint64_t)(9223372036854775807L
), }, { .name = ("period"), .info = &(qdev_prop_uint32), .
offset = __builtin_offsetof(VirtIORNGS390, vdev.conf.period_ms
) + ((uint32_t*)0 - (typeof(((VirtIORNGS390 *)0)->vdev.conf
.period_ms)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)1 <<
16, }
,
564 DEFINE_PROP_END_OF_LIST(){},
565};
566
567static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
568{
569 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 569, __func__))
;
570 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 570, __func__))
;
571
572 k->init = s390_virtio_rng_init;
573 dc->props = s390_virtio_rng_properties;
574}
575
576static const TypeInfo s390_virtio_rng = {
577 .name = TYPE_VIRTIO_RNG_S390"virtio-rng-s390",
578 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
579 .instance_size = sizeof(VirtIORNGS390),
580 .instance_init = s390_virtio_rng_instance_init,
581 .class_init = s390_virtio_rng_class_init,
582};
583
584static int s390_virtio_busdev_init(DeviceState *dev)
585{
586 VirtIOS390Device *_dev = (VirtIOS390Device *)dev;
587 VirtIOS390DeviceClass *_info = VIRTIO_S390_DEVICE_GET_CLASS(dev)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)(object_get_class(((Object *)((dev)))))), ("virtio-s390-device"
), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 587, __func__))
;
588
589 virtio_s390_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
590
591 return _info->init(_dev);
592}
593
594static void s390_virtio_busdev_reset(DeviceState *dev)
595{
596 VirtIOS390Device *_dev = (VirtIOS390Device *)dev;
597
598 virtio_reset(_dev->vdev);
599}
600
601static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
602{
603 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 603, __func__))
;
604
605 dc->init = s390_virtio_busdev_init;
606 dc->bus_type = TYPE_S390_VIRTIO_BUS"s390-virtio-bus";
607 dc->unplug = qdev_simple_unplug_cb;
608 dc->reset = s390_virtio_busdev_reset;
609}
610
611static const TypeInfo virtio_s390_device_info = {
612 .name = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
613 .parent = TYPE_DEVICE"device",
614 .instance_size = sizeof(VirtIOS390Device),
615 .class_init = virtio_s390_device_class_init,
616 .class_size = sizeof(VirtIOS390DeviceClass),
617 .abstract = true1,
618};
619
620static Property s390_virtio_scsi_properties[] = {
621 DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSIS390, vdev.parent_obj.conf){ .name = ("num_queues"), .info = &(qdev_prop_uint32), .offset
= __builtin_offsetof(VirtIOSCSIS390, vdev.parent_obj.conf.num_queues
) + ((uint32_t*)0 - (typeof(((VirtIOSCSIS390 *)0)->vdev.parent_obj
.conf.num_queues)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t
)1, }, { .name = ("max_sectors"), .info = &(qdev_prop_uint32
), .offset = __builtin_offsetof(VirtIOSCSIS390, vdev.parent_obj
.conf.max_sectors) + ((uint32_t*)0 - (typeof(((VirtIOSCSIS390
*)0)->vdev.parent_obj.conf.max_sectors)*)0), .qtype = QTYPE_QINT
, .defval = (uint32_t)0xFFFF, }, { .name = ("cmd_per_lun"), .
info = &(qdev_prop_uint32), .offset = __builtin_offsetof(
VirtIOSCSIS390, vdev.parent_obj.conf.cmd_per_lun) + ((uint32_t
*)0 - (typeof(((VirtIOSCSIS390 *)0)->vdev.parent_obj.conf.
cmd_per_lun)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)128
, }
,
622 DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features){ .name = ("indirect_desc"), .info = &(qdev_prop_bit), .bitnr
= (28), .offset = __builtin_offsetof(VirtIOS390Device, host_features
) + ((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("event_idx"), .info = &(qdev_prop_bit), .bitnr = (29), .
offset = __builtin_offsetof(VirtIOS390Device, host_features) +
((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("hotplug"), .info = &(qdev_prop_bit), .bitnr = (1), .offset
= __builtin_offsetof(VirtIOS390Device, host_features) + ((uint32_t
*)0 - (typeof(((VirtIOS390Device *)0)->host_features)*)0),
.qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name = ("param_change"
), .info = &(qdev_prop_bit), .bitnr = (2), .offset = __builtin_offsetof
(VirtIOS390Device, host_features) + ((uint32_t*)0 - (typeof((
(VirtIOS390Device *)0)->host_features)*)0), .qtype = QTYPE_QBOOL
, .defval = (_Bool)1, }
,
623 DEFINE_PROP_END_OF_LIST(){},
624};
625
626static void s390_virtio_scsi_class_init(ObjectClass *klass, void *data)
627{
628 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 628, __func__))
;
629 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 629, __func__))
;
630
631 k->init = s390_virtio_scsi_init;
632 dc->props = s390_virtio_scsi_properties;
633}
634
635static const TypeInfo s390_virtio_scsi = {
636 .name = TYPE_VIRTIO_SCSI_S390"virtio-scsi-s390",
637 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
638 .instance_size = sizeof(VirtIOSCSIS390),
639 .instance_init = s390_virtio_scsi_instance_init,
640 .class_init = s390_virtio_scsi_class_init,
641};
642
643#ifdef CONFIG_VHOST_SCSI1
644static Property s390_vhost_scsi_properties[] = {
645 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features){ .name = ("indirect_desc"), .info = &(qdev_prop_bit), .bitnr
= (28), .offset = __builtin_offsetof(VirtIOS390Device, host_features
) + ((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }, { .name =
("event_idx"), .info = &(qdev_prop_bit), .bitnr = (29), .
offset = __builtin_offsetof(VirtIOS390Device, host_features) +
((uint32_t*)0 - (typeof(((VirtIOS390Device *)0)->host_features
)*)0), .qtype = QTYPE_QBOOL, .defval = (_Bool)1, }
,
646 DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIS390, vdev.parent_obj.conf){ .name = ("vhostfd"), .info = &(qdev_prop_string), .offset
= __builtin_offsetof(VHostSCSIS390, vdev.parent_obj.conf.vhostfd
) + ((char**)0 - (typeof(((VHostSCSIS390 *)0)->vdev.parent_obj
.conf.vhostfd)*)0), }, { .name = ("wwpn"), .info = &(qdev_prop_string
), .offset = __builtin_offsetof(VHostSCSIS390, vdev.parent_obj
.conf.wwpn) + ((char**)0 - (typeof(((VHostSCSIS390 *)0)->vdev
.parent_obj.conf.wwpn)*)0), }, { .name = ("num_queues"), .info
= &(qdev_prop_uint32), .offset = __builtin_offsetof(VHostSCSIS390
, vdev.parent_obj.conf.num_queues) + ((uint32_t*)0 - (typeof(
((VHostSCSIS390 *)0)->vdev.parent_obj.conf.num_queues)*)0)
, .qtype = QTYPE_QINT, .defval = (uint32_t)1, }, { .name = ("max_sectors"
), .info = &(qdev_prop_uint32), .offset = __builtin_offsetof
(VHostSCSIS390, vdev.parent_obj.conf.max_sectors) + ((uint32_t
*)0 - (typeof(((VHostSCSIS390 *)0)->vdev.parent_obj.conf.max_sectors
)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t)0xFFFF, }, { .
name = ("cmd_per_lun"), .info = &(qdev_prop_uint32), .offset
= __builtin_offsetof(VHostSCSIS390, vdev.parent_obj.conf.cmd_per_lun
) + ((uint32_t*)0 - (typeof(((VHostSCSIS390 *)0)->vdev.parent_obj
.conf.cmd_per_lun)*)0), .qtype = QTYPE_QINT, .defval = (uint32_t
)128, }
,
647 DEFINE_PROP_END_OF_LIST(){},
648};
649
650static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
651{
652 DeviceClass *dc = DEVICE_CLASS(klass)((DeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 652, __func__))
;
653 VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass)((VirtIOS390DeviceClass *)object_class_dynamic_cast_assert(((
ObjectClass *)((klass))), ("virtio-s390-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 653, __func__))
;
654
655 k->init = s390_vhost_scsi_init;
656 dc->props = s390_vhost_scsi_properties;
657}
658
659static const TypeInfo s390_vhost_scsi = {
660 .name = TYPE_VHOST_SCSI_S390"vhost-scsi-s390",
661 .parent = TYPE_VIRTIO_S390_DEVICE"virtio-s390-device",
662 .instance_size = sizeof(VHostSCSIS390),
663 .instance_init = s390_vhost_scsi_instance_init,
664 .class_init = s390_vhost_scsi_class_init,
665};
666#endif
667
668/***************** S390 Virtio Bus Bridge Device *******************/
669/* Only required to have the virtio bus as child in the system bus */
670
671static int s390_virtio_bridge_init(SysBusDevice *dev)
672{
673 /* nothing */
674 return 0;
675}
676
677static void s390_virtio_bridge_class_init(ObjectClass *klass, void *data)
678{
679 SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass)((SysBusDeviceClass *)object_class_dynamic_cast_assert(((ObjectClass
*)((klass))), ("sys-bus-device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 679, __func__))
;
680
681 k->init = s390_virtio_bridge_init;
682}
683
684static const TypeInfo s390_virtio_bridge_info = {
685 .name = "s390-virtio-bridge",
686 .parent = TYPE_SYS_BUS_DEVICE"sys-bus-device",
687 .instance_size = sizeof(SysBusDevice),
688 .class_init = s390_virtio_bridge_class_init,
689};
690
691/* virtio-s390-bus */
692
693static void virtio_s390_bus_new(VirtioBusState *bus, size_t bus_size,
694 VirtIOS390Device *dev)
695{
696 DeviceState *qdev = DEVICE(dev)((DeviceState *)object_dynamic_cast_assert(((Object *)((dev))
), ("device"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 696, __func__))
;
697 BusState *qbus;
698 char virtio_bus_name[] = "virtio-bus";
699
700 qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_S390_BUS"virtio-s390-bus",
701 qdev, virtio_bus_name);
702 qbus = BUS(bus)((BusState *)object_dynamic_cast_assert(((Object *)((bus))), (
"bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 702, __func__))
;
703 qbus->allow_hotplug = 1;
704}
705
706static void virtio_s390_bus_class_init(ObjectClass *klass, void *data)
707{
708 VirtioBusClass *k = VIRTIO_BUS_CLASS(klass)((VirtioBusClass *)object_class_dynamic_cast_assert(((ObjectClass
*)(klass)), ("virtio-bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 708, __func__))
;
709 BusClass *bus_class = BUS_CLASS(klass)((BusClass *)object_class_dynamic_cast_assert(((ObjectClass *
)((klass))), ("bus"), "/home/stefan/src/qemu/qemu.org/qemu/hw/s390x/s390-virtio-bus.c"
, 709, __func__))
;
710 bus_class->max_dev = 1;
711 k->notify = virtio_s390_notify;
712 k->get_features = virtio_s390_get_features;
713}
714
715static const TypeInfo virtio_s390_bus_info = {
716 .name = TYPE_VIRTIO_S390_BUS"virtio-s390-bus",
717 .parent = TYPE_VIRTIO_BUS"virtio-bus",
718 .instance_size = sizeof(VirtioS390BusState),
719 .class_init = virtio_s390_bus_class_init,
720};
721
722static void s390_virtio_register_types(void)
723{
724 type_register_static(&virtio_s390_bus_info);
725 type_register_static(&s390_virtio_bus_info);
726 type_register_static(&virtio_s390_device_info);
727 type_register_static(&s390_virtio_serial);
728 type_register_static(&s390_virtio_blk);
729 type_register_static(&s390_virtio_net);
730 type_register_static(&s390_virtio_scsi);
731#ifdef CONFIG_VHOST_SCSI1
732 type_register_static(&s390_vhost_scsi);
733#endif
734 type_register_static(&s390_virtio_rng);
735 type_register_static(&s390_virtio_bridge_info);
736}
737
738type_init(s390_virtio_register_types)static void __attribute__((constructor)) do_qemu_init_s390_virtio_register_types
(void) { register_module_init(s390_virtio_register_types, MODULE_INIT_QOM
); }