/dev/mem contains physical memory addresses?
/dev/mem contains physical memory addresses?
am 06.07.2006 11:36:29 von Daniel Rodrick
Hi list,
I read that the /dev/mem represents the memory of the system.
1) Does that mean I can if start reading from /dev/mem, I can read any
portion of the memory?
2) If I read at offset "n" in the file /dev/mem, would I be reading
contents of the PHYSICAL memory address "n", or the VIRTUAL memory
addtress "n"?
Thanks,
Dan.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 06.07.2006 11:44:59 von Arjan van de Ven
On Thu, 2006-07-06 at 15:06 +0530, Daniel Rodrick wrote:
> Hi list,
>
> I read that the /dev/mem represents the memory of the system.
>
> 1) Does that mean I can if start reading from /dev/mem, I can read any
> portion of the memory?
depends on your kernel; several distributions apply security patches
that prevent rootkits from doing evil things in /dev/mem; with those you
can only access non-kernel memory via /dev/mem
> 2) If I read at offset "n" in the file /dev/mem, would I be reading
> contents of the PHYSICAL memory address "n", or the VIRTUAL memory
> addtress "n"?
PHYSICAL. if you want virutal you need to use /dev/kmem.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 06.07.2006 11:49:45 von Jinesh K J
On 7/6/06, Daniel Rodrick wrote:
> Hi list,
>
> I read that the /dev/mem represents the memory of the system.
>
> 1) Does that mean I can if start reading from /dev/mem, I can read any
> portion of the memory?
>
> 2) If I read at offset "n" in the file /dev/mem, would I be reading
> contents of the PHYSICAL memory address "n", or the VIRTUAL memory
> addtress "n"?
>
You'll be accessing only PHYSICAL since VIRTUAL addresses are not
unique and global. But, its possible that the physical memory that
you're accessing is a part of the virtual address space of some user
program running in the system.
Jinesh.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 06.07.2006 19:51:12 von George Zhim
Hi!
On 7/6/06, Arjan van de Ven wrote:
> PHYSICAL. if you want virutal you need to use /dev/kmem.
isn't /dev/kmem some sort of core file with structures resembling core files ?
how does that relate to virtual memory (isn't virtual memory unique
per process) ?
(btw is there any documentation regarding /dev/kmem ? couldn't really find...)
thanks,
George.
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 06.07.2006 20:07:47 von Arjan van de Ven
On Thu, 2006-07-06 at 19:51 +0200, George Zhim wrote:
> Hi!
>
> On 7/6/06, Arjan van de Ven wrote:
> > PHYSICAL. if you want virutal you need to use /dev/kmem.
>
> isn't /dev/kmem some sort of core file with structures resembling core files ?
no that's /proc/kcore
> how does that relate to virtual memory (isn't virtual memory unique
> per process) ?
it's the kernels view of its virtual memory
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 07.07.2006 06:37:10 von om.turyx
On 7/6/06, Arjan van de Ven wrote:
> On Thu, 2006-07-06 at 19:51 +0200, George Zhim wrote:
> > Hi!
> >
> > On 7/6/06, Arjan van de Ven wrote:
> > > PHYSICAL. if you want virutal you need to use /dev/kmem.
How about peripheral memory mapped to some addresses? Assuming I have
a PCI device and a on board flash PROM, would I be able to see them in
/proc/mem
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Re: /dev/mem contains physical memory addresses?
am 07.07.2006 06:45:19 von om.turyx
On 7/6/06, Arjan van de Ven wrote:
> On Thu, 2006-07-06 at 19:51 +0200, George Zhim wrote:
> > Hi!
> >
> > On 7/6/06, Arjan van de Ven wrote:
> > > PHYSICAL. if you want virutal you need to use /dev/kmem.
How about peripheral memory mapped to some addresses? Assuming I have
a PCI device and a on board flash PROM, would I be able to see them in
/proc/(k)mem ? I feel not. Am I correct?
Regards,
om.
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Re: /dev/mem contains physical memory addresses?
am 07.07.2006 07:36:59 von Arjan van de Ven
On Fri, 2006-07-07 at 10:15 +0530, Om. wrote:
> On 7/6/06, Arjan van de Ven wrote:
> > On Thu, 2006-07-06 at 19:51 +0200, George Zhim wrote:
> > > Hi!
> > >
> > > On 7/6/06, Arjan van de Ven wrote:
> > > > PHYSICAL. if you want virutal you need to use /dev/kmem.
> How about peripheral memory mapped to some addresses? Assuming I have
> a PCI device and a on board flash PROM, would I be able to see them in
> /proc/(k)mem ? I feel not. Am I correct?
/dev/mem yes
HOWEVER, there is a much nicer way to mmap a PCI device's resources, and
that is sysfs.
/sys/bus/pci/devices/0000:00:02.0/resource0
for example is the first resource of a PCI device on my system.
No need to muck about with the dangerous /dev/mem; this one is at least
well defined and portable across systems, including virtualization etc
etc
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
Re: /dev/mem contains physical memory addresses?
am 07.07.2006 07:58:54 von Daniel Rodrick
> > How about peripheral memory mapped to some addresses? Assuming I have
> > a PCI device and a on board flash PROM, would I be able to see them in
> > /proc/(k)mem ? I feel not. Am I correct?
>
> /dev/mem yes
>
> HOWEVER, there is a much nicer way to mmap a PCI device's resources, and
> that is sysfs.
> /sys/bus/pci/devices/0000:00:02.0/resource0
> for example is the first resource of a PCI device on my system.
> No need to muck about with the dangerous /dev/mem; this one is at least
> well defined and portable across systems, including virtualization etc
> etc
So you mean to say that if I have a device whose registers are are
memory mapped to say physical addresses "0x20020000 - 0x20020010".
Then the file /sys/bus/pci/devices/0000:00:02.0/resource0 will contain
thsi memory range as its contents?
Thanks,
Dan
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/
Re: /dev/mem contains physical memory addresses?
am 07.07.2006 08:03:41 von Arjan van de Ven
On Fri, 2006-07-07 at 11:28 +0530, Daniel Rodrick wrote:
> > > How about peripheral memory mapped to some addresses? Assuming I have
> > > a PCI device and a on board flash PROM, would I be able to see them in
> > > /proc/(k)mem ? I feel not. Am I correct?
> >
> > /dev/mem yes
> >
> > HOWEVER, there is a much nicer way to mmap a PCI device's resources, and
> > that is sysfs.
> > /sys/bus/pci/devices/0000:00:02.0/resource0
> > for example is the first resource of a PCI device on my system.
> > No need to muck about with the dangerous /dev/mem; this one is at least
> > well defined and portable across systems, including virtualization etc
> > etc
>
> So you mean to say that if I have a device whose registers are are
> memory mapped to say physical addresses "0x20020000 - 0x20020010".
> Then the file /sys/bus/pci/devices/0000:00:02.0/resource0 will contain
> thsi memory range as its contents?
well assuming the device is 00:02.0 on the bus (obviously you need to
find the right device) and that it's the first resource of the device,
then yes. (and you have to mmap it, not "read"/"write")
lspci -v is your friend in finding out which resource and which device
it is...
Greetings,
Arjan van de Ven
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/