Works on Bochs, but on real PC page faults :/
Works on Bochs, but on real PC page faults :/
Hello.
I'm writting OS and I write microkernel for it and some modules (init, keyboard driver and simple shell). OS works well on bochs but when i boot real computer from cd with it, i get page fault in process init.sys. I want check it and i dump page dir and page tabless, and all values are ok :/. I think that I make mistake in paging code, and once works, but if i try again don't work :/ I trying dump more information, and on 2PC's, Bochs, Quemu, VMWare are the same. OS source is on cvs, you can browse it via WWW http://cvs.milyges.homelinux.net (module idylla_os), paging code is in src/kernel/hal/ia32/paging.c. Boot CD image os at http://milyges.homelinux.net/~milyges/idylla.iso.gz. CVS server is my home server and it works from 8AM to 10PM.
Sorry for my english
Greetings for all.
I'm writting OS and I write microkernel for it and some modules (init, keyboard driver and simple shell). OS works well on bochs but when i boot real computer from cd with it, i get page fault in process init.sys. I want check it and i dump page dir and page tabless, and all values are ok :/. I think that I make mistake in paging code, and once works, but if i try again don't work :/ I trying dump more information, and on 2PC's, Bochs, Quemu, VMWare are the same. OS source is on cvs, you can browse it via WWW http://cvs.milyges.homelinux.net (module idylla_os), paging code is in src/kernel/hal/ia32/paging.c. Boot CD image os at http://milyges.homelinux.net/~milyges/idylla.iso.gz. CVS server is my home server and it works from 8AM to 10PM.
Sorry for my english
Greetings for all.
Re:Works on Bochs, but on real PC page faults :/
Common differences between bochs and a real pc:
* You need retries for your code. Your floppy is not ideal and does not work every time, nor does any other bit of hardware.
* Your memory is filled with something not unlike /dev/urandom. You MUST clean it before using it or you'll get very weird things. I forgot once, just after adding threadswitching & page fault handling, gave me a 160M dump of all sorts of thread switches to unavailable threads that were uninitialized entries until one accidentally contained just zeroes, which made it go to the idle thread.
* Your hardware is not bochs. Your drivers can make errors, some bits don't work like they do in bochs and some do, where bochs fails.
* You need retries for your code. Your floppy is not ideal and does not work every time, nor does any other bit of hardware.
* Your memory is filled with something not unlike /dev/urandom. You MUST clean it before using it or you'll get very weird things. I forgot once, just after adding threadswitching & page fault handling, gave me a 160M dump of all sorts of thread switches to unavailable threads that were uninitialized entries until one accidentally contained just zeroes, which made it go to the idle thread.
* Your hardware is not bochs. Your drivers can make errors, some bits don't work like they do in bochs and some do, where bochs fails.
Re:Works on Bochs, but on real PC page faults :/
Hello.
I add some debuging code to procedure umap_mem and it's work! Next I remove it code and again page fault ??? ??? ???
Strange......
//EDIT: I test some it under PC and I think that is something wrong with kernel stack :-\ But I don't know what :-\
Anybody can help me??
I add some debuging code to procedure umap_mem and it's work! Next I remove it code and again page fault ??? ??? ???
Strange......
//EDIT: I test some it under PC and I think that is something wrong with kernel stack :-\ But I don't know what :-\
Anybody can help me??
Re:Works on Bochs, but on real PC page faults :/
As a sidenote, what "from 8AM to 10PM" do you mean?
Re:Works on Bochs, but on real PC page faults :/
My server work at this timeCandy wrote: As a sidenote, what "from 8AM to 10PM" do you mean?
Re:Works on Bochs, but on real PC page faults :/
Candy was asking where in the world that was, 8am til 10pm for you probably isn't 8am til 10pm for him.
Re:Works on Bochs, but on real PC page faults :/
Sorry, my english is not good.Kemp wrote: Candy was asking where in the world that was, 8am til 10pm for you probably isn't 8am til 10pm for him.
I'm live in Poland (now on my timer is 8PM)
Re:Works on Bochs, but on real PC page faults :/
I believe bochs fills all memory with 0's on boot while a regular PC is filled with static junk. This can make a huge difference with paging.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Works on Bochs, but on real PC page faults :/
in other words, be paranoid, and everytime you assume a given area of memory contains zeroes, just do a "memset(...,0)" instead of just assuming.
Re:Works on Bochs, but on real PC page faults :/
Hmmm.
GRUB clean kernel bss section??? If not maybe I found error, but now I can not check it :-\
GRUB clean kernel bss section??? If not maybe I found error, but now I can not check it :-\
Re:Works on Bochs, but on real PC page faults :/
From the FAQ (BareBones):
Note that other Multiboot bootloaders might not support this, so do the memset() anyway...Will GRUB wipe the BSS section before loading the kernel?
Yes. For ELF kernels, the .bss section is automatically identified and cleared (despite the Multiboot specification being a bit vague about it). For other formats, if you ask it politely to do so, that is if you use the 'address override' information from the multiboot header (flag #16) and give a non-zero value to the bss_end_addr field. Note that using "address override" with an ELF kernel will disable the default behaviour and do what is described by the "address override" header instead.
Every good solution is obvious once you've found it.
Re:Works on Bochs, but on real PC page faults :/
OK. I add memset in kernel initialization code (clear BSS), when create heap (clear all heap memory), and when I create new page dir and new page table. Now First multiboot module (init.sys) is loading well. But......
Module init.sys starting and loading other modules and now I get Page fault when sheduler give control to second module, code is not mapped :/ Why it working for first, but not working for second module??? I do not have any idea :/
Module init.sys starting and loading other modules and now I get Page fault when sheduler give control to second module, code is not mapped :/ Why it working for first, but not working for second module??? I do not have any idea :/
Re:Works on Bochs, but on real PC page faults :/
OK it is working. ;D
Thanks for help. I add cleaning kernel .bss section, new page tabs and page dirs, and reloading page dir after any change of page dir/table.
Thanks for help. I add cleaning kernel .bss section, new page tabs and page dirs, and reloading page dir after any change of page dir/table.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Works on Bochs, but on real PC page faults :/
there's one very important thing to keep in mind with GRUB's "modules": they are loaded, period. That is, they are loaded as-is, without having a single byte in memory that is different from its on-disk version.
That strongly differs from e.g. linux modules that are processed and have their symbols resolved against the kernel symtable, have their BSS allocated and initialized (i cannot even guarantee that GRUB will see that your module needs 4MB extra space for its .bss section, for instance, and in a paged environment you barely care ...
That strongly differs from e.g. linux modules that are processed and have their symbols resolved against the kernel symtable, have their BSS allocated and initialized (i cannot even guarantee that GRUB will see that your module needs 4MB extra space for its .bss section, for instance, and in a paged environment you barely care ...
Re:Works on Bochs, but on real PC page faults :/
Sorry, I not sure what you want talk to me, I hope that I understand you ::)
My modules have elf format, and I copy all sections of them to my memory, I manualy allocate space for .bss ;D Grub only loading file for me. Kernel do rest.
My modules have elf format, and I copy all sections of them to my memory, I manualy allocate space for .bss ;D Grub only loading file for me. Kernel do rest.