A thread traps to the kernel with INT 80; the interrupt gate is used to change the privilege ring and CS:RIP; the old values are pushed to the 'stack'.
I found this:
'When a thread enters the kernel, the current value of the user-mode stack (SS:ESP) and instruction pointer (CS:EIP) are saved to the thread's kernel-mode stack, and the CPU switches to the kernel-mode stack - with the int $80 syscall mechanism, this is done by the CPU itself. The remaining register values and flags are then also saved to the kernel stack.'
How does the CPU know the address of the thread's kernel mode stack in order to do this? The only place I can think of where the thread's kernel mode stack pointer is stored is in the TCB, but how does the CPU know where to locate the TCB for the current thread. Does it refer to a single TCB in a fixed and known location?