Paging/Multitasking Trouble
Paging/Multitasking Trouble
I've been having some paging (here I am again with my paging ) and multitasking trouble. I'm trying to implement multitasking, but I know that before I do that, I must create a new paging directory to work with. This is all fine, the cloning of the directories work and paging works. Now comes my problem; I switch to my kernel directory (which will finally enable paging), then create the heap, then I clone my kernel directory and then I need to switch again to the cloned directory. However, switching to the cloned directory gives me a 'Third exception (14) with no resolution' from Bochs. I haven't even tried the multitasking code yet as it's useless to test it when paging keeps failing. Have you got any idea what's wrong?
The (C++) code to my Paging.cpp and Paging.h files are added with my post (if you would like to see more files, like the heap or the function that calls InitPaging, etc.. please do ask).
Thanks for your time,
Creature
The (C++) code to my Paging.cpp and Paging.h files are added with my post (if you would like to see more files, like the heap or the function that calls InitPaging, etc.. please do ask).
Thanks for your time,
Creature
- Attachments
-
- Paging.h
- The header going with Paging.cpp.
- (3 KiB) Downloaded 62 times
-
- Paging.cpp
- See the comment '//<-- Third exception (14) with no resolution. This is what triple-faults.'
- (8.43 KiB) Downloaded 111 times
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- gzaloprgm
- Member
- Posts: 141
- Joined: Sun Sep 23, 2007 4:53 pm
- Location: Buenos Aires, Argentina
- Contact:
Re: Paging/Multitasking Trouble
Having your kheap code would work. If its similar to JamesM tutorial I think I know whats the bug:
while(i < (CurMemAddress + PAGE_SIZE))
{
AllocFrame(GetPage(i, true, KernelDir), false, false);
i += PAGE_SIZE;
}
Try changing the while statement to
while( i < (1024*1024*4))
Tell me if it helps.
Cheers,
Gonzalo
while(i < (CurMemAddress + PAGE_SIZE))
{
AllocFrame(GetPage(i, true, KernelDir), false, false);
i += PAGE_SIZE;
}
Try changing the while statement to
while( i < (1024*1024*4))
Tell me if it helps.
Cheers,
Gonzalo
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
Re: Paging/Multitasking Trouble
It didn't work, but thanks for trying. The last SwitchPageDirectory(CurrentDir) still fails for some reason. And yes, it was (greatly ) inspired by JamesM's tutorials.
Edit: I added my heap headers. The package contains Heap.cpp, Heap.h, OrderedList.cpp and OrderedList.h.
Edit: I added my heap headers. The package contains Heap.cpp, Heap.h, OrderedList.cpp and OrderedList.h.
- Attachments
-
- Files.zip
- (5.08 KiB) Downloaded 77 times
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Re: Paging/Multitasking Trouble
After further studies (cough) I found that the problem seems to be a heap bug somewhere, but after checking the heap code over and over again (and fixing some minor problems), it's still giving a Third Exception (14) With No Resolution.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
- AndrewAPrice
- Member
- Posts: 2303
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Paging/Multitasking Trouble
The heap problem is most likely due to your page table/directories not being set up correctly.
You see, the exception was triggered while trying to fetch the next instruction. The triple fault was triggered because the double fault could not be handled, and the double fault was triggered because the page fault was could not be handled, and the page fault was triggered because most likely you were trying to access virtual memory that isn't mapped. Therefore 2 things can be assumed:
- Your interrupt handlers and IDT (even possibly GDT) are not longer in the same virtual memory location as they should be. This caused the page fault to fail and fire a double fault, and caused the double fault to fail and fire a triple fault.
- The code you are currently executing does not exist at the same virtual memory location straight after switching page directories.
Okay, so what does all of that mean you should do? Make sure:
- The memory you are currently executing is at the same virtual address before and after loading your new page table.
- The page table you're writing to CR3, the addresses of the page tables you're writing into the page directory, and the addresses of the pages you're writing into the page tables are actually their PHYSICAL address, not virtual address (I'm guestimating this is the issue).
You see, the exception was triggered while trying to fetch the next instruction. The triple fault was triggered because the double fault could not be handled, and the double fault was triggered because the page fault was could not be handled, and the page fault was triggered because most likely you were trying to access virtual memory that isn't mapped. Therefore 2 things can be assumed:
- Your interrupt handlers and IDT (even possibly GDT) are not longer in the same virtual memory location as they should be. This caused the page fault to fail and fire a double fault, and caused the double fault to fail and fire a triple fault.
- The code you are currently executing does not exist at the same virtual memory location straight after switching page directories.
Okay, so what does all of that mean you should do? Make sure:
- The memory you are currently executing is at the same virtual address before and after loading your new page table.
- The page table you're writing to CR3, the addresses of the page tables you're writing into the page directory, and the addresses of the pages you're writing into the page tables are actually their PHYSICAL address, not virtual address (I'm guestimating this is the issue).
My OS is Perception.
Re: Paging/Multitasking Trouble
I also think this is the most likely, as I remember Bochs reporting something about a non-existing physical address a while ago. When debugging, I see that when the first directory is written to CR3 and paging is enabled, the PhysicalAddress and 'TablesPhysAddr' have the same address, which is correct and should be the case. However, when the second pageDirectory is written, the two are completely different.MessiahAndrw wrote: - The page table you're writing to CR3, the addresses of the page tables you're writing into the page directory, and the addresses of the pages you're writing into the page tables are actually their PHYSICAL address, not virtual address (I'm guestimating this is the issue).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
-
- Posts: 1
- Joined: Mon Jun 27, 2011 3:35 pm
Re: Paging/Multitasking Trouble
Ive noticed same with FP sources.
I have tried debugging over and over again. I wind up with the following and belive it to be a PageAlloc issue after 1024 allocations.
We shift shr 12 as required and use virttophysical to convert the addresses as required.
The first 1024 page tables and 0th (kernel) directory allocate ok.
I get thrown to the 1gb mark on page 1 /directory 1 allocation(when I remove the shifting and virtual converstion) or wind up woth zeroed addresses if I use the same scema I allocated page directory 0 with.This goes for page tables AND the directory physical location for the cr3.
Not understanding why this is.
Note PAE mode, only allocates the 1st (kernel page 0) page. I havent gotten this far in PAE mode yet, but it comes online ok.
My heap works and comes online ok, but as we know, we need paging, not FLAT memory modes.I've disabled it for now until we can get this and tasking units up and up into usermode, which I am having diffulty throwing the CS correctly into.
I GPF instead, but it is caught by the OS, not QEMU.
If I can find a way to do this with out of bounds EIPs I would be grateful.
CPL3 HINT:
You have to convert the AS code to NASM to get everything else correct:
IE:
push $1f turns into jmp 1
and
1:
I have tried debugging over and over again. I wind up with the following and belive it to be a PageAlloc issue after 1024 allocations.
We shift shr 12 as required and use virttophysical to convert the addresses as required.
The first 1024 page tables and 0th (kernel) directory allocate ok.
I get thrown to the 1gb mark on page 1 /directory 1 allocation(when I remove the shifting and virtual converstion) or wind up woth zeroed addresses if I use the same scema I allocated page directory 0 with.This goes for page tables AND the directory physical location for the cr3.
Not understanding why this is.
Note PAE mode, only allocates the 1st (kernel page 0) page. I havent gotten this far in PAE mode yet, but it comes online ok.
My heap works and comes online ok, but as we know, we need paging, not FLAT memory modes.I've disabled it for now until we can get this and tasking units up and up into usermode, which I am having diffulty throwing the CS correctly into.
I GPF instead, but it is caught by the OS, not QEMU.
If I can find a way to do this with out of bounds EIPs I would be grateful.
CPL3 HINT:
You have to convert the AS code to NASM to get everything else correct:
IE:
push $1f turns into jmp 1
and
1:
- Attachments
-
[The extension pas has been deactivated and can no longer be displayed.]
-
[The extension pas has been deactivated and can no longer be displayed.]
-
[The extension pas has been deactivated and can no longer be displayed.]