From patchwork Thu Sep 28 07:15:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Liu X-Patchwork-Id: 146235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3488942vqu; Thu, 28 Sep 2023 10:45:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTqB4i4bGdlnuMWuRNgRuB1DEGsmlRy1Ikl7YRgX8KgF0ZNuI93Gq5veDAsIhddMS6gstF X-Received: by 2002:a05:6a20:8e0a:b0:133:bbe0:312f with SMTP id y10-20020a056a208e0a00b00133bbe0312fmr2206335pzj.50.1695923144832; Thu, 28 Sep 2023 10:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923144; cv=none; d=google.com; s=arc-20160816; b=nguSzGnm5C63N2HhKSLB4I8sitUV10HBV0g5KJFCdRlWCxb1nbWH0cOnotQiWdu90E BQDH2WvvOe8qdgYatBxFX6gOkAnzmQblp6pZF16SgI7obmk07Vwutl/zZWA0OTOV09Zw PvogtMutX8ZoOEG8m9iILOqbNR7apcvT8VFV2V5q1oWHplYLM8Jmm/W01CtcvLZBdk2s hBE8j4HDoms4e1PpZWBDq2CN7HaBcJacD6X7dDS4tv21EG+e+9z3hyik7LESIATahANB jVlqySJ4GkH7hkUvCjfBh8JxxRbfzcDOQQ5oQk3iXhvhjlchp7zwC2VpmGP1h4yRYrYO KfHg== 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=fMe+4r4h27YBWGP1Mh7yCshcsdgO6yvR9/I+ocLojQQ=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=FkGHUZnx1AS3yUHe1Zf+AADZxpeo4RteWeeCcFzrWXkVii7vGXGOmmvLSJrrqheRSh qnH2moEvyB6sX4+jAP1kgOY5MDQGQYFv2xn3Imsg6kHBWEt/WskXsNvSPQE5f+CsZzB7 4YIVp2EBvXvQO03G9sD/9WYFWG921EekMSL8ygPzlpLM666J7UNf25/WClWMfy17lb02 xTdpSPR5ivsujHZzx0mXfEzNHytTTtNzxdx/RbqnTApXMp+KMOxz5JAz8SId2zIYberj rC+v2BqNuYSMvnFgR5MV9hfIjNJh7J1fBRmDTAyT6iJ2gUR+8KpUezN6btv/JMXQ6BDY BAuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=MUUMRgTT; 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 kn8-20020a170903078800b001c5cf1c30cfsi13139569plb.435.2023.09.28.10.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:45:44 -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=MUUMRgTT; 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 E65D882CB51C; Thu, 28 Sep 2023 00:16:07 -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 S231509AbjI1HQB (ORCPT + 20 others); Thu, 28 Sep 2023 03:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231367AbjI1HPn (ORCPT ); Thu, 28 Sep 2023 03:15:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6D35CC0; Thu, 28 Sep 2023 00:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695885341; x=1727421341; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=caYY16c3X4qJEs7vjlwRO/5AoAt3WHXwfSZCdiD2ZmE=; b=MUUMRgTThCSMlVV1j4ZAkDCiQnN9ahJ6PcuzU+TcvyVcHdmKXm8mQy/F g+aAp8eaWWt/Te+fZL3WWhBmn6nKxpYDZDEVMpnN8ProDarasVWjq+4c8 VkYWlZkfoHhL0Pd+5xO1+G2i+/Pc9m0Vp5TFJFlLkTABF/rXNwnpQFpvr 2CXqJYOih/iLUOE5kDpWrP6E5EH2Ry4iaPh6XPmwo1l/bTqxlHDB9ijOA yvddVyVhU3n9kD3aiazM2aqmWI40jlWP72/xnU9snwxIyt6pTv5KwNYbN +LqUS+2BpDfjQGXGz5fVOmtVooC9h75rOJ0zcTap1qW+Lp0oZcbn3ijS1 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="412914872" X-IronPort-AV: E=Sophos;i="6.03,183,1694761200"; d="scan'208";a="412914872" 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:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10846"; a="784602100" X-IronPort-AV: E=Sophos;i="6.03,183,1694761200"; d="scan'208";a="784602100" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga001.jf.intel.com with ESMTP; 28 Sep 2023 00:15:36 -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 Subject: [PATCH v2 4/6] iommufd/hw_pagetable: Support allocating nested parent domain Date: Thu, 28 Sep 2023 00:15:26 -0700 Message-Id: <20230928071528.26258-5-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928071528.26258-1-yi.l.liu@intel.com> References: <20230928071528.26258-1-yi.l.liu@intel.com> MIME-Version: 1.0 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: 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:16:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778304307906676603 X-GMAIL-MSGID: 1778304307906676603 This extends IOMMU_HWPT_ALLOC to allocate domains used as parent (stage-2) in nested translation. Signed-off-by: Yi Liu Reviewed-by: Lu Baolu Reviewed-by: Kevin Tian --- drivers/iommu/iommufd/hw_pagetable.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 5be7a31cbd9c..8b3d2875d642 100644 --- a/drivers/iommu/iommufd/hw_pagetable.c +++ b/drivers/iommu/iommufd/hw_pagetable.c @@ -83,6 +83,9 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas, lockdep_assert_held(&ioas->mutex); + if (flags && !ops->domain_alloc_user) + return ERR_PTR(-EOPNOTSUPP); + hwpt = iommufd_object_alloc(ictx, hwpt, IOMMUFD_OBJ_HW_PAGETABLE); if (IS_ERR(hwpt)) return hwpt; @@ -154,7 +157,7 @@ int iommufd_hwpt_alloc(struct iommufd_ucmd *ucmd) struct iommufd_ioas *ioas; int rc; - if (cmd->flags || cmd->__reserved) + if ((cmd->flags & (~IOMMU_HWPT_ALLOC_NEST_PARENT)) || cmd->__reserved) return -EOPNOTSUPP; idev = iommufd_get_device(ucmd, cmd->dev_id);