Message ID | 20230919092523.39286-5-yi.l.liu@intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3244776vqi; Tue, 19 Sep 2023 02:32:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDvnbHhcH68mjooX32Y7wumeIt+KjalfoYusOamXrewcxC/S6CyddDaVL4Q2n7nvMOsGAA X-Received: by 2002:a05:6870:7027:b0:1d2:4b4c:eb11 with SMTP id u39-20020a056870702700b001d24b4ceb11mr14567072oae.32.1695115927836; Tue, 19 Sep 2023 02:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695115927; cv=none; d=google.com; s=arc-20160816; b=AQZhJssuRkzGu810uGwRsbt15zsZIJ5/kzmZ9yeMYDH8oCfZlfSBI3CPB3VvqVuwvv Ws1gLkfXA1uMxRAnoEoPEv+Y8SKysKAezBfPYkyZaxqSHJ+JG0TEplNJZVQ7q8G1nXoU DspUJbnyQsKKdMT2HR/8ORyxV4sGLHNrtxlYv78qv4tQrV1u2R6O7ZYLzrFC7Apo4+h3 lflp8n1oNfdZiFdCs1EhI5q1hErRTnNOGlcDLL5kqsooRoAcixf1QQIcBdZuPZzQLUzE GxQpDk8XeeROuWGkmJdSqx72QO0ABibxXXvIC56FWXWFABPEo2BzACT9F813ou9V7jCn 3HTQ== 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=Za4EkxBilisrWScE5f7iblx6T9qB1xELBkJ/ylhGX2A=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=uIxhPpUlKd5criBEfUmJKVhj/LRbuFFu0qQaFreVI6SCBqlh6fILza3JdaDtdKVIWp By2WmujMsCXeCyX1ZXFqaOyc3yu67tRIx5GnoA2y9vv2bMw0V3O16cdePfBEk9qFGVTJ Rph7jcNUBKW4PrTgHP0KPiWRUIuDYZcMkexWzSeo1+GCo+4MiPnZ2o8ZQiy7XLyhfAOL CUaDVjlK7osfpyvMPlBUpVpvci18dqveCOnZnr5Vu8bWKa5UaXveYgq/yhDC3vrWeIo3 5PoCmn47zZSUZ42Y0BD9wIZe3YWjiN4jwnK9aXsOw4M99FN8SfyiyyzSViRpQNGepSbY t8Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxEwXDz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id r15-20020a638f4f000000b005775613e206si9416038pgn.507.2023.09.19.02.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 02:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SxEwXDz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 2606C8182EE1; Tue, 19 Sep 2023 02:26:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbjISJ0Z (ORCPT <rfc822;toshivichauhan@gmail.com> + 26 others); Tue, 19 Sep 2023 05:26:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbjISJ0U (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 19 Sep 2023 05:26:20 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59984134; Tue, 19 Sep 2023 02:26:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695115573; x=1726651573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q66OHCFRu99evLMCHuExKGxiNMAzbw1601UJQaxYYqQ=; b=SxEwXDz+jalvWe/dutrmWsSyZEo1t4MwJCSVo4ZcJjd7SiGvrivuok03 mWCpZ0VUbJWyub9fzTdF2CfCHOZgWGK02iDOiFLkniNnnNmadyVMXZJE7 UrtC7VXOBRud+FkfLTLdPBOnhLaHsLebLHju2Y3XTPbIZvkZXKTAd6FFP rggKnkWOXzI/SXx9dGlE458WzuGfhNRodh1hpsakeYG61u2EwBbXj1G0e uksDIwQRNylTtHUVx+8/9fjFzYhacLrz1BaxnHdQzZjYnhvQp5WImiTkj 6v1DamzK7dyvl0SaAYTxDuW+P5X1PnR6g99Bu2io0DTRTcNjbzg2uF0lk g==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446368928" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="446368928" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 02:25:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="722804772" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="722804772" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga006.jf.intel.com with ESMTP; 19 Sep 2023 02:25:34 -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 4/6] iommufd/hw_pagetable: Support allocating nested parent domain Date: Tue, 19 Sep 2023 02:25:21 -0700 Message-Id: <20230919092523.39286-5-yi.l.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230919092523.39286-1-yi.l.liu@intel.com> References: <20230919092523.39286-1-yi.l.liu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:26:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777457879029452292 X-GMAIL-MSGID: 1777457879029452292 |
Series |
iommufd support allocating nested parent domain
|
|
Commit Message
Yi Liu
Sept. 19, 2023, 9:25 a.m. UTC
This extends IOMMU_HWPT_ALLOC to allocate domains used as parent (stage-2)
in nested translation.
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
drivers/iommu/iommufd/hw_pagetable.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On 9/19/23 5:25 PM, Yi Liu wrote: > This extends IOMMU_HWPT_ALLOC to allocate domains used as parent (stage-2) > in nested translation. > > Signed-off-by: Yi Liu <yi.l.liu@intel.com> > --- > 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..26a8a818ffa3 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 & IOMMU_HWPT_ALLOC_NEST_PARENT) && !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; Need a parenthesis here, otherwise the compiler will interpret it as a different condition. if ((cmd->flags & ~IOMMU_HWPT_ALLOC_NEST_PARENT) || cmd->__reserved) return -EOPNOTSUPP; Best regards, baolu
On 2023/9/20 13:05, Baolu Lu wrote: > On 9/19/23 5:25 PM, Yi Liu wrote: >> This extends IOMMU_HWPT_ALLOC to allocate domains used as parent (stage-2) >> in nested translation. >> >> Signed-off-by: Yi Liu <yi.l.liu@intel.com> >> --- >> 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..26a8a818ffa3 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 & IOMMU_HWPT_ALLOC_NEST_PARENT) && !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; > > Need a parenthesis here, otherwise the compiler will interpret it as a > different condition. > > if ((cmd->flags & ~IOMMU_HWPT_ALLOC_NEST_PARENT) || cmd->__reserved) > return -EOPNOTSUPP; ok.
> From: Liu, Yi L <yi.l.liu@intel.com> > Sent: Tuesday, September 19, 2023 5:25 PM > > @@ -83,6 +83,9 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, > struct iommufd_ioas *ioas, > > lockdep_assert_held(&ioas->mutex); > > + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ops- > >domain_alloc_user) > + return ERR_PTR(-EOPNOTSUPP); > + if (flags && !ops->domain_alloc_user) return ERR_PTR(-EOPNOTSUPP); as long as flags is non-zero we'll need the new alloc_user ops.
On 2023/9/26 13:32, Tian, Kevin wrote: >> From: Liu, Yi L <yi.l.liu@intel.com> >> Sent: Tuesday, September 19, 2023 5:25 PM >> >> @@ -83,6 +83,9 @@ iommufd_hw_pagetable_alloc(struct iommufd_ctx *ictx, >> struct iommufd_ioas *ioas, >> >> lockdep_assert_held(&ioas->mutex); >> >> + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ops- >>> domain_alloc_user) >> + return ERR_PTR(-EOPNOTSUPP); >> + > > if (flags && !ops->domain_alloc_user) > return ERR_PTR(-EOPNOTSUPP); > > as long as flags is non-zero we'll need the new alloc_user ops. yes.
diff --git a/drivers/iommu/iommufd/hw_pagetable.c b/drivers/iommu/iommufd/hw_pagetable.c index 5be7a31cbd9c..26a8a818ffa3 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 & IOMMU_HWPT_ALLOC_NEST_PARENT) && !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);