]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/MemEncryptSevLib.h
OvmfPkg/VmgExitLib: Add support for DR7 Read/Write NAE events
[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
16/**\r
17 Returns a boolean to indicate whether SEV is enabled\r
18\r
d4dd22c7 19 @retval TRUE SEV is enabled\r
a1f22614 20 @retval FALSE SEV is not enabled\r
d4dd22c7 21**/\r
a1f22614
BS
22BOOLEAN\r
23EFIAPI\r
24MemEncryptSevIsEnabled (\r
25 VOID\r
26 );\r
27\r
28/**\r
5b5028e6
LE
29 This function clears memory encryption bit for the memory region specified by\r
30 BaseAddress and NumPages from the current page table context.\r
31\r
32 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
33 current CR3)\r
34 @param[in] BaseAddress The physical address that is the start\r
35 address of a memory region.\r
36 @param[in] NumPages The number of pages from start memory\r
37 region.\r
38 @param[in] Flush Flush the caches before clearing the bit\r
39 (mostly TRUE except MMIO addresses)\r
40\r
41 @retval RETURN_SUCCESS The attributes were cleared for the\r
42 memory region.\r
43 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
44 @retval RETURN_UNSUPPORTED Clearing the memory encryption attribute\r
45 is not supported\r
46**/\r
a1f22614
BS
47RETURN_STATUS\r
48EFIAPI\r
49MemEncryptSevClearPageEncMask (\r
50 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
51 IN PHYSICAL_ADDRESS BaseAddress,\r
5b5028e6
LE
52 IN UINTN NumPages,\r
53 IN BOOLEAN Flush\r
a1f22614
BS
54 );\r
55\r
56/**\r
57 This function sets memory encryption bit for the memory region specified by\r
154dcd6c 58 BaseAddress and NumPages from the current page table context.\r
a1f22614 59\r
154dcd6c
LE
60 @param[in] Cr3BaseAddress Cr3 Base Address (if zero then use\r
61 current CR3)\r
62 @param[in] BaseAddress The physical address that is the start\r
63 address of a memory region.\r
64 @param[in] NumPages The number of pages from start memory\r
65 region.\r
66 @param[in] Flush Flush the caches before setting the bit\r
67 (mostly TRUE except MMIO addresses)\r
a1f22614 68\r
154dcd6c
LE
69 @retval RETURN_SUCCESS The attributes were set for the memory\r
70 region.\r
71 @retval RETURN_INVALID_PARAMETER Number of pages is zero.\r
72 @retval RETURN_UNSUPPORTED Setting the memory encryption attribute\r
73 is not supported\r
74**/\r
a1f22614
BS
75RETURN_STATUS\r
76EFIAPI\r
77MemEncryptSevSetPageEncMask (\r
78 IN PHYSICAL_ADDRESS Cr3BaseAddress,\r
79 IN PHYSICAL_ADDRESS BaseAddress,\r
154dcd6c
LE
80 IN UINTN NumPages,\r
81 IN BOOLEAN Flush\r
a1f22614 82 );\r
61a044c6
LE
83\r
84\r
85/**\r
86 Locate the page range that covers the initial (pre-SMBASE-relocation) SMRAM\r
87 Save State Map.\r
88\r
89 @param[out] BaseAddress The base address of the lowest-address page that\r
90 covers the initial SMRAM Save State Map.\r
91\r
92 @param[out] NumberOfPages The number of pages in the page range that covers\r
93 the initial SMRAM Save State Map.\r
94\r
95 @retval RETURN_SUCCESS BaseAddress and NumberOfPages have been set on\r
96 output.\r
97\r
98 @retval RETURN_UNSUPPORTED SMM is unavailable.\r
99**/\r
100RETURN_STATUS\r
101EFIAPI\r
102MemEncryptSevLocateInitialSmramSaveStateMapPages (\r
103 OUT UINTN *BaseAddress,\r
104 OUT UINTN *NumberOfPages\r
105 );\r
a1f22614 106#endif // _MEM_ENCRYPT_SEV_LIB_H_\r