From patchwork Wed Mar 19 17:32:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 14022875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CF052C35FFC for ; Wed, 19 Mar 2025 17:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:CC:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vCaZbioWfyaVzkUJibmLi7b6cSq203xUO5Hw2akccaQ=; b=YU53jqOS/NED9d2C9vXYZ9maGa BtWFNGqf/Tx9l6AzBsJB77hnXu0aoB9m4XCT/9Hhw4jXrYMBBSBacsj7jtcLSLCnFbWvfC3HoJ92/ E+xT3Juead+OTlKZNkLxjGbZ/McLnsWR7n4AUL2SJIPmFPrU8drl94g7c+57dKrFPdLVzgXgXH08f RLhiyBkeyJwL/t8TJHErL8ucbO2+E3uqqZL2FjfEFFhVvBvL+8EluNsSkVc1TMe5EhjcnqjHpeu6G djK2gJn0nVsi/z2swgJJRdgN4X2gtmBvyy2BJS/jPTg84gM/F12V8XG6kPDbHdZfTx5gUyT5IWgUj SfVMWRzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tuxOE-00000009jZE-0IAB; Wed, 19 Mar 2025 17:39:38 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tuxHp-00000009iYd-1Jah for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2025 17:33:03 +0000 Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4ZHwhD26tfz6K9RP; Thu, 20 Mar 2025 01:30:04 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id E51A314050C; Thu, 20 Mar 2025 01:32:59 +0800 (CST) Received: from A2303104131.china.huawei.com (10.203.177.241) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 19 Mar 2025 18:32:53 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [RFC PATCH v3 3/5] iommu/arm-smmu-v3-iommufd: Pass in kvm pointer to viommu_alloc Date: Wed, 19 Mar 2025 17:32:00 +0000 Message-ID: <20250319173202.78988-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20250319173202.78988-1-shameerali.kolothum.thodi@huawei.com> References: <20250319173202.78988-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.177.241] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To frapeml500008.china.huawei.com (7.182.85.71) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250319_103301_650461_24CE8715 X-CRM114-Status: GOOD ( 15.25 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No functional changes. This will be used in a later patch to add support to use KVM VMID in ARM SMMUv3 s2 stage configuration. Signed-off-by: Shameer Kolothum --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 1 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 1 + drivers/iommu/iommufd/viommu.c | 3 ++- include/linux/iommu.h | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c index 6f8be1164167..ee2fac5c899b 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c @@ -370,6 +370,7 @@ static const struct iommufd_viommu_ops arm_vsmmu_ops = { }; struct iommufd_viommu *arm_vsmmu_alloc(struct device *dev, + struct kvm *kvm, struct iommu_domain *parent, struct iommufd_ctx *ictx, unsigned int viommu_type) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h index 1f6696bc4f6c..9f49de52a700 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h @@ -1060,6 +1060,7 @@ struct arm_vsmmu { #if IS_ENABLED(CONFIG_ARM_SMMU_V3_IOMMUFD) void *arm_smmu_hw_info(struct device *dev, u32 *length, u32 *type); struct iommufd_viommu *arm_vsmmu_alloc(struct device *dev, + struct kvm *kvm, struct iommu_domain *parent, struct iommufd_ctx *ictx, unsigned int viommu_type); diff --git a/drivers/iommu/iommufd/viommu.c b/drivers/iommu/iommufd/viommu.c index 69b88e8c7c26..e157d786f295 100644 --- a/drivers/iommu/iommufd/viommu.c +++ b/drivers/iommu/iommufd/viommu.c @@ -47,7 +47,8 @@ int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd) goto out_put_hwpt; } - viommu = ops->viommu_alloc(idev->dev, hwpt_paging->common.domain, + viommu = ops->viommu_alloc(idev->dev, idev->kvm, + hwpt_paging->common.domain, ucmd->ictx, cmd->type); if (IS_ERR(viommu)) { rc = PTR_ERR(viommu); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index cb01fe49f5df..2f61e0178cfa 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -44,6 +44,7 @@ struct iommu_dma_cookie; struct iommu_fault_param; struct iommufd_ctx; struct iommufd_viommu; +struct kvm; #define IOMMU_FAULT_PERM_READ (1 << 0) /* read */ #define IOMMU_FAULT_PERM_WRITE (1 << 1) /* write */ @@ -646,7 +647,8 @@ struct iommu_ops { int (*def_domain_type)(struct device *dev); struct iommufd_viommu *(*viommu_alloc)( - struct device *dev, struct iommu_domain *parent_domain, + struct device *dev, struct kvm *kvm, + struct iommu_domain *parent_domain, struct iommufd_ctx *ictx, unsigned int viommu_type); const struct iommu_domain_ops *default_domain_ops;