summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1Michael S. Tsirkin2014-12-091-0/+7
| | | | | | | | | | | What does it mean if rev 1 device does not set VIRTIO_F_VERSION_1? E.g. is it native endian? Let's not even try to drive such devices: fail attempts to finalize features. virtio core will detect this and bail out. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: allow finalize_features to failMichael S. Tsirkin2014-12-099-16/+38
| | | | | | | This will make it easy for transports to validate features and return failure. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_ccw: legacy: don't negotiate rev 1/featuresMichael S. Tsirkin2014-12-091-3/+13
| | | | | | | | | | | | | Legacy balloon device doesn't pretend to support revision 1 or 64 bit features. But just in case someone implements a broken one that does, let's not even try to drive legacy only devices using revision 1, and let's not give them a chance to say they support VIRTIO_F_VERSION_1 by not reading or writing high feature bits. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: add API to detect legacy devicesMichael S. Tsirkin2014-12-092-0/+9
| | | | | | | | | | | | | | | transports need to be able to detect legacy-only devices (ATM balloon only) to use legacy path to drive them. Add a core API to do just that. The implementation just blacklists balloon: not too pretty, but let's not over-engineer. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio_console: fix sparse warningsMichael S. Tsirkin2014-12-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | CHECK drivers/char/virtio_console.c drivers/char/virtio_console.c:687:36: warning: incorrect type in argument 1 (different address spaces) drivers/char/virtio_console.c:687:36: expected void [noderef] <asn:1>*to drivers/char/virtio_console.c:687:36: got char *out_buf drivers/char/virtio_console.c:790:35: warning: incorrect type in argument 2 (different address spaces) drivers/char/virtio_console.c:790:35: expected char *out_buf drivers/char/virtio_console.c:790:35: got char [noderef] <asn:1>*ubuf fill_readbuf is reused with both kernel and userspace pointers, depending on value of to_user flag. Tag address parameter as __user, and cast to/from regular pointer type when we know it's safe. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: remove unnecessary forward declarations in vhost.hJason Wang2014-12-091-4/+0
| | | | | | | | | | Signed-off-by: Jason Wang <jasowang@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: drop VIRTIO_F_VERSION_1 from driversMichael S. Tsirkin2014-12-094-4/+0
| | | | | | | | | | | Core activates this bit automatically now, drop it from drivers that set it explicitly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: make VIRTIO_F_VERSION_1 a transport bitMichael S. Tsirkin2014-12-093-3/+9
| | | | | | | | | | | Activate VIRTIO_F_VERSION_1 automatically unless legacy_only is set. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_balloon: add legacy_only flagMichael S. Tsirkin2014-12-092-0/+3
| | | | | | | | | | | | | We have no plans to support virtio 1.0 in balloon driver. Add an explicit flag to mark it legacy only. This will be used by follow-up patches. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_console: virtio 1.0 supportMichael S. Tsirkin2014-12-092-15/+21
| | | | | | | | | | Pretty straight-forward, just use accessors for all fields. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* af_packet: virtio 1.0 stubsMichael S. Tsirkin2014-12-091-13/+22
| | | | | | | | | | | | | | This merely fixes sparse warnings, without actually adding support for the new APIs. Still working out the best way to enable the new functionality. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost/scsi: partial virtio 1.0 supportMichael S. Tsirkin2014-12-091-10/+12
| | | | | | | | | | | | | Include all endian conversions as required by virtio 1.0. Don't set virtio 1.0 yet, since that requires ANY_LAYOUT which we don't yet support. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio_scsi: export to userspaceMichael S. Tsirkin2014-12-092-37/+38
| | | | | | | | | | | | Replace uXX by __uXX and _packed by __attribute((packed)) as seems to be the norm for userspace headers. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio_scsi: move to uapiMichael S. Tsirkin2014-12-091-0/+0
| | | | | | | | | | | | | Guests need to use virtio scsi API, so export it to uapi, nice to e.g. qemu and will help us remember this file affects ABI. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
* virtio_scsi: v1.0 supportMichael S. Tsirkin2014-12-092-34/+49
| | | | | | | | | | | | | Note: for consistency, and to avoid sparse errors, convert all fields, even those no longer in use for virtio v1.0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
* macvtap: TUN_VNET_LE supportMichael S. Tsirkin2014-12-091-25/+43
| | | | | | | | | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* tun: TUN_VNET_LE support, fix sparse warnings for virtio headersMichael S. Tsirkin2014-12-091-19/+29
| | | | | | | | | | | | Pretty straight-forward: convert all fields to/from virtio endian-ness. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* tun: add VNET_LE flagMichael S. Tsirkin2014-12-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | virtio 1.0 modified virtio net header format, making all fields little endian. Users can tweak header format before submitting it to tun, but this means more data copies where none were necessary. And if the iovec is in RO memory, this means we might need to split iovec also means we might in theory overflow iovec max size. This patch adds a simpler way for applications to handle this, using new "little endian" flag in tun. As a result, tun simply byte-swaps header fields as appropriate. This is a NOP on LE architectures. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* tun: drop most type definesMichael S. Tsirkin2014-12-091-34/+28
| | | | | | | | | | | It's just as easy to use IFF_ flags directly, there's no point in adding our own defines. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* tun: move internal flag defines out of uapiMichael S. Tsirkin2014-12-092-64/+24
| | | | | | | | | | | | | | | | | TUN_ flags are internal and never exposed to userspace. Any application using it is almost certainly buggy. Move them out to tun.c. Note: we remove these completely in follow-up patches, this code movement is split out for ease of review. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost/net: enable virtio 1.0Michael S. Tsirkin2014-12-091-1/+2
| | | | | | | | Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost/net: larger header for virtio 1.0Michael S. Tsirkin2014-12-091-1/+2
| | | | | | | | | | Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* vhost/net: virtio 1.0 byte swapMichael S. Tsirkin2014-12-091-5/+10
| | | | | | | | | | | | | I had to add an explicit tag to suppress compiler warning: gcc isn't smart enough to notice that len is always initialized since function is called with size > 0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* vhost: virtio 1.0 endian-ness supportMichael S. Tsirkin2014-12-091-37/+49
| | | | | | | | Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost: switch to __get/__put_user exclusivelyMichael S. Tsirkin2014-12-091-3/+10
| | | | | | | | | | | | | | | | | Most places in vhost can use __get/__put_user rather than get/put_user since addresses are pre-validated. This should be good for performance, but this also will help make code sparse-clean: get/put_user macros don't play well with __virtioXX bitwise tags. Switch to get/put_user to __ variants everywhere in vhost. There's one exception - for consistency switch that as well, and add an explicit access_ok check. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* vhost/net: force len for TX to host endianMichael S. Tsirkin2014-12-091-5/+5
| | | | | | | | | | | | | | | vhost/net keeps a copy of the used ring in host memory but (ab)uses the length field for internal house-keeping. This works because the length in the used ring for tx is always 0. In order to suppress sparse warnings, we force native endianness here. Note that these values are never exposed to guests. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* vhost: add memory access wrappersMichael S. Tsirkin2014-12-091-0/+31
| | | | | | | | | | | | | Add guest memory access wrappers to handle virtio endianness conversions. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* vhost: make features 64 bitMichael S. Tsirkin2014-12-091-3/+3
| | | | | | | | | | | | | | We need to use bit 32 for virtio 1.0. Make vhost_has_feature bool to avoid discarding high bits. Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* virtio_net: enable v1.0 supportMichael S. Tsirkin2014-12-091-0/+1
| | | | | | | | | | Now that we have completed 1.0 support, enable it in our driver. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_net: disable mac write for virtio 1.0Michael S. Tsirkin2014-12-091-1/+2
| | | | | | | | | | | | | | The spec states that mac in config space is only driver-writable in the legacy case. Fence writing it in virtnet_set_mac_address() in the virtio 1.0 case. Suggested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio_net: bigger header when VERSION_1 is setMichael S. Tsirkin2014-12-091-1/+2
| | | | | | | | | | | | | With VERSION_1 virtio_net uses same header size whether mergeable buffers are enabled or not. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* virtio_net: stricter short buffer length checksMichael S. Tsirkin2014-12-091-1/+1
| | | | | | | | | | | | | | | | Our buffer length check is not strict enough for mergeable buffers: buffer can still be shorter that header + address by 2 bytes. Fix that up. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* virtio_net: get rid of virtio_net_hdr/skb_vnet_hdrMichael S. Tsirkin2014-12-091-49/+41
| | | | | | | | | | | | | | | | | | virtio 1.0 doesn't use virtio_net_hdr anymore, and in fact, it's not really useful since virtio_net_hdr_mrg_rxbuf includes that as the first field anyway. Let's drop it, precalculate header len and store within vi instead. This way we can also remove struct skb_vnet_hdr. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Jason Wang <jasowang@redhat.com>
* virtio_net: pass vi aroundMichael S. Tsirkin2014-12-091-18/+20
| | | | | | | | | | | | | Too many places poke at [rs]q->vq->vdev->priv just to get the vi structure. Let's just pass the pointer around: seems cleaner, and might even be faster. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio_blk: fix race at module removalMichael S. Tsirkin2014-12-091-1/+1
| | | | | | | | | | | | | | | | If a device appears while module is being removed, driver will get a callback after we've given up on the major number. In theory this means this major number can get reused by something else, resulting in a conflict. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio_blk: make serial attribute staticMichael S. Tsirkin2014-12-091-1/+2
| | | | | | | | | | | It's never declared so no need to make it extern. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* KVM: s390: enable virtio-ccw revision 1Cornelia Huck2014-12-091-1/+1
| | | | | | | | | | | | | Now that virtio-ccw has everything needed to support virtio 1.0 in place, try to enable it if the host supports it. Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* KVM: s390 allow virtio_ccw status writes to failMichael S. Tsirkin2014-12-091-1/+6
| | | | | | | | | | | | | Gracefully handle failure to write device status. We really should handle other errors as well, but this one is needed for virtio 1.0 compliance. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* KVM: s390: virtio-ccw revision 1 SET_VQCornelia Huck2014-12-091-12/+42
| | | | | | | | | | | | | | | The CCW_CMD_SET_VQ command has a different format for revision 1+ devices, allowing to specify a more complex virtqueue layout. For now, we stay however with the old layout and simply use the new command format for virtio-1 devices. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
* KVM: s390: Set virtio-ccw transport revisionThomas Huth2014-12-091-0/+63
| | | | | | | | | | | | | | | | | With the new SET-VIRTIO-REVISION command of the virtio 1.0 standard, we can now negotiate the virtio-ccw revision after setting a channel online. Note that we don't negotiate version 1 yet. [Cornelia Huck: reworked revision loop a bit] Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_blk: v1.0 supportMichael S. Tsirkin2014-12-092-36/+49
| | | | | | | | | | | | | | | Based on patch by Cornelia Huck. Note: for consistency, and to avoid sparse errors, convert all fields, even those no longer in use for virtio v1.0. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_net: v1.0 endiannessMichael S. Tsirkin2014-12-092-20/+28
| | | | | | | | | | | | | | | Based on patches by Rusty Russell, Cornelia Huck. Note: more code changes are needed for 1.0 support (due to different header size). So we don't advertize support for 1.0 yet. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio: add legacy feature table supportMichael S. Tsirkin2014-12-092-1/+28
| | | | | | | | | | | | | | virtio-blk has some legacy feature bits that modern drivers must not negotiate, but are needed for old legacy hosts (that e.g. don't support virtio-scsi). Allow a separate legacy feature table for such cases. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: simplify feature bit handlingMichael S. Tsirkin2014-12-091-4/+6
| | | | | | | | | | | | Now that we use u64 for bits, we can simply & them together. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: set FEATURES_OKMichael S. Tsirkin2014-12-092-7/+24
| | | | | | | | | | | set FEATURES_OK as per virtio 1.0 spec Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: allow transports to get avail/used addressesCornelia Huck2014-12-092-0/+19
| | | | | | | | | | | | | | | | | | For virtio-1, we can theoretically have a more complex virtqueue layout with avail and used buffers not on a contiguous memory area with the descriptor table. For now, it's fine for a transport driver to stay with the old layout: It needs, however, a way to access the locations of the avail/used rings so it can register them with the host. Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
* virtio_config: endian conversion for v1.0Michael S. Tsirkin2014-12-091-3/+6
| | | | | | | | | | | | | | | | We (ab)use virtio conversion functions for device-specific config space accesses. Based on original patches by Cornelia and Rusty. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: David Hildenbrand <dahi@linux.vnet.com>
* virtio_ring: switch to new memory access APIsMichael S. Tsirkin2014-12-091-44/+45
| | | | | | | | | | | | | | | Use virtioXX_to_cpu and friends for access to all multibyte structures in memory. Note: this is intentionally mechanical. A follow-up patch will split long lines etc. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: memory access APIsMichael S. Tsirkin2014-12-095-22/+161
| | | | | | | | | | | | | | | | | | | | | virtio 1.0 makes all memory structures LE, so we need APIs to conditionally do a byteswap on BE architectures. To make it easier to check code statically, add virtio specific types for multi-byte integers in memory. Add low level wrappers that do a byteswap conditionally, these will be useful e.g. for vhost. Add high level wrappers that query device endian-ness and act accordingly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
* virtio: add virtio 1.0 feature bitMichael S. Tsirkin2014-12-091-0/+3
| | | | | | | | | | | | | | | | | | | | | Based on original patches by Rusty Russell, Thomas Huth and Cornelia Huck. Note: at this time, we do not negotiate this feature bit in core, drivers have to declare VERSION_1 support explicitly. For this reason we treat this bit as a device bit and not as a transport bit for now. After all drivers are converted, we will be able to move VERSION_1 to core and drop it from all drivers. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
OpenPOWER on IntegriCloud