Files
linuxkit/projects/kernel-config/patches-4.11.x/0007-VMCI-only-try-to-load-on-VMware-hypervisor.patch
Tycho Andersen ef4bd01de8 kernel-config project: add draft of kernel configs
The kernel configs themselves are stored as diffs of what we want vs. each
version's defconfig.

Thus, things like e.g. CONFIG_DEVKMEM drop out after it was made
non-default. The implication of this is (I hope) that as upstream adopts
security features, our delta can shrink (or more realistically, only
include the next-next gen features).

Signed-off-by: Tycho Andersen <tycho@docker.com>
2017-05-22 17:51:09 -06:00

65 lines
2.2 KiB
Diff

From f467ed8a4c51eed215f9f8db32cad8f240a59a2e Mon Sep 17 00:00:00 2001
From: Dexuan Cui <decui@microsoft.com>
Date: Fri, 5 May 2017 16:57:29 -0600
Subject: [PATCH 7/9] 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: https://github.com/dcui/linux/commits/decui/hv_sock/v4.11/20170511
(cherry picked from commit b5566b1b6e5cb19b381590587f841f950caabe4d)
---
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.12.2