Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp942840rwb; Wed, 7 Dec 2022 06:56:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fmHLgS+8s7FJD8FVabq7knl0Uzh77Kgi7GbcHMZSa0gnwQWmWaAq4glWsko0b0Ku8lGLA X-Received: by 2002:aa7:da10:0:b0:46c:43ff:6961 with SMTP id r16-20020aa7da10000000b0046c43ff6961mr19226399eds.14.1670424992296; Wed, 07 Dec 2022 06:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670424992; cv=none; d=google.com; s=arc-20160816; b=OjJUprRORzY+KyPgr9QKwlpzBSqewfghhtK7OqPfsTlOBjjDFIDHoBr1J4AdAmtVK1 lDFh0BbL0XxyK5xUFysF113bHtGptqdH8iwL6CNk9ePXZUD1bMReIDSju5gtzcAGK90o P5Rs31zUyRgJgItfCBqqzIhdq/qikkleZNrWJ2jUt8/gpEr2X4mTOz2AfpYWtPS3f8L6 tHewsQzPHcGIwJn/uOej0lWpOVsKU5NbiADI2pbUigFT2eB8TV+SgAQ9dnpkPwKVT/OB wrECJ7mcQrEjwHJ/5xZS5p4Ta2jrw0LNJJ+taMUcodpoKffu0sQo9jFqad1G53v8byOZ shLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=YvL4Rtud+P0zaL4/YxF93cvP9IbqWfH6Ifp9mV/wBYA=; b=HrQNLo7whigJ0nCgnwYL6h4tIwRWn+5pRukQ3Gghoio0CzDBjT22amC9/PPWntGm0e vYbBn7XKzdps53fJT1mHjJZNBFbCF+YKYLrcTzdtsisCgOgubfBNwEq9e8t5EBZbPUeS Lg9NNqHMy5mPd6QpIMUKGja/TkrDW7KAMWirjocs0Wi0AxLwD3qABVo0qbPHL1phbuQM Z6wimzdjmmrchBZLMyV1nnv9QEvKUyCv17i9qGifu6Rf3koI3CULm7imAq/FIpwHu3oa h21tOZdjJf3oLwULrh3gfe0JWAagXWISu+DZTGAwTWvPAZly/y0mqfT3T4LWyEIvCSyH q/zA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb15-20020a170907160f00b0073dcb2ec4d2si17605011ejc.889.2022.12.07.06.56.12; Wed, 07 Dec 2022 06:56:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229843AbiLGOS6 (ORCPT + 77 others); Wed, 7 Dec 2022 09:18:58 -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 X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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