mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] virtio_rpmsg: Fix config space alignment
@ 2026-11-20 23:01 Francesco Valla
  2026-11-23  8:12 ` Arnaud POULIQUEN
  0 siblings, 1 reply; 4+ messages in thread
From: Francesco Valla @ 2026-11-20 23:01 UTC (permalink / raw)
  To: Bjorn Andersson, Mathieu Poirier, Tanmay Shah, Arnaud POULIQUEN,
	openamp-rp
  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 extending the version field to 16 bits.

Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space")
Signed-off-by: Francesco Valla <francesco@valla.it>
---
Changes in v2:
- version field extended to 16 bits instead of adding a reserved byte.
- Rebased on current master.
- Link to v1: https://patch.msgid.link/20261101-rpmsg-config-size-v1-1-65686b445b22@valla.it
---
 drivers/rpmsg/virtio_rpmsg_bus.c   | 2 +-
 include/linux/rpmsg/virtio_rpmsg.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 23ff6c8b7a20..27282475a732 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -815,7 +815,7 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
 static int rpmsg_virtio_get_buf_size(struct virtproc_info *vrp)
 {
 	struct virtio_device *vdev;
-	u8 version;
+	u16 version;
 	u16 size;
 
 	vdev = vrp->vdev;
diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
index 0872cbca4593..57f48d537de9 100644
--- a/include/linux/rpmsg/virtio_rpmsg.h
+++ b/include/linux/rpmsg/virtio_rpmsg.h
@@ -31,7 +31,7 @@
  * the structure is naturally 32-bit aligned.
  */
 struct virtio_rpmsg_config {
-	u8 version;
+	__virtio16 version;
 	__virtio16 size;
 	/* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
 	__virtio32 txbuf_size;

---
base-commit: 5f22fb20497f4983094131f00a734362300d22d2
change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d

Best regards,
--  
Francesco Valla <francesco@valla.it>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] virtio_rpmsg: Fix config space alignment
  2026-11-20 23:01 [PATCH v2] virtio_rpmsg: Fix config space alignment Francesco Valla
@ 2026-11-23  8:12 ` Arnaud POULIQUEN
  2026-11-23 14:12   ` Mathieu Poirier
  0 siblings, 1 reply; 4+ messages in thread
From: Arnaud POULIQUEN @ 2026-11-23  8:12 UTC (permalink / raw)
  To: Francesco Valla, Bjorn Andersson, Mathieu Poirier, Tanmay Shah,
	openamp-rp
  Cc: linux-remoteproc, linux-kernel



On 11/21/26 00:01, 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 extending the version field to 16 bits.
> 
> Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space")
> Signed-off-by: Francesco Valla <francesco@valla.it>
> ---
> Changes in v2:
> - version field extended to 16 bits instead of adding a reserved byte.
> - Rebased on current master.
> - Link to v1: https://patch.msgid.link/20261101-rpmsg-config-size-v1-1-65686b445b22@valla.it
> ---
>   drivers/rpmsg/virtio_rpmsg_bus.c   | 2 +-
>   include/linux/rpmsg/virtio_rpmsg.h | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
> index 23ff6c8b7a20..27282475a732 100644
> --- a/drivers/rpmsg/virtio_rpmsg_bus.c
> +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
> @@ -815,7 +815,7 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
>   static int rpmsg_virtio_get_buf_size(struct virtproc_info *vrp)
>   {
>   	struct virtio_device *vdev;
> -	u8 version;
> +	u16 version;
>   	u16 size;
>   
>   	vdev = vrp->vdev;
> diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
> index 0872cbca4593..57f48d537de9 100644
> --- a/include/linux/rpmsg/virtio_rpmsg.h
> +++ b/include/linux/rpmsg/virtio_rpmsg.h
> @@ -31,7 +31,7 @@
>    * the structure is naturally 32-bit aligned.
>    */
>   struct virtio_rpmsg_config {
> -	u8 version;
> +	__virtio16 version;
>   	__virtio16 size;
>   	/* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
>   	__virtio32 txbuf_size;


Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>

Thanks,

Arnaud

> 
> ---
> base-commit: 5f22fb20497f4983094131f00a734362300d22d2
> change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d
> 
> Best regards,
> --
> Francesco Valla <francesco@valla.it>
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] virtio_rpmsg: Fix config space alignment
  2026-11-23  8:12 ` Arnaud POULIQUEN
@ 2026-11-23 14:12   ` Mathieu Poirier
  2026-11-23 18:16     ` Arnaud POULIQUEN
  0 siblings, 1 reply; 4+ messages in thread
From: Mathieu Poirier @ 2026-11-23 14:12 UTC (permalink / raw)
  To: Arnaud POULIQUEN
  Cc: Francesco Valla, Bjorn Andersson, Tanmay Shah, openamp-rp,
	linux-remoteproc, linux-kernel

