Page 1 of 1
Page fault,why ?
Posted: Mon Sep 16, 2002 11:00 pm
by Kupak
i've got a strange problem,if i dont set the u/s bit in the page table for a new process's kernel stack,the iretd (i think) in the context_start() code gives me page fault,if i set it no problem.
Another question: how does u/s bit behave when set in page directories,overrides the settings of the page tables ?
THX !
RE:Page fault,why ?
Posted: Tue Sep 17, 2002 11:00 pm
by anton
Is WP flag in CR0 set? What is the privelage of your code?
Now anout the second question :
From 3.6.4 Volume 3 :
User/supervisor (U/S) flag, bit 2
Specifies the user-supervisor privileges for a page or group of pages (in the
case of a page-directory entry that points to a page table). ...
Anton
RE:Page fault,why ?
Posted: Tue Sep 17, 2002 11:00 pm
by Kupak
Hi Anton !
I dont touch that flag,but why would that matter !?
The code is ring 0,it happens when the kernel starts a new process !
Context_load() is the place where i build up the stack frame for the iretd,so that the ring 3 code can start.Iretd pops the ring 3 es:esp from the kernel stack and eflags then eip:cs.
Here is the code :
_context_start:
cli
mov eax,[esp+4] ;eip
mov ebx,[esp+8] ;user stack
mov ecx,32+3 ;ring 3 data segment selector
push ecx ;ss3
push ebx ;esp3
push dword 0x200 ;eflags
push dword 24+3 ;ring 3 code selector
push eax ;eip
mov ds,cx
mov es,cx
mov fs,cx
mov gs,cx
xor eax,eax
xor ebx,ebx
xor ecx,ecx
xor edx,edx
mov edi,0
mov esi,0
mov ebp,0
iretd
RE:Page fault,why ?
Posted: Thu Sep 19, 2002 11:00 pm
by anton
Probobly iretd does not generate a page fault, code that is after that(the thread it self) generates it!
From 4.11.2 v3
...
When the processor is in supervisor mode, it can access all pages; when in
user mode, it can access only !!!user-level pages!!!.
So, if you don't set u/s the page is in supervisor mode, but your program runs in user mode(ring 3)=>page fault!!!
anton