OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:33 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Solved PAE paging problems
PostPosted: Sun Jul 01, 2018 3:36 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
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?

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Last edited by Octacone on Mon Jul 02, 2018 11:55 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: PAE questions
PostPosted: Sun Jul 01, 2018 4:11 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
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.


Top
 Profile  
 
 Post subject: Re: PAE questions
PostPosted: Sun Jul 01, 2018 12:56 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
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.


65? I went over that thing like 50 times and didn't notice it...
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


Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Sun Jul 01, 2018 4:36 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
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:

Code:
static_assert(sizeof(page_t) == 8, "Something went wrong with the sizing of the page_t structure and needs to be corrected.");


This way, the compiler can help you by double checking the structure sizes for you.

_________________
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


Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Mon Jul 02, 2018 5:56 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
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:

Code:
static_assert(sizeof(page_t) == 8, "Something went wrong with the sizing of the page_t structure and needs to be corrected.");


This way, the compiler can help you by double checking the structure sizes for you.


Yeah I fixed the problem as soon as it was pointed out to me.
I didn't know that static_assert worked in a standalone environment, that is really handy.

Anyways here is that latest code:
Code:

I know it's a lot of code but this way people will see it. 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


Last edited by Octacone on Mon Jul 02, 2018 11:49 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Mon Jul 02, 2018 8:31 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
Quote:
Looks like people are very lazy when it comes to clicking.
Being rude to other posters is not the best policy when asking for help.


Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Mon Jul 02, 2018 10:13 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1108
iansjack wrote:
Quote:
Looks like people are very lazy when it comes to clicking.
Being rude to other posters is not the best policy when asking for help.


Or you could turn it around by replacing clicking with debugging. :)


Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Mon Jul 02, 2018 10:15 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
iansjack wrote:
Quote:
Looks like people are very lazy when it comes to clicking.
Being rude to other posters is not the best policy when asking for help.


That was not supposed to be rude. It is generally true, unrelated to this forum.

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: PAE paging problems
PostPosted: Mon Jul 02, 2018 10:21 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
alexfru wrote:
iansjack wrote:
Quote:
Looks like people are very lazy when it comes to clicking.
Being rude to other posters is not the best policy when asking for help.


Or you could turn it around by replacing clicking with debugging. :)


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.
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


Top
 Profile  
 
 Post subject: Solved PAE paging problems
PostPosted: Mon Jul 02, 2018 11:55 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
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.

_________________
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader


Top
 Profile  
 
 Post subject: Re: Solved PAE paging problems
PostPosted: Mon Jul 02, 2018 10:06 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 74 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group