How can I run user programs that need more than 4KB of stack space?

You may modify the stack setup code to allocate more than one page of stack space for each process. This is not required in this project.

Syscall

In the 80x86 architecture, the int instruction is the most commonly used means for invoking system calls. This instruction is handled in the same way as other software exceptions.

In Pintos, user programs invoke int $0x30 to make a system call.

Arguments validation

https://cs162.org/static/proj/pintos-docs/docs/userprog/accessing-user-mem/

"sets eax to 0xffffffff and copies its former value into eip."

eax is set to the instruction pointer where the pagefault occurs, so if you want to go back to where you page faulted from you need to set the eip to the former value of eax after you set it to 0xffffffff

if (!user) {
  f->eip = (void (*)(void))f->eax;
  f->eax = 0;
  return;
}