Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp199640ybl; Tue, 28 Jan 2020 21:58:14 -0800 (PST) X-Google-Smtp-Source: APXvYqx8lC4YqHujiZRN9rGfRLZa/zGC2xx0U8fBUf+JIl2PTxpPubZ1wRUqpkf6q26q2VI11Uaz X-Received: by 2002:a9d:3bc4:: with SMTP id k62mr20067045otc.186.1580277494080; Tue, 28 Jan 2020 21:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580277494; cv=none; d=google.com; s=arc-20160816; b=MPiYfCJG7YUsaMoVL2wwuIbvQT5Msg1oW1BwHR/x+6zZTZ1MeZNmDqEwlhnfZGxPfK /cujYMSxdNQ5ZuaxKT9qy8mrIwq5xC4AAz0ecynuYbJTfet94GMBPDfHnA/eCxNrq6ff 0WPew8A/yyabr31UYJFKKtttf47iEo0bNK4SO+T8WlFuAPKesJDDGpoGamy1gcCFwN7s IL5kWA0OMBMixwIXJ7kR+d+doj4h8zzEQMYQXnLwE0CTiOlFMBm9sam2mdLxxs99N5Im 9AYZYhdoA3B4gLTo19W7FgFtGiNpK1rHV1RSYNiMiiYHmQidF8QfXkFcCicmFp8kbSbw 2TKw== 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; bh=A5Mr3DtYznsVLXQHhXCTM+NG5Z2cfjFVuhOvy+Ul2tw=; b=pTcNavSkKT9kH34rnrHhm6keI6QxeRbrYYIK2hBYjOmI+6lvXPrmIKQrOdCYKyjlLJ leqivX9gqpDIz79RpDjbUGxYANURvUadSGik+VvnLpyUqZvstykip2PeGU+K39tC3unb efC+6hAoKml25fg4XOelvWqRYCHr1ZRnjERupeA52WvIrL7oaZquwTl5Z44ShmFPUphP wRir3WFPkdK5HSWHclEKjpIOQ8Za/zEQrR7jCeVtO+pS2SfbCQYoxROOLJxHokUG0KzJ 3c+H5jH+depenzyt3BIOlYsSCIkOzFN1IvBhY2hVanq9ssyedOdNJAMlHNaEhqKtPivC P5Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l132si598510oib.192.2020.01.28.21.58.02; Tue, 28 Jan 2020 21:58:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726623AbgA2F44 (ORCPT + 99 others); Wed, 29 Jan 2020 00:56:56 -0500 Received: from mga09.intel.com ([134.134.136.24]:55027 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726528AbgA2F4x (ORCPT ); Wed, 29 Jan 2020 00:56:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2020 21:56:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,376,1574150400"; d="scan'208";a="252500713" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by fmsmga004.fm.intel.com with ESMTP; 28 Jan 2020 21:56:52 -0800 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , "Lu Baolu" , Joerg Roedel , David Woodhouse Cc: "Yi Liu" , "Tian, Kevin" , Raj Ashok , Alex Williamson , "Christoph Hellwig" , Jean-Philippe Brucker , Jonathan Cameron , Eric Auger , Jacob Pan Subject: [PATCH 1/3] iommu/uapi: Define uapi version and capabilities Date: Tue, 28 Jan 2020 22:02:02 -0800 Message-Id: <1580277724-66994-2-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1580277724-66994-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1580277724-66994-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 Define a unified UAPI version to be used for compatibility checks between user and kernel. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/uapi/linux/iommu.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h index fcafb6401430..65a26c2519ee 100644 --- a/include/uapi/linux/iommu.h +++ b/include/uapi/linux/iommu.h @@ -8,6 +8,54 @@ #include +/** + * Current version of the IOMMU user API. This is intended for query + * between user and kernel to determine compatible data structures. + * + * Having a single UAPI version to govern the user-kernel data structures + * makes compatibility check straightforward. On the contrary, supporting + * combinations of multiple versions of the data can be a nightmare. + * + * UAPI version can be bumped up with the following rules: + * 1. All data structures passed between user and kernel space share + * the same version number. i.e. any extension to to any structure + * results in version bump up. + * + * 2. Data structures are open to extension but closed to modification. + * New fields must be added at the end of each data structure with + * 64bit alignment. Flag bits can be added without size change but + * existing ones cannot be altered. + * + * 3. Versions are backward compatible. + * + * 4. Version to size lookup is supported by kernel internal API for each + * API function type. @version is mandatory for new data structures + * and must be at the beginning with type of __u32. + */ +#define IOMMU_UAPI_VERSION 1 +static inline int iommu_get_uapi_version(void) +{ + return IOMMU_UAPI_VERSION; +} + +/* + * Supported UAPI features that can be reported to user space. + * These types represent the capability available in the kernel. + * + * REVISIT: UAPI version also implies the capabilities. Should we + * report them explicitly? + */ +enum IOMMU_UAPI_DATA_TYPES { + IOMMU_UAPI_BIND_GPASID, + IOMMU_UAPI_CACHE_INVAL, + IOMMU_UAPI_PAGE_RESP, + NR_IOMMU_UAPI_TYPE, +}; + +#define IOMMU_UAPI_CAP_MASK ((1 << IOMMU_UAPI_BIND_GPASID) | \ + (1 << IOMMU_UAPI_CACHE_INVAL) | \ + (1 << IOMMU_UAPI_PAGE_RESP)) + #define IOMMU_FAULT_PERM_READ (1 << 0) /* read */ #define IOMMU_FAULT_PERM_WRITE (1 << 1) /* write */ #define IOMMU_FAULT_PERM_EXEC (1 << 2) /* exec */ -- 2.7.4