paging with multitasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

paging with multitasking

Post by xyjamepa »

Hi...
One more time I'm working on my hardware multitasking,It consists of
two tasks:main() which is PL0 and task() which is PL3,I can
switch from PL0 to PL3 successfully also I can go back to PL0
without any exceptions or errors,All this done without
enabling paging,but when I enable paging I get page fault exception.
I know that each task need different page directory,and in my case
I need two page directories with different PL,so I made one pde
with PL supervisor and another pde with PL user,Also I loaded
the CR3 in each TSS with suitable page directory address like this:

tss[0].cr3=pd //supervisor page directory
tss[1].cr3=pd_u //user page directory

I don't know what's wrong with my code so here's a minimized version
of my kernel ,Also an IMG I think it might help...

Thanx.
Attachments
knl.tar.gz
kernel
(16.96 KiB) Downloaded 17 times
a.tar.gz
IMG file
(47.64 KiB) Downloaded 19 times
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

I suggest you start with writing something that dumps registers whenever your kernel panics. Surely given CR2 and the faulting EIP you can figure where things go wrong and continue from there.

A pagefault with no single clue as to what might or might not be causing it isn't a good start for anybody to start debugging.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Post by jnc100 »

According to bochs debugger, cr2 when your page fault fires is 0x101d0f.

It also says (info tab) that you are mapping 0x000a0000-0x00112fff linearly, so it can't be a page not present fault.

I suggest you also dump (in addition to what Combuster said) the exception error code to the screen as well so you can see if its user code accessing supervisor memory or if its a write to read-only memory. In fact, a dump of all registers is often helpful on a kernel panic.

Regards,
John.
User avatar
xyjamepa
Member
Member
Posts: 397
Joined: Fri Sep 29, 2006 8:59 am

Post by xyjamepa »

Hi...
Now I made one page directory and one page table,each one
is user|write|present so they can be accessed from the PL3 or PL0
so my two tasks now have the same page directory,I know
this is not good but it is temporary till we solve the problem. :wink:

Now please correct me If I'm mistake:

*I made a page directory after the kernel end
*I save a physical page for for pde physical address
*pde can be accessed like this user | present | write

after all that paging is enabled successfully but when
I enable task switching Boch's restart... :(

Just to make sure CR3 in the TSS field sould be loaded
with the physical address of the pde?

Here's an updated source and IMG.

Thanx.
Attachments
a.tar.gz
IMG file
(47.66 KiB) Downloaded 15 times
knl.tar.gz
Kernel
(16.97 KiB) Downloaded 23 times
Post Reply