All of lore.kernel.org
 help / color / mirror / Atom feed
* Why "high memory" in x86?
@ 2006-08-01  5:48 Rajat Jain
  2006-08-01  9:18 ` Rajendra
       [not found] ` <20060801090248.4aad8a39@thomas.toulouse>
  0 siblings, 2 replies; 13+ messages in thread
From: Rajat Jain @ 2006-08-01  5:48 UTC (permalink / raw)
  To: kernelnewbies, linux-newbie

Hi list,

I recently read that the concept of "High Memory" was introduced
because certain architectures are capable of physically addressing
larger amounts of memory than they can virtually address (physical
address space > virtual address space). I also read that nowadays
"high Memory" exists only in x86.

1) Why is virtual memory > 896 MB on x86 designated as high memory?
AFAIK x86 has 4 GB of virtual address space (=physical address space?)

2) Has the "high Memory" concept got anything to do with PAE (Page
Address Extention) feature of x86?

3) Do any other architectures than x86 have the concept of high memory?

TIA,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-01  5:48 Why "high memory" in x86? Rajat Jain
@ 2006-08-01  9:18 ` Rajendra
  2006-08-01 13:51   ` Dave B. Sharp
       [not found] ` <20060801090248.4aad8a39@thomas.toulouse>
  1 sibling, 1 reply; 13+ messages in thread
From: Rajendra @ 2006-08-01  9:18 UTC (permalink / raw)
  Cc: kernelnewbies, linux-newbie

The reason for the high memory is this.

   o Linux divides the address space into two parts, user and kernel.
   o Kernel gets 1 GB of address space while user gets 3GB virtual 
address space.
   o Kernel needs to access all of the  memory so ideally it needs 4 GB 
of virtual addresses.
   o But since only 1 GB (i.e. beyond 0xc000 0000) is available, so we 
call the rest as
      high memory (approx 3 GB)
   o The high memory is accessed using temp. page table entries that map 
the high memory
      areas in kernel address space.
   o The high memory region is mostly allocated to the user space programs.
  
hope it answers the question !

regd,
~rpm
Rajat Jain wrote:

> Hi list,
>
> I recently read that the concept of "High Memory" was introduced
> because certain architectures are capable of physically addressing
> larger amounts of memory than they can virtually address (physical
> address space > virtual address space). I also read that nowadays
> "high Memory" exists only in x86.
>
> 1) Why is virtual memory > 896 MB on x86 designated as high memory?
> AFAIK x86 has 4 GB of virtual address space (=physical address space?)
>
> 2) Has the "high Memory" concept got anything to do with PAE (Page
> Address Extention) feature of x86?
>
> 3) Do any other architectures than x86 have the concept of high memory?
>
> TIA,
>
> Rajat
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
       [not found] ` <20060801090248.4aad8a39@thomas.toulouse>
@ 2006-08-01  9:53   ` Rajat Jain
  2006-08-01 12:09     ` Rajat Jain
  0 siblings, 1 reply; 13+ messages in thread
From: Rajat Jain @ 2006-08-01  9:53 UTC (permalink / raw)
  To: Thomas Petazzoni, chauhan_ait, clucas; +Cc: kernelnewbies, linux-newbie

On 8/1/06, Thomas Petazzoni <thomas.petazzoni@enix.org> wrote:
> Hi,
>
> Le Tue, 1 Aug 2006 11:18:16 +0530,
> "Rajat Jain" <rajat.noida.india@gmail.com> a écrit :
>
> > I recently read that the concept of "High Memory" was introduced
> > because certain architectures are capable of physically addressing
> > larger amounts of memory than they can virtually address (physical
> > address space > virtual address space). I also read that nowadays
> > "high Memory" exists only in x86.
> >
> > 1) Why is virtual memory > 896 MB on x86 designated as high memory?
> > AFAIK x86 has 4 GB of virtual address space (=physical address space?)
> >
>
> If you're talking about CONFIG_HIGHMEM, then no, it's not really
> designed for when you have more physical memory than it's possible to
> virtually access. It's because the Linux kernel decided to split all
> 4GB virtual address spaces into two parts: 3 GB for the application, 1
> GB for the kernel. The 1 GB for the kernel is an identity mapping of
> the physical memory, which allows the kernel to access very simply all
> the physical memory.
>
> However, it has the drawback that when having more than 1 GB of
> physical memory, things get harder. CONFIG_HIGHMEM allows to access
> more than 1 GB of physical memory. It does it by mapping temporarly
> physical pages that are above 1 GB. In fact, it's not 1 GB that is
> identically-mapped, but 896 MB, the rest (1 GB - 896 MB) is used for the
> temporary mappings needed to access pages above 896 MB.
>
> My explanation might be a bit confusing (it's early in the morning,
> here). I'd suggest you to read « Understanding the Linux Virtual Memory
> Manager »,
> http://www.phptr.com/content/images/0131453483/downloads/gorman_book.pdf
>
> > 2) Has the "high Memory" concept got anything to do with PAE (Page
> > Address Extention) feature of x86?
>
> I don't think so.
>
> > 3) Do any other architectures than x86 have the concept of high
> > memory?
>
> 64 bits architecture, no. Other 32 bits architecture, maybe, but I'm
> not sure.
>
> Sincerly,
>
> Thomas
> --

