Issue
How do kernel switch the kernel stack and user stack?
I'm viewing interrupt handling in linux kernel.
I know that process only use kernel stack in kernel mode.
But, How it bring the kernel stack pointer when interrupt is occurred?
I didn't saw that kernel save its stack pointer to some register in the interrupt exit code.
Solution
The TSS have a pointer to kernel stack.
When the INT n
is called, the CPU read TSS by referring the GDT.
The TSS have kernel stack pointer and it is set when the thread is created.
The CPU read kernel stack pointer and set esp to kernel stack pointer and compose interrupt frame in kernel stack.
Answered By - Joontaek Oh Answer Checked By - David Goodson (WPSolving Volunteer)