From patchwork Tue Aug 8 07:49: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: 132732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2328924vqr; Tue, 8 Aug 2023 11:55:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHtV6aCMk0GaT8EjSfKsKWAHV/ShaQ1JtMHPszSf+IqQx4dl8xpV0UHb6VLVxccvQ0uWGNE X-Received: by 2002:a17:902:dac3:b0:1bb:f669:e856 with SMTP id q3-20020a170902dac300b001bbf669e856mr13164197plx.27.1691520956309; Tue, 08 Aug 2023 11:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520956; cv=none; d=google.com; s=arc-20160816; b=JpZnsRhsuqUdsiVOzOsOweQS9L5rx6w5XTx3Hes30wmmtZQ42z8duMW/pSsdg7DRPD BQ1soGY5NGwMU2tgMdvZo/jjMusLuKwUOYAfce4bQ2uLXQflV1wLTzH9JuFN82+tTsX1 obDQXanJOezH1iw/9ymzXpzocN7zECIKP/4Yw9Go4rzEl5Of1CkIJX6SQ17Nk1IeK71/ S1wSeovHQdBRcKAoiXF7rDfBrrAwRNd+WsgEMJiPqhprtQhKLhIF/ZTXwwH+c2GZ7jwZ rFawn5UFgFjxOeXs0rLkRFyGuicfXn7MFw51pxKPJIzZO7hLDg6i6eklmSSf0WsuHCRB RE9A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a6549c3000000b00563477c3519si7288414pgs.488.2023.08.08.11.55.42; Tue, 08 Aug 2023 11:55:56 -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 S233062AbjHHQmy (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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773688277922493224 X-GMAIL-MSGID: 1773688277922493224 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 */