I have a question about how Linux traps memory access errors. As far as I know, a user space program doesn't need to ask operating system every time it wants to access memory, now when the process tries to access a memory location not in it's address space the CPU must be having a way to stop this and communicate this event to the OS.
So my question is: How does the CPU inform the OS about this event ? Does it start executing a predefined code ? If yes, please let me know about where in memory is that code, what is that code section called, what does it do, etc.