Thanks every one. But perhaps I could not make my doubt very clear. My
very first doubt is that since kernel and each of the user process
have its own seperate virtual address space, why does the VIRTUAL
address space has to be split up betwen kernel and user process? Why
is the kernel limited to using only 1 GB of the available 4 GB virtual
address space? What is the limitation to overcome which, the temporary
mapping solution was proposed (Can't we map all of 4 GB permanently)?

My second doubt is whether the lowest 1 GB (0->1 GB) or the highest 1
GB (3->4 GB) physical addresses are mapped to kernel virtual
addresses? If the highest 1 GB addresses are permanently identity
mapped, shouldn't the "high memory" exist below 3 GB virtual addresses
(rather than above 896 MB virtual addresses)?

What am I missing?

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-01  9:53   ` Rajat Jain
@ 2006-08-01 12:09     ` Rajat Jain
  0 siblings, 0 replies; 13+ messages in thread
From: Rajat Jain @ 2006-08-01 12:09 UTC (permalink / raw)
  To: Thomas Petazzoni, chauhan_ait, clucas; +Cc: kernelnewbies, linux-newbie

>
> What am I missing?
>
> Thanks,
>
> Rajat
>

Sorry & thanks every one ... I missed out that the kernel is actually
executing on the behalf of a user process only, and is hence sharing
its virtual address space with a user process all the time. My doubts
are clarified.

However, what is meant when we that the 1 GB of physical memory is
"identity mapped" to 1 GB kernel virtual address space? I think it
means that all the user processes have have the 3GB->4GB virtual
addresses mapped to the kernel code & data. Is this right?

Thanks,

Rajat
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-01  9:18 ` Rajendra
@ 2006-08-01 13:51   ` Dave B. Sharp
  2006-08-02  4:25     ` Rajendra
  0 siblings, 1 reply; 13+ messages in thread
From: Dave B. Sharp @ 2006-08-01 13:51 UTC (permalink / raw)
  To: kernelnewbies, Linux Newbie

Yes, but why is only 1GB of memory "available"? The
whole address space is available to other kernels.

  Dave Sharp

--- Rajendra <rpm@solidcore.com> wrote:

> The reason for the high memory is this.
> 
>    o Linux divides the address space into two parts,
> user and kernel.
>    o Kernel gets 1 GB of address space while user
> gets 3GB virtual 
> address space.
>    o Kernel needs to access all of the  memory so
> ideally it needs 4 GB 
> of virtual addresses.
>    o But since only 1 GB (i.e. beyond 0xc000 0000)
> is available, so we 
> call the rest as
>       high memory (approx 3 GB)
>    o The high memory is accessed using temp. page
> table entries that map 
> the high memory
>       areas in kernel address space.
>    o The high memory region is mostly allocated to
> the user space programs.
>   
> hope it answers the question !
> 
> regd,
> ~rpm
> Rajat Jain wrote:
> 
> > Hi list,
> >
> > I recently read that the concept of "High Memory"
> was introduced
> > because certain architectures are capable of
> physically addressing
> > larger amounts of memory than they can virtually
> address (physical
> > address space > virtual address space). I also
> read that nowadays
> > "high Memory" exists only in x86.
> >
> > 1) Why is virtual memory > 896 MB on x86
> designated as high memory?
> > AFAIK x86 has 4 GB of virtual address space
> (=physical address space?)
> >
> > 2) Has the "high Memory" concept got anything to
> do with PAE (Page
> > Address Extention) feature of x86?
> >
> > 3) Do any other architectures than x86 have the
> concept of high memory?
> >
> > TIA,
> >
> > Rajat
> > -
> > To unsubscribe from this list: send the line
> "unsubscribe 
> > linux-newbie" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at 
> http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at
> http://www.linux-learn.org/faqs
> >
> 
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at 
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at
> http://www.linux-learn.org/faqs
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-01 13:51   ` Dave B. Sharp
@ 2006-08-02  4:25     ` Rajendra
  2006-08-02 16:37       ` Ritesh Kumar
  0 siblings, 1 reply; 13+ messages in thread
From: Rajendra @ 2006-08-02  4:25 UTC (permalink / raw)
  Cc: kernelnewbies, Linux Newbie

When protection and paging is switched on the processor, it requires valid
page tables entry for every page that is accessed. Now there are only 4 GB
addresses that are available, so we have to divide it in such a way that the
kernel as well as the user can access it. So what we do is we say that first
three GB address will always be user space address. The page table entries
of these will keep on changing as the process loads, allocates and 
deallocates
memory. While the last 1 GB i.e. from 3 GB to 4 GB is given to kernel and
it's page table entries are always present in the processor page tables. 
The kernel
address are hence identity mapped i.e.  phy_addr = (virt_addr << 4) >> 
4. Since
the kernel is the program that manages all the resources including 
memory, so it needs
access to all the memory that is there in the system, so for regions of 
memory
above 1 GB (physical), we use special mechanism and call it as high memory.

~rpm

Dave B. Sharp wrote:

>Yes, but why is only 1GB of memory "available"? The
>whole address space is available to other kernels.
>
>  Dave Sharp
>
>--- Rajendra <rpm@solidcore.com> wrote:
>
>  
>
>>The reason for the high memory is this.
>>
>>   o Linux divides the address space into two parts,
>>user and kernel.
>>   o Kernel gets 1 GB of address space while user
>>gets 3GB virtual 
>>address space.
>>   o Kernel needs to access all of the  memory so
>>ideally it needs 4 GB 
>>of virtual addresses.
>>   o But since only 1 GB (i.e. beyond 0xc000 0000)
>>is available, so we 
>>call the rest as
>>      high memory (approx 3 GB)
>>   o The high memory is accessed using temp. page
>>table entries that map 
>>the high memory
>>      areas in kernel address space.
>>   o The high memory region is mostly allocated to
>>the user space programs.
>>  
>>hope it answers the question !
>>
>>regd,
>>~rpm
>>Rajat Jain wrote:
>>
>>    
>>
>>>Hi list,
>>>
>>>I recently read that the concept of "High Memory"
>>>      
>>>
>>was introduced
>>    
>>
>>>because certain architectures are capable of
>>>      
>>>
>>physically addressing
>>    
>>
>>>larger amounts of memory than they can virtually
>>>      
>>>
>>address (physical
>>    
>>
>>>address space > virtual address space). I also
>>>      
>>>
>>read that nowadays
>>    
>>
>>>"high Memory" exists only in x86.
>>>
>>>1) Why is virtual memory > 896 MB on x86
>>>      
>>>
>>designated as high memory?
>>    
>>
>>>AFAIK x86 has 4 GB of virtual address space
>>>      
>>>
>>(=physical address space?)
>>    
>>
>>>2) Has the "high Memory" concept got anything to
>>>      
>>>
>>do with PAE (Page
>>    
>>
>>>Address Extention) feature of x86?
>>>
>>>3) Do any other architectures than x86 have the
>>>      
>>>
>>concept of high memory?
>>    
>>
>>>TIA,
>>>
>>>Rajat
>>>-
>>>To unsubscribe from this list: send the line
>>>      
>>>
>>"unsubscribe 
>>    
>>
>>>linux-newbie" in
>>>the body of a message to majordomo@vger.kernel.org
>>>More majordomo info at 
>>>      
>>>
>>http://vger.kernel.org/majordomo-info.html
>>    
>>
>>>Please read the FAQ at
>>>      
>>>
>>http://www.linux-learn.org/faqs
>>    
>>
>>-
>>To unsubscribe from this list: send the line
>>"unsubscribe linux-newbie" in
>>the body of a message to majordomo@vger.kernel.org
>>More majordomo info at 
>>http://vger.kernel.org/majordomo-info.html
>>Please read the FAQ at
>>http://www.linux-learn.org/faqs
>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>-
>To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at http://www.linux-learn.org/faqs
>
>  
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-02  4:25     ` Rajendra
@ 2006-08-02 16:37       ` Ritesh Kumar
  2006-08-03  5:20         ` Rajendra
  0 siblings, 1 reply; 13+ messages in thread
From: Ritesh Kumar @ 2006-08-02 16:37 UTC (permalink / raw)
  To: Rajendra; +Cc: kernelnewbies, Linux Newbie

[-- Attachment #1: Type: text/plain, Size: 4875 bytes --]

On 8/2/06, Rajendra <rpm@solidcore.com> wrote:
>
> When protection and paging is switched on the processor, it requires valid
> page tables entry for every page that is accessed. Now there are only 4 GB
> addresses that are available, so we have to divide it in such a way that
> the
> kernel as well as the user can access it. So what we do is we say that
> first
> three GB address will always be user space address. The page table entries
> of these will keep on changing as the process loads, allocates and
> deallocates
> memory. While the last 1 GB i.e. from 3 GB to 4 GB is given to kernel and
> it's page table entries are always present in the processor page tables.
> The kernel
> address are hence identity mapped i.e.  phy_addr = (virt_addr << 4) >>
> 4. Since
> the kernel is the program that manages all the resources including
> memory, so it needs
> access to all the memory that is there in the system, so for regions of
> memory
> above 1 GB (physical), we use special mechanism and call it as high
> memory.
>
> ~rpm



There is a very good thread/article on kerneltrap discussing high memory and
the memory split. However, another thought came to my mind while reading
this.
Why does the kernel really have to map all the memory pages in its 1GB
address space? If the memory is (only) mapped in the lower 3GB, the kernel
sill can access it right? The kernel just might need to be a little careful
when dealing with memory in the lower 3GB space as 1) it might change on the
next context switch 2) Its not trusted.
The basic advantage would be being able to use all the 4GB of RAM on a 32
bit machine without any HighMem overhead.

Ritesh

> Dave B. Sharp wrote:
>
> >Yes, but why is only 1GB of memory "available"? The
> >whole address space is available to other kernels.
> >
> >  Dave Sharp
> >
> >--- Rajendra <rpm@solidcore.com> wrote:
> >
> >
> >
> >>The reason for the high memory is this.
> >>
> >>   o Linux divides the address space into two parts,
> >>user and kernel.
> >>   o Kernel gets 1 GB of address space while user
> >>gets 3GB virtual
> >>address space.
> >>   o Kernel needs to access all of the  memory so
> >>ideally it needs 4 GB
> >>of virtual addresses.
> >>   o But since only 1 GB (i.e. beyond 0xc000 0000)
> >>is available, so we
> >>call the rest as
> >>      high memory (approx 3 GB)
> >>   o The high memory is accessed using temp. page
> >>table entries that map
> >>the high memory
> >>      areas in kernel address space.
> >>   o The high memory region is mostly allocated to
> >>the user space programs.
> >>
> >>hope it answers the question !
> >>
> >>regd,
> >>~rpm
> >>Rajat Jain wrote:
> >>
> >>
> >>
> >>>Hi list,
> >>>
> >>>I recently read that the concept of "High Memory"
> >>>
> >>>
> >>was introduced
> >>
> >>
> >>>because certain architectures are capable of
> >>>
> >>>
> >>physically addressing
> >>
> >>
> >>>larger amounts of memory than they can virtually
> >>>
> >>>
> >>address (physical
> >>
> >>
> >>>address space > virtual address space). I also
> >>>
> >>>
> >>read that nowadays
> >>
> >>
> >>>"high Memory" exists only in x86.
> >>>
> >>>1) Why is virtual memory > 896 MB on x86
> >>>
> >>>
> >>designated as high memory?
> >>
> >>
> >>>AFAIK x86 has 4 GB of virtual address space
> >>>
> >>>
> >>(=physical address space?)
> >>
> >>
> >>>2) Has the "high Memory" concept got anything to
> >>>
> >>>
> >>do with PAE (Page
> >>
> >>
> >>>Address Extention) feature of x86?
> >>>
> >>>3) Do any other architectures than x86 have the
> >>>
> >>>
> >>concept of high memory?
> >>
> >>
> >>>TIA,
> >>>
> >>>Rajat
> >>>-
> >>>To unsubscribe from this list: send the line
> >>>
> >>>
> >>"unsubscribe
> >>
> >>
> >>>linux-newbie" in
> >>>the body of a message to majordomo@vger.kernel.org
> >>>More majordomo info at
> >>>
> >>>
> >>http://vger.kernel.org/majordomo-info.html
> >>
> >>
> >>>Please read the FAQ at
> >>>
> >>>
> >>http://www.linux-learn.org/faqs
> >>
> >>
> >>-
> >>To unsubscribe from this list: send the line
> >>"unsubscribe linux-newbie" in
> >>the body of a message to majordomo@vger.kernel.org
> >>More majordomo info at
> >>http://vger.kernel.org/majordomo-info.html
> >>Please read the FAQ at
> >>http://www.linux-learn.org/faqs
> >>
> >>
> >>
> >
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam?  Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
> >-
> >To unsubscribe from this list: send the line "unsubscribe linux-newbie"
> in
> >the body of a message to majordomo@vger.kernel.org
> >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >Please read the FAQ at http://www.linux-learn.org/faqs
> >
> >
> >
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
>
>

[-- Attachment #2: Type: text/html, Size: 7380 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-02 16:37       ` Ritesh Kumar
@ 2006-08-03  5:20         ` Rajendra
  2006-08-03  5:59           ` Rajat Jain
  2006-08-03  6:35           ` Ritesh Kumar
  0 siblings, 2 replies; 13+ messages in thread
From: Rajendra @ 2006-08-03  5:20 UTC (permalink / raw)
  To: kernelnewbies; +Cc: Linux Newbie

Ok, it seems like the stuff that i wrote was not quiet clear, let me 
rephrase.

  o When something runs on a processor, processor just understands the 
the privilege
     level (PL) of the code in case of linux it is either 0 or 3. The 
whole idea of kernel space
     and user space is an abstraction for understanding and implementation.

  o If the processor has paging enabled (which is always true), then it 
requires to have
     a page table entry for every page that is accessed be it  PL 0 or PL 3.

  o Now we need some code to manage to whole of the physical memory and 
suitably add
     or remove the page table entries and we call such a code as kernel 
code.

  o In case of Linux everything that runs on the processor is always a 
part of something called
     a process. So, every instruction that runs has to be a part of some 
process (except for interrupts)
     The "process" is again a unix abstraction of grouping certain 
sequence of instructions.
 
 o We say that the process has access of the whole 4 GB virtual address 
space as the processor
    can generate that many unique virtual addresses.

 o What we say is, the first three GB address will always run at PL3 
while the next 1 GB will
     be at PL 0.

 o The top 1 GB address space is called the kernel and is common for all 
processes.

 o When a process is created, the X86 linux creates a page table for 
process's first 3 GB entries
    as required by the executable running while the last 1 GB is shared 
with all processes
    as it is the kernel address.

 o Since the kernel code has to be always present and can never be paged 
out, so it's entries
    are pinned i.e. always present in page tables. Hence we identity map 
the pages i.e. virtual
    address is same as physical address (except for the MSB nibble which 
is  >= 0xC).

 o Now the question that comes is, what if the physical memory is more 
then 1 GB, so for
    such a case we call it as high memory and manage it using temp. page 
table entries.

 o One thing we have to note here is that, kernel is the code that 
creates page table entries
    for user process and sometimes needs to access the pages. Now for 
accessing the pages
    it needs some entry in the page table that maps the virtual page 
with physical page. For
    the first 896 MB of physical pages, the entries are identity mapped 
while for the rest we
    have to first add an entry in page table and mark it as PL0 and then 
only the processor
    will allow a valid access.

 o If we want to access the high memory with user space addresses then 
kernel will
    have to find the virtual address in the user space which is free and 
map it to the high
    memory  and such a mapping will be available only for the process as 
the entries are
    present in it's page table only. (Page tables are per process in 
linux)  

    

Ritesh Kumar wrote:

> On 8/2/06, *Rajendra* <rpm@solidcore.com <mailto:rpm@solidcore.com>> 
> wrote:
>
>     When protection and paging is switched on the processor, it
>     requires valid
>     page tables entry for every page that is accessed. Now there are
>     only 4 GB
>     addresses that are available, so we have to divide it in such a
>     way that the
>     kernel as well as the user can access it. So what we do is we say
>     that first
>     three GB address will always be user space address. The page table
>     entries
>     of these will keep on changing as the process loads, allocates and
>     deallocates
>     memory. While the last 1 GB i.e. from 3 GB to 4 GB is given to
>     kernel and
>     it's page table entries are always present in the processor page
>     tables.
>     The kernel
>     address are hence identity mapped i.e .  phy_addr = (virt_addr <<
>     4) >>
>     4. Since
>     the kernel is the program that manages all the resources including
>     memory, so it needs
>     access to all the memory that is there in the system, so for
>     regions of
>     memory
>     above 1 GB (physical), we use special mechanism and call it as
>     high memory.
>
>     ~rpm
>
>
>
> There is a very good thread/article on kerneltrap discussing high 
> memory and the memory split. However, another thought came to my mind 
> while reading this.
> Why does the kernel really have to map all the memory pages in its 1GB 
> address space? If the memory is (only) mapped in the lower 3GB, the 
> kernel sill can access it right? The kernel just might need to be a 
> little careful when dealing with memory in the lower 3GB space as 1) 
> it might change on the next context switch 2) Its not trusted.
> The basic advantage would be being able to use all the 4GB of RAM on a 
> 32 bit machine without any HighMem overhead.
>
> Ritesh
>
>     Dave B. Sharp wrote:
>
>     >Yes, but why is only 1GB of memory "available"? The
>     >whole address space is available to other kernels.
>     >
>     >  Dave Sharp
>     >
>     >--- Rajendra < rpm@solidcore.com <mailto:rpm@solidcore.com>> wrote:
>     >
>     >
>     >
>     >>The reason for the high memory is this.
>     >>
>     >>   o Linux divides the address space into two parts,
>     >>user and kernel.
>     >>   o Kernel gets 1 GB of address space while user
>     >>gets 3GB virtual
>     >>address space.
>     >>   o Kernel needs to access all of the  memory so
>     >>ideally it needs 4 GB
>     >>of virtual addresses.
>     >>   o But since only 1 GB (i.e . beyond 0xc000 0000)
>     >>is available, so we
>     >>call the rest as
>     >>      high memory (approx 3 GB)
>     >>   o The high memory is accessed using temp. page
>     >>table entries that map
>     >>the high memory
>     >>      areas in kernel address space.
>     >>   o The high memory region is mostly allocated to
>     >>the user space programs.
>     >>
>     >>hope it answers the question !
>     >>
>     >>regd,
>     >>~rpm
>     >>Rajat Jain wrote:
>     >>
>     >>
>     >>
>     >>>Hi list,
>     >>>
>     >>>I recently read that the concept of "High Memory"
>     >>>
>     >>>
>     >>was introduced
>     >>
>     >>
>     >>>because certain architectures are capable of
>     >>>
>     >>>
>     >>physically addressing
>     >>
>     >>
>     >>>larger amounts of memory than they can virtually
>     >>>
>     >>>
>     >>address (physical
>     >>
>     >>
>     >>>address space > virtual address space). I also
>     >>>
>     >>>
>     >>read that nowadays
>     >>
>     >>
>     >>>"high Memory" exists only in x86.
>     >>>
>     >>>1) Why is virtual memory > 896 MB on x86
>     >>>
>     >>>
>     >>designated as high memory?
>     >>
>     >>
>     >>>AFAIK x86 has 4 GB of virtual address space
>     >>>
>     >>>
>     >>(=physical address space?)
>     >>
>     >>
>     >>>2) Has the "high Memory" concept got anything to
>     >>>
>     >>>
>     >>do with PAE (Page
>     >>
>     >>
>     >>>Address Extention) feature of x86?
>     >>>
>     >>>3) Do any other architectures than x86 have the
>     >>>
>     >>>
>     >>concept of high memory?
>     >>
>     >>
>     >>>TIA,
>     >>>
>     >>>Rajat
>     >>>-
>     >>>To unsubscribe from this list: send the line
>     >>>
>     >>>
>     >>"unsubscribe
>     >>
>     >>
>     >>>linux-newbie" in
>     >>>the body of a message to majordomo@vger.kernel.org
>     <mailto:majordomo@vger.kernel.org>
>     >>>More majordomo info at
>     >>>
>     >>>
>     >>http://vger.kernel.org/majordomo-info.html
>     <http://vger.kernel.org/majordomo-info.html>
>     >>
>     >>
>     >>>Please read the FAQ at
>     >>>
>     >>>
>     >>http://www.linux-learn.org/faqs
>     >>
>     >>
>     >>-
>     >>To unsubscribe from this list: send the line
>     >>"unsubscribe linux-newbie" in
>     >>the body of a message to majordomo@vger.kernel.org
>     <mailto:majordomo@vger.kernel.org>
>     >>More majordomo info at
>     >>http://vger.kernel.org/majordomo-info.html
>     >>Please read the FAQ at
>     >>http://www.linux-learn.org/faqs <http://www.linux-learn.org/faqs>
>     >>
>     >>
>     >>
>     >
>     >
>     >__________________________________________________
>     >Do You Yahoo!?
>     >Tired of spam?  Yahoo! Mail has the best spam protection around
>     > http://mail.yahoo.com
>     >-
>     >To unsubscribe from this list: send the line "unsubscribe
>     linux-newbie" in
>     >the body of a message to majordomo@vger.kernel.org
>     <mailto:majordomo@vger.kernel.org>
>     >More majordomo info at  http://vger.kernel.org/majordomo-info.html
>     >Please read the FAQ at http://www.linux-learn.org/faqs
>     <http://www.linux-learn.org/faqs>
>     >
>     >
>     >
>
>
>     --
>     Kernelnewbies: Help each other learn about the Linux kernel.
>     Archive:       http://mail.nl.linux.org/kernelnewbies/
>     FAQ:           http://kernelnewbies.org/faq/
>
>

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-03  5:20         ` Rajendra
@ 2006-08-03  5:59           ` Rajat Jain
  2006-08-03 10:52             ` Rajendra
  2006-08-03  6:35           ` Ritesh Kumar
  1 sibling, 1 reply; 13+ messages in thread
From: Rajat Jain @ 2006-08-03  5:59 UTC (permalink / raw)
  To: Rajendra; +Cc: kernelnewbies, Linux Newbie

On 8/3/06, Rajendra <rpm@solidcore.com> wrote:
> Ok, it seems like the stuff that i wrote was not quiet clear, let me
> rephrase.
>
>  o When something runs on a processor, processor just understands the
> the privilege
>     level (PL) of the code in case of linux it is either 0 or 3. The
> whole idea of kernel space
>     and user space is an abstraction for understanding and implementation.
>
>  o If the processor has paging enabled (which is always true), then it
> requires to have
>     a page table entry for every page that is accessed be it  PL 0 or PL 3.
>
>  o Now we need some code to manage to whole of the physical memory and
> suitably add
>     or remove the page table entries and we call such a code as kernel
> code.
>
>  o In case of Linux everything that runs on the processor is always a
> part of something called
>     a process. So, every instruction that runs has to be a part of some
> process (except for interrupts)
>     The "process" is again a unix abstraction of grouping certain
> sequence of instructions.
>
>  o We say that the process has access of the whole 4 GB virtual address
> space as the processor
>    can generate that many unique virtual addresses.
>
>  o What we say is, the first three GB address will always run at PL3
> while the next 1 GB will
>     be at PL 0.
>
>  o The top 1 GB address space is called the kernel and is common for all
> processes.
>
>  o When a process is created, the X86 linux creates a page table for
> process's first 3 GB entries
>    as required by the executable running while the last 1 GB is shared
> with all processes
>    as it is the kernel address.
>
>  o Since the kernel code has to be always present and can never be paged
> out, so it's entries
>    are pinned i.e. always present in page tables. Hence we identity map
> the pages i.e. virtual
>    address is same as physical address (except for the MSB nibble which
> is  >= 0xC).
>
>  o Now the question that comes is, what if the physical memory is more
> then 1 GB, so for
>    such a case we call it as high memory and manage it using temp. page
> table entries.
>
>  o One thing we have to note here is that, kernel is the code that
> creates page table entries
>    for user process and sometimes needs to access the pages. Now for
> accessing the pages
>    it needs some entry in the page table that maps the virtual page
> with physical page. For
>    the first 896 MB of physical pages, the entries are identity mapped
> while for the rest we
>    have to first add an entry in page table and mark it as PL0 and then
> only the processor
>    will allow a valid access.
>
>  o If we want to access the high memory with user space addresses then
> kernel will
>    have to find the virtual address in the user space which is free and
> map it to the high
>    memory  and such a mapping will be available only for the process as
> the entries are
>    present in it's page table only. (Page tables are per process in
> linux)
>

Firstly, Thanks a TONN for the above mail (surely clarified all my
doubts)! But just one query.

If the kernel wants to access the high memory, it will map it into the
virtual address space of the KERNEL (3GB -> 4GB), right? Now at this
point, what will happen to the original (identity) mapping of that
kernel virtual memory address (to which it has now mapped the high
memory)?

TIA,

Rajat

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-03  5:20         ` Rajendra
  2006-08-03  5:59           ` Rajat Jain
@ 2006-08-03  6:35           ` Ritesh Kumar
  1 sibling, 0 replies; 13+ messages in thread
