My understanding is that the Linux kernel allocates a stack to every process before it starts, and this initial size is configurable. A process can
PUSH data to the stack directly via CPU instructions, i.e. without involving the OS in each such step.
At some point, however, the
PUSH operation may exceed the allocated stack size, and a variety of things can happen depending on whether or not the Kernel can allocate a larger stack size.
My question is: What happens right after that initial
PUSH? How does the system detect the "stack overflow", and that it needs to grow the stack until it eventually resumes execution of the process?
We can focus on the x86 arch if helpful.
I'd imagine we have the following parties involved:
For example, who detects the "stack overflow, is it the CPU? the MMU? Does that result in issuing a HW interrupt? Something else? and if so, who handles what here? (until the stack is finally expanded, and the process can resume its next CPU instruction?)