I have 2 gdt segments for kernel, one for code, the other for data
I have 2 gdt segments for user space, one for code, the other for data
all segments span the entire 4gb address space
Now my kernel data and code is mapped into virtual address space by setting the page table bit to supervisory only... (not accessed by all)
now I transitioned my kernel process into user mode and tries to make syscalls.... I got an error saying that page fault
for the stack I am trying to access...
The segment selector value is 0x23
last 2 bit is rpl which is segment selector indicates it is user mode... after switch to user mode, is my cpl 3?
what did I do wrong? I find that rpl, dpl and cpl confusing...
should I set kernel code and data to supervisory or to all? will that make user code able to execute kernel code??
I am drowning in questions ! pulling me out of my misery!!!
kernel vs user space question
- bellezzasolo
- Member
- Posts: 110
- Joined: Sun Feb 20, 2011 2:01 pm
Re: kernel vs user space question
Have you set up ESP0 of your TSS to a valid stack?ITchimp wrote:I have 2 gdt segments for kernel, one for code, the other for data
I have 2 gdt segments for user space, one for code, the other for data
all segments span the entire 4gb address space
Now my kernel data and code is mapped into virtual address space by setting the page table bit to supervisory only... (not accessed by all)
now I transitioned my kernel process into user mode and tries to make syscalls.... I got an error saying that page fault
for the stack I am trying to access...
The segment selector value is 0x23
last 2 bit is rpl which is segment selector indicates it is user mode... after switch to user mode, is my cpl 3?
what did I do wrong? I find that rpl, dpl and cpl confusing...
should I set kernel code and data to supervisory or to all? will that make user code able to execute kernel code??
I am drowning in questions ! pulling me out of my misery!!!
When transitioning from ring 3 to ring 0, the CPU loads the stack from the TSS, rather than executing an interrupt handler on a user stack.
Alternatively, if you haven't changed stack when transitioning from ring 0 to ring 3, then you'll be trying to access a ring 0 stack.
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
https://github.com/ChaiSoft/ChaiOS