Message ID | 20230928071528.26258-1-yi.l.liu@intel.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3205529vqu; Thu, 28 Sep 2023 03:23:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzNzRIfOFh9p9Lf6pUKhnaczhzL1BqMobRz5r2IBWCzQXPkstV2ktejebibX5HgUw3WJFm X-Received: by 2002:a05:6a20:f3af:b0:15d:b699:5522 with SMTP id qr47-20020a056a20f3af00b0015db6995522mr692295pzb.34.1695896591318; Thu, 28 Sep 2023 03:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695896591; cv=none; d=google.com; s=arc-20160816; b=tHsaB5qjPlLk0aYVvefPtu7SzCR/9lrB4M3E5tqTyamFBl73nYdqVcXRb0rdBBeVRx kkFd/eUpR2zu91LkVqrTR5CwpoVXxs3Fr/HATK8aBwgC4JjfI+zhmSOdmh5r/iiMjsMJ MInDfxtE/eWDN/QSdMTyy5Ae/hs+yvG1Zs4FEuQiF+HSrJheylLfQGDtGnPb6IktwJt9 W8z0+tJkqVejnwDUrfh/sWwAn0Qx8S6u6Pue2BxX7pvS+ECbyhZMhO3henn9xr3it7zt d49VWrRafHlpdPfN87TBCPfwXnXbR27oEJJAe5qI9VAkyXXBbg3E0XHQqvH4Q2BGBPBb ya4w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mceESmqZ2R1uDa9bLm2v9tUaZ/bbGMHIEPTl1I78BfE=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=HBeTXYRAw4f7d4moAzIv7rLKX/9uZOGXWiApqpbg5iJVn+MIoyGN6Guc/TKodLoL+f ORFSa9BqVI+h77+av7j+BetWqXNdQafEbZmnclfnLKhVeaKQKVQpPwyZ0Tdw/gBDHkgx X8RIAUA9mRuNY0uRiTuOLdDxerpVGlSnolh3Ihck+shg5OcW7kJEL+dKybAlRtMIquG7 mOFsGqVTArNenDJjnl4hOkkYlxr26TD9GEgKAixt5vTDGj1gdOli3uCxE2WwtNv/e/D/ OAyUgiRyJt3m07rtaUSbl+n50q8N2kmi5Maz5VTFGWDoYbxLz5UxQleZ8YWx9e5igRtJ FzeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jI8IrMhY; 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 u9-20020a17090341c900b001c62cfff798si8703975ple.372.2023.09.28.03.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 03:23:11 -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=jI8IrMhY; 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 5A7A982CAC11; Thu, 28 Sep 2023 00:15:58 -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 S231514AbjI1HPt (ORCPT <rfc822;ruipengqi7@gmail.com> + 20 others); Thu, 28 Sep 2023 03:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231246AbjI1HPd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 28 Sep 2023 03:15:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCC041B2; Thu, 28 Sep 2023 00:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695885331; x=1727421331; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Wn3wXR37JoGGgItNRNp+OOoXXPlkBH9261CwXM5sCbI=; b=jI8IrMhYRBlshiNNQKlu4aWa2NYg4d++uIhmAsDBi0B6EanfrnPaCPje d4gaMzQR7+I/3C2aYyI4ppDn/TdaKA/9hywDGI/+MUVhg6MKnVPSRevnx /CBJiHGJreHMi8SIZi34E6XgUrNyIIZbTwW+BAXe1a1srZFl73Rzso0WK 7vc2TfGebw+CnzouT/s3b365CTCQu8qXfimcdWU0MbsGE93SE+lF7Moay KJZECdfsOVvtqgEBVfiBX9uBtlrk65qaFX4gKRZzDgGhbEshd0TxvS7Im bFBAubR1lS6NDqokWwelF6d3OlNm9Ueoek1LghDLr6tTlSkom6GXGTxnx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="412914813" X-IronPort-AV: E=Sophos;i="6.03,183,1694761200"; d="scan'208";a="412914813" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2023 00:15:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="784601954" X-IronPort-AV: E=Sophos;i="6.03,183,1694761200"; d="scan'208";a="784601954" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga001.jf.intel.com with ESMTP; 28 Sep 2023 00:15:30 -0700 From: Yi Liu <yi.l.liu@intel.com> 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 Subject: [PATCH v2 0/6] iommufd support allocating nested parent domain Date: Thu, 28 Sep 2023 00:15:22 -0700 Message-Id: <20230928071528.26258-1-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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: <linux-kernel.vger.kernel.org> 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]); Thu, 28 Sep 2023 00:15:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778276463684099150 X-GMAIL-MSGID: 1778276463684099150 |
Series |
iommufd support allocating nested parent domain
|
|
Message
Yi Liu
Sept. 28, 2023, 7:15 a.m. UTC
IOMMU hardwares that support nested translation would have two stages address translation (normally mentioned as stage-1 and stage-2). The page table formats of the stage-1 and stage-2 can be different. e.g., VT-d has different page table formats for stage-1 and stage-2. Nested parent domain is the iommu domain used to represent the stage-2 translation. In IOMMUFD, both stage-1 and stage-2 translation are tracked as HWPT (a.k.a. iommu domain). Stage-2 HWPT is parent of stage-1 HWPT as stage-1 cannot work alone in nested translation. In the cases of stage-1 and stage-2 page table format are different, the parent HWPT should use exactly the stage-2 page table format. However, the existing kernel hides the format selection in iommu drivers, so the domain allocated via IOMMU_HWPT_ALLOC can use either stage-1 page table format or stage-2 page table format, there is no guarantees for it. To enforce the page table format of the nested parent domain, this series introduces a new iommu op (domain_alloc_user) which can accept user flags to allocate domain as userspace requires. It also converts IOMMUFD to use the new domain_alloc_user op for domain allocation if supported, then extends the IOMMU_HWPT_ALLOC ioctl to pass down a NEST_PARENT flag to allocate a HWPT which can be used as parent. This series implements the new op in Intel iommu driver to have a complete picture. It is a preparation for adding nesting support in IOMMUFD/IOMMU. Complete code can be found: https://github.com/yiliu1765/iommufd/tree/iommufd_alloc_user_v2 Change log: v2: - Require domain_alloc_user op if IOMMU_HWPT_ALLOC passes non-zero flags (Kevin) - IOMMUFD core should check kernel known flags while iommu driver needs to check supported flags as well (Jason) - Minor tweaks per Baolu's comment v1: https://lore.kernel.org/linux-iommu/20230919092523.39286-1-yi.l.liu@intel.com/ Regards, Yi Liu Yi Liu (6): iommu: Add new iommu op to create domains owned by userspace iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation iommufd/hw_pagetable: Accepts user flags for domain allocation iommufd/hw_pagetable: Support allocating nested parent domain iommufd/selftest: Add domain_alloc_user() support in iommu mock iommu/vt-d: Add domain_alloc_user op drivers/iommu/intel/iommu.c | 28 +++++++++++++++++ drivers/iommu/iommufd/device.c | 2 +- drivers/iommu/iommufd/hw_pagetable.c | 31 ++++++++++++++----- drivers/iommu/iommufd/iommufd_private.h | 3 +- drivers/iommu/iommufd/selftest.c | 19 ++++++++++++ include/linux/iommu.h | 11 ++++++- include/uapi/linux/iommufd.h | 12 ++++++- tools/testing/selftests/iommu/iommufd.c | 24 +++++++++++--- .../selftests/iommu/iommufd_fail_nth.c | 2 +- tools/testing/selftests/iommu/iommufd_utils.h | 11 +++++-- 10 files changed, 124 insertions(+), 19 deletions(-)
Comments
On Thu, Sep 28, 2023 at 12:15:22AM -0700, Yi Liu wrote: > Yi Liu (6): > iommu: Add new iommu op to create domains owned by userspace > iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation > iommufd/hw_pagetable: Accepts user flags for domain allocation > iommufd/hw_pagetable: Support allocating nested parent domain > iommufd/selftest: Add domain_alloc_user() support in iommu mock > iommu/vt-d: Add domain_alloc_user op I copy edited the commit messages, and moved the hunk adding IOMMU_HWPT_ALLOC_NEST_PARENT from 'iommu: Add new iommu op to create domains owned by userspace' into 'iommufd: Support allocating nested parent domain' Otherwise applied to iommufd for-next Thanks, Jason
On 2023/10/11 00:47, Jason Gunthorpe wrote: > On Thu, Sep 28, 2023 at 12:15:22AM -0700, Yi Liu wrote: > >> Yi Liu (6): >> iommu: Add new iommu op to create domains owned by userspace >> iommufd/hw_pagetable: Use domain_alloc_user op for domain allocation >> iommufd/hw_pagetable: Accepts user flags for domain allocation >> iommufd/hw_pagetable: Support allocating nested parent domain >> iommufd/selftest: Add domain_alloc_user() support in iommu mock >> iommu/vt-d: Add domain_alloc_user op > > I copy edited the commit messages, and moved the hunk adding > IOMMU_HWPT_ALLOC_NEST_PARENT from 'iommu: Add new iommu op to create > domains owned by userspace' into 'iommufd: Support allocating nested > parent domain' sure. this movement makes sense to me. > Otherwise applied to iommufd for-next thanks. feel free to let me know if an updated version is needed.