Page 1 of 1

Ring0 and Ring3?

Posted: Sun Apr 05, 2009 10:58 pm
by Raven
Hi

Suppose Ring0 task is running and we switch to Ring3.
Now we create another task, what will be the priveldge level of that task?

What I did is set up a syscall that creates new task ( loads the program from disk, creates new PCB node and sets up appropriate eip,esp and ebp,puts that node in the end and returns ).
The two task run fine and are prempted by scheduler, BUT as soon as i use qemu to check the CPL it shows 3 for older and 0 for this new task.

I am not able to understand what is wrong with it.
I might be missing something.
Please help?

Re: Ring0 and Ring3?

Posted: Mon Apr 06, 2009 12:21 am
by pcmattman
Hi,
Now we create another task, what will be the priveldge level of that task?
The privilege level will be whatever you set it to. You must explicitly set the privilege level for every task you create - that's just part of creating it.

Re: Ring0 and Ring3?

Posted: Mon Apr 06, 2009 12:32 am
by Brendan
Hi,
Raven wrote:What I did is set up a syscall that creates new task ( loads the program from disk, creates new PCB node and sets up appropriate eip,esp and ebp,puts that node in the end and returns ).
The two task run fine and are prempted by scheduler, BUT as soon as i use qemu to check the CPL it shows 3 for older and 0 for this new task.
In this case; if the new task is meant to start running CPL=3 code immediately then your kernel probably put the wrong value for "current CS" into the new task's TSS; or, if the new task is meant to start running some kernel/scheduler code before returning to CPL=3 then the kernel probably put the wrong value for "return CS" on the new task's kernel stack.


Cheers,

Brendan

Re: Ring0 and Ring3?

Posted: Mon Apr 06, 2009 6:24 am
by Raven
Hi

The interrupt to create a new task is invoked by a task running in CPL=3 and the TSS (only TSS in system) has cs,ds,es,fs and gs set to kernel mode with RPL=3. Within this ISR as said node is created,populated and placed. Now, when i return from that ISR the CPL should be 3, correct ?

Now, i am confused how to set the CPL=3 for new task as this will be scheduled by scheduler.
Should i put a flag in PCB which will tell me whether to push Ring3 CS,DS, etc. on stack so that they be popped by scheduler for new task only?

Please help