Re: [edk2] [RFC v4 01/13] UefiCpuPkg: Define AMD Memory Encryption specific CPUID and MSR
Reviewed-by: Jeff Fan-Original Message- From: Brijesh Singh [mailto:brijesh.si...@amd.com] Sent: Thursday, May 11, 2017 6:09 AM To: edk2-devel@lists.01.org Cc: thomas.lenda...@amd.com; leo.du...@amd.com; Brijesh Singh; Justen, Jordan L; Laszlo Ersek; Fan, Jeff; Gao, Liming Subject: [RFC v4 01/13] UefiCpuPkg: Define AMD Memory Encryption specific CPUID and MSR The patch defines AMD's Memory Encryption Information CPUID leaf and SEV status MSR. The complete description for CPUID leaf is available in APM volume 2, Section 15.34. Cc: Jordan Justen Cc: Laszlo Ersek Cc: Jeff Fan Cc: Liming Gao Cc: Leo Duran Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brijesh Singh --- UefiCpuPkg/Include/Register/Amd/Cpuid.h| 162 UefiCpuPkg/Include/Register/Amd/Fam17Msr.h | 62 UefiCpuPkg/Include/Register/Amd/Msr.h | 29 3 files changed, 253 insertions(+) diff --git a/UefiCpuPkg/Include/Register/Amd/Cpuid.h b/UefiCpuPkg/Include/Register/Amd/Cpuid.h new file mode 100644 index ..5cd42667dc46 --- /dev/null +++ b/UefiCpuPkg/Include/Register/Amd/Cpuid.h @@ -0,0 +1,162 @@ +/** @file + CPUID leaf definitions. + + Provides defines for CPUID leaf indexes. Data structures are + provided for registers returned by a CPUID leaf that contain one or more bit fields. + If a register returned is a single 32-bit value, then a data + structure is not provided for that register. + + Copyright (c) 2017, Advanced Micro Devices. All rights reserved. + This program and the accompanying materials are licensed and made + available under the terms and conditions of the BSD License which + accompanies this distribution. The full text of the license may be + found at http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + AMD64 Architecture Programming Manaul volume 2, March 2017, Sections + 15.34 + +**/ + +#ifndef __AMD_CPUID_H__ +#define __AMD_CPUID_H__ + +/** + + Memory Encryption Information + + @param EAX CPUID_MEMORY_ENCRYPTION_INFO (0x801F) + + @retval EAX Returns the memory encryption feature support status. + @retval EBX If memory encryption feature is present then return +the page table bit number used to enable memory encryption support +and reducing of physical address space in bits. + @retval ECX Returns number of encrypted guest supported simultaneosuly. + @retval EDX Returns minimum SEV enabled and SEV disbled ASID.. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuid (CPUID_MEMORY_ENCRYPTION_INFO, , , , ); + @endcode +**/ + +#define CPUID_MEMORY_ENCRYPTION_INFO 0x801F + +/** + CPUID Memory Encryption support information EAX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0] Secure Memory Encryption (Sme) Support +/// +UINT32 SmeBit:1; + +/// +/// [Bit 1] Secure Encrypted Virtualization (Sev) Support +/// +UINT32 SevBit:1; + +/// +/// [Bit 2] Page flush MSR support +/// +UINT32 PageFlushMsrBit:1; + +/// +/// [Bit 3] Encrypted state support +/// +UINT32 SevEsBit:1; + +/// +/// [Bit 4:31] Reserved +/// +UINT32 ReservedBits:28; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_EAX; + +/** + CPUID Memory Encryption support information EBX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0:5] Page table bit number used to enable memory encryption +/// +UINT32 PtePosBits:6; + +/// +/// [Bit 6:11] Reduction of system physical address space bits when memory encryption is enabled +/// +UINT32 ReducedPhysBits:5; + +/// +/// [Bit 12:31] Reserved +/// +UINT32 ReservedBits:21; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_EBX; + +/** + CPUID Memory Encryption support information ECX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0:31] Number of encrypted guest supported simultaneously +/// +UINT32 NumGuests; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_ECX; + +/** + CPUID Memory Encryption support information EDX for CPUID leaf +
[edk2] [RFC v4 01/13] UefiCpuPkg: Define AMD Memory Encryption specific CPUID and MSR
The patch defines AMD's Memory Encryption Information CPUID leaf and SEV status MSR. The complete description for CPUID leaf is available in APM volume 2, Section 15.34. Cc: Jordan JustenCc: Laszlo Ersek Cc: Jeff Fan Cc: Liming Gao Cc: Leo Duran Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Brijesh Singh --- UefiCpuPkg/Include/Register/Amd/Cpuid.h| 162 UefiCpuPkg/Include/Register/Amd/Fam17Msr.h | 62 UefiCpuPkg/Include/Register/Amd/Msr.h | 29 3 files changed, 253 insertions(+) diff --git a/UefiCpuPkg/Include/Register/Amd/Cpuid.h b/UefiCpuPkg/Include/Register/Amd/Cpuid.h new file mode 100644 index ..5cd42667dc46 --- /dev/null +++ b/UefiCpuPkg/Include/Register/Amd/Cpuid.h @@ -0,0 +1,162 @@ +/** @file + CPUID leaf definitions. + + Provides defines for CPUID leaf indexes. Data structures are provided for + registers returned by a CPUID leaf that contain one or more bit fields. + If a register returned is a single 32-bit value, then a data structure is + not provided for that register. + + Copyright (c) 2017, Advanced Micro Devices. All rights reserved. + This program and the accompanying materials are licensed and made available + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Specification Reference: + AMD64 Architecture Programming Manaul volume 2, March 2017, Sections 15.34 + +**/ + +#ifndef __AMD_CPUID_H__ +#define __AMD_CPUID_H__ + +/** + + Memory Encryption Information + + @param EAX CPUID_MEMORY_ENCRYPTION_INFO (0x801F) + + @retval EAX Returns the memory encryption feature support status. + @retval EBX If memory encryption feature is present then return +the page table bit number used to enable memory encryption support +and reducing of physical address space in bits. + @retval ECX Returns number of encrypted guest supported simultaneosuly. + @retval EDX Returns minimum SEV enabled and SEV disbled ASID.. + + Example usage + @code + UINT32 Eax; + UINT32 Ebx; + UINT32 Ecx; + UINT32 Edx; + + AsmCpuid (CPUID_MEMORY_ENCRYPTION_INFO, , , , ); + @endcode +**/ + +#define CPUID_MEMORY_ENCRYPTION_INFO 0x801F + +/** + CPUID Memory Encryption support information EAX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0] Secure Memory Encryption (Sme) Support +/// +UINT32 SmeBit:1; + +/// +/// [Bit 1] Secure Encrypted Virtualization (Sev) Support +/// +UINT32 SevBit:1; + +/// +/// [Bit 2] Page flush MSR support +/// +UINT32 PageFlushMsrBit:1; + +/// +/// [Bit 3] Encrypted state support +/// +UINT32 SevEsBit:1; + +/// +/// [Bit 4:31] Reserved +/// +UINT32 ReservedBits:28; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_EAX; + +/** + CPUID Memory Encryption support information EBX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0:5] Page table bit number used to enable memory encryption +/// +UINT32 PtePosBits:6; + +/// +/// [Bit 6:11] Reduction of system physical address space bits when memory encryption is enabled +/// +UINT32 ReducedPhysBits:5; + +/// +/// [Bit 12:31] Reserved +/// +UINT32 ReservedBits:21; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_EBX; + +/** + CPUID Memory Encryption support information ECX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0:31] Number of encrypted guest supported simultaneously +/// +UINT32 NumGuests; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_ECX; + +/** + CPUID Memory Encryption support information EDX for CPUID leaf + #CPUID_MEMORY_ENCRYPTION_INFO. +**/ +typedef union { + /// + /// Individual bit fields + /// + struct { +/// +/// [Bit 0:31] Minimum SEV enabled, SEV-ES disabled ASID +/// +UINT32 MinAsid; + } Bits; + /// + /// All bit fields as a 32-bit value + /// + UINT32 Uint32; +} CPUID_MEMORY_ENCRYPTION_INFO_EDX; + +#endif diff --git a/UefiCpuPkg/Include/Register/Amd/Fam17Msr.h