Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1272530rdb; Wed, 20 Sep 2023 04:56:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEq1qWjw5HyQRwZ9gA3p+Qe3LBwWKZC+RwkNdKkkthgOlsWaZc4+N0S4v3IUAtb2P9/TbwW X-Received: by 2002:a17:902:ced2:b0:1bd:a42a:215e with SMTP id d18-20020a170902ced200b001bda42a215emr2485145plg.38.1695211012066; Wed, 20 Sep 2023 04:56:52 -0700 (PDT) Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id q12-20020a170902dacc00b001bf2dc67da3si6401093plx.209.2023.09.20.04.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 04:56:52 -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=ZbAh41I4; arc=fail (signature failed); 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 438058216E6C; Tue, 19 Sep 2023 22:41:50 -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 S231455AbjITFll (ORCPT + 99 others); Wed, 20 Sep 2023 01:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232380AbjITFli (ORCPT ); Wed, 20 Sep 2023 01:41:38 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 475EE8F; Tue, 19 Sep 2023 22:41:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695188492; x=1726724492; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=2w3CXv16jh/HeLZ2b8RizYCEaY8sdsLRpWeMt5tRBxM=; b=ZbAh41I4RHEQu5CiUwWpFC4Rq9ZPUaojGbnAq2G++g0+FiC+8xrqidgA yRoXrttzXplw3xnfwJAvoXkxigvx9eOAPcxbVEdisR1RA/602bUki9Y1a q6d6ARkR3afCZtIldlJwMTVH8HHijrAob3A2rvHOHGh4yXQWb0g7cyAV1 PgA/zDTT+lesH3IQx8Zhe7bgJcAk4WnVWbxeIBeef0ud2jdwMoem8leo0 fKchCHEYD7b1mioDrc6ubCjneMCAe/Syu3PmYMs0OhscY6Rix01NNl8RS QebsKZ8kZsuM2q02HDuuEITqgHLmWMTOzgbqdC9SixG9iFXfN4h8OCYTp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="444224174" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="444224174" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2023 22:41:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10838"; a="920145390" X-IronPort-AV: E=Sophos;i="6.02,161,1688454000"; d="scan'208";a="920145390" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by orsmga005.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 19 Sep 2023 22:41:31 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 19 Sep 2023 22:41:30 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Tue, 19 Sep 2023 22:41:30 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32 via Frontend Transport; Tue, 19 Sep 2023 22:41:30 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.32; Tue, 19 Sep 2023 22:41:29 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F10j0F/gnzqQmE5yAJ8E1gJ3Um6bTKeUMh7JwgbiwvzLFlE0P+5anxwiLwSqM5epHyFTrk8paUZFBpVMGY35xOanE9GosAqtMbE4nQx35ngqrnK7vevhr13Vv52Bfn8z/Rz28Pj/aenkrEVI6f9zPlaUBn5KYvj2xmqdGY/yLzSg7ghH8WBMHW5d25s7ItnnUBN+oJcfZq2O/uEQz7P67uXiXbh2N3Soa5+CjNpbfh3gF0r86t7YaVPbzuHovOG3+7aLuR0YGaLt7UPvWFmIOrAiG2sxEFRqIMZysOfxjFjn+lF8/xyAarza453TJTx6z814f8jdCilPtdlkeSqdcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+pP2dI0ru7CTFHmTlRaccfgPZMzozAFI+dCUPYMEX+8=; b=dTLEjSqGdinI+w26/N3r8iSPG8ilrnuRyxwKw63OJjOBhV90zS3XnLlup9+rnTXApr9Ja10TY5hfpBBPY1d/fZSFfpj/JWczDUQEb8aIyty4/ds1z7CPTsyDzZtTV4WK79l4X4/4PjPIldbYPViPBn63Mk94TQWzYRsVW/b/5Mk6R06VSDtxBwq+uiXYy861KFs8GNDHZuyhmM2RwCZicWlVMSJkT+HKlU1XL7ho5QA5FRjrStV6s1C5Pq8Gdc9oOejmrH03vkGnIWazV/8plWLSQ8dm16FBeDzLz5xd34wJTqmZOUzk7xxeXqcOVKoAdD45tB+eF+CQUsbBYPhlGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB4965.namprd11.prod.outlook.com (2603:10b6:510:34::7) by SA1PR11MB6846.namprd11.prod.outlook.com (2603:10b6:806:2b0::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Wed, 20 Sep 2023 05:41:26 +0000 Received: from PH0PR11MB4965.namprd11.prod.outlook.com ([fe80::a64d:9793:1235:dd90]) by PH0PR11MB4965.namprd11.prod.outlook.com ([fe80::a64d:9793:1235:dd90%7]) with mapi id 15.20.6813.018; Wed, 20 Sep 2023 05:41:26 +0000 Message-ID: <74533792-7dcd-d745-dc07-671260bc9e22@intel.com> Date: Wed, 20 Sep 2023 13:41:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH 6/6] iommu/vt-d: Add domain_alloc_user op To: Yi Liu , "joro@8bytes.org" , "alex.williamson@redhat.com" , "jgg@nvidia.com" , "Tian, Kevin" , "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.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" , "Duan, Zhenzhong" , "Martins, Joao" References: <20230919092523.39286-1-yi.l.liu@intel.com> <20230919092523.39286-7-yi.l.liu@intel.com> Content-Language: en-US From: "Yang, Weijiang" In-Reply-To: <20230919092523.39286-7-yi.l.liu@intel.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SI1PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:1f6::14) To PH0PR11MB4965.namprd11.prod.outlook.com (2603:10b6:510:34::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB4965:EE_|SA1PR11MB6846:EE_ X-MS-Office365-Filtering-Correlation-Id: 51dc0fcd-be76-4bd8-7fce-08dbb99c3b11 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +Dud2Tb5bnIk5JBCdCmFEwf11rJ3VPCnASI8KvrDLbHGQby7Bu/BsUnLpGd7WjlgStURNclWN4URMg34AJTTdZRi+Q1b6BEYsxCIAsK4n/0cYp4dN5YqpxlUeXeFC1NwZnsDdo6B7IPo1vj9ER9ytYemqw82Le6x/rJX8hfRwkK2ucBPLEifrtUCxLqWe5NP1cPucdyQwWPGc3EXUYC9NRYTowBbnSy4CvK2vRA9JmXyzTGOEGoqVUj81hI1USoDXs1+2T0EKau6MGZcgPpBD6plwoNmF9xBBhr923iVT9AI6rwSZcvh5bPBd0I7+edLdW64Nti80lke/D6gLk+aNiRnt23KX+kCmQhOTxSJXu2Mww0siXLyEgvxwvI1HJdZGGPpQDZ0g9/NzDLguZUlpeRkOlGYYOT2YP2cRZm2tC4EEChg4JTu5wxlAlfes98EoNwMOs+/QCMo0iTrS2zREnQIZfAAiJL+PyMuvWhqLX2D2uOnPbx58WX50B5Fg8jgAPtM7/i+q+wF1U5u5Bn5nc+RyWotTIzYplS1q32b8oK2qfEbl9f586s0bIeSqDSbfe5L0kLLXttTir4Sey1J+TFEw1tvkPiXNZ39JwnCkRnBeeLyhpvhi6blDU5om16zGSLOjUrqIxnzLyo3ZxRPlQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB4965.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(376002)(136003)(346002)(39860400002)(396003)(1800799009)(186009)(451199024)(478600001)(6666004)(53546011)(6486002)(6506007)(6512007)(26005)(2616005)(2906002)(4326008)(66476007)(66556008)(66946007)(54906003)(316002)(110136005)(8676002)(5660300002)(41300700001)(8936002)(7416002)(82960400001)(31696002)(36756003)(86362001)(38100700002)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?N29wS2ZyUHBDN1hBbVBONzYwdmVMSEJqc3pCckVqcVBIZGM0QUZrUG1hOUQ1?= =?utf-8?B?VDhRMEhQTXlnYkU2anQxSDQ3Ymx2clliUXlCZDlFNisyQXErVEJjeU02WWVK?= =?utf-8?B?ZU96ekNnT3pWN0ZDVHNrYjRwWFlkRTZkT2RKd1pnVS90am1QWDJ3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WJmaTRvakxPdmNqMTBFOHVhcUZtR29MbHgzK0hG?= =?utf-8?B?WHhlT1NHUElyelNqNnBrRnBibmMxNkFsRmxCOTBlNjdpQ1hFbU9za0VBS3BM?= =?utf-8?B?RU02YzdEOFA0N2NPOEEyZ25NQUVGdjh2R1hSNm02WU5TaGdwMDlBbWZtWXFr?= =?utf-8?B?Z0xFdXVOQnR0ejlKUG84d1U0YnpkcWRpWGVsVXo3emk4UVg0YjdRZWRpSENt?= =?utf-8?B?bFE9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 51dc0fcd-be76-4bd8-7fce-08dbb99c3b11 X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB4965.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 05:41:26.3146 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R8tFE/Jm0aESYOK+l+BnxRdfGitbLUstImfGq0NJIPVlzo4iIjnE+1R5wy3cwnwBT6dCDn1MxlLUMGo9Kgybgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR11MB6846 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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:41:50 -0700 (PDT) On 9/19/2023 5:25 PM, Yi Liu wrote: > 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); The outer caller has checked (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) before it comes here. If this callback is dedicated for nested domain allocation, then you may omit the condition here.