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) };