Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp3174086rwb; Mon, 7 Aug 2023 09:15:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuBLvVoZ+FPPiDQ5VVJZd40fbbsQnsKJe/vkGJOgeI0FgCRkQDyi2hIj2RCnhemp5ho5kj X-Received: by 2002:a17:903:110c:b0:1bc:210d:6365 with SMTP id n12-20020a170903110c00b001bc210d6365mr10269496plh.2.1691424901538; Mon, 07 Aug 2023 09:15:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691424901; cv=pass; d=google.com; s=arc-20160816; b=eqhgzNl6bYn4PSA0yZtua3OC6aTkaj6i+BswnVvOHaIUqRnFEgIFkyZxokBpScIrmx LGVW3u/+csjV7j44gDGKmZNl08gYo4qOi/X2yi0VR1Il4MKtPdc1WK0Hh50hfA3lLusy a7mjC1orVY7fErdGPX5pczz2ej2c3jQbWo0vviYzeKJ+IHXNVDmXV+PyTjz5OV9WeNDM xQpip4jhO56PeX9uoQ2II03lAhEWzorHKCk6O2rKNRSOu6wGZLCYPQX00aaIpiWBKhQH Do7ARwhuIzGVdbuDu1mteIDCFFYguu9vDyEzgK6eySXI/EPqxK9Iz13McRIerwtgNBuC +j8Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature; bh=g/NzRp193nqAxXn8JZZPzxcjXOA+pW2XqeRynYxntwA=; fh=gzUgUM91ce2+kynShxtjLIcIuKFeZAKr4QGXTWDsYhk=; b=nNDeqGQyQv0Y6DA3gaTLJKo+yCKktWp84rMJislIqJnDGwtgJoWgLCXrYK8MFGt9Gc glMAwxbV3OU80ZP3vujPh6gmpTn/aGr6AokcQVcP1yrY8ZenRhQrTUrobc/EdcdxtDem 1kmpbQGHY7l0s57eG07tzN3oKBUEiYJ2oY10b/ITa6aqSNkuYj8Aih42Rkvt/fI4NRI/ lx+EZBTZtEKPO59RjPVBSOi7gezevCOmUA1PnLTqKdUOfok9Ii2BhRslcpH23q7xnXEl /WByUGJ0WxTHJo3vR1JC8m1SpRQ+qDib8NZyyHMmewvqDFeTOpZ37tDxe0/ymce6U7Ae dnIA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kkVjoLES; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kv16-20020a17090328d000b001ab29e00303si5791909plb.426.2023.08.07.09.14.48; Mon, 07 Aug 2023 09:15:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kkVjoLES; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229760AbjHGPJn (ORCPT + 99 others); Mon, 7 Aug 2023 11:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjHGPJm (ORCPT ); Mon, 7 Aug 2023 11:09:42 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2CE1BF7; Mon, 7 Aug 2023 08:09:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691420960; x=1722956960; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=bsCxadbHACR7pSUdYy4AL9dNViCS2KFxLuz2BdDsYKc=; b=kkVjoLEST1VwmuI+xsKe+2qgxTV0v1akOQuJMsiaW4YaFHv8BbgIggo5 H26cKI+IgowT/vZSkmZ+MkIpyQYMOlX6B2s23ib0lplTSzF2zG1423f49 5MWDC7sWks5VweuC7IzLsEMQs7eGQt4ssfVYpfJg6vsqPClUmzPcD8YMF p7ktG0eiwd4rJQA8kgLeyE10MkCFvXzzHSnB43+XF0f0I/pEYaDTzO2I0 N4HzAHiLwyZMKJYWPWzXZT/vHTNPn07FJy0J7I+zujAuZ6y07KX7JQa79 C97zyVcD8Q98JbslJo1KPQGWW3+cmR3qTJyg4lfD4nBklQSeIqpp4Z9Kz w==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="360654951" X-IronPort-AV: E=Sophos;i="6.01,262,1684825200"; d="scan'208";a="360654951" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2023 08:08:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="760528737" X-IronPort-AV: E=Sophos;i="6.01,262,1684825200"; d="scan'208";a="760528737" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga008.jf.intel.com with ESMTP; 07 Aug 2023 08:08:37 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 7 Aug 2023 08:08:37 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Mon, 7 Aug 2023 08:08:37 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.170) 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.27; Mon, 7 Aug 2023 08:08:36 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KLRS85Gpba1JrDwnF+ZsOIkPvmOpT6rB/O/SRSI+UCEPF9TGLOth297Z1UV9dVn2V+Ns6DlL/z+/D50o96IIfYoNIVKk34iabZdnBy+RbruzxZPZ3Z2POLMCDJ8PPit5mVGOSEZZiIb3vfepixW3HyrrzOQaxlxQSg6Mo3wd+B/80oS0p0Ml55i1DWPSl4Smlv1b5lG+Ch4T5NJ3H8upabatmkd1nzl36e36Yy6HuM3hZgl2QWzoVv+mO7wzPA0oqmP2VwmrEfFFcvA7yXC41Jfhbj15+EGFC+JrQgDif0uy4DTe4Ue8fiAuBUG2SetH6OVrJ0TPY56i5OVXZRcDpg== 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=g/NzRp193nqAxXn8JZZPzxcjXOA+pW2XqeRynYxntwA=; b=XOH3wyMN9Xj8QOxL72wi3iqTtMQM35ox6Bb2fPoMnCo1nMDPscUqnWitbH94Gz8tcqmLkpanWdwK70w2Gwz85DAvLZeUztnmaRDAFJ3T+B8LU2DPRT6ZsWw72Xw/mVXJ9V/7yTjMg+aZuna1MZlwd/OEy8GjcFJY15tgulktpK6x4jg0sBiwipIYA/9S2Dswmv/JP62rsFNT6fnHCFqyGw1YgPzlZ8Q4hmCCJhjYLVhc8kIpuOQGxgmEWZjZPmBxNDYWraAwd87HkxAJ6XMInsPTKV7qDkNck4nfpSrJd/lgazVoCPR7YW7QrpKzKVvTM2koMC0paqS4EyxIch8ujQ== 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 Received: from DS0PR11MB7529.namprd11.prod.outlook.com (2603:10b6:8:141::20) by PH0PR11MB7421.namprd11.prod.outlook.com (2603:10b6:510:281::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.26; Mon, 7 Aug 2023 15:08:30 +0000 Received: from DS0PR11MB7529.namprd11.prod.outlook.com ([fe80::b556:42c4:772f:d47e]) by DS0PR11MB7529.namprd11.prod.outlook.com ([fe80::b556:42c4:772f:d47e%7]) with mapi id 15.20.6652.025; Mon, 7 Aug 2023 15:08:29 +0000 From: "Liu, Yi L" To: "Tian, Kevin" , "joro@8bytes.org" , "alex.williamson@redhat.com" , "jgg@nvidia.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.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" Subject: RE: [PATCH v4 09/12] iommu/vt-d: Add iotlb flush for nested domain Thread-Topic: [PATCH v4 09/12] iommu/vt-d: Add iotlb flush for nested domain Thread-Index: AQHZvh/uqwr3PK6FO0KhG3jtetteiK/WrrGAgAhNwpA= Date: Mon, 7 Aug 2023 15:08:29 +0000 Message-ID: References: <20230724111335.107427-1-yi.l.liu@intel.com> <20230724111335.107427-10-yi.l.liu@intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS0PR11MB7529:EE_|PH0PR11MB7421:EE_ x-ms-office365-filtering-correlation-id: 2588996b-511f-4f28-457d-08db975828a9 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8MX5Fx3hH71Z1nPIRhn4LJ1TakMlXet49Pwp/EANudIysKppyjv1suqgRf/QVoIolGbwJQTzW4EPKFkrQsmF75lnXiUDfelPHum63Vu5XuedcDWWpLjuQDJovjbtheDJPNk3JempRZmmpn/R8seR6MxkHsuFqEBNh/ePncARLrZ3085UvexntBcofXocQ0VNGOdeAY6yJHpPu2/XOomiEZlXSVz8dADZFmLO7ebiGU66+tamUWdzwJ7MWqedCtoFZA6xWU/+LO6lXht5dNAqftVzn4q3HFJj/eI1SQcDxNgietpCkU/aE+AaNgHaKrPJIMmkq8zwQyvIyeE+xK9dQ4NavnzgKEmWx5fMJnQV1VtFinwfKuo2XWExPN8fb7/PbvWwAqyx9RVMOp2fRVAvx93kOaRiqGET2REp8n97PY8gkTXTNkl242tPI1y9l9961uUYOxlv6f1ZrRohHrPyW05fPn3CBEvzBDR83efkUBxQ34SH/lAx35BgxTBatRwI5STQwxj6jdShehS48bDS0wyMUEtHnvnlkhtNk988JmAE6w9jUx5aTSYoOLTfz8836ihXR2rBvWU1Hp9LR4siVs0GYqjzqJ9zYhivXRgK85PiJyEz0Ajonnae6Py8/Un9 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DS0PR11MB7529.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(346002)(376002)(39860400002)(396003)(136003)(186006)(1800799003)(451199021)(7416002)(66946007)(66556008)(64756008)(76116006)(66476007)(4326008)(2906002)(478600001)(66446008)(52536014)(8676002)(8936002)(5660300002)(41300700001)(55016003)(316002)(54906003)(110136005)(86362001)(38070700005)(33656002)(82960400001)(122000001)(71200400001)(7696005)(38100700002)(9686003)(53546011)(6506007)(83380400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?mtlzMzZkiEd8shFKPjZOQPlgF5EXznScqm6RMfIsrknOHAO+fI/Movck2Hy+?= =?us-ascii?Q?GwClwNOnHB+x2UhfeIXFler6lRA9bXy8BPrD81Rl2oSYvbpvG6AvUAOvw8zX?= =?us-ascii?Q?zo4m+12/mbN1HSTrHcWpp5g2Uf4iK0MdehtuWNFoc9Kc0LV2E7ufLs8SsccY?= =?us-ascii?Q?RrIng1epjUK3KjzhbhnqyJBV9icX06p1VI2I12eASDIm8dWgWZKBCSYSR5IX?= =?us-ascii?Q?WsckPwHnDoRrIjHK0joRDgAxZkdhXrv/omsjrGmFxXn8elACOZiDvk0HpxYj?= =?us-ascii?Q?wK026B8ErXZt6E7yGrl2zPDQ81776QnLMnn6xvN4GY3S6PczgwtLMcrPXvxK?= =?us-ascii?Q?Lg6gvgsqcW8yHzNkUZShn6CB/13WfiG9k5Hba/CFojAT2A+PA/s+N8vdBRl0?= =?us-ascii?Q?nBNFFAdGm2tHUlthppViy4wNTHXiICAIHrcJzy3Yopfl2Jlb+HDAOMZqwIMp?= =?us-ascii?Q?3TqfcFXAWNVF8VtkTOx5xOLKwk3E7meHa8Qxq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MLb0jyprBi9eM+U6LRwbvISgHmNb/+1yC1tAqaqfeI7Pt+YyjMnLst4m?= =?us-ascii?Q?+pyqdWxx6pDkOye+/MAz5z0jjq1ZQ1j4kL8QyEm8p3UkltRu5eR1eQ/ae98T?= =?us-ascii?Q?zUyyUa0cpZH2FsqIbEx7+rjoTlu3RZCUoAhwWY6ty78KS49TP3DEJciwTg?= =?us-ascii?Q?=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7529.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2588996b-511f-4f28-457d-08db975828a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Aug 2023 15:08:29.7645 (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: zq7t591YG6hlX8XfMCuHuGhppKSBltg1H9qbrv1wNO4ppzNwEDUaQ5YTbvoNkLXgfpJc/noE/aI2ofjHLLPkVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB7421 X-OriginatorOrg: intel.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 > From: Tian, Kevin > Sent: Wednesday, August 2, 2023 3:47 PM > > Subject: RE: [PATCH v4 09/12] iommu/vt-d: Add iotlb flush for nested doma= in >=20 > > From: Liu, Yi L > > Sent: Monday, July 24, 2023 7:14 PM > > > > +static int intel_nested_cache_invalidate_user(struct iommu_domain > > *domain, > > + void *user_data) > > +{ > > + struct iommu_hwpt_vtd_s1_invalidate_desc *req =3D user_data; > > + struct iommu_hwpt_vtd_s1_invalidate *inv_info =3D user_data; > > + struct dmar_domain *dmar_domain =3D to_dmar_domain(domain); > > + unsigned int entry_size =3D inv_info->entry_size; > > + u64 uptr =3D inv_info->inv_data_uptr; > > + u64 nr_uptr =3D inv_info->entry_nr_uptr; > > + struct device_domain_info *info; > > + u32 entry_nr, index; > > + unsigned long flags; > > + int ret =3D 0; > > + > > + if (get_user(entry_nr, (uint32_t __user *)u64_to_user_ptr(nr_uptr))) > > + return -EFAULT; > > + > > + for (index =3D 0; index < entry_nr; index++) { > > + ret =3D copy_struct_from_user(req, sizeof(*req), > > + u64_to_user_ptr(uptr + index * > > entry_size), > > + entry_size); >=20 > If continuing this direction then the driver should also check minsz etc. > for struct iommu_hwpt_vtd_s1_invalidate and iommu_hwpt_vtd_s1_invalidate_= desc > since they are uAPI and subject to change. Then needs to define size in the uapi data structure, and copy size first a= nd check minsz before going forward. How about the structures for hwpt alloc like struct iommu_hwpt_vtd_s1? Should check minsz for them as well? =20 Regards, Yi Liu