Re: Virtual and Linear addresses

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

 



On Friday 08 September 2006 04:34, pandari kashyap wrote:
> 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??
>

If the system has 2GB of RAM then it is clear that 2GB < 0xFFFF0000, so 
0xFFFF0000 can not be a physical address. But regardless of how much memory 
the system has, CPU can never _directly_ access physical memory when 
operating in protected mode. The address that the CPU uses will always go 
through the MMU which will translate it to the physical address.

It is also not a kernel linear address, because the kernel linear address 
space can only address up to 896MB. So it is the other kind of kernel virtual 
address, e.g. a highmem address.

Note that not all highmem addresses are mapped in the kernel address space. 
Accessing random addresses in this area can lead to page faults. 

To map a physical address in the kernel address space you can you the kmap*() 
family() of functions. kmap() allows you to map a specific physical address 
somewhere in the highmem area.

vmalloc() will also return an address within the highmem area. Essentially 
vmalloc() maps a random set of pages, possibly non-linearly, to fulfil the 
allocation request. 


If my memory still serves me well, the address you choose (0xFFFF0000) is part 
of a range in highmem which identifies "fixed addresses". See fixmap for more 
details.

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