Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: virtual -->physical --> virtual address

Posted on 2011-10-15 09:01:08 by ratheesh kannoth

{
virtual_addr1 = kmalloc(0x20, GFP_USER);
phy_addr1 = __pa(virtual_addr1 );
virtual_addr2 = ioremap(phy_addr1, 0x20 );

}


I noticed that virtual_addr1 is not equal to virtual_addr2. And if i
dereference virtual_addr2 ( *virtual_addr2 ),
kernel crash. What is wrong here ?

-Ratheesh

Report this message

#2: Re: virtual -->physical --> virtual address

Posted on 2011-10-15 19:57:35 by Mirko Banchi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Il giorno 15/ott/2011, alle ore 09.01, ratheesh kannoth ha scritto:

> {
> virtual_addr1 = kmalloc(0x20, GFP_USER);
> phy_addr1 = __pa(virtual_addr1 );
> virtual_addr2 = ioremap(phy_addr1, 0x20 );
>
> }
>
>
> I noticed that virtual_addr1 is not equal to virtual_addr2. And if i
> dereference virtual_addr2 ( *virtual_addr2 ),
> kernel crash. What is wrong here ?
>

Obviously virtual_addr1 and virtual_addr2 are not equals! kmalloc returns a logical address (in fact you can simply calc the relative physical address with macro __pa) and ioremap returns a virtual address in the range [VMALLOC_START - VMALLOC_END]. However usually ioremap is used to deal with iomem and you shouldn't dereference the returned pointer directly: you should use instead ioread{8,16,32} or iowrite{8,16,32} family functions in order to make code portable. However i try to write a simple LKM with your code and i can dereference the pointer returned by ioremap correctly. Can you post some detailed code?

Mirko

- --
Mirko Banchi

e-mail: mk.banchi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
id-jabber: mk.banchi-/eSpBmjxGS4dnm+yROfE0A@public.gmane.org

PGP key fingerprint:

308F BFB1 4E67 2522 C88E
DC69 7631 52ED 32A5 6456



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Darwin)

iEYEARECAAYFAk6ZyZAACgkQdjFS7TKlZFaeIACfY5w9Z12jBkIUFvdreBPI QBcC
CasAn1cAjnoWc/743741GREIDOa6zj9I
=nkdk
-----END PGP SIGNATURE-----

Report this message