OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 9:38 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: is CR3 physical,linear or virtual ?
PostPosted: Sun Apr 23, 2017 4:36 pm 
Offline

Joined: Tue Apr 18, 2017 6:02 pm
Posts: 13
I'm trying to use paging and i hit a road block.
im trying to load the page directory into CR3 but it tripple faults even tho i am 99% sure that the directory and the tables are correct

Here is my problem:

after loading the second stage i do following things:

Identity page 0x0 - 0x400000 (because it fills a whole table)
Map 0x100000 to 0xC0000000 (im doing higher half kernel)
set cr3 to the page directory
enable paging

load kernel into 0xc0100000 and put stack at 0xc00FFFFF

execute kernel:

kernel creates page tables and page directories (Identity page 0x0 - 0x100000 and map 0x100000 to 0xC0000000)
kernel sets cr3 to new page directory address
Tripple fault

now lets say the directory is stored at 0xc0200000 (physical address 0x300000)
do i have to set cr3 to 0xc0200000 or 0x300000 ?(i have gdt mapped from 0x0 to 0xFFFFFFFF so linear = physical)

and i didnt have problems in the second stage bootloader because its Identity maped and virtual would equal to physical

Sry for bad english it is not my first language.


Top
 Profile  
 
 Post subject: Re: is CR3 physical,linear or virtual ?
PostPosted: Sun Apr 23, 2017 5:09 pm 
Offline
Member
Member
User avatar

Joined: Thu Aug 06, 2015 6:41 am
Posts: 97
Location: Netherlands
cr3 is supposed to be the physical address of your page directory. You should look at the logs of your emulator (or better yet, let your kernel print the exceptions to screen and loop forever) to see which exception (and error code) caused a tripple fault and look it up here, that might help to get an idea of the possible causes. Register contents can usually also be found in logs, which could be useful to check if your code actually wrote the right address to cr3.


Top
 Profile  
 
 Post subject: Re: is CR3 physical,linear or virtual ?
PostPosted: Sun Apr 23, 2017 6:28 pm 
Offline
Member
Member

Joined: Sat Feb 27, 2010 8:55 pm
Posts: 147
SeeSoftware wrote:
now lets say the directory is stored at 0xc0200000 (physical address 0x300000)
do i have to set cr3 to 0xc0200000 or 0x300000 ?

0x300000


SeeSoftware wrote:
linear = physical

I don't want to sound like I'm nit-picking, but you have to be very precise in your vocabulary (otherwise you just end up confusing yourself!)
Setting up flat mode means offsets = linear address; your GDT alone tells us nothing about physical addresses.

SeeSoftware wrote:
(i have gdt mapped from 0x0 to 0xFFFFFFFF...

Generally we'd say we set up flat mode; I generally see "mapping" to refer to pages rather than segments.

SeeSoftware wrote:
Sry for bad english it is not my first language.

I think you did pretty good; I had no trouble understanding you :)


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 197 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