Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752533AbdHQIAx (ORCPT ); Thu, 17 Aug 2017 04:00:53 -0400 Received: from mail-hk2apc01on0131.outbound.protection.outlook.com ([104.47.124.131]:44064 "EHLO APC01-HK2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751593AbdHQIAv (ORCPT ); Thu, 17 Aug 2017 04:00:51 -0400 From: Dexuan Cui 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'" , "'linux-kernel@vger.kernel.org'" , "'Dan Carpenter'" , Stefan Hajnoczi Subject: [PATCH] vsock: only load vmci transport on VMware hypervisor by default Thread-Topic: [PATCH] vsock: only load vmci transport on VMware hypervisor by default Thread-Index: AdMXLqHUpz8ZGmCVQCq3Yks74VajMA== Date: Thu, 17 Aug 2017 08:00:29 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-08-17T01:00:27.1481503-07:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [50.35.78.155] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0055;6:TZhBk0jHBJZvjCt78c3W0kAqKqfne+tWzqM9e5KDoCVz7xVGN0wVlm5HH7tg91Bw/xyrgIEdyYfynXtWMK7NDWX4cGu46d3Igaq69yTyKcpH0A1GlBzJUg/EEIvj1wj1N8Pt4noJrhQ9pB0m4KcA/gFUk71pExfxwAs4/0X5yVviDY+HieXZAbN/LhT/h7yjHHiItVaI48//r8zkm4jtn7elx8kxbQdSvrwOx0bbgLlZMdNRgCtkbF2k2Xw/er0ZQ92h0ADg4kybtSJXJqgR56yZH4G2d/q8+b0X2rT40CFjsPxdN1jLMvs/zpmdrdQj4dVCUQ6y3Tmy+v2d5jaAMw==;5:f189xbnuUeY8JUXykDw6mMVgKxBLlmwqiYKjdc+T1B63cvfn16pMaQS3Mi4o4v2nPJ8T3S/JMR6ne0fWOKTQhPMWPzadOKHJDOCNCU5lXw20YXfHuIOAu6mWV8sXnkdjxyGhX6k/te04ARTyeIrL9w==;24:iPhHgqfkdBbBLZcVunjDmOCciB4IiSfVPDQVeM306Hl1xBGQaOnjhqzRIYlO8P5VKZndnMajJy0XiLNn/qaNzk9nQfDf85Y1hwVycAeiKbY=;7:zUBpiaPQgTqyfsabtcOQ9pUc4Fuu+W9P9IfcvaofwwoguE6DaNFBRgPFdky5xX2id60d1mSYyt2Kzu9rPQ377OPCj2aLUkzXbiAK4HDSZXcLHGPN3zAHlM5gjEnWqon/8NQeMxa8T1MwOP5W5vJaIBr3S2xRWkdYlxL0zPFh3JCjuTjFbBOY34tovoi8xuAa5Mmc/PCNKhMRVbcnVx4zv1BzH9nNe7wq5kElfamLLGU= x-ms-office365-filtering-correlation-id: 5eb94bd1-8e7b-4d79-032f-08d4e54607eb x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1P15301MB0055; x-ms-traffictypediagnostic: KL1P15301MB0055: x-exchange-antispam-report-test: UriScan:(61668805478150)(89211679590171); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(61426038)(61427038)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0055;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0055; x-forefront-prvs: 0402872DA1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(47760400005)(189002)(199003)(5005710100001)(74316002)(478600001)(10290500003)(8990500004)(77096006)(6506006)(105586002)(106356001)(2906002)(3280700002)(3660700001)(86362001)(86612001)(14454004)(5660300001)(97736004)(7416002)(7696004)(3846002)(102836003)(6116002)(66066001)(68736007)(9686003)(4326008)(54906002)(55016002)(54356999)(53936002)(2900100001)(25786009)(33656002)(6436002)(305945005)(101416001)(50986999)(189998001)(8936002)(8676002)(10090500001)(81156014)(81166006)(7736002)(491001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0055;H:KL1P15301MB0008.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Aug 2017 08:00:29.9552 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0055 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7H80w54020060 Content-Length: 2970 Lines: 85 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 Cc: Alok Kataria Cc: Andy King Cc: Adit Ranadive Cc: George Zhang Cc: Jorgen Hansen Cc: K. Y. Srinivasan Cc: Haiyang Zhang Cc: Stephen Hemminger --- 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 #include #include +#include #include #include #include @@ -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