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 7AED2A00C2; Tue, 8 Mar 2022 15:48:02 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0FF184068B; Tue, 8 Mar 2022 15:48:01 +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 F12F040141 for ; Tue, 8 Mar 2022 15:47:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646750879; 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=zPFNL7qFhWZ349wHDhMmYrFXfUDFCVxWq+hxH3deyZw=; b=IxM8QkTFHKA35HuGgDYos1SfDoTxzjtg2jU7BwGVUxWxwaRbG4eKQQv3U8ZjEiTiBnQtms Q7eC5rz0RYJ3HB/yaeVAzSWzdRcomdry7cHfWTaK+GrdM7fpYh7uD420uifOz7yt7eT3JZ uMosivWeVBbWtAj+V5w02q7J8Dk1brs= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-jWMnQh58Ot2BnaE19fzfRA-1; Tue, 08 Mar 2022 09:47:58 -0500 X-MC-Unique: jWMnQh58Ot2BnaE19fzfRA-1 Received: by mail-oi1-f198.google.com with SMTP id j3-20020acaeb03000000b002d9a8533ee2so4826117oih.18 for ; Tue, 08 Mar 2022 06:47:58 -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=zPFNL7qFhWZ349wHDhMmYrFXfUDFCVxWq+hxH3deyZw=; b=34VZ+fOeqUztxkk9W2qPXiiQ9iwwOEvHdMKB1DMO8tCbXfTmmqNOeu/OtS95LzGufg ycaMUd/U3jezEW/P9f/E4TxnmEcDpCpKfw9RBe+ipyxF3bsWoCtGTtcF4zP2dptIQkoV GcbwhhjQIijPSFe4pxiXuMuHPnsypgQ3p6EbVBGxO2180Zs/lrxsCcgmypZyBdE3CBoa mEPa97OHxlC+7vly0iDlS7sWKt8dvbmjH6mRkfAMf6F9dXafS8/CCdTBf7W+YHxUDS4I cRenwnlVKlRu+QR56HgXNdYReNWLs5NpXFUyllFU2G/1FbHS7xeOiScp7CAeoOhnqJcQ wmqg== X-Gm-Message-State: AOAM532XJzy8PoZJBorAdtSomMFiufjJ/shBkQVvM+Otj+cXdASz0oEw H7cU0aeInc/WcMNel0JypQEhbDSJDInh+4JIo1T50DbNSThZrFuECMNn3SLaYclzSaO94Ral8tn /f4SNToEpO/XdOki7xZI= X-Received: by 2002:a05:6870:468b:b0:da:6cd7:d7c7 with SMTP id a11-20020a056870468b00b000da6cd7d7c7mr2539306oap.282.1646750877435; Tue, 08 Mar 2022 06:47:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwetOc68gZ7Hr+Lrpml5HCXKIB4wF3qkeQgVpFdT55rP+Dem4nHyl1TdFX2W7r6fxkAcTAFqVPigvlohJx8dFg= X-Received: by 2002:a05:6870:468b:b0:da:6cd7:d7c7 with SMTP id a11-20020a056870468b00b000da6cd7d7c7mr2539292oap.282.1646750877172; Tue, 08 Mar 2022 06:47:57 -0800 (PST) MIME-Version: 1.0 References: <20220307181101.10394-1-david.marchand@redhat.com> <20220308094422.25685-1-david.marchand@redhat.com> In-Reply-To: <20220308094422.25685-1-david.marchand@redhat.com> From: Christophe Fontaine Date: Tue, 8 Mar 2022 15:47:46 +0100 Message-ID: Subject: Re: [PATCH v2] vhost: fix external message handlers To: David Marchand Cc: dev@dpdk.org, roy.fan.zhang@intel.com, Maxime Coquelin , Chenbo Xia Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=cfontain@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 10:44 AM 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") > > Reported-by: Fan Zhang > Signed-off-by: David Marchand > --- > Changes since v1: > - fixed build with clang, > > --- > 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..c946cc2ef4 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. > + */ > +struct __rte_packed 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) > -- > 2.23.0 > Sorry to have missed that test with virtio-crypto ; I'll create another thread to talk about the VhostUserMsg extension. Reviewed-by: Christophe Fontaine Thanks, Christophe