]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/MemEncryptSevLib.h
Ovmf/ResetVector: Simplify and consolidate the SEV features checks
[mirror_edk2.git] / OvmfPkg / Include / Library / MemEncryptSevLib.h
CommitLineData
a1f22614
BS
1/** @file\r
2\r
3 Define Secure Encrypted Virtualization (SEV) base library helper function\r
4\r
5 Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
6\r
b26f0cf9 7 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a1f22614
BS
8\r
9**/\r
10\r
11#ifndef _MEM_ENCRYPT_SEV_LIB_H_\r
12#define _MEM_ENCRYPT_SEV_LIB_H_\r
13\r
14#include <Base.h>\r
15\r
0afa1d08
TL
16/**\r
17 Returns a boolean to indicate whether SEV-ES is enabled.\r
18\r
19 @retval TRUE SEV-ES is enabled\r
20 @retval FALSE SEV-ES is not enabled\r
21**/\r
22BOOLEAN\r
23EFIAPI\r
24MemEncryptSevEsIsEnabled (\r
25 VOID\r
26 );\r
27\r
a1f22614
BS
28/**\r
29 Returns a boolean to indicate whether SEV is enabled\r
30\r
d4dd22c7 31 @retval TRUE SEV is enabled\r
a1f22614 32 @retval FALSE SEV is not enabled\r
d4dd22c7 33**/\r
a1f22614
BS
34BOOLEAN\r
35EFIAPI\r
36MemEncryptSevIsEnabled (\r
37 VOID\r
38 );\r
39\r
40/**\r
5b5028e6
LE
41 This function clears memory encryption bit for the memory region specified by\r
42 BaseAddress and NumPages from the current page table context.\r
43\r
44 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
45 current CR3)\r
46 @param[in] BaseAddress The physical address that is the start\r
47 address of a memory region.\r
48 @param[in] NumPages The number of pages from start memory\r
49 region.\r
50 @param[in] Flush Flush the caches before clearing the bit\r
51 (mostly TRUE except MMIO addresses)\r
52\r
53 @retval RETURN_SUCCESS The attributes were cleared for the\r
54 memory region.\r
55 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
56 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r
57 is not supported\r
58**/\r
a1f22614
BS
59RETURN_STATUS\r
60EFIAPI\r
61MemEncryptSevClearPageEncMask (\r
62 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
63 IN PHYSICAL_ADDRESS BaseAddress,\r
5b5028e6
LE
64 IN UINTN NumPages,\r
65 IN BOOLEAN Flush\r
a1f22614
BS
66 );\r
67\r
68/**\r
69 This function sets memory encryption bit for the memory region specified by\r
154dcd6c 70 BaseAddress and NumPages from the current page table context.\r
a1f22614 71\r
154dcd6c
LE
72 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
73 current CR3)\r
74 @param[in] BaseAddress The physical address that is the start\r
75 address of a memory region.\r
76 @param[in] NumPages The number of pages from start memory\r
77 region.\r
78 @param[in] Flush Flush the caches before setting the bit\r
79 (mostly TRUE except MMIO addresses)\r
a1f22614 80\r
154dcd6c
LE
81 @retval RETURN_SUCCESS The attributes were set for the memory\r
82 region.\r
83 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
84 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute\r
85 is not supported\r
86**/\r
a1f22614
BS
87RETURN_STATUS\r
88EFIAPI\r
89MemEncryptSevSetPageEncMask (\r
90 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
91 IN PHYSICAL_ADDRESS BaseAddress,\r
154dcd6c
LE
92 IN UINTN NumPages,\r
93 IN BOOLEAN Flush\r
a1f22614 94 );\r
61a044c6
LE
95\r
96\r
97/**\r
98 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM\r
99 Save State Map.\r
100\r
101 @param[out] BaseAddress The base address of the lowest-address page that\r
102 covers the initial SMRAM Save State Map.\r
103\r
104 @param[out] NumberOfPages The number of pages in the page range that covers\r
105 the initial SMRAM Save State Map.\r
106\r
107 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on\r
108 output.\r
109\r
110 @retval RETURN_UNSUPPORTED SMM is unavailable.\r
111**/\r
112RETURN_STATUS\r
113EFIAPI\r
114MemEncryptSevLocateInitialSmramSaveStateMapPages (\r
115 OUT UINTN *BaseAddress,\r
116 OUT UINTN *NumberOfPages\r
117 );\r
a1f22614 118#endif // _MEM_ENCRYPT_SEV_LIB_H_\r