Re: MMU protected kernel stacks [was: Re: Kernel stack corruption with SCSI]

Ingo Molnar (
Sat, 4 Jan 1997 19:44:04 +0100 (MET)

> > AHA2940 driver hangs in the init phase. Without having looked into the
> > SCSI code i bet the problem is that the driver allocates some (small)
> > control structure on the stack, and uses virt_to_bus(stackaddr) to set up
> > DMA, which looses badly with vmalloc()-ed memory.
> yup, this was the problem, the following code solved it:

argh it doesnt solve it ... [silly me].

Is there any easy way to do this?

the only way i can think of is hacking virt_to_* to detect such MMU kernel
stack areas and doing the translation correctly.

the current translation [for i386 and the Sun4c] is something like this:

#define virt_to_bus(virt_addr) (virt_addr - PAGE_OFFSET)

Which isnt correct if the 'virtual' address is some random MMU mapped
page outside of the almost 1:1 linear mapped kernel virtual memory.

something like this could be done:

if (virt_addr-PAGE_OFFSET < mem_size)
return virt_addr-PAGE_OFFSET;
/* do complete page-table lookup address translation */


-- mingo