4

The device we work at now need to have a user space virtual memory address, we try to use do_mmap() as below:

*uvaddr = (void *)do_mmap(0, 0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, 0); 

But we got following error

Unable to handle kernel paging request for data at ad8 

Is it okay to use "do_mmap()" in a device driver? If not, any correct way to do it?

0

1 Answer 1

1

It's possible that do_mmap is succeeding, but uvaddr does not point to a valid location to store the result. To check this for sure, do something like:

void *mmap_result; printk(KERN_DEBUG "uvaddr = %p", uvaddr); mmap_result = (void *)do_mmap(0, 0, size, PROT_READ|PROT_WRITE, MAP_ANONYMOUS, 0); printk(KERN_DEBUG "mmap_result = %p", mmap_result); *uvaddr = mmap_result; 

This should tell you for certain which is failing: the call to do_mmap or the assignment to *uvaddr.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.