Sanctum considers system software to be untrusted, and governs
transitions into and out of enclave code. An enclave's host application
\textbf{enters an enclave} via a security monitor call that locks a thread
state area, and transfers control to its entry point. After completing its
intended task, the enclave code \textbf{exits} by asking the monitor to
unlock the thread's state area, and transfer control back to the host
application.

Enclaves cannot make system calls directly: Sanctum cannot trust
the OS to restore an enclave's execution state, so the enclave's runtime
must ask the host application to proxy syscalls such as file system and
network I/O requests.

Sanctum's security monitor is the first responder for interrupts: an interrupt received during enclave execution causes an \textit{asynchronous
enclave exit} (AEX), whereby the monitor saves the core's registers in the
current thread's AEX state area, zeroes the registers, sanitizes core
microarchitectural state (via a fixed sequence of branches and loads),
exits the enclave, and dispatches the interrupt as if it was received by the
code entering the enclave.

On a normal enclave enter or exit operation (as opposed to an AEX), the enclave
is expected to sanitize its own microarchitectural state, including branch history
and private caches via a sequence of unprivileged instructions.

Unlike SGX, resuming enclave execution after an AEX means re-entering the
enclave using its normal entry point, and having the enclave's code ask the
security monitor to restore the pre-AEX execution state.  Sanctum enclaves are
aware of asynchronous exits so they can implement security policies. For
example, an enclave thread that performs time-sensitive work, such as periodic
I/O, may terminate itself if it ever gets preempted by an AEX.

%TODO fault handler complexity?
The security monitor configures the CPU to dispatch all faults occurring within an
enclave directly to the enclave's designated fault handler, which is expected
to be implemented by the enclave's runtime (SGX sanitizes and dispatches faults to the OS). For example, a \texttt{libc}
runtime would translate faults into UNIX signals which, by default, would exit
the enclave. It is possible, though not advisable for performance reasons
(\S~\ref{sec:enclave_eviction}), for a runtime to handle page faults and
implement demand paging securely, and robust against the
attacks described in \citep{xu2015pagefaults}.
