Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1157355pxk; Mon, 31 Aug 2020 11:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNIQm96mvlq7fQZvnnFlUDiQ1eDCoxvHwfsIcyyiVo3dMP+dtLILCC7DZFXB7N6XXj6ZCI X-Received: by 2002:a17:906:840c:: with SMTP id n12mr2072540ejx.246.1598898016133; Mon, 31 Aug 2020 11:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598898016; cv=none; d=google.com; s=arc-20160816; b=CBsz540ueaPXXYlnDovLFNlXKdpokbdgeG4MkIRY461MvdV4Ua4qG1iKhHfWfyKCHX D/Bd3Njw7N4xaUBjbfKt79Ah+64P6S3D9tyns1/t1vUlDTiksutXlWMWlR5kRimE2mXa d870CIYb0DoamR11v0XCdR8U8kMnrfCRQtgyKyj1OJ8l9QlCzyNTybpYG3YHJqJHY42N rbM30uEoKO/czyMXGAaBX5edjoYTFgQyoPvBmb/AxUuLsJGcIf/EYqWWQX8PE668a4fN ZCaDOnMsh4KEU23tbEej7DqrTynRKjAMJ2n0D/YWgeEsTtfCtgVuZbbFV0SnBmRswhOM QFBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cd/kUvj/qKVGHAwJBYWnGQx2hf0aCQ0hRurRYYSX7es=; b=gaH3qj6xxCeG3DTIDlu6VD4TkDI4NcyRMOlUxKdDuaskkZXnR0umc2cq6/OiJWngO7 iHVnsTe/P/6La7slaS52W2x71pwLl6k+26XbAieZvTVbVx/GOHqj5YVGaXIvDcI3Z7y5 GWrED650hV+vGOdh/ymrP3/H339cPckC29J8f4/UDRO16HhiewowBpYgYKet+sBwZW+o QH5pot3+t3QtNBV2URJhfFX9dGbse7i4AbllrjVONSX9lAAtG7YInjBHkhPCgrIiS7ND npgZWxH4Am8sGc5DzjhYcDlJO1n+gJC4twMKU9NEgHYn6uoV86ggbz6e8sqOOEBownz2 rVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iP8pgYDN; 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 w6si5797162ejb.150.2020.08.31.11.19.52; Mon, 31 Aug 2020 11:20:16 -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=iP8pgYDN; 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 S1729673AbgHaSSs (ORCPT + 99 others); Mon, 31 Aug 2020 14:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729619AbgHaSSS (ORCPT ); Mon, 31 Aug 2020 14:18:18 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0579C061239 for ; Mon, 31 Aug 2020 11:18:16 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id l9so1828305plt.8 for ; Mon, 31 Aug 2020 11:18:16 -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=iP8pgYDNXBrtm/wJWZ2ip7GxuPPyLjMWRgYZz5r4mQ5jFBGlNiPpzoQ9e0lVY5ydRl Ma34JMs2RJVVlSaGje892KlERaePO30L+Reswlst3MdK6+bb/zihB8+l45U91vbXiaWB dwCBunUBvMDWlN5NBMTEJo7dv9k96hDvINBj0ojzbSpJY95mx5BcsPpeEMEv9SvMejVw SV3BuqjYMmQCtvCp0cNLuNCcl08lQHmd70I+WUF63pclmJHvGzCOuIALYbcLh4Fbh1BU SH/WwAn4KBQXD/NFYJTzNopJmVt6B/q+22SRBAIaGHXfF7xbvMkLeylbmuTlQU7Kcp+3 1ICQ== 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=OAAXCCIN/iyDdDgBKl0dqxWj+EJ3Die8O5RTKjEKIWh8mru7Jm4oTQKtyn35z3iZSC Kcial9MiOhT60s92k4PMPYm7+rpPabst7WFPN9iFF3FAYWBg5LrpQjznEbJVl557kHnW GAu+faKHTbU+cvN0lMCeKyw/QYPCP6uTf3HztCwBMfFbqHAsFp5W6ztqhgbi35CFMQbl Yljg9iUHBW32XRAvxRcU8nuVsDhAQQaEHJrcdxEH43+76cAtkrb2YaE3qDmZaC1Ji9gW f9FlR3LERbJNvyyeFejdsTCA2/J8T/LbXg3WZ00JFhb7acxWjK2kfuJe724IA40L/D7Y ADwA== X-Gm-Message-State: AOAM530FE76aQoJFgbNbIweur5E4mNukcJfmJoUeRwMtZoymdg5WU5Oo m8Yn0P4JJcUDVvQ1VG1SuuVk7RwyyFI= X-Received: by 2002:a17:902:b714:: with SMTP id d20mr1937372pls.103.1598897896399; Mon, 31 Aug 2020 11:18:16 -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 y128sm8672547pfy.74.2020.08.31.11.18.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2020 11:18:16 -0700 (PDT) From: Jacob Pan X-Google-Original-From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , Joerg Roedel , Alex Williamson Cc: "Lu Baolu" , David Woodhouse , Yi Liu , "Tian, Kevin" , Raj Ashok , "Christoph Hellwig" , Jean-Philippe Brucker , Eric Auger , Jonathan Corbet , Jacob Pan Subject: [PATCH v8 5/7] iommu/uapi: Rename uapi functions Date: Mon, 31 Aug 2020 11:24:58 -0700 Message-Id: <1598898300-65475-6-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1598898300-65475-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1598898300-65475-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org 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