mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-07-19 17:26:28 +00:00
Merge pull request #2788 from rn/kern
Update kernel to 4.14.3/4.9.66/4.4.103 and remove 4.13.x
This commit is contained in:
commit
00aaf428d9
@ -1,6 +1,6 @@
|
||||
# This is a blueprint for building the open source components of Docker for Mac
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/vpnkit-expose-port:15c56c57ac9a7adeec20b34f36f2bc165c347679 # install vpnkit-expose-port and vpnkit-iptables-wrapper on host
|
||||
|
@ -339,7 +339,7 @@ file:
|
||||
|
||||
```
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- <foo>/zfs-kmod:4.9.47
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS1 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Minimal YAML to run a redis server (used at DockerCon'17)
|
||||
# connect: nc localhost 6379
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -171,12 +171,11 @@ endef
|
||||
# Build Targets
|
||||
# Debug targets only for latest stable and LTS stable
|
||||
#
|
||||
$(eval $(call kernel,4.14.2,4.14.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.14.2,4.14.x,-dbg))
|
||||
$(eval $(call kernel,4.13.16,4.13.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.9.65,4.9.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.9.65,4.9.x,-dbg))
|
||||
$(eval $(call kernel,4.4.102,4.4.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.14.3,4.14.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.14.3,4.14.x,-dbg))
|
||||
$(eval $(call kernel,4.9.66,4.9.x,$(EXTRA)))
|
||||
$(eval $(call kernel,4.9.66,4.9.x,-dbg))
|
||||
$(eval $(call kernel,4.4.103,4.4.x,$(EXTRA)))
|
||||
|
||||
# Target for kernel config
|
||||
kconfig: | sources
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/arm64 4.14.2 Kernel Configuration
|
||||
# Linux/arm64 4.14.3 Kernel Configuration
|
||||
#
|
||||
CONFIG_ARM64=y
|
||||
CONFIG_64BIT=y
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/x86 4.14.2 Kernel Configuration
|
||||
# Linux/x86 4.14.3 Kernel Configuration
|
||||
#
|
||||
CONFIG_64BIT=y
|
||||
CONFIG_X86_64=y
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/arm64 4.4.102 Kernel Configuration
|
||||
# Linux/arm64 4.4.103 Kernel Configuration
|
||||
#
|
||||
CONFIG_ARM64=y
|
||||
CONFIG_64BIT=y
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/x86 4.4.102 Kernel Configuration
|
||||
# Linux/x86 4.4.103 Kernel Configuration
|
||||
#
|
||||
CONFIG_64BIT=y
|
||||
CONFIG_X86_64=y
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/arm64 4.9.65 Kernel Configuration
|
||||
# Linux/arm64 4.9.66 Kernel Configuration
|
||||
#
|
||||
CONFIG_ARM64=y
|
||||
CONFIG_64BIT=y
|
||||
|
@ -1,6 +1,6 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/x86 4.9.65 Kernel Configuration
|
||||
# Linux/x86 4.9.66 Kernel Configuration
|
||||
#
|
||||
CONFIG_64BIT=y
|
||||
CONFIG_X86_64=y
|
||||
|
@ -1,34 +0,0 @@
|
||||
From f20567378457fca252a1be2d84ca65c5ae6640db Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 16:57:12 -0600
|
||||
Subject: [PATCH 01/12] vmbus: vmbus_open(): reset onchannel_callback on error
|
||||
|
||||
No real issue is observed without the patch, but let's add this
|
||||
just in case.
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Cc: K. Y. Srinivasan <kys@microsoft.com>
|
||||
Cc: Haiyang Zhang <haiyangz@microsoft.com>
|
||||
Cc: Stephen Hemminger <sthemmin@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit 5181302de497cb7d5de37bbc84e01eca676f20d8)
|
||||
---
|
||||
drivers/hv/channel.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
|
||||
index be3fccab07fe..4775616ec87f 100644
|
||||
--- a/drivers/hv/channel.c
|
||||
+++ b/drivers/hv/channel.c
|
||||
@@ -225,6 +225,8 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
|
||||
get_order(send_ringbuffer_size + recv_ringbuffer_size));
|
||||
error_set_chnstate:
|
||||
newchannel->state = CHANNEL_OPEN_STATE;
|
||||
+ newchannel->onchannel_callback = NULL;
|
||||
+ newchannel->channel_callback_context = NULL;
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vmbus_open);
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,63 +0,0 @@
|
||||
From 6fb88fbdbd7f8074bd38c75e75a358f5f1683a1f Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 16:57:20 -0600
|
||||
Subject: [PATCH 02/12] vmbus: remove "goto error_clean_msglist" in
|
||||
vmbus_open()
|
||||
|
||||
This is just a cleanup patch to simplify the code a little.
|
||||
No semantic change.
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Cc: K. Y. Srinivasan <kys@microsoft.com>
|
||||
Cc: Haiyang Zhang <haiyangz@microsoft.com>
|
||||
Cc: Stephen Hemminger <sthemmin@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit 866488f04fc4d8ff513697db2f80263e90277291)
|
||||
---
|
||||
drivers/hv/channel.c | 18 +++++++-----------
|
||||
1 file changed, 7 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
|
||||
index 4775616ec87f..033100a1cd59 100644
|
||||
--- a/drivers/hv/channel.c
|
||||
+++ b/drivers/hv/channel.c
|
||||
@@ -185,17 +185,18 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
|
||||
ret = vmbus_post_msg(open_msg,
|
||||
sizeof(struct vmbus_channel_open_channel), true);
|
||||
|
||||
- if (ret != 0) {
|
||||
- err = ret;
|
||||
- goto error_clean_msglist;
|
||||
- }
|
||||
-
|
||||
- wait_for_completion(&open_info->waitevent);
|
||||
+ if (ret == 0)
|
||||
+ wait_for_completion(&open_info->waitevent);
|
||||
|
||||
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
|
||||
list_del(&open_info->msglistentry);
|
||||
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
|
||||
|
||||
+ if (ret != 0) {
|
||||
+ err = ret;
|
||||
+ goto error_free_gpadl;
|
||||
+ }
|
||||
+
|
||||
if (newchannel->rescind) {
|
||||
err = -ENODEV;
|
||||
goto error_free_gpadl;
|
||||
@@ -210,11 +211,6 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
|
||||
kfree(open_info);
|
||||
return 0;
|
||||
|
||||
-error_clean_msglist:
|
||||
- spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
|
||||
- list_del(&open_info->msglistentry);
|
||||
- spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
|
||||
-
|
||||
error_free_gpadl:
|
||||
vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle);
|
||||
kfree(open_info);
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,934 +0,0 @@
|
||||
From b0eb295ce0869888ab501e4c39b6de13f9a2b2d2 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 16:57:26 -0600
|
||||
Subject: [PATCH 03/12] hv_sock: implements Hyper-V transport for Virtual
|
||||
Sockets (AF_VSOCK)
|
||||
|
||||
Hyper-V Sockets (hv_sock) supplies a byte-stream based communication
|
||||
mechanism between the host and the guest. It uses VMBus ringbuffer as the
|
||||
transportation layer.
|
||||
|
||||
With hv_sock, applications between the host (Windows 10, Windows Server
|
||||
2016 or newer) and the guest can talk with each other using the traditional
|
||||
socket APIs.
|
||||
|
||||
More info about Hyper-V Sockets is available here:
|
||||
|
||||
"Make your own integration services":
|
||||
https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service
|
||||
|
||||
The patch implements the necessary support in Linux guest by introducing a new
|
||||
vsock transport for AF_VSOCK.
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Cc: K. Y. Srinivasan <kys@microsoft.com>
|
||||
Cc: Haiyang Zhang <haiyangz@microsoft.com>
|
||||
Cc: Stephen Hemminger <sthemmin@microsoft.com>
|
||||
Cc: Andy King <acking@vmware.com>
|
||||
Cc: Dmitry Torokhov <dtor@vmware.com>
|
||||
Cc: George Zhang <georgezhang@vmware.com>
|
||||
Cc: Jorgen Hansen <jhansen@vmware.com>
|
||||
Cc: Reilly Grant <grantr@vmware.com>
|
||||
Cc: Asias He <asias@redhat.com>
|
||||
Cc: Stefan Hajnoczi <stefanha@redhat.com>
|
||||
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
|
||||
Cc: Cathy Avery <cavery@redhat.com>
|
||||
Cc: Rolf Neugebauer <rolf.neugebauer@docker.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit b02ea409f1fceeaac6fd971db5d095ecc903de2d)
|
||||
---
|
||||
MAINTAINERS | 1 +
|
||||
net/vmw_vsock/Kconfig | 12 +
|
||||
net/vmw_vsock/Makefile | 3 +
|
||||
net/vmw_vsock/hyperv_transport.c | 829 +++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 845 insertions(+)
|
||||
create mode 100644 net/vmw_vsock/hyperv_transport.c
|
||||
|
||||
diff --git a/MAINTAINERS b/MAINTAINERS
|
||||
index 1c3feffb1c1c..6b8572bac997 100644
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -6269,6 +6269,7 @@ F: drivers/net/hyperv/
|
||||
F: drivers/scsi/storvsc_drv.c
|
||||
F: drivers/uio/uio_hv_generic.c
|
||||
F: drivers/video/fbdev/hyperv_fb.c
|
||||
+F: net/vmw_vsock/hyperv_transport.c
|
||||
F: include/linux/hyperv.h
|
||||
F: tools/hv/
|
||||
F: Documentation/ABI/stable/sysfs-bus-vmbus
|
||||
diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig
|
||||
index 8831e7c42167..a24369d175fd 100644
|
||||
--- a/net/vmw_vsock/Kconfig
|
||||
+++ b/net/vmw_vsock/Kconfig
|
||||
@@ -46,3 +46,15 @@ config VIRTIO_VSOCKETS_COMMON
|
||||
This option is selected by any driver which needs to access
|
||||
the virtio_vsock. The module will be called
|
||||
vmw_vsock_virtio_transport_common.
|
||||
+
|
||||
+config HYPERV_VSOCKETS
|
||||
+ tristate "Hyper-V transport for Virtual Sockets"
|
||||
+ depends on VSOCKETS && HYPERV
|
||||
+ help
|
||||
+ This module implements a Hyper-V transport for Virtual Sockets.
|
||||
+
|
||||
+ Enable this transport if your Virtual Machine host supports Virtual
|
||||
+ Sockets over Hyper-V VMBus.
|
||||
+
|
||||
+ To compile this driver as a module, choose M here: the module will be
|
||||
+ called hv_sock. If unsure, say N.
|
||||
diff --git a/net/vmw_vsock/Makefile b/net/vmw_vsock/Makefile
|
||||
index 09fc2eb29dc8..e63d574234a9 100644
|
||||
--- a/net/vmw_vsock/Makefile
|
||||
+++ b/net/vmw_vsock/Makefile
|
||||
@@ -2,6 +2,7 @@ obj-$(CONFIG_VSOCKETS) += vsock.o
|
||||
obj-$(CONFIG_VMWARE_VMCI_VSOCKETS) += vmw_vsock_vmci_transport.o
|
||||
obj-$(CONFIG_VIRTIO_VSOCKETS) += vmw_vsock_virtio_transport.o
|
||||
obj-$(CONFIG_VIRTIO_VSOCKETS_COMMON) += vmw_vsock_virtio_transport_common.o
|
||||
+obj-$(CONFIG_HYPERV_VSOCKETS) += hv_sock.o
|
||||
|
||||
vsock-y += af_vsock.o af_vsock_tap.o vsock_addr.o
|
||||
|
||||
@@ -11,3 +12,5 @@ vmw_vsock_vmci_transport-y += vmci_transport.o vmci_transport_notify.o \
|
||||
vmw_vsock_virtio_transport-y += virtio_transport.o
|
||||
|
||||
vmw_vsock_virtio_transport_common-y += virtio_transport_common.o
|
||||
+
|
||||
+hv_sock-y += hyperv_transport.o
|
||||
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
|
||||
new file mode 100644
|
||||
index 000000000000..fd89bf357617
|
||||
--- /dev/null
|
||||
+++ b/net/vmw_vsock/hyperv_transport.c
|
||||
@@ -0,0 +1,829 @@
|
||||
+/*
|
||||
+ * Hyper-V transport for vsock
|
||||
+ *
|
||||
+ * Hyper-V Sockets supplies a byte-stream based communication mechanism
|
||||
+ * between the host and the VM. This driver implements the necessary
|
||||
+ * support in the VM by introducing the new vsock transport.
|
||||
+ *
|
||||
+ * Copyright (c) 2017, Microsoft Corporation.
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify it
|
||||
+ * under the terms and conditions of the GNU General Public License,
|
||||
+ * version 2, as published by the Free Software Foundation.
|
||||
+ *
|
||||
+ * This program is distributed in the hope it will be useful, but WITHOUT
|
||||
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
+ * more details.
|
||||
+ *
|
||||
+ */
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/vmalloc.h>
|
||||
+#include <linux/hyperv.h>
|
||||
+#include <net/sock.h>
|
||||
+#include <net/af_vsock.h>
|
||||
+
|
||||
+/* The host side's design of the feature requires 6 exact 4KB pages for
|
||||
+ * recv/send rings respectively -- this is suboptimal considering memory
|
||||
+ * consumption, however unluckily we have to live with it, before the
|
||||
+ * host comes up with a better design in the future.
|
||||
+ */
|
||||
+#define PAGE_SIZE_4K 4096
|
||||
+#define RINGBUFFER_HVS_RCV_SIZE (PAGE_SIZE_4K * 6)
|
||||
+#define RINGBUFFER_HVS_SND_SIZE (PAGE_SIZE_4K * 6)
|
||||
+
|
||||
+/* The MTU is 16KB per the host side's design */
|
||||
+#define HVS_MTU_SIZE (1024 * 16)
|
||||
+
|
||||
+struct vmpipe_proto_header {
|
||||
+ u32 pkt_type;
|
||||
+ u32 data_size;
|
||||
+};
|
||||
+
|
||||
+/* For recv, we use the VMBus in-place packet iterator APIs to directly copy
|
||||
+ * data from the ringbuffer into the userspace buffer.
|
||||
+ */
|
||||
+struct hvs_recv_buf {
|
||||
+ /* The header before the payload data */
|
||||
+ struct vmpipe_proto_header hdr;
|
||||
+
|
||||
+ /* The payload */
|
||||
+ u8 data[HVS_MTU_SIZE];
|
||||
+};
|
||||
+
|
||||
+/* We can send up to HVS_MTU_SIZE bytes of payload to the host, but let's use
|
||||
+ * a small size, i.e. HVS_SEND_BUF_SIZE, to minimize the dynamically-allocated
|
||||
+ * buffer, because tests show there is no significant performance difference.
|
||||
+ *
|
||||
+ * Note: the buffer can be eliminated in the future when we add new VMBus
|
||||
+ * ringbuffer APIs that allow us to directly copy data from userspace buffer
|
||||
+ * to VMBus ringbuffer.
|
||||
+ */
|
||||
+#define HVS_SEND_BUF_SIZE (PAGE_SIZE_4K - sizeof(struct vmpipe_proto_header))
|
||||
+
|
||||
+struct hvs_send_buf {
|
||||
+ /* The header before the payload data */
|
||||
+ struct vmpipe_proto_header hdr;
|
||||
+
|
||||
+ /* The payload */
|
||||
+ u8 data[HVS_SEND_BUF_SIZE];
|
||||
+};
|
||||
+
|
||||
+#define HVS_HEADER_LEN (sizeof(struct vmpacket_descriptor) + \
|
||||
+ sizeof(struct vmpipe_proto_header))
|
||||
+
|
||||
+/* See 'prev_indices' in hv_ringbuffer_read(), hv_ringbuffer_write(), and
|
||||
+ * __hv_pkt_iter_next().
|
||||
+ */
|
||||
+#define VMBUS_PKT_TRAILER (sizeof(u64))
|
||||
+
|
||||
+#define HVS_PKT_LEN(payload_len) (HVS_HEADER_LEN + \
|
||||
+ ALIGN((payload_len), 8) + \
|
||||
+ VMBUS_PKT_TRAILER)
|
||||
+
|
||||
+/* Per-socket state (accessed via vsk->trans) */
|
||||
+struct hvsock {
|
||||
+ struct vsock_sock *vsk;
|
||||
+
|
||||
+ uuid_le vm_srv_id;
|
||||
+ uuid_le host_srv_id;
|
||||
+
|
||||
+ struct vmbus_channel *chan;
|
||||
+ struct vmpacket_descriptor *recv_desc;
|
||||
+
|
||||
+ /* The length of the payload not delivered to userland yet */
|
||||
+ u32 recv_data_len;
|
||||
+ /* The offset of the payload */
|
||||
+ u32 recv_data_off;
|
||||
+};
|
||||
+
|
||||
+/* In the VM, we support Hyper-V Sockets with AF_VSOCK, and the endpoint is
|
||||
+ * <cid, port> (see struct sockaddr_vm). Note: cid is not really used here:
|
||||
+ * when we write apps to connect to the host, we can only use VMADDR_CID_ANY
|
||||
+ * or VMADDR_CID_HOST (both are equivalent) as the remote cid, and when we
|
||||
+ * write apps to bind() & listen() in the VM, we can only use VMADDR_CID_ANY
|
||||
+ * as the local cid.
|
||||
+ *
|
||||
+ * On the host, Hyper-V Sockets are supported by Winsock AF_HYPERV:
|
||||
+ * https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-
|
||||
+ * guide/make-integration-service, and the endpoint is <VmID, ServiceId> with
|
||||
+ * the below sockaddr:
|
||||
+ *
|
||||
+ * struct SOCKADDR_HV
|
||||
+ * {
|
||||
+ * ADDRESS_FAMILY Family;
|
||||
+ * USHORT Reserved;
|
||||
+ * GUID VmId;
|
||||
+ * GUID ServiceId;
|
||||
+ * };
|
||||
+ * Note: VmID is not used by Linux VM and actually it isn't transmitted via
|
||||
+ * VMBus, because here it's obvious the host and the VM can easily identify
|
||||
+ * each other. Though the VmID is useful on the host, especially in the case
|
||||
+ * of Windows container, Linux VM doesn't need it at all.
|
||||
+ *
|
||||
+ * To make use of the AF_VSOCK infrastructure in Linux VM, we have to limit
|
||||
+ * the available GUID space of SOCKADDR_HV so that we can create a mapping
|
||||
+ * between AF_VSOCK port and SOCKADDR_HV Service GUID. The rule of writing
|
||||
+ * Hyper-V Sockets apps on the host and in Linux VM is:
|
||||
+ *
|
||||
+ ****************************************************************************
|
||||
+ * the only valid Service GUIDs, from the perspectives of both the host and *
|
||||
+ * Linux VM, that can be connected by the other end, must conform to this *
|
||||
+ * format: <port>-facb-11e6-bd58-64006a7986d3, and the "port" must be in *
|
||||
+ * this range [0, 0x7FFFFFFF]. *
|
||||
+ ****************************************************************************
|
||||
+ *
|
||||
+ * When we write apps on the host to connect(), the GUID ServiceID is used.
|
||||
+ * When we write apps in Linux VM to connect(), we only need to specify the
|
||||
+ * port and the driver will form the GUID and use that to request the host.
|
||||
+ *
|
||||
+ * From the perspective of Linux VM:
|
||||
+ * 1. the local ephemeral port (i.e. the local auto-bound port when we call
|
||||
+ * connect() without explicit bind()) is generated by __vsock_bind_stream(),
|
||||
+ * and the range is [1024, 0xFFFFFFFF).
|
||||
+ * 2. the remote ephemeral port (i.e. the auto-generated remote port for
|
||||
+ * a connect request initiated by the host's connect()) is generated by
|
||||
+ * hvs_remote_addr_init() and the range is [0x80000000, 0xFFFFFFFF).
|
||||
+ */
|
||||
+
|
||||
+#define MAX_LISTEN_PORT ((u32)0x7FFFFFFF)
|
||||
+#define MAX_VM_LISTEN_PORT MAX_LISTEN_PORT
|
||||
+#define MAX_HOST_LISTEN_PORT MAX_LISTEN_PORT
|
||||
+#define MIN_HOST_EPHEMERAL_PORT (MAX_HOST_LISTEN_PORT + 1)
|
||||
+
|
||||
+/* 00000000-facb-11e6-bd58-64006a7986d3 */
|
||||
+static const uuid_le srv_id_template =
|
||||
+ UUID_LE(0x00000000, 0xfacb, 0x11e6, 0xbd, 0x58,
|
||||
+ 0x64, 0x00, 0x6a, 0x79, 0x86, 0xd3);
|
||||
+
|
||||
+static inline bool is_valid_srv_id(const uuid_le *id)
|
||||
+{
|
||||
+ return !memcmp(&id->b[4], &srv_id_template.b[4], sizeof(uuid_le) - 4);
|
||||
+}
|
||||
+
|
||||
+static inline unsigned int get_port_by_srv_id(const uuid_le *svr_id)
|
||||
+{
|
||||
+ return *((unsigned int *)svr_id);
|
||||
+}
|
||||
+
|
||||
+static inline void hvs_addr_init(struct sockaddr_vm *addr,
|
||||
+ const uuid_le *svr_id)
|
||||
+{
|
||||
+ unsigned int port = get_port_by_srv_id(svr_id);
|
||||
+
|
||||
+ vsock_addr_init(addr, VMADDR_CID_ANY, port);
|
||||
+}
|
||||
+
|
||||
+static inline void hvs_remote_addr_init(struct sockaddr_vm *remote,
|
||||
+ struct sockaddr_vm *local)
|
||||
+{
|
||||
+ static u32 host_ephemeral_port = MIN_HOST_EPHEMERAL_PORT;
|
||||
+ struct sock *sk;
|
||||
+
|
||||
+ vsock_addr_init(remote, VMADDR_CID_ANY, VMADDR_PORT_ANY);
|
||||
+
|
||||
+ while (1) {
|
||||
+ /* Wrap around ? */
|
||||
+ if (host_ephemeral_port < MIN_HOST_EPHEMERAL_PORT ||
|
||||
+ host_ephemeral_port == VMADDR_PORT_ANY)
|
||||
+ host_ephemeral_port = MIN_HOST_EPHEMERAL_PORT;
|
||||
+
|
||||
+ remote->svm_port = host_ephemeral_port++;
|
||||
+
|
||||
+ sk = vsock_find_connected_socket(remote, local);
|
||||
+ if (!sk) {
|
||||
+ /* Found an available ephemeral port */
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* Release refcnt got in vsock_find_connected_socket */
|
||||
+ sock_put(sk);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static bool hvs_channel_readable(struct vmbus_channel *chan)
|
||||
+{
|
||||
+ u32 readable = hv_get_bytes_to_read(&chan->inbound);
|
||||
+
|
||||
+ /* 0-size payload means FIN */
|
||||
+ return readable >= HVS_PKT_LEN(0);
|
||||
+}
|
||||
+
|
||||
+static int hvs_channel_readable_payload(struct vmbus_channel *chan)
|
||||
+{
|
||||
+ u32 readable = hv_get_bytes_to_read(&chan->inbound);
|
||||
+
|
||||
+ if (readable > HVS_PKT_LEN(0)) {
|
||||
+ /* At least we have 1 byte to read. We don't need to return
|
||||
+ * the exact readable bytes: see vsock_stream_recvmsg() ->
|
||||
+ * vsock_stream_has_data().
|
||||
+ */
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (readable == HVS_PKT_LEN(0)) {
|
||||
+ /* 0-size payload means FIN */
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* No payload or FIN */
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static inline size_t hvs_channel_writable_bytes(struct vmbus_channel *chan)
|
||||
+{
|
||||
+ u32 writeable = hv_get_bytes_to_write(&chan->outbound);
|
||||
+ size_t ret;
|
||||
+
|
||||
+ /* The ringbuffer mustn't be 100% full, and we should reserve a
|
||||
+ * zero-length-payload packet for the FIN: see hv_ringbuffer_write()
|
||||
+ * and hvs_shutdown().
|
||||
+ */
|
||||
+ if (writeable <= HVS_PKT_LEN(1) + HVS_PKT_LEN(0))
|
||||
+ return 0;
|
||||
+
|
||||
+ ret = writeable - HVS_PKT_LEN(1) - HVS_PKT_LEN(0);
|
||||
+
|
||||
+ return round_down(ret, 8);
|
||||
+}
|
||||
+
|
||||
+static int hvs_send_data(struct vmbus_channel *chan,
|
||||
+ struct hvs_send_buf *send_buf, size_t to_write)
|
||||
+{
|
||||
+ send_buf->hdr.pkt_type = 1;
|
||||
+ send_buf->hdr.data_size = to_write;
|
||||
+ return vmbus_sendpacket(chan, &send_buf->hdr,
|
||||
+ sizeof(send_buf->hdr) + to_write,
|
||||
+ 0, VM_PKT_DATA_INBAND, 0);
|
||||
+}
|
||||
+
|
||||
+static void hvs_channel_cb(void *ctx)
|
||||
+{
|
||||
+ struct sock *sk = (struct sock *)ctx;
|
||||
+ struct vsock_sock *vsk = vsock_sk(sk);
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ struct vmbus_channel *chan = hvs->chan;
|
||||
+
|
||||
+ if (hvs_channel_readable(chan))
|
||||
+ sk->sk_data_ready(sk);
|
||||
+
|
||||
+ /* Mark it writable only if there is enough space */
|
||||
+ if (hvs_channel_writable_bytes(chan) >= HVS_SEND_BUF_SIZE)
|
||||
+ sk->sk_write_space(sk);
|
||||
+}
|
||||
+
|
||||
+static void hvs_close_connection(struct vmbus_channel *chan)
|
||||
+{
|
||||
+ struct sock *sk = get_per_channel_state(chan);
|
||||
+ struct vsock_sock *vsk = vsock_sk(sk);
|
||||
+
|
||||
+ sk->sk_state = SS_UNCONNECTED;
|
||||
+ sock_set_flag(sk, SOCK_DONE);
|
||||
+ vsk->peer_shutdown |= SEND_SHUTDOWN | RCV_SHUTDOWN;
|
||||
+
|
||||
+ sk->sk_state_change(sk);
|
||||
+}
|
||||
+
|
||||
+static void hvs_open_connection(struct vmbus_channel *chan)
|
||||
+{
|
||||
+ uuid_le *if_instance, *if_type;
|
||||
+ unsigned char conn_from_host;
|
||||
+
|
||||
+ struct sockaddr_vm addr;
|
||||
+ struct sock *sk, *new = NULL;
|
||||
+ struct vsock_sock *vnew;
|
||||
+ struct hvsock *hvs, *hvs_new;
|
||||
+ int ret;
|
||||
+
|
||||
+ if_type = &chan->offermsg.offer.if_type;
|
||||
+ if_instance = &chan->offermsg.offer.if_instance;
|
||||
+ conn_from_host = chan->offermsg.offer.u.pipe.user_def[0];
|
||||
+
|
||||
+ /* The host or the VM should only listen on a port in
|
||||
+ * [0, MAX_LISTEN_PORT]
|
||||
+ */
|
||||
+ if (!is_valid_srv_id(if_type) ||
|
||||
+ get_port_by_srv_id(if_type) > MAX_LISTEN_PORT)
|
||||
+ return;
|
||||
+
|
||||
+ hvs_addr_init(&addr, conn_from_host ? if_type : if_instance);
|
||||
+ sk = vsock_find_bound_socket(&addr);
|
||||
+ if (!sk)
|
||||
+ return;
|
||||
+
|
||||
+ if ((conn_from_host && sk->sk_state != VSOCK_SS_LISTEN) ||
|
||||
+ (!conn_from_host && sk->sk_state != SS_CONNECTING))
|
||||
+ goto out;
|
||||
+
|
||||
+ if (conn_from_host) {
|
||||
+ if (sk->sk_ack_backlog >= sk->sk_max_ack_backlog)
|
||||
+ goto out;
|
||||
+
|
||||
+ new = __vsock_create(sock_net(sk), NULL, sk, GFP_KERNEL,
|
||||
+ sk->sk_type, 0);
|
||||
+ if (!new)
|
||||
+ goto out;
|
||||
+
|
||||
+ new->sk_state = SS_CONNECTING;
|
||||
+ vnew = vsock_sk(new);
|
||||
+ hvs_new = vnew->trans;
|
||||
+ hvs_new->chan = chan;
|
||||
+ } else {
|
||||
+ hvs = vsock_sk(sk)->trans;
|
||||
+ hvs->chan = chan;
|
||||
+ }
|
||||
+
|
||||
+ set_channel_read_mode(chan, HV_CALL_DIRECT);
|
||||
+ ret = vmbus_open(chan, RINGBUFFER_HVS_SND_SIZE,
|
||||
+ RINGBUFFER_HVS_RCV_SIZE, NULL, 0,
|
||||
+ hvs_channel_cb, conn_from_host ? new : sk);
|
||||
+ if (ret != 0) {
|
||||
+ if (conn_from_host) {
|
||||
+ hvs_new->chan = NULL;
|
||||
+ sock_put(new);
|
||||
+ } else {
|
||||
+ hvs->chan = NULL;
|
||||
+ }
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ set_per_channel_state(chan, conn_from_host ? new : sk);
|
||||
+ vmbus_set_chn_rescind_callback(chan, hvs_close_connection);
|
||||
+
|
||||
+ /* See hvs_channel_cb() and hvs_notify_poll_out() */
|
||||
+ set_channel_pending_send_size(chan,
|
||||
+ HVS_PKT_LEN(HVS_SEND_BUF_SIZE) + 1);
|
||||
+
|
||||
+ if (conn_from_host) {
|
||||
+ new->sk_state = SS_CONNECTED;
|
||||
+ sk->sk_ack_backlog++;
|
||||
+
|
||||
+ hvs_addr_init(&vnew->local_addr, if_type);
|
||||
+ hvs_remote_addr_init(&vnew->remote_addr, &vnew->local_addr);
|
||||
+
|
||||
+ hvs_new->vm_srv_id = *if_type;
|
||||
+ hvs_new->host_srv_id = *if_instance;
|
||||
+
|
||||
+ vsock_insert_connected(vnew);
|
||||
+ vsock_enqueue_accept(sk, new);
|
||||
+ } else {
|
||||
+ sk->sk_state = SS_CONNECTED;
|
||||
+ sk->sk_socket->state = SS_CONNECTED;
|
||||
+
|
||||
+ vsock_insert_connected(vsock_sk(sk));
|
||||
+ }
|
||||
+
|
||||
+ sk->sk_state_change(sk);
|
||||
+
|
||||
+out:
|
||||
+ /* Release refcnt obtained when we called vsock_find_bound_socket() */
|
||||
+ sock_put(sk);
|
||||
+}
|
||||
+
|
||||
+static u32 hvs_get_local_cid(void)
|
||||
+{
|
||||
+ return VMADDR_CID_ANY;
|
||||
+}
|
||||
+
|
||||
+static int hvs_sock_init(struct vsock_sock *vsk, struct vsock_sock *psk)
|
||||
+{
|
||||
+ struct hvsock *hvs;
|
||||
+
|
||||
+ hvs = kzalloc(sizeof(*hvs), GFP_KERNEL);
|
||||
+ if (!hvs)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ vsk->trans = hvs;
|
||||
+ hvs->vsk = vsk;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int hvs_connect(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *h = vsk->trans;
|
||||
+
|
||||
+ h->vm_srv_id = srv_id_template;
|
||||
+ h->host_srv_id = srv_id_template;
|
||||
+
|
||||
+ *((u32 *)&h->vm_srv_id) = vsk->local_addr.svm_port;
|
||||
+ *((u32 *)&h->host_srv_id) = vsk->remote_addr.svm_port;
|
||||
+
|
||||
+ return vmbus_send_tl_connect_request(&h->vm_srv_id, &h->host_srv_id);
|
||||
+}
|
||||
+
|
||||
+static int hvs_shutdown(struct vsock_sock *vsk, int mode)
|
||||
+{
|
||||
+ struct vmpipe_proto_header hdr;
|
||||
+ struct hvs_send_buf *send_buf;
|
||||
+ struct hvsock *hvs;
|
||||
+
|
||||
+ if (!(mode & SEND_SHUTDOWN))
|
||||
+ return 0;
|
||||
+
|
||||
+ hvs = vsk->trans;
|
||||
+
|
||||
+ send_buf = (struct hvs_send_buf *)&hdr;
|
||||
+
|
||||
+ /* It can't fail: see hvs_channel_writable_bytes(). */
|
||||
+ (void)hvs_send_data(hvs->chan, send_buf, 0);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void hvs_release(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ struct vmbus_channel *chan = hvs->chan;
|
||||
+
|
||||
+ if (chan)
|
||||
+ hvs_shutdown(vsk, RCV_SHUTDOWN | SEND_SHUTDOWN);
|
||||
+
|
||||
+ vsock_remove_sock(vsk);
|
||||
+}
|
||||
+
|
||||
+static void hvs_destruct(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ struct vmbus_channel *chan = hvs->chan;
|
||||
+
|
||||
+ if (chan)
|
||||
+ vmbus_hvsock_device_unregister(chan);
|
||||
+
|
||||
+ kfree(hvs);
|
||||
+}
|
||||
+
|
||||
+static int hvs_dgram_bind(struct vsock_sock *vsk, struct sockaddr_vm *addr)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static int hvs_dgram_dequeue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
+ size_t len, int flags)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static int hvs_dgram_enqueue(struct vsock_sock *vsk,
|
||||
+ struct sockaddr_vm *remote, struct msghdr *msg,
|
||||
+ size_t dgram_len)
|
||||
+{
|
||||
+ return -EOPNOTSUPP;
|
||||
+}
|
||||
+
|
||||
+static bool hvs_dgram_allow(u32 cid, u32 port)
|
||||
+{
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
+ size_t len, int flags)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ bool need_refill = !hvs->recv_desc;
|
||||
+ struct hvs_recv_buf *recv_buf;
|
||||
+ u32 payload_len, to_read;
|
||||
+ int ret;
|
||||
+
|
||||
+ if (flags & MSG_PEEK)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ if (need_refill) {
|
||||
+ hvs->recv_desc = hv_pkt_iter_first(hvs->chan);
|
||||
+ recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
+
|
||||
+ payload_len = recv_buf->hdr.data_size;
|
||||
+ if (payload_len == 0 || payload_len > HVS_MTU_SIZE)
|
||||
+ return -EIO;
|
||||
+
|
||||
+ hvs->recv_data_len = payload_len;
|
||||
+ hvs->recv_data_off = 0;
|
||||
+ } else {
|
||||
+ recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
+ }
|
||||
+
|
||||
+ to_read = min_t(u32, len, hvs->recv_data_len);
|
||||
+ ret = memcpy_to_msg(msg, recv_buf->data + hvs->recv_data_off, to_read);
|
||||
+ if (ret != 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ hvs->recv_data_len -= to_read;
|
||||
+
|
||||
+ if (hvs->recv_data_len == 0)
|
||||
+ hvs->recv_desc = hv_pkt_iter_next(hvs->chan, hvs->recv_desc);
|
||||
+ else
|
||||
+ hvs->recv_data_off += to_read;
|
||||
+
|
||||
+ return to_read;
|
||||
+}
|
||||
+
|
||||
+static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
+ size_t len)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ struct vmbus_channel *chan = hvs->chan;
|
||||
+ struct hvs_send_buf *send_buf;
|
||||
+ size_t to_write, max_writable, ret;
|
||||
+
|
||||
+ BUILD_BUG_ON(sizeof(*send_buf) != PAGE_SIZE_4K);
|
||||
+
|
||||
+ send_buf = kmalloc(sizeof(*send_buf), GFP_KERNEL);
|
||||
+ if (!send_buf)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ max_writable = hvs_channel_writable_bytes(chan);
|
||||
+ to_write = min_t(size_t, len, max_writable);
|
||||
+ to_write = min_t(size_t, to_write, HVS_SEND_BUF_SIZE);
|
||||
+
|
||||
+ ret = memcpy_from_msg(send_buf->data, msg, to_write);
|
||||
+ if (ret < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = hvs_send_data(hvs->chan, send_buf, to_write);
|
||||
+ if (ret < 0)
|
||||
+ goto out;
|
||||
+
|
||||
+ ret = to_write;
|
||||
+out:
|
||||
+ kfree(send_buf);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static s64 hvs_stream_has_data(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+ s64 ret;
|
||||
+
|
||||
+ switch (hvs_channel_readable_payload(hvs->chan)) {
|
||||
+ case 1:
|
||||
+ ret = 1;
|
||||
+ break;
|
||||
+ case 0:
|
||||
+ vsk->peer_shutdown |= SEND_SHUTDOWN;
|
||||
+ ret = 0;
|
||||
+ break;
|
||||
+ default: /* -1 */
|
||||
+ ret = 0;
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static s64 hvs_stream_has_space(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+
|
||||
+ return hvs_channel_writable_bytes(hvs->chan);
|
||||
+}
|
||||
+
|
||||
+static u64 hvs_stream_rcvhiwat(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ return HVS_MTU_SIZE + 1;
|
||||
+}
|
||||
+
|
||||
+static bool hvs_stream_is_active(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+
|
||||
+ return hvs->chan != NULL;
|
||||
+}
|
||||
+
|
||||
+static bool hvs_stream_allow(u32 cid, u32 port)
|
||||
+{
|
||||
+ static const u32 valid_cids[] = {
|
||||
+ VMADDR_CID_ANY,
|
||||
+ VMADDR_CID_HOST,
|
||||
+ };
|
||||
+ int i;
|
||||
+
|
||||
+ /* The host's port range [MIN_HOST_EPHEMERAL_PORT, 0xFFFFFFFF) is
|
||||
+ * reserved as ephemeral ports, which are used as the host's ports
|
||||
+ * when the host initiates connections.
|
||||
+ */
|
||||
+ if (port > MAX_HOST_LISTEN_PORT)
|
||||
+ return false;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(valid_cids); i++) {
|
||||
+ if (cid == valid_cids[i])
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_poll_in(struct vsock_sock *vsk, size_t target, bool *readable)
|
||||
+{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+
|
||||
+ *readable = hvs_channel_readable(hvs->chan);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_poll_out(struct vsock_sock *vsk, size_t target, bool *writable)
|
||||
+{
|
||||
+ /* Report writable only if there is enough space */
|
||||
+ *writable = hvs_stream_has_space(vsk) >= HVS_SEND_BUF_SIZE;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_recv_init(struct vsock_sock *vsk, size_t target,
|
||||
+ struct vsock_transport_recv_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_recv_pre_block(struct vsock_sock *vsk, size_t target,
|
||||
+ struct vsock_transport_recv_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_recv_pre_dequeue(struct vsock_sock *vsk, size_t target,
|
||||
+ struct vsock_transport_recv_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_recv_post_dequeue(struct vsock_sock *vsk, size_t target,
|
||||
+ ssize_t copied, bool data_read,
|
||||
+ struct vsock_transport_recv_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_send_init(struct vsock_sock *vsk,
|
||||
+ struct vsock_transport_send_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_send_pre_block(struct vsock_sock *vsk,
|
||||
+ struct vsock_transport_send_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_send_pre_enqueue(struct vsock_sock *vsk,
|
||||
+ struct vsock_transport_send_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static
|
||||
+int hvs_notify_send_post_enqueue(struct vsock_sock *vsk, ssize_t written,
|
||||
+ struct vsock_transport_send_notify_data *d)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void hvs_set_buffer_size(struct vsock_sock *vsk, u64 val)
|
||||
+{
|
||||
+ /* Ignored. */
|
||||
+}
|
||||
+
|
||||
+static void hvs_set_min_buffer_size(struct vsock_sock *vsk, u64 val)
|
||||
+{
|
||||
+ /* Ignored. */
|
||||
+}
|
||||
+
|
||||
+static void hvs_set_max_buffer_size(struct vsock_sock *vsk, u64 val)
|
||||
+{
|
||||
+ /* Ignored. */
|
||||
+}
|
||||
+
|
||||
+static u64 hvs_get_buffer_size(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ return -ENOPROTOOPT;
|
||||
+}
|
||||
+
|
||||
+static u64 hvs_get_min_buffer_size(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ return -ENOPROTOOPT;
|
||||
+}
|
||||
+
|
||||
+static u64 hvs_get_max_buffer_size(struct vsock_sock *vsk)
|
||||
+{
|
||||
+ return -ENOPROTOOPT;
|
||||
+}
|
||||
+
|
||||
+static struct vsock_transport hvs_transport = {
|
||||
+ .get_local_cid = hvs_get_local_cid,
|
||||
+
|
||||
+ .init = hvs_sock_init,
|
||||
+ .destruct = hvs_destruct,
|
||||
+ .release = hvs_release,
|
||||
+ .connect = hvs_connect,
|
||||
+ .shutdown = hvs_shutdown,
|
||||
+
|
||||
+ .dgram_bind = hvs_dgram_bind,
|
||||
+ .dgram_dequeue = hvs_dgram_dequeue,
|
||||
+ .dgram_enqueue = hvs_dgram_enqueue,
|
||||
+ .dgram_allow = hvs_dgram_allow,
|
||||
+
|
||||
+ .stream_dequeue = hvs_stream_dequeue,
|
||||
+ .stream_enqueue = hvs_stream_enqueue,
|
||||
+ .stream_has_data = hvs_stream_has_data,
|
||||
+ .stream_has_space = hvs_stream_has_space,
|
||||
+ .stream_rcvhiwat = hvs_stream_rcvhiwat,
|
||||
+ .stream_is_active = hvs_stream_is_active,
|
||||
+ .stream_allow = hvs_stream_allow,
|
||||
+
|
||||
+ .notify_poll_in = hvs_notify_poll_in,
|
||||
+ .notify_poll_out = hvs_notify_poll_out,
|
||||
+ .notify_recv_init = hvs_notify_recv_init,
|
||||
+ .notify_recv_pre_block = hvs_notify_recv_pre_block,
|
||||
+ .notify_recv_pre_dequeue = hvs_notify_recv_pre_dequeue,
|
||||
+ .notify_recv_post_dequeue = hvs_notify_recv_post_dequeue,
|
||||
+ .notify_send_init = hvs_notify_send_init,
|
||||
+ .notify_send_pre_block = hvs_notify_send_pre_block,
|
||||
+ .notify_send_pre_enqueue = hvs_notify_send_pre_enqueue,
|
||||
+ .notify_send_post_enqueue = hvs_notify_send_post_enqueue,
|
||||
+
|
||||
+ .set_buffer_size = hvs_set_buffer_size,
|
||||
+ .set_min_buffer_size = hvs_set_min_buffer_size,
|
||||
+ .set_max_buffer_size = hvs_set_max_buffer_size,
|
||||
+ .get_buffer_size = hvs_get_buffer_size,
|
||||
+ .get_min_buffer_size = hvs_get_min_buffer_size,
|
||||
+ .get_max_buffer_size = hvs_get_max_buffer_size,
|
||||
+};
|
||||
+
|
||||
+static int hvs_probe(struct hv_device *hdev,
|
||||
+ const struct hv_vmbus_device_id *dev_id)
|
||||
+{
|
||||
+ struct vmbus_channel *chan = hdev->channel;
|
||||
+
|
||||
+ hvs_open_connection(chan);
|
||||
+
|
||||
+ /* Always return success to suppress the unnecessary error message
|
||||
+ * in vmbus_probe(): on error the host will rescind the device in
|
||||
+ * 30 seconds and we can do cleanup at that time in
|
||||
+ * vmbus_onoffer_rescind().
|
||||
+ */
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int hvs_remove(struct hv_device *hdev)
|
||||
+{
|
||||
+ struct vmbus_channel *chan = hdev->channel;
|
||||
+
|
||||
+ vmbus_close(chan);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+/* This isn't really used. See vmbus_match() and vmbus_probe() */
|
||||
+static const struct hv_vmbus_device_id id_table[] = {
|
||||
+ {},
|
||||
+};
|
||||
+
|
||||
+static struct hv_driver hvs_drv = {
|
||||
+ .name = "hv_sock",
|
||||
+ .hvsock = true,
|
||||
+ .id_table = id_table,
|
||||
+ .probe = hvs_probe,
|
||||
+ .remove = hvs_remove,
|
||||
+};
|
||||
+
|
||||
+static int __init hvs_init(void)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ if (vmbus_proto_version < VERSION_WIN10)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ ret = vmbus_driver_register(&hvs_drv);
|
||||
+ if (ret != 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = vsock_core_init(&hvs_transport);
|
||||
+ if (ret) {
|
||||
+ vmbus_driver_unregister(&hvs_drv);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void __exit hvs_exit(void)
|
||||
+{
|
||||
+ vsock_core_exit();
|
||||
+ vmbus_driver_unregister(&hvs_drv);
|
||||
+}
|
||||
+
|
||||
+module_init(hvs_init);
|
||||
+module_exit(hvs_exit);
|
||||
+
|
||||
+MODULE_DESCRIPTION("Hyper-V sockets");
|
||||
+MODULE_VERSION("1.0.0");
|
||||
+MODULE_LICENSE("GPL");
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,64 +0,0 @@
|
||||
From 0127ff8979dc662d1174e6658ad8dcf77c38ea16 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 16:57:29 -0600
|
||||
Subject: [PATCH 04/12] VMCI: only try to load on VMware hypervisor
|
||||
|
||||
Without the patch, vmw_vsock_vmci_transport.ko and vmw_vmci.ko can
|
||||
automatically load when an application creates an AF_VSOCK socket.
|
||||
|
||||
This is the expected good behavior on VMware hypervisor, but as we
|
||||
are adding hv_sock.ko (i.e. Hyper-V transport for AF_VSOCK), we should
|
||||
make sure vmw_vsock_vmci_transport.ko can't load on Hyper-V, otherwise
|
||||
there is a -EBUSY conflict when both vmw_vsock_vmci_transport.ko and
|
||||
hv_sock.ko try to call vsock_core_init().
|
||||
|
||||
On the other hand, hv_sock.ko can only load on Hyper-V, because it
|
||||
depends on hv_vmbus.ko, which deteces Hyper-V in hv_acpi_init().
|
||||
|
||||
KVM's vsock_virtio_transport doesn't have the issue because it doesn't
|
||||
define MODULE_ALIAS_NETPROTO(PF_VSOCK).
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Cc: Alok Kataria <akataria@vmware.com>
|
||||
Cc: Andy King <acking@vmware.com>
|
||||
Cc: Adit Ranadive <aditr@vmware.com>
|
||||
Cc: George Zhang <georgezhang@vmware.com>
|
||||
Cc: Jorgen Hansen <jhansen@vmware.com>
|
||||
Cc: K. Y. Srinivasan <kys@microsoft.com>
|
||||
Cc: Haiyang Zhang <haiyangz@microsoft.com>
|
||||
Cc: Stephen Hemminger <sthemmin@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit 27e512021e36c67dd1c773a52b23d71896c80602)
|
||||
---
|
||||
drivers/misc/vmw_vmci/vmci_driver.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c
|
||||
index d7eaf1eb11e7..1789ea71ff5d 100644
|
||||
--- a/drivers/misc/vmw_vmci/vmci_driver.c
|
||||
+++ b/drivers/misc/vmw_vmci/vmci_driver.c
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
+#include <linux/hypervisor.h>
|
||||
|
||||
#include "vmci_driver.h"
|
||||
#include "vmci_event.h"
|
||||
@@ -58,6 +59,13 @@ static int __init vmci_drv_init(void)
|
||||
int vmci_err;
|
||||
int error;
|
||||
|
||||
+ /*
|
||||
+ * Check if we are running on VMware's hypervisor and bail out
|
||||
+ * if we are not.
|
||||
+ */
|
||||
+ if (x86_hyper != &x86_hyper_vmware)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
vmci_err = vmci_event_init();
|
||||
if (vmci_err < VMCI_SUCCESS) {
|
||||
pr_err("Failed to initialize VMCIEvent (result=%d)\n",
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,30 +0,0 @@
|
||||
From bb149fe950de91e8207c8eaa2da5617d9b36fc77 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 16:57:35 -0600
|
||||
Subject: [PATCH 05/12] hv_sock: add the support of auto-loading
|
||||
|
||||
After we disable VMWare virtual sockets driver's auto-loading on Hyper-V,
|
||||
we can enable hv_sock's auto-loading now.
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Cc: K. Y. Srinivasan <kys@microsoft.com>
|
||||
Cc: Haiyang Zhang <haiyangz@microsoft.com>
|
||||
Cc: Stephen Hemminger <sthemmin@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit e2c1d1b8e8d17cc9b423688d59ad486c5f38deca)
|
||||
---
|
||||
net/vmw_vsock/hyperv_transport.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
|
||||
index fd89bf357617..f465b0b662df 100644
|
||||
--- a/net/vmw_vsock/hyperv_transport.c
|
||||
+++ b/net/vmw_vsock/hyperv_transport.c
|
||||
@@ -827,3 +827,4 @@ module_exit(hvs_exit);
|
||||
MODULE_DESCRIPTION("Hyper-V sockets");
|
||||
MODULE_VERSION("1.0.0");
|
||||
MODULE_LICENSE("GPL");
|
||||
+MODULE_ALIAS_NETPROTO(PF_VSOCK);
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,430 +0,0 @@
|
||||
From f2b16b13af015d34ecccf1ecf656bff21062dbbb Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 5 May 2017 18:52:02 -0600
|
||||
Subject: [PATCH 06/12] tools: hv_sock: 2 simple test cases.
|
||||
|
||||
Please read this document first:
|
||||
https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/make-integration-service
|
||||
|
||||
And you may want to have a look at
|
||||
https://github.com/dcui/linux/commit/691aff936c0fa6fc24e2662c0e8cc6ab65509600#diff-2cf9109d84c1ba75b09e40090f4a2176R100
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit e015b0a767dcab79b8b8361516f3f4322cdc90a7)
|
||||
---
|
||||
tools/hv/hv_sock/test-001/client_in_vm.c | 38 +++++++++
|
||||
tools/hv/hv_sock/test-001/server_on_host.c | 128 +++++++++++++++++++++++++++++
|
||||
tools/hv/hv_sock/test-002/client_on_host.c | 127 ++++++++++++++++++++++++++++
|
||||
tools/hv/hv_sock/test-002/server_in_vm.c | 85 +++++++++++++++++++
|
||||
4 files changed, 378 insertions(+)
|
||||
create mode 100644 tools/hv/hv_sock/test-001/client_in_vm.c
|
||||
create mode 100644 tools/hv/hv_sock/test-001/server_on_host.c
|
||||
create mode 100644 tools/hv/hv_sock/test-002/client_on_host.c
|
||||
create mode 100644 tools/hv/hv_sock/test-002/server_in_vm.c
|
||||
|
||||
diff --git a/tools/hv/hv_sock/test-001/client_in_vm.c b/tools/hv/hv_sock/test-001/client_in_vm.c
|
||||
new file mode 100644
|
||||
index 000000000000..2e2371b13fa7
|
||||
--- /dev/null
|
||||
+++ b/tools/hv/hv_sock/test-001/client_in_vm.c
|
||||
@@ -0,0 +1,38 @@
|
||||
+/* The program runs in Linux VM. */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <linux/vm_sockets.h>
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ int fd;
|
||||
+
|
||||
+ struct sockaddr_vm sa = {
|
||||
+ .svm_family = AF_VSOCK,
|
||||
+ .svm_reserved1 = 0,
|
||||
+ .svm_cid = VMADDR_CID_ANY,
|
||||
+ };
|
||||
+
|
||||
+ /* Connecting to the host's 00000808-facb-11e6-bd58-64006a7986d3 */
|
||||
+ sa.svm_port = 0x808;
|
||||
+
|
||||
+ fd = socket(AF_VSOCK, SOCK_STREAM, 0);
|
||||
+ if (fd < 0) {
|
||||
+ perror("socket");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (connect(fd, (struct sockaddr*)&sa, sizeof(sa)) != 0) {
|
||||
+ perror("connect");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ printf("Connected to the host.\n");
|
||||
+
|
||||
+ close(fd);
|
||||
+ printf("Closed the connection.\n");
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/tools/hv/hv_sock/test-001/server_on_host.c b/tools/hv/hv_sock/test-001/server_on_host.c
|
||||
new file mode 100644
|
||||
index 000000000000..22c48e8d3789
|
||||
--- /dev/null
|
||||
+++ b/tools/hv/hv_sock/test-001/server_on_host.c
|
||||
@@ -0,0 +1,128 @@
|
||||
+/* The program runs on Windows 10 or Windows Server 2016 host or newer. */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdint.h>
|
||||
+#include <winsock2.h>
|
||||
+#include <ws2def.h>
|
||||
+#include <initguid.h>
|
||||
+
|
||||
+#pragma comment(lib, "ws2_32.lib")
|
||||
+
|
||||
+#ifndef AF_HYPERV
|
||||
+#define AF_HYPERV 34
|
||||
+#define HV_PROTOCOL_RAW 1
|
||||
+
|
||||
+typedef struct _SOCKADDR_HV
|
||||
+{
|
||||
+ ADDRESS_FAMILY Family;
|
||||
+ USHORT Reserved;
|
||||
+ GUID VmId;
|
||||
+ GUID ServiceId;
|
||||
+} SOCKADDR_HV, *PSOCKADDR_HV;
|
||||
+
|
||||
+DEFINE_GUID(HV_GUID_SELF, 0x00000000, 0x0000, 0x0000,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
+#endif /* AF_HYPERV */
|
||||
+
|
||||
+#define VMADDR_PORT_ANY 0xFFFFFFFF
|
||||
+
|
||||
+/* 00000000-facb-11e6-bd58-64006a7986d3 */
|
||||
+DEFINE_GUID(HVSOCK_LINUX_TEMPLATE, 0x00000000, 0xfacb, 0x11e6,
|
||||
+ 0xbd, 0x58, 0x64, 0x00, 0x6a, 0x79, 0x86, 0xd3);
|
||||
+
|
||||
+static const GUID VsockServiceIdTemplate = HVSOCK_LINUX_TEMPLATE;
|
||||
+
|
||||
+bool TryConvertVsockPortToServiceId(uint32_t port, GUID *serviceId)
|
||||
+{
|
||||
+ if (port == VMADDR_PORT_ANY)
|
||||
+ return false;
|
||||
+
|
||||
+ *serviceId = VsockServiceIdTemplate;
|
||||
+ serviceId->Data1 = port;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool TryConvertServiceIdToVsockPort(const GUID *serviceId, uint32_t *port)
|
||||
+{
|
||||
+ if (memcmp(&serviceId->Data2, &VsockServiceIdTemplate.Data2,
|
||||
+ sizeof(GUID) - sizeof(uint32_t)) != 0 ||
|
||||
+ serviceId->Data1 == VMADDR_PORT_ANY) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ *port = serviceId->Data1;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+int CreateListenSocket(uint32_t port, SOCKET *result_fd)
|
||||
+{
|
||||
+ SOCKADDR_HV localAddr;
|
||||
+ SOCKET fd;
|
||||
+ int ret;
|
||||
+
|
||||
+ fd = socket(AF_HYPERV, SOCK_STREAM, HV_PROTOCOL_RAW);
|
||||
+ if (fd == INVALID_SOCKET) {
|
||||
+ printf("socket() failed: error = %d\n", WSAGetLastError());
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memset(&localAddr, 0, sizeof(SOCKADDR_HV));
|
||||
+ localAddr.Family = AF_HYPERV;
|
||||
+ localAddr.VmId = HV_GUID_SELF;
|
||||
+ TryConvertVsockPortToServiceId(port, &localAddr.ServiceId);
|
||||
+
|
||||
+ ret = bind(fd, (SOCKADDR *)&localAddr, sizeof(SOCKADDR_HV));
|
||||
+ if (ret == SOCKET_ERROR) {
|
||||
+ printf("bind() failed: error = %d\n", WSAGetLastError());
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ ret = listen(fd, 10);
|
||||
+ if (ret == SOCKET_ERROR) {
|
||||
+ printf("listen() failed: error = %d\n", WSAGetLastError());
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ *result_fd = fd;
|
||||
+ printf("Listening on fd = 0x%d, local port = 0x%x\n", fd, port);
|
||||
+ return 0;
|
||||
+err:
|
||||
+ closesocket(fd);
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ WSADATA wsaData;
|
||||
+ SOCKADDR_HV remoteAddr;
|
||||
+ int remoteAddrLen;
|
||||
+ SOCKET fd;
|
||||
+ SOCKET children[100];
|
||||
+ int i, ret;
|
||||
+
|
||||
+ // Initialize Winsock
|
||||
+ ret = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
+ if (ret != NO_ERROR) {
|
||||
+ printf("WSAStartup() failed with error: %d\n", ret);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ // We'll listen on 00000808-facb-11e6-bd58-64006a7986d3
|
||||
+ if (CreateListenSocket(0x808, &fd) < 0) {
|
||||
+ printf("failed to listen!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ for (i = 0; i < ARRAYSIZE(children); i++) {
|
||||
+ remoteAddrLen = sizeof(SOCKADDR_HV);
|
||||
+ children[i] = accept(fd, (sockaddr *)&remoteAddr, &remoteAddrLen);
|
||||
+ closesocket(children[i]);
|
||||
+ printf("Got a connection and closed it.\n");
|
||||
+ }
|
||||
+
|
||||
+ closesocket(fd);
|
||||
+out:
|
||||
+ WSACleanup();
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/tools/hv/hv_sock/test-002/client_on_host.c b/tools/hv/hv_sock/test-002/client_on_host.c
|
||||
new file mode 100644
|
||||
index 000000000000..ed5ae99fbfba
|
||||
--- /dev/null
|
||||
+++ b/tools/hv/hv_sock/test-002/client_on_host.c
|
||||
@@ -0,0 +1,127 @@
|
||||
+/* The program runs on Windows 10 or Windows Server 2016 host or newer. */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <stdint.h>
|
||||
+#include <winsock2.h>
|
||||
+#include <ws2def.h>
|
||||
+#include <initguid.h>
|
||||
+#include <rpc.h> /* for UuidFromStringA() */
|
||||
+#pragma comment(lib, "ws2_32.lib")
|
||||
+#pragma comment(lib, "rpcrt4.lib")
|
||||
+
|
||||
+#ifndef AF_HYPERV
|
||||
+#define AF_HYPERV 34
|
||||
+#define HV_PROTOCOL_RAW 1
|
||||
+
|
||||
+typedef struct _SOCKADDR_HV
|
||||
+{
|
||||
+ ADDRESS_FAMILY Family;
|
||||
+ USHORT Reserved;
|
||||
+ GUID VmId;
|
||||
+ GUID ServiceId;
|
||||
+}SOCKADDR_HV, *PSOCKADDR_HV;
|
||||
+
|
||||
+DEFINE_GUID(HV_GUID_SELF, 0x00000000, 0x0000, 0x0000,
|
||||
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
|
||||
+#endif /* AF_HYPERV */
|
||||
+
|
||||
+#define VMADDR_PORT_ANY 0xFFFFFFFF
|
||||
+
|
||||
+/* 00000000-facb-11e6-bd58-64006a7986d3 */
|
||||
+DEFINE_GUID(HVSOCK_LINUX_TEMPLATE, 0x00000000, 0xfacb, 0x11e6,
|
||||
+ 0xbd, 0x58, 0x64, 0x00, 0x6a, 0x79, 0x86, 0xd3);
|
||||
+
|
||||
+static const GUID VsockServiceIdTemplate = HVSOCK_LINUX_TEMPLATE;
|
||||
+
|
||||
+bool TryConvertVsockPortToServiceId(uint32_t port, GUID *serviceId)
|
||||
+{
|
||||
+ if (port == VMADDR_PORT_ANY)
|
||||
+ return false;
|
||||
+
|
||||
+ *serviceId = VsockServiceIdTemplate;
|
||||
+ serviceId->Data1 = port;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool TryConvertServiceIdToVsockPort(const GUID *serviceId, uint32_t *port)
|
||||
+{
|
||||
+ if (memcmp(&serviceId->Data2, &VsockServiceIdTemplate.Data2,
|
||||
+ sizeof(GUID) - sizeof(uint32_t)) != 0 ||
|
||||
+ serviceId->Data1 == VMADDR_PORT_ANY) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ *port = serviceId->Data1;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+int ConnectToVM(const SOCKADDR_HV *remoteAddr, SOCKET *result_fd)
|
||||
+{
|
||||
+ SOCKADDR_HV localAddr;
|
||||
+ SOCKET fd;
|
||||
+ uint32_t port;
|
||||
+ int ret;
|
||||
+
|
||||
+ fd = socket(AF_HYPERV, SOCK_STREAM, HV_PROTOCOL_RAW);
|
||||
+ if (fd == INVALID_SOCKET) {
|
||||
+ printf("socket() failed with error: %d\n", WSAGetLastError());
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ ret = connect(fd, (SOCKADDR *)remoteAddr, sizeof(SOCKADDR_HV));
|
||||
+ if (ret == SOCKET_ERROR) {
|
||||
+ printf("connect() failed: error = %d\n", WSAGetLastError());
|
||||
+ closesocket(fd);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ *result_fd = fd;
|
||||
+ printf("Connected to the VM: fd = 0x%x\n", fd);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ const char *msg = "***Hello! This message is from the host!***\n";
|
||||
+ WSADATA wsaData;
|
||||
+ SOCKADDR_HV remoteAddr;
|
||||
+ SOCKET fd;
|
||||
+ int ret;
|
||||
+
|
||||
+ // Initialize Winsock
|
||||
+ ret = WSAStartup(MAKEWORD(2, 2), &wsaData);
|
||||
+ if (ret != NO_ERROR) {
|
||||
+ printf("WSAStartup() failed with error: %d\n", ret);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ memset(&remoteAddr, 0, sizeof(SOCKADDR_HV));
|
||||
+ remoteAddr.Family = AF_HYPERV;
|
||||
+
|
||||
+ // The Linux VM is listening in Vsock port 0x2017
|
||||
+ TryConvertVsockPortToServiceId(0x2017, &remoteAddr.ServiceId);
|
||||
+
|
||||
+ // This is the "remote" VM's VMID got by the PowerShell command
|
||||
+ // "Get-VM -Name <the_VM_name> | ft id".
|
||||
+ //
|
||||
+ // Change it for your own VM.
|
||||
+ if (UuidFromStringA((RPC_CSTR)"c2624c46-1212-484a-8e28-83dd15fef815",
|
||||
+ &remoteAddr.VmId) != RPC_S_OK) {
|
||||
+ printf("Failed to parse the remote VMID: %d\n", GetLastError());
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ if (ConnectToVM(&remoteAddr, &fd) < 0) {
|
||||
+ printf("Failed to connect to the VM!\n");
|
||||
+ ret = -1;
|
||||
+ goto out;
|
||||
+ }
|
||||
+ ret = send(fd, msg, strlen(msg), 0);
|
||||
+ printf("Sent a msg to the VM: msg_len = %d.\nExited.\n", ret);
|
||||
+
|
||||
+ closesocket(fd);
|
||||
+out:
|
||||
+ WSACleanup();
|
||||
+ return ret;
|
||||
+}
|
||||
diff --git a/tools/hv/hv_sock/test-002/server_in_vm.c b/tools/hv/hv_sock/test-002/server_in_vm.c
|
||||
new file mode 100644
|
||||
index 000000000000..fb4370c53152
|
||||
--- /dev/null
|
||||
+++ b/tools/hv/hv_sock/test-002/server_in_vm.c
|
||||
@@ -0,0 +1,85 @@
|
||||
+/* The program runs in Linux VM. */
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <stdbool.h>
|
||||
+#include <unistd.h>
|
||||
+#include <fcntl.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/socket.h>
|
||||
+#include <sys/select.h>
|
||||
+#include <netdb.h>
|
||||
+#include <linux/vm_sockets.h>
|
||||
+
|
||||
+int main()
|
||||
+{
|
||||
+ uint32_t port = 0x2017;
|
||||
+
|
||||
+ int listen_fd;
|
||||
+ int client_fd;
|
||||
+
|
||||
+ struct sockaddr_vm sa_listen = {
|
||||
+ .svm_family = AF_VSOCK,
|
||||
+ .svm_reserved1 = 0,
|
||||
+ .svm_cid = VMADDR_CID_ANY,
|
||||
+ };
|
||||
+
|
||||
+ struct sockaddr_vm sa_client;
|
||||
+ socklen_t socklen_client;
|
||||
+
|
||||
+ char buf[4096];
|
||||
+ int len;
|
||||
+
|
||||
+ /* We'll listen on 00002017-facb-11e6-bd58-64006a7986d3 */
|
||||
+ sa_listen.svm_port = port;
|
||||
+
|
||||
+ listen_fd = socket(AF_VSOCK, SOCK_STREAM, 0);
|
||||
+ if (listen_fd < 0) {
|
||||
+ perror("socket()");
|
||||
+ exit(-1);
|
||||
+ }
|
||||
+
|
||||
+ if (bind(listen_fd, (struct sockaddr *)&sa_listen,
|
||||
+ sizeof(sa_listen)) != 0) {
|
||||
+ perror("bind()");
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ if (listen(listen_fd, 10) != 0) {
|
||||
+ perror("listen()");
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ printf("Listening on port 0x%x...\n", port);
|
||||
+
|
||||
+ socklen_client = sizeof(sa_client);
|
||||
+ client_fd = accept(listen_fd, (struct sockaddr*)&sa_client,
|
||||
+ &socklen_client);
|
||||
+ if (client_fd < 0) {
|
||||
+ perror("accept()");
|
||||
+ goto err;
|
||||
+ }
|
||||
+
|
||||
+ printf("Got a connection from the host: cid=0x%x, port=0x%x.\n",
|
||||
+ sa_client.svm_cid, sa_client.svm_port);
|
||||
+
|
||||
+ do {
|
||||
+ printf("Reading data from the connection...\n");
|
||||
+ len = read(client_fd, buf, sizeof(buf));
|
||||
+ if (len > 0) {
|
||||
+ printf("Read %d bytes:\n", len);
|
||||
+ fflush(stdout);
|
||||
+ write(STDOUT_FILENO, buf, len);
|
||||
+ }
|
||||
+ } while (len > 0);
|
||||
+
|
||||
+ printf("The other end closed the connection.\n");
|
||||
+
|
||||
+ close(client_fd);
|
||||
+ close(listen_fd);
|
||||
+ return 0;
|
||||
+err:
|
||||
+ close(listen_fd);
|
||||
+ return -1;
|
||||
+}
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,113 +0,0 @@
|
||||
From f5027645f58894e602ae72dbbe17d6614cb92418 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Tue, 16 May 2017 22:14:03 +0800
|
||||
Subject: [PATCH 07/12] hvsock: fix a race in hvs_stream_dequeue()
|
||||
|
||||
If hv_pkt_iter_next() returns a non-NULL pointer, we must update
|
||||
the recv_data_len/data_off info, otherwise the received data will
|
||||
be silently dropped, and let's fix hvs_stream_has_data() accordingly.
|
||||
|
||||
Thank Rolf for finding this!
|
||||
|
||||
Reported-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit b9cc90e62104bd001b05d897f84cb7d30d1780bb)
|
||||
---
|
||||
net/vmw_vsock/hyperv_transport.c | 50 +++++++++++++++++++++++++++++-----------
|
||||
1 file changed, 36 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
|
||||
index f465b0b662df..30154836acd0 100644
|
||||
--- a/net/vmw_vsock/hyperv_transport.c
|
||||
+++ b/net/vmw_vsock/hyperv_transport.c
|
||||
@@ -476,13 +476,33 @@ static bool hvs_dgram_allow(u32 cid, u32 port)
|
||||
return false;
|
||||
}
|
||||
|
||||
+static int hvs_update_recv_data(struct hvsock *hvs)
|
||||
+{
|
||||
+ struct hvs_recv_buf *recv_buf;
|
||||
+ u32 payload_len;
|
||||
+
|
||||
+ recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
+ payload_len = recv_buf->hdr.data_size;
|
||||
+
|
||||
+ if (payload_len > HVS_MTU_SIZE)
|
||||
+ return -EIO;
|
||||
+
|
||||
+ if (payload_len == 0)
|
||||
+ hvs->vsk->peer_shutdown |= SEND_SHUTDOWN;
|
||||
+
|
||||
+ hvs->recv_data_len = payload_len;
|
||||
+ hvs->recv_data_off = 0;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
size_t len, int flags)
|
||||
{
|
||||
struct hvsock *hvs = vsk->trans;
|
||||
bool need_refill = !hvs->recv_desc;
|
||||
struct hvs_recv_buf *recv_buf;
|
||||
- u32 payload_len, to_read;
|
||||
+ u32 to_read;
|
||||
int ret;
|
||||
|
||||
if (flags & MSG_PEEK)
|
||||
@@ -490,29 +510,28 @@ static ssize_t hvs_stream_dequeue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
|
||||
if (need_refill) {
|
||||
hvs->recv_desc = hv_pkt_iter_first(hvs->chan);
|
||||
- recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
-
|
||||
- payload_len = recv_buf->hdr.data_size;
|
||||
- if (payload_len == 0 || payload_len > HVS_MTU_SIZE)
|
||||
- return -EIO;
|
||||
-
|
||||
- hvs->recv_data_len = payload_len;
|
||||
- hvs->recv_data_off = 0;
|
||||
- } else {
|
||||
- recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
+ ret = hvs_update_recv_data(hvs);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
+ recv_buf = (struct hvs_recv_buf *)(hvs->recv_desc + 1);
|
||||
to_read = min_t(u32, len, hvs->recv_data_len);
|
||||
ret = memcpy_to_msg(msg, recv_buf->data + hvs->recv_data_off, to_read);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
hvs->recv_data_len -= to_read;
|
||||
-
|
||||
- if (hvs->recv_data_len == 0)
|
||||
+ if (hvs->recv_data_len == 0) {
|
||||
hvs->recv_desc = hv_pkt_iter_next(hvs->chan, hvs->recv_desc);
|
||||
- else
|
||||
+ if (hvs->recv_desc) {
|
||||
+ ret = hvs_update_recv_data(hvs);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ }
|
||||
+ } else {
|
||||
hvs->recv_data_off += to_read;
|
||||
+ }
|
||||
|
||||
return to_read;
|
||||
}
|
||||
@@ -554,6 +573,9 @@ static s64 hvs_stream_has_data(struct vsock_sock *vsk)
|
||||
struct hvsock *hvs = vsk->trans;
|
||||
s64 ret;
|
||||
|
||||
+ if (hvs->recv_data_len > 0)
|
||||
+ return 1;
|
||||
+
|
||||
switch (hvs_channel_readable_payload(hvs->chan)) {
|
||||
case 1:
|
||||
ret = 1;
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,49 +0,0 @@
|
||||
From 7f4c7966ea61834e1eec19f533e1733b61b37083 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 19 May 2017 21:49:59 +0800
|
||||
Subject: [PATCH 08/12] hvsock: fix vsock_dequeue/enqueue_accept race
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit 022c888e809721a67ecd3072e6331cbdaab45536)
|
||||
---
|
||||
net/vmw_vsock/af_vsock.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
|
||||
index dfc8c51e4d74..b7b2c66d91fd 100644
|
||||
--- a/net/vmw_vsock/af_vsock.c
|
||||
+++ b/net/vmw_vsock/af_vsock.c
|
||||
@@ -126,6 +126,7 @@ static struct proto vsock_proto = {
|
||||
|
||||
static const struct vsock_transport *transport;
|
||||
static DEFINE_MUTEX(vsock_register_mutex);
|
||||
+static DEFINE_SPINLOCK(vsock_accept_queue_lock);
|
||||
|
||||
/**** EXPORTS ****/
|
||||
|
||||
@@ -406,7 +407,10 @@ void vsock_enqueue_accept(struct sock *listener, struct sock *connected)
|
||||
|
||||
sock_hold(connected);
|
||||
sock_hold(listener);
|
||||
+
|
||||
+ spin_lock(&vsock_accept_queue_lock);
|
||||
list_add_tail(&vconnected->accept_queue, &vlistener->accept_queue);
|
||||
+ spin_unlock(&vsock_accept_queue_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vsock_enqueue_accept);
|
||||
|
||||
@@ -423,7 +427,10 @@ static struct sock *vsock_dequeue_accept(struct sock *listener)
|
||||
vconnected = list_entry(vlistener->accept_queue.next,
|
||||
struct vsock_sock, accept_queue);
|
||||
|
||||
+ spin_lock(&vsock_accept_queue_lock);
|
||||
list_del_init(&vconnected->accept_queue);
|
||||
+ spin_unlock(&vsock_accept_queue_lock);
|
||||
+
|
||||
sock_put(listener);
|
||||
/* The caller will need a reference on the connected socket so we let
|
||||
* it call sock_put().
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,133 +0,0 @@
|
||||
From 569b14b7ef62686eaaa22a0e41bcc84686b4d32e Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Wed, 21 Jun 2017 22:30:42 +0800
|
||||
Subject: [PATCH 09/12] hv-sock: a temporary workaround for the
|
||||
pending_send_size issue
|
||||
|
||||
While I'm trying to find out the root cause, I believe this can work
|
||||
as a good temporary workround for internal uses...
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit 7592de58cbf8d199d721503385c20a02743425a9)
|
||||
---
|
||||
net/vmw_vsock/af_vsock.c | 7 +++++--
|
||||
net/vmw_vsock/hyperv_transport.c | 30 ++++++++++++++++++++++++------
|
||||
2 files changed, 29 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
|
||||
index b7b2c66d91fd..4ebc1131c32d 100644
|
||||
--- a/net/vmw_vsock/af_vsock.c
|
||||
+++ b/net/vmw_vsock/af_vsock.c
|
||||
@@ -1544,7 +1544,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
struct sock *sk;
|
||||
struct vsock_sock *vsk;
|
||||
ssize_t total_written;
|
||||
- long timeout;
|
||||
+ long timeout, timeout_once;
|
||||
int err;
|
||||
struct vsock_transport_send_notify_data send_data;
|
||||
DEFINE_WAIT_FUNC(wait, woken_wake_function);
|
||||
@@ -1613,7 +1613,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
}
|
||||
|
||||
release_sock(sk);
|
||||
- timeout = wait_woken(&wait, TASK_INTERRUPTIBLE, timeout);
|
||||
+ timeout_once = wait_woken(&wait, TASK_INTERRUPTIBLE, 1);
|
||||
lock_sock(sk);
|
||||
if (signal_pending(current)) {
|
||||
err = sock_intr_errno(timeout);
|
||||
@@ -1623,6 +1623,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
|
||||
err = -EAGAIN;
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
goto out_err;
|
||||
+ } else {
|
||||
+ if (timeout_once == 0)
|
||||
+ timeout--;
|
||||
}
|
||||
}
|
||||
remove_wait_queue(sk_sleep(sk), &wait);
|
||||
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
|
||||
index 30154836acd0..b8bf1446ae13 100644
|
||||
--- a/net/vmw_vsock/hyperv_transport.c
|
||||
+++ b/net/vmw_vsock/hyperv_transport.c
|
||||
@@ -268,7 +268,7 @@ static void hvs_channel_cb(void *ctx)
|
||||
sk->sk_data_ready(sk);
|
||||
|
||||
/* Mark it writable only if there is enough space */
|
||||
- if (hvs_channel_writable_bytes(chan) >= HVS_SEND_BUF_SIZE)
|
||||
+ if (hv_get_bytes_to_write(&chan->outbound) > 0)
|
||||
sk->sk_write_space(sk);
|
||||
}
|
||||
|
||||
@@ -350,9 +350,11 @@ static void hvs_open_connection(struct vmbus_channel *chan)
|
||||
set_per_channel_state(chan, conn_from_host ? new : sk);
|
||||
vmbus_set_chn_rescind_callback(chan, hvs_close_connection);
|
||||
|
||||
+#if 0
|
||||
/* See hvs_channel_cb() and hvs_notify_poll_out() */
|
||||
set_channel_pending_send_size(chan,
|
||||
HVS_PKT_LEN(HVS_SEND_BUF_SIZE) + 1);
|
||||
+#endif
|
||||
|
||||
if (conn_from_host) {
|
||||
new->sk_state = SS_CONNECTED;
|
||||
@@ -542,7 +544,7 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
struct hvsock *hvs = vsk->trans;
|
||||
struct vmbus_channel *chan = hvs->chan;
|
||||
struct hvs_send_buf *send_buf;
|
||||
- size_t to_write, max_writable, ret;
|
||||
+ ssize_t to_write, max_writable, ret;
|
||||
|
||||
BUILD_BUG_ON(sizeof(*send_buf) != PAGE_SIZE_4K);
|
||||
|
||||
@@ -551,8 +553,8 @@ static ssize_t hvs_stream_enqueue(struct vsock_sock *vsk, struct msghdr *msg,
|
||||
return -ENOMEM;
|
||||
|
||||
max_writable = hvs_channel_writable_bytes(chan);
|
||||
- to_write = min_t(size_t, len, max_writable);
|
||||
- to_write = min_t(size_t, to_write, HVS_SEND_BUF_SIZE);
|
||||
+ to_write = min_t(ssize_t, len, max_writable);
|
||||
+ to_write = min_t(ssize_t, to_write, HVS_SEND_BUF_SIZE);
|
||||
|
||||
ret = memcpy_from_msg(send_buf->data, msg, to_write);
|
||||
if (ret < 0)
|
||||
@@ -595,8 +597,22 @@ static s64 hvs_stream_has_data(struct vsock_sock *vsk)
|
||||
static s64 hvs_stream_has_space(struct vsock_sock *vsk)
|
||||
{
|
||||
struct hvsock *hvs = vsk->trans;
|
||||
+ s64 ret;
|
||||
|
||||
- return hvs_channel_writable_bytes(hvs->chan);
|
||||
+ ret = hvs_channel_writable_bytes(hvs->chan);
|
||||
+ if (ret > 0) {
|
||||
+ set_channel_pending_send_size(hvs->chan, 0);
|
||||
+ } else {
|
||||
+ /* See hvs_channel_cb() and hvs_notify_poll_out() */
|
||||
+ set_channel_pending_send_size(hvs->chan,
|
||||
+ HVS_PKT_LEN(HVS_SEND_BUF_SIZE) + 1);
|
||||
+
|
||||
+ ret = hvs_channel_writable_bytes(hvs->chan);
|
||||
+ if (ret > 0)
|
||||
+ set_channel_pending_send_size(hvs->chan, 0);
|
||||
+ }
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static u64 hvs_stream_rcvhiwat(struct vsock_sock *vsk)
|
||||
@@ -646,8 +662,10 @@ int hvs_notify_poll_in(struct vsock_sock *vsk, size_t target, bool *readable)
|
||||
static
|
||||
int hvs_notify_poll_out(struct vsock_sock *vsk, size_t target, bool *writable)
|
||||
{
|
||||
+ struct hvsock *hvs = vsk->trans;
|
||||
+
|
||||
/* Report writable only if there is enough space */
|
||||
- *writable = hvs_stream_has_space(vsk) >= HVS_SEND_BUF_SIZE;
|
||||
+ *writable = hvs_channel_writable_bytes(hvs->chan) > 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,41 +0,0 @@
|
||||
From 8a95556b04647ce5fd417486d794a2e588716254 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 7 Jul 2017 09:15:29 +0800
|
||||
Subject: [PATCH 10/12] hv-sock: avoid double FINs if shutdown() is called
|
||||
|
||||
The host expects a single FIN.
|
||||
|
||||
Signed-off-by: Dexuan Cui <decui@microsoft.com>
|
||||
Origin: git@github.com:dcui/linux.git
|
||||
(cherry picked from commit f315dfcf9c3b4b32f43a21664762cbacd8f05d6a)
|
||||
---
|
||||
net/vmw_vsock/hyperv_transport.c | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
|
||||
index b8bf1446ae13..50e4bc822c69 100644
|
||||
--- a/net/vmw_vsock/hyperv_transport.c
|
||||
+++ b/net/vmw_vsock/hyperv_transport.c
|
||||
@@ -95,6 +95,9 @@ struct hvsock {
|
||||
u32 recv_data_len;
|
||||
/* The offset of the payload */
|
||||
u32 recv_data_off;
|
||||
+
|
||||
+ /* Have we sent the zero-length packet (FIN)? */
|
||||
+ unsigned long fin_sent;
|
||||
};
|
||||
|
||||
/* In the VM, we support Hyper-V Sockets with AF_VSOCK, and the endpoint is
|
||||
@@ -425,6 +428,9 @@ static int hvs_shutdown(struct vsock_sock *vsk, int mode)
|
||||
|
||||
hvs = vsk->trans;
|
||||
|
||||
+ if (test_and_set_bit(0, &hvs->fin_sent))
|
||||
+ return 0;
|
||||
+
|
||||
send_buf = (struct hvs_send_buf *)&hdr;
|
||||
|
||||
/* It can't fail: see hvs_channel_writable_bytes(). */
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,61 +0,0 @@
|
||||
From f8c3b6382e09ff9e6443a5893da10e408402acc4 Mon Sep 17 00:00:00 2001
|
||||
From: Randy Dodgen <dodgen@google.com>
|
||||
Date: Thu, 24 Aug 2017 15:26:01 -0400
|
||||
Subject: [PATCH 11/12] ext4: fix fault handling when mounted with -o dax,ro
|
||||
|
||||
If an ext4 filesystem is mounted with both the DAX and read-only
|
||||
options, executables on that filesystem will fail to start (claiming
|
||||
'Segmentation fault') due to the fault handler returning
|
||||
VM_FAULT_SIGBUS.
|
||||
|
||||
This is due to the DAX fault handler (see ext4_dax_huge_fault)
|
||||
attempting to write to the journal when FAULT_FLAG_WRITE is set. This is
|
||||
the wrong behavior for write faults which will lead to a COW page; in
|
||||
particular, this fails for readonly mounts.
|
||||
|
||||
This change avoids journal writes for faults that are expected to COW.
|
||||
|
||||
It might be the case that this could be better handled in
|
||||
ext4_iomap_begin / ext4_iomap_end (called via iomap_ops inside
|
||||
dax_iomap_fault). These is some overlap already (e.g. grabbing journal
|
||||
handles).
|
||||
|
||||
Signed-off-by: Randy Dodgen <dodgen@google.com>
|
||||
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||
Reviewed-by: Jan Kara <jack@suse.cz>
|
||||
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
|
||||
Origin: https://github.com/torvalds/linux
|
||||
(cherry picked from commit fd96b8da68d32a9403726db09b229f4b5ac849c7)
|
||||
---
|
||||
fs/ext4/file.c | 15 ++++++++++++++-
|
||||
1 file changed, 14 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
|
||||
index 86ea1d92839a..197653ea6041 100644
|
||||
--- a/fs/ext4/file.c
|
||||
+++ b/fs/ext4/file.c
|
||||
@@ -279,7 +279,20 @@ static int ext4_dax_huge_fault(struct vm_fault *vmf,
|
||||
handle_t *handle = NULL;
|
||||
struct inode *inode = file_inode(vmf->vma->vm_file);
|
||||
struct super_block *sb = inode->i_sb;
|
||||
- bool write = vmf->flags & FAULT_FLAG_WRITE;
|
||||
+
|
||||
+ /*
|
||||
+ * We have to distinguish real writes from writes which will result in a
|
||||
+ * COW page; COW writes should *not* poke the journal (the file will not
|
||||
+ * be changed). Doing so would cause unintended failures when mounted
|
||||
+ * read-only.
|
||||
+ *
|
||||
+ * We check for VM_SHARED rather than vmf->cow_page since the latter is
|
||||
+ * unset for pe_size != PE_SIZE_PTE (i.e. only in do_cow_fault); for
|
||||
+ * other sizes, dax_iomap_fault will handle splitting / fallback so that
|
||||
+ * we eventually come back with a COW page.
|
||||
+ */
|
||||
+ bool write = (vmf->flags & FAULT_FLAG_WRITE) &&
|
||||
+ (vmf->vma->vm_flags & VM_SHARED);
|
||||
|
||||
if (write) {
|
||||
sb_start_pagefault(sb);
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,28 +0,0 @@
|
||||
From 9efb158fb2c4e93b7690dbe9e2ba3b978deaca4b Mon Sep 17 00:00:00 2001
|
||||
From: Cheng-mean Liu <soccerl@microsoft.com>
|
||||
Date: Tue, 11 Jul 2017 16:58:26 -0700
|
||||
Subject: [PATCH 12/12] NVDIMM: reducded ND_MIN_NAMESPACE_SIZE from 4MB to 4KB
|
||||
(page size)
|
||||
|
||||
Signed-off-by: Cheng-mean Liu <soccerl@microsoft.com>
|
||||
Origin: https://github.com/Microsoft/opengcs/blob/master/kernelconfig/4.11/patch_lower-the-minimum-PMEM-size.patch
|
||||
---
|
||||
include/uapi/linux/ndctl.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
|
||||
index 3f03567631cb..e63c201ed1ef 100644
|
||||
--- a/include/uapi/linux/ndctl.h
|
||||
+++ b/include/uapi/linux/ndctl.h
|
||||
@@ -263,7 +263,7 @@ enum nd_driver_flags {
|
||||
};
|
||||
|
||||
enum {
|
||||
- ND_MIN_NAMESPACE_SIZE = 0x00400000,
|
||||
+ ND_MIN_NAMESPACE_SIZE = 0x00001000,
|
||||
};
|
||||
|
||||
enum ars_masks {
|
||||
--
|
||||
2.14.1
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 8874cb6a9fb80c3b0f35116362484a014b1042b2 Mon Sep 17 00:00:00 2001
|
||||
From 35ef9254b0c4cfb8d1ca108ae114c49b7b9c0b2b Mon Sep 17 00:00:00 2001
|
||||
From: Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 12:55:49 -0300
|
||||
Subject: [PATCH 01/12] tools build: Add test for sched_getcpu()
|
||||
@ -146,5 +146,5 @@ index 43899e0d6fa1..c3b180254f91 100644
|
||||
|
||||
int is_printable_array(char *p, unsigned int len);
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 18014c91387a34dd5b15e87825902c5d4315ed77 Mon Sep 17 00:00:00 2001
|
||||
From 90fc913acdd81b67d7b367a3c0cfc4885b72e1f3 Mon Sep 17 00:00:00 2001
|
||||
From: Arnaldo Carvalho de Melo <acme@redhat.com>
|
||||
Date: Thu, 13 Oct 2016 17:12:35 -0300
|
||||
Subject: [PATCH 02/12] perf jit: Avoid returning garbage for a ret variable
|
||||
@ -66,5 +66,5 @@ index 95f0884aae02..f3ed3c963c71 100644
|
||||
while ((jr = jit_get_next_entry(jd))) {
|
||||
switch(jr->prefix.id) {
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 33f928dd406c2a42937be110b3390de98586a4ad Mon Sep 17 00:00:00 2001
|
||||
From a4b5046bf47f507bf514154444f49b20cb434ea5 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Sat, 23 Jul 2016 01:35:51 +0000
|
||||
Subject: [PATCH 03/12] hv_sock: introduce Hyper-V Sockets
|
||||
@ -1787,5 +1787,5 @@ index 000000000000..331d3759f5cb
|
||||
+MODULE_DESCRIPTION("Hyper-V Sockets");
|
||||
+MODULE_LICENSE("Dual BSD/GPL");
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From d61670ca6b66ec890d2268ac50cf29494456562e Mon Sep 17 00:00:00 2001
|
||||
From ead831c3415e24149a5d871911f8b25895a908ff Mon Sep 17 00:00:00 2001
|
||||
From: Rolf Neugebauer <rolf.neugebauer@gmail.com>
|
||||
Date: Mon, 23 May 2016 18:55:45 +0100
|
||||
Subject: [PATCH 04/12] vmbus: Don't spam the logs with unknown GUIDs
|
||||
@ -26,5 +26,5 @@ index d8bc4b910192..8df02f3ca0b2 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 11863c7c35e5c1d1b104ee92117b52bc26a60b1b Mon Sep 17 00:00:00 2001
|
||||
From 70b74738d9b75517ce4ff02aa390e10bea72afa1 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ng <alexng@messages.microsoft.com>
|
||||
Date: Sun, 6 Nov 2016 13:14:07 -0800
|
||||
Subject: [PATCH 05/12] Drivers: hv: utils: Fix the mapping between host
|
||||
@ -44,5 +44,5 @@ index bcd06306f3e8..e7707747f56d 100644
|
||||
}
|
||||
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From bdca678b6c34474508418c7821f1ff3fbb40ba72 Mon Sep 17 00:00:00 2001
|
||||
From b14ddee6415c3b0ecae19e5c52bb1865b7d6980f Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ng <alexng@messages.microsoft.com>
|
||||
Date: Sun, 6 Nov 2016 13:14:10 -0800
|
||||
Subject: [PATCH 06/12] Drivers: hv: vss: Improve log messages.
|
||||
@ -101,5 +101,5 @@ index a76e3db0d01f..b1446d51ef45 100644
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 9c892205867bf4a2f0864b3bd2a1ee4ad998687b Mon Sep 17 00:00:00 2001
|
||||
From a93030d11246445ebafbb1ac965bb4cfc160b71e Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ng <alexng@messages.microsoft.com>
|
||||
Date: Sun, 6 Nov 2016 13:14:11 -0800
|
||||
Subject: [PATCH 07/12] Drivers: hv: vss: Operation timeouts should match host
|
||||
@ -44,5 +44,5 @@ index b1446d51ef45..4e543dbb731a 100644
|
||||
rc = hvutil_transport_send(hvt, vss_msg, sizeof(*vss_msg), NULL);
|
||||
if (rc) {
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 5a4f20802d0f475698471f29b5f4960f1e9b05e7 Mon Sep 17 00:00:00 2001
|
||||
From bed22e1348f22c79b9f95172418ba0704cdce6a5 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ng <alexng@messages.microsoft.com>
|
||||
Date: Sat, 28 Jan 2017 12:37:17 -0700
|
||||
Subject: [PATCH 08/12] Drivers: hv: vmbus: Use all supported IC versions to
|
||||
@ -488,5 +488,5 @@ index c9af8369b4f7..7df9eb8f0cf7 100644
|
||||
void hv_event_tasklet_disable(struct vmbus_channel *channel);
|
||||
void hv_event_tasklet_enable(struct vmbus_channel *channel);
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 9ac021a4572ab271472edf4cde945fb49f986483 Mon Sep 17 00:00:00 2001
|
||||
From 8fd6b628c6022656ae2fb02dc68445fedcf54ccd Mon Sep 17 00:00:00 2001
|
||||
From: Alex Ng <alexng@messages.microsoft.com>
|
||||
Date: Sat, 28 Jan 2017 12:37:18 -0700
|
||||
Subject: [PATCH 09/12] Drivers: hv: Log the negotiated IC versions.
|
||||
@ -114,5 +114,5 @@ index f3797c07be10..89440c2eb346 100644
|
||||
hb_srv_version & 0xFFFF);
|
||||
}
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 100b9780c23acdaf54432391960a6ea914da505a Mon Sep 17 00:00:00 2001
|
||||
From 6cd38bb68454303af6e7f38a4e4d91675b3b2708 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Sun, 26 Mar 2017 16:42:20 +0800
|
||||
Subject: [PATCH 10/12] vmbus: fix missed ring events on boot
|
||||
@ -52,5 +52,5 @@ index e7949b64bfbc..2fe024e86209 100644
|
||||
|
||||
void hv_process_channel_removal(struct vmbus_channel *channel, u32 relid)
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 72315ab9c95e4ca0fe1eec19cccf14a8e941a252 Mon Sep 17 00:00:00 2001
|
||||
From 16b7ee65a4962f5c7f62868f2b9163f4ad73324e Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Wed, 29 Mar 2017 18:37:10 +0800
|
||||
Subject: [PATCH 11/12] vmbus: remove "goto error_clean_msglist" in
|
||||
@ -56,5 +56,5 @@ index 1606e7f08f4b..1caed01954f6 100644
|
||||
vmbus_teardown_gpadl(newchannel, newchannel->ringbuffer_gpadlhandle);
|
||||
kfree(open_info);
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From da6fedd18c446840102599d1b722aa87c18b0b5e Mon Sep 17 00:00:00 2001
|
||||
From ff1dc8b45d014829cbafe74e1457c9561ff4ddd8 Mon Sep 17 00:00:00 2001
|
||||
From: Dexuan Cui <decui@microsoft.com>
|
||||
Date: Fri, 24 Mar 2017 20:53:18 +0800
|
||||
Subject: [PATCH 12/12] vmbus: dynamically enqueue/dequeue the channel on
|
||||
@ -173,5 +173,5 @@ index 7df9eb8f0cf7..a87757cf277b 100644
|
||||
|
||||
void vmbus_setevent(struct vmbus_channel *channel);
|
||||
--
|
||||
2.14.1
|
||||
2.15.0
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=tty0 console=ttyS0 console=ttyAMA0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:6b3755e47f00d6027321d3fca99a19af6504be75
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:6b3755e47f00d6027321d3fca99a19af6504be75
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:6b3755e47f00d6027321d3fca99a19af6504be75
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 console=tty0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:6b3755e47f00d6027321d3fca99a19af6504be75 # with runc, logwrite, startmemlogd
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:6b3755e47f00d6027321d3fca99a19af6504be75
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0 page_poison=1"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.4.102
|
||||
image: linuxkit/kernel:4.4.103
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Sanity check on the kernel config file
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=kconfig
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Test code goes here
|
||||
linuxkit build -format kernel+initrd -name "${NAME}" test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,15 +0,0 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.13.16
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
- linuxkit/runc:1b0741d07949c0acc444cd6a04ee7f833443579d
|
||||
onboot:
|
||||
- name: check-kernel-config
|
||||
image: linuxkit/test-kernel-config:ff8fac1c318403aff3e2993dd9b130304e09f92e
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.14.2
|
||||
image: linuxkit/kernel:4.14.3
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -3,7 +3,7 @@
|
||||
# In the last stage, it creates a package, which can be used for
|
||||
# testing.
|
||||
|
||||
FROM linuxkit/kernel:4.4.102 AS ksrc
|
||||
FROM linuxkit/kernel:4.4.103 AS ksrc
|
||||
|
||||
# Extract headers and compile module
|
||||
FROM linuxkit/alpine:07f7d136e427dc68154cd5edbb2b9576f9ac5213 AS build
|
||||
|
@ -19,7 +19,7 @@ clean_up() {
|
||||
trap clean_up EXIT
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
docker pull linuxkit/kernel:4.9.65
|
||||
docker pull linuxkit/kernel:4.9.66
|
||||
# Build a package
|
||||
docker build -t ${IMAGE_NAME} .
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.4.102
|
||||
image: linuxkit/kernel:4.4.103
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -3,7 +3,7 @@
|
||||
# In the last stage, it creates a package, which can be used for
|
||||
# testing.
|
||||
|
||||
FROM linuxkit/kernel:4.9.65 AS ksrc
|
||||
FROM linuxkit/kernel:4.9.66 AS ksrc
|
||||
|
||||
# Extract headers and compile module
|
||||
FROM linuxkit/alpine:07f7d136e427dc68154cd5edbb2b9576f9ac5213 AS build
|
||||
|
@ -19,7 +19,7 @@ clean_up() {
|
||||
trap clean_up EXIT
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
docker pull linuxkit/kernel:4.9.65
|
||||
docker pull linuxkit/kernel:4.9.66
|
||||
# Build a package
|
||||
docker build -t ${IMAGE_NAME} .
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,23 +0,0 @@
|
||||
# This Dockerfile extracts the kernel headers from the kernel image
|
||||
# and then compiles a simple hello world kernel module against them.
|
||||
# In the last stage, it creates a package, which can be used for
|
||||
# testing.
|
||||
|
||||
FROM linuxkit/kernel:4.13.16 AS ksrc
|
||||
|
||||
# Extract headers and compile module
|
||||
FROM linuxkit/alpine:07f7d136e427dc68154cd5edbb2b9576f9ac5213 AS build
|
||||
RUN apk add build-base libelf-dev
|
||||
|
||||
COPY --from=ksrc /kernel-dev.tar /
|
||||
RUN tar xf kernel-dev.tar
|
||||
|
||||
WORKDIR /kmod
|
||||
COPY ./src/* ./
|
||||
RUN make all
|
||||
|
||||
# Package
|
||||
FROM alpine:3.5
|
||||
COPY --from=build /kmod/hello_world.ko /
|
||||
COPY check.sh /check.sh
|
||||
ENTRYPOINT ["/bin/sh", "/check.sh"]
|
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
function failed {
|
||||
printf "Kernel module test suite FAILED\n"
|
||||
/sbin/poweroff -f
|
||||
}
|
||||
|
||||
uname -a
|
||||
modinfo hello_world.ko || failed
|
||||
insmod hello_world.ko || failed
|
||||
[ -n "$(dmesg | grep -o 'Hello LinuxKit')" ] || failed
|
||||
rmmod hello_world || failed
|
||||
|
||||
printf "Kernel module test suite PASSED\n"
|
||||
|
||||
/sbin/poweroff -f
|
@ -1,6 +0,0 @@
|
||||
obj-m += hello_world.o
|
||||
KVER=$(shell basename /usr/src/linux-headers-*)
|
||||
all:
|
||||
make -C /usr/src/$(KVER) M=$(PWD) modules
|
||||
clean:
|
||||
make -C /usr/src/$(KVER) M=$(PWD) clean
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* A simple Hello World kernel module
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
int init_hello(void)
|
||||
{
|
||||
printk(KERN_INFO "Hello LinuxKit\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit_hello(void)
|
||||
{
|
||||
printk(KERN_INFO "Goodbye LinuxKit.\n");
|
||||
}
|
||||
|
||||
module_init(init_hello);
|
||||
module_exit(exit_hello);
|
||||
MODULE_AUTHOR("Rolf Neugebauer <rolf.neugebauer@docker.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("A simple Hello World kernel module for testing");
|
@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Test build and insertion of kernel modules
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=kmod
|
||||
IMAGE_NAME=kmod-test
|
||||
|
||||
clean_up() {
|
||||
docker rmi ${IMAGE_NAME} || true
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
docker pull linuxkit/kernel:4.9.65
|
||||
# Build a package
|
||||
docker build -t ${IMAGE_NAME} .
|
||||
|
||||
# Build and run a LinuxKit image with kernel module (and test script)
|
||||
linuxkit build -format kernel+initrd -name "${NAME}" test.yml
|
||||
RESULT="$(linuxkit run ${NAME})"
|
||||
echo "${RESULT}" | grep -q "Hello LinuxKit"
|
||||
|
||||
exit 0
|
@ -1,20 +0,0 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.13.16
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
- linuxkit/runc:1b0741d07949c0acc444cd6a04ee7f833443579d
|
||||
onboot:
|
||||
- name: check
|
||||
image: kmod-test
|
||||
binds:
|
||||
- /dev:/dev
|
||||
- /lib/modules:/lib/modules
|
||||
capabilities:
|
||||
- all
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
@ -3,7 +3,7 @@
|
||||
# In the last stage, it creates a package, which can be used for
|
||||
# testing.
|
||||
|
||||
FROM linuxkit/kernel:4.14.2 AS ksrc
|
||||
FROM linuxkit/kernel:4.14.3 AS ksrc
|
||||
|
||||
# Extract headers and compile module
|
||||
FROM linuxkit/alpine:07f7d136e427dc68154cd5edbb2b9576f9ac5213 AS build
|
||||
|
@ -19,7 +19,7 @@ clean_up() {
|
||||
trap clean_up EXIT
|
||||
|
||||
# Make sure we have the latest kernel image
|
||||
docker pull linuxkit/kernel:4.9.65
|
||||
docker pull linuxkit/kernel:4.9.66
|
||||
# Build a package
|
||||
docker build -t ${IMAGE_NAME} .
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.14.2
|
||||
image: linuxkit/kernel:4.14.3
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.4.102
|
||||
image: linuxkit/kernel:4.4.103
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,5 +1,5 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.65
|
||||
image: linuxkit/kernel:4.9.66
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:7357177a8be310e40fef7424305a72c198e857c4
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Namespace stress with a single short TCP/IPv4 connection over a veth pair in reverse order
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-ns
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
linuxkit build -format kernel+initrd -name ${NAME} ../../common.yml test.yml
|
||||
RESULT="$(linuxkit run -cpus 2 ${NAME})"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,10 +0,0 @@
|
||||
onboot:
|
||||
- name: test-ns
|
||||
image: linuxkit/test-ns:1fca30ea85c94571200d00c7b282c537b537de48
|
||||
command: ["/bin/sh", "/runp-runc-net.sh", "1", "-l", "5", "-i", "15", "-ip", "4", "-p", "tcp", "-s", "-c", "1", "-r"]
|
||||
mounts: # for runc
|
||||
- type: cgroup
|
||||
options: ["rw"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Namespace stress with a single short TCP/IPv4 connection over a veth pair
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-ns
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
linuxkit build -format kernel+initrd -name ${NAME} ../../common.yml test.yml
|
||||
RESULT="$(linuxkit run -cpus 2 ${NAME})"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,10 +0,0 @@
|
||||
onboot:
|
||||
- name: test-ns
|
||||
image: linuxkit/test-ns:1fca30ea85c94571200d00c7b282c537b537de48
|
||||
command: ["/bin/sh", "/runp-runc-net.sh", "1", "-l", "5", "-i", "15", "-ip", "4", "-p", "tcp", "-s", "-c", "1"]
|
||||
mounts: # for runc
|
||||
- type: cgroup
|
||||
options: ["rw"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Namespace stress with 10 concurrent short TCP/IPv4 connections over a veth pair in reverse order
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-ns
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
linuxkit build -format kernel+initrd -name ${NAME} ../../common.yml test.yml
|
||||
RESULT="$(linuxkit run -cpus 2 ${NAME})"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,10 +0,0 @@
|
||||
onboot:
|
||||
- name: test-ns
|
||||
image: linuxkit/test-ns:1fca30ea85c94571200d00c7b282c537b537de48
|
||||
command: ["/bin/sh", "/runp-runc-net.sh", "1", "-l", "5", "-i", "15", "-ip", "4", "-p", "tcp", "-s", "-c", "10"]
|
||||
mounts: # for runc
|
||||
- type: cgroup
|
||||
options: ["rw"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
@ -1,23 +0,0 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Namespace stress with 10 concurrent short TCP/IPv4 connections over a veth pair
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-ns
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-*
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
linuxkit build -format kernel+initrd -name ${NAME} ../../common.yml test.yml
|
||||
RESULT="$(linuxkit run -cpus 2 ${NAME})"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
@ -1,10 +0,0 @@
|
||||
onboot:
|
||||
- name: test-ns
|
||||
image: linuxkit/test-ns:1fca30ea85c94571200d00c7b282c537b537de48
|
||||
command: ["/bin/sh", "/runp-runc-net.sh", "1", "-l", "5", "-i", "15", "-ip", "4", "-p", "tcp", "-s", "-c", "10"]
|
||||
mounts: # for runc
|
||||
- type: cgroup
|
||||
options: ["rw"]
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:280bd01daa8776fbe1f4d912977f1886b8374834
|
||||
command: ["/bin/sh", "/poweroff.sh", "3"]
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user