From patchwork Fri Oct 20 09:32:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 155927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp931935vqb; Fri, 20 Oct 2023 02:33:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRuq8CHJkXONna/5HbcNp8rguZP1+SWT++XEzOs0te1dhONUutbHkalAb54sFndTwsuYHv X-Received: by 2002:aa7:888b:0:b0:6bd:9281:9446 with SMTP id z11-20020aa7888b000000b006bd92819446mr1296088pfe.10.1697794383940; Fri, 20 Oct 2023 02:33:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697794383; cv=none; d=google.com; s=arc-20160816; b=a6+fSq10/HOVfU4psBtBbVlN8WXlo/8orh6iYuk6UMVynRgTJZnV9sHLRtjc+YYCLv RrY1zKiecbgbmaE3SrTECi8DTaSDWeb/SX5iCMvlIHoJYIUXGXlqq27hGk1mzcHIYCto pepREIMU5bC5cJ1D8rTUv+2sB4H5WsbPhwxLah5tH4G415kzV7TMVmTAsG8xhoBunWPS Jpx1L5yDKXFItGvkegHkIaaDRdR5D69ou4VDhpSzzxLGMKKro2MRfUK7ok8+O/g1ULEp EOyOAfA557BrkNM2bYcLdzv1UjOQnpKWpH8AnOyCwvJOXNDQSBtBb3PdAjMRH/7YOdJA vv5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Zh8S3XlLW2/ul5i4g1MbO9BJhGw2bDPeJg+EvgkuWlU=; fh=AYfEg8UxxCZNlRHxnJWvHuqsheVQzM8ymhb/+J0VVdk=; b=q9/L+0eUc/jhR9cDGmy+ML8YHnMhpvpUAi8Jx8zGnNmdQ1T+OvRwxfb55LUfg8LGmv BC7XPCSDgZHeP0HrkfPc61ENIN/BxfmV5qf5vRxz5dqHoM9Jja0sYrhCbhxPL2yeE4qj ijwVihye+sDv04Z7kdqXJ8PkbVYdNFNzNRp3wNYYvEPxbnNsASFNST0YqPm5hhObLmd0 q3cOYxkxG7EgAQ9ZbMb85pZHA5LBMg2lB7In0DXeHZfRfoVsnZ+7kBZ54+4sixW8WG+u of1qgVeSn6sFW61pMuzE86K2Bv2cEWyM++6ef37HQb/xsDt5hKMkkT0e9nLbxEGYSu4W DZpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UCzGZEpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g28-20020a63375c000000b00585a454179fsi1441659pgn.162.2023.10.20.02.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 02:33:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UCzGZEpC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 174D482CAC1C; Fri, 20 Oct 2023 02:33:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376699AbjJTJcy (ORCPT + 25 others); Fri, 20 Oct 2023 05:32:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376682AbjJTJcv (ORCPT ); Fri, 20 Oct 2023 05:32:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF27CD49; Fri, 20 Oct 2023 02:32:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697794369; x=1729330369; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fFn6Ev4d2j4fnS20q4JAEtrpLg+WWBPIqtUwgZSmJGA=; b=UCzGZEpC0jTjkRP8iRy4NCeEJM1H6kP2LOcgz32/XXUo2P94hbGP4hwa lsIsEbwmIPGW8/hUPgbCSyIICjBptmDKozOFlnmLxJ3Zk6wFmkNLQfDQ6 F/keDJt7RrDKYtVYDZsJMQtTl+8TNnWYSnKy+yu77utGxxw4/T4drCQxA EKbBQrapxXbhGpXdoy6k+hidUNUDzD4cPhYRhTj7YZTwwWNRTHs93HGbq 7y2wHELqyFGKYlixVEBEDMXQ9QtK4VnzrMOS4j02pOCTAk1tCCjj0fos4 sKzn0jqKSwBVatHJRMRizAYZsMpzadT9VUTxdS+vAkMs8phxkdkqmHEUb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="450691673" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="450691673" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 02:32:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="733906290" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="733906290" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga006.jf.intel.com with ESMTP; 20 Oct 2023 02:32:48 -0700 From: Yi Liu To: joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com, baolu.lu@linux.intel.com Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com, kvm@vger.kernel.org, mjrosato@linux.ibm.com, chao.p.peng@linux.intel.com, yi.l.liu@intel.com, yi.y.sun@linux.intel.com, peterx@redhat.com, jasowang@redhat.com, shameerali.kolothum.thodi@huawei.com, lulu@redhat.com, suravee.suthikulpanit@amd.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, zhenzhong.duan@intel.com, joao.m.martins@oracle.com, xin.zeng@intel.com Subject: [PATCH v6 1/8] iommufd: Add data structure for Intel VT-d stage-1 domain allocation Date: Fri, 20 Oct 2023 02:32:39 -0700 Message-Id: <20231020093246.17015-2-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231020093246.17015-1-yi.l.liu@intel.com> References: <20231020093246.17015-1-yi.l.liu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 02:33:03 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780266444377879433 X-GMAIL-MSGID: 1780266444377879433 This adds IOMMU_HWPT_DATA_VTD_S1 for stage-1 hw_pagetable of Intel VT-d and the corressponding data structure for userspace specified parameter for the domain allocation. Reviewed-by: Kevin Tian Signed-off-by: Yi Liu --- include/uapi/linux/iommufd.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index fc305a48ab81..9b843a197ea8 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -357,12 +357,42 @@ enum iommufd_hwpt_alloc_flags { IOMMU_HWPT_ALLOC_NEST_PARENT = 1 << 0, }; +/** + * enum iommu_hwpt_vtd_s1_flags - Intel VT-d stage-1 page table + * entry attributes + * @IOMMU_VTD_S1_SRE: Supervisor request + * @IOMMU_VTD_S1_EAFE: Extended access enable + * @IOMMU_VTD_S1_WPE: Write protect enable + */ +enum iommu_hwpt_vtd_s1_flags { + IOMMU_VTD_S1_SRE = 1 << 0, + IOMMU_VTD_S1_EAFE = 1 << 1, + IOMMU_VTD_S1_WPE = 1 << 2, +}; + +/** + * struct iommu_hwpt_vtd_s1 - Intel VT-d stage-1 page table + * info (IOMMU_HWPT_DATA_VTD_S1) + * @flags: Combination of enum iommu_hwpt_vtd_s1_flags + * @pgtbl_addr: The base address of the stage-1 page table. + * @addr_width: The address width of the stage-1 page table + * @__reserved: Must be 0 + */ +struct iommu_hwpt_vtd_s1 { + __aligned_u64 flags; + __aligned_u64 pgtbl_addr; + __u32 addr_width; + __u32 __reserved; +}; + /** * enum iommu_hwpt_data_type - IOMMU HWPT Data Type * @IOMMU_HWPT_DATA_NONE: no data + * @IOMMU_HWPT_DATA_VTD_S1: Intel VT-d stage-1 page table */ enum iommu_hwpt_data_type { IOMMU_HWPT_DATA_NONE, + IOMMU_HWPT_DATA_VTD_S1, }; /**