From patchwork Fri Jul 7 01:34:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2960221vqx; Thu, 6 Jul 2023 19:02:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+3SgF+vZUw/r3YUn5WezoqDyx/D7P6ATjIsSD49hpOnyehi7s4njCa4KHawK0EJ8KuG5y X-Received: by 2002:a05:6870:a693:b0:1a6:442d:ef60 with SMTP id i19-20020a056870a69300b001a6442def60mr4308949oam.30.1688695320654; Thu, 06 Jul 2023 19:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688695320; cv=none; d=google.com; s=arc-20160816; b=vQb3r8KJ9rQDqH+zIRsmg4Kso+4HxyvuLHxNcerEvwtVI/YZWvZRF4cRMjN+eOyObG bwbLof6zSBx/o2nNHVpTa9uT1JgzRvbHjL+Xs+IRUBfYwn+tdZKhkbVVilWDDbjOMzg1 8IcDWKY6rjEhv9UEH5Kddylc8sUeeYVN5M1HmiLoM9d36W1yJaR5PAjV5YaRuLI+UhjO +YVcwWKJXekF+fJN45X02y/XBWkX6k40Z8WwMWTAw7VT0qEhpqdwiBMR/gfgRLTe2hiU AAtyV3TkmJ5Y9Ygya9paO48ZUtGmJOo7XFqvGV1qkMVb5U47Ly5KIi6mjzdJ1sEJfXSP MOHg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rrlyzb1rYGTATfU6UUjoGvhPJ61GIDeTuqKLDKr3xwo=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=08gduwAMI9aEFnapU1iBE5OpvXUrROEPV8Jsm58uruVk7ycWSDwULP1aKgOBMuuTkI 3P7up/PmtuXp5AZ9gobX+nfdxMx0aoXjyyHuIyP4TIj6dR3bOpSikdvUjfW/Moa2/8OQ Xb+6HZJCEZ4/7tkvgy0X4DlhYGHUig4UzoeCSy3W7lwZzH7Jovi39xtzzI7xkivO33DS AmJBfMjzc/ZPWbPNddVqMpJCF3WIhz5N24rG5iO10E50te545azPwx+DHrneu6xj24Rz rr2Q1GteMnz/bYy6L2UlgKbcHc3IL6sDMNHMszMs3kGv+7gy5NLqUb8EwF+Va+Cz4HUo PAhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="YBp/TkGN"; 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 w7-20020a17090a5e0700b002639c4f81d5si939842pjf.147.2023.07.06.19.01.46; Thu, 06 Jul 2023 19:02:00 -0700 (PDT) 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="YBp/TkGN"; 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 S231887AbjGGBfE (ORCPT + 99 others); Thu, 6 Jul 2023 21:35:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjGGBfC (ORCPT ); Thu, 6 Jul 2023 21:35:02 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAD061BDB for ; Thu, 6 Jul 2023 18:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693701; x=1720229701; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=w9KMIa9FeqUiMJ7hHb6xqUyUsuqFNPtVvcMNCNqbITA=; b=YBp/TkGNbvvUfW95TUSywl1jB/MT3fSuzbYJjS6vjZ5iENKxmvDiYVMV AsffmE/WAjmoTTxYunt71QKnhOWY1aTvAZdaSSN6nYPlRJpR5DuKEr0He DqRAxu2MgkGFO0gTKxfltlVE2eZbKToIJNUs7mMy1LISQ/La9tvBSv2Hg KETUvya5BM9j1iFHugNv/PTFh4tHN2F2g6dbfXJvaMJ5K0zTLmWSNT1rS DURrZsmNA0lyLyrH61Ijcoo7RewjkZS1AGiY37O4htuLcT+zEQsGyXbVY U5jHES+Uo3Wwknnjpbmms5iaBltbJPBi5vrVKXRE8ew+6WR6/G5qx4qnN w==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832245" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832245" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791292" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791292" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:34:58 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 1/6] iommu: Add two pasid helper functions Date: Fri, 7 Jul 2023 09:34:36 +0800 Message-Id: <20230707013441.365583-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770725384845703988?= X-GMAIL-MSGID: =?utf-8?q?1770725384845703988?= mm_get_pasid() is for getting mm pasid value and mm_set_pasid() is for setting mm pasid value. The motivation is to replace mm->pasid with an iommu private data structure that is introduced in a later patch. Signed-off-by: Tina Zhang --- arch/x86/kernel/traps.c | 2 +- include/linux/iommu.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 58b1f208eff51..8587461c43664 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -678,7 +678,7 @@ static bool try_fixup_enqcmd_gp(void) if (!mm_valid_pasid(current->mm)) return false; - pasid = current->mm->pasid; + pasid = mm_get_pasid(current->mm); /* * Did this thread already have its PASID activated? diff --git a/include/linux/iommu.h b/include/linux/iommu.h index e8c9a7da10609..d39e647219eb8 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1174,6 +1174,15 @@ static inline bool mm_valid_pasid(struct mm_struct *mm) { return mm->pasid != IOMMU_PASID_INVALID; } +static inline u32 mm_get_pasid(struct mm_struct *mm) +{ + return mm->pasid; +} + +static inline void mm_set_pasid(struct mm_struct *mm, u32 pasid) +{ + mm->pasid = pasid; +} void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); @@ -1196,6 +1205,11 @@ static inline u32 iommu_sva_get_pasid(struct iommu_sva *handle) } static inline void mm_pasid_init(struct mm_struct *mm) {} static inline bool mm_valid_pasid(struct mm_struct *mm) { return false; } +static inline u32 mm_get_pasid(struct mm_struct *mm) +{ + return IOMMU_PASID_INVALID; +} +static inline void mm_set_pasid(struct mm_struct *mm, u32 pasid) {} static inline void mm_pasid_drop(struct mm_struct *mm) {} #endif /* CONFIG_IOMMU_SVA */ From patchwork Fri Jul 7 01:34:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116899 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2951021vqx; Thu, 6 Jul 2023 18:38:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlGT+SWG0sknoYEALofZH29kre8c5cwyCEjr6C38Jb9w8DWT5W7vK1QzuO1nSWP9HMWw3m7P X-Received: by 2002:a81:4815:0:b0:579:e374:c915 with SMTP id v21-20020a814815000000b00579e374c915mr3503532ywa.37.1688693881218; Thu, 06 Jul 2023 18:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688693881; cv=none; d=google.com; s=arc-20160816; b=peIYsPOnv3ZOwiGtNSsJQv1d8gZthQ9HjOz8H53++Bo7usIJ/EntV4FGYeONcKUtCi ZbGIHfMGS9r/TsLJLG1SHCxR9MPyga5Ybh80yP9QkMKTCI6U/VHuzqpResf9+I8OfiFQ 3uaCXydoJJI5QaaAzhpyE6NvJ+ytotFtQQHEns+Q6nOEVqCR/59+9eAv8nG/SYIVrWC6 jJqk9i5PsFDe/QESB/08urYUtif9vrdP6waJY1rNmzlzVmQWmuO3pVKWiq8h6B8CP49z ESuDlJiG0aVDrFk5iPOQhKFQL2Ec5Gd0Yw4NW0v3rUeS7rrZ+UAJen8W3GIwvWa+YSni xIoQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=eDr28+zihtSiM8T9S0gRAkLXPBO+w5xdE+rXy9BeVDs=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=AG0k+VAvyICVy0XQ20c31gPsyXzK3+T+xU4uYM8cO5ObGfdzupvGf5fbv8lQivwpNI qUIgETFhTTZL598JnHaHww6m9xVvrNOipe/O8zXpZQnZ9u97F3lxF1cH/dvaTCr/VTrX vsZ/66KiUHxKVExJ1Ct1LwyuNPCbvKZ1qhnHgmek9VtrhwXAY2DiFef1wCxWQ2jUaZlP rBpLQ2wxf06VJO5iku0QJOIKUktqSzicwLB1kR9ud1Z+tGn5DsFpiWYD07dxIttjm5JZ AKinhp7POpBr/4ynwkelO1lrCTm6m95Szx+Gsc4VNhtY8IMT3+/nUqlp1C6TKiuuHbf+ ejuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iMkOG0cd; 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 k28-20020a635a5c000000b0055b618c77efsi2642146pgm.179.2023.07.06.18.37.45; Thu, 06 Jul 2023 18:38:01 -0700 (PDT) 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=iMkOG0cd; 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 S231906AbjGGBfK (ORCPT + 99 others); Thu, 6 Jul 2023 21:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231895AbjGGBfG (ORCPT ); Thu, 6 Jul 2023 21:35:06 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304861BF4 for ; Thu, 6 Jul 2023 18:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693705; x=1720229705; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=M4yHvqOjBvNXxYpbH9KMyRDRPz6GZ0HRmaDFz16Hw8M=; b=iMkOG0cdzZxE0YBkisSQc6MRTRxq0LRfWcof/ixYu60hOto1Bwe3W/Hb Pj3sc+yg1WFOAKuuK6OnbRJjDakz5gSjf/XPkaiCp6Qtp7cpG2TeuoPhN TjHK065Tj+v4MWyByoRtvpbuGl5Yz3rW5293mNbKYQxMZtIihuEjmkYJD qZ2Oo9vbTaP3A/6g7xOTiJvuVAEWfCR+GWgJ5pc5BRy27nMrQj1eEBNd9 xYVU/D5pv5/WgPYIzhSABOz1BYBI1riarm0/msESLCNa8tcDaP27k1NDs cqXxNwADiaqph9GAU26cHcJdrpvFmG6ynd/8x8IpLAb19yiqxVD7GufYZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832259" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832259" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791308" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791308" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:01 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 2/6] iommu: Call helper functions to get/set assigned pasid value Date: Fri, 7 Jul 2023 09:34:37 +0800 Message-Id: <20230707013441.365583-3-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770723874811008648?= X-GMAIL-MSGID: =?utf-8?q?1770723874811008648?= Use the helper function mm_get_pasid() to get the mm assigned pasid value and mm_set_pasid() to set the mm assigned pasid value. Signed-off-by: Tina Zhang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 12 ++++++------ drivers/iommu/intel/svm.c | 8 ++++---- drivers/iommu/iommu-sva.c | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c index a5a63b1c947eb..0b455654d3650 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c @@ -204,7 +204,7 @@ static void arm_smmu_mm_invalidate_range(struct mmu_notifier *mn, if (!(smmu_domain->smmu->features & ARM_SMMU_FEAT_BTM)) arm_smmu_tlb_inv_range_asid(start, size, smmu_mn->cd->asid, PAGE_SIZE, false, smmu_domain); - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, start, size); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), start, size); } static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) @@ -222,10 +222,10 @@ static void arm_smmu_mm_release(struct mmu_notifier *mn, struct mm_struct *mm) * DMA may still be running. Keep the cd valid to avoid C_BAD_CD events, * but disable translation. */ - arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, &quiet_cd); + arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), &quiet_cd); arm_smmu_tlb_inv_asid(smmu_domain->smmu, smmu_mn->cd->asid); - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, 0, 0); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), 0, 0); smmu_mn->cleared = true; mutex_unlock(&sva_lock); @@ -279,7 +279,7 @@ arm_smmu_mmu_notifier_get(struct arm_smmu_domain *smmu_domain, goto err_free_cd; } - ret = arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, cd); + ret = arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), cd); if (ret) goto err_put_notifier; @@ -304,7 +304,7 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn) return; list_del(&smmu_mn->list); - arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, NULL); + arm_smmu_write_ctx_desc(smmu_domain, mm_get_pasid(mm), NULL); /* * If we went through clear(), we've already invalidated, and no @@ -312,7 +312,7 @@ static void arm_smmu_mmu_notifier_put(struct arm_smmu_mmu_notifier *smmu_mn) */ if (!smmu_mn->cleared) { arm_smmu_tlb_inv_asid(smmu_domain->smmu, cd->asid); - arm_smmu_atc_inv_domain(smmu_domain, mm->pasid, 0, 0); + arm_smmu_atc_inv_domain(smmu_domain, mm_get_pasid(mm), 0, 0); } /* Frees smmu_mn */ diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index e95b339e9cdc0..e6377cff6a935 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel/svm.c @@ -306,13 +306,13 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, unsigned long sflags; int ret = 0; - svm = pasid_private_find(mm->pasid); + svm = pasid_private_find(mm_get_pasid(mm)); if (!svm) { svm = kzalloc(sizeof(*svm), GFP_KERNEL); if (!svm) return -ENOMEM; - svm->pasid = mm->pasid; + svm->pasid = mm_get_pasid(mm); svm->mm = mm; INIT_LIST_HEAD_RCU(&svm->devs); @@ -350,7 +350,7 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, /* Setup the pasid table: */ sflags = cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0; - ret = intel_pasid_setup_first_level(iommu, dev, mm->pgd, mm->pasid, + ret = intel_pasid_setup_first_level(iommu, dev, mm->pgd, mm_get_pasid(mm), FLPT_DEFAULT_DID, sflags); if (ret) goto free_sdev; @@ -364,7 +364,7 @@ static int intel_svm_bind_mm(struct intel_iommu *iommu, struct device *dev, free_svm: if (list_empty(&svm->devs)) { mmu_notifier_unregister(&svm->notifier, mm); - pasid_private_remove(mm->pasid); + pasid_private_remove(mm_get_pasid(mm)); kfree(svm); } diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 9821bc44f5ac1..7a41b6510e385 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -28,7 +28,7 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma mutex_lock(&iommu_sva_lock); /* Is a PASID already associated with this mm? */ if (mm_valid_pasid(mm)) { - if (mm->pasid < min || mm->pasid > max) + if (mm_get_pasid(mm) < min || mm_get_pasid(mm) > max) ret = -EOVERFLOW; goto out; } @@ -36,7 +36,7 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL); if (ret < min) goto out; - mm->pasid = ret; + mm_set_pasid(mm, ret); ret = 0; out: mutex_unlock(&iommu_sva_lock); @@ -70,7 +70,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm if (!max_pasids) return ERR_PTR(-EOPNOTSUPP); - /* Allocate mm->pasid if necessary. */ + /* Allocate pasid if necessary. */ ret = iommu_sva_alloc_pasid(mm, 1, max_pasids - 1); if (ret) return ERR_PTR(ret); @@ -81,7 +81,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm mutex_lock(&iommu_sva_lock); /* Search for an existing domain. */ - domain = iommu_get_domain_for_dev_pasid(dev, mm->pasid, + domain = iommu_get_domain_for_dev_pasid(dev, mm_get_pasid(mm), IOMMU_DOMAIN_SVA); if (IS_ERR(domain)) { ret = PTR_ERR(domain); @@ -100,7 +100,7 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm goto out_unlock; } - ret = iommu_attach_device_pasid(domain, dev, mm->pasid); + ret = iommu_attach_device_pasid(domain, dev, mm_get_pasid(mm)); if (ret) goto out_free_domain; domain->users = 1; @@ -132,7 +132,7 @@ EXPORT_SYMBOL_GPL(iommu_sva_bind_device); void iommu_sva_unbind_device(struct iommu_sva *handle) { struct iommu_domain *domain = handle->domain; - ioasid_t pasid = domain->mm->pasid; + ioasid_t pasid = mm_get_pasid(domain->mm); struct device *dev = handle->dev; mutex_lock(&iommu_sva_lock); @@ -149,7 +149,7 @@ u32 iommu_sva_get_pasid(struct iommu_sva *handle) { struct iommu_domain *domain = handle->domain; - return domain->mm->pasid; + return mm_get_pasid(domain->mm); } EXPORT_SYMBOL_GPL(iommu_sva_get_pasid); @@ -216,5 +216,5 @@ void mm_pasid_drop(struct mm_struct *mm) if (likely(!mm_valid_pasid(mm))) return; - ida_free(&iommu_global_pasid_ida, mm->pasid); + ida_free(&iommu_global_pasid_ida, mm_get_pasid(mm)); } From patchwork Fri Jul 7 01:34:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116901 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2955050vqx; Thu, 6 Jul 2023 18:48:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFxB4vPAgMhJVcNRZnG4fMmVhJL9WxhfIWIsbAopMMXXVrYtFINeZbUIqZzt9I0i4T6k2ky X-Received: by 2002:a17:902:c407:b0:1b8:862:74ee with SMTP id k7-20020a170902c40700b001b8086274eemr4938229plk.11.1688694528504; Thu, 06 Jul 2023 18:48:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688694528; cv=none; d=google.com; s=arc-20160816; b=ZR+w/CDp49mm8+5ExJ1BCiAGE7UO979wSLeY0MO8hv8+RWoIxZJG0OdQvfjMjIv7em Y00j5rHXxGx2IgI23tzvcVO/rB9szvVmjacfi8yQG98AgxUtFNAIN1Nm036GGDnWFtKr wAeNYIGVtLSjdY6rb6CHUBycn+ECYcjVC14q9v7I1+8TLuOnylDYrmlwmNlyyV3/H4EQ 9l5/T8nbAgE5G3CLvClrTWaQ7nqWw7fks9prbGHaDCskAWkd8l3zXp9GLVb0g2+WnY22 JKeW54bGToOZvQk6cJdtfOltF0+agCL53IBTIOg8/qa24Mzn1/g5O16VcUc6lAaUSL+z rwKA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9TP+ZihLKz4yadXoJwG8HSp5GNv75e/DczGEyoHV274=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=jrlfgRBtRmqN2ZvcbtUZVBa9elP1mlr+JKQZ8JdguS7Ebkgf2KScYlxXV0jpC/QyuX +hgZGo1+M8K1X+CcHKQDviJIOZ6Ii7/OWnNMaktEmUpgfjMTHf7Qs3fqAel2Nq926xX1 NXlaoakOsvRU2WCEOZACL27TOvawf68lvVrP40G/0So0PZUX50NdVPe8MiNoS79Pb23/ Cv2ijlQo8mLaoXk9Rj/3RgPHJAKteFTGyNUzhcaB1ilawQ8Ldlu2zFlFkQ8ZzXSV2t4O jPNhRFn700sl7euYGC9FVM86KDBylvIalRJ60u0suuOH7VoMfoAq7Q5hHFE59Jt9Nj4U L8aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nubovSnn; 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 n8-20020a170902e54800b001b20e2ba8e1si2840063plf.23.2023.07.06.18.48.34; Thu, 06 Jul 2023 18:48:48 -0700 (PDT) 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=nubovSnn; 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 S231895AbjGGBfP (ORCPT + 99 others); Thu, 6 Jul 2023 21:35:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbjGGBfN (ORCPT ); Thu, 6 Jul 2023 21:35:13 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B61751BFC for ; Thu, 6 Jul 2023 18:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693709; x=1720229709; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JfdYLppNc9eLDWu4uhQ6N/Y+k4M58Rts/UgDTo8w0sg=; b=nubovSnnAYjxeAk/5Effg9ptGHCTnHx0xH1eRB6LtoUUs0h6pLiSIq7+ 3ekT+u8MTk8pOhVdMIh4/zJrENAhX0ggFDS0N7Jz8kNNK79c1e6HuuvI5 8BSpsaS6KP/gLRTsgKTtpX5oY6PjpAKKF3jxYJzBKquBiidCJ1wfxrDtf XxCV7d/N92YdMWIbVxDPj5rkW5oSFEGCL5ZcGZLBqyTPnyBec7SVq6fb6 fKcOSq+lFjg0KxVvovXzqF4OB2PZT/itAU6comSL3uyGD/M3gtSLPr62b CaynUUMwvvUDynEa2iVxK3n8G0AGfNgDNwz7uzneHc7Hc0DD0SJ2tK+6n Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832273" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832273" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791324" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791324" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:05 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 3/6] iommu: Introduce struct iommu_mm_data Date: Fri, 7 Jul 2023 09:34:38 +0800 Message-Id: <20230707013441.365583-4-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770724553575401712?= X-GMAIL-MSGID: =?utf-8?q?1770724553575401712?= To make sva domain 1:1 with mm pasid, mm needs to keep reference to the sva domain as well as keeping the information of mm pasid. Introduce struct iommu_mm_data to wrap the information up. When a process is created, the mm pasid is initialized as IOMMU_PASID_ INVALID. The default_iommu_mms is introduced to initialize an mm pasid with that default value. Signed-off-by: Tina Zhang --- drivers/iommu/iommu.c | 2 ++ include/linux/iommu.h | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f1dcfa3f1a1b4..35fa1c1b12826 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -83,6 +83,8 @@ static const char * const iommu_group_resv_type_string[] = { [IOMMU_RESV_SW_MSI] = "msi", }; +struct iommu_mm_data default_iommu_mm = { IOMMU_PASID_INVALID, NULL }; + #define IOMMU_CMD_LINE_DMA_API BIT(0) #define IOMMU_CMD_LINE_STRICT BIT(1) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d39e647219eb8..20135912584ba 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -42,6 +42,8 @@ struct iommu_sva; struct iommu_fault_event; struct iommu_dma_cookie; +extern struct iommu_mm_data default_iommu_mm; + /* iommu fault flags */ #define IOMMU_FAULT_READ 0x0 #define IOMMU_FAULT_WRITE 0x1 @@ -664,6 +666,11 @@ struct iommu_sva { struct iommu_domain *domain; }; +struct iommu_mm_data { + u32 pasid; + struct iommu_domain *sva_domain; +}; + int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, const struct iommu_ops *ops); void iommu_fwspec_free(struct device *dev); From patchwork Fri Jul 7 01:34:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116905 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2968055vqx; Thu, 6 Jul 2023 19:21:42 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/baTF+xex91ceDeALvI7l2dvUu/8zQOY/zjw4Eb6xvzR1/szJecQLfaex17vxQlKR0j/i X-Received: by 2002:a17:90a:6b85:b0:263:5033:9f36 with SMTP id w5-20020a17090a6b8500b0026350339f36mr3301071pjj.24.1688696502344; Thu, 06 Jul 2023 19:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688696502; cv=none; d=google.com; s=arc-20160816; b=bwRsJ7gyGCKkIPb/jTPzIKYbRCUlb+VddbFABtwHGp9KxsS/yboynboN5Ly4LK2N8M 0zI/1ZNUtuB3NerwoL9Nz3dzR0ZloiB5RhGQ3XiR5WqDnxaFP9EuuGPGq/TjcXruOevt hMHD20VFsIRWVR9Y08kRhSuPT/Npng2hLPOQgsn27Cg3qbYouDIMXPfjFYlJykasKgzX EwLHdW7HXZy2H+kxTkBmlfNRSMv5/H8dTEqSc0dyvcUrHzDa8Hfu3EvpLFgscjFNpVI4 qc54jdPbYqgraCk6Cy0sn3F4amQQY/80b51HVMfxpjbyl9Kyo/qQTK6T2ZCOkhZnx8UC sifg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CZ4OpPs6pwJ8/75+VnhfWX9yko/c10h0yfrt3vmwh+Q=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=b0B0mnmrb+swv2Z+ZYbmiAKqi+O0MLqpgdBisvnn1JFbzFZ5NRbsUvMNEfdI7/XVvQ itO8xCCX4TunIVpQxK1VkJK+lN1jDyrjuK8ZcGkHBJAXsZDkRvx816vwxBMbTsRu4Kb1 Oy4AkdveG67CijMUzhCEmO19AGIjN18RTIfKgH5sfhooWdwvliwHHslz1iYR/4vUrfCe YFVYR2csq9+jMLVPgSiUPsnBBE0Oe3+pgxgWyrAwMH2v6JplG+0LCBeqJAxM7wq3WMsx fhE7QFcnYMLJkMqy+HjihEG7NOHR+dgv4i0Dz/4wPzVrljBaJ95PnbeAcFeUoNW609Le aVgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="nGBR/EbT"; 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 co14-20020a17090afe8e00b00263e8027e64si966421pjb.138.2023.07.06.19.21.29; Thu, 06 Jul 2023 19:21:42 -0700 (PDT) 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="nGBR/EbT"; 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 S231972AbjGGBfW (ORCPT + 99 others); Thu, 6 Jul 2023 21:35:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbjGGBfQ (ORCPT ); Thu, 6 Jul 2023 21:35:16 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 509A51FEA for ; Thu, 6 Jul 2023 18:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693712; x=1720229712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=eBd7C5+K4RvrvJS52RC+bdvbj/BI96OctjrNMXfnImA=; b=nGBR/EbTzL/yTpcBukdROfD2zoHTn/wUCgYJkjQnggTkE820TsLdBEYm n22giaZIetQb3TVEs6Ln+gTWZK7GKAQmgPuqhnDaF7i4Hp/MlFozv62K1 kb7/nGvJ2FR+0LVoNhc+9kA74ufvmgUUb/dNtYFBpqrfiUsIoZn57rwuO ZodWQUY4ZEcRxxJfP72E5gg7IUZXNC3cKVq3HnJbebmofsoGH8rIjE0cx WpvCmjdzaP0YJYcPnw5bkiZZV2kGqqrY1XzgEbPS83jEc7SfM5X3IL2bG sjzhdJFLw47ZcHYuXeC+noTXCSH5axoSEEamm+stI6wiTKRU0gxeIybBY g==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832288" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832288" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791346" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791346" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:08 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 4/6] mm: Add iommu_mm field to mm_struct Date: Fri, 7 Jul 2023 09:34:39 +0800 Message-Id: <20230707013441.365583-5-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770726624018628285?= X-GMAIL-MSGID: =?utf-8?q?1770726624018628285?= The iommu_mm field has all the information needed for managing sva domain 1:1 with mm pasid. Add it to the mm_struct as the sva-related field and use default_iommu_mm to initialize init_mm pasid. Signed-off-by: Tina Zhang --- include/linux/mm_types.h | 2 ++ mm/init-mm.c | 1 + 2 files changed, 3 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 306a3d1a0fa65..bb00caa078335 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -581,6 +581,7 @@ struct mm_cid { #endif struct kioctx_table; +struct iommu_mm_data; struct mm_struct { struct { struct maple_tree mm_mt; @@ -773,6 +774,7 @@ struct mm_struct { #ifdef CONFIG_IOMMU_SVA u32 pasid; + struct iommu_mm_data *iommu_mm; #endif #ifdef CONFIG_KSM /* diff --git a/mm/init-mm.c b/mm/init-mm.c index efa97b57acfd8..c43b7d0347312 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -44,6 +44,7 @@ struct mm_struct init_mm = { .cpu_bitmap = CPU_BITS_NONE, #ifdef CONFIG_IOMMU_SVA .pasid = IOMMU_PASID_INVALID, + .iommu_mm = &default_iommu_mm, #endif INIT_MM_CONTEXT(init_mm) }; From patchwork Fri Jul 7 01:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2958422vqx; Thu, 6 Jul 2023 18:58:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGiMU1fGqMw6yFQoauhsQDsz7H21YXR4IEP0r89b4FaSY3ikTFmX2cACmG0+I00yngF4E88 X-Received: by 2002:a05:6a20:1596:b0:12d:5196:65ff with SMTP id h22-20020a056a20159600b0012d519665ffmr3122996pzj.31.1688695088403; Thu, 06 Jul 2023 18:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688695088; cv=none; d=google.com; s=arc-20160816; b=BGisy6F6gIXB0j4e3bIxO79odLconu9qKnu/8ONvmJvXiVnifwxfgknpVKk+DgnND9 LLgPG85463csDqTb0ofXJGWuPkOAx6D/keHq15XyoeyVreoTfCkCbT9mVXAkz8IcauI0 HuaJCawRwmqLlXXcCO3hQluA1NNNxyWRSZfyZA5dBmLPIPCdaejV6Ti5ApR9j0smeOe8 ERvZq0Jv1ucbPi+YIwSyQkcnfvegon88mOmmWhbjL0BAnL/Sy9v5CC29nWl5Ji/Fl7YQ 6YmNcfayvEP5MSXmUaJitgL/T72rX446wZtTJGBPXtieocDv/6BynN/UUNpl2Bdgda6O x2QQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BlMTcQv+KRYZ6FKVYv0fj5v8xpzSzI6AYN6fLcy88vs=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=V221+8FttIF5rr1exV1QHj+DMTVlrFYGY2t/uAeNWU87kYhQj5naIIetjjqEdTUDgz O30rBQxP5m46A35qYKHPam4VTA7pKRqnianQlUD4XaLlO9T8J0VlEzYMlnqQ36KsgVy5 x++7yimJ5tSNVlwNfJB3jMVh9BxMloWQ6Sh9zUMYCj51dkxUJUkiZ4gt/LbHemIy6QWX EBorfVBJ9tBeDIaLuSkwDOQmyUAH6OBfKc5AucWc8mYNItLPV4A4e/LF7O8KXYd3WDdR Afr9E7raK72ot2CMepOm7xjwFC+TOeyLyaUH5fAAIptHtBBmIZ41+eLNWtU7XX7EZ6tW Aeiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FupDQZbQ; 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 lb14-20020a170902fa4e00b001b694ecf48esi2273116plb.100.2023.07.06.18.57.52; Thu, 06 Jul 2023 18:58:08 -0700 (PDT) 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=FupDQZbQ; 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 S232017AbjGGBf2 (ORCPT + 99 others); Thu, 6 Jul 2023 21:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231921AbjGGBf0 (ORCPT ); Thu, 6 Jul 2023 21:35:26 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E1BC2101 for ; Thu, 6 Jul 2023 18:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693715; x=1720229715; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1h7edKtoFv8FxuKLDfoJ9kk0foTEvF67RC9h6LudYHI=; b=FupDQZbQ2il+emcJsNbzJnh7q1PNZADTE1NrfJ7FYPnGsq7w2vQerWhn e7lFkZKYqHzqZGmJj273GfbtmqNfQiFIaEJgczfrppK8mRjA4W0J7nTeN unPUdmxEdGHUd8gCdkBH/BYkfw1kxbViFb8ZaAKZ2zp+ke6B5e9llS0DE JJlzUfU8LwnXMNplaeUFtODQI79OEY5lOM4XhhNXa/m24LeoDq+f+K0uE Z6S+1TWuFk3X/MV39hXlK9OEd3Ca2ZJJ8lZVbfIqTZCFY9/1RE/IAbuTe vgEbg9DXuhV0i2YGA6hyh1TocFtkDGU2sATcI1ngu9LXwydIkcAJKNVUz Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832309" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832309" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791362" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791362" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:11 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 5/6] iommu: Support mm PASID 1:1 with sva domain Date: Fri, 7 Jul 2023 09:34:40 +0800 Message-Id: <20230707013441.365583-6-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770725141251457772?= X-GMAIL-MSGID: =?utf-8?q?1770725141251457772?= Each mm bound to devices gets a PASID and a corresponding sva domain allocated in iommu_sva_bind_device(), which are referenced by iommu_mm field of the mm. And that PASID and sva domain get released in iommu_sva_ unbind_device() when no devices are binding to that mm. As a result, during the life cycle, sva domain has 1:1 with mm PASID. Since the required info of PASID and sva domain are kept in struct iommu_mm_data of a mm, use mm->iommu_mm field instead of the old pasid field in mm struct. Signed-off-by: Tina Zhang --- drivers/iommu/iommu-sva.c | 54 +++++++++++++++++++++++++++------------ drivers/iommu/iommu.c | 1 + include/linux/iommu.h | 8 +++--- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c index 7a41b6510e385..342d8ba9ab479 100644 --- a/drivers/iommu/iommu-sva.c +++ b/drivers/iommu/iommu-sva.c @@ -15,6 +15,7 @@ static DEFINE_IDA(iommu_global_pasid_ida); /* Allocate a PASID for the mm within range (inclusive) */ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t max) { + struct iommu_mm_data *iommu_mm = NULL; int ret = 0; if (min == IOMMU_PASID_INVALID || @@ -33,9 +34,18 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma goto out; } + iommu_mm = kzalloc(sizeof(struct iommu_mm_data), GFP_KERNEL); + if (!iommu_mm) { + ret = -ENOMEM; + goto out; + } + mm->iommu_mm = iommu_mm; + ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL); - if (ret < min) + if (ret < min) { + kfree(iommu_mm); goto out; + } mm_set_pasid(mm, ret); ret = 0; out: @@ -61,7 +71,7 @@ static int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t ma */ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm) { - struct iommu_domain *domain; + struct iommu_domain *domain, *sva_domain = mm->iommu_mm->sva_domain; struct iommu_sva *handle; ioasid_t max_pasids; int ret; @@ -88,31 +98,41 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm goto out_unlock; } - if (domain) { - domain->users++; - goto out; + if (unlikely(domain)) { + /* Re-attach the device to the same domain? */ + if (domain == sva_domain) { + goto out; + } else { + /* Didn't get detached from the previous domain? */ + ret = -EBUSY; + goto out_unlock; + } } - /* Allocate a new domain and set it on device pasid. */ - domain = iommu_sva_domain_alloc(dev, mm); - if (!domain) { - ret = -ENOMEM; - goto out_unlock; + if (sva_domain) { + sva_domain->users++; + } else { + /* Allocate a new domain and set it on device pasid. */ + sva_domain = iommu_sva_domain_alloc(dev, mm); + if (!sva_domain) { + ret = -ENOMEM; + goto out_unlock; + } + sva_domain->users = 1; } - ret = iommu_attach_device_pasid(domain, dev, mm_get_pasid(mm)); + ret = iommu_attach_device_pasid(sva_domain, dev, mm_get_pasid(mm)); if (ret) goto out_free_domain; - domain->users = 1; out: mutex_unlock(&iommu_sva_lock); handle->dev = dev; - handle->domain = domain; + handle->domain = sva_domain; return handle; out_free_domain: - iommu_domain_free(domain); + iommu_domain_free(sva_domain); out_unlock: mutex_unlock(&iommu_sva_lock); kfree(handle); @@ -136,10 +156,9 @@ void iommu_sva_unbind_device(struct iommu_sva *handle) struct device *dev = handle->dev; mutex_lock(&iommu_sva_lock); - if (--domain->users == 0) { - iommu_detach_device_pasid(domain, dev, pasid); + iommu_detach_device_pasid(domain, dev, pasid); + if (--domain->users == 0) iommu_domain_free(domain); - } mutex_unlock(&iommu_sva_lock); kfree(handle); } @@ -217,4 +236,5 @@ void mm_pasid_drop(struct mm_struct *mm) return; ida_free(&iommu_global_pasid_ida, mm_get_pasid(mm)); + kfree(mm->iommu_mm); } diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 35fa1c1b12826..2f55a157b1f15 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -3393,5 +3393,6 @@ struct iommu_domain *iommu_sva_domain_alloc(struct device *dev, domain->iopf_handler = iommu_sva_handle_iopf; domain->fault_data = mm; + mm->iommu_mm->sva_domain = domain; return domain; } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 20135912584ba..1511ded7bc910 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1175,20 +1175,20 @@ static inline bool tegra_dev_iommu_get_stream_id(struct device *dev, u32 *stream #ifdef CONFIG_IOMMU_SVA static inline void mm_pasid_init(struct mm_struct *mm) { - mm->pasid = IOMMU_PASID_INVALID; + mm->iommu_mm = &default_iommu_mm; } static inline bool mm_valid_pasid(struct mm_struct *mm) { - return mm->pasid != IOMMU_PASID_INVALID; + return mm->iommu_mm->pasid != IOMMU_PASID_INVALID; } static inline u32 mm_get_pasid(struct mm_struct *mm) { - return mm->pasid; + return mm->iommu_mm->pasid; } static inline void mm_set_pasid(struct mm_struct *mm, u32 pasid) { - mm->pasid = pasid; + mm->iommu_mm->pasid = pasid; } void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, From patchwork Fri Jul 7 01:34:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 116904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2961974vqx; Thu, 6 Jul 2023 19:05:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlFc5ucWc7YMKBAz6PI1X99yozzkqmRQPvCjELVzbNnKwArutfPURni0GZB5873hCs9vss34 X-Received: by 2002:a17:903:32d1:b0:1b8:a67f:1c15 with SMTP id i17-20020a17090332d100b001b8a67f1c15mr10828236plr.25.1688695540589; Thu, 06 Jul 2023 19:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688695540; cv=none; d=google.com; s=arc-20160816; b=W04LEUu5yok620rXT8hHGBqufqCupCn8rqiJR2JvqZb1Gampk1lA9IBoE4nb1ewJem xOLC45msQtqVicSF4aBAUOo2oa4zZyaOueWxYTiCMYuoMCxSi0csqPqMrlq3LTsZBn7E TJENBJ3h9QfwLf6leRJpG2naRumpnEsyjSlBU216kZH/CeUVqJGRQzBL+0194R1ao9tl ZC0ecFz3tS9vMaRl2wADFdENPxJ5WyJku0kNc24wnMg+MuaJsYOQShFt4JFDsZxQdDmu cJL7NyX39RVJSgBS5z5fA6S5BFgN//AXcxIWLTciP+1A2tvBAa5nX1KEJ3KvZnLRajkY tkqQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4FuoBcuar9kdSM+2O4FbUViRe799+9XEPUrbnZuYsJo=; fh=YLwvJdOekjmHJibOqKattcm/709ZiAsNlTvjC0MrDUo=; b=zHdxnleWPyiACJpo1rJxKJ+u9OJWJYe0FgEZ9JOZ4uizs6Yjn5JWFcEO2PUw62eh7G 7rQEba+MY2lsyVQOPIQGu8RuUWyqWYnxZhgDfF2QGnhVjGRjdIGZ9+HguOEVL8e2+Qej LYGlfbIfymv59YROgw+90Hvzmp0oQvSMjFkFnZsJ3dFrGvjY2d3PdRcASFrwl23i6Mai RxLfOqizKTwK+magzLtgbUlsJjHTnkzEnM2c9RIoJAFmzKnMrffnEFTZEWFxiEu46hbt yUGtAViZ3clxzTMI7c2bkc2RWkwvprqEX9EtzI92kVimxOgofMAIHJU9tFFt5fKs0rMC xh6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Qwiy4Tm9; 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 f20-20020a170902f39400b001b89654fa42si2356645ple.476.2023.07.06.19.05.24; Thu, 06 Jul 2023 19:05:40 -0700 (PDT) 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=Qwiy4Tm9; 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 S229910AbjGGBgp (ORCPT + 99 others); Thu, 6 Jul 2023 21:36:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjGGBgn (ORCPT ); Thu, 6 Jul 2023 21:36:43 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6572B2115 for ; Thu, 6 Jul 2023 18:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688693779; x=1720229779; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TX3zfSSKDYdQMJ/lhBfeXvJtyWDmev5GpUgBT8vYQ+w=; b=Qwiy4Tm94fhp/tANMqil7VWuQSE71JB3YMFKorbV58HyopeSkjJ1KwnM 4Bxc1XpsT+lZC5y2ghouq5oTJyjpVwtExXjnswhQNKpWcc+FEUluHF3ZW 0BYZY/VTplsLvEJxilzQCjiDt22YHPDLZte6dHLZHvjfwi3XuFRVg4R8r TT3+yeQHPSLiJ62nP5CdVim5HCntWUdnZh5p4kdSCAzwzGdiH8aWMapne uvChwHtZI/gVaakXab7GIpR6PGNaWOFs2tyB/Q6lh9hIh2GkLxlOQGyPh I3IkDFpp3Woh3FA+Lm1Ln2452S8venTgLvoGDF1/ARI3UKylZ+yzI0jn2 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="429832329" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="429832329" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10763"; a="893791373" X-IronPort-AV: E=Sophos;i="6.01,187,1684825200"; d="scan'208";a="893791373" Received: from fengj-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.www.tendawifi.com) ([10.254.210.124]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2023 18:35:15 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Joerg Roedel , Will Deacon , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [RFC PATCH 6/6] mm: Deprecate pasid field Date: Fri, 7 Jul 2023 09:34:41 +0800 Message-Id: <20230707013441.365583-7-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230707013441.365583-1-tina.zhang@intel.com> References: <20230707013441.365583-1-tina.zhang@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770725615007498646?= X-GMAIL-MSGID: =?utf-8?q?1770725615007498646?= Drop the pasid field, as all the information needed for sva domain management has been moved to the newly added iommu_mm field. Signed-off-by: Tina Zhang --- mm/init-mm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/init-mm.c b/mm/init-mm.c index c43b7d0347312..50824dd5a949a 100644 --- a/mm/init-mm.c +++ b/mm/init-mm.c @@ -43,7 +43,6 @@ struct mm_struct init_mm = { .user_ns = &init_user_ns, .cpu_bitmap = CPU_BITS_NONE, #ifdef CONFIG_IOMMU_SVA - .pasid = IOMMU_PASID_INVALID, .iommu_mm = &default_iommu_mm, #endif INIT_MM_CONTEXT(init_mm)