Member-only story
Exceptions on macOS
Introduction to Exception Handling and Syscalls on macOS
This article explores how macOS handles exceptions and system calls on Apple Silicon, focusing on Exception Levels, transition mechanisms, and processing synchronous and asynchronous exceptions. We will cover the role of Supervisor Calls (SVC), handling interrupts (IRQ/FIQ), and system errors (SError), as well as how user apps interact with the kernel through BSD system calls and Mach traps on some simple example programs.
I tried to explain everything in simple words, but if the concept of kernel and user mode is new to you, I encourage you to watch this first:
At the bottom of the article, you will also find the Exception Handle Map that summarizes the whole content of this article. Enjoy!
Exception Levels
Apple Silicon’s macOS is based on the ARM architecture, which employs a hierarchical privilege model based on Exception Levels (ELs). They define the execution context and privileges of code running on the processor: