Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4605034rwb; Tue, 8 Aug 2023 10:50:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE3O5B9vmGuCWTxUN7VNl2kdpQjuooD8E6CNpCm76pPktIt1JdnM8shwt+xTOM6IwJL4BXe X-Received: by 2002:a05:6a20:a10c:b0:126:8b2d:4462 with SMTP id q12-20020a056a20a10c00b001268b2d4462mr10954585pzk.24.1691517047131; Tue, 08 Aug 2023 10:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691517047; cv=none; d=google.com; s=arc-20160816; b=N2Fy4eU4itid+5/WacmykJh2MNSTg0q+UP5kGqM/AkWr9KxLEj1XOHSqqTyLazhYa1 EJOKx+x3CYwyJMKhP6ZMYqcvvD9GQxWcsTmRApeKK0lE1G2jkdgh0N58ChhqkYYmXa9x fGHRRBPoTnTpIT1pCDBXrl29dnHDG9R8ukFzNuSPx0xOzWrKpZy9dg9U7LMxDXus/rvS yYSSeSXferUkc8UUfKFGMlN4v/tB1iBx3E+mkM4y8+SYC0aIKEG11yPsZiY7rMfLqXuO obtkAPm3FdiRRms3aTGgNCuNhaXnGhCL8a5cexkdEAAlW0s+tpaZxL/z8ji/DWYcXN4y NgOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=qABHr0MVq9K8OFDMUR2uH3R16FK+1ZBhSMiJ8AFkD4c=; fh=/lTHmTEAhz5c6hgBRAPnmJsxw5vDTKZT1TYa5ynR+LA=; b=f1JnRtfKhukhBAsqQo22oNmbABLE4WxeX0Il+Ve6bkSfo4LeuZ2OH9Y2S6VWi+wk5q dUSVHNll1k0l70H2HNdK0ms+bS5mBOXB+5nFkSiW0vmf8doXf13yPX6Db5daWqId/XKe V0ptnaof7x0V2Z5hwENibH8WAdtOgkuBe5bjOOCZQRQBK7Ty4PJEotl2vWyLDaFE0r+T H9OFEzGqVaZEMAeEcUA15FYRLSgtro8klY+V8CFyPBgrYWQeMqFFFFFILIKy/HrJdE6H w2EEfZLNh44PcyGaw6lbuY+Uyhr8T43fvw9ZREq93OOCPPYyNrdqMfHvWgyj5862BFwH JLHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d8sCkdvS; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z70-20020a633349000000b00564b8c575c4si4232220pgz.819.2023.08.08.10.50.35; Tue, 08 Aug 2023 10:50:47 -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=d8sCkdvS; 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 S233056AbjHHQmy (ORCPT + 99 others); Tue, 8 Aug 2023 12:42:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233339AbjHHQmF (ORCPT ); Tue, 8 Aug 2023 12:42:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 648093DE36 for ; Tue, 8 Aug 2023 08:55: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=1691510112; x=1723046112; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=A507Xs1crKDCNKJRmv5uCTlfgOCIAdl3cBwBkuALTds=; b=d8sCkdvSY+2/5Jy7IBlrAmH2+4Cw9hlFN+PUTfW/9L0pc8mX19/S59QN X01IxFeOJ5FYTXhjsv+/rJfAbTzFpvE4r7suXYs4p4VZYUIkvW6qp9Sap ascA4T+w9nKZtqBPj8tP+em5betumioyaTAD5jbf0x5HFJe5dxUy+QTUf ykk0xdeunqRzBTEYebnDctk/5m5baL/ojifz9wmy8D8+6+QSErJfE97oz 1dGQ55OcGsjVXUjcYSEUBWrLi/y9RYS+ekLvdy0YRrrrWEtNbSG54UVTj C2GfamrHQUWpkikVKq8DYRDwK5z1oz+12JhIN/rpiBLdCbXBlWMOnFPbp g==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="437078656" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="437078656" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 00:49:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="681146272" X-IronPort-AV: E=Sophos;i="6.01,263,1684825200"; d="scan'208";a="681146272" Received: from kechen-optiplex-9020.bj.intel.com ([10.238.156.126]) by orsmga003.jf.intel.com with ESMTP; 08 Aug 2023 00:49:51 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Lu Baolu , Michael Shavit Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [PATCH 1/5] iommu: Add mm_get_pasid() helper function Date: Tue, 8 Aug 2023 15:49:40 +0800 Message-Id: <20230808074944.7825-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230808074944.7825-1-tina.zhang@intel.com> References: <20230808074944.7825-1-tina.zhang@intel.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,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 mm_get_pasid() is for getting 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 | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 4a817d20ce3b..6e259b11cd87 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 d31642596675..30e4d1ca39b5 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1180,6 +1180,10 @@ 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; +} void mm_pasid_drop(struct mm_struct *mm); struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); @@ -1202,6 +1206,10 @@ 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_pasid_drop(struct mm_struct *mm) {} #endif /* CONFIG_IOMMU_SVA */ -- 2.17.1