finding kernel virtual addr from physical addr of a user buffer

From: yogeshwar sonawane
Date: Mon Nov 30 2009 - 05:42:28 EST


Hi all,

I want to see/monitor/check/read the data of a user buffer. The idea
is like this :-

There is a network card which is sending/receiving the data. Many
applications are using that card.
Sometimes i am getting an application level error saying received data
is corrupt. I want to see/print send and receive buffer.
Having application level changes for printing is out of scope as there
can be multiple applications running simultaneous.

We have modified our card's firmware so that it will dump the Physical
addresses of user buffers which are sent or received.
After reading the dumped PA, we will pass a single PA to a driver
through sysfs file. Then we will cat the sysfs file which should show
the one page buffer contents corresponding to passed PA.

For this to work, the driver has to have access to the PA. First, i am
finding page frame no. (pfn) by right-shifting PA. Then kmap() is
called using pfn_to_page().
This will give kernel virtual address which can be used to print/show
data during "cat sysfs file" command.

1) Whether the above mentioned steps are correct ? Kindly comment.

2) In the driver store() function, i have modified the contents by
using kernel virtual address. But sometimes i am not able to see the
modified contents at user level.
Kindly suggest what can be the problem ?

3) Kindly suggest any other way to see/check user buffer contents when
PA is available ?

Thanking you,
Yogeshwar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/