Hi Viresh,
On 24 Jul 2025, at 11:58, Viresh Kumar viresh.kumar@linaro.org wrote:
On 24-07-25, 06:53, Bertrand Marquis wrote:
We need to check for operations like feature or config space read as I do not see how an error can be signaled back to the driver when it is reading a register/
For them we we can simply return 0, as there is no way to send an error.
If this could be handled in the transport and we could allow the bus to return an error that would be awesome as this part of the spec is making by FF-A bus spec very complex by asking the bus to generate dummy messages for those cases.
We need to discuss this during next HVAC meeting as this would give an opportunity for the bus to delegate some (maybe most) of the error handling to the transport which would help simplifying bus implementations.
We will need to check that this is mentioned in the spec. Would be a good idea anyway to have a build time assert checking that this value is not smaller than that as a lot of the code is working on this assumption without checking it.
what about this then ?
Yes this is what i had in mind.
I would not put those in the header though as this is something taken as an assumption by the implementation but if the header is used by a different implementation it might handle things differently.
So i would suggest to move this into the source code inside the functions making this assumption.
Cheers Bertrand
diff --git a/include/uapi/linux/virtio_msg.h b/include/uapi/linux/virtio_msg.h index 823bfbd6ecf1..58fca6799e3c 100644 --- a/include/uapi/linux/virtio_msg.h +++ b/include/uapi/linux/virtio_msg.h @@ -171,6 +171,27 @@ struct virtio_msg { __u8 payload[]; } __attribute__((packed));
+static_assert(sizeof(struct virtio_msg) + sizeof(struct get_device_info_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_features) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_features_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_features) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_config) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_config_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_config) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_config_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_device_status_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_device_status) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_device_status_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_vqueue) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_vqueue_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct set_vqueue) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct reset_vqueue) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_shm) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct get_shm_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct event_config) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct event_avail) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct event_used) < VIRTIO_MSG_MIN_SIZE);
static inline void *virtio_msg_payload(struct virtio_msg *vmsg) { return &vmsg->payload; @@ -218,4 +239,10 @@ struct bus_status { __u8 state; } __attribute__((packed));
+static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_get_devices) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_get_devices_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_event_device) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_ping) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_ping_resp) < VIRTIO_MSG_MIN_SIZE); +static_assert(sizeof(struct virtio_msg) + sizeof(struct bus_status) < VIRTIO_MSG_MIN_SIZE); #endif /* _LINUX_VIRTIO_MSG_H */
-- viresh _______________________________________________ Virtio-msg mailing list -- virtio-msg@lists.linaro.org To unsubscribe send an email to virtio-msg-leave@lists.linaro.org
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.