From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE078C64E8A for ; Fri, 20 Nov 2020 11:04:09 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4637424124 for ; Fri, 20 Nov 2020 11:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="rXo0btu+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4637424124 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 90BB42E0E8; Fri, 20 Nov 2020 11:04:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tb+rV-FVcxCi; Fri, 20 Nov 2020 11:04:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 8A0B52038D; Fri, 20 Nov 2020 11:04:03 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5C50BC163C; Fri, 20 Nov 2020 11:04:03 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 30F9DC0891 for ; Fri, 20 Nov 2020 11:04:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 1CF9886DC2 for ; Fri, 20 Nov 2020 11:04:02 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NtogPGzdtHO3 for ; Fri, 20 Nov 2020 11:04:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 950CA86DAF for ; Fri, 20 Nov 2020 11:04:01 +0000 (UTC) Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1C3422255; Fri, 20 Nov 2020 11:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605870241; bh=mX/p1HAFLIFTQg9G08w9hM65P8tSBhCpzNO+qokhof8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rXo0btu+7YkF0HfhHhr9fCe0rvUbz1OzazP7il7YfgjZzs5kJLVRrJ4JFG8g1lOFS Iy1YuX71Hx5/Ifp0hXjR2x2rZtrqfX5+fJ5yxza2kKhSq99Ej//3hSDe/lQliIoqIo naTlp+uDe0OmsgL15I7b68KRL5kMzW/LBqHN5yiM= Date: Fri, 20 Nov 2020 11:03:55 +0000 From: Will Deacon To: Lu Baolu Subject: Re: [Patch V8 1/3] iommu: Add support to change default domain of an iommu group Message-ID: <20201120110355.GA6151@willie-the-truck> References: <20200925190620.18732-1-ashok.raj@intel.com> <20200925190620.18732-2-ashok.raj@intel.com> <20201118135153.GB2177@willie-the-truck> <568d4dee-ad10-ca4f-d51a-8909afb6b782@linux.intel.com> <20201119085303.GA3599@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Cc: Will Deacon , iommu@lists.linux-foundation.org, Robin Murphy , Ashok Raj , Christoph Hellwig X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Fri, Nov 20, 2020 at 10:11:58AM +0800, Lu Baolu wrote: > On 11/19/20 4:53 PM, Will Deacon wrote: > > On Thu, Nov 19, 2020 at 10:18:05AM +0800, Lu Baolu wrote: > > > On 11/18/20 9:51 PM, Will Deacon wrote: > > > > On Fri, Sep 25, 2020 at 12:06:18PM -0700, Ashok Raj wrote: > > > > > From: Sai Praneeth Prakhya > > > > [...] > > > > > > > +free_new_domain: > > > > > + iommu_domain_free(group->default_domain); > > > > > + group->default_domain = prev_dom; > > > > > + group->domain = prev_dom;i > > > > > > > > Hmm. This seems to rely on all users of group->default_domain holding the > > > > group->mutex. Have you confirmed that this is the case? There's a funny > > > > use of iommu_group_get() in the exynos IOMMU driver at least. > > > > > > Emm. This change happens within the area with group->mutex held. Or I > > > am not getting your point? > > > > Yeah, sorry, I wasn't very clear. This code holds the group->mutex, and it > > relies on _anybody_ else who wants to inspect group->default_domain also > > holding that mutex, otherwise they could observe a transient domain pointer > > which we free on the failure path here. > > Clear to me now. Thanks for explanation. :-) > > Changing default domain through sysfs requires the users to ubind any > driver from the devices in the group. There's a check code and return > failure if this requirement doesn't meet. > > So we only need to consider the device release path. device_lock(dev) is > used in this patch to guarantee that no device release happens at the > same time. Aha, thanks. Please can you add a comment for future reference? > > > > > My question is whether or not there is code that inspects > > group->default_domain without group->mutex held? The exynos case doesn't > > obviously hold it, and I'd like to make sure that there aren't others that > > we need to worry about. > > I searched the code. The exynos is the only case that inspects > group->default_domain without holding the mutex during run time. It's in > the device release path, so I think it's safe. Great, thanks for looking. Will _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu