Pull virtio/vhost updates from Michael Tsirkin: - new vsock device support in host and guest - platform IOMMU support in host and guest, including compatibility quirks for legacy systems. - misc fixes and cleanups. * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: VSOCK: Use kvfree() vhost: split out vringh Kconfig vhost: detect 32 bit integer wrap around vhost: new device IOTLB API vhost: drop vringh dependency vhost: convert pre sorted vhost memory array to interval tree vhost: introduce vhost memory accessors VSOCK: Add Makefile and Kconfig VSOCK: Introduce vhost_vsock.ko VSOCK: Introduce virtio_transport.ko VSOCK: Introduce virtio_vsock_common.ko VSOCK: defer sock removal to transports VSOCK: transport-specific vsock_transport functions vhost: drop vringh dependency vop: pull in vhost Kconfig virtio: new feature to detect IOMMU device quirk balloon: check the number of available pages in leak balloon vhost: lockless enqueuing vhost: simplify work flushing
Showing the changes to include/uapi/linux (5 of 28 files). Show all
Unified · Split
| @@ -454,6 +454,7 @@ header-y += virtio_ring.h · 453 unmodified lines | ||
| 454 | 454 | header-y += virtio_rng.h |
| 455 | 455 | header-y += virtio_scsi.h |
| 456 | 456 | header-y += virtio_types.h |
| 457 | +header-y += virtio_vsock.h | |
| 457 | 458 | header-y += vm_sockets.h |
| 458 | 459 | header-y += vt.h |
| 459 | 460 | header-y += vtpm_proxy.h |
| @@ -47,6 +47,32 @@ struct vhost_vring_addr { · 46 unmodified lines | ||
| 47 | 47 | __u64 log_guest_addr; |
| 48 | 48 | }; |
| 49 | 49 | |
| 50 | +/* no alignment requirement */ | |
| 51 | +struct vhost_iotlb_msg { | |
| 52 | + __u64 iova; | |
| 53 | + __u64 size; | |
| 54 | + __u64 uaddr; | |
| 55 | +#define VHOST_ACCESS_RO 0x1 | |
| 56 | +#define VHOST_ACCESS_WO 0x2 | |
| 57 | +#define VHOST_ACCESS_RW 0x3 | |
| 58 | + __u8 perm; | |
| 59 | +#define VHOST_IOTLB_MISS 1 | |
| 60 | +#define VHOST_IOTLB_UPDATE 2 | |
| 61 | +#define VHOST_IOTLB_INVALIDATE 3 | |
| 62 | +#define VHOST_IOTLB_ACCESS_FAIL 4 | |
| 63 | + __u8 type; | |
| 64 | +}; | |
| 65 | + | |
| 66 | +#define VHOST_IOTLB_MSG 0x1 | |
| 67 | + | |
| 68 | +struct vhost_msg { | |
| 69 | + int type; | |
| 70 | + union { | |
| 71 | + struct vhost_iotlb_msg iotlb; | |
| 72 | + __u8 padding[64]; | |
| 73 | + }; | |
| 74 | +}; | |
| 75 | + | |
| 50 | 76 | struct vhost_memory_region { |
| 51 | 77 | __u64 guest_phys_addr; |
| 52 | 78 | __u64 memory_size; /* bytes */ |
| @@ -146,6 +172,8 @@ struct vhost_memory { · 93 unmodified lines | ||
| 146 | 172 | #define VHOST_F_LOG_ALL 26 |
| 147 | 173 | /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ |
| 148 | 174 | #define VHOST_NET_F_VIRTIO_NET_HDR 27 |
| 175 | +/* Vhost have device IOTLB */ | |
| 176 | +#define VHOST_F_DEVICE_IOTLB 63 | |
| 149 | 177 | |
| 150 | 178 | /* VHOST_SCSI specific definitions */ |
| 151 | 179 | |
| @@ -175,4 +203,9 @@ struct vhost_scsi_target { · 23 unmodified lines | ||
| 175 | 203 | #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32) |
| 176 | 204 | #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32) |
| 177 | 205 | |
| 206 | +/* VHOST_VSOCK specific defines */ | |
| 207 | + | |
| 208 | +#define VHOST_VSOCK_SET_GUEST_CID _IOW(VHOST_VIRTIO, 0x60, __u64) | |
| 209 | +#define VHOST_VSOCK_SET_RUNNING _IOW(VHOST_VIRTIO, 0x61, int) | |
| 210 | + | |
| 178 | 211 | #endif |
| @@ -49,7 +49,7 @@ · 48 unmodified lines | ||
| 49 | 49 | * transport being used (eg. virtio_ring), the rest are per-device feature |
| 50 | 50 | * bits. */ |
| 51 | 51 | #define VIRTIO_TRANSPORT_F_START 28 |
| 52 | −#define VIRTIO_TRANSPORT_F_END 33 | |
| 52 | +#define VIRTIO_TRANSPORT_F_END 34 | |
| 53 | 53 | |
| 54 | 54 | #ifndef VIRTIO_CONFIG_NO_LEGACY |
| 55 | 55 | /* Do we get callbacks when the ring is completely used, even if we've |
| @@ -63,4 +63,12 @@ · 7 unmodified lines | ||
| 63 | 63 | /* v1.0 compliant. */ |
| 64 | 64 | #define VIRTIO_F_VERSION_1 32 |
| 65 | 65 | |
| 66 | +/* | |
| 67 | + * If clear - device has the IOMMU bypass quirk feature. | |
| 68 | + * If set - use platform tools to detect the IOMMU. | |
| 69 | + * | |
| 70 | + * Note the reverse polarity (compared to most other features), | |
| 71 | + * this is for compatibility with legacy systems. | |
| 72 | + */ | |
| 73 | +#define VIRTIO_F_IOMMU_PLATFORM 33 | |
| 66 | 74 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ |
| @@ -41,5 +41,6 @@ · 40 unmodified lines | ||
| 41 | 41 | #define VIRTIO_ID_CAIF 12 /* Virtio caif */ |
| 42 | 42 | #define VIRTIO_ID_GPU 16 /* virtio GPU */ |
| 43 | 43 | #define VIRTIO_ID_INPUT 18 /* virtio input */ |
| 44 | +#define VIRTIO_ID_VSOCK 19 /* virtio vsock transport */ | |
| 44 | 45 | |
| 45 | 46 | #endif /* _LINUX_VIRTIO_IDS_H */ |
| @@ -0,0 +1,94 @@ | ||
| 1 | +/* | |
| 2 | + * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so | |
| 3 | + * anyone can use the definitions to implement compatible drivers/servers: | |
| 4 | + * | |
| 5 | + * | |
| 6 | + * Redistribution and use in source and binary forms, with or without | |
| 7 | + * modification, are permitted provided that the following conditions | |
| 8 | + * are met: | |
| 9 | + * 1. Redistributions of source code must retain the above copyright | |
| 10 | + * notice, this list of conditions and the following disclaimer. | |
| 11 | + * 2. Redistributions in binary form must reproduce the above copyright | |
| 12 | + * notice, this list of conditions and the following disclaimer in the | |
| 13 | + * documentation and/or other materials provided with the distribution. | |
| 14 | + * 3. Neither the name of IBM nor the names of its contributors | |
| 15 | + * may be used to endorse or promote products derived from this software | |
| 16 | + * without specific prior written permission. | |
| 17 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' | |
| 18 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 19 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 20 | + * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE | |
| 21 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 22 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 23 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 24 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 25 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 26 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 27 | + * SUCH DAMAGE. | |
| 28 | + * | |
| 29 | + * Copyright (C) Red Hat, Inc., 2013-2015 | |
| 30 | + * Copyright (C) Asias He <asias@redhat.com>, 2013 | |
| 31 | + * Copyright (C) Stefan Hajnoczi <stefanha@redhat.com>, 2015 | |
| 32 | + */ | |
| 33 | + | |
| 34 | +#ifndef _UAPI_LINUX_VIRTIO_VSOCK_H | |
| 35 | +#define _UAPI_LINUX_VIRTIO_VOSCK_H | |
| 36 | + | |
| 37 | +#include <linux/types.h> | |
| 38 | +#include <linux/virtio_ids.h> | |
| 39 | +#include <linux/virtio_config.h> | |
| 40 | + | |
| 41 | +struct virtio_vsock_config { | |
| 42 | + __le64 guest_cid; | |
| 43 | +} __attribute__((packed)); | |
| 44 | + | |
| 45 | +enum virtio_vsock_event_id { | |
| 46 | + VIRTIO_VSOCK_EVENT_TRANSPORT_RESET = 0, | |
| 47 | +}; | |
| 48 | + | |
| 49 | +struct virtio_vsock_event { | |
| 50 | + __le32 id; | |
| 51 | +} __attribute__((packed)); | |
| 52 | + | |
| 53 | +struct virtio_vsock_hdr { | |
| 54 | + __le64 src_cid; | |
| 55 | + __le64 dst_cid; | |
| 56 | + __le32 src_port; | |
| 57 | + __le32 dst_port; | |
| 58 | + __le32 len; | |
| 59 | + __le16 type; /* enum virtio_vsock_type */ | |
| 60 | + __le16 op; /* enum virtio_vsock_op */ | |
| 61 | + __le32 flags; | |
| 62 | + __le32 buf_alloc; | |
| 63 | + __le32 fwd_cnt; | |
| 64 | +} __attribute__((packed)); | |
| 65 | + | |
| 66 | +enum virtio_vsock_type { | |
| 67 | + VIRTIO_VSOCK_TYPE_STREAM = 1, | |
| 68 | +}; | |
| 69 | + | |
| 70 | +enum virtio_vsock_op { | |
| 71 | + VIRTIO_VSOCK_OP_INVALID = 0, | |
| 72 | + | |
| 73 | + /* Connect operations */ | |
| 74 | + VIRTIO_VSOCK_OP_REQUEST = 1, | |
| 75 | + VIRTIO_VSOCK_OP_RESPONSE = 2, | |
| 76 | + VIRTIO_VSOCK_OP_RST = 3, | |
| 77 | + VIRTIO_VSOCK_OP_SHUTDOWN = 4, | |
| 78 | + | |
| 79 | + /* To send payload */ | |
| 80 | + VIRTIO_VSOCK_OP_RW = 5, | |
| 81 | + | |
| 82 | + /* Tell the peer our credit info */ | |
| 83 | + VIRTIO_VSOCK_OP_CREDIT_UPDATE = 6, | |
| 84 | + /* Request the peer to send the credit info to us */ | |
| 85 | + VIRTIO_VSOCK_OP_CREDIT_REQUEST = 7, | |
| 86 | +}; | |
| 87 | + | |
| 88 | +/* VIRTIO_VSOCK_OP_SHUTDOWN flags values */ | |
| 89 | +enum virtio_vsock_shutdown { | |
| 90 | + VIRTIO_VSOCK_SHUTDOWN_RCV = 1, | |
| 91 | + VIRTIO_VSOCK_SHUTDOWN_SEND = 2, | |
| 92 | +}; | |
| 93 | + | |
| 94 | +#endif /* _UAPI_LINUX_VIRTIO_VSOCK_H */ | |