Some Memory Related Quries

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
skada
Posts: 4
Joined: Sun May 30, 2010 7:26 am

Some Memory Related Quries

Post by skada »

Hi all, my first post!
I have 12M memory and no paging enabled (so linear address = phy add ?) and only 2 gdt entries (no user space) then
shouldn't asm volatile ("mov 0x1ef0000,%eax") produce some error ?
but as it seems it works fine. What is the thing that I am missing ?
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Some Memory Related Quries

Post by Gigasoft »

No, there is no data abort exception on x86, so no error will be detected.
skada
Posts: 4
Joined: Sun May 30, 2010 7:26 am

Re: Some Memory Related Quries

Post by skada »

so I can go on accessing all the mem upto 4gb and nothing will happen ? kinda odd..
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Some Memory Related Quries

Post by Creature »

berkus wrote:Do you have segment limit on your GDT entries? If you limit them to 12Mb you should get a protection fault when accessing outside that segment.
The unfortunate thing is that some devices might use higher physical memory addresses for buffers (e.g. Bochs' 0xE0000000 LFB address), which you would be restricting yourself from using as well (I think), but I may be wrong.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Some Memory Related Quries

Post by gerryg400 »

so I can go on accessing all the mem upto 4gb and nothing will happen ? kinda odd..
It is actually paging that provides memory protection and isolation in most modern OS designs. The reason that you can access all memory is that paging is disabled and presumably your segment limits are large. Enable paging and you'll get plenty of faults.
If a trainstation is where trains stop, what is a workstation ?
skada
Posts: 4
Joined: Sun May 30, 2010 7:26 am

Re: Some Memory Related Quries

Post by skada »

yup.. it seems if paging is disabled then if I access any memory which is not present (above 12MB in this case) the data returned is FFFF ...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Some Memory Related Quries

Post by Combuster »

That has nothing to do with paging being disabled...
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Kenny
Member
Member
Posts: 29
Joined: Thu Mar 01, 2007 7:42 am

Re: Some Memory Related Quries

Post by Kenny »

As far as the processor is concerned, it has 4GB of memory that it can access, it doesn't know that the memory space is actually full of system RAM, BIOS ROM, device buffers, device ROM, and a fairly large number of holes where no memory exists.

What segmentation and / or paging (virtual memory) do is make the processor restrict what from this 4GB space the code is allowed to access. Setting a segment size of 8MB and trying to access memory above that cause an Int 0x13 General Protection Fault. Enabling paging and accessing memory that isn't mapped with cause a Page Fault.

If, from these methods, the processor has decided that it is allowed to access that memory address, it sends a request to other parts of the system (the North Bridge, PCI bus, whatever is mapped to that address) and waits for a response. It is for electrical reasons (the way the processor interprets the signals on the wires) that you get 0xFF returned if you try to read memory that doesn't exist.

Just to complicate matters, it is possible that if you try to read non-existent memory, that the memory controller will step in and return sometihng other than 0xFF, possibly 0x00, possibly even the last value that written to the data bus. It is also feasible that due to memory caching, you could write a value into a memory hole and then read it back correctly.

If you are interested in finding out which blocks of memory your system has available, there are a number of BIOS calls that can be made, more information can be found on http://wiki.osdev.org/Detecting_Memory_%28x86%29.

Hope this helps
Post Reply