Re: Virtual and Linear addresses

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

 




Tavi,
Thanks for taking the time to reply to me. I think the upper 1GB equation looks more like this.

P = L - C where C on intel x86 architecture is usually given by PAGE_OFFSET and L is the kernel linear address.

I have the following question:

1. Why can't Kernel access physical addresses? . For ex:-, if there is a line of code that looks like the following inside the kernel
(*(char*)0xffff0000) = 'a' ;

Then what kind of address is 0xffff0000 if we assume that the system has 2GB of RAM. Is it Linear or physical?. In case it is linear what if we want to store 'a' in physical address 0xffff0000??

2. What is the difference and philosophy between kmalloc and vmalloc?

Thanks for your help in advance?

Pandari

On 9/8/06, Octavian Purdila <tavi@xxxxxxxxx> wrote:
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


[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