* [PATCH] virtio_rpmsg: fix config space alignment
@ 2026-11-01 13:54 Francesco Valla
2026-11-06 17:37 ` Mathieu Poirier
0 siblings, 1 reply; 5+ messages in thread
From: Francesco Valla @ 2026-11-01 13:54 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Tanmay Shah, Arnaud POULIQUEN
Cc: linux-remoteproc, linux-kernel, Francesco Valla
The comment for virtio_rpmsg_config says that this structure is
naturally aligned to 32 bits, and this is desirable by some
architectures that don't get along with unaligned accesses.
The content of the structure itself however isn't aligned, and the
__packed attribute prevent the compiler to add this alignment.
Fix this by adding a padding byte.
Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space")
Signed-off-by: Francesco Valla <francesco@valla.it>
---
Hello,
unfortunately I missed this when the original patch set was sent, but I
think it's worth fixing (or at least discussing) this now before it
enters a stable kernel.
The same support in open-amp has already been merged [1], but maybe it
can be fixed before the next release there too?
Another, lower-impact solution would be to fix the comment, but that can
then led to issues on architectures that does not support unaligned
accesses (e.g.: AMR Cortex-M0).
Thank you
Francesco
[1] https://github.com/OpenAMP/open-amp/commit/744376f566c3ec7e06a7d093d785295b78aa486f
---
include/linux/rpmsg/virtio_rpmsg.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
index 0872cbca4593..d24fedb63023 100644
--- a/include/linux/rpmsg/virtio_rpmsg.h
+++ b/include/linux/rpmsg/virtio_rpmsg.h
@@ -23,6 +23,7 @@
*
* @version: version of this structure, currently %RPMSG_VDEV_CONFIG_V1.
* @size: size of this structure in bytes.
+ * @reserved: padding, reserved for future usage.
* @txbuf_size: Tx buf size from remote's view. For Linux this is rx buf size.
* @rxbuf_size: Rx buf size from remote's view. For Linux this is tx buf size.
*
@@ -33,6 +34,7 @@
struct virtio_rpmsg_config {
u8 version;
__virtio16 size;
+ u8 reserved;
/* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
__virtio32 txbuf_size;
__virtio32 rxbuf_size;
---
base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a
change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d
Best regards,
--
Francesco Valla <francesco@valla.it>
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] virtio_rpmsg: fix config space alignment 2026-11-01 13:54 [PATCH] virtio_rpmsg: fix config space alignment Francesco Valla @ 2026-11-06 17:37 ` Mathieu Poirier 2026-11-19 15:29 ` Mathieu Poirier 0 siblings, 1 reply; 5+ messages in thread From: Mathieu Poirier @ 2026-11-06 17:37 UTC (permalink / raw) To: Francesco Valla Cc: Bjorn Andersson, Tanmay Shah, Arnaud POULIQUEN, linux-remoteproc, linux-kernel On Sun, Nov 01, 2026 at 02:54:03PM +0100, Francesco Valla wrote: > The comment for virtio_rpmsg_config says that this structure is > naturally aligned to 32 bits, and this is desirable by some > architectures that don't get along with unaligned accesses. > The content of the structure itself however isn't aligned, and the > __packed attribute prevent the compiler to add this alignment. > > Fix this by adding a padding byte. > > Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space") > Signed-off-by: Francesco Valla <francesco@valla.it> > --- > Hello, > > unfortunately I missed this when the original patch set was sent, but I > think it's worth fixing (or at least discussing) this now before it > enters a stable kernel. > > The same support in open-amp has already been merged [1], but maybe it > can be fixed before the next release there too? > > Another, lower-impact solution would be to fix the comment, but that can > then led to issues on architectures that does not support unaligned > accesses (e.g.: AMR Cortex-M0). > Thanks for bringing this to my attention. I agree with this patch. I will give Arnaud a couple of weeks to reply to this email though. > Thank you > > Francesco > > [1] https://github.com/OpenAMP/open-amp/commit/744376f566c3ec7e06a7d093d785295b78aa486f > --- > include/linux/rpmsg/virtio_rpmsg.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h > index 0872cbca4593..d24fedb63023 100644 > --- a/include/linux/rpmsg/virtio_rpmsg.h > +++ b/include/linux/rpmsg/virtio_rpmsg.h > @@ -23,6 +23,7 @@ > * > * @version: version of this structure, currently %RPMSG_VDEV_CONFIG_V1. > * @size: size of this structure in bytes. > + * @reserved: padding, reserved for future usage. > * @txbuf_size: Tx buf size from remote's view. For Linux this is rx buf size. > * @rxbuf_size: Rx buf size from remote's view. For Linux this is tx buf size. > * > @@ -33,6 +34,7 @@ > struct virtio_rpmsg_config { > u8 version; > __virtio16 size; > + u8 reserved; > /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */ > __virtio32 txbuf_size; > __virtio32 rxbuf_size; > > --- > base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a > change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d > > Best regards, > -- > Francesco Valla <francesco@valla.it> > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_rpmsg: fix config space alignment 2026-11-06 17:37 ` Mathieu Poirier @ 2026-11-19 15:29 ` Mathieu Poirier 2026-11-20 17:50 ` Arnaud POULIQUEN 0 siblings, 1 reply; 5+ messages in thread From: Mathieu Poirier @ 2026-11-19 15:29 UTC (permalink / raw) To: Francesco Valla, openamp-rp Cc: Bjorn Andersson, Tanmay Shah, Arnaud POULIQUEN, linux-remoteproc, linux-kernel [Adding openAMP mailing list] Heads up OpenAMP people, I will merge this patch in a week. Thanks, Mathieu On Fri, Nov 06, 2026 at 11:37:24AM -0600, Mathieu Poirier wrote: > On Sun, Nov 01, 2026 at 02:54:03PM +0100, Francesco Valla wrote: > > The comment for virtio_rpmsg_config says that this structure is > > naturally aligned to 32 bits, and this is desirable by some > > architectures that don't get along with unaligned accesses. > > The content of the structure itself however isn't aligned, and the > > __packed attribute prevent the compiler to add this alignment. > > > > Fix this by adding a padding byte. > > > > Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space") > > Signed-off-by: Francesco Valla <francesco@valla.it> > > --- > > Hello, > > > > unfortunately I missed this when the original patch set was sent, but I > > think it's worth fixing (or at least discussing) this now before it > > enters a stable kernel. > > > > The same support in open-amp has already been merged [1], but maybe it > > can be fixed before the next release there too? > > > > Another, lower-impact solution would be to fix the comment, but that can > > then led to issues on architectures that does not support unaligned > > accesses (e.g.: AMR Cortex-M0). > > > > Thanks for bringing this to my attention. I agree with this patch. I will give > Arnaud a couple of weeks to reply to this email though. > > > Thank you > > > > Francesco > > > > [1] https://github.com/OpenAMP/open-amp/commit/744376f566c3ec7e06a7d093d785295b78aa486f > > --- > > include/linux/rpmsg/virtio_rpmsg.h | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h > > index 0872cbca4593..d24fedb63023 100644 > > --- a/include/linux/rpmsg/virtio_rpmsg.h > > +++ b/include/linux/rpmsg/virtio_rpmsg.h > > @@ -23,6 +23,7 @@ > > * > > * @version: version of this structure, currently %RPMSG_VDEV_CONFIG_V1. > > * @size: size of this structure in bytes. > > + * @reserved: padding, reserved for future usage. > > * @txbuf_size: Tx buf size from remote's view. For Linux this is rx buf size. > > * @rxbuf_size: Rx buf size from remote's view. For Linux this is tx buf size. > > * > > @@ -33,6 +34,7 @@ > > struct virtio_rpmsg_config { > > u8 version; > > __virtio16 size; > > + u8 reserved; > > /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */ > > __virtio32 txbuf_size; > > __virtio32 rxbuf_size; > > > > --- > > base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a > > change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d > > > > Best regards, > > -- > > Francesco Valla <francesco@valla.it> > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_rpmsg: fix config space alignment 2026-11-19 15:29 ` Mathieu Poirier @ 2026-11-20 17:50 ` Arnaud POULIQUEN 2026-11-20 22:29 ` Francesco Valla 0 siblings, 1 reply; 5+ messages in thread From: Arnaud POULIQUEN @ 2026-11-20 17:50 UTC (permalink / raw) To: Mathieu Poirier, Francesco Valla, openamp-rp Cc: Bjorn Andersson, Tanmay Shah, linux-remoteproc, linux-kernel Hello, Sorry it goes out of my radar. On 11/19/26 16:29, Mathieu Poirier wrote: > [Adding openAMP mailing list] > > Heads up OpenAMP people, I will merge this patch in a week. > > Thanks, > Mathieu > > On Fri, Nov 06, 2026 at 11:37:24AM -0600, Mathieu Poirier wrote: >> On Sun, Nov 01, 2026 at 02:54:03PM +0100, Francesco Valla wrote: >>> The comment for virtio_rpmsg_config says that this structure is >>> naturally aligned to 32 bits, and this is desirable by some >>> architectures that don't get along with unaligned accesses. >>> The content of the structure itself however isn't aligned, and the >>> __packed attribute prevent the compiler to add this alignment. >>> >>> Fix this by adding a padding byte. >>> >>> Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space") >>> Signed-off-by: Francesco Valla <francesco@valla.it> >>> --- >>> Hello, >>> >>> unfortunately I missed this when the original patch set was sent, but I >>> think it's worth fixing (or at least discussing) this now before it >>> enters a stable kernel. >>> >>> The same support in open-amp has already been merged [1], but maybe it >>> can be fixed before the next release there too? >>> >>> Another, lower-impact solution would be to fix the comment, but that can >>> then led to issues on architectures that does not support unaligned >>> accesses (e.g.: AMR Cortex-M0). >>> >> >> Thanks for bringing this to my attention. I agree with this patch. I will give >> Arnaud a couple of weeks to reply to this email though. >> >>> Thank you >>> >>> Francesco >>> >>> [1] https://github.com/OpenAMP/open-amp/commit/744376f566c3ec7e06a7d093d785295b78aa486f >>> --- >>> include/linux/rpmsg/virtio_rpmsg.h | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h >>> index 0872cbca4593..d24fedb63023 100644 >>> --- a/include/linux/rpmsg/virtio_rpmsg.h >>> +++ b/include/linux/rpmsg/virtio_rpmsg.h >>> @@ -23,6 +23,7 @@ >>> * >>> * @version: version of this structure, currently %RPMSG_VDEV_CONFIG_V1. >>> * @size: size of this structure in bytes. >>> + * @reserved: padding, reserved for future usage. >>> * @txbuf_size: Tx buf size from remote's view. For Linux this is rx buf size. >>> * @rxbuf_size: Rx buf size from remote's view. For Linux this is tx buf size. >>> * >>> @@ -33,6 +34,7 @@ >>> struct virtio_rpmsg_config { >>> u8 version; >>> __virtio16 size; >>> + u8 reserved; >>> /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */ >>> __virtio32 txbuf_size; >>> __virtio32 rxbuf_size; What about using a u16 for the version instead? Even if we never use the MSB of the field, it seems cleaner to me than adding a reserved field. Indeed, we can consider the config space header as containing the version and the size. The rest is version-dependent, including the reserved part. Regards, Arnaud >>> >>> --- >>> base-commit: cbbddb6b08cc9900a87cccaa9b22bbe06aa4f50a >>> change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d >>> >>> Best regards, >>> -- >>> Francesco Valla <francesco@valla.it> >>> ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] virtio_rpmsg: fix config space alignment 2026-11-20 17:50 ` Arnaud POULIQUEN @ 2026-11-20 22:29 ` Francesco Valla 0 siblings, 0 replies; 5+ messages in thread From: Francesco Valla @ 2026-11-20 22:29 UTC (permalink / raw) To: Arnaud POULIQUEN Cc: Mathieu Poirier, openamp-rp, Bjorn Andersson, Tanmay Shah, linux-remoteproc, linux-kernel Hello Arnaud, On Fri, Nov 20, 2026 at 06:50:47PM +0100, Arnaud POULIQUEN wrote: > Hello, > > Sorry it goes out of my radar. > > On 11/19/26 16:29, Mathieu Poirier wrote: > > [Adding openAMP mailing list] > > > > Heads up OpenAMP people, I will merge this patch in a week. > > > > Thanks, > > Mathieu > > > > On Fri, Nov 06, 2026 at 11:37:24AM -0600, Mathieu Poirier wrote: > > > On Sun, Nov 01, 2026 at 02:54:03PM +0100, Francesco Valla wrote: > > > > The comment for virtio_rpmsg_config says that this structure is > > > > naturally aligned to 32 bits, and this is desirable by some > > > > architectures that don't get along with unaligned accesses. > > > > The content of the structure itself however isn't aligned, and the > > > > __packed attribute prevent the compiler to add this alignment. > > > > > > > > Fix this by adding a padding byte. > > > > > > > > Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space") > > > > Signed-off-by: Francesco Valla <francesco@valla.it> > > > > --- > > > > Hello, > > > > > > > > unfortunately I missed this when the original patch set was sent, but I > > > > think it's worth fixing (or at least discussing) this now before it > > > > enters a stable kernel. > > > > > > > > The same support in open-amp has already been merged [1], but maybe it > > > > can be fixed before the next release there too? > > > > > > > > Another, lower-impact solution would be to fix the comment, but that can > > > > then led to issues on architectures that does not support unaligned > > > > accesses (e.g.: AMR Cortex-M0). > > > > > > > > > > Thanks for bringing this to my attention. I agree with this patch. I will give > > > Arnaud a couple of weeks to reply to this email though. > > > > Thank you > > > > > > > > Francesco > > > > > > > > [1] https://github.com/OpenAMP/open-amp/commit/744376f566c3ec7e06a7d093d785295b78aa486f > > > > --- > > > > include/linux/rpmsg/virtio_rpmsg.h | 2 ++ > > > > 1 file changed, 2 insertions(+) > > > > > > > > diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h > > > > index 0872cbca4593..d24fedb63023 100644 > > > > --- a/include/linux/rpmsg/virtio_rpmsg.h > > > > +++ b/include/linux/rpmsg/virtio_rpmsg.h > > > > @@ -23,6 +23,7 @@ > > > > * > > > > * @version: version of this structure, currently %RPMSG_VDEV_CONFIG_V1. > > > > * @size: size of this structure in bytes. > > > > + * @reserved: padding, reserved for future usage. > > > > * @txbuf_size: Tx buf size from remote's view. For Linux this is rx buf size. > > > > * @rxbuf_size: Rx buf size from remote's view. For Linux this is tx buf size. > > > > * > > > > @@ -33,6 +34,7 @@ > > > > struct virtio_rpmsg_config { > > > > u8 version; > > > > __virtio16 size; > > > > + u8 reserved; > > > > /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */ > > > > __virtio32 txbuf_size; > > > > __virtio32 rxbuf_size; > > > What about using a u16 for the version instead? > Even if we never use the MSB of the field, it seems cleaner to me than > adding a reserved field. > Indeed, we can consider the config space header as containing the > version and the size. The rest is version-dependent, including the > reserved part. > Between the two options, I prefer the u16 version, to keep the version-dependent "payload" aligned to 32 bits. I'll send a V2 with this modification. Shall I send also the corresponding modification for open-amp, or you'll take care of that? > Regards, > Arnaud > Regards, Francesco ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-20 22:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-01 13:54 [PATCH] virtio_rpmsg: fix config space alignment Francesco Valla 2026-11-06 17:37 ` Mathieu Poirier 2026-11-19 15:29 ` Mathieu Poirier 2026-11-20 17:50 ` Arnaud POULIQUEN 2026-11-20 22:29 ` Francesco Valla
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.