From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D9AE2A0547; Mon, 27 Sep 2021 06:56:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AB1240686; Mon, 27 Sep 2021 06:56:13 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 5AF284003D for ; Mon, 27 Sep 2021 06:56:11 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10119"; a="285416293" X-IronPort-AV: E=Sophos;i="5.85,325,1624345200"; d="scan'208";a="285416293" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2021 21:56:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,325,1624345200"; d="scan'208";a="477815388" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by fmsmga007.fm.intel.com with ESMTP; 26 Sep 2021 21:56:09 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Sun, 26 Sep 2021 21:56:09 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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.2242.12; Sun, 26 Sep 2021 21:56:08 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Sun, 26 Sep 2021 21:56:08 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.177) 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.2242.12; Sun, 26 Sep 2021 21:56:08 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jmyfT87r9pLzaZWT+/0EVJQjnFaHLImEyCtIgvxa78kr/ojQOX7dJUHTk/4VryAa2sjcBlTFXzPPwBizDpFS02rK8Axz3KmA9zsJAmEXO9rBr7nND3zSoevGKWayOMGxOKT5YM1XzNIdJ4SCBofumogfibKYeERsUdFTJSI6m7ERVB36cdtEq6YYMQa885QqL6MtVtdv6Talis4c4cT1fiAWPZs65gzptXDhanA+bBOaa3pI2fcqCMpO0FDGgQp4THXAxwQsAeEvIXydMDmbZ8QfAFggDQPS9AOdm8EhK4fece83jBmO97ipdV8sdkNWbG7opnbIhK2YrkN7GRf8jA== 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; bh=eBZfj3yc9kB1E/pkRCCnKlyufrb52I/kJzhUIaTYIS8=; b=QnMm9+of1G346plcz+x5kd0AHB0kcQACpZA26YugkuHfVmuKTu0fnPtIbDcXspwC6HzvG9rEJe2f7C0K+ZGMs5z8h33V7ICbW+xkTfYSwBLl9wfKhQnEFvtaYbYwpsgoLlkRQROTqJs7rT06rrS+fhEd5O/KR1vtimc/DR7Lh6bXQLmgC7shLk7/1gsoVSAp2bRlcqE4Biq4FBcos9n3AXLvDZ/iqq+gCKpReRgvj16s8yF+Z0S0m+3i7g8oPjiuHT/Wi5dBnDcbTsohg4P2oIkk3LN3ae6J5i9NijjRW37ZmnZyvbdtKH0siQ26Avfv6A85ldR39XWK0zdryJy4Tg== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eBZfj3yc9kB1E/pkRCCnKlyufrb52I/kJzhUIaTYIS8=; b=Z5LCEwhWls15gIAyfUzFPnQy2Nu0K7wTpTTIGg7xvkBmwDx2ZCJzOlnT7+MDws4Tw2o5Dge3wW9UKT22kreZjSYcN1RIrptxrU9C87/l+hCrVsIGXEYfx/uf3vWpCuFWI1TlFEUI4iTMOyP5T1tZamQGUTmlKKD+aLkkxp5co8Y= Received: from BN9PR11MB5513.namprd11.prod.outlook.com (2603:10b6:408:102::11) by BN6PR11MB1732.namprd11.prod.outlook.com (2603:10b6:404:102::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Mon, 27 Sep 2021 04:55:59 +0000 Received: from BN9PR11MB5513.namprd11.prod.outlook.com ([fe80::99b5:c482:4da6:799e]) by BN9PR11MB5513.namprd11.prod.outlook.com ([fe80::99b5:c482:4da6:799e%7]) with mapi id 15.20.4544.021; Mon, 27 Sep 2021 04:55:59 +0000 From: "Ding, Xuan" To: "Hu, Jiayu" , "dev@dpdk.org" , "Burakov, Anatoly" , "maxime.coquelin@redhat.com" , "Xia, Chenbo" CC: "Jiang, Cheng1" , "Richardson, Bruce" , "Pai G, Sunil" , "Wang, Yinan" , "Yang, YvonneX" Thread-Topic: [PATCH v3 2/2] vhost: enable IOMMU for async vhost Thread-Index: AQHXsfXBGUWjVwHN70ikErKDDc9Wkqu3SUuAgAAI9eA= Date: Mon, 27 Sep 2021 04:55:59 +0000 Message-ID: References: <20210901053044.109901-1-xuan.ding@intel.com> <20210925100358.61995-1-xuan.ding@intel.com> <20210925100358.61995-3-xuan.ding@intel.com> <144cf26ebf434ff4b6f3b0b22ebc41a6@intel.com> In-Reply-To: <144cf26ebf434ff4b6f3b0b22ebc41a6@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 29ed3bba-124d-4cb0-3a0c-08d98173192d x-ms-traffictypediagnostic: BN6PR11MB1732: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 2qa32n5A31EcJoksfmtk8nm6nZUY3sfv8NB//suNOUkxiv5rj0SA1L+ce9iQdSiqKHB0FNe8A/TmOg5lemik8ZgRrDqE9iBKB1ZpG/NqM2rIsUi6pS6uPw7w1bu/tmC2x7u/TnGMbV6AewUjsmdZekiU2wB/PN6STE53lb7jCfUQNqtIz2G7cJ6Cp9/VimtlUN57LF39aM+7Qlqatz0vtrWVqCFAExLXhBuPS9xgbChxFUEvNjYKu4QYHJ+KTyTki9uqMvPY3Bf+vOY2DzBcxZN6TG8dwAMqgCYi8km8EWmR+82GpMCamldOqiHeaVGmq+N1djESZ+UOs/Z+/VLBomxNY7glkxknmPTu4TNfGZ6XatgeISImZNN6En9bkOlxfwTCB05Kg1nmxzTqb7bpHjjXiVurcF8cOmY6n7b48M+VxpBu82ABA95xgpgn+jrUkOTA3QH09tNaN1ZSN/W9VAclBrO7eSMu/r3Iclm6gHjle9r1rBbs0HOuI41MkTF2AYJhZY2uyttKDGkWfaoiljdgmReLvMdvn1H7GWoPdwlm7ekNXZZm/7JpgJDbmAXPXdPTyngE/HA4vQG2sbyGk88dtIFR5bZs4egHCR27MB0IRMlKHpBuVP+sr+ayX2Ji+2SAODO9Xh9Qz/I6EX5hPgKzpUfVuvLSLpuvtTa7PZMTpBfi59IeHHlS9g/LQD+XlhE3JkMp8KyY57DLA9+TvA== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BN9PR11MB5513.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(6636002)(107886003)(316002)(110136005)(54906003)(66946007)(4326008)(5660300002)(2906002)(66476007)(66446008)(64756008)(66556008)(52536014)(8676002)(38070700005)(508600001)(55016002)(122000001)(71200400001)(33656002)(8936002)(86362001)(186003)(6506007)(53546011)(9686003)(38100700002)(76116006)(7696005)(83380400001)(26005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?KX56bLZAFFacaTA0yl0GW0OssvXUbFn9YZjsk18jv7kT0PEJouTA7r1h?= =?Windows-1252?Q?Ygls8UX7194shWuxUv2lZ12bORThszW5OQ4rbMrKj/gg9N//kvPem22F?= =?Windows-1252?Q?9XFOLUwOOS50miA2XT9VO/Bf8y6cMT7T4J6ZLjyE1zRBD/a1Fdksx+A2?= =?Windows-1252?Q?EJdpHiH2Mg9rxlbbEtVFOnusc43UIEFFg4WsDpN5Xow1hJS2/H0PeZ8o?= =?Windows-1252?Q?6x/6pn3pg7q+DPSxJv6DXun2cp8N2+T0/eYpCGV025evq3E1laYWcIyZ?= =?Windows-1252?Q?YXHGNJEhSq2w26+pEXPaCahX2EwzHuPWLGwBwrxbmJNV1lU6hp2JbUVQ?= =?Windows-1252?Q?o5wMHoU1h8SrLfEHvJ96dSwQ9q3D3IrbyMw4Cq2c1KCwtrEO2ac8F1+5?= =?Windows-1252?Q?OMjQkO2ksCJHHe01nYMhDyO3arsQ1aMlDOGCCT1SeBicNDNiP71APe/1?= =?Windows-1252?Q?PhooFU7MFL/Ngu6RZIpjRfSobgPjiEOKHafW1hfwwsEKcfMp2r4Pc05+?= =?Windows-1252?Q?6qs3ou2+Gs9IEfnFRS5k5p5FyOtiMrzGWErH0R27bqIICQfZI+0Yd52q?= =?Windows-1252?Q?gfMKNaa6aOX77eSbXN0Dpks2cW/UKkMoSk7LcgqBZY6OL88CMYkPQHvW?= =?Windows-1252?Q?ijjsTh/UNSCeZnUAmPDe3tCSVjb/vS9Ur/fPyZYfdmoz50tK/4vgSgKB?= =?Windows-1252?Q?D3RJ0mKhrGaeVLLGAOJ2uGLmwtZL+c8gICQLOb/MKSwbNq3tpAHoxcv9?= =?Windows-1252?Q?mhydoQeZXLnCpiDYKUR5taxZfYKnCDWHiIAxeXrmtposlcYIBnF1EjEu?= =?Windows-1252?Q?emi/HIThgADH8EslxkSXJWTDC8nBRPv37DOU3LIJmVGp9F1mPWullShI?= =?Windows-1252?Q?uQgxoPPUAd/Gvu1hkGc1rFzObvgyueIyHObkLdqYvpiC8ap+ck5ak3z+?= =?Windows-1252?Q?e+zql+gIHit84t/v/uYXVvLH/c+ReIVQbhru6OQauWprWt8rt12QGdDu?= =?Windows-1252?Q?RQ7u8umsZHX2Yx37O4YP5/E+0S9CZ9QwP5Z5GhcrD4SlZIzVUevLls4W?= =?Windows-1252?Q?IOA+th+vhS8L3n+RPZI61k/khYv3xGQtRsVqrxYe8uu+286lTkkL2Ne9?= =?Windows-1252?Q?a0cpump3L5Uzvg1mht3OCRe1p3kSPTtDTJtJ9ZQe/ag/zFPjMCXcmJDi?= =?Windows-1252?Q?hVoysH8wjBYDDLt7v4C0cdFbd82OZuzIoUpIT2WAlRpa2DkIjLsg//ai?= =?Windows-1252?Q?hsS9WAmt9rhUxxT+rrOr/Ysd87lu/EGWuqxumMh5x70XZLXyyU26cu9x?= =?Windows-1252?Q?prEfM7kAYxNGN+wuMNeSe4Y6SQRmyF+Xmxa4PhCgwX+9dVV2m5ZYi6Uj?= =?Windows-1252?Q?Oyiyx87do/ZFb/xJfqD6UBHqj9on+bMdjnmzEs52A7M4Bt6bkWycYMD9?= Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5513.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29ed3bba-124d-4cb0-3a0c-08d98173192d X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2021 04:55:59.1370 (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: UKwSxW+ggA5RShId0JWhUErxYORbstYY8yklOhg78d5qRjBapEh5EMpgvTkqeiEWqQqUpPgeLVdbZA9ztoTbaw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1732 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v3 2/2] vhost: enable IOMMU for async vhost X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Jiayu, > -----Original Message----- > From: Hu, Jiayu > Sent: Monday, September 27, 2021 12:18 PM > To: Ding, Xuan ; dev@dpdk.org; Burakov, Anatoly > ; maxime.coquelin@redhat.com; Xia, Chenbo > > Cc: Jiang, Cheng1 ; Richardson, Bruce > ; Pai G, Sunil ; Wang, > Yinan ; Yang, YvonneX > Subject: RE: [PATCH v3 2/2] vhost: enable IOMMU for async vhost >=20 > Hi Xuan, >=20 > > -----Original Message----- > > From: Ding, Xuan > > Sent: Saturday, September 25, 2021 6:04 PM > > To: dev@dpdk.org; Burakov, Anatoly ; > > maxime.coquelin@redhat.com; Xia, Chenbo > > Cc: Hu, Jiayu ; Jiang, Cheng1 ; > > Richardson, Bruce ; Pai G, Sunil > > ; Wang, Yinan ; Yang, > > YvonneX ; Ding, Xuan > > Subject: [PATCH v3 2/2] vhost: enable IOMMU for async vhost > > > > The use of IOMMU has many advantages, such as isolation and address > > translation. This patch extends the capbility of DMA engine to use IOMM= U if > > the DMA engine is bound to vfio. > > > > When set memory table, the guest memory will be mapped into the default > > container of DPDK. > > > > Signed-off-by: Xuan Ding > > --- > > lib/vhost/vhost.h | 4 ++ > > lib/vhost/vhost_user.c | 112 > > ++++++++++++++++++++++++++++++++++++++++- > > 2 files changed, 114 insertions(+), 2 deletions(-) > > > > diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index > > 89a31e4ca8..bc5695e899 100644 > > --- a/lib/vhost/vhost.h > > +++ b/lib/vhost/vhost.h > > @@ -370,6 +370,10 @@ struct virtio_net { > > int16_tbroadcast_rarp; > > uint32_tnr_vring; > > intasync_copy; > > + > > +/* Record the dma map status for each region. */ > > +bool*async_map_status; > > + > > intextbuf; > > intlinearbuf; > > struct vhost_virtqueue*virtqueue[VHOST_MAX_QUEUE_PAIRS * 2]; > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index > > 29a4c9af60..3990e9b057 100644 > > --- a/lib/vhost/vhost_user.c > > +++ b/lib/vhost/vhost_user.c > > @@ -45,6 +45,8 @@ > > #include > > #include > > #include > > +#include > > +#include > > > > #include "iotlb.h" > > #include "vhost.h" > > @@ -141,6 +143,63 @@ get_blk_size(int fd) > > return ret =3D=3D -1 ? (uint64_t)-1 : (uint64_t)stat.st_blksize; } > > > > +static int > > +async_dma_map(struct rte_vhost_mem_region *region, bool > > +*dma_map_success, bool do_map) { > > +uint64_t host_iova; > > +int ret =3D 0; > > + > > +host_iova =3D rte_mem_virt2iova((void *)(uintptr_t)region- > > >host_user_addr); > > +if (do_map) { > > +/* Add mapped region into the default container of DPDK. */ > > +ret =3D > > rte_vfio_container_dma_map(RTE_VFIO_DEFAULT_CONTAINER_FD, > > + region->host_user_addr, > > + host_iova, > > + region->size); > > +*dma_map_success =3D ret =3D=3D 0; > > + > > +if (ret) { > > +/* > > + * DMA device may bind with kernel driver, in this > > case, > > + * we don't need to program IOMMU manually. > > However, if no > > + * device is bound with vfio/uio in DPDK, and vfio > > kernel > > + * module is loaded, the API will still be called and > > return > > + * with ENODEV/ENOSUP. > > + * > > + * DPDK VFIO only returns ENODEV/ENOSUP in very > > similar > > + * situations(VFIO either unsupported, or supported > > + * but no devices found). Either way, no mappings > > could be > > + * performed. We treat it as normal case in async > > path. > > + */ > > +if (rte_errno =3D=3D ENODEV && rte_errno =3D=3D ENOTSUP) { > > +return 0; > > +} else { > > +VHOST_LOG_CONFIG(ERR, "DMA engine map > > failed\n"); > > +return ret; > > +} > > +} > > + > > +} else { > > +/* No need to do vfio unmap if the map failed. */ > > +if (!*dma_map_success) > > +return 0; > > + > > +/* Remove mapped region from the default container of > > DPDK. */ > > +ret =3D > > rte_vfio_container_dma_unmap(RTE_VFIO_DEFAULT_CONTAINER_FD, > > + region->host_user_addr, > > + host_iova, > > + region->size); > > +if (ret) { > > +VHOST_LOG_CONFIG(ERR, "DMA engine unmap > > failed\n"); > > +return ret; > > +} > > +/* Clear the flag once the unmap succeeds. */ > > +*dma_map_success =3D 0; > > +} > > + > > +return ret; > > +} > > + > > static void > > free_mem_region(struct virtio_net *dev) { @@ -153,6 +212,9 @@ > > free_mem_region(struct virtio_net *dev) > > for (i =3D 0; i < dev->mem->nregions; i++) { > > reg =3D &dev->mem->regions[i]; > > if (reg->host_user_addr) { > > +if (dev->async_copy && rte_vfio_is_enabled("vfio")) > > +async_dma_map(reg, &dev- > > >async_map_status[i], false); > > + > > munmap(reg->mmap_addr, reg->mmap_size); > > close(reg->fd); > > } > > @@ -203,6 +265,11 @@ vhost_backend_cleanup(struct virtio_net *dev) > > } > > > > dev->postcopy_listening =3D 0; > > + > > +if (dev->async_map_status) { > > +rte_free(dev->async_map_status); > > +dev->async_map_status =3D NULL; > > +} > > } > > > > static void > > @@ -621,6 +688,17 @@ numa_realloc(struct virtio_net *dev, int index) > > } > > dev->mem =3D mem; > > > > +if (dev->async_copy && rte_vfio_is_enabled("vfio")) { > > +dev->async_map_status =3D rte_zmalloc_socket("async-dma- > > map-status", > > +sizeof(bool) * dev->mem->nregions, > > 0, node); > > +if (!dev->async_map_status) { > > +VHOST_LOG_CONFIG(ERR, > > +"(%d) failed to realloc dma mapping status on > > node\n", > > +dev->vid); > > +return dev; > > +} > > +} > > + > > gp =3D rte_realloc_socket(dev->guest_pages, dev->max_guest_pages * > > sizeof(*gp), > > RTE_CACHE_LINE_SIZE, node); > > if (!gp) { > > @@ -1151,12 +1229,14 @@ vhost_user_postcopy_register(struct virtio_net > > *dev, int main_fd, static int vhost_user_mmap_region(struct virtio_ne= t *dev, > > struct rte_vhost_mem_region *region, > > +uint32_t region_index, > > uint64_t mmap_offset) > > { > > void *mmap_addr; > > uint64_t mmap_size; > > uint64_t alignment; > > int populate; > > +int ret; > > > > /* Check for memory_size + mmap_offset overflow */ > > if (mmap_offset >=3D -region->size) { > > @@ -1210,13 +1290,25 @@ vhost_user_mmap_region(struct virtio_net *dev, > > region->mmap_size =3D mmap_size; > > region->host_user_addr =3D (uint64_t)(uintptr_t)mmap_addr + > > mmap_offset; > > > > -if (dev->async_copy) > > +if (dev->async_copy) { > > if (add_guest_pages(dev, region, alignment) < 0) { > > VHOST_LOG_CONFIG(ERR, > > "adding guest pages to region > > failed.\n"); > > return -1; > > } > > > > +if (rte_vfio_is_enabled("vfio")) { > > +ret =3D async_dma_map(region, &dev- > > >async_map_status[region_index], true); > > +if (ret) { > > +VHOST_LOG_CONFIG(ERR, "Configure > > IOMMU for DMA " > > +"engine failed\n"); > > +rte_free(dev->async_map_status); > > +dev->async_map_status =3D NULL; >=20 > The freed dev->async_map_status is accessed in free_mem_region() later. > You need to free it after calling free_mem_region(). Thanks for the catch! Will fix it in next version. >=20 > > +return -1; > > +} > > +} > > +} > > + > > VHOST_LOG_CONFIG(INFO, > > "guest memory region size: 0x%" PRIx64 "\n" > > "\t guest physical addr: 0x%" PRIx64 "\n" > > @@ -1291,6 +1383,11 @@ vhost_user_set_mem_table(struct virtio_net > > **pdev, struct VhostUserMsg *msg, > > dev->mem =3D NULL; > > } > > > > +if (dev->async_map_status) { > > +rte_free(dev->async_map_status); > > +dev->async_map_status =3D NULL; > > +} >=20 > To handle the gust memory hot-plug case, you need to un-map > iommu tables before program iommu for new memory. But you > seem only free the old dev->async_map_status. Yes, you are right. Will unmap the region in iommu table in hot-plug scenar= io. Regards, Xuan >=20 > Thanks, > Jiayu >=20 > > + > > /* Flush IOTLB cache as previous HVAs are now invalid */ > > if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) > > for (i =3D 0; i < dev->nr_vring; i++) > > @@ -1329,6 +1426,17 @@ vhost_user_set_mem_table(struct virtio_net > > **pdev, struct VhostUserMsg *msg, > > goto free_guest_pages; > > } > > > > +if (dev->async_copy) { > > +dev->async_map_status =3D rte_zmalloc_socket("async-dma- > > map-status", > > +sizeof(bool) * memory->nregions, 0, > > numa_node); > > +if (!dev->async_map_status) { > > +VHOST_LOG_CONFIG(ERR, > > +"(%d) failed to allocate memory for dma > > mapping status\n", > > +dev->vid); > > +goto free_guest_pages; > > +} > > +} > > + > > for (i =3D 0; i < memory->nregions; i++) { > > reg =3D &dev->mem->regions[i]; > > > > @@ -1345,7 +1453,7 @@ vhost_user_set_mem_table(struct virtio_net > > **pdev, struct VhostUserMsg *msg, > > > > mmap_offset =3D memory->regions[i].mmap_offset; > > > > -if (vhost_user_mmap_region(dev, reg, mmap_offset) < 0) { > > +if (vhost_user_mmap_region(dev, reg, i, mmap_offset) < 0) { > > VHOST_LOG_CONFIG(ERR, "Failed to mmap > > region %u\n", i); > > goto free_mem_table; > > } > > -- > > 2.17.1 >=20