I have a question when I located the address in kernel. I insert a hello module in kernel, in this module, I put these things:
char mystring[]="this is my address";
printk("<1>The address of mystring is %p",virt_to_phys(mystring));
I think I can get the physical address of mystring, but what I found is, in syslog, the printed address of it is 0x38dd0000. However, I dumped the memory and found the real address of it is dcd2a000, which is quite different from the former one. How to explain this? I did something wrong? Thanks
PS: I used a tool to dump the whole memory, physical addresses.
According to the Man page of VIRT_TO_PHYS
Try allocating the memory for
mystring
usingkmalloc
first;Here is an implementation of strcpy found here: