Re: git: 1d13d938fe6c - main - virtio: Ensure power-of-two alignment for indirect queue

From: Jessica Clarke <jrtc27_at_freebsd.org>
Date: Fri, 20 Mar 2026 12:44:04 UTC
On 17 Mar 2026, at 11:34, Jessica Clarke <jrtc27@freebsd.org> wrote:
> 
> On 17 Mar 2026, at 11:24, Andrew Turner <andrew@freebsd.org> wrote:
>> 
>> The branch main has been updated by andrew:
>> 
>> URL: https://cgit.FreeBSD.org/src/commit/?id=1d13d938fe6c7639d2bb4cb5248a1f81275b6891
>> 
>> commit 1d13d938fe6c7639d2bb4cb5248a1f81275b6891
>> Author:     Sarah Walker <sarah.walker2@arm.com>
>> AuthorDate: 2026-03-17 10:54:30 +0000
>> Commit:     Andrew Turner <andrew@FreeBSD.org>
>> CommitDate: 2026-03-17 10:56:27 +0000
>> 
>>   virtio: Ensure power-of-two alignment for indirect queue
>> 
>>   Some platforms enforce power-of-two alignment for bus_dma tags. Rounding up
>>   the natural size may result in over-alignment, but should be safe.
>> 
>>   PR:             293770
>>   Reviewed by:    andrew
>>   Fixes:          c499ad6f997c ("virtio: Use bus_dma for ring and indirect buffer allocations")
>>   Sponsored by:   Arm Ltd
>>   Differential Revision:  https://reviews.freebsd.org/D55843
>> ---
>> sys/dev/virtio/virtqueue.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c
>> index b7fdb4703ccb..10b5179bd3d5 100644
>> --- a/sys/dev/virtio/virtqueue.c
>> +++ b/sys/dev/virtio/virtqueue.c
>> @@ -341,7 +341,7 @@ virtqueue_init_indirect(struct virtqueue *vq, int indirect_size)
>> align = size;
> 
> Why is this the alignment in the first place? Pre-busdma it just used
> malloc with no explicit alignment. Given:
> 
>  size = indirect_size * sizeof(struct vring_desc);
> 
> can’t this get quite large? Except VIRTIO_MAX_INDIRECT looks to be
> rather stale, tied to the malloc rather than busdma world…

Ping?

Jessica