Access permissions of /dev/mem
What does the follow yield:
cat /dev/mem | wc
I get:
cat: /dev/mem: Operation not permitted
1908 11791 1048576
So for me it does stop at 1MB.
Note that cat uses open, not mmap so its not an identical test.
Are you sure you're reading beyond 1MB?
Yes, you're right, /dev/mem allows you to map any physical address, including non-RAM memory mapped IO. This can can be useful for a quick and dirty hack to access some hardware device without writing a kernel driver.
CONFIG_STRICT_DEVMEM makes the kernel check addresses in /dev/mem with
devmem_is_allowed()
inarch/x86/mm/init.c
, and the comment there explains:* On x86, access has to be given to the first megabyte of ram because that area * contains bios code and data regions used by X and dosemu and similar apps. * Access has to be given to non-kernel-ram areas as well, these contain the PCI * mmio resources as well as potential bios/acpi data regions.
your address
0xFFFF0000
is quite likely to be non-RAM, since BIOSes typically put IO memory just below 4GB, so that's why you're able to map it even with STRICT_DEVMEM.