From patchwork Tue Sep 12 12:59:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 138388 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp620572vqx; Tue, 12 Sep 2023 12:05:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF4MxpvDuGxxFdCUEIhUqdy+fi4IvtSnyLJJhxHvp7NtFkog/MedMaWfP563anU0vcnfkSY X-Received: by 2002:a17:903:1c5:b0:1bb:55be:e198 with SMTP id e5-20020a17090301c500b001bb55bee198mr769321plh.0.1694545510230; Tue, 12 Sep 2023 12:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694545510; cv=none; d=google.com; s=arc-20160816; b=r+h12BAgHzIlc4tvB0+6NOjY/4JdoBTp/oNtzWu04LrvO1JHgmen4QO9Yajnu6hn95 Pcn/t7IqWCRNS2oDh3p6vMDn1mVk04+sy6vQsu2UADQ5HntLzYOS15PO6IZfTWoi4GjY /oVDv6Aw+FpQUbUOO6w4xkFLT3UYeJ/Geev4rqMeSGkjLlH478NoHCz+Oj2u8QJkozfO 0RAXfY39HHbuYeZn8jCdy1jWAXVUOQzJ09wM7+Gpb/GqANuw3l419pLMWkYNirhmlftH HFUhjl5/WnLD3C4x9diGtju/2Q/lW1d0PHpmLURppuUVQudQoW0u3T4834exA+LZsYw4 Av7A== 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=kyD20IWhVaNZrswDkwvGF5JY8PTtcHOyFU4S4oYzpR4=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=D7Ig2tu+fJxjUBhHE+9xqUXPZdu0679197OGuQpWwsfZz+X/b1Z7j2s7RJTrimfSvt jFNCbeYaiQnkpWch7RwGtwLoAwRANrwxejhrOPRpvkggc6YeY21MGd6zvSSKv88qd3Xm 9Q7K/Zp1fbeFDokqzyH5pRAeIafv/r3pX4fNm7ZfFAyvUQz9XRgOMX1s97lErDr8X4l5 c14psivOWOG8k8axFCC2Rrl3jsYYD1vSFiuSs3QIIB8uW3EE4/ORtq/5coRpadTcF5By QrecRwMaVJ3htjR6hEv9ePOOKFTm9uP5wFPiYd28W9FyRWqBhRQ/HOSDWVwj9yDT7eMd vFoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N00++X9z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id j3-20020a170903028300b001b9d180fd9asi7453435plr.121.2023.09.12.12.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 12:05:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=N00++X9z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id B694881DF778; Tue, 12 Sep 2023 06:00:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235320AbjILM74 (ORCPT + 37 others); Tue, 12 Sep 2023 08:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235286AbjILM7y (ORCPT ); Tue, 12 Sep 2023 08:59:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A9310CA for ; Tue, 12 Sep 2023 05:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694523590; x=1726059590; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UkPWO7fE+y65rWaaiU51i7SbuwuOUve8DJxS805k7Cc=; b=N00++X9zH/0nN6kfLAvBgu1HD7US1jwF4ZJPVkFO66iwnf5EawzvFGNp 5c6LA1gRLXmB++JakeSO1PlWwD6LAPDZhqJ//AlUIYqdlpBMgqZ646w7X v0DirHzDrBun73YR/5yeAzis9/M9EgCOL30IasVWCMr1efYgq3Q+p/1Q3 YnPXEj8piU5CZhDUjO2qNQjs0fq5nHT7nh81G+Gs8C2/x5B24g7NV1kNJ fo8hctZA+OGC/+SWXKxzgU7oQ1zUKUputRglXziE0X6Q9B7sEvZSh+WK4 ygyfUqarcxlDe0YbQEX0ME0vmClxRhU+3+AJJSbEhoMf+81ROccLIi3Tk Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="378277303" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="378277303" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 05:59:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="858799246" X-IronPort-AV: E=Sophos;i="6.02,139,1688454000"; d="scan'208";a="858799246" Received: from tongshi-mobl.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.255.28.214]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2023 05:59:48 -0700 From: Tina Zhang To: Jason Gunthorpe , Kevin Tian , Lu Baolu Cc: Michael Shavit , Vasant Hegde , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Tina Zhang Subject: [PATCH v4 1/6] iommu: Add mm_get_enqcmd_pasid() helper function Date: Tue, 12 Sep 2023 20:59:31 +0800 Message-Id: <20230912125936.722348-2-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230912125936.722348-1-tina.zhang@intel.com> References: <20230912125936.722348-1-tina.zhang@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Sep 2023 06:00:17 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776859752829283105 X-GMAIL-MSGID: 1776859752829283105 mm_get_enqcmd_pasid() is for getting enqcmd pasid value. The motivation is to replace mm->pasid with an iommu private data structure that is introduced in a later patch. Reviewed-by: Lu Baolu Signed-off-by: Tina Zhang --- Changes in v2: - Change mm_get_pasid() to mm_get_enqcmd_pasid() 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 c876f1d36a81..832f4413d96a 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -591,7 +591,7 @@ static bool try_fixup_enqcmd_gp(void) if (!mm_valid_pasid(current->mm)) return false; - pasid = current->mm->pasid; + pasid = mm_get_enqcmd_pasid(current->mm); /* * Did this thread already have its PASID activated? diff --git a/include/linux/iommu.h b/include/linux/iommu.h index c50a769d569a..a4eab6697fe1 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -1189,6 +1189,10 @@ static inline bool mm_valid_pasid(struct mm_struct *mm) { return mm->pasid != IOMMU_PASID_INVALID; } +static inline u32 mm_get_enqcmd_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); @@ -1211,6 +1215,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_enqcmd_pasid(struct mm_struct *mm) +{ + return IOMMU_PASID_INVALID; +} static inline void mm_pasid_drop(struct mm_struct *mm) {} #endif /* CONFIG_IOMMU_SVA */