Use mmap () in Ubuntu9.04Kernel2.6.28.10

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.