Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp828141rdb; Tue, 19 Sep 2023 11:15:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFb1yZHJKFmoWAa+bjXg0NAf05HAikMVVTE2HR6//X9l9W707N0zAm5Q4MusFiODAj7HLNv X-Received: by 2002:a05:6a20:7352:b0:15a:f4e:620d with SMTP id v18-20020a056a20735200b0015a0f4e620dmr394247pzc.4.1695147340161; Tue, 19 Sep 2023 11:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695147340; cv=none; d=google.com; s=arc-20160816; b=ZlAqvcXFxfKIJ8IFzM9LzpnBDrhbVTt8IRyIeO1biDY4o/B6TvZ1Q/HgQZSDqhJ0Ic aBkYb9HlzDQ6ed5dDkrUcbFUIfkANdxPtZS+YnTu4p7cWHy1N2JWcsvMoWT0GTD12XjG ZM+neQqYKwNHGAdTBuSCVkUw6I86IJKjELETjHShFl+hYP2oqmEbMvhYre2gHHVB3p3d q9ocsacRn8bHHbrMPsho28fH6jJi9ZakQ+GL+8LaJwx6X1tc6D7TiAh78CWu/prdXvTb tN48iBBlEsadlL4QFNSw+H9P/Dm8Ix+zLeGX8o51W+zkdQmvSQnjldqDUbJgRECaKzJB Qpqg== 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=qkK7YV873sVdW51UZUIcTDcFfYXiu8MriT05qvT7mbc=; fh=ncJBVmsnOSqrX1O37yfYEzicwaA2e7ARxnsU7aiysyE=; b=Zp9VK7Wt18xEEN9ayMpQtMnYPkUCode7k09gISyz/DdoHmHZa/RihcR198YBGvHtET Rgqpdx54f2g9dC8VDtVbKCdJBh/sH8G0RZMSocKKkRQqiLEMTC3cjKnifZQmqu068yPh dyvGvtnU9Z1y/iPyX2Pr1N6y5izPEzok5MeMDb6QSCdoJ85CHDKpvD+T7/4eMpyUmqmi waeM7By07lYv/Beem9rk9P0hfp+f5mSVnrMwtAmW1/uAkw9UYcP787erzbdiNwVtg81F blR549ASl2+xL9lmvrVRQlbrXi8SVpxU8kNzcJNYZZbXyydrcnRclfYX2P8Dall025GB rrlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CHAn9QRK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id h184-20020a6383c1000000b005775c7e503csi1278758pge.116.2023.09.19.11.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 11:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CHAn9QRK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 14CCE814419E; Tue, 19 Sep 2023 02:26:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231580AbjISJ0e (ORCPT + 99 others); Tue, 19 Sep 2023 05:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231436AbjISJ0W (ORCPT ); Tue, 19 Sep 2023 05:26:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52CA9F2; Tue, 19 Sep 2023 02:26:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695115576; x=1726651576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=W3riUZjJN8lKSKgwdYFNtz+cVKj5BdWi3nncFILY6lA=; b=CHAn9QRKv3H3tDCiTWgLAvQCce/ncVyy1qkQ1UoZ+ThsxQWzC+w1kfXb SFwRzv3OBav2+J3ai7Ayn9IjzF+TNRR1G0zM3dqPPqW9XsAme7XgnSGlm shn8TPCMJB7GHzWBSkGw7F++rW13hhE6VTFGcyEElqrAsG3j0tTfhrVon jQkL7u2kACsx/huk51IJWALf/d4if/4CwUr2jpmLSADaTD2aljTvlX72M nAUdIyPJauSCzg6ra/zXhK+mFMiBI2n/Xhf60G64XVbegVr0gkF8H5E/l 0HksFpgr9vXCaMdJl6pfCkgTy2AKFaX7S94eTSko2j1Rh3STA8aoz8vvE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="446368969" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="446368969" 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:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10837"; a="722804776" X-IronPort-AV: E=Sophos;i="6.02,159,1688454000"; d="scan'208";a="722804776" Received: from 984fee00a4c6.jf.intel.com ([10.165.58.231]) by orsmga006.jf.intel.com with ESMTP; 19 Sep 2023 02:25: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 6/6] iommu/vt-d: Add domain_alloc_user op Date: Tue, 19 Sep 2023 02:25:23 -0700 Message-Id: <20230919092523.39286-7-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 02:26:36 -0700 (PDT) This adds the domain_alloc_user op implementation. It supports allocating domains to be used as parent under nested translation. Signed-off-by: Yi Liu --- drivers/iommu/intel/iommu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 5db283c17e0d..491bcde1ff96 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4074,6 +4074,25 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) return NULL; } +static struct iommu_domain * +intel_iommu_domain_alloc_user(struct device *dev, u32 flags) +{ + struct iommu_domain *domain; + struct intel_iommu *iommu; + + iommu = device_to_iommu(dev, NULL, NULL); + if (!iommu) + return ERR_PTR(-ENODEV); + + if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap)) + return ERR_PTR(-EOPNOTSUPP); + + domain = iommu_domain_alloc(dev->bus); + if (!domain) + domain = ERR_PTR(-ENOMEM); + return domain; +} + static void intel_iommu_domain_free(struct iommu_domain *domain) { if (domain != &si_domain->domain && domain != &blocking_domain) @@ -4807,6 +4826,7 @@ const struct iommu_ops intel_iommu_ops = { .capable = intel_iommu_capable, .hw_info = intel_iommu_hw_info, .domain_alloc = intel_iommu_domain_alloc, + .domain_alloc_user = intel_iommu_domain_alloc_user, .probe_device = intel_iommu_probe_device, .probe_finalize = intel_iommu_probe_finalize, .release_device = intel_iommu_release_device, -- 2.34.1