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