Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3486512imm; Mon, 13 Aug 2018 12:34:41 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwBlW8NzjCq/sgyduDZJiWJTlg0kv95JmXJAhE2PNE5HOB29bdCGsbAEQA22C55pFVJIElC X-Received: by 2002:aa7:8118:: with SMTP id b24-v6mr20250221pfi.78.1534188881026; Mon, 13 Aug 2018 12:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534188880; cv=none; d=google.com; s=arc-20160816; b=P5YDELERLnWyi86rHr90NKwAde7wVicv61juFewLS6IpDPFLppBjE66x0NaroFPEyA jjbkyF3XXmZ3QPXGmVQ1k2lNKt9DPri+LbUiYLvv33ef1uJvKmJI3ObcbAoDVzvTyhFL 8m0o/4I5ZWfwnAZ78St6SoL1IailqhwGE1LYqfy+WBIqJJ2J1lzhEEgfDY9W97kAvDfU PzGkjw6k+hPPhuGAe8oVuaUsTa7MAj+xEn7+jAf+e+rtnk6kxx/pwOFxicEwB/IQwwKa vv/peWLEIsEx4L8FP9Xm1rhf53Ef7MwosrNS///PmeAcNztgqmOH/ZHsXfg9JiobN6Z3 j1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:msip_labels :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=z3B2Y9ucQWTmWBzHEdyZOpZ6hLSROcXnwFkas20nro4=; b=FQfcVzyWPi+TEVLWRddEGt71nZQgBpw2GAbmbGW54GuOS7trxC9nNLAKTgfGXubCRO uPY22bslNHto1kPtizwLJcTfwN7lq4bf2PnkMP3+G3eFVyIkXAIDl9fAd/mKMW/KXYGb 5xhqmf01fiUhR5JSZqpm5FvryeBEG3xaaBjzB0tgTPxsG4NIQccoukwl35Mh9wNesZCQ gFyIFgqeMBxscw8pIZR125OROtPl2lXo0s2mHfbxTzK1j3aT688Fw4zls7KQcZ/hvwKm af2suHfdTNeIKbRnctmU9fETFkjrLPy7A390g5CSjrWG2I7g48VAjoMjxpC5K1ofJ47Q Cl6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=matBi3dc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d34-v6si14743833pld.301.2018.08.13.12.34.25; Mon, 13 Aug 2018 12:34:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=matBi3dc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730667AbeHMWQL (ORCPT + 99 others); Mon, 13 Aug 2018 18:16:11 -0400 Received: from mail-by2nam03on0121.outbound.protection.outlook.com ([104.47.42.121]:10400 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728763AbeHMWQK (ORCPT ); Mon, 13 Aug 2018 18:16:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z3B2Y9ucQWTmWBzHEdyZOpZ6hLSROcXnwFkas20nro4=; b=matBi3dcC2+AuMER49lCPykYn6EL0U6l7UV+hg8RrUfZGSo1rdXG21EsCcItG990AijGHQnadakT2Pjtez1pHwDd6JnvmzjHJcHf+hJtXK0pvaQw0d8Keq9yKKPU1Z9owj7742OnN3/whVxSreeNzZAzQdz596B+333qvNHP+YA= Received: from CY4PR21MB0773.namprd21.prod.outlook.com (10.173.192.19) by CY4PR21MB0278.namprd21.prod.outlook.com (10.173.193.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.1; Mon, 13 Aug 2018 19:30:51 +0000 Received: from CY4PR21MB0773.namprd21.prod.outlook.com ([fe80::9039:1f12:39f1:267f]) by CY4PR21MB0773.namprd21.prod.outlook.com ([fe80::9039:1f12:39f1:267f%9]) with mapi id 15.20.1080.002; Mon, 13 Aug 2018 19:30:51 +0000 From: "Michael Kelley (EOSG)" To: KY Srinivasan , "gregkh@linuxfoundation.org" , "linux-kernel@vger.kernel.org" , "devel@linuxdriverproject.org" , "olaf@aepfle.de" , "apw@canonical.com" , "jasowang@redhat.com" , Stephen Hemminger , "vkuznets@redhat.com" CC: Stephen Hemminger Subject: RE: [PATCH 2/5] vmbus: add driver_override support Thread-Topic: [PATCH 2/5] vmbus: add driver_override support Thread-Index: AQHUMP7hUja4hqhYOEGCevbfjkIbnqS+Ebaw Date: Mon, 13 Aug 2018 19:30:50 +0000 Message-ID: References: <20180810230520.2055-1-kys@linuxonhyperv.com> <20180810230611.2114-1-kys@linuxonhyperv.com> <20180810230611.2114-2-kys@linuxonhyperv.com> In-Reply-To: <20180810230611.2114-2-kys@linuxonhyperv.com> 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_Owner=mikelley@ntdev.microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2018-08-13T19:30:49.3432975Z; 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 x-originating-ip: [2001:4898:80e8:3:e19a:eef5:264f:f70c] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR21MB0278;6:DhbFNpfjoFSSP0P1X7RDKZutNJFXaVMfjCTT9IJR+UcFX/o9PTgYWH6vfQktTNUM0m9xWjzJDAE3zqaLQtF87Xah0ByN77o4ktaVKnYCsoi/KdWsEPrigAIkDrZObkFhVBG4Dh1xkR0DHMHztiIZsShaZ3IAfuO7IZvrgel3WaU3SnkH6pM7VA0UzSBGZscZGtuteIAHFxpBnIZY/QL5hSLfS2CWDXKaElFaTwMNgFctAMRM58cwqdFBPPlaaZ2Yqi4Tyek9FyDgKw3lUD0+c3si1rsspjsYX0TMQgLPaF8QiSGSZSkvh8dyT0YCqULYN7OD7CaC97NAOJKi24430KSrCYszDgUNx2FQfqnK+pEnnntndXf0KDQ4/WGmTEWFuSug2vJ3lrD07idV4jQbIOkAl9MNsm0Fu1AQVeKn241EuVtc+uPLdytK7Oy5fFEaNSwomRMES4hiwk06qaQ7gQ==;5:NEyrlgATL0F+dAVNE0tGShVNgnrblOQ2m+ajzhQ02iEj8ToLpzLkSbzIULGgStVSkRqk1GW0WGY1PH0opLIEM1YDzUHcCxfVksS4kUI4PDNXemjUU6pLTi1bw7gYNXWpBXh+662HUlOQIiQbdqT4QfBHdX7N4l3HTKreltiL17U=;7:fjzOYaMXkxyM+/6mmuvfdY9JaoNsmeEdFvKpIu7tMNfgVmRoHmxKEMzwOQAdwI8HiuQ7o2Fo5YOI/G9M7oFPKhOPWad7ZQHTk6IuwIgGW/0BgN9nqDAHLe4ffP51Uy4k+kUkGxCBmgX1VNs/ceAqADHWXI19VHqRrgWvMGtTvmZw/hjYLxX0O8fO6Gi33O49KlDnBW5LxCxvRDL+DI1/vO3D/YlG2Z5vBM2kCr2SXstg80BEki5q2ybn+BqsRPdK x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 803e3fbb-557c-4516-e271-08d60153477b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:CY4PR21MB0278; x-ms-traffictypediagnostic: CY4PR21MB0278: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(4782527817362); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(2018427008)(6055026)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:CY4PR21MB0278;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0278; x-forefront-prvs: 07630F72AD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(346002)(376002)(366004)(136003)(396003)(189003)(199004)(305945005)(7736002)(6436002)(6116002)(86362001)(7696005)(68736007)(25786009)(76176011)(2906002)(74316002)(2501003)(6506007)(86612001)(446003)(476003)(14444005)(256004)(5024004)(486006)(46003)(2201001)(8936002)(11346002)(102836004)(5660300001)(10090500001)(22452003)(97736004)(2900100001)(53936002)(33656002)(478600001)(316002)(105586002)(106356001)(55016002)(5250100002)(6346003)(14454004)(1511001)(99286004)(10290500003)(4326008)(229853002)(81156014)(81166006)(8990500004)(6306002)(6246003)(966005)(9686003)(72206003)(8676002)(110136005);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0278;H:CY4PR21MB0773.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Michael.H.Kelley@microsoft.com; x-microsoft-antispam-message-info: ulIiCDUFuc3b2ApHV0GOO06qz+lxDbicM4OEKBXj69e9hWwtLme+UMW9TrXi+7uNRkxxE6iC46IXW5ZyNNoAy2XpIN+je/XW39MRHHY3JrsMV9KudZPY/xTuDCDeInqYJy/SneimD9tPpyK/ebgEdrJJoHQntsi+BEhsdSvYn1SA7gSD+vpUdTirHW2GqlqW64Sf7Mo06JLSSiU+uJjO8nvVlhPDc3UFp2IUwvH/zBvpKgm5A93jmRZqSVq+NAxCPwFC48pJ0ayzCd6jp3PAX3l/9Zr+d1M/utWghZpR3pbppKmsx0ztRuDVF0VaLkpunq2ghf+VhpPyxp1LHbCQeR0jteJlF5xtCDQZNJfrHL8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 803e3fbb-557c-4516-e271-08d60153477b X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Aug 2018 19:30:51.0466 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0278 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: kys@linuxonhyperv.com Sent: Friday, August 1= 0, 2018 4:06 PM > From: Stephen Hemminger >=20 > Add support for overriding the default driver for a VMBus device > in the same way that it can be done for PCI devices. This patch > adds the /sys/bus/vmbus/devices/.../driver_override file > and the logic for matching. >=20 > This is used by driverctl tool to do driver override. > https://gitlab.com/driverctl/driverctl >=20 > Signed-off-by: Stephen Hemminger > Signed-off-by: K. Y. Srinivasan > --- > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > index b1b548a21f91..e6d8fdac6d8b 100644 > --- a/drivers/hv/vmbus_drv.c > +++ b/drivers/hv/vmbus_drv.c > @@ -498,6 +498,54 @@ static ssize_t device_show(struct device *dev, > } > static DEVICE_ATTR_RO(device); >=20 > +static ssize_t driver_override_store(struct device *dev, > + struct device_attribute *attr, > + const char *buf, size_t count) > +{ > + struct hv_device *hv_dev =3D device_to_hv_device(dev); > + char *driver_override, *old, *cp; > + > + /* We need to keep extra room for a newline */ > + if (count >=3D (PAGE_SIZE - 1)) > + return -EINVAL; Does 'count' actually have a relationship to PAGE_SIZE, or is PAGE_SIZE just used as an arbitrary size limit? I'm wondering what happens on ARM64 with a 64K page size, for example. If it's just arbitrary, coding such a constant would be better. > +/* > + * Return a matching hv_vmbus_device_id pointer. > + * If there is no match, return NULL. > + */ > +static const struct hv_vmbus_device_id *hv_vmbus_get_id(struct hv_driver= *drv, > + struct hv_device *dev) > +{ > + const uuid_le *guid =3D &dev->dev_type; > + const struct hv_vmbus_device_id *id; >=20 > - return NULL; > + /* When driver_override is set, only bind to the matching driver */ > + if (dev->driver_override && strcmp(dev->driver_override, drv->name)) > + return NULL; This function needs to be covered by the device lock, so that dev->driver_override can't be set to NULL and the memory freed during the above 'if' statement. When called from vmbus_probe(), the device lock is held, so it's good. But when called from vmbus_match(), the device lock may not be held: consider the path __driver_attach() -> driver_match_device() -> vmbus_match(). Michael