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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AA1CC4708E for ; Wed, 7 Dec 2022 14:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiLGOS4 (ORCPT ); Wed, 7 Dec 2022 09:18:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiLGOSp (ORCPT ); Wed, 7 Dec 2022 09:18:45 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67A3355CB6; Wed, 7 Dec 2022 06:18:44 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9A0B723A; Wed, 7 Dec 2022 06:18:50 -0800 (PST) Received: from [10.57.74.110] (unknown [10.57.74.110]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1D7F23F73D; Wed, 7 Dec 2022 06:18:40 -0800 (PST) Message-ID: <73a033d6-c1fe-c012-4648-774aa5b93a61@arm.com> Date: Wed, 7 Dec 2022 14:18:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [PATCH v2 4/7] iommu: Let iommu.strict override ops->def_domain_type Content-Language: en-GB To: Jason Gunthorpe , Baolu Lu Cc: Niklas Schnelle , Matthew Rosato , Gerd Bayer , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Wenjia Zhang , Pierre Morel , linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org, Julian Ruess References: <52fe7769ca5b66523c2c93c7d46ebc17dc144aca.camel@linux.ibm.com> <6c4c3a3e-1d8d-7994-3c03-388ef63dddb3@arm.com> <4b34be4433856d9a3a5bf13dad7a77c1ba93db13.camel@linux.ibm.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On 2022-12-07 13:23, Jason Gunthorpe wrote: > On Wed, Dec 07, 2022 at 09:18:19PM +0800, Baolu Lu wrote: > >>> - /* Check if the device in the group still has a driver bound to it */ >>> - device_lock(dev); >> >> With device_lock() removed, this probably races with the >> iommu_release_device() path? group->mutex seems insufficient to avoid >> the race. Perhaps I missed anything. > > This path only deals with group, so there is no 'dev' and no race with > removal. If we can now use the ownership mechanism to enforce the required constraints for change_dev_def_domain, that would be worthwhile (and a lot clearer) as a separate patch in its own right. Thanks, Robin. > Later on we obtain the group mutex and then extract the first device > from the group list as a representative device of the group - eg to > perform iommu_domain allocation. > > Under the group mutex devices on the device list cannot become > invalid. > > It is the same reasoning we use in other places that iterate over the > group device list under lock. > > Jason