]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/PlatformPei/AmdSev.c
OvmfPkg/PlatformPei: sync AmdSevInitialize() definition with declaration
[mirror_edk2.git] / OvmfPkg / PlatformPei / AmdSev.c
CommitLineData
13b5d743
BS
1/**@file\r
2 Initialize Secure Encrypted Virtualization (SEV) support\r
3\r
4 Copyright (c) 2017, Advanced Micro Devices. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD\r
8 License which accompanies this distribution. The full text of the license\r
9 may be found at http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15//\r
16// The package level header files this module uses\r
17//\r
18#include <PiPei.h>\r
19\r
20#include <Library/DebugLib.h>\r
21#include <Library/PcdLib.h>\r
22#include <Register/Cpuid.h>\r
23#include <Register/Amd/Cpuid.h>\r
24#include <Library/MemEncryptSevLib.h>\r
25\r
c0d221a3
LE
26#include "Platform.h"\r
27\r
13b5d743
BS
28/**\r
29\r
30 Function checks if SEV support is available, if present then it sets\r
31 the dynamic PcdPteMemoryEncryptionAddressOrMask with memory encryption mask.\r
32\r
33 **/\r
34VOID\r
13b5d743
BS
35AmdSevInitialize (\r
36 VOID\r
37 )\r
38{\r
39 CPUID_MEMORY_ENCRYPTION_INFO_EBX Ebx;\r
40 UINT64 EncryptionMask;\r
41 RETURN_STATUS PcdStatus;\r
42\r
43 //\r
44 // Check if SEV is enabled\r
45 //\r
46 if (!MemEncryptSevIsEnabled ()) {\r
47 return;\r
48 }\r
49\r
50 //\r
51 // CPUID Fn8000_001F[EBX] Bit 0:5 (memory encryption bit position)\r
52 //\r
53 AsmCpuid (CPUID_MEMORY_ENCRYPTION_INFO, NULL, &Ebx.Uint32, NULL, NULL);\r
54 EncryptionMask = LShiftU64 (1, Ebx.Bits.PtePosBits);\r
55\r
56 //\r
57 // Set Memory Encryption Mask PCD\r
58 //\r
59 PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);\r
60 ASSERT_RETURN_ERROR (PcdStatus);\r
61\r
62 DEBUG ((DEBUG_INFO, "SEV is enabled (mask 0x%lx)\n", EncryptionMask));\r
6041ac65
BS
63\r
64 //\r
65 // Set Pcd to Deny the execution of option ROM when security\r
66 // violation.\r
67 //\r
68 PcdStatus = PcdSet32S (PcdOptionRomImageVerificationPolicy, 0x4);\r
69 ASSERT_RETURN_ERROR (PcdStatus);\r
13b5d743 70}\r