SunnyShah
SunnyShah

Reputation: 30527

How to access physical memory in linux from userspace?

I have a physical memory address, which driver provide me through ioctl. How can I access it in my application in linux.

Upvotes: 2

Views: 1728

Answers (3)

Ana Betts
Ana Betts

Reputation: 74702

This is evil, you're going to have subtle problems with this approach, and you're most likely going to corrupt memory. As abyx says, have the IOCTL itself return the memory that you're interested in.

Upvotes: 4

abyx
abyx

Reputation: 73028

Usually, to access that in userspace you'd use copy_to_user() to get a valid userspace copy.

Upvotes: 3

Mads Elvheim
Mads Elvheim

Reputation:

If you absolutely have to, use the functions mmap and mprotect from the header <unistd.h> Open /dev/mem

Upvotes: 5

Related Questions