Page 1 of 2
paging questions
Posted: Mon Sep 01, 2003 5:26 pm
by beyondsociety
If we later enable paging, and map address 0xC000.0000 to 0x0010.0000 (and use a segment with base address zero), the same address will continue to be used.
Q1. What do you mean my using a segment with base address zero?
Memory Mapping
1. Map all physical memory into the address space. This can be either done 1:1 (physical memory is addressed by the bottom of the address space or at some offset (physical memory accessible starting at say 0xD000.0000). This approachs advantage is its simplicity; however, its disadvantage is the fact that the user may have any amount of memory installed in their system, all of which must be addressable.
Q2. Win NT maps upto 512MB of physical memory to the kernels address space. Why would they do this? My guess is there assuming that everybody has at least 512MB of Memory?
it has the disadvantage that you can only access page mappings inside the current address space. This is referrng to option 3 under memory mapping.
Q3. How can you get around this disadvantage?
Q4. Is it better to put the page tables at a address below or above the page directory address?
If you chosen to put your kernel in the bottom half and your application in the top half, your stuck unless you re-map the first 1MB so that its accessable to ring 3 and make sure theres nothing important here.
Q5. What do you mean by bottom half versus top half when it comes to this statement?
Re:paging questions
Posted: Tue Sep 02, 2003 1:45 am
by Solar
beyondsociety wrote:
Q1. What do you mean by using a segment with base address zero?
It is a common approach to define CS (code segment), DS (data segment) and SS (stack segment) as starting at address 0, ending at address 2^32-1, and just forgetting about memory segments from there on.
This effectively disables the memory segment feature of the IA-32, and is called "flat memory model". As I learned, most compilers don't support anything else
but flat memory.
Re:paging questions
Posted: Tue Sep 02, 2003 1:51 am
by Pype.Clicker
Solar wrote:
As I learned, most compilers don't support anything else but flat memory.
Keep faith, my young paddawan ... things are not *that* deseperate. GCC do not support the full extend of IA32 segmentations promises, but it can handle situations more complex than pure flat model provided that you don't break the rule SS.base == DS.base ...
look at
this post to know what i'm talkin' about
Re:paging questions
Posted: Tue Sep 02, 2003 2:38 am
by BI lazy
padawan ... *lol* this makes me think of "May The Schwartz Be With You" ... yeah, beware of the daaaark side of computing ];->
Re:paging questions
Posted: Tue Sep 02, 2003 2:46 am
by Solar
Pype.Clicker wrote:
Keep faith, my young paddawan ...
Erm... we have a problem here - I call
Lennart "young padawan" already...
(Sorry, insider joke.
)
Re:paging questions
Posted: Tue Sep 02, 2003 5:08 am
by Pype.Clicker
beyondsociety wrote:
Q4. Is it better to put the page tables at a address below or above the page directory address?
None is better, afaik. Put your page tables & directories wherever you want.
Q5. What do you mean by bottom half versus top half when it comes to this statement?
A common design choice is to split the available address space in 2 parts: the
kernel space and the
user space. Kernel space is usually the very same in every address space while the user space content depend on the currently active process.
This "barrier" define two halves in the address space (despites the two halves usually don't have the same size, but sounds like "half" has become a widely used term here ...)
Whether you decide to put your kernel in addresses [0..barrier] (bottom half) or [barrier..0xffffffff] (top half) is up to you. Bottom half is easier to initialize because you can usually assume that physical memory is large enough and keep the very same configuration before and after paging setup.
Installing your kernel in the top half is a bit more complicated to set up but you'll have the opportunity of running VM86 as user-mode code with completely protected kernel.
Re:paging questions
Posted: Tue Sep 02, 2003 5:09 am
by Pype.Clicker
For your other questions, maybe providing a link to the thread/page/whatever you're quoting would be helpful.
Re:paging questions
Posted: Tue Sep 02, 2003 6:27 am
by Tim
Looks like the MM tutorials I wrote.
beyondsociety: have all your questions been answered?
Re:paging questions
Posted: Tue Sep 02, 2003 6:52 am
by Pype.Clicker
Re:paging questions
Posted: Tue Sep 02, 2003 7:44 am
by beyondsociety
Looks like the MM tutorials I wrote.
beyondsociety: have all your questions been answered?
Two and three havent been answered.
Also, I am thinking of loading my kernel to 1GB and then loading the user address space higher up like at 2-3GB.
I thinking of puttting vm86 from 1MB -1GB. Is there any problems with this? Could I load it to a higher address like in between the kernel and user?
Re:paging questions
Posted: Tue Sep 02, 2003 9:00 am
by Solar
beyondsociety wrote:
I am thinking of loading my kernel to 1GB and then loading the user address space higher up like at 2-3GB.
Depending on what your OS is aimed for, remember that address space itself can be a valuable ressource. There are server applications out there that wouldn't like being taken away half of the available address space.
Re:paging questions
Posted: Tue Sep 02, 2003 9:38 am
by beyondsociety
My os is going to be a high-end desktop meaning that its should be capable of doing the normal desktop os stuff but also be able to meet my programming and engineering needs.
With this in mind, where do you think I should load my kernel and user address space?
Re:paging questions
Posted: Tue Sep 02, 2003 9:46 am
by Pype.Clicker
imho, 3GB of user addressable memory is the strict minimum if you want to allow for applications like video manipulations, heavy 3D or math computations, etc.
Re:paging questions
Posted: Tue Sep 02, 2003 10:13 am
by Tim
beyondsociety wrote:Q2. Win NT maps upto 512MB of physical memory to the kernels address space. Why would they do this? My guess is there assuming that everybody has at least 512MB of Memory?
They assume that most of the time, arbitrary accesses to physical memory will need addresses below 512MB. Normal allocations (i.e. malloc and VirtualAlloc) allocate regions of virtual address space, which can be backed by physical memory at any address (even above 512MB, and even above 4GB if AWE is enabled).
But often drivers will want to access arbitrary physical addresses which won't necessarily have permanent mappings. In general, the Windows kernel could map virtual addresses for these physical addresses temporarily, and unmap them when finished. A quicker way of doing this, which doesn't require any TLB flushes, is to map some physical memory all the time. And if you have 512MB of RAM or less installed, Windows will never need to do any temporary mappings.
it has the disadvantage that you can only access page mappings inside the current address space. This is referrng to option 3 under memory mapping.
Q3. How can you get around this disadvantage?
Access the other process's PT/PD manually, through its physical address.
Re:paging questions
Posted: Tue Sep 02, 2003 12:16 pm
by beyondsociety
In general, the Windows kernel could map virtual addresses for these physical addresses temporarily, and unmap them when finished.
A quicker way of doing this, which doesn't require any TLB flushes, is to map some physical memory all the time. And if you have 512MB of RAM or less installed, Windows will never need to do any temporary mappings.
How much physical memory should you map if you were to use the quicker way?