On-stack allocation of DMA S/G lists

John Baldwin jhb at freebsd.org
Mon Aug 6 14:40:04 UTC 2012


On Thursday, July 12, 2012 8:26:05 am John Baldwin wrote:
> On Sunday, July 08, 2012 7:05:16 am Peter Jeremy wrote:
> > BTW(2): Whilst studying busdma_machdep.c for arm and mips, I've
> > noticed they appear to potentially allocate substantial kernel stack
> > under some conditions as several bus_dma(9) functions include:
> >     bus_dma_segment_t dm_segments[dmat->nsegments];
> > What prevents this overflowing the kernel stack?
> 
> That does seem dubious.  x86 stores the array in the tag instead.

I have an untested patch to change bus-dma on arm and mips to allocate a
dynamic S/G list in each DMA tag on first use instead of using on-stack
allocation (which I think is rather bogus).  Can folks review and test this 
patch please?  Thanks.

http://www.FreeBSD.org/~jhb/patches/arm_mips_dynamic_dma_segs.patch

-- 
John Baldwin


More information about the freebsd-arm mailing list