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 8BAF9A00C2; Tue, 8 Mar 2022 09:38:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 297304068B; Tue, 8 Mar 2022 09:38:15 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 22F9740041 for ; Tue, 8 Mar 2022 09:38:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646728693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ooWBC9srH5JwtR1GQu4xZVKTJPoDdLQJmKyxSvshU0A=; b=DO5mFSc2t4BQm5wYXqWXSr7dN85kgfSYbeJDcj24k9w+Jxfvtele6v4qt1jwC2umqIvusR diRtWjWRQ/LeabZsA2RhirMU+IotOSsuXRaGernw8xZjfhYMxSjcSuEyXBUJrqqaaJQSME U2HrDwqMhnb8rYZv9vdXbtABaiotaiU= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-554-JzF-kipXMV6RDUdFeiAiUg-1; Tue, 08 Mar 2022 03:38:12 -0500 X-MC-Unique: JzF-kipXMV6RDUdFeiAiUg-1 Received: by mail-lf1-f72.google.com with SMTP id m18-20020a0565120a9200b004439214844dso4620771lfu.9 for ; Tue, 08 Mar 2022 00:38:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ooWBC9srH5JwtR1GQu4xZVKTJPoDdLQJmKyxSvshU0A=; b=E6O7VZwXNXYavB2NUj16mlUjspsnK8e8feUuY92Nffo4fuk6DJKe2NwjIU8b/pR0nw FmEulqu3bG3bhGn/nInGUZDG+BJ3Sn0TiflVHpwJRHIGNGwTamv69KeLYUjEFRmXk5eD eVZlRoK92OkZ5b6+v9vg78r+sIFclzW1iyZZ4qMHk2nUTk7GNP0jwN6SswMqpGxGAc9k 3A4Fb7YFkL7TbMbe8mEgjt2iS4oD0yJEvICdNJFMhWbUt3IRUrkiDLfmR11EPNl+sIlb LNXP+eNMGD5j+tOzEQnqnEZlDSd5epDWC8P27VeIVh2aVchduVnn8iCImNf+RWfUjoOY /u4w== X-Gm-Message-State: AOAM5336rFwwhbvzF6NxNOfI7fBJGNpEJCE9NlRdt29f5L9Q35CJE6D7 v3FmF06xmStpd9p6xI6uT0/MAuh1suHX0kfc0QKjhu5EkrBz1OYPLnneK+2YEgmzts8K510UpUm XYUUssOqvqDF03NLkewo= X-Received: by 2002:a05:6512:39ce:b0:448:36de:d2ea with SMTP id k14-20020a05651239ce00b0044836ded2eamr3605579lfu.499.1646728691022; Tue, 08 Mar 2022 00:38:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDNQwnWVrwKyVqUoPzdsqBYmJeybJjFvPOXqauzPWqm5IUbZm5/gTT7JyncTteXqUfvCrkzg7K6iwxj2r3yAc= X-Received: by 2002:a05:6512:39ce:b0:448:36de:d2ea with SMTP id k14-20020a05651239ce00b0044836ded2eamr3605570lfu.499.1646728690765; Tue, 08 Mar 2022 00:38:10 -0800 (PST) MIME-Version: 1.0 References: <20220307181101.10394-1-david.marchand@redhat.com> <2db1dea9-43e3-9ffa-5dcf-f1bc9d2c7315@redhat.com> In-Reply-To: <2db1dea9-43e3-9ffa-5dcf-f1bc9d2c7315@redhat.com> From: David Marchand Date: Tue, 8 Mar 2022 09:37:59 +0100 Message-ID: Subject: Re: [PATCH] vhost: fix external message handlers To: Maxime Coquelin Cc: dev , Fan Zhang , Chenbo Xia , Christophe Fontaine Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 Tue, Mar 8, 2022 at 9:34 AM Maxime Coquelin wrote: > On 3/7/22 19:11, David Marchand wrote: > > Following a rework, external message handlers were receiving a pointer > > to a vhost_user message (as stated in the API), but lost the ability to > > interact with fds attached to the message. > > Restore the original layout and put a build check and reminders. > > > > Bugzilla ID: 953 > > Fixes: 5e0099dc709e ("vhost: remove payload size limitation") > > > > Signed-off-by: David Marchand > > --- > > This patch is untested, but sending quickly to get feedback from the > > reporter and comments from author and maintainers. > > > > > > --- > > lib/vhost/vhost_user.c | 8 ++++---- > > lib/vhost/vhost_user.h | 7 +++++-- > > 2 files changed, 9 insertions(+), 6 deletions(-) > > > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > > index 723c6890c3..589b950458 100644 > > --- a/lib/vhost/vhost_user.c > > +++ b/lib/vhost/vhost_user.c > > @@ -3023,8 +3023,8 @@ vhost_user_msg_handler(int vid, int fd) > > > > handled = false; > > if (dev->extern_ops.pre_msg_handle) { > > - ret = (*dev->extern_ops.pre_msg_handle)(dev->vid, > > - (void *)&ctx.msg); > > + RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0); > > + ret = (*dev->extern_ops.pre_msg_handle)(dev->vid, &ctx); > > switch (ret) { > > case RTE_VHOST_MSG_RESULT_REPLY: > > send_vhost_reply(dev, fd, &ctx); > > @@ -3069,8 +3069,8 @@ vhost_user_msg_handler(int vid, int fd) > > skip_to_post_handle: > > if (ret != RTE_VHOST_MSG_RESULT_ERR && > > dev->extern_ops.post_msg_handle) { > > - ret = (*dev->extern_ops.post_msg_handle)(dev->vid, > > - (void *)&ctx.msg); > > + RTE_BUILD_BUG_ON(offsetof(struct vhu_msg_context, msg) != 0); > > + ret = (*dev->extern_ops.post_msg_handle)(dev->vid, &ctx); > > switch (ret) { > > case RTE_VHOST_MSG_RESULT_REPLY: > > send_vhost_reply(dev, fd, &ctx); > > diff --git a/lib/vhost/vhost_user.h b/lib/vhost/vhost_user.h > > index be53669f3b..555f89c97a 100644 > > --- a/lib/vhost/vhost_user.h > > +++ b/lib/vhost/vhost_user.h > > @@ -152,10 +152,13 @@ typedef struct VhostUserMsg { > > /* Nothing should be added after the payload */ > > } __rte_packed VhostUserMsg; > > > > -struct vhu_msg_context { > > +/* Note: this structure and VhostUserMsg can't be changed carelessly as > > + * external message handlers rely on them. > > + */ > > +__rte_packed struct vhu_msg_context { > > + VhostUserMsg msg; > > int fds[VHOST_MEMORY_MAX_NREGIONS]; > > int fd_num; > > - VhostUserMsg msg; > > }; > > > > #define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64) > > We should revisit the callbacks prototype when we'll be allowed to break > API, passing the message pointer as void * is definitely not a good > idea. Indeed. > > In the mean time, I agree with your fix: > > Reviewed-by: Maxime Coquelin > > We may also add Reported-by tag when applying. There is an issue with clang, I'll send a v2. -- David Marchand