Environment: Ubuntu9.04 the precautions for using mmap () in 2.6.28.10 kernel (as shown in kernel 2.6.25 +) are not mentioned here. In the new kernel, there are two options related to mmap () ing memory/dev/mem: CONFIG_X86_PAT and CONFIG_STRICT_DEVMEM. The kernel contains the following: CONFIG_STRICT_DEVMEM: Ifthisopti
Environment: Ubuntu 9.04
Let's talk about the precautions for using mmap () in the 2.6.28.10 kernel (as if in the 2.6.25 + kernel.
In the new kernel, there are two options related to mmap () ing memory/dev/mem: CONFIG_X86_PAT and CONFIG_STRICT_DEVMEM. the kernel has such a paragraph:
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 obviusly 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.
Therefore, to use the mmap/ing/dev/mem file, you must cancel the two volumes. If CONFIG_X86_PAT is not canceled,/dev/mem cannot be mapped. If CONFIG_STRICT_DEVMEM is not canceled, the kernel space cannot be mapped. When mmap () is called, the Invalid Parameter error occurs.
Set in the. config file:
CONFIG_X86_PAT = n
CONFIG_STRICT_DEVMEM = n
CONFIG_X86_PAT = n
CONFIG_STRICT_DEVMEM = n
You can also set to cancel two options in the following path:
The CONFIG_X86_PAT is located:
Processor type and features->
[*] X86 PAT support
The position of CONFIG_STRICT_DEVMEM is:
Kernel hacking->
[] Filter access to/dev/mem