All of lore.kernel.org
 help / color / mirror / Atom feed
* read physical address space
@ 2015-11-17 15:21 alan hopes
  2015-11-17 16:28 ` yalin wang
  0 siblings, 1 reply; 3+ messages in thread
From: alan hopes @ 2015-11-17 15:21 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: read physical address space
  2015-11-17 15:21 read physical address space alan hopes
@ 2015-11-17 16:28 ` yalin wang
  2015-11-24 15:48   ` alan hopes
  0 siblings, 1 reply; 3+ messages in thread
From: yalin wang @ 2015-11-17 16:28 UTC (permalink / raw)
  To: alan hopes; +Cc: linux-kernel

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 <hopes.alan@gmail.com> wrote:
> 
> phys_addr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: read physical address space
  2015-11-17 16:28 ` yalin wang
@ 2015-11-24 15:48   ` alan hopes
  0 siblings, 0 replies; 3+ messages in thread
From: alan hopes @ 2015-11-24 15:48 UTC (permalink / raw)
  To: yalin wang; +Cc: linux-kernel

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 <yalin.wang2010@gmail.com> 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 <hopes.alan@gmail.com> wrote:
>>
>> phys_addr
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-24 15:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-17 15:21 read physical address space alan hopes
2015-11-17 16:28 ` yalin wang
2015-11-24 15:48   ` alan hopes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.