]>
Commit | Line | Data |
---|---|---|
a1f22614 BS |
1 | /** @file\r |
2 | \r | |
3 | Define Secure Encrypted Virtualization (SEV) base library helper function\r | |
4 | \r | |
b78de543 | 5 | Copyright (c) 2017 - 2020, AMD Incorporated. All rights reserved.<BR>\r |
a1f22614 | 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 | |
b78de543 TL |
16 | //\r |
17 | // Internal structure for holding SEV-ES information needed during SEC phase\r | |
18 | // and valid only during SEC phase and early PEI during platform\r | |
19 | // initialization.\r | |
20 | //\r | |
21 | // This structure is also used by assembler files:\r | |
22 | // OvmfPkg/ResetVector/ResetVector.nasmb\r | |
23 | // OvmfPkg/ResetVector/Ia32/PageTables64.asm\r | |
24 | // any changes must stay in sync with its usage.\r | |
25 | //\r | |
26 | typedef struct _SEC_SEV_ES_WORK_AREA {\r | |
27 | UINT8 SevEsEnabled;\r | |
28 | } SEC_SEV_ES_WORK_AREA;\r | |
29 | \r | |
0afa1d08 TL |
30 | /**\r |
31 | Returns a boolean to indicate whether SEV-ES is enabled.\r | |
32 | \r | |
33 | @retval TRUE SEV-ES is enabled\r | |
34 | @retval FALSE SEV-ES is not enabled\r | |
35 | **/\r | |
36 | BOOLEAN\r | |
37 | EFIAPI\r | |
38 | MemEncryptSevEsIsEnabled (\r | |
39 | VOID\r | |
40 | );\r | |
41 | \r | |
a1f22614 BS |
42 | /**\r |
43 | Returns a boolean to indicate whether SEV is enabled\r | |
44 | \r | |
d4dd22c7 | 45 | @retval TRUE SEV is enabled\r |
a1f22614 | 46 | @retval FALSE SEV is not enabled\r |
d4dd22c7 | 47 | **/\r |
a1f22614 BS |
48 | BOOLEAN\r |
49 | EFIAPI\r | |
50 | MemEncryptSevIsEnabled (\r | |
51 | VOID\r | |
52 | );\r | |
53 | \r | |
54 | /**\r | |
5b5028e6 LE |
55 | This function clears memory encryption bit for the memory region specified by\r |
56 | BaseAddress and NumPages from the current page table context.\r | |
57 | \r | |
58 | @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r | |
59 | current CR3)\r | |
60 | @param[in] BaseAddress The physical address that is the start\r | |
61 | address of a memory region.\r | |
62 | @param[in] NumPages The number of pages from start memory\r | |
63 | region.\r | |
64 | @param[in] Flush Flush the caches before clearing the bit\r | |
65 | (mostly TRUE except MMIO addresses)\r | |
66 | \r | |
67 | @retval RETURN_SUCCESS The attributes were cleared for the\r | |
68 | memory region.\r | |
69 | @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r | |
70 | @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r | |
71 | is not supported\r | |
72 | **/\r | |
a1f22614 BS |
73 | RETURN_STATUS\r |
74 | EFIAPI\r | |
75 | MemEncryptSevClearPageEncMask (\r | |
76 | IN PHYSICAL_ADDRESS Cr3BaseAddress,\r | |
77 | IN PHYSICAL_ADDRESS BaseAddress,\r | |
5b5028e6 LE |
78 | IN UINTN NumPages,\r |
79 | IN BOOLEAN Flush\r | |
a1f22614 BS |
80 | );\r |
81 | \r | |
82 | /**\r | |
83 | This function sets memory encryption bit for the memory region specified by\r | |
154dcd6c | 84 | BaseAddress and NumPages from the current page table context.\r |
a1f22614 | 85 | \r |
154dcd6c LE |
86 | @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r |
87 | current CR3)\r | |
88 | @param[in] BaseAddress The physical address that is the start\r | |
89 | address of a memory region.\r | |
90 | @param[in] NumPages The number of pages from start memory\r | |
91 | region.\r | |
92 | @param[in] Flush Flush the caches before setting the bit\r | |
93 | (mostly TRUE except MMIO addresses)\r | |
a1f22614 | 94 | \r |
154dcd6c LE |
95 | @retval RETURN_SUCCESS The attributes were set for the memory\r |
96 | region.\r | |
97 | @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r | |
98 | @retval RETURN_UNSUPPORTED Setting the memory encryption attribute\r | |
99 | is not supported\r | |
100 | **/\r | |
a1f22614 BS |
101 | RETURN_STATUS\r |
102 | EFIAPI\r | |
103 | MemEncryptSevSetPageEncMask (\r | |
104 | IN PHYSICAL_ADDRESS Cr3BaseAddress,\r | |
105 | IN PHYSICAL_ADDRESS BaseAddress,\r | |
154dcd6c LE |
106 | IN UINTN NumPages,\r |
107 | IN BOOLEAN Flush\r | |
a1f22614 | 108 | );\r |
61a044c6 LE |
109 | \r |
110 | \r | |
111 | /**\r | |
112 | Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM\r | |
113 | Save State Map.\r | |
114 | \r | |
115 | @param[out] BaseAddress The base address of the lowest-address page that\r | |
116 | covers the initial SMRAM Save State Map.\r | |
117 | \r | |
118 | @param[out] NumberOfPages The number of pages in the page range that covers\r | |
119 | the initial SMRAM Save State Map.\r | |
120 | \r | |
121 | @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on\r | |
122 | output.\r | |
123 | \r | |
124 | @retval RETURN_UNSUPPORTED SMM is unavailable.\r | |
125 | **/\r | |
126 | RETURN_STATUS\r | |
127 | EFIAPI\r | |
128 | MemEncryptSevLocateInitialSmramSaveStateMapPages (\r | |
129 | OUT UINTN *BaseAddress,\r | |
130 | OUT UINTN *NumberOfPages\r | |
131 | );\r | |
a1f22614 | 132 | #endif // _MEM_ENCRYPT_SEV_LIB_H_\r |