Getting argv onto user stack

In the recitation diagram, it shows that stackptr and argv are both pointers in kernel space, pointing to addresses on the stack.

However, enter_new_process requires a pointer from userspace to function. Would I be correct in assuming that the pointer to argv itself also has to be copied onto the user stack before passing it into enter_new_process?

No. The pointer gets passed back through a register.

1 Like

Simply passing a pointer into the register takes care of it being put into userspace?

No. The argv char ** pointer gets passed back through a register. It needs to point to the argv char * array, and all of those pointers to strings, which all need to be in user memory. It’s just the initial pointer that doesn’t get passed in memory but rather in a register.