[okl4-developer] pagefault
Frank Kaiser
frank.kaiser at opensynergy.com
Fri Aug 1 02:32:06 EST 2008
Hello, Matthew
Many thanks for pointing me to the document. The main statement I derive
from it is that the L4 kernel is a single stack thread. Any process
entering the kernel domain (mainly by software or hardware interrupt) is
assigned the same stack of 1 kB. I could reproduce this in the
ARM-specific code of the exception handlers.
I can also follow the statement that a single stack kernel has a
reentrancy problem which can easily be avoided by disabling hardware
interrupts in the kernel domain, with a negative impact on interrupt
latency. I have not yet determined what the current code of v2.1 is
doing to this respect.
Our page fault problem which triggered this discussion was caused by a
reentrancy problem of the first-level interrupt handler (called from the
exception vector handler). Our interrupt handler has to serve a
platform-specific hardware request at the end of its execution, which is
originally not possible because the CONTINUATION scheme prevents the
return of functions called by the interrupt handler. So I wrote a
special function to serve the hardware request which is forwarded as
continuation function. Within this function the final return to the
exception handler is executed which requires to store the return address
somewhere. My first attempt to store that return address in a plain
variable caused the page fault, because there are 2 different return
points in the exception handler, whether the interrupt occurs in user
mode or in kernel mode. Apparently the interrupt handler was restarted
from the periodic interval timer (occuring every 5 ms) while still
serving another interrupt which occurred in user mode. The 2nd interrupt
overwrote the stored return interrupt and then the 1st interrupt
returned to the wrong point in the exception handler causing the page
fault.
I could solve this by implementing a FIFO scheme for the return address.
After having anticipated this single stack approach, I wonder that my
fix works. If the 2nd interrupt uses the same stack as the 1st one, how
is it possible that the not yet terminated 1st one survives the reusage
of the stack by the 2nd one? I think I'll spend some time with the J-Tag
debugger to find out more.
Regards
Frank
> -----Original Message-----
> From: Matthew Warton [mailto:mwarton at ok-labs.com]
> Sent: Thursday, July 31, 2008 3:19 AM
> To: Frank Kaiser
> Cc: Geoffrey Lee; developer at okl4.org
> Subject: Re: [okl4-developer] pagefault
>
> Hi Frank,
>
> I originally wrote all of the continuation code in OKL4 as my honours
> thesis at UNSW. you can read the thesis at
> www.disy.cse.unsw.edu.au/theses_public/05/mwarton.pdf
> for an overview of the goals and original state of this work.
>
> Much of this code has evolved in the 2 years since it was originally
> written, but it is still largely recognizable as the same. As for
> your question, the mask 0x3f8 is used because the kernel's stack is
> only 1k, if the stack overflows this 1k we have already overwritten
> some important data and the kernel will likely crash at some point.
>
>
> Thanks,
> Matthew Warton
More information about the Developer
mailing list