No One in Particular
No One in Particular

Reputation: 2874

Can a user buffer always be mapped into a contiguous kernel virtual address?

If a user creates a buffer (either through malloc or static configuration), can this buffer always be mapped into the kernels address space contiguously?

I want to have the kernel loop over the array in user space without copying it via copy_from_user and then copy_to_user.

Given that the user presents the address/length of the buffer to the kernel via an ioctl, what calls do I make at the kernel layer to get a kva for the entire buffer.

Thanks.

Upvotes: 0

Views: 66

Answers (1)

Alex Hoppus
Alex Hoppus

Reputation: 3935

Theoretically, if you are in the context of your application (you are making ioctl), nothing stops you to write/read directly from user address from kernel except swapping (if this is a case in your system). So you can use mlock to pin your ram buffer in userspace. You don't need kva here, you might use user address. I'am not completely sure, but this should work. Have you tried?

Upvotes: 0

Related Questions