mb/lenovo/t530: Convert to ASL 2.0 syntax
[coreboot.git] / Documentation / security / memory_clearing.md
blobe5c19256b9419c065ac8eb027350892c59ca27bc
1 # Memory clearing
3 The main memory on computer platforms in high security environments contains
4 sensible data. On unexpected reboot the data might persist and could be
5 read by a malicious application in the bootflow or userspace.
7 In order to prevent leaking information from pre-reset, the boot firmware can
8 clear the main system memory on boot, wiping all information.
10 A common API indicates if the main memory has to be cleared. That could be
11 on user request or by a Trusted Execution Environment indicating that secrets
12 are in memory.
14 As every platform has different bring-up mechanisms and memory-layouts, every
15 The device must indicate support for memory clearing as part of the boot
16 process.
18 ## Requirements
20 1. The platform must clear all platform memory (DRAM) if requested
21 2. Code that is placed in DRAM might be skipped (as workaround)
22 3. Stack that is placed in DRAM might be skipped (as workaround)
23 4. All DRAM is cleared with zeros
25 ## Implementation
27 A platform that supports memory clearing selects Kconfig
28 ``PLATFORM_HAS_DRAM_CLEAR`` and calls
30 ```C
31 bool security_clear_dram_request(void);
32 ```
34 to detect if memory should be cleared.
36 The memory is cleared in ramstage as part of `DEV_INIT` stage. It's possible to
37 clear it earlier on some platforms, but on x86 MTRRs needs to be programmed
38 first, which happens in `DEV_INIT`.
40 Without MTRRs (and caches enabled) clearing memory takes multiple seconds.
41 ## Exceptions
43 As some platforms place code and stack in DRAM (FSP1.0), the regions can be
44 skipped.
46 ## Architecture specific implementations
48 * [x86 PAE](../arch/x86/pae.md)