lkml.org 
[lkml]   [2000]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Strange virtual/physical address of global data
Date
Timur Tabi writes:
> I wrote a little module to test virt_to_phys:
>
> unsigned long test_data;
>
> int init_module(void)
> {
> void *virt = &test_data;
> unsigned long phys = virt_to_phys(virt);
>
> When I run this and check the valur of virt and phys, it appears that phys is
> outside the range of physical memory! That is, if I have 512MB of RAM, then
> phys is equal to about 520M. However, if I make test_data a local variable:
>
>
> int init_module(void)
> {
> unsigned long test_data;
> void *virt = &test_data;
> unsigned long phys = virt_to_phys(virt);
>
> Then I get a number which makes sense (less than 512M)
>
> Could someone explain this to me?

virt_to_* is only valid for addresses that the kernel returns from kmalloc
and get_free_page, or an address in the kernels direct mapped memory region.
Note that the kernel stack is also located in the direct mapped memory
region.

virt_to_* is not valid for:

vmalloc'd space
module space (this is the same as vmalloc'd space)
user space
any other weird and wonderful address that you can think of

In other words, your usage of the above is not correct.
_____
|_____| ------------------------------------------------- ---+---+-
| | Russell King rmk@arm.linux.org.uk --- ---
| | | | http://www.arm.linux.org.uk/personal/aboutme.html / / |
| +-+-+ --- -+-
/ | THE developer of ARM Linux |+| /|\
/ | | | --- |
+-+-+ ------------------------------------------------- /\\\ |
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.046 / U:9.400 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site