diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-06 09:20:13 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-06 09:20:13 -0400 |
| commit | 0803e04011c2e107b9611660301edde94d7010cc (patch) | |
| tree | 75699c1999c71a93dc8194a9cac338412e36d78d /include/uapi/linux | |
| parent | 80fac0f577a35c437219a2786c1804ab8ca1e998 (diff) | |
| parent | b226acab2f6aaa45c2af27279b63f622b23a44bd (diff) | |
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
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
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/Kbuild | 1 | ||||
| -rw-r--r-- | include/uapi/linux/vhost.h | 33 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_config.h | 10 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_ids.h | 1 | ||||
| -rw-r--r-- | include/uapi/linux/virtio_vsock.h | 94 |
5 files changed, 138 insertions, 1 deletions
diff --git a/include/uapi/linux/Kbuild b/include/uapi/linux/Kbuild index c44747c0796a..185f8ea2702f 100644 --- a/include/uapi/linux/Kbuild +++ b/include/uapi/linux/Kbuild | |||
| @@ -454,6 +454,7 @@ header-y += virtio_ring.h | |||
| 454 | header-y += virtio_rng.h | 454 | header-y += virtio_rng.h |
| 455 | header-y += virtio_scsi.h | 455 | header-y += virtio_scsi.h |
| 456 | header-y += virtio_types.h | 456 | header-y += virtio_types.h |
| 457 | header-y += virtio_vsock.h | ||
| 457 | header-y += vm_sockets.h | 458 | header-y += vm_sockets.h |
| 458 | header-y += vt.h | 459 | header-y += vt.h |
| 459 | header-y += vtpm_proxy.h | 460 | header-y += vtpm_proxy.h |
diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h index 61a8777178c6..56b7ab584cc0 100644 --- a/include/uapi/linux/vhost.h +++ b/include/uapi/linux/vhost.h | |||
| @@ -47,6 +47,32 @@ struct vhost_vring_addr { | |||
| 47 | __u64 log_guest_addr; | 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 | struct vhost_memory_region { | 76 | struct vhost_memory_region { |
| 51 | __u64 guest_phys_addr; | 77 | __u64 guest_phys_addr; |
| 52 | __u64 memory_size; /* bytes */ | 78 | __u64 memory_size; /* bytes */ |
| @@ -146,6 +172,8 @@ struct vhost_memory { | |||
| 146 | #define VHOST_F_LOG_ALL 26 | 172 | #define VHOST_F_LOG_ALL 26 |
| 147 | /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ | 173 | /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ |
| 148 | #define VHOST_NET_F_VIRTIO_NET_HDR 27 | 174 | #define VHOST_NET_F_VIRTIO_NET_HDR 27 |
| 175 | /* Vhost have device IOTLB */ | ||
| 176 | #define VHOST_F_DEVICE_IOTLB 63 | ||
| 149 | 177 | ||
| 150 | /* VHOST_SCSI specific definitions */ | 178 | /* VHOST_SCSI specific definitions */ |
| 151 | 179 | ||
| @@ -175,4 +203,9 @@ struct vhost_scsi_target { | |||
| 175 | #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32) | 203 | #define VHOST_SCSI_SET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x43, __u32) |
| 176 | #define VHOST_SCSI_GET_EVENTS_MISSED _IOW(VHOST_VIRTIO, 0x44, __u32) | 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 | #endif | 211 | #endif |
diff --git a/include/uapi/linux/virtio_config.h b/include/uapi/linux/virtio_config.h index 4cb65bbfa654..308e2096291f 100644 --- a/include/uapi/linux/virtio_config.h +++ b/include/uapi/linux/virtio_config.h | |||
| @@ -49,7 +49,7 @@ | |||
| 49 | * transport being used (eg. virtio_ring), the rest are per-device feature | 49 | * transport being used (eg. virtio_ring), the rest are per-device feature |
| 50 | * bits. */ | 50 | * bits. */ |
| 51 | #define VIRTIO_TRANSPORT_F_START 28 | 51 | #define VIRTIO_TRANSPORT_F_START 28 |
| 52 | #define VIRTIO_TRANSPORT_F_END 33 | 52 | #define VIRTIO_TRANSPORT_F_END 34 |
| 53 | 53 | ||
| 54 | #ifndef VIRTIO_CONFIG_NO_LEGACY | 54 | #ifndef VIRTIO_CONFIG_NO_LEGACY |
| 55 | /* Do we get callbacks when the ring is completely used, even if we've | 55 | /* Do we get callbacks when the ring is completely used, even if we've |
| @@ -63,4 +63,12 @@ | |||
| 63 | /* v1.0 compliant. */ | 63 | /* v1.0 compliant. */ |
| 64 | #define VIRTIO_F_VERSION_1 32 | 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 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ | 74 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ |
diff --git a/include/uapi/linux/virtio_ids.h b/include/uapi/linux/virtio_ids.h index 77925f587b15..3228d582234a 100644 --- a/include/uapi/linux/virtio_ids.h +++ b/include/uapi/linux/virtio_ids.h | |||
| @@ -41,5 +41,6 @@ | |||
| 41 | #define VIRTIO_ID_CAIF 12 /* Virtio caif */ | 41 | #define VIRTIO_ID_CAIF 12 /* Virtio caif */ |
| 42 | #define VIRTIO_ID_GPU 16 /* virtio GPU */ | 42 | #define VIRTIO_ID_GPU 16 /* virtio GPU */ |
| 43 | #define VIRTIO_ID_INPUT 18 /* virtio input */ | 43 | #define VIRTIO_ID_INPUT 18 /* virtio input */ |
| 44 | #define VIRTIO_ID_VSOCK 19 /* virtio vsock transport */ | ||
| 44 | 45 | ||
| 45 | #endif /* _LINUX_VIRTIO_IDS_H */ | 46 | #endif /* _LINUX_VIRTIO_IDS_H */ |
diff --git a/include/uapi/linux/virtio_vsock.h b/include/uapi/linux/virtio_vsock.h new file mode 100644 index 000000000000..6b011c19b50f --- /dev/null +++ b/include/uapi/linux/virtio_vsock.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 | |||
