Hacker News new | ask | show | jobs
by FooBarWidget 5797 days ago
Why would there by any copying? The kernel can directly read userspace memory.
1 comments

For the kernel to execute a system call, it has to place the arguments on its stack. a system call doesn't execute in the userland.
Yes but the argument to poll is a pointer. The pointer would be copied but the kernel can still follow the pointer to userspace, right?
The pointer referred to by the process is not accessible by the kernel because when the user process was running, it had a different vm space than the kernel vm space. So if it just passes the pointer (without copying the pointer's data), then the kernel will point to a virtual address that won't exist until the user process gets swapped in again.
This sounds really strange to me. The kernel has full access to the page tables so can't it lookup things in userspace?
When the kernel is executing a function call placed on the stack, all the addresses on the stack are assumed in the same vm space. It does not know that an address is actually a virtual memory address belonging to process X and tries to figure out the value in the physical memory.
Yeah but it's possible to look up things in userspace right? So just change poll() to assume that the pointer points to userspace. I don't see the need for copying.