文章已收录到http://www.qq-live.com/index.php?app=blog&id=5
使用内核版本为linux-2.6.32-220.23.1.el6。
不能使用mmap映射/dev/mem。
报错如下:
Nov 12 22:26:06 localhost kernel: Program read_test tried to access /dev/mem between 1c21a000->1c21b000.
查找输出的错误,找到可能有两个地方输出这个错误:
1)drivers/char/mem.c
#ifdef CONFIG_STRICT_DEVMEM
static inline int range_is_allowed(unsigned long pfn, unsigned long size)
{
u64 from = ((u64)pfn) << PAGE_SHIFT;
u64 to = from + size;
u64 cursor = from;
while (cursor < to) {
if (!devmem_is_allowed(pfn)) {
printk(KERN_INFO
&