With paging on is it normal for the cpu to crash with out faulting if your stack grows into unmapped pages?
-Christopher
Quick Stack Question
RE:Quick Stack Question
Yes.
Think of it this way, you've accessed a inaccessable stack page... you've run out of stack space. So, the processor issues a page fault. But, most OSs handle a page fault as a standard interrupt gate or trap, which doesn't change ss or esp, right?
But, an interrupt needs a return address... where's that address go? On the stack... but you don't have any stack... you've run out.
So, the processor then issues a double fault... same deal, need a return address, but no stack, and so the processor goes right on to a triple fault, and there's your reboot.
There's a few ways to handle this; allocate more stack, or make your page fault (or, perhaps more useful, your double fault) exception a task gate, which will allow you to load new ss and esp values.
Cheers,
Jeff
Think of it this way, you've accessed a inaccessable stack page... you've run out of stack space. So, the processor issues a page fault. But, most OSs handle a page fault as a standard interrupt gate or trap, which doesn't change ss or esp, right?
But, an interrupt needs a return address... where's that address go? On the stack... but you don't have any stack... you've run out.
So, the processor then issues a double fault... same deal, need a return address, but no stack, and so the processor goes right on to a triple fault, and there's your reboot.
There's a few ways to handle this; allocate more stack, or make your page fault (or, perhaps more useful, your double fault) exception a task gate, which will allow you to load new ss and esp values.
Cheers,
Jeff
RE:Quick Stack Question
Jeff,
istopher
Thanks
I have been beating my brain for a few days so I have just been ignoring the problem. I'm going to try that out see if it works because my "hack" to get around that was been to police the sp but that is costly in terms of overhead.
-Christopher
istopher
Thanks
I have been beating my brain for a few days so I have just been ignoring the problem. I'm going to try that out see if it works because my "hack" to get around that was been to police the sp but that is costly in terms of overhead.
-Christopher
RE:Quick Stack Question
"make your page fault (or, perhaps more useful, your double fault) exception a task gate"-that's not the only way,
You can also use a call gate, which changes the run level. In this case it will use the stack of the new run level(if old<=new, ...).
You can also use a call gate, which changes the run level. In this case it will use the stack of the new run level(if old<=new, ...).
RE:Quick Stack Question
> You can also use a call gate, which changes the run level. In this case it
> will use the stack of the new run level(if old<=new, ...).
Yes, but then you'll always be leaving out one privelege level. Any privelege level could exceed the stack allocated for it. I suppose if you can _garauntee_ that the OS (at level 0) wont, then making the exception handler p0 as well would be acceptable (but could cause problems if your drivers are also at p0... I wouldn't trust 'em
Jeff
> will use the stack of the new run level(if old<=new, ...).
Yes, but then you'll always be leaving out one privelege level. Any privelege level could exceed the stack allocated for it. I suppose if you can _garauntee_ that the OS (at level 0) wont, then making the exception handler p0 as well would be acceptable (but could cause problems if your drivers are also at p0... I wouldn't trust 'em
Jeff