Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4211814pxk; Tue, 22 Sep 2020 13:17:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYcimggZvq1qPZVmszNd9EAzCgGnHAKnqzqHMbtm55lD5cN7sbyszvtSywpMO32ZwX7YU9 X-Received: by 2002:aa7:d58e:: with SMTP id r14mr6190148edq.52.1600805847056; Tue, 22 Sep 2020 13:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600805847; cv=none; d=google.com; s=arc-20160816; b=XA1sbtB7IIf2nbiIVsWuL/txp+OCyFTPrFOvGTDwmSnZGaRm57TMXa5wU7cwASedLc gfsXK8TPxcw5YQ9IQ2VpPD91iRP2cIMXF9JbXEC5i/9GnYu2hcSDdVFwkZmFp4KoDxil Bo+uK/85k3XVv9n4dlwwSicfqswlduHCoED9TIWPAYWbgz/zLFvUfqJqZ3odr6W5D741 NVeqSJBBooSSYuwRHEZ+8QB8mCeIeuJUUYWAOrtIACPh7MnTAyTnyw8kMUs57ZN6BQh2 pptvV4cEaH3ggaU+gY6yfcmgijbZaAXyTGcJgKtc9FZFbpSNdJe3kVgEyUWR8rzgxewr ukKQ== 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=cd/kUvj/qKVGHAwJBYWnGQx2hf0aCQ0hRurRYYSX7es=; b=gBLvXhCae7z9WdLeBoOAH4YbStYtgimuOBN6adQ+03ft+jSvP5yILfmOD5zxEeGsrg /8LBlr+l37H2ZBnC/Ld7/OgATP3jD6Lw8Ux9rQAN3yiM2R2yyxCycwsJnDCXuQIUDuHL MBEHpDfTRUJ9Gewv/0m4gJ258mojr2qbAL8dtAnd3qd4TVbc8A+4ve6JZBoqYumxYVQA iqwmFdYeXxqqqFu2BcAYEr53ugLWO0QBqKS1F2PfzyS26n2gGkicJ91sv5BAg177nEHH 1V3eGxgz34d/ohJPH008aHk6/HA46/+bREiPlvXkGlvhZh6Y6oplFf3mmrUCSQB0HtTl iqYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DmxsWTMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bk4si11773984ejb.215.2020.09.22.13.17.02; Tue, 22 Sep 2020 13:17:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DmxsWTMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbgIVUPw (ORCPT + 99 others); Tue, 22 Sep 2020 16:15:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726567AbgIVUPl (ORCPT ); Tue, 22 Sep 2020 16:15:41 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B49AC061755; Tue, 22 Sep 2020 13:15:41 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id x22so8679438pfo.12; Tue, 22 Sep 2020 13:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cd/kUvj/qKVGHAwJBYWnGQx2hf0aCQ0hRurRYYSX7es=; b=DmxsWTMr9JQwOMCRjH4NkW8Vc+twqFrimTjOwCsvJ19HMzd2zqj4VaMMV1Ki6VSDka o6DZMQvC67E8CqASOYDxKakAP0PuB2NR3mYW8c1IBj9+RNW3E2Da1sXhSINqHL7sZ8Zr yzZMmBQ48jEmppFiAsMYxMSRrr+o7sQ/nXIcNMx8gpNBehwcrvrdXwkCVxnKwUa+JyQO nI72TjEI4OPK1jgDg9JpCGmLBAsLUK+gjsYXEk2Uncv98ymrsZm4BExSIZv3SHKJ/Yh1 1HlEI20pVWThfwp7u5fTyQIivuPVmnHsVg725Gf9nbWiv8jVpGSw0aF+LMAZq/hYytXw SUMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cd/kUvj/qKVGHAwJBYWnGQx2hf0aCQ0hRurRYYSX7es=; b=fJQTTmqCs6+0a9f78Bp0RnKOfEzPkGSRsa2iLHBiZizBxsjw/DUeRU/7YmYkzK+Phu K5sHn2Xru4rd0EsT+v2KFLDf7FQH4S2PZ79iALyNyljwZtaGwd6AXbF5VT5V9zi7ky3E YNi74KUePiiXGC0FsnsAAkzpE9DYUPxQ56mNWpkuYH2vZ0Jbv/bsySL71cV4GL39b5PB CZ4KejVh4OifqwR6gPrUsmcGvDypdQiERfz40RtGM7Bwrl02IhQ3WJiRKtptk0bdAuOq QjCqjcYmsxpk7tig4ulsR+TZ+CbWoTUOdtX5nrct7tKcg+p6601IMhGXfknYmuv6UMwL HQCA== X-Gm-Message-State: AOAM533gDyBhYpHc607TT53WL5FMaU59v4AynVH0Y5PnJs9LCQhoXMHC 9Wp8Np1DFZJfzAFzi6Ru1Yo= X-Received: by 2002:a17:902:ba88:b029:d1:e5e7:bde1 with SMTP id k8-20020a170902ba88b02900d1e5e7bde1mr6495442pls.65.1600805740941; Tue, 22 Sep 2020 13:15:40 -0700 (PDT) Received: from jacob-builder.jf.intel.com (jfdmzpr04-ext.jf.intel.com. [134.134.137.73]) by smtp.gmail.com with ESMTPSA id e10sm15793028pgb.45.2020.09.22.13.15.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Sep 2020 13:15:40 -0700 (PDT) From: Jacob Pan X-Google-Original-From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson , "Lu Baolu" , David Woodhouse , Jonathan Corbet Cc: linux-api@vger.kernel.org, Jean-Philippe Brucker , Eric Auger , Jacob Pan , Yi Liu , "Tian, Kevin" , Raj Ashok , Wu Hao , Yi Sun , Randy Dunlap Subject: [PATCH v10 5/7] iommu/uapi: Rename uapi functions Date: Tue, 22 Sep 2020 13:17:00 -0700 Message-Id: <1600805822-1177-6-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600805822-1177-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1600805822-1177-1-git-send-email-jacob.jun.pan@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org User APIs such as iommu_sva_unbind_gpasid() may also be used by the kernel. Since we introduced user pointer to the UAPI functions, in-kernel callers cannot share the same APIs. In-kernel callers are also trusted, there is no need to validate the data. We plan to have two flavors of the same API functions, one called through ioctls, carrying a user pointer and one called directly with valid IOMMU UAPI structs. To differentiate both, let's rename existing functions with an iommu_uapi_ prefix. Suggested-by: Alex Williamson Reviewed-by: Eric Auger Signed-off-by: Jacob Pan --- drivers/iommu/iommu.c | 18 +++++++++--------- include/linux/iommu.h | 31 ++++++++++++++++--------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 609bd25bf154..4ae02291ccc2 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1961,35 +1961,35 @@ int iommu_attach_device(struct iommu_domain *domain, struct device *dev) } EXPORT_SYMBOL_GPL(iommu_attach_device); -int iommu_cache_invalidate(struct iommu_domain *domain, struct device *dev, - struct iommu_cache_invalidate_info *inv_info) +int iommu_uapi_cache_invalidate(struct iommu_domain *domain, struct device *dev, + struct iommu_cache_invalidate_info *inv_info) { if (unlikely(!domain->ops->cache_invalidate)) return -ENODEV; return domain->ops->cache_invalidate(domain, dev, inv_info); } -EXPORT_SYMBOL_GPL(iommu_cache_invalidate); +EXPORT_SYMBOL_GPL(iommu_uapi_cache_invalidate); -int iommu_sva_bind_gpasid(struct iommu_domain *domain, - struct device *dev, struct iommu_gpasid_bind_data *data) +int iommu_uapi_sva_bind_gpasid(struct iommu_domain *domain, + struct device *dev, struct iommu_gpasid_bind_data *data) { if (unlikely(!domain->ops->sva_bind_gpasid)) return -ENODEV; return domain->ops->sva_bind_gpasid(domain, dev, data); } -EXPORT_SYMBOL_GPL(iommu_sva_bind_gpasid); +EXPORT_SYMBOL_GPL(iommu_uapi_sva_bind_gpasid); -int iommu_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, - ioasid_t pasid) +int iommu_uapi_sva_unbind_gpasid(struct iommu_domain *domain, struct device *dev, + ioasid_t pasid) { if (unlikely(!domain->ops->sva_unbind_gpasid)) return -ENODEV; return domain->ops->sva_unbind_gpasid(dev, pasid); } -EXPORT_SYMBOL_GPL(iommu_sva_unbind_gpasid); +EXPORT_SYMBOL_GPL(iommu_uapi_sva_unbind_gpasid); static void __iommu_detach_device(struct iommu_domain *domain, struct device *dev) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index fee209efb756..710d5d2691eb 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -424,13 +424,13 @@ extern int iommu_attach_device(struct iommu_domain *domain, struct device *dev); extern void iommu_detach_device(struct iommu_domain *domain, struct device *dev); -extern int iommu_cache_invalidate(struct iommu_domain *domain, - struct device *dev, - struct iommu_cache_invalidate_info *inv_info); -extern int iommu_sva_bind_gpasid(struct iommu_domain *domain, - struct device *dev, struct iommu_gpasid_bind_data *data); -extern int iommu_sva_unbind_gpasid(struct iommu_domain *domain, - struct device *dev, ioasid_t pasid); +extern int iommu_uapi_cache_invalidate(struct iommu_domain *domain, + struct device *dev, + struct iommu_cache_invalidate_info *inv_info); +extern int iommu_uapi_sva_bind_gpasid(struct iommu_domain *domain, + struct device *dev, struct iommu_gpasid_bind_data *data); +extern int iommu_uapi_sva_unbind_gpasid(struct iommu_domain *domain, + struct device *dev, ioasid_t pasid); extern struct iommu_domain *iommu_get_domain_for_dev(struct device *dev); extern struct iommu_domain *iommu_get_dma_domain(struct device *dev); extern int iommu_map(struct iommu_domain *domain, unsigned long iova, @@ -1032,21 +1032,22 @@ static inline int iommu_sva_get_pasid(struct iommu_sva *handle) return IOMMU_PASID_INVALID; } -static inline int -iommu_cache_invalidate(struct iommu_domain *domain, - struct device *dev, - struct iommu_cache_invalidate_info *inv_info) +static inline int iommu_uapi_cache_invalidate(struct iommu_domain *domain, + struct device *dev, + struct iommu_cache_invalidate_info *inv_info) { return -ENODEV; } -static inline int iommu_sva_bind_gpasid(struct iommu_domain *domain, - struct device *dev, struct iommu_gpasid_bind_data *data) + +static inline int iommu_uapi_sva_bind_gpasid(struct iommu_domain *domain, + struct device *dev, + struct iommu_gpasid_bind_data *data) { return -ENODEV; } -static inline int iommu_sva_unbind_gpasid(struct iommu_domain *domain, - struct device *dev, int pasid) +static inline int iommu_uapi_sva_unbind_gpasid(struct iommu_domain *domain, + struct device *dev, int pasid) { return -ENODEV; } -- 2.7.4