4

Accessing mmaped /dev/mem [migrated]

view full story
linux-howto

http://unix.stackexchange.com – I have simple program that tries to access the physical memory in user space, where the kernel stores the first struct page. On a 64-bit machine this address is: kernel virtual address: ffffea0000000000 physical address: 0000620000000000 I am trying to access this physical address through mmap in user space, but the following code crashes the kernel: int *addr; if ((fd = open("/dev/mem", O_RDWR|O_SYNC)) < 0 ) { printf("Error opening file. \n"); close(fd); return (-1); } /* mmap. address of first struct page for 64 bit architectures * is 0x0000620000000000. */ addr = (HowTos)