From: Ritesh Kumar @ 2006-08-03  6:35 UTC (permalink / raw)
  To: Rajendra; +Cc: kernelnewbies, Linux Newbie

[-- Attachment #1: Type: text/plain, Size: 10293 bytes --]

On 8/3/06, Rajendra <rpm@solidcore.com> wrote:
>
> Ok, it seems like the stuff that i wrote was not quiet clear, let me
> rephrase.
>
>   o When something runs on a processor, processor just understands the
> the privilege
>      level (PL) of the code in case of linux it is either 0 or 3. The
> whole idea of kernel space
>      and user space is an abstraction for understanding and
> implementation.
>
>   o If the processor has paging enabled (which is always true), then it
> requires to have
>      a page table entry for every page that is accessed be it  PL 0 or PL
> 3.
>
>   o Now we need some code to manage to whole of the physical memory and
> suitably add
>      or remove the page table entries and we call such a code as kernel
> code.
>
>   o In case of Linux everything that runs on the processor is always a
> part of something called
>      a process. So, every instruction that runs has to be a part of some
> process (except for interrupts)
>      The "process" is again a unix abstraction of grouping certain
> sequence of instructions.
>
> o We say that the process has access of the whole 4 GB virtual address
> space as the processor
>     can generate that many unique virtual addresses.
>
> o What we say is, the first three GB address will always run at PL3
> while the next 1 GB will
>      be at PL 0.



I couldn't quite understand the previous statement. I hope you mean that
code running in PL3 will never have access to the last 1 GB of address
space.


o The top 1 GB address space is called the kernel and is common for all
> processes.


o When a process is created, the X86 linux creates a page table for
> process's first 3 GB entries
>     as required by the executable running while the last 1 GB is shared
> with all processes
>     as it is the kernel address.
>
> o Since the kernel code has to be always present and can never be paged
> out, so it's entries
>     are pinned i.e. always present in page tables. Hence we identity map
> the pages i.e. virtual
>     address is same as physical address (except for the MSB nibble which
> is  >= 0xC).
>
> o Now the question that comes is, what if the physical memory is more
> then 1 GB, so for
>     such a case we call it as high memory and manage it using temp. page
> table entries.
>
> o One thing we have to note here is that, kernel is the code that
> creates page table entries
>     for user process and sometimes needs to access the pages. Now for
> accessing the pages
>     it needs some entry in the page table that maps the virtual page
> with physical page. For
>     the first 896 MB of physical pages, the entries are identity mapped
> while for the rest we
>     have to first add an entry in page table and mark it as PL0 and then
> only the processor
>     will allow a valid access.
>
> o If we want to access the high memory with user space addresses then
> kernel will
>     have to find the virtual address in the user space which is free and
> map it to the high
>     memory  and such a mapping will be available only for the process as
> the entries are
>     present in it's page table only. (Page tables are per process in
> linux)



