Accessing physical memory behind the 'holes'?

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
user11924
Posts: 3
Joined: Mon Jun 27, 2011 12:33 am

Accessing physical memory behind the 'holes'?

Post by user11924 »

Is there any way to access the physical memory corresponding to the addresses that are 'holes' according to the BIOS (perhaps because there are devices mapped there or whatever)?

Or is that memory always empty, from when the computer is turned on to when it is turned off?
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Accessing physical memory behind the 'holes'?

Post by bluemoon »

There is no usable memory in the hole. It can be faulty ram that is disabled, or for any reason the BIOS don't feel like you using it.
wikiwolf
Posts: 13
Joined: Sun Apr 24, 2011 10:51 am

Re: Accessing physical memory behind the 'holes'?

Post by wikiwolf »

Devices can be remapped but BIOS areas are reserved, don't mess with them.
Memory-mapped I/O is the common method to access devices on the x86 architecture so it's unlikely you can get rid of memory gaps...
...or maybe I'm missing something. I'm not very expert, sorry.

Some useful info in the wiki:
http://wiki.osdev.org/Memory_Map_%28x86%29
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Accessing physical memory behind the 'holes'?

Post by Brendan »

Hi,

There is one case - for most modern chipsets/motherboards, the area reserved for legacy ROMs (e.g. from 0x000C0000 to 0x000EFFFF) is actually RAM. The BIOS copies "ROM images" from PCI devices into this area and then tells the memory controller to treat this area as "read only". With some special (chipset/motherboard specific) ninja hacks (and some MTRR changes), you can reclaim this RAM and gain an extra 192 KiB of RAM to play with. :)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Nable
Member
Member
Posts: 453
Joined: Tue Nov 08, 2011 11:35 am

Re: Accessing physical memory behind the 'holes'?

Post by Nable »

> extra 192 KiB of RAM
MMIO uses much more space than 192k. For example, you have 4G of RAM and framebuffer is mapped somewhere in these 4G.
6.25 or 12.5% (for rather typical 256/512M framebuffers) of memory will be lost.

Afair, one can program MTRRs to specify whether bus access will go to MMIO or RAM, am I right?
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Accessing physical memory behind the 'holes'?

Post by Griwes »

Nable wrote:> extra 192 KiB of RAM
MMIO uses much more space than 192k. For example, you have 4G of RAM and framebuffer is mapped somewhere in these 4G.
6.25 or 12.5% (for rather typical 256/512M framebuffers) of memory will be lost.

Afair, one can program MTRRs to specify whether bus access will go to MMIO or RAM, am I right?
Nowadays, you have 256TiB of virtual address space, so 256/512MiB is 9.5 * 10^-5% or 19 * 10^-5% - it doesn't really matter (I don't count physical RAM here, which is normally about 6GiB and more nowadays).
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Accessing physical memory behind the 'holes'?

Post by xenos »

My laptop has 4GB RAM installed and it has a memory hole from 0xC0000000 to 0xFFFFFFFF. However, that does not mean that 1GB of my physical RAM is inaccessible - it is simply mapped to 0x100000000 to 0x13FFFFFFF. So there really is no physical memory hidden behind that hole.

The situation may be differrent for legacy memory holes in the area 0xA0000 to 0xFFFFF.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Accessing physical memory behind the 'holes'?

Post by bluemoon »

I'm more curious on 15m-16m memory hole on legacy machine, do that memory get remapped or just get wasted?
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Accessing physical memory behind the 'holes'?

Post by Brendan »

Hi,
bluemoon wrote:I'm more curious on 15m-16m memory hole on legacy machine, do that memory get remapped or just get wasted?
I'd assume there's old motherboards (e.g. intended for 8 MiB of RAM or less) that don't remap anything in that hole when more memory is present. I'd assume there's slightly newer motherboards (e.g. intended for 16 MiB or more RAM) where RAM in that area is remapped elsewhere and others that don't. I'd also assume there's even newer motherboards (probably everything made in the last 15 years) where 1 MiB of RAM wasn't considered worth worrying about anymore. I'd also assume there's recent motherboards that don't even support the hole (as it's not used unless there's ISA devices, and ISA is "obsolete enough" now).

Unless you know the details for a specific motherboard/chipset you can't really know if the RAM gets remapped or not; and if the RAM isn't remapped you'd need a lot more details to determine if anything can be done about it anyway. For example, if a computer does have this hole, and if you had enough information to write chipset specific code to disable the hole, you'd still have to determine if there are any ISA devices using the hole before you could safely disable it. Of course ISA sucks - you'd have to manually probe for every ISA card ever created that could be using the hole just to determine if any are present.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
user11924
Posts: 3
Joined: Mon Jun 27, 2011 12:33 am

Re: Accessing physical memory behind the 'holes'?

Post by user11924 »

bluemoon wrote:There is no usable memory in the hole. It can be faulty ram that is disabled, or for any reason the BIOS don't feel like you using it.
Hmmm... but e.g. System Management Mode can definitely use RAM behind the Video RAM address range (http://fawlty.cs.usfca.edu/~cruse/cs630f06/duflot.pdf), so that's what made me wonder if you could somehow hack around for other addresses as well.
user11924
Posts: 3
Joined: Mon Jun 27, 2011 12:33 am

Re: Accessing physical memory behind the 'holes'?

Post by user11924 »

Brendan wrote:
bluemoon wrote:I'm more curious on 15m-16m memory hole on legacy machine, do that memory get remapped or just get wasted?
Unless you know the details for a specific motherboard/chipset you can't really know if the RAM gets remapped or not; and if the RAM isn't remapped you'd need a lot more details to determine if anything can be done about it anyway. For example, if a computer does have this hole, and if you had enough information to write chipset specific code to disable the hole, you'd still have to determine if there are any ISA devices using the hole before you could safely disable it. Of course ISA sucks - you'd have to manually probe for every ISA card ever created that could be using the hole just to determine if any are present.

That's interesting, cool!
Post Reply