]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/XenPlatformPei/AmdSev.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / XenPlatformPei / AmdSev.c
CommitLineData
3b96221f
AP
1/**@file\r
2 Initialize Secure Encrypted Virtualization (SEV) support\r
3\r
45388d04 4 Copyright (c) 2017 - 2020, Advanced Micro Devices. All rights reserved.<BR>\r
3b96221f
AP
5 Copyright (c) 2019, Citrix Systems, Inc.\r
6\r
7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
8\r
9**/\r
10//\r
11// The package level header files this module uses\r
12//\r
13#include <Library/DebugLib.h>\r
14#include <Library/MemEncryptSevLib.h>\r
15#include <Library/PcdLib.h>\r
16#include <PiPei.h>\r
3b96221f
AP
17\r
18#include "Platform.h"\r
19\r
20/**\r
21\r
22 Function checks if SEV support is available, if present then it sets\r
23 the dynamic PcdPteMemoryEncryptionAddressOrMask with memory encryption mask.\r
24\r
25 **/\r
26VOID\r
27AmdSevInitialize (\r
28 VOID\r
29 )\r
30{\r
ac0a286f
MK
31 UINT64 EncryptionMask;\r
32 RETURN_STATUS PcdStatus;\r
3b96221f
AP
33\r
34 //\r
35 // Check if SEV is enabled\r
36 //\r
37 if (!MemEncryptSevIsEnabled ()) {\r
38 return;\r
39 }\r
40\r
3b96221f
AP
41 //\r
42 // Set Memory Encryption Mask PCD\r
43 //\r
45388d04 44 EncryptionMask = MemEncryptSevGetEncryptionMask ();\r
ac0a286f 45 PcdStatus = PcdSet64S (PcdPteMemoryEncryptionAddressOrMask, EncryptionMask);\r
3b96221f
AP
46 ASSERT_RETURN_ERROR (PcdStatus);\r
47\r
48 DEBUG ((DEBUG_INFO, "SEV is enabled (mask 0x%lx)\n", EncryptionMask));\r
49\r
50 //\r
51 // Set Pcd to Deny the execution of option ROM when security\r
52 // violation.\r
53 //\r
54 PcdStatus = PcdSet32S (PcdOptionRomImageVerificationPolicy, 0x4);\r
55 ASSERT_RETURN_ERROR (PcdStatus);\r
56}\r