Do you mean to say that high memory can be exclusively mapped to just the
user address space? And in such cases the kernel goes through some hoops to
fetch the data from that memory when it requires it (like either temporarily
mapping it in its own address space or copying the data from the userspace
to its memory)? If that's true then my question is answered ;-)
I always thought (though I haven't looked at the mm code) that any userspace
memory is *always* also mapped in the kernel. With highmem, you basically
would remap the parts of memory into kernel space as you need them.

Ritesh


Ritesh Kumar wrote:
>
> > On 8/2/06, *Rajendra* <rpm@solidcore.com <mailto:rpm@solidcore.com>>
> > wrote:
> >
> >     When protection and paging is switched on the processor, it
> >     requires valid
> >     page tables entry for every page that is accessed. Now there are
> >     only 4 GB
> >     addresses that are available, so we have to divide it in such a
> >     way that the
> >     kernel as well as the user can access it. So what we do is we say
> >     that first
> >     three GB address will always be user space address. The page table
> >     entries
> >     of these will keep on changing as the process loads, allocates and
> >     deallocates
> >     memory. While the last 1 GB i.e. from 3 GB to 4 GB is given to
> >     kernel and
> >     it's page table entries are always present in the processor page
> >     tables.
> >     The kernel
> >     address are hence identity mapped i.e .  phy_addr = (virt_addr <<
> >     4) >>
> >     4. Since
> >     the kernel is the program that manages all the resources including
> >     memory, so it needs
> >     access to all the memory that is there in the system, so for
> >     regions of
> >     memory
> >     above 1 GB (physical), we use special mechanism and call it as
> >     high memory.
> >
> >     ~rpm
> >
> >
> >
> > There is a very good thread/article on kerneltrap discussing high
> > memory and the memory split. However, another thought came to my mind
> > while reading this.
> > Why does the kernel really have to map all the memory pages in its 1GB
> > address space? If the memory is (only) mapped in the lower 3GB, the
> > kernel sill can access it right? The kernel just might need to be a
> > little careful when dealing with memory in the lower 3GB space as 1)
> > it might change on the next context switch 2) Its not trusted.
> > The basic advantage would be being able to use all the 4GB of RAM on a
> > 32 bit machine without any HighMem overhead.
> >
> > Ritesh
> >
> >     Dave B. Sharp wrote:
> >
> >     >Yes, but why is only 1GB of memory "available"? The
> >     >whole address space is available to other kernels.
> >     >
> >     >  Dave Sharp
> >     >
> >     >--- Rajendra < rpm@solidcore.com <mailto:rpm@solidcore.com>> wrote:
> >     >
> >     >
> >     >
> >     >>The reason for the high memory is this.
> >     >>
> >     >>   o Linux divides the address space into two parts,
> >     >>user and kernel.
> >     >>   o Kernel gets 1 GB of address space while user
> >     >>gets 3GB virtual
> >     >>address space.
> >     >>   o Kernel needs to access all of the  memory so
> >     >>ideally it needs 4 GB
> >     >>of virtual addresses.
> >     >>   o But since only 1 GB (i.e . beyond 0xc000 0000)
> >     >>is available, so we
> >     >>call the rest as
> >     >>      high memory (approx 3 GB)
> >     >>   o The high memory is accessed using temp. page
> >     >>table entries that map
> >     >>the high memory
> >     >>      areas in kernel address space.
> >     >>   o The high memory region is mostly allocated to
> >     >>the user space programs.
> >     >>
> >     >>hope it answers the question !
> >     >>
> >     >>regd,
> >     >>~rpm
> >     >>Rajat Jain wrote:
> >     >>
> >     >>
> >     >>
> >     >>>Hi list,
> >     >>>
> >     >>>I recently read that the concept of "High Memory"
> >     >>>
> >     >>>
> >     >>was introduced
> >     >>
> >     >>
> >     >>>because certain architectures are capable of
> >     >>>
> >     >>>
> >     >>physically addressing
> >     >>
> >     >>
> >     >>>larger amounts of memory than they can virtually
> >     >>>
> >     >>>
> >     >>address (physical
> >     >>
> >     >>
> >     >>>address space > virtual address space). I also
> >     >>>
> >     >>>
> >     >>read that nowadays
> >     >>
> >     >>
> >     >>>"high Memory" exists only in x86.
> >     >>>
> >     >>>1) Why is virtual memory > 896 MB on x86
> >     >>>
> >     >>>
> >     >>designated as high memory?
> >     >>
> >     >>
> >     >>>AFAIK x86 has 4 GB of virtual address space
> >     >>>
> >     >>>
> >     >>(=physical address space?)
> >     >>
> >     >>
> >     >>>2) Has the "high Memory" concept got anything to
> >     >>>
> >     >>>
> >     >>do with PAE (Page
> >     >>
> >     >>
> >     >>>Address Extention) feature of x86?
> >     >>>
> >     >>>3) Do any other architectures than x86 have the
> >     >>>
> >     >>>
> >     >>concept of high memory?
> >     >>
> >     >>
> >     >>>TIA,
> >     >>>
> >     >>>Rajat
> >     >>>-
> >     >>>To unsubscribe from this list: send the line
> >     >>>
> >     >>>
> >     >>"unsubscribe
> >     >>
> >     >>
> >     >>>linux-newbie" in
> >     >>>the body of a message to majordomo@vger.kernel.org
> >     <mailto:majordomo@vger.kernel.org>
> >     >>>More majordomo info at
> >     >>>
> >     >>>
> >     >>http://vger.kernel.org/majordomo-info.html
> >     <http://vger.kernel.org/majordomo-info.html>
> >     >>
> >     >>
> >     >>>Please read the FAQ at
> >     >>>
> >     >>>
> >     >>http://www.linux-learn.org/faqs
> >     >>
> >     >>
> >     >>-
> >     >>To unsubscribe from this list: send the line
> >     >>"unsubscribe linux-newbie" in
> >     >>the body of a message to majordomo@vger.kernel.org
> >     <mailto:majordomo@vger.kernel.org>
> >     >>More majordomo info at
> >     >>http://vger.kernel.org/majordomo-info.html
> >     >>Please read the FAQ at
> >     >>http://www.linux-learn.org/faqs <http://www.linux-learn.org/faqs>
> >     >>
> >     >>
> >     >>
> >     >
> >     >
> >     >__________________________________________________
> >     >Do You Yahoo!?
> >     >Tired of spam?  Yahoo! Mail has the best spam protection around
> >     > http://mail.yahoo.com
> >     >-
> >     >To unsubscribe from this list: send the line "unsubscribe
> >     linux-newbie" in
> >     >the body of a message to majordomo@vger.kernel.org
> >     <mailto:majordomo@vger.kernel.org>
> >     >More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >     >Please read the FAQ at http://www.linux-learn.org/faqs
> >     <http://www.linux-learn.org/faqs>
> >     >
> >     >
> >     >
> >
> >
> >     --
> >     Kernelnewbies: Help each other learn about the Linux kernel.
> >     Archive:       http://mail.nl.linux.org/kernelnewbies/
> >     FAQ:           http://kernelnewbies.org/faq/
> >
> >
>
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
>
>

