Solved PAE paging problems
Solved PAE paging problems
I am currently trying to implement PAE paging but something is wrong.
My kernel triple faults because everything is mapped 0x10E000 bytes too high, for e.g instead of 0x1000->0x1000 I see 0x1000->0x10E000.
After 3 days of bug hunting I can't find anything obvious left to fix.
Can you please take a look at my PAE data structures and tell me if there is something that doesn't look good: https://pastebin.com/E6DzWc3s?
My kernel triple faults because everything is mapped 0x10E000 bytes too high, for e.g instead of 0x1000->0x1000 I see 0x1000->0x10E000.
After 3 days of bug hunting I can't find anything obvious left to fix.
Can you please take a look at my PAE data structures and tell me if there is something that doesn't look good: https://pastebin.com/E6DzWc3s?
Last edited by Octacone on Mon Jul 02, 2018 11:55 am, edited 3 times in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: PAE questions
I can see a couple of potential problems with your use of bitfields (apart from the obvious one that you have allocated 65 bits in page_t).
1. Possible packing problems. As your structs are not packed it's possible that each bitfield is occupying 64 bits.
2. The order in which the compiler allocates bits for bitfields is not specified in the C standard. It varies between processor and compiler.
Either of these may not matter in your case, or one or both may apply - I don't know which compiler you are using. The easiest way to check is to look at the tables actually produced by your code. It should be fairly obvious if there is a problem. As for bitfields, I'd avoid them and use masks instead.
1. Possible packing problems. As your structs are not packed it's possible that each bitfield is occupying 64 bits.
2. The order in which the compiler allocates bits for bitfields is not specified in the C standard. It varies between processor and compiler.
Either of these may not matter in your case, or one or both may apply - I don't know which compiler you are using. The easiest way to check is to look at the tables actually produced by your code. It should be fairly obvious if there is a problem. As for bitfields, I'd avoid them and use masks instead.
Re: PAE questions
65? I went over that thing like 50 times and didn't notice it...iansjack wrote:I can see a couple of potential problems with your use of bitfields (apart from the obvious one that you have allocated 65 bits in page_t).
1. Possible packing problems. As your structs are not packed it's possible that each bitfield is occupying 64 bits.
2. The order in which the compiler allocates bits for bitfields is not specified in the C standard. It varies between processor and compiler.
Either of these may not matter in your case, or one or both may apply - I don't know which compiler you are using. The easiest way to check is to look at the tables actually produced by your code. It should be fairly obvious if there is a problem. As for bitfields, I'd avoid them and use masks instead.
All of the issues are now fixed but nothing has changed.
I am actually writing this in C++ not C, don't know about the way C++ orders bitfields, but they worked for me in the past as far as paging goes.
I use GCC cross-compiler to compile my code.
I am looking at the tables and I don't see anything interesting.
Anyways, here is the rest of my code: https://pastebin.com/BRX2va4E
I hope somebody can notice something awfully wrong.
Edit: ignore line 47
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
- eryjus
- Member
- Posts: 286
- Joined: Fri Oct 21, 2011 9:47 pm
- Libera.chat IRC: eryjus
- Location: Tustin, CA USA
Re: PAE paging problems
Did you find your 64-/65-bit problem? It's pretty evident based on the original pastebin. If you did, can you update your code so we are looking at the latest and greatest?
Also, you might want to add a static_assert since you are using C++. Something like the following would be a good addition in my opinion:
This way, the compiler can help you by double checking the structure sizes for you.
Also, you might want to add a static_assert since you are using C++. Something like the following would be a good addition in my opinion:
Code: Select all
static_assert(sizeof(page_t) == 8, "Something went wrong with the sizing of the page_t structure and needs to be corrected.");
Adam
The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal
"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal
"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
Re: PAE paging problems
Yeah I fixed the problem as soon as it was pointed out to me.eryjus wrote:Did you find your 64-/65-bit problem? It's pretty evident based on the original pastebin. If you did, can you update your code so we are looking at the latest and greatest?
Also, you might want to add a static_assert since you are using C++. Something like the following would be a good addition in my opinion:
This way, the compiler can help you by double checking the structure sizes for you.Code: Select all
static_assert(sizeof(page_t) == 8, "Something went wrong with the sizing of the page_t structure and needs to be corrected.");
I didn't know that static_assert worked in a standalone environment, that is really handy.
Anyways here is that latest code:
Code: Select all
Last edited by Octacone on Mon Jul 02, 2018 11:49 am, edited 1 time in total.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: PAE paging problems
Being rude to other posters is not the best policy when asking for help.Looks like people are very lazy when it comes to clicking.
Re: PAE paging problems
Or you could turn it around by replacing clicking with debugging.iansjack wrote:Being rude to other posters is not the best policy when asking for help.Looks like people are very lazy when it comes to clicking.
Re: PAE paging problems
That was not supposed to be rude. It is generally true, unrelated to this forum.iansjack wrote:Being rude to other posters is not the best policy when asking for help.Looks like people are very lazy when it comes to clicking.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: PAE paging problems
Well I don't think there are things left to debug. I checked if all the addresses are matching, if the tables look okay in memory, went over my code a lot of times, nothing.alexfru wrote:Or you could turn it around by replacing clicking with debugging.iansjack wrote:Being rude to other posters is not the best policy when asking for help.Looks like people are very lazy when it comes to clicking.
Just impossible to figure out.
There are just no other implementations I could cross reference, only legacy paging, no PAE.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Solved PAE paging problems
Solved!
Another stupid mistake, PAE wasn't enabled at all...
Oh boy my number had a ->bit<- extra, 33 instead of 32.
I was using 000000...b NASM notation.
Another stupid mistake, PAE wasn't enabled at all...
Oh boy my number had a ->bit<- extra, 33 instead of 32.
I was using 000000...b NASM notation.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Re: Solved PAE paging problems
And that is why I despise binary notation, especially for large numbers. Telling the difference between 8 and 9 is way easier than telling the difference between 32 and 33. Hexadecimal for LIVE!
Carpe diem!