On Mon, 23 Nov 2026 at 02:12, Arnaud POULIQUEN
<arnaud.pouliquen@foss.st.com> wrote:
>
>
>
> On 11/21/26 00:01, 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 extending the version field to 16 bits.
> >
> > Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space")
> > Signed-off-by: Francesco Valla <francesco@valla.it>
> > ---
> > Changes in v2:
> > - version field extended to 16 bits instead of adding a reserved byte.
> > - Rebased on current master.
> > - Link to v1: https://patch.msgid.link/20261101-rpmsg-config-size-v1-1-65686b445b22@valla.it
> > ---
> >   drivers/rpmsg/virtio_rpmsg_bus.c   | 2 +-
> >   include/linux/rpmsg/virtio_rpmsg.h | 2 +-
> >   2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
> > index 23ff6c8b7a20..27282475a732 100644
> > --- a/drivers/rpmsg/virtio_rpmsg_bus.c
> > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
> > @@ -815,7 +815,7 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
> >   static int rpmsg_virtio_get_buf_size(struct virtproc_info *vrp)
> >   {
> >       struct virtio_device *vdev;
> > -     u8 version;
> > +     u16 version;
> >       u16 size;
> >
> >       vdev = vrp->vdev;
> > diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
> > index 0872cbca4593..57f48d537de9 100644
> > --- a/include/linux/rpmsg/virtio_rpmsg.h
> > +++ b/include/linux/rpmsg/virtio_rpmsg.h
> > @@ -31,7 +31,7 @@
> >    * the structure is naturally 32-bit aligned.
> >    */
> >   struct virtio_rpmsg_config {
> > -     u8 version;
> > +     __virtio16 version;
> >       __virtio16 size;
> >       /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
> >       __virtio32 txbuf_size;
>
>
> Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
>

Applied.

Thanks,
Mathieu

> Thanks,
>
> Arnaud
>
> >
> > ---
> > base-commit: 5f22fb20497f4983094131f00a734362300d22d2
> > change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d
> >
> > Best regards,
> > --
> > Francesco Valla <francesco@valla.it>
> >
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] virtio_rpmsg: Fix config space alignment
  2026-11-23 14:12   ` Mathieu Poirier
@ 2026-11-23 18:16     ` Arnaud POULIQUEN
  0 siblings, 0 replies; 4+ messages in thread
From: Arnaud POULIQUEN @ 2026-11-23 18:16 UTC (permalink / raw)
  To: Mathieu Poirier
  Cc: Francesco Valla, Bjorn Andersson, Tanmay Shah, openamp-rp,
	linux-remoteproc, linux-kernel

Hello Mathieu

On 11/23/26 15:12, Mathieu Poirier wrote:
> On Mon, 23 Nov 2026 at 02:12, Arnaud POULIQUEN
> <arnaud.pouliquen@foss.st.com> wrote:
>>
>>
>>
>> On 11/21/26 00:01, 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 extending the version field to 16 bits.
>>>
>>> Fixes: ca96ea25e51a ("rpmsg: virtio_rpmsg_bus: Get buffer size from config space")
>>> Signed-off-by: Francesco Valla <francesco@valla.it>
>>> ---
>>> Changes in v2:
>>> - version field extended to 16 bits instead of adding a reserved byte.
>>> - Rebased on current master.
>>> - Link to v1: https://patch.msgid.link/20261101-rpmsg-config-size-v1-1-65686b445b22@valla.it
>>> ---
>>>    drivers/rpmsg/virtio_rpmsg_bus.c   | 2 +-
>>>    include/linux/rpmsg/virtio_rpmsg.h | 2 +-
>>>    2 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
>>> index 23ff6c8b7a20..27282475a732 100644
>>> --- a/drivers/rpmsg/virtio_rpmsg_bus.c
>>> +++ b/drivers/rpmsg/virtio_rpmsg_bus.c
>>> @@ -815,7 +815,7 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
>>>    static int rpmsg_virtio_get_buf_size(struct virtproc_info *vrp)
>>>    {
>>>        struct virtio_device *vdev;
>>> -     u8 version;
>>> +     u16 version;
>>>        u16 size;
>>>
>>>        vdev = vrp->vdev;
>>> diff --git a/include/linux/rpmsg/virtio_rpmsg.h b/include/linux/rpmsg/virtio_rpmsg.h
>>> index 0872cbca4593..57f48d537de9 100644
>>> --- a/include/linux/rpmsg/virtio_rpmsg.h
>>> +++ b/include/linux/rpmsg/virtio_rpmsg.h
>>> @@ -31,7 +31,7 @@
>>>     * the structure is naturally 32-bit aligned.
>>>     */
>>>    struct virtio_rpmsg_config {
>>> -     u8 version;
>>> +     __virtio16 version;
>>>        __virtio16 size;
>>>        /* The tx/rx individual buffer size (if VIRTIO_RPMSG_F_BUFSZ) */
>>>        __virtio32 txbuf_size;
>>
>>
>> Acked-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
>>
> 
> Applied.

Could you tell me whether this fix will be included in 7.4 or integrated
into 7.5?

Or perhaps both, if 7.4 becomes the LTS release?

I would need this information to manage the compatibility details
properly in OpenAMP.
Regards,
Arnaud

> 
> Thanks,
> Mathieu
> 
>> Thanks,
>>
>> Arnaud
>>
>>>
>>> ---
>>> base-commit: 5f22fb20497f4983094131f00a734362300d22d2
>>> change-id: 20261101-rpmsg-config-size-0dbe9ea63c6d
>>>
>>> Best regards,
>>> --
>>> Francesco Valla <francesco@valla.it>
>>>
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-23 18:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 23:01 [PATCH v2] virtio_rpmsg: Fix config space alignment Francesco Valla
2026-11-23  8:12 ` Arnaud POULIQUEN
2026-11-23 14:12   ` Mathieu Poirier
2026-11-23 18:16     ` Arnaud POULIQUEN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®