Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2421698ybh; Fri, 24 Jul 2020 12:20:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyU03+SqdW3r9K9+17Y5k/4qEgUrsqKjfcykjwE73drk8S5T0FKMUeE+Jl0JkbpMbFeBxnP X-Received: by 2002:a17:906:5246:: with SMTP id y6mr10326708ejm.316.1595618441303; Fri, 24 Jul 2020 12:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595618441; cv=none; d=google.com; s=arc-20160816; b=Ul4pToz2u8qw7Tkr3okN6CfozWfAamacOBjJKtvCJuZ7jcVDm0/LSjHnC6Sm4oZ45L baIlhTxQBWySe4oMcOgMpeRhGfv8YK7Vx8ogX6EOV0CuEdEV3ZoI2UkE5xCUQvmUAUhl IHu6otibzOX5tEgPpc2J5aJVZfg3QnLFMMlowWSu5dc0u/RRCGoBwDVjmLrVlzdIo//J e0JFu0VgBi8EvaGU1lp2pgpLfXq4aGwaFak7eCQmuXIxd+9w6Ocxsbi+Ttvz5V8YIERa x8MHd1UVWY2jW7VM3A3k0qLHt3/G+0/OxFsGlCFPG5B1m5f0UvTo5hQ0kTAS6BcTHtiq LBmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=AJj/7mTJTokfFN7V2SBXvCQ6TJ6IN4DPcE0cHn1s29c=; b=jS/ejDOS1pS9syE/AknCPvU76Q0TM18lR6q2F+Abu+SjC0m0+qx3ll/hQOxd8TJ19N 4ZQUnqUITw4wtAvir2KWcziCBdUAUnO69f0YnbdU+qs1C3xAg3g1xnqCkjh3nENP+E6q v5i0MrMzAHsuaNg6yDaROvYIHmZpda8Cj9Z2RJncvHTMMjjfd+ZuZZRCt12HDPGow/RT WP3NCGxhGiv7QZEXrVJ/m0elVb2MiKrh/EZtUu1KvZKksGSsebSWz9DneUVq6X9uzymX HgiMpIAbPhssPianNtpg8ehIz+7lYNketLtDu7Yj8yvy+qchiyAT3DFlz1hLcCV8iGM8 07Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CxBmKivf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co3si1018611edb.134.2020.07.24.12.20.18; Fri, 24 Jul 2020 12:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CxBmKivf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726703AbgGXTRT (ORCPT + 99 others); Fri, 24 Jul 2020 15:17:19 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26063 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726572AbgGXTRT (ORCPT ); Fri, 24 Jul 2020 15:17:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595618237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AJj/7mTJTokfFN7V2SBXvCQ6TJ6IN4DPcE0cHn1s29c=; b=CxBmKivfJaKx+RiMkJeQYD4/c0/Kg5lTuE8xgboLRdk/szxaVv18+89/XeExAxK9IrqkPH QEJ209rK67mlSVtF77pL7G1Iq5kumsSJtVWV9+RQNav/cqyoQtu6/rsPjeizcjAdcaEBHo TIZbpgJtV41dlD5klgY8xVC7wW3Uukk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-270-6BoaiVaGM7ebz50loHlDeQ-1; Fri, 24 Jul 2020 15:17:13 -0400 X-MC-Unique: 6BoaiVaGM7ebz50loHlDeQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D39CF800464; Fri, 24 Jul 2020 19:17:10 +0000 (UTC) Received: from x1.home (ovpn-112-71.phx2.redhat.com [10.3.112.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80C546FEFE; Fri, 24 Jul 2020 19:17:09 +0000 (UTC) Date: Fri, 24 Jul 2020 13:17:08 -0600 From: Alex Williamson To: WeitaoWang-oc Cc: Alan Stern , Greg KH , "mathias.nyman@linux.intel.com" , "ulf.hansson@linaro.org" , "vkoul@kernel.org" , "hslester96@gmail.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "Carsten_Schmid@mentor.com" , "efremov@linux.com" , "Tony W. Wang(XA-RD)" , "Cobe Chen(BJ-RD)" , "Tim Guo(BJ-RD)" , "wwt8723@163.com" Subject: Re: [PATCH] USB:Fix kernel NULL pointer when unbind UHCI form vfio-pci Message-ID: <20200724131708.0a0f3358@x1.home> In-Reply-To: <11a7a3e67d6c40cd9fd06cd4d6300283@zhaoxin.com> References: <1595419068-4812-1-git-send-email-WeitaoWang-oc@zhaoxin.com> <20200722124414.GA3153105@kroah.com> <20200722145913.GB1310843@rowland.harvard.edu> <1bf449377e3448bc9c8bc7b64d7b7990@zhaoxin.com> <20200722221817.542971a2@x1.home> <20200723153821.GC1352396@rowland.harvard.edu> <20200723101735.3222c289@w520.home> <20200723163835.GA1357775@rowland.harvard.edu> <11a7a3e67d6c40cd9fd06cd4d6300283@zhaoxin.com> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 24 Jul 2020 12:57:49 +0000 WeitaoWang-oc wrote: > On Thu, 23 Jul 2020 12:38:21 -0400, Alan wrote: > > On Thu, Jul 23, 2020 at 10:17:35AM -0600, Alex Williamson wrote: > > > The IOMMU grouping restriction does solve the hardware issue, so long > > > as one driver doesn't blindly assume the driver private data for > > > another device and modify it. > > > > Correction: The IOMMU grouping restriction solves the hardware issue for > > vfio-pci. It won't necessarily help if some other driver comes along > > and wants to bind to this hardware. > > > > > I do agree that your solution would > > > work, requiring all devices are unbound before any can be bound, but it > > > also seems difficult to manage. The issue is largely unique to USB > > > AFAIK. On the other hand, drivers coordinating with each other to > > > register their _private_ data as share-able within a set of drivers > > > seems like a much more direct and explicit interaction between the > > > drivers. Thanks, > > > > Yes, that makes sense. But it would have to be implemented in the > > driver core, not in particular subsystems like USB or PCI. And it might > > be seen as overkill, given that only UHCI/OHCI/EHCI devices require this > > sort of sharing AFAIK. > > > > Also, when you think about it, what form would such coordination among > > drivers take? From your description, it sounds like the drivers would > > agree to avoid accessing each other's private data if the proper > > registration wasn't in place. > > > > On the other hand, a stronger and perhaps more robust approach would be > > to enforce the condition that non-cooperating drivers are never bound to > > devices in the same group at the same time. That's basically what I'm > > proposing here -- the question is whether the enforcement should be > > instituted in the kernel or should merely be part of a standard protocol > > followed by userspace drivers. > > > > Given that it's currently needed in only one place, it seems reasonable > > to leave this as a "gentlemen's agreement" in userspace for the time > > being instead of adding it to the kernel. > > > > Provided that EHCI and UHCI host controller declare not support P2P and > ACS. So, we can assign EHCI and UHCI host controller to different IOMMU > group separately. We assign EHCI host controller to host and assign UHCI > host controller to VM. Then, ehci_hcd driver load/unload operation in host > will cause the same issue as discussed And you have an example of such a device? I expect these do not exist, nor should they. It seems like it would be an improper use of ACS. Thanks, Alex