From patchwork Tue Sep 19 09:25:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 141985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3507317vqi; Tue, 19 Sep 2023 09:13:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHW1xcU1eveLguWgvvszb+2ndrylkabBV46r2aI2W5rGm8LkxXhwJqKzpQ/fMZmcONZqWW/ X-Received: by 2002:a17:902:b710:b0:1c4:1b27:1cd6 with SMTP id d16-20020a170902b71000b001c41b271cd6mr9463809pls.26.1695139999881; Tue, 19 Sep 2023 09:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695139999; cv=none; d=google.com; s=arc-20160816; b=n/LIlSj73XJtUhVK64DFhr6NrkPneXV70SINlEdFo5Or1ccyJ4xx/4/ot5w0Dio6vY OnewEp0UCWD4qCCyQBqp6by8ilJIuAG7+ng16rmwPCT4npfssN5tXz8Bd7cknnmcwYQJ mPOJaCaOEa5r4ZInq/QLKy252596wGPbkgt4ovfitlpVmfHLkRIy1UFqM+nxPKeu+xzs NwDIwnicfLcwsJSC9LYg9p9FTJNELtMxjCBszQXfIVbLCxrhi4JVm+AqqyWeB7SOVbc9 MUNVGOwG/fXRSg91hEFP2g2UAYpXUC0FY7EFUUmP/jSI2EiEjbEfVKzDZV/OcCdJLf0m LnUQ== 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=rzLj9kamT4uCoY7kVVGpAReBPcRjfnhREDiGVpsrvGo=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=t2XKu8JqoiRnuZTIGiK7JJwC7ulrDYfraYUTDcPDmoDH2nhg4IUjMnTTIYL9w/qPUK padtuMpPgQA4DKFqu8eI36csBj0UPpcOEnkrNU6oDDUiCxDZwsiufFS8viegfhO96UR6 K40EIprUzkXt3g3cC4uyYuokab74Q3I//DE4PT3zYUnlTxDhTfydFwc8HnvBEYKrMXZW juv56Bro7xux0ky7BVYnNhEnLTBia6Z4il1QCw1yFVk/RG1BgalL7OG9CxkzPiO969nX vYPXTXMmRHm78l00utgkaoJ7AB8/HfMrcEovbNUDJrtNsWfKrw7xrNSUuOiGMbS0bfOa JokQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OkOXU2b6; 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 a7-20020a170902900700b001c3e500e6d4si9827527plp.344.2023.09.19.09.13.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 09:13:19 -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=OkOXU2b6; 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 65CEA8096A49; Tue, 19 Sep 2023 02:27:09 -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 S231285AbjISJ0k (ORCPT + 26 others); Tue, 19 Sep 2023 05:26:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbjISJ0V (ORCPT ); Tue, 19 Sep 2023 05:26:21 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 939E1102; Tue, 19 Sep 2023 02:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695115576; x=1726651576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nqhafFsOTCXMpS7yBdxvrhkU6NiVVIo1xDbd9DzqNGI=; b=OkOXU2b60WA0DZ/h0Vh/3RZIuya4J47xG8j+efDmw9TUbxA9od6KmzCt fAndSzsyLlVcUyj1lVvrz+D+RqVI3Ax54STXAODerUFTM6+1dgObR9pXF qKKOASkMZIVvwsn9HWqO6OqcCoxawy/if/lxs2XHg6lgVSVwcP69y/lUG thxyv+0DxR87hVD0At4jbLbHKk9B1XUoKrIBK1LBmW76Sx+wB/0d6SjJk 8ur8Qijwhsu3nQuaINp29sVKeroVhPUyA22Ec0vkyOjg9eHxnwH6JQ8Ny efZWnEdx1EZZDwX6qK8+NR3DD02AddO/0yLt2tAoecW3cM8u1t3+qHlCY A==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446368958" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="446368958" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 02:25:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="722804771" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="722804771" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga006.jf.intel.com with ESMTP; 19 Sep 2023 02:25:34 -0700 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com Subject: [PATCH 3/6] iommufd/hw_pagetable: Accepts user flags for domain allocation Date: Tue, 19 Sep 2023 02:25:20 -0700 Message-Id: <20230919092523.39286-4-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230919092523.39286-1-yi.l.liu@intel.com> References: <20230919092523.39286-1-yi.l.liu@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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:27:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777483120790746214 X-GMAIL-MSGID: 1777483120790746214 This extends iommufd_hw_pagetable_alloc() to accepts user flags. Signed-off-by: Yi Liu Reviewed-by: Kevin Tian --- drivers/iommu/iommufd/device.c | 2 +- drivers/iommu/iommufd/hw_pagetable.c | 9 ++++++--- drivers/iommu/iommufd/iommufd_private.h | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index ce78c3671539..e88fa73a45e6 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -540,7 +540,7 @@ iommufd_device_auto_get_domain(struct iommufd_device *idev, } hwpt = iommufd_hw_pagetable_alloc(idev->ictx, ioas, idev, - immediate_attach); + 0, immediate_attach); if (IS_ERR(hwpt)) { destroy_hwpt = ERR_CAST(hwpt); goto out_unlock; diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 48874f896521..5be7a31cbd9c 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -61,6 +61,7 @@ int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt) * @ictx: iommufd context * @ioas: IOAS to associate the domain with * @idev: Device to get an iommu_domain for + * @flags: Flags from userspace * @immediate_attach: True if idev should be attached to the hwpt * * Allocate a new iommu_domain and return it as a hw_pagetable. The HWPT @@ -73,7 +74,8 @@ int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt) */ struct iommufd_hw_pagetable * iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, - struct iommufd_device *idev, bool immediate_attach) + struct iommufd_device *idev, u32 flags, + bool immediate_attach) { const struct iommu_ops *ops = dev_iommu_ops(idev->dev); struct iommufd_hw_pagetable *hwpt; @@ -91,7 +93,7 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, hwpt->ioas = ioas; if (ops->domain_alloc_user) { - hwpt->domain = ops->domain_alloc_user(idev->dev, 0); + hwpt->domain = ops->domain_alloc_user(idev->dev, flags); if (IS_ERR(hwpt->domain)) { rc = PTR_ERR(hwpt->domain); hwpt->domain = NULL; @@ -166,7 +168,8 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) } mutex_lock(&ioas->mutex); - hwpt = iommufd_hw_pagetable_alloc(ucmd->ictx, ioas, idev, false); + hwpt = iommufd_hw_pagetable_alloc(ucmd->ictx, ioas, + idev, cmd->flags, false); if (IS_ERR(hwpt)) { rc = PTR_ERR(hwpt); goto out_unlock; diff --git a/drivers/iommu/iommufd/iommufd_private.h b/drivers/iommu/iommufd/iommufd_private.h index 2c58670011fe..3064997a0181 100644 --- a/drivers/iommu/iommufd/iommufd_private.h +++ b/drivers/iommu/iommufd/iommufd_private.h @@ -242,7 +242,8 @@ struct iommufd_hw_pagetable { struct iommufd_hw_pagetable * iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, - struct iommufd_device *idev, bool immediate_attach); + struct iommufd_device *idev, u32 flags, + bool immediate_attach); int iommufd_hw_pagetable_enforce_cc(struct iommufd_hw_pagetable *hwpt); int iommufd_hw_pagetable_attach(struct iommufd_hw_pagetable *hwpt, struct iommufd_device *idev);