[-- Attachment #2: Type: text/html, Size: 18645 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-03  5:59           ` Rajat Jain
@ 2006-08-03 10:52             ` Rajendra
  2006-08-03 11:55               ` Daniel Rodrick
  0 siblings, 1 reply; 13+ messages in thread
From: Rajendra @ 2006-08-03 10:52 UTC (permalink / raw)
  To: kernelnewbies; +Cc: Linux Newbie

Rajat Jain wrote:

> On 8/3/06, Rajendra <rpm@solidcore.com> wrote:
>
>> Ok, it seems like the stuff that i wrote was not quiet clear, let me
>> rephrase.
>>
>>  o When something runs on a processor, processor just understands the
>> the privilege
>>     level (PL) of the code in case of linux it is either 0 or 3. The
>> whole idea of kernel space
>>     and user space is an abstraction for understanding and 
>> implementation.
>>
>>  o If the processor has paging enabled (which is always true), then it
>> requires to have
>>     a page table entry for every page that is accessed be it  PL 0 or 
>> PL 3.
>>
>>  o Now we need some code to manage to whole of the physical memory and
>> suitably add
>>     or remove the page table entries and we call such a code as kernel
>> code.
>>
>>  o In case of Linux everything that runs on the processor is always a
>> part of something called
>>     a process. So, every instruction that runs has to be a part of some
>> process (except for interrupts)
>>     The "process" is again a unix abstraction of grouping certain
>> sequence of instructions.
>>
>>  o We say that the process has access of the whole 4 GB virtual address
>> space as the processor
>>    can generate that many unique virtual addresses.
>>
>>  o What we say is, the first three GB address will always run at PL3
>> while the next 1 GB will
>>     be at PL 0.
>>
>>  o The top 1 GB address space is called the kernel and is common for all
>> processes.
>>
>>  o When a process is created, the X86 linux creates a page table for
>> process's first 3 GB entries
>>    as required by the executable running while the last 1 GB is shared
>> with all processes
>>    as it is the kernel address.
>>
>>  o Since the kernel code has to be always present and can never be paged
>> out, so it's entries
>>    are pinned i.e. always present in page tables. Hence we identity map
>> the pages i.e. virtual
>>    address is same as physical address (except for the MSB nibble which
>> is  >= 0xC).
>>
>>  o Now the question that comes is, what if the physical memory is more
>> then 1 GB, so for
>>    such a case we call it as high memory and manage it using temp. page
>> table entries.
>>
>>  o One thing we have to note here is that, kernel is the code that
>> creates page table entries
>>    for user process and sometimes needs to access the pages. Now for
>> accessing the pages
>>    it needs some entry in the page table that maps the virtual page
>> with physical page. For
>>    the first 896 MB of physical pages, the entries are identity mapped
>> while for the rest we
>>    have to first add an entry in page table and mark it as PL0 and then
>> only the processor
>>    will allow a valid access.
>>
>>  o If we want to access the high memory with user space addresses then
>> kernel will
>>    have to find the virtual address in the user space which is free and
>> map it to the high
>>    memory  and such a mapping will be available only for the process as
>> the entries are
>>    present in it's page table only. (Page tables are per process in
>> linux)
>>
>
> Firstly, Thanks a TONN for the above mail (surely clarified all my
> doubts)! But just one query.
>
> If the kernel wants to access the high memory, it will map it into the
> virtual address space of the KERNEL (3GB -> 4GB), right? Now at this
> point, what will happen to the original (identity) mapping of that
> kernel virtual memory address (to which it has now mapped the high
> memory)?
>
> TIA,
>
> Rajat
>
That is why kernel does not access the whole 1 GB, it's only 896MB, the rest
of the 128MB is used to create temp page table entries for the high mem.
e.g. if you have 2 GB of ram, then the 896 MB will be identity mapped while
for the rest 1GB + 128MB we will use the 128 MB kernel address space for
accessing the "high memory". The 896 MB limit comes only if you have 
compiled the
kernel with CONFIG_HIGHMEM option enabled else it is assumed that
you do not have high memory in you system.

