Re: Virtual and Linear addresses

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday 08 September 2006 01:27, pandari kashyap wrote:
> Hello,
>
> Could somebody please explain the difference between kernel virtual address
> and Linear address? For example on a 32 bit PC platform, let us say there
> are 2 gigs of RAM. According to Linux....the lower 3GB is reserved for user
> mode processes and the higher 1GB is directly mapped into Kernel Linear
> address space. After statically allocating space for Kernel image and data
> structures, let us say that there is still around 1.5 gigs of RAM. On these
> lines what are virtual addresses and how do they work?
>

physical address = the actual address that is used to fetch or store data in 
memory

virtual address = the addresses wich the CPU (an thus all programs and kernel) 
are using to access memory; these addreses are translated to physical 
addresses with the help of page tables

linear address space = a setup of page tables in which the for each virtual 
address v it coresponds a physical address p = v + C, where C is a constant

Since each process needs it's own address space, each process has a set of 
different page tables so that the same virtual address in different processes 
can point to different physical addreses.

The kernel also needs a distinct address space. While we could have an entire 
different address space for the kernel, due to efficiency reasons, the full 
4Gb address space is shared between the kernel (the 3G-4G zone) and whatever 
process is running at the time (0G-3G). 

Part of the kernel address space is a linear address space (about 896MB). This 
has certain advantages. Remember, the kernel can not access physical 
addresses directly, it must do so through a virtual address. Having most of 
it's address space mapped linearly, the kernel is able to quickly convert 
(v=p-C) and access the given physical address p through virtual address v.

The part of the kernel space which is not mapped linearly is called highmem, 
(about 128MB) and it is used by the kernel to access the rest of the physical 
memory, if more then 896MB are available. In order to access physical memory 
outside the scope of the kernel linear address space, the kernel needs to 
construct page tables to map the desired physical address somewhere in the 
highmem area. Which is much more costly.


tavi

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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux