Paging not detecting non-present directories
- Primis
- Member
- Posts: 62
- Joined: Fri May 14, 2010 3:46 pm
- Libera.chat IRC: Primis
- Location: New York, NY
- Contact:
Paging not detecting non-present directories
So I was rewriting a new kernel from scratch, when it came time to write the paging code, so I write a basic set for the first 4MB identity map, then I was going to expand from there. However, when I went to test my code in rebochs, the page table shows that the pages that should be marked as invalid are showing up as present, and are mapped to 0, I've tried this in bochs, and in virtual box to no avail. Is it my code or is it my compiler? (relevant code in paste)
http://pastebin.com/EA6gG2YS
http://pastebin.com/EA6gG2YS
Re: Paging not detecting non-present directories
Your code looks reasonable for 32 bit paging assuming you're already in protected mode when it runs. Out of interest, what type does unsigned represent in your compiler? And what exactly does bochs suggest is wrong? Is it the output from 'info tab'?
Regards,
John.
Regards,
John.
- Primis
- Member
- Posts: 62
- Joined: Fri May 14, 2010 3:46 pm
- Libera.chat IRC: Primis
- Location: New York, NY
- Contact:
Re: Paging not detecting non-present directories
In my test code, I have it try and access a non-present address (specifically 0xA0000000) which should result in a page fault, however the code keeps executing without an issue, so I tested it in reBochs (great simulator with a built in debugger) and when I checked my page tables, all the pages in the directory above the mapped area were still showing as "present" but the pages were all redirecting to 0x00, it makes no sense. The table set up properly, just not the invalid pages...
- Primis
- Member
- Posts: 62
- Joined: Fri May 14, 2010 3:46 pm
- Libera.chat IRC: Primis
- Location: New York, NY
- Contact:
Re: Paging not detecting non-present directories
And uh, 'unsigned' is shorthand for 'unsigned int' which defaults to 32 bits
Re: Paging not detecting non-present directories
Not necessarily - C99 only defines unsigned int to be at least 2 bytes, ILP64 compilers have it as 8 bytes. If using a gcc cross compiler for x86 this is unlikely to be your problem (however this wasn't explicitly stated in your post), but for portability you can use the types in stdint.h.Primis wrote:And uh, 'unsigned' is shorthand for 'unsigned int' which defaults to 32 bits
The only other possible issue I can see is that gcc is optimising your memory accesses away. Are you able to inspect the raw bytes at 0x9c004, 0x9c008 etc to see that they contain what you think they contain?
Regards,
John.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Paging not detecting non-present directories
Without looking, the EBDA?jnc100 wrote:(...) the raw bytes at 0x9c004, 0x9c008 etc to see that they contain (...)
(And no, I really haven't bothered to look at the code yet. It just sounds like a really bad plan)
Re: Paging not detecting non-present directories
I upgraded computers one time about 5 years ago. When booted to CD-ROM my PS/2 emulated keyboard and mouse worked but when booted to hard drive, my mouse didn't work. My boot-loaders were different for CD-ROM and mouse. Both boot-loaders copied themselves up to under 0xA0000 and loaded my 2nd stage at 0x10000. I was unaware there was such a thing as an EBDA.
It turns-out I got lucky because I learned my particular BIOS has a byte in EBDA 0x9FC30 which must be set to 0x01 or the mouse doesn't work.
Today, I load to under 0x90000 and I just shove a 0x01 into 0x9FC30 and pray.
I just upgraded this week and my new computer doesn't appear to support ATA/ATAPI port I/O.
I have been working for 9 years full-time and I have upgraded about 4 times, each time it failed to work. This time I can't fix it. I guess I'll be in VMWare from now on, which makes it pointless.
It turns-out I got lucky because I learned my particular BIOS has a byte in EBDA 0x9FC30 which must be set to 0x01 or the mouse doesn't work.
Today, I load to under 0x90000 and I just shove a 0x01 into 0x9FC30 and pray.
I just upgraded this week and my new computer doesn't appear to support ATA/ATAPI port I/O.
I have been working for 9 years full-time and I have upgraded about 4 times, each time it failed to work. This time I can't fix it. I guess I'll be in VMWare from now on, which makes it pointless.
Re: Paging not detecting non-present directories
I thought this at first when I saw his code, but checking both my virtualbox memory map and even with our wiki the EBDA tends to start at 0x9fc00 and the pages at 0x9c000 (where he puts the page directory) and 0x9d000 (first page table) should be okay. Obviously this is no substitute for actually checking the memory map on his own particular machine.Combuster wrote:Without looking, the EBDA?jnc100 wrote:(...) the raw bytes at 0x9c004, 0x9c008 etc to see that they contain (...)
(And no, I really haven't bothered to look at the code yet. It just sounds like a really bad plan)
Regards,
John.
- Primis
- Member
- Posts: 62
- Joined: Fri May 14, 2010 3:46 pm
- Libera.chat IRC: Primis
- Location: New York, NY
- Contact:
Re: Paging not detecting non-present directories
Turns out gcc optimizations were the blame, a quick -O0 on the compilation list worked wonders.
Re: Paging not detecting non-present directories
If I were you I would not blame the optimization, but the misbehave code that messed it up.Primis wrote:Turns out gcc optimizations were the blame, a quick -O0 on the compilation list worked wonders.
Have you provide enough hints for gcc (eg. clobber list in sensitive instructions)?
Re: Paging not detecting non-present directories
Unless you are doing something really freaky you most probably have a bug.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/