stack, page fault and tripple fault question
Posted: Thu Jan 16, 2003 9:09 pm
i have been thinking about make my own os(who doesn't think about this here?) for a long time. I'm reading the Intel 386 book and i see that using TSS is possible to have a very strong protection. After looking trought internet i found that almost nobody uses TSS and change tasks by hand(faster and better performance, but less protection against faults).
I want to have everithing clear before writing anything. Here is the explanation of the possible problem and what would happen.
We have one perfect task running on a 386+ computer with X(128 Mb) Mb memory with the kernel loaded at some high memory(eg: 0xC0000000), we use paging in the memory manager. The top of the stack is something below the kernel's memory(like 0xB0000000). We have more tasks running on the system so some of the pages are not present because of virtual memory. The our perfect task call one procedure(using CALL in X86). Doing this, the processor will push the old IP in the stack(to return here with RET instruction) but when in try to push the IP the page is not present, and we well have one PAGE FAULT. Then it will try to go to the page fault esception handler, and it will try to push CS, IP and FLAGS, but still the page is not present, so we well have DOUBLE FAULT, again try to push something and TRIPLE FAULT.
ok, this is only my imagination, could it happen? how can we avoid this problem?
i suppose that we can check thet dirty flag, of the last page we are using of the stack and make the next present, but it will take more time to check, and still is not error free, because some procedure could reserve more than a page of the stack (using SUB ESP, X) and still we will have this problem.
also i would like to know if ?'m right or i'm thinking about something impossible.
I want to have everithing clear before writing anything. Here is the explanation of the possible problem and what would happen.
We have one perfect task running on a 386+ computer with X(128 Mb) Mb memory with the kernel loaded at some high memory(eg: 0xC0000000), we use paging in the memory manager. The top of the stack is something below the kernel's memory(like 0xB0000000). We have more tasks running on the system so some of the pages are not present because of virtual memory. The our perfect task call one procedure(using CALL in X86). Doing this, the processor will push the old IP in the stack(to return here with RET instruction) but when in try to push the IP the page is not present, and we well have one PAGE FAULT. Then it will try to go to the page fault esception handler, and it will try to push CS, IP and FLAGS, but still the page is not present, so we well have DOUBLE FAULT, again try to push something and TRIPLE FAULT.
ok, this is only my imagination, could it happen? how can we avoid this problem?
i suppose that we can check thet dirty flag, of the last page we are using of the stack and make the next present, but it will take more time to check, and still is not error free, because some procedure could reserve more than a page of the stack (using SUB ESP, X) and still we will have this problem.
also i would like to know if ?'m right or i'm thinking about something impossible.