physical memory access on addresses larger than 4GB (64bit)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
algawi86
Posts: 10
Joined: Wed Feb 01, 2017 6:48 am
Libera.chat IRC: asaf_algawi

physical memory access on addresses larger than 4GB (64bit)

Post by algawi86 »

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: Select all

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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: physical memory access on addresses larger than 4GB (64b

Post by iansjack »

If you only have 4GB of RAM and your memory is identity mapped, you obviously can't access RAM above 4GB.
algawi86
Posts: 10
Joined: Wed Feb 01, 2017 6:48 am
Libera.chat IRC: asaf_algawi

Re: physical memory access on addresses larger than 4GB (64b

Post by algawi86 »

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.
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: physical memory access on addresses larger than 4GB (64b

Post by iansjack »

How do you expect to be able to read/write memory that doesn't exist?
algawi86
Posts: 10
Joined: Wed Feb 01, 2017 6:48 am
Libera.chat IRC: asaf_algawi

Re: physical memory access on addresses larger than 4GB (64b

Post by algawi86 »

if e820 tells me the range 00000000100000000:000000013FFFFFFF is accessible, why can't i use it ?
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: physical memory access on addresses larger than 4GB (64b

Post by iansjack »

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.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: physical memory access on addresses larger than 4GB (64b

Post by xenos »

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
Octocontrabass
Member
Member
Posts: 5586
Joined: Mon Mar 25, 2013 7:01 pm

Re: physical memory access on addresses larger than 4GB (64b

Post by Octocontrabass »

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