OSDev.org
https://forum.osdev.org/

Page Fault
https://forum.osdev.org/viewtopic.php?f=1&t=17082
Page 1 of 1

Author:  JoeTheProgrammer [ Tue May 27, 2008 5:52 pm ]
Post subject:  Page Fault

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

Author:  piranha [ Tue May 27, 2008 8:26 pm ]
Post subject: 

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

Author:  JoeTheProgrammer [ Tue May 27, 2008 8:58 pm ]
Post subject: 

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

Author:  piranha [ Tue May 27, 2008 9:10 pm ]
Post subject: 

Is the code that you've written good?

-JL

Author:  JoeTheProgrammer [ Tue May 27, 2008 9:13 pm ]
Post subject: 

piranha wrote:
Is the code that you've written good?

-JL


Here it is:

In boot.asm
Code:
global _testMonitorWriteSysCall

int80h_eax0:     db 'Int 80h EAX=0 Called...',23
         
_testMonitorWriteSysCall:
    mov eax, 0
    mov ebx, int80h_eax0
    int 80h


In main:
Code:
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;
}

Author:  JamesM [ Wed May 28, 2008 1:43 am ]
Post subject: 

Hi,

Quote:
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

Author:  JoeTheProgrammer [ Wed May 28, 2008 12:15 pm ]
Post subject: 

JamesM wrote:
Hi,

Quote:
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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/