Subject: Re: alloca in the kernel
To: Alfred Perlstein <firstname.lastname@example.org>
From: Jaromir Dolecek <email@example.com>
Date: 01/06/2002 13:09:17
Alfred Perlstein wrote:
> * Lennart Augustsson <firstname.lastname@example.org> [020105 20:04] wrote:
> > alloca() is nasty, let's avoid it in the kernel.
> I've always assumed that alloca() gets its backing store from the
> stack, you definetly don't want to encourage allocating large things
> on the stack in the kernel, right?
The bit in macppc machdep.c could theoretically easily be replaced
with malloc(9)/free(9). However, note it's initppc() function, and
thus the virtual system might not be initialized yet enough to use
malloc/free. In this case, alloca() there seems to be a fairly
clever way to allocate needed temporary storage. Since the (maximum)
ofmap length is not known in advance, it seems to be necessary
to allocate the (stack) memory on run-time. Is there an upper bound
of mmu.translations length? The code should at least check that
ofmaplen is smaller than size of kernel stack at that point.
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.NetBSD.org/Ports/i386/ps2.html
-= Those who would give up liberty for a little temporary safety deserve =-
-= neither liberty nor safety, and will lose both. -- Benjamin Franklin =-