Message ID | 20230306025804.13912-1-baolu.lu@linux.intel.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1631607wrd; Sun, 5 Mar 2023 19:04:54 -0800 (PST) X-Google-Smtp-Source: AK7set/LYBRV5s6U29zhIMXNagQ/B+0B2TdnThh4A+c6rtn6ZBiosLUrNz2FlOnshVDVte65P2/G X-Received: by 2002:a17:906:dd7:b0:87e:a34b:9e2b with SMTP id p23-20020a1709060dd700b0087ea34b9e2bmr9483381eji.28.1678071894719; Sun, 05 Mar 2023 19:04:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678071894; cv=none; d=google.com; s=arc-20160816; b=wgkRf8/4AZFDk+Oi6tOsO/OeAchj7bq/TDXJtmp6w82HnunZqGQiW+tjLbQZZKXarH M84cylOLqsw6+ELko+lDLILZqKrF8nYHozXdRMC9OIAik4aS2lnYd53Qq16vfbWuCnOG SJF5cDDcw3iMoz3RmnTTfcl25F3qMeHvGLYH0gVvaEJEMtb5Ot5g/WouHSk5AFIavNkd 1XCNKYfnl6qNseJw1jTw3bdE/G9D9RuqSZPUURIsTfbWCiGaSJZ9LjeOYXpR36age8Ni 2KwhdZfWEzCzDcW0UChfgjJ1EhtzJrALCkHUnzb80qRB6AQxDfjDhT481h1+3LORyRxb qozA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WGTW8zl9Pw57+o9qtycMYDjAkzQsXMqvGcSNBpcTef8=; b=Mh3Gt83vV7tOb+B0bPrauz+Ac2k6eCxAryZ7qfv24kLAB5sEpH7LiSN1/idqJiDFGG OQG80UPS5jMyG076UWSuWN/AgkpFBcjeJpo7+3FnYUr3Db3eWoJUS0BJNUvUoZXSBI98 j2qenGMykhVFGaT2uq6B8GN5pJrRAL5WGacrK0fFqNBkSXHZsYlEth3/usUG92MJL/v9 pnEf/JwuI8brOEVPyzTM5E3cdUdJClpGNPxtjwkLRrKX21kzl7Z8JQXjseeDoiR3a4rH vaRWLbD3zqjv7JlODB8w1wPVhTOH+1nMPG9L1SC2StRiurC/lJdAE3/U07JvPq2SY8In Ij6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Zfk1Mifl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020a17090627ce00b008db6177cc3bsi2522044ejc.525.2023.03.05.19.04.31; Sun, 05 Mar 2023 19:04:54 -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; dkim=pass header.i=@intel.com header.s=Intel header.b=Zfk1Mifl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229554AbjCFC7S (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Sun, 5 Mar 2023 21:59:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229486AbjCFC7Q (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 5 Mar 2023 21:59:16 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1747010419 for <linux-kernel@vger.kernel.org>; Sun, 5 Mar 2023 18:59:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678071556; x=1709607556; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=frp35F+rukJEyC3hLBZu7cN+WEg26QfBVYPdBkx+1Ew=; b=Zfk1MifloVVXZLmPoBin77GrY8NTiGxu5kgoEAXUPdQWPkRWsyhXocLj 2CV+TdTnUi/cSNdQcDuxWaLsKrZ4xxV7Mi72aKzaoUWaOn68xkyfQn4c3 YlRicKfZt7/ASWiILgJrZFDu4E1791EJP+uu7+9HmR5nL1PA5ady9yQOJ rqmdA3OYn/mwX6h48ic294j2Ed1hLzxfo5qrZwSLPt7eOfwqNwoHzdkEn xZrU5jra5oSdoA8DF+DSN3HJxsQ8hGYY4JQgQZ4aprWWByvGEJOzkvjKH FThWmyFMm4VoWlVifpHi8y4ZVqaDebwnv5A/YBwTBiB+Hg4Z3yi48WRZG g==; X-IronPort-AV: E=McAfee;i="6500,9779,10640"; a="363071469" X-IronPort-AV: E=Sophos;i="5.98,236,1673942400"; d="scan'208";a="363071469" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2023 18:59:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10640"; a="765072466" X-IronPort-AV: E=Sophos;i="5.98,236,1673942400"; d="scan'208";a="765072466" Received: from allen-box.sh.intel.com ([10.239.159.48]) by FMSMGA003.fm.intel.com with ESMTP; 05 Mar 2023 18:59:13 -0800 From: Lu Baolu <baolu.lu@linux.intel.com> To: iommu@lists.linux.dev Cc: Joerg Roedel <joro@8bytes.org>, Jason Gunthorpe <jgg@nvidia.com>, Christoph Hellwig <hch@infradead.org>, Kevin Tian <kevin.tian@intel.com>, Will Deacon <will@kernel.org>, Robin Murphy <robin.murphy@arm.com>, linux-kernel@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com> Subject: [PATCH v3 0/6] iommu: Extend changing default domain to normal group Date: Mon, 6 Mar 2023 10:57:58 +0800 Message-Id: <20230306025804.13912-1-baolu.lu@linux.intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759585914888862601?= X-GMAIL-MSGID: =?utf-8?q?1759585914888862601?= |
Series |
iommu: Extend changing default domain to normal group
|
|
Message
Baolu Lu
March 6, 2023, 2:57 a.m. UTC
The IOMMU group sysfs interface allows users to change the default domain of a group. The current implementation uses device_lock() to make sure that the devices in the group are not bound to any driver and won't be bound during the process of changing the default domain. In order to avoid a possible deadlock caused by lock order of device_lock and group->mutex, it limits the functionality to singleton groups only. The recently implemented DMA ownership framework can be applied here to replace device_lock(). In addition, use group->mutex to ensure that the iommu ops of the device are always valid during the process of changing default domain. With above replacement and enhancement, the device_lock() could be removed and the singleton-group-only limitation could be removed. This series is based on v6.3-rc1 with below series from Robin applied, https://lore.kernel.org/linux-iommu/cover.1674753627.git.robin.murphy@arm.com/ The whole series is also available on github: https://github.com/LuBaolu/intel-iommu/commits/iommu-sysfs-default-domain-extension-v3 Please help to review and suggest. Change log: v3: - "arm_iommu_detach_device() is a noop" is not entirely right. It is used to to make the iommu driver stop using the domain that it is about to free. It cannot be a NOP or it is a UAF. [Jason] - Use Jason's new arm_iommu_release_device() proposal instead. v2: - https://lore.kernel.org/linux-iommu/20230217094736.159005-1-baolu.lu@linux.intel.com/ - Use group->mutex instead of an additional rw lock. v1: initial post - https://lore.kernel.org/linux-iommu/20230213074941.919324-1-baolu.lu@linux.intel.com/ Lu Baolu (6): ARM/dma-mapping: Add arm_iommu_release_device() iommu: Split iommu_group_remove_device() into helpers iommu: Same critical region for device release and removal iommu: Move lock from iommu_change_dev_def_domain() to its caller iommu: Replace device_lock() with group->mutex iommu: Cleanup iommu_change_dev_def_domain() arch/arm/include/asm/dma-iommu.h | 1 + arch/arm/mm/dma-mapping.c | 25 ++ drivers/iommu/iommu.c | 270 ++++++++---------- drivers/iommu/ipmmu-vmsa.c | 15 +- .../ABI/testing/sysfs-kernel-iommu_groups | 1 - 5 files changed, 156 insertions(+), 156 deletions(-)
Comments
On Mon, Mar 06, 2023 at 10:57:58AM +0800, Lu Baolu wrote: > The IOMMU group sysfs interface allows users to change the default > domain of a group. The current implementation uses device_lock() to make > sure that the devices in the group are not bound to any driver and won't > be bound during the process of changing the default domain. In order to > avoid a possible deadlock caused by lock order of device_lock and > group->mutex, it limits the functionality to singleton groups only. > > The recently implemented DMA ownership framework can be applied here to > replace device_lock(). In addition, use group->mutex to ensure that the > iommu ops of the device are always valid during the process of changing > default domain. > > With above replacement and enhancement, the device_lock() could be > removed and the singleton-group-only limitation could be removed. > > This series is based on v6.3-rc1 with below series from Robin applied, > https://lore.kernel.org/linux-iommu/cover.1674753627.git.robin.murphy@arm.com/ Joerg can you help Lu with patch planning here? Can we get Robin's series, this one and a maybe few more that clash on this for the cycle? Should this one go before Robin's series? It didn't seem obviously dependent beyond using the same helper function? Thanks, Jason