OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 1:00 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 2:01 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
hi,
i was trying to implement paging, it was fast at first, all was doing great, but after i created a blank dir, and fill the table index, i have to initializate paging, and there's where the problem comes.inmediately when the paging is enabling, i got a triple fault, and comes back to grub.i couldn't solve it by my own or searching it in google.

Thanks!


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 2:17 pm 
Offline
Member
Member
User avatar

Joined: Fri Aug 07, 2015 6:13 am
Posts: 1134
That is not enough info. It would be useful to see your code/know if you've used any tutorials.
What's the error code you're getting and what's the faulting address (see CR2 register)?
Triple faults (page faults in this case) can be caused by a variety of things.

For starters make sure:
1. CR3 holds a PHYSICAL address.
2. Your paging structures are mapped correctly, accessing them if not mapped leads to a page fault.
3. Your kernel is mapped correctly, aka PHYSICAL = VIRTUAL (if there is no higher half setup, if there is that's a different story)

Where is your kernel located (higher/lower half)?
Without any other info we can only guess.
Run it in Bochs and tell us what happens.

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


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 2:34 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
you can see my code in the github page that's below of the message. i've used the osdever paging page, Paging, and Setting Up Paging.the kernel is in the lower half.when i run bochs, the last thing that says is: ''[CPU0] WARNING: HLT instruction with IF=0!"

Thanks!


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 2:55 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 21, 2011 9:47 pm
Posts: 286
Location: Tustin, CA USA
Where exactly are your page tables? I could not find a Page Directory or any Page Table. I could not find an place where they might be initialized (statically or runtime).

I am looking for the code in your initialization that will, at minimum:
* Allocate a 4096-byte block of memory that is 4K aligned for the Page Directory
* Clear that block of memory
* Allocate another 4096-byte block of memory that is 4K aligned for the kernel Page Table
* Clear that block of memory
* Determine the PD entry for the running kernel
* Install the kernel Page Table in the correct Page Directory Entry (physical address, mind)
* Determine the proper kernel Page Table entries for the running kernel
* Install the kernel physical memory frames into the kernel Page Table in the proper entries
* Install the Page Directory into the cr3 register (physical address, mind)
* Enables paging

Failing to build all these structures, paging will not work if you try to enable it and you will Page Fault with the very next instruction. Your Page Fault handler code will not be locatable and you will Double Fault. Your Double Fault code will not be locatable and you will triple fault.

_________________
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: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 3:08 pm 
Offline
Member
Member
User avatar

Joined: Mon Jan 15, 2018 2:27 pm
Posts: 201
IMO. Getting paging right is one of the most confusing things in OS development. But it's just like riding a bike. Once you get it right you don't forget it (no matter what architecture).


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 7:49 pm 
Offline
Member
Member
User avatar

Joined: Tue Mar 06, 2007 11:17 am
Posts: 1225
Does CR2 contain a page address or an unaligned address?

I suspect that it would contain the exact address that failed and it would need to be manually aligned to 4096 bytes (or the size of pages) to find out the faulting page, but I don't know.

_________________
Live PC 1: Image Live PC 2: Image

YouTube:
http://youtube.com/@AltComp126/streams
http://youtube.com/@proyectos/streams

http://master.dl.sourceforge.net/projec ... 7z?viasf=1


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Tue Nov 27, 2018 11:19 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1604
Yes, CR2 contains the entire failed address. If it failed, the processor can't know the page size, right? (Well, OK, unless it failed due to permissions)

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: Trying to enable paging causes triple faulting
PostPosted: Wed Nov 28, 2018 4:30 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
hi,
sorry for make no response.i've found the problem, i forgot to blank the page directory and fill the table index.sorry if i bothered with this!

Thanks!


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: IlcIliaDev, rdos and 123 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