Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1240414pxk; Fri, 25 Sep 2020 09:33:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoUPhT4i/zfNF/0OIEruHynAQ1yO61eBqdFRTzgsx9rv7Nu7Dofw4hC6Npeawkimu88k7e X-Received: by 2002:a17:907:2055:: with SMTP id pg21mr3691224ejb.501.1601051625315; Fri, 25 Sep 2020 09:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601051625; cv=none; d=google.com; s=arc-20160816; b=AYTMaZXLg7/x736OmF21gJbxKuLmHLKbuwjnIsQJAvIKrDBzAL/oaDIQEZVpDziMQ2 qjI9OPDzL1ILfYHPla9QG4nI9lg6sP9w+vCLbtuMoRfrEyqjR9QkKvUfPlZIoni4FgXd lDRSkozaW3AaVeqDxpXv/lpaT1MYALiIaR16RVS2Z4dLzHCXMqchCxEHrzCARsKlD6ri nhW+fqo2AuL/IJxtbQqtNkQlKQHb8ifJtqYcg3/bFh7QfHjt0Qu6wVG5EtusPBLOzhG+ BeVcfdEPCCgF1cUB74nKpAWIsR3D6Vi7cXmnp5F1MrtLug0fxlgkTbnmriU1duLTnk6G YNnw== 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=ndRHpDdWkC6bt62058lXfxZupL2c/xEjKfzcO8mR4b3d4/5aeghsufdS8oUGGdzuNB P3r8nGwI+mzWn8NhhyEq+VgXtWHWawbQcWu1Ey7xsOlRU+2QGVlJJKhLrtbIMs520Le3 lFYotX/CsOcnQmQERsnZDVkiwjr5SJTTXxADcHc1eCxUCbMjLMA4pDcJM+5g8UQCpHf2 0U01CaNNXymKQoDLei5pqf/uCP+L+Bf7RENw223IQGRmq6NB+zsk3zscI0pDy1P2ZsGs GY+tEDIbxumNOTIESItafQIQLmigC88y1k7CO+AeKtrVKSZdzy9Q9GGGHyfKdLTvgcWt zDQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="mEyhJR/g"; 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 k19si2169493ejx.426.2020.09.25.09.33.21; Fri, 25 Sep 2020 09:33:45 -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="mEyhJR/g"; 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 S1729517AbgIYQbA (ORCPT + 99 others); Fri, 25 Sep 2020 12:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729488AbgIYQa6 (ORCPT ); Fri, 25 Sep 2020 12:30:58 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17590C0613CE; Fri, 25 Sep 2020 09:30:58 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id b17so2011910pji.1; Fri, 25 Sep 2020 09:30:58 -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=mEyhJR/g4bpYOqOqLHkx9hTMsIrcV6XsQQ/dluoM6FLGbRiEfjlPj0muZL7l2KG8Gf URx8O7SWHcoO8Y0I/TMqbENKaJrrnl1bTjdrXcFhtIkCgqUQzePd+p8iuZokm0aSD4FD 2DJNX3cgR6/IfzNH9LD9b2MVOuynLyzPT1jZP46wrpuYM+/LLjgzMtRWOH5vqroBzT39 XYXchQ/SGD5KCIzXPJw3TY6qvoMRlVvKibgxFbL03s6guKi+k7ThyK+ItHATLlJlGF2J B/PmW4gM1xl/V6sBs5qCdnTr758rZvivvb50bS8CQzxwTKfn5y4tw5fo70JG/HTBNyQa XCGw== 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=jaMq36sjdSM5UcvtRGGjod4Dxof66tFVFGcspaGpJieYc7hyHCBeOnFoQ0txjiYaFU CVJnnBwtTijjjZi9GHjxicmHKYgWf80xEZM8/BE+HiwCRRnjZwhMLws/k4tTCbo6Rl5e 4BL94wlkCkDoKxDxz5e5vYCiAyL+TjZfhdX1FU9dl45Zebhvp1p+NBOkBm+r8My/vyTV bNn0L4/YWSAyHnEYCP21Ht5pbdpUef6q9NVfx/+kngmR6ZejaBzd9G17CbUHSx+qUG0a 9GsaTtdse6Ns+Q0ZMjLaxkjhdcl86rThOYT11NcCBDcX5798vnmeoxwjI8v2cXbJ9FS5 gVFQ== X-Gm-Message-State: AOAM532lPJTa1X49Y5k09LRkiQK8mwYqPybTye0vt2pbs0YAJS3bNbob +ZDZwfWJGUe3HezVzzAxYEE= X-Received: by 2002:a17:90b:fc4:: with SMTP id gd4mr376733pjb.129.1601051457680; Fri, 25 Sep 2020 09:30:57 -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 j19sm3197039pfe.108.2020.09.25.09.30.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Sep 2020 09:30:57 -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 v12 4/6] iommu/uapi: Rename uapi functions Date: Fri, 25 Sep 2020 09:32:45 -0700 Message-Id: <1601051567-54787-5-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1601051567-54787-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1601051567-54787-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