Page 1 of 1
Page Fault
Posted: Tue May 27, 2008 5:52 pm
by JoeTheProgrammer
I am using the tutorial JamesM has written. I am trying to do a system call, but every time I try to do int 80h in the kernel's main function with ebx set to the string to display (monitor_write system call) , I get a page fault. I am a total newbie at kernel development, but can anyone help me figure out what is wrong?
Thanks,
Joseph
Posted: Tue May 27, 2008 8:26 pm
by piranha
1) Are you using the
exact same code as the tutorial?
2) This is the latest (User-Mode) tutorial, right?
3) When does this pagefault happen?
4) What info does it give?
JamesM's Tutorial wrote:If you keep getting page faults when jumping to user mode, make sure that your kernel code/data is set to be user-accessible. When you actually load user programs you won't want this to be the case, however at the moment we merely jump back to the kernel and execute code in main(), so it needs to be accessible in user mode!
-JL
Posted: Tue May 27, 2008 8:58 pm
by JoeTheProgrammer
piranha wrote:1) Are you using the
exact same code as the tutorial?
2) This is the latest (User-Mode) tutorial, right?
3) When does this pagefault happen?
4) What info does it give?
JamesM's Tutorial wrote:If you keep getting page faults when jumping to user mode, make sure that your kernel code/data is set to be user-accessible. When you actually load user programs you won't want this to be the case, however at the moment we merely jump back to the kernel and execute code in main(), so it needs to be accessible in user mode!
-JL
1) I am using the same code, except for the code to display the string using the system call
2) Yes
3) It gives me the pagefault right after the int 80h system call
4)Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"
Thanks,
Joseph
Posted: Tue May 27, 2008 9:10 pm
by piranha
Is the code that you've written good?
-JL
Posted: Tue May 27, 2008 9:13 pm
by JoeTheProgrammer
piranha wrote:Is the code that you've written good?
-JL
Here it is:
In boot.asm
Code: Select all
global _testMonitorWriteSysCall
int80h_eax0: db 'Int 80h EAX=0 Called...',23
_testMonitorWriteSysCall:
mov eax, 0
mov ebx, int80h_eax0
int 80h
In main:
Code: Select all
int main(struct multiboot *mboot_ptr, u32int initial_stack)
{
page_directory_t *dir;
initial_esp = initial_stack;
// Initialise all the ISRs and segmentation
init_descriptor_tables();
// Initialise the screen (by clearing it)
monitor_clear();
// Initialise the PIT to 100Hz
asm volatile("sti");
init_timer(50);
// Start paging.
initialise_paging();
// Start multitasking.
initialise_tasking();
initialise_syscalls();
monitor_write(" ----------------------------------------- \n");
monitor_write("| Welcome |\n");
monitor_write(" ----------------------------------------- \n");
switch_to_user_mode();
testMonitorWriteSysCall();
return 0;
}
Posted: Wed May 28, 2008 1:43 am
by JamesM
Hi,
Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"
Do you think that 0x2d2d2d2d is a valid address?
The EIP is 0x100050 - so what code is it executing? Have you disassembled the binary (objdump -d kernel)
Cheers,
James
Posted: Wed May 28, 2008 12:15 pm
by JoeTheProgrammer
JamesM wrote:Hi,
Here is the info it gives: "Page fault! (present user-mode ) at 0x0x2d2d2d2d -EIP: 0x100050"
Do you think that 0x2d2d2d2d is a valid address?
The EIP is 0x100050 - so what code is it executing? Have you disassembled the binary (objdump -d kernel)
Cheers,
James
No that is not a valid address. Now it is working, so it seems I have somehow fixed the problem.
Thanks,
Joseph