From patchwork Mon Sep 25 02:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 144189 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp963002vqu; Sun, 24 Sep 2023 20:55:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXtlN3Agw4jFq+jqARrfcvULvKzmNI2D2iBctHsJQt8052pUjdk3g4eoPVQIsQ+/aqehaK X-Received: by 2002:a05:6358:41a3:b0:143:9f18:d71a with SMTP id w35-20020a05635841a300b001439f18d71amr6305196rwc.14.1695614116468; Sun, 24 Sep 2023 20:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695614116; cv=none; d=google.com; s=arc-20160816; b=Ag2fuJ/RSD0vlWOrp2yycyjqjHz7swiWUBbNuxJ0wxg97l2z0hqTXi99TqKnwNvCaq x3j1NBCDRDA3BMoLrYTIPD7eejSuqDQzg0zq//rND3e7VXLgiaBuQc/3jkXd2GcaL2id Z/sfVd+WHce+Utb30204PHSPfC+5I5vJuQGPXLbsCpBttCFpZlIJtGqoN4lrb6WAsKTQ wfvmc+ysNkMAf0u2jDG5iKcfh1QhP3tAsjd4Zy+HxyJKprRP7pasj3EoAR415X5Js95Y PixDk6XKk5Q8ChXAthU3RxfCqS+TRtdQ1mTdmbpgaVOnuca8RuwPig9AUeqpyWC+pxT9 I9XQ== 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=jn50gwLRxwc9r2t55Ovfm7sR8dZQ0ZsVgWn2bZS9BjA=; fh=zW1GPeUL3MQGLvvmLmBmaazP2MzqJ1fOEi8He5Dzy3k=; b=wcM+Rnch8FEIk15/xQ81XINjKX6FFv0o4bjrl/BKt2qN8z/8Y5hV+RX84/GIMYhXUn aJlwbH3B4iJJ6MrU8n6bj4mBW4yfLZfDuohbLs1uhgBI/9mDZ0rmf+n9XVkYQgWMclsw JohOn8Hv3rt9KFVmPJAoyXZPYivBOTj71Ktz1hXea0jUtL6cU3GCbVWXgei3Qsvf+liz fPpFLy4ABSkGJqHjkGPlp7QbgnsUnDlyHyrJeQun9xU3QMuPnOo6Y6TLSCOKNvHSXjfd Q/VJXacngWJAQGlz1zO6E1D9A8GssoHZKjvdKjS+GDK/AjI3MRzaH1xi6Ji7JWNUmi7w FtBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IdDxm0dX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id m1-20020a656a01000000b0056a670ebd73si10249106pgu.498.2023.09.24.20.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Sep 2023 20:55:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IdDxm0dX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 9641B80E6FF8; Sun, 24 Sep 2023 19:39:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231909AbjIYCi7 (ORCPT + 30 others); Sun, 24 Sep 2023 22:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231854AbjIYCil (ORCPT ); Sun, 24 Sep 2023 22:38:41 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF4FFB for ; Sun, 24 Sep 2023 19:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695609514; x=1727145514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Dlf1dxlHWIpaa3k6WU6MZd1gS+MEcmDGRb+EBcE9Ias=; b=IdDxm0dXTplbiwuM89glbs+rvyvOZ1gntYl4xW0eYr3oZWiUWboomM4s uXCYctdLsKeVt7B4t7KUlxWmzwrqu4801qu2bh0a+eqrGkRdQd+HjgEri EnioOUeeJIiJY4j4bRS+LR8MArvWPxe+gmCCVQ6EQN5hlMjQj2RN+vGfV dTjL8sAVMnKJ2akwTvFdC4avJOyRz/wYyhM7CrqfZZfLwXblfVwmEnRMG 2PspV1mvoKsMMNjSi+9g669TjAT4rRrGUMjlHK41ZOkgpngOwJc2w9YPo 13HrzcNUacY8tv+9L2FEfFEbsuQmtHbZMPhqDdmU9SzbUqNyZOv3IZ0z6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="360534591" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="360534591" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="777505069" X-IronPort-AV: E=Sophos;i="6.03,174,1694761200"; d="scan'208";a="777505069" Received: from jingxues-mobl1.ccr.corp.intel.com (HELO tinazhan-desk1.intel.com) ([10.254.214.78]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Sep 2023 19:38:31 -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 v5 2/6] iommu: Add mm_get_enqcmd_pasid() helper function Date: Mon, 25 Sep 2023 10:38:09 +0800 Message-Id: <20230925023813.575016-3-tina.zhang@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925023813.575016-1-tina.zhang@intel.com> References: <20230925023813.575016-1-tina.zhang@intel.com> MIME-Version: 1.0 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 pete.vger.email 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 (pete.vger.email [0.0.0.0]); Sun, 24 Sep 2023 19:39:20 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777980268092910481 X-GMAIL-MSGID: 1777980268092910481 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 Reviewed-by: Jason Gunthorpe --- Change 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 */