regards,
~rpm

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-03 10:52             ` Rajendra
@ 2006-08-03 11:55               ` Daniel Rodrick
  2006-08-03 18:44                 ` Rahul Iyer
  0 siblings, 1 reply; 13+ messages in thread
From: Daniel Rodrick @ 2006-08-03 11:55 UTC (permalink / raw)
  To: Rajendra; +Cc: kernelnewbies, Linux Newbie

> >
> > If the kernel wants to access the high memory, it will map it into the
> > virtual address space of the KERNEL (3GB -> 4GB), right? Now at this
> > point, what will happen to the original (identity) mapping of that
> > kernel virtual memory address (to which it has now mapped the high
> > memory)?
> >
> > TIA,
> >
> > Rajat
> >
> That is why kernel does not access the whole 1 GB, it's only 896MB, the rest
> of the 128MB is used to create temp page table entries for the high mem.
> e.g. if you have 2 GB of ram, then the 896 MB will be identity mapped while
> for the rest 1GB + 128MB we will use the 128 MB kernel address space for
> accessing the "high memory".

Oh, so you mean to say that the physical memory between 896MB and 1GB
is used to store the page tables and the memory map. But the
corresponding virtual memory addresses (~3.8 GB -> 4 GB) are used to
map high memory physical addresses?

Thanks,

Dan
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Why "high memory" in x86?
  2006-08-03 11:55               ` Daniel Rodrick
