【转】Ubuntu 9.04, Kernel 2.6.28.10中mmap()使用

本文讲述了在Ubuntu 9.04上,使用Kernel 2.6.28.10进行mmap()操作时需要注意的配置问题。主要内容涉及CONFIG_X86_PAT和CONFIG_STRICT_DEVMEM两个内核选项,这两项设置会影响到对/dev/mem的映射。如果不禁用这些选项,可能会导致映射失败或权限问题。解决方案是在内核配置中设置CONFIG_X86_PAT为n和CONFIG_STRICT_DEVMEM为n。
摘要由CSDN通过智能技术生成

在这里不说语法和API,就说说在2.6.28.10内核(好像在2.6.25+的内核中就是这样了)中使用mmap()注意的事项。 在新的内核中,有两个选项和mmap()映射内存/dev/mem有关:CONFIG_X86_PAT和CONFIG_STRICT_DEVMEM,内核中有这样一段话:

CONFIG_STRICT_DEVMEM: If this option is disabled, you allow userspace (root) access to all of memory, including kernel and userspace memory. Accidental access to this is obviously disastrous, but specific access can be used by people debugging the kernel. Note that with PAT support enabled, even in this case there are restrictions on /dev/mem use due to the cache aliasing requirements. If this option is switched on, the /dev/mem file only allows userspace access to PCI space and the BIOS code and data regions. This is sufficient for dosemu and X and all common users of /dev/mem.

所以,如果要使用mmap映射/dev/mem文件的话,必须将这两个量取消。如果不取消CONFIG_X86_PAT,则/dev/mem不允许映射;如果不取消CONFIG_STRICT_DEVMEM,则内核空间不能映射,调用mmap()的时候会出现Invalid Parameter错误 在.config文件中

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值