* [PATCH] vhost: fix external message handlers
@ 2022-03-07 18:11 David Marchand
2022-03-08 8:34 ` Maxime Coquelin
2022-03-08 9:44 ` [PATCH v2] " David Marchand
0 siblings, 2 replies; 9+ messages in thread
From: David Marchand @ 2022-03-07 18:11 UTC (permalink / raw)
To: dev, roy.fan.zhang, Maxime Coquelin, Chenbo Xia, Christophe Fontaine
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 <david.marchand@redhat.com>
---
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)
--
2.23.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost: fix external message handlers
2022-03-07 18:11 [PATCH] vhost: fix external message handlers David Marchand
@ 2022-03-08 8:34 ` Maxime Coquelin
2022-03-08 8:37 ` David Marchand
2022-03-08 9:44 ` [PATCH v2] " David Marchand
1 sibling, 1 reply; 9+ messages in thread
From: Maxime Coquelin @ 2022-03-08 8:34 UTC (permalink / raw)
To: David Marchand, dev, roy.fan.zhang, Chenbo Xia, Christophe Fontaine
Hi,
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 <david.marchand@redhat.com>
> ---
> 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.
In the mean time, I agree with your fix:
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
We may also add Reported-by tag when applying.
Thanks!
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost: fix external message handlers
2022-03-08 8:34 ` Maxime Coquelin
@ 2022-03-08 8:37 ` David Marchand
2022-03-08 8:39 ` Maxime Coquelin
0 siblings, 1 reply; 9+ messages in thread
From: David Marchand @ 2022-03-08 8:37 UTC (permalink / raw)
To: Maxime Coquelin; +Cc: dev, Fan Zhang, Chenbo Xia, Christophe Fontaine
On Tue, Mar 8, 2022 at 9:34 AM Maxime Coquelin
<maxime.coquelin@redhat.com> 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 <david.marchand@redhat.com>
> > ---
> > 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 <maxime.coquelin@redhat.com>
>
> We may also add Reported-by tag when applying.
There is an issue with clang, I'll send a v2.
--
David Marchand
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] vhost: fix external message handlers
2022-03-08 8:37 ` David Marchand
@ 2022-03-08 8:39 ` Maxime Coquelin
0 siblings, 0 replies; 9+ messages in thread
From: Maxime Coquelin @ 2022-03-08 8:39 UTC (permalink / raw)
To: David Marchand; +Cc: dev, Fan Zhang, Chenbo Xia, Christophe Fontaine
On 3/8/22 09:37, David Marchand wrote:
> On Tue, Mar 8, 2022 at 9:34 AM Maxime Coquelin
> <maxime.coquelin@redhat.com> 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 <david.marchand@redhat.com>
>>> ---
>>> 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 <maxime.coquelin@redhat.com>
>>
>> We may also add Reported-by tag when applying.
>
> There is an issue with clang, I'll send a v2.
>
Ok.
Fan, can you have a try and confirm it fixes the issue on your side?
Thanks,
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] vhost: fix external message handlers
2022-03-07 18:11 [PATCH] vhost: fix external message handlers David Marchand
2022-03-08 8:34 ` Maxime Coquelin
@ 2022-03-08 9:44 ` David Marchand
2022-03-08 10:44 ` Maxime Coquelin
` (2 more replies)
1 sibling, 3 replies; 9+ messages in thread
From: David Marchand @ 2022-03-08 9:44 UTC (permalink / raw)
To: dev, roy.fan.zhang, Maxime Coquelin, Chenbo Xia, Christophe Fontaine
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 <roy.fan.zhang@intel.com>
Signed-off-by: David Marchand <david.marchand@redhat.com>
---
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] vhost: fix external message handlers
2022-03-08 9:44 ` [PATCH v2] " David Marchand
@ 2022-03-08 10:44 ` Maxime Coquelin
2022-03-08 14:04 ` Poczatek, Jakub
2022-03-08 14:47 ` Christophe Fontaine
2022-03-08 15:06 ` David Marchand
2 siblings, 1 reply; 9+ messages in thread
From: Maxime Coquelin @ 2022-03-08 10:44 UTC (permalink / raw)
To: David Marchand, dev, roy.fan.zhang, Chenbo Xia, Christophe Fontaine
On 3/8/22 10:44, 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 <roy.fan.zhang@intel.com>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> 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)
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Thanks,
Maxime
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH v2] vhost: fix external message handlers
2022-03-08 10:44 ` Maxime Coquelin
@ 2022-03-08 14:04 ` Poczatek, Jakub
0 siblings, 0 replies; 9+ messages in thread
From: Poczatek, Jakub @ 2022-03-08 14:04 UTC (permalink / raw)
To: Maxime Coquelin, David Marchand, dev, Zhang, Roy Fan, Xia,
Chenbo, Christophe Fontaine
Hi everyone,
> 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 <roy.fan.zhang@intel.com>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v1:
> - fixed build with clang,
>
> ---
Tested-by: Jakub Poczatek <Jakub.poczatek@intel.com>
Acked-by: Jakub Poczatek <Jakub.poczatek@intel.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] vhost: fix external message handlers
2022-03-08 9:44 ` [PATCH v2] " David Marchand
2022-03-08 10:44 ` Maxime Coquelin
@ 2022-03-08 14:47 ` Christophe Fontaine
2022-03-08 15:06 ` David Marchand
2 siblings, 0 replies; 9+ messages in thread
From: Christophe Fontaine @ 2022-03-08 14:47 UTC (permalink / raw)
To: David Marchand; +Cc: dev, roy.fan.zhang, Maxime Coquelin, Chenbo Xia
On Tue, Mar 8, 2022 at 10:44 AM David Marchand
<david.marchand@redhat.com> 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 <roy.fan.zhang@intel.com>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> 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 <cfontain@redhat.com>
Thanks,
Christophe
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] vhost: fix external message handlers
2022-03-08 9:44 ` [PATCH v2] " David Marchand
2022-03-08 10:44 ` Maxime Coquelin
2022-03-08 14:47 ` Christophe Fontaine
@ 2022-03-08 15:06 ` David Marchand
2 siblings, 0 replies; 9+ messages in thread
From: David Marchand @ 2022-03-08 15:06 UTC (permalink / raw)
To: dev, Fan Zhang, Maxime Coquelin, Chenbo Xia, Christophe Fontaine
On Tue, Mar 8, 2022 at 10:45 AM David Marchand
<david.marchand@redhat.com> 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 <roy.fan.zhang@intel.com>
> Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Tested-by: Jakub Poczatek <jakub.poczatek@intel.com>
Acked-by: Jakub Poczatek <jakub.poczatek@intel.com>
Reviewed-by: Christophe Fontaine <cfontain@redhat.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-03-08 15:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-07 18:11 [PATCH] vhost: fix external message handlers David Marchand
2022-03-08 8:34 ` Maxime Coquelin
2022-03-08 8:37 ` David Marchand
2022-03-08 8:39 ` Maxime Coquelin
2022-03-08 9:44 ` [PATCH v2] " David Marchand
2022-03-08 10:44 ` Maxime Coquelin
2022-03-08 14:04 ` Poczatek, Jakub
2022-03-08 14:47 ` Christophe Fontaine
2022-03-08 15:06 ` David Marchand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).