17 #include <linux/virtio.h>
18 #include <linux/virtio_config.h>
19 #include <linux/slab.h>
20 #include <linux/virtio_console.h>
22 #include <linux/virtio_ring.h>
23 #include <linux/export.h>
26 #include <asm/kvm_para.h>
29 #include <asm/setup.h>
32 #define VIRTIO_SUBCODE_64 0x0D00
37 static void *kvm_devices;
45 #define to_kvmdev(vd) container_of(vd, struct kvm_device, vdev)
63 return (
u8 *)(kvm_vq_config(desc) + desc->
num_vq);
68 return kvm_vq_features(desc) + desc->
feature_len * 2;
78 + desc->feature_len * 2
88 u8 *in_features = kvm_vq_features(desc);
91 if (in_features[i / 8] & (1 << (i % 8)))
101 u8 *out_features = kvm_vq_features(desc) + desc->
feature_len;
108 for (i = 0; i <
bits; i++) {
110 out_features[i / 8] |= (1 << (i % 8));
118 void *
buf,
unsigned len)
123 memcpy(buf, kvm_vq_configspace(desc) + offset, len);
126 static void kvm_set(
struct virtio_device *vdev,
unsigned int offset,
127 const void *buf,
unsigned len)
132 memcpy(kvm_vq_configspace(desc) + offset, buf, len);
169 static void kvm_notify(
struct virtqueue *vq)
190 if (index >= kdev->
desc->num_vq)
196 config = kvm_vq_config(kdev->
desc)+
index;
199 vring_size(config->
num,
205 vdev,
true, (
void *) config->
address,
222 vring_size(config->
num,
228 static void kvm_del_vq(
struct virtqueue *vq)
234 vring_size(config->
num,
255 if (nvqs > kdev->
desc->num_vq)
258 for (i = 0; i < nvqs; ++
i) {
259 vqs[
i] = kvm_find_vq(vdev, i, callbacks[i], names[i]);
267 return PTR_ERR(vqs[i]);
279 .get_features = kvm_get_features,
280 .finalize_features = kvm_finalize_features,
283 .get_status = kvm_get_status,
284 .set_status = kvm_set_status,
286 .find_vqs = kvm_find_vqs,
287 .del_vqs = kvm_del_vqs,
288 .bus_name = kvm_bus_name,
295 static struct device *kvm_root;
312 kdev->
vdev.dev.parent = kvm_root;
314 kdev->
vdev.config = &kvm_vq_configspace_ops;
328 static void scan_devices(
void)
333 for (i = 0; i <
PAGE_SIZE; i += desc_size(d)) {
339 add_kvm_device(d, i);
363 for (i = 0; i <
PAGE_SIZE; i += desc_size(d)) {
380 add_kvm_device(d, i);
388 unsigned int param32,
unsigned long param64)
428 static int __init kvm_devices_init(
void)
436 if (IS_ERR(kvm_root)) {
437 rc = PTR_ERR(kvm_root);
450 INIT_WORK(&hotplug_work, hotplug_devices);
460 static __init int early_put_chars(
u32 vtermno,
const char *buf,
int count)
463 unsigned int len =
count;
465 if (len >
sizeof(scratch) - 1)
468 memcpy(scratch, buf, len);
473 static int __init s390_virtio_console_init(
void)