Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1224940rdb; Wed, 20 Sep 2023 03:22:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFKvtSaEv00xkxI0QliyEboXV91zgHHvHHdCE5LgUUoSKTdIaRq+iffKEdrMU9jacaQzLAs X-Received: by 2002:a05:6870:96a8:b0:1d6:51aa:139b with SMTP id o40-20020a05687096a800b001d651aa139bmr2600161oaq.19.1695205379143; Wed, 20 Sep 2023 03:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695205379; cv=none; d=google.com; s=arc-20160816; b=juUT8lZQraw8vIVRRtMwVArshIohk/7825Hd1HSsdT73kYx3DDS2exu0UDwv6DSNVI 3oo4K8HyF7TfKcKM4zXBCmice2uoZHrSdTO9sMSrwQb0tf9QXA79dIpagYfP0oAI1y1J mL90L6wWLcHvbRw3sBZESO3uaS7tROxZ0J0OlmL1LiVpGxJbPwdKo6ngutLd4Axs6NoD 6XYzyefjQ4nj62fOQLE4SaJRHDeBg8Tb2YpIbTlNTbOTmp9BKCXNz6pM339mdvk5RIs9 tztaA1+n6dlqLXlpeUsZYiG7C3Xk2Ec7iGxi4X6hvt2RlinWXJ2qBCL2nGrMTWtjcrNg sSwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:to:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=+16CavHHa6VTwdbD1XXVSy4ejHGWDKYo2TwqKnE3cSY=; fh=RyUMBMrENLl9z3agrcvUie7TturAiXShjxmDx0E12f4=; b=mYQpU6wXuf6jQScFOqPyvVOTu5ZG1dYULLMq+CYmP9Q2ikbyyNqM3zghICY9lXw71w cfjuN7lC4Bbx+XhdRdCGCLa9GUT38WfJxbVYM3ljrWeYS4ZNSbYir7ZYTaY8QNfKK7Ly YQE6FH12BqbJ2RR5JT/jghMtrcOeBPEHb4C7AVMEWG6edj+obM2ZV7QG1zVeUIBLTMac sud3f+MNqnV94ppf+ZW/lcUFF0z4YBD0AIhHsHSg798DQSCX1q3JGwyzPs38OOW9qJGr F1xoZrwweZsWoQ1sSC/7TZ3jILAlWXr43FW/+NDmp+xx5pY+SONFzNJ446hpI29lPglo VoUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="WP3BDN/6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id y7-20020a636407000000b00578ea9a0b97si513694pgb.539.2023.09.20.03.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 03:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="WP3BDN/6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 229F082A4A38; Tue, 19 Sep 2023 22:08:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232152AbjITFIg (ORCPT + 99 others); Wed, 20 Sep 2023 01:08:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229770AbjITFIf (ORCPT ); Wed, 20 Sep 2023 01:08:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94468AB; Tue, 19 Sep 2023 22:08:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695186509; x=1726722509; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=1+jAS6yHwzuVm+ydois1vVDLifWQ2vZ5OOkmlSpSb0I=; b=WP3BDN/6fuxDUPw55b/SOI0Qw++nHZ7za2U5hNWWgn2A2b4CT48PhgwG O89mFVIyGUqSt8EokOEPpXs5urck0Wt1VrPNMjtE8OCqIirYX2/uo4GX9 1RelsLBN8o6tZDE9nnkYxQixOrimJkwxlkFMW1bMDZFnG7FQuFqm9kNcE PlSBM9jybRCjzqBIF50vsE2eMUni/VVCUDf0bh5IaOuc4/irebxWd9hRc zYw620G5ffSDm62ZxvHLQECZKlIkMtzbbCe6ybyaEXflMiL8/KIpLLovK teG86QZ5C63rwNcfAZYPEgGLBbG1Y9xV1L+DQ94oVE2yv/J7G9bxIdmmV w==; X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="377434407" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="377434407" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 22:08:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="781556740" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="781556740" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga001.jf.intel.com with ESMTP; 19 Sep 2023 22:08:22 -0700 Message-ID: <7d07bea9-02a5-7113-8cc1-f7aed073cf96@linux.intel.com> Date: Wed, 20 Sep 2023 13:05:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Cc: baolu.lu@linux.intel.com, 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.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: Re: [PATCH 4/6] iommufd/hw_pagetable: Support allocating nested parent domain To: Yi Liu , joro@8bytes.org, alex.williamson@redhat.com, jgg@nvidia.com, kevin.tian@intel.com, robin.murphy@arm.com References: <20230919092523.39286-1-yi.l.liu@intel.com> <20230919092523.39286-5-yi.l.liu@intel.com> Content-Language: en-US From: Baolu Lu In-Reply-To: <20230919092523.39286-5-yi.l.liu@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,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 morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 22:08:36 -0700 (PDT) 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 > --- > 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