mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
x86/cpu/AMD: Document AMD Secure Memory Encryption (SME)
Create a Documentation entry to describe the AMD Secure Memory Encryption (SME) feature and add documentation for the mem_encrypt= kernel parameter. Signed-off-by: Tom Lendacky <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brijesh Singh <[email protected]> Cc: Dave Young <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Jonathan Corbet <[email protected]> Cc: Konrad Rzeszutek Wilk <[email protected]> Cc: Larry Woodman <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Matt Fleming <[email protected]> Cc: Michael S. Tsirkin <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Radim Krčmář <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Toshimitsu Kani <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/ca0a0c13b055fd804cfc92cbaca8acd68057eed0.1500319216.git.thomas.lendacky@amd.com Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
1ed7d32763
commit
c262f3b9a3
2 changed files with 79 additions and 0 deletions
68
Documentation/x86/amd-memory-encryption.txt
Normal file
68
Documentation/x86/amd-memory-encryption.txt
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
Secure Memory Encryption (SME) is a feature found on AMD processors.
|
||||
|
||||
SME provides the ability to mark individual pages of memory as encrypted using
|
||||
the standard x86 page tables. A page that is marked encrypted will be
|
||||
automatically decrypted when read from DRAM and encrypted when written to
|
||||
DRAM. SME can therefore be used to protect the contents of DRAM from physical
|
||||
attacks on the system.
|
||||
|
||||
A page is encrypted when a page table entry has the encryption bit set (see
|
||||
below on how to determine its position). The encryption bit can also be
|
||||
specified in the cr3 register, allowing the PGD table to be encrypted. Each
|
||||
successive level of page tables can also be encrypted by setting the encryption
|
||||
bit in the page table entry that points to the next table. This allows the full
|
||||
page table hierarchy to be encrypted. Note, this means that just because the
|
||||
encryption bit is set in cr3, doesn't imply the full hierarchy is encyrpted.
|
||||
Each page table entry in the hierarchy needs to have the encryption bit set to
|
||||
achieve that. So, theoretically, you could have the encryption bit set in cr3
|
||||
so that the PGD is encrypted, but not set the encryption bit in the PGD entry
|
||||
for a PUD which results in the PUD pointed to by that entry to not be
|
||||
encrypted.
|
||||
|
||||
Support for SME can be determined through the CPUID instruction. The CPUID
|
||||
function 0x8000001f reports information related to SME:
|
||||
|
||||
0x8000001f[eax]:
|
||||
Bit[0] indicates support for SME
|
||||
0x8000001f[ebx]:
|
||||
Bits[5:0] pagetable bit number used to activate memory
|
||||
encryption
|
||||
Bits[11:6] reduction in physical address space, in bits, when
|
||||
memory encryption is enabled (this only affects
|
||||
system physical addresses, not guest physical
|
||||
addresses)
|
||||
|
||||
If support for SME is present, MSR 0xc00100010 (MSR_K8_SYSCFG) can be used to
|
||||
determine if SME is enabled and/or to enable memory encryption:
|
||||
|
||||
0xc0010010:
|
||||
Bit[23] 0 = memory encryption features are disabled
|
||||
1 = memory encryption features are enabled
|
||||
|
||||
Linux relies on BIOS to set this bit if BIOS has determined that the reduction
|
||||
in the physical address space as a result of enabling memory encryption (see
|
||||
CPUID information above) will not conflict with the address space resource
|
||||
requirements for the system. If this bit is not set upon Linux startup then
|
||||
Linux itself will not set it and memory encryption will not be possible.
|
||||
|
||||
The state of SME in the Linux kernel can be documented as follows:
|
||||
- Supported:
|
||||
The CPU supports SME (determined through CPUID instruction).
|
||||
|
||||
- Enabled:
|
||||
Supported and bit 23 of MSR_K8_SYSCFG is set.
|
||||
|
||||
- Active:
|
||||
Supported, Enabled and the Linux kernel is actively applying
|
||||
the encryption bit to page table entries (the SME mask in the
|
||||
kernel is non-zero).
|
||||
|
||||
SME can also be enabled and activated in the BIOS. If SME is enabled and
|
||||
activated in the BIOS, then all memory accesses will be encrypted and it will
|
||||
not be necessary to activate the Linux memory encryption support. If the BIOS
|
||||
merely enables SME (sets bit 23 of the MSR_K8_SYSCFG), then Linux can activate
|
||||
memory encryption by default (CONFIG_AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT=y) or
|
||||
by supplying mem_encrypt=on on the kernel command line. However, if BIOS does
|
||||
not enable SME, then Linux will not be able to activate memory encryption, even
|
||||
if configured to do so by default or the mem_encrypt=on command line parameter
|
||||
is specified.
|
||||
Loading…
Reference in a new issue