User mode

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
System123
Member
Member
Posts: 196
Joined: Mon Jul 07, 2008 1:25 am

User mode

Post by System123 »

I have finally got my kernel to multitask, and to switch to user mode. However when the kernel is in user mode and the cpu reaches the return from a system call i end up with a general protection fault. I think the problem is in my tss and the way i install the interrupt handler so i have a few questions.

In the tss does the ss0 value also have to have the last 2bits set aswel? ie: it must be 0x13 instead of 0x10?

And when it comes to installing the idt entry i worked out the flags to be 0xEE is this correct? And must this segment selector be 0x0B or must it be the user segment identifier?
Gizmic OS
Currently - Busy with FAT12 driver and VFS
Hangin10
Member
Member
Posts: 162
Joined: Wed Feb 27, 2008 12:40 am

Re: User mode

Post by Hangin10 »

In the tss does the ss0 value also have to have the last 2bits set aswel? ie: it must be 0x13 instead of 0x10?
Nope.
And when it comes to installing the idt entry i worked out the flags to be 0xEE is this correct? And must this segment selector be 0x0B or must it be the user segment identifier?
0xEE will make the handler "reachable from any privilege level" (the AMD manual). The segment selector in the IDT entry should be a kernel code segment.

I'd recommend checking your stack. Make sure all the pushes and pops match up in your assembly code, and that you pop any error codes off the stack before IRETing.

EDIT: The ss0 value from the TSS, and the code selector from the IDT entry don't need any alteration. (and setting the Requested Privilege Level to 3 is probably a bad idea if you want the interrupt handlers to change to ring zero).
Post Reply