OSDev.org

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

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: physical memory access on addresses larger than 4GB (64bit)
PostPosted: Mon Jan 15, 2018 2:24 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
Hi,
I''m having some problems with memory access,
my os is setup as follows on VMWare

I've setup the machine to 4GB and i got the following address map from e820
edit:
the same problem exists even when i use 8GB of ram.

the format is base, limit, type
Code:
0000000000009F400 000000000009FFFF 0002
000000000000CE000 00000000000CFFFF 0002
000000000000DC000 00000000000FFFFF 0002
00000000000100000 00000000BFEDFFFF 0001
000000000BFEE0000 00000000BFEFEFFF 0003
000000000BFEFF000 00000000BFEFFFFF 0004
000000000BFF00000 00000000BFFFFFFF 0001
000000000F0000000 00000000F7FFFFFF 0002
000000000FEC00000 00000000FEC0FFFF 0002
000000000FEE00000 00000000FEE00FFF 0002
000000000FFFE0000 00000000FFFFFFFF 0002
00000000100000000 000000013FFFFFFF 0001


as you can see the last region is accessible and i wish to write to that region.
I've setup my machine to long mode with a cr3 which has identity mapping accross 16GB of ram
and still the machine crashes when i try and access that region.


Last edited by algawi86 on Mon Jan 15, 2018 3:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 2:55 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
If you only have 4GB of RAM and your memory is identity mapped, you obviously can't access RAM above 4GB.


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 2:59 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
the code for building the cr3 does not take into account the actual size of ram, it just maps 16GB of ram to itself.
even when i set the machine to 8GB i get the same results.

So in reality when e820 states i have an address which is accessible i should be able to read and write from it.


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 3:29 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
How do you expect to be able to read/write memory that doesn't exist?


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 3:32 am 
Offline

Joined: Wed Feb 01, 2017 6:48 am
Posts: 10
if e820 tells me the range 00000000100000000:000000013FFFFFFF is accessible, why can't i use it ?


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 4:35 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
It's always possible that there is an error in your memory-detection routine. It shouldn't tell you that non-present memory is accessible.

It's also possible that there is an error in your page-mapping code.

The simpe fact remains - if memory isn't present then you can't read or write it.


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Mon Jan 15, 2018 10:19 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1110
Location: Tartu, Estonia
The memory map looks correct to me - I get the same in my 4GB laptop (also under Linux). Obviously RAM is located at physical addresses 0-3GB and 4-5GB, to have a memory hole for other things in the 3-4GB area. The RAM above that hole should be accessible.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: physical memory access on addresses larger than 4GB (64b
PostPosted: Tue Jan 16, 2018 10:59 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
iansjack wrote:
The simpe fact remains - if memory isn't present then you can't read or write it.

You can, but it won't do anything useful. There's no "nonexistent hardware" exception in x86.

If your code is crashing due to an exception, then you've most likely configured the page tables wrong.


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: Bing [Bot], Google [Bot], Kamal123 and 65 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