Role of the SEC Phase in UEFI Boot Sequence
The Security (SEC) phase is the initial stage of the Unified Extensible Firmware Interface (UEFI) boot process, acting as the foundation for platform integrity and hardware initialization. This article outlines the primary functions of the SEC phase, detailing how it establishes the platform's initial root of trust, configures temporary system memory, and safely hands over execution to the Pre-EFI Initialization (PEI) phase.
Primary Purpose: Establishing the Root of Trust
The overarching function of the SEC phase is to establish the initial Root of Trust for the entire system. Because it executes immediately when the platform powers on, the SEC phase verifies the cryptographic signatures and integrity of the early firmware components before executing them. This prevents malicious firmware (such as bootkits) from compromising the boot flow before basic security mechanisms can load.
Key Responsibilities of the SEC Phase
Handling System Reset Events: The SEC phase contains the reset vector code, making it the very first code executed by the CPU upon receiving power or after a hardware reset. It determines the reset cause (such as a power-on reset, warm boot, or wake-up from sleep) and prepares the processor state accordingly.
Transitioning CPU Execution Modes: Modern x86 processors power on in legacy 16-bit real mode. The SEC phase is responsible for transitioning the processor into 32-bit flat protected mode (or 64-bit long mode on certain modern implementations) to allow execution of more complex initialization code.
Configuring Cache-as-RAM (CAR): At this earliest point in the boot sequence, external system memory (DRAM) has not been initialized. To execute C-based code and maintain a stack, the SEC phase configures the CPU's internal L1 or L2 cache to function as temporary memory, a technique known as Cache-as-RAM (CAR).
Passing Control to the PEI Phase: Once temporary memory and basic platform authentication are complete, the SEC phase constructs the Hand-Off Block (HOB) list and locates the entry point of the Pre-EFI Initialization (PEI) Foundation. It then passes vital system parameters—such as the location of the temporary RAM, the size of the firmware volume, and the Boot Firmware Volume (BFV) address—to the PEI phase and relinquishes execution control.