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 F0E1AA0542; Wed, 26 Oct 2022 08:48:33 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D869E40E28; Wed, 26 Oct 2022 08:48:33 +0200 (CEST) Received: from out28-196.mail.aliyun.com (out28-196.mail.aliyun.com [115.124.28.196]) by mails.dpdk.org (Postfix) with ESMTP id 9D97C40A7F for ; Wed, 26 Oct 2022 08:48:28 +0200 (CEST) X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07438201|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_system_inform|0.000321497-7.28197e-06-0.999671; FP=0|0|0|0|0|-1|-1|-1; HT=ay29a033018047187; MF=chenh@yusur.tech; NM=1; PH=DS; RN=4; RT=4; SR=0; TI=SMTPD_---.Pqpg8Rg_1666766904; Received: from 192.168.10.108(mailfrom:chenh@yusur.tech fp:SMTPD_---.Pqpg8Rg_1666766904) by smtp.aliyun-inc.com; Wed, 26 Oct 2022 14:48:25 +0800 Message-ID: <396c2827-62fe-a5db-7a6a-f5be3b730612@yusur.tech> Date: Wed, 26 Oct 2022 14:48:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v3] examples/vdpa: support running in nested virtualization environment To: Maxime Coquelin , dev@dpdk.org Cc: zy@yusur.tech, Chenbo Xia References: <20221025060848.3227766-1-chenh@yusur.tech> <20221025061939.3229676-1-chenh@yusur.tech> <9be2c87a-bbab-1187-93c9-1fc2a42cc7b9@redhat.com> From: Hao Chen In-Reply-To: <9be2c87a-bbab-1187-93c9-1fc2a42cc7b9@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 On 2022/10/26 14:10, Maxime Coquelin wrote: > Hi Hao > > On 10/25/22 08:19, Hao Chen wrote: >> When we run dpdk vdpa in the nested virtual machine vm-L1 and ping >> test in vm-L2, the ping is NG. The reason for troubleshooting is > > NG == not good? Please don't use abbreviations. > Yes, I will pay attention to this later. >> that the virtio net in vm-L2 sends control information to the vring, >> and the qemu back-end device in vm-L1 cannot obtain correct data >> from the vring. This problem is related to the opening of the vIOMMU. >> >> This patch add option '--iommu-support' to use guest vIOMMU to >> protect vhost, then the ping test in vm-L2 is OK. >> This option is required in a nested virtualization environment. > > I'm wondering whether the flag shouldn't just be set by default, as the > feature negotiation will be done between the vDPA driver & the guest > driver anyways? > Yes, It can be set by default rather than as an option. VIRTIO_F_IOMMU_PLATFORM feature will not be negotiated successfully if it is not in a nested virtualization environment. I will simplify the patch. Thanks. > >> Signed-off-by: Hao Chen >> --- >> v3: >> *Modify mail title. >> >> v2: >> *fprintf all string including the eal one. >> *remove exit(1). >> >>   examples/vdpa/main.c | 17 ++++++++++++----- >>   1 file changed, 12 insertions(+), 5 deletions(-) >> >> diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c >> index 4c7e81d7b6..71149461c6 100644 >> --- a/examples/vdpa/main.c >> +++ b/examples/vdpa/main.c >> @@ -43,16 +43,18 @@ static char iface[MAX_PATH_LEN]; >>   static int devcnt; >>   static int interactive; >>   static int client_mode; >> +static int iommu_support; >>     /* display usage */ >>   static void >>   vdpa_usage(const char *prgname) >>   { >> -    printf("Usage: %s [EAL options] -- " >> -                 "    --interactive|-i: run in interactive mode.\n" >> -                 "    --iface : specify the path prefix of the >> socket files, e.g. /tmp/vhost-user-.\n" >> -                 "    --client: register a vhost-user socket as >> client mode.\n", >> -                 prgname); >> +    const char *usage_str = "    --interactive|-i: run in >> interactive mode.\n" >> +                "    --iface : specify the path prefix of the >> socket files, e.g. /tmp/vhost-user-.\n" >> +                "    --client: register a vhost-user socket as >> client mode.\n" >> +                "    --iommu-support: use guest vIOMMU to protect >> vhost.\n"; >> + >> +    fprintf(stderr, "Usage: %s [EAL options] --\n%s", prgname, >> usage_str); >>   } >>     static int >> @@ -63,6 +65,7 @@ parse_args(int argc, char **argv) >>           {"iface", required_argument, NULL, 0}, >>           {"interactive", no_argument, &interactive, 1}, >>           {"client", no_argument, &client_mode, 1}, >> +        {"iommu-support", no_argument, &iommu_support, 1}, >>           {NULL, 0, 0, 0}, >>       }; >>       int opt, idx; >> @@ -220,6 +223,10 @@ start_vdpa(struct vdpa_port *vport) >>               socket_path); >>           return -1; >>       } >> + >> +    if (iommu_support) >> +        vport->flags |= RTE_VHOST_USER_IOMMU_SUPPORT; >> + >>       ret = rte_vhost_driver_register(socket_path, vport->flags); >>       if (ret != 0) >>           rte_exit(EXIT_FAILURE, >