<p dir="ltr">Kernel physical addr : 0x32d01fe0<br>
Platform phys offset : 0x30000000<br>
Page offset : 0xc0553fb4</p>
<p dir="ltr">The page offset looks weird, since 32bit kernel has 2/2 or 3/1 or 1/3 user/kernel virtual address split. It is not reasonable to have 0xc0553fb4 as page offset. You should c0000000 for 3/1 split.</p>
<div class="gmail_quote">2014/9/13 下午8:59 於 "mind entropy" <<a href="mailto:mindentropy@gmail.com">mindentropy@gmail.com</a>> 寫道:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Sep 13, 2014 at 2:01 PM, Miles MH Chen <<a href="mailto:orca.chen@gmail.com">orca.chen@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> Do you know the value of PHYS_OFFSET of your platform?<br>
> PHYS_OFFSET defines the starting physical address of your DRAM.<br>
><br>
> physical address = kmalloc'ed address - PAGE_OFFSET + PHYS_OFFSET<br>
><br>
> MH<br>
><br>
> On Sat, Sep 13, 2014 at 4:02 PM, mind entropy <<a href="mailto:mindentropy@gmail.com">mindentropy@gmail.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I want to know the physical address [just for debugging and info.Not<br>
>> for DMA etc] of a particular virtual address allocated via kmalloc.<br>
>><br>
>> I am running the below code on S3C2440 with 64MB of RAM. The<br>
>> /proc/meminfo returns<br>
>><br>
>> MemTotal: 59164 kB<br>
>> MemFree: 35884 kB<br>
>> MemAvailable: 47148 kB<br>
>><br>
>><br>
>> I run the following module for printing the addresses. [This module<br>
>> is only for test. So excuse if I have cut corners].<br>
>><br>
>> ------------------------------------------------<br>
>><br>
>> #include <linux/init.h><br>
>> #include <linux/kernel.h><br>
>> #include <linux/printk.h><br>
>> #include <linux/module.h><br>
>> #include <linux/gfp.h><br>
>> #include <linux/types.h><br>
>> #include <linux/mm.h><br>
>> #include <linux/mm_types.h><br>
>> #include <linux/slab.h><br>
>><br>
>> static int vm_mem_test_init(void)<br>
>> {<br>
>><br>
>> void *km;<br>
>><br>
>> printk(KERN_ALERT "vm mem test init\n");<br>
>><br>
>> km = kmalloc(1,GFP_KERNEL);<br>
>><br>
>> if(km == NULL) {<br>
>> printk(KERN_ALERT "Could not kmalloc\n");<br>
>> return -1;<br>
>> } else {<br>
>> printk(KERN_ALERT "Allocated\n");<br>
>> printk(KERN_ALERT "Virtual addr : %x\n",(unsigned int)km);<br>
>> printk(KERN_ALERT "Kernel physical addr :<br>
>> 0x%x\n",virt_to_phys(km));<br>
>> kfree(km);<br>
>> }<br>
>><br>
>> return 0;<br>
>><br>
>> }<br>
>><br>
>><br>
>> The output for the following is:<br>
>><br>
>> Virtual addr : c2c080e0<br>
>> Kernel physical addr : 0x32c080e0<br>
>><br>
>> -----------------------------------------------------------<br>
>><br>
>> The kernel physical address is wrong as I only have 64MB. Should I be<br>
>> doing a kernel page table walk to get the associated physical address?<br>
>><br>
>> Thanks<br>
>> Gautam.<br>
>><br>
>> _______________________________________________<br>
>> Kernelnewbies mailing list<br>
>> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
>> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
><br>
<br>
Miles,<br>
<br>
I tried printing it. The output is as follows:<br>
<br>
Kernel physical addr : 0x32d01fe0<br>
Platform phys offset : 0x30000000<br>
Page offset : 0xc0553fb4<br>
<br>
The S3C2440 is an ARM9TDMI processor.<br>
<br>
<br>
-Gautam.<br>
</blockquote></div>