netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vsock: only load vmci transport on VMware hypervisor by default
@ 2017-08-17  8:00 Dexuan Cui
  2017-08-17 13:55 ` Stefan Hajnoczi
  2017-08-17 17:04 ` David Miller
  0 siblings, 2 replies; 17+ messages in thread
From: Dexuan Cui @ 2017-08-17  8:00 UTC (permalink / raw)
  To: 'Jorgen S. Hansen', 'davem@davemloft.net',
	'netdev@vger.kernel.org'
  Cc: 'gregkh@linuxfoundation.org',
	'devel@linuxdriverproject.org',
	KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	'George Zhang', 'Michal Kubecek',
	'Asias He', 'Stefan Hajnoczi',
	'Vitaly Kuznetsov', 'Cathy Avery',
	'jasowang@redhat.com', 'Rolf Neugebauer',
	'Dave Scott', 'Marcelo Cerri',
	'apw@canonical.com', 'olaf@aepfle.de',
	'joe@perches.com'


Without the patch, vmw_vsock_vmci_transport.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 going to add 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 Hyper-V.

On the other hand, hv_sock.ko can only load on Hyper-V, because it
depends on hv_vmbus.ko, which detects 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).

The patch also adds a module parameter "skip_hypervisor_check" for
vmw_vsock_vmci_transport.ko.

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>
---
 net/vmw_vsock/Kconfig          |  2 +-
 net/vmw_vsock/vmci_transport.c | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/vmw_vsock/Kconfig b/net/vmw_vsock/Kconfig
index a24369d..3f52929 100644
--- a/net/vmw_vsock/Kconfig
+++ b/net/vmw_vsock/Kconfig
@@ -17,7 +17,7 @@ config VSOCKETS
 
 config VMWARE_VMCI_VSOCKETS
 	tristate "VMware VMCI transport for Virtual Sockets"
-	depends on VSOCKETS && VMWARE_VMCI
+	depends on VSOCKETS && VMWARE_VMCI && HYPERVISOR_GUEST
 	help
 	  This module implements a VMCI transport for Virtual Sockets.
 
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index 10ae782..c068873 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <linux/cred.h>
+#include <linux/hypervisor.h>
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
@@ -73,6 +74,10 @@ struct vmci_transport_recv_pkt_info {
 	struct vmci_transport_packet pkt;
 };
 
+static bool skip_hypervisor_check;
+module_param(skip_hypervisor_check, bool, 0444);
+MODULE_PARM_DESC(hot_add, "If set, attempt to load on non-VMware platforms");
+
 static LIST_HEAD(vmci_transport_cleanup_list);
 static DEFINE_SPINLOCK(vmci_transport_cleanup_lock);
 static DECLARE_WORK(vmci_transport_cleanup_work, vmci_transport_cleanup);
@@ -2085,6 +2090,12 @@ static int __init vmci_transport_init(void)
 {
 	int err;
 
+	/* Check if we are running on VMware's hypervisor and bail out
+	 * if we are not.
+	 */
+	if (!skip_hypervisor_check && x86_hyper != &x86_hyper_vmware)
+		return -ENODEV;
+
 	/* Create the datagram handle that we will use to send and receive all
 	 * VSocket control messages for this context.
 	 */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-09-06 19:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-17  8:00 [PATCH] vsock: only load vmci transport on VMware hypervisor by default Dexuan Cui
2017-08-17 13:55 ` Stefan Hajnoczi
2017-08-17 15:16   ` Jorgen S. Hansen
2017-08-18  3:07     ` Dexuan Cui
2017-08-18 15:37       ` Stefan Hajnoczi
2017-08-18 23:07         ` Dexuan Cui
2017-08-22  9:54           ` Stefan Hajnoczi
2017-08-22 13:07             ` Jorgen S. Hansen
2017-08-23  4:21               ` Dexuan Cui
2017-08-29  2:36                 ` Dexuan Cui
2017-08-29 15:37                   ` Jorgen S. Hansen
2017-08-31 11:54                     ` Stefan Hajnoczi
2017-09-02  6:25                       ` Dexuan Cui
2017-09-06 14:11                       ` Jorgen S. Hansen
2017-09-06 19:39                         ` Dexuan Cui
2017-08-17 17:04 ` David Miller
2017-08-17 18:27   ` Dexuan Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).