2015-11-17 15:21:36

by alan hopes

[permalink] [raw]
Subject: read physical address space

Hi,

I am new to kernel and working on a college project.

I have kernel module which takes process ID. Based on the PID, I walk
its page tables and get to PTE for a particular VMA area.

I convert PTE to physical address (phy_addr) and now I want to read
from the that physical address.

I have made sure the page containing the physical address is mapped
but if I do printk (*phys_addr) , then kernel crashes.

I think I am missing some important concept here. Do I need another
driver to access physical space, may be a PCI driver as RAM being a
PCI device ?

Thanks
Alan


2015-11-17 16:55:10

by yalin wang

[permalink] [raw]
Subject: Re: read physical address space

you should access it like this:
printk ( *(int*)kmap(pays_to_page(pays_addr)));

pays address must be mapped into virtual address before access it .
> On Nov 17, 2015, at 23:21, alan hopes <[email protected]> wrote:
>
> phys_addr

2015-11-24 15:48:26

by alan hopes

[permalink] [raw]
Subject: Re: read physical address space

Thanks Yalin.

Yeah, got it.. So, it means I can't directly access physical address,
its only the responsibility of MMU to access it. Even if I have a
physical address, I need to convert it to kernel virtual address to
access it to maintain consistency with other general user-mode memory
access operation.

Thanks
Alan.

On Tue, Nov 17, 2015 at 4:28 PM, yalin wang <[email protected]> wrote:
> you should access it like this:
> printk ( *(int*)kmap(pays_to_page(pays_addr)));
>
> pays address must be mapped into virtual address before access it .
>> On Nov 17, 2015, at 23:21, alan hopes <[email protected]> wrote:
>>
>> phys_addr
>