@ 2006-08-03 18:44                 ` Rahul Iyer
  0 siblings, 0 replies; 13+ messages in thread
From: Rahul Iyer @ 2006-08-03 18:44 UTC (permalink / raw)
  To: Daniel Rodrick; +Cc: Rajendra, kernelnewbies, Linux Newbie

On Thu, 2006-08-03 at 17:25 +0530, Daniel Rodrick wrote:
> > >
> > > If the kernel wants to access the high memory, it will map it into the
> > > virtual address space of the KERNEL (3GB -> 4GB), right? Now at this
> > > point, what will happen to the original (identity) mapping of that
> > > kernel virtual memory address (to which it has now mapped the high
> > > memory)?
> > >
> > > TIA,
> > >
> > > Rajat
> > >
> > That is why kernel does not access the whole 1 GB, it's only 896MB, the rest
> > of the 128MB is used to create temp page table entries for the high mem.
> > e.g. if you have 2 GB of ram, then the 896 MB will be identity mapped while
> > for the rest 1GB + 128MB we will use the 128 MB kernel address space for
> > accessing the "high memory".
> 
> Oh, so you mean to say that the physical memory between 896MB and 1GB
> is used to store the page tables and the memory map. But the
> corresponding virtual memory addresses (~3.8 GB -> 4 GB) are used to
> map high memory physical addresses?
> 
Nope! So, the kernel has a 1G address space (3G to 4G), right? Now, how
does it map this 1G of address space? What it does is maps virtual
addresses from 3G to 3G + 896M to physical addresses 0 to 896M. So
essentially, the pseudocode below describes the case:

#define KERN_V_ADDR_START 3g
#define KERN_MAX_DIRECT_MAP 896M

if (v_addr < (KERN_V_ADDR_START + KERN_MAX_DIRECT_MAP))
	p_addr = v_addr - KERN_V_ADDR_START;

For the actual kernel code for this, look for _pa and _va.

So, as you can see, the maximum physical address you can access directly
is 896M. So, what about physical memory more than that? In order to
manage this, the kernel uses the remaining 128M of its address space (1G
- 896M) to temporarily map physical addresses > 896M.

I hope this makes it clearer.
-r

> Thanks,
> 
> Dan
> 
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2006-08-03 18:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01  5:48 Why "high memory" in x86? Rajat Jain
2006-08-01  9:18 ` Rajendra
2006-08-01 13:51   ` Dave B. Sharp
2006-08-02  4:25     ` Rajendra
2006-08-02 16:37       ` Ritesh Kumar
2006-08-03  5:20         ` Rajendra
2006-08-03  5:59           ` Rajat Jain
2006-08-03 10:52             ` Rajendra
2006-08-03 11:55               ` Daniel Rodrick
2006-08-03 18:44                 ` Rahul Iyer
2006-08-03  6:35           ` Ritesh Kumar
     [not found] ` <20060801090248.4aad8a39@thomas.toulouse>
2006-08-01  9:53   ` Rajat Jain
2006-08-01 12:09     ` Rajat Jain

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.