Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Combuster wrote:It means you borked something else.
Are you perchance using an unlinked version of your code? The address of the call instruction is just pointing nowhere
To elaborate on what Combuster said, your call instruction doesn't look like it was linked properly. It should call a function in your kernel, but instead it calls to a bad address.
Did this disassembly come from an object file or your final kernel?
I must agree with the sentiments of the posts from JamesM and Combuster: an instruction like 'e8 fc ff ff ff' is the way to produce a call in an object file with an addend of -4 assuming you're using ELF with .rel (rather than .rela) linkage.
i.e. use ld on the output
Regards,
John.
edit: I've just noticed you were posting the object file. Suggest you post the disassembly of the final binary instead.
Okay thanks, I've attached the tarball ( a grub floppy image with the name floppy.img is needed, you also need fasm to compile the sources : http://flatassembler.net/ ) .
Thanks
Last edited by White-spirit on Mon May 12, 2008 11:22 am, edited 1 time in total.
EDIT2: Post updated to cover the *actual* problem.
I don't see what your problem is. You force a page fault, the page fault occurs, is handled, and of course keeps occurring. No GPFs fire at all.
So what's the problem? "Page fault" is in the "Fault" class of exception - when you IRET control returns to the faulting instruction, not the instruction after as in the "Trap" type.
This is so that your page fault handler can change the page tables to make such an access valid. It is expected that if that cannot be accomplished, the current task be killed (in POSIX, with a SIGSEGV), so control should never actually return to the user program.
All in all there seem to be no problems anywhere - everything is doing as it should do.
thanks for testing the code but I already know that it works on Qemu ( why interrupt 9 and not 8 on your screenshot ? ), but in bochs I get GPFs after IRET when interrupts 8, 10-14 are fired.
For the page faults, I already know that all the faults return to the instruction that caused the fault, to let, for example, the page faults handler set some pages which don't exist in RAM .
EDIT :
here are some screenshots of my kernel runing in bochs .
Attachments
GPF after page fault
littlefoot_pf_bochs.png (13.15 KiB) Viewed 2450 times
GPF after interrupt 8
littlefoot_gpf_bochs.png (13.38 KiB) Viewed 2451 times
AJ wrote:That's because of the stack misalignment. Your IRET instruction will be attempting to load your error code as if it were a code segment selector...
Cheers,
Adam
Not quite - it's an *actual* page fault he does.
Interesting how it works in qemu but not in bochs. When I test it in bochs I get the read_virtual_checks(): read beyond limit errors and a GPF firing.
After investigation I've worked out that that error is caused by your read - you're reading a 4-byte value (u32int) from 0xFFFFFFFF. The emulator doesn't support wraparound properly so it gives an error message of its own and a general protection fault.
Reading from 0xFFFFFFF0 instead causes no such problems.
JamesM wrote:After investigation I've worked out that that error is caused by your read - you're reading a 4-byte value (u32int) from 0xFFFFFFFF. The emulator doesn't support wraparound properly so it gives an error message of its own and a general protection fault.
Interesting - thanks for the correction. I assumed Bochs was moaning about invalid segment limits from an incorrectly selected..um..selector.