TianoCore EDK2 master
Loading...
Searching...
No Matches
SecMemEncryptSevLibInternal.c
Go to the documentation of this file.
1
11#include <Library/BaseLib.h>
12#include <Library/DebugLib.h>
14#include <Library/PcdLib.h>
15#include <Register/Amd/Cpuid.h>
16#include <Register/Amd/Msr.h>
17#include <Register/Cpuid.h>
18#include <Uefi/UefiBaseType.h>
19
27EFIAPI
29 VOID
30 )
31{
32 OVMF_WORK_AREA *WorkArea;
33
34 WorkArea = (OVMF_WORK_AREA *)FixedPcdGet32 (PcdOvmfWorkAreaBase);
35
36 //
37 // If its not SEV guest then SevEsWorkArea is not valid.
38 //
39 if ((WorkArea == NULL) || (WorkArea->Header.GuestType != CcGuestTypeAmdSev)) {
40 return NULL;
41 }
42
43 return (SEC_SEV_ES_WORK_AREA *)FixedPcdGet32 (PcdSevEsWorkAreaBase);
44}
45
51UINT32
52EFIAPI
54 VOID
55 )
56{
57 SEC_SEV_ES_WORK_AREA *SevEsWorkArea;
58
59 SevEsWorkArea = GetSevEsWorkArea ();
60 if (SevEsWorkArea == NULL) {
61 return 0;
62 }
63
64 return (UINT32)(UINTN)SevEsWorkArea->SevStatusMsrValue;
65}
66
73BOOLEAN
74EFIAPI
76 VOID
77 )
78{
80
81 Msr.Uint32 = InternalMemEncryptSevStatus ();
82
83 return Msr.Bits.SevSnpBit ? TRUE : FALSE;
84}
85
92BOOLEAN
93EFIAPI
95 VOID
96 )
97{
99
100 Msr.Uint32 = InternalMemEncryptSevStatus ();
101
102 return Msr.Bits.SevEsBit ? TRUE : FALSE;
103}
104
111BOOLEAN
112EFIAPI
114 VOID
115 )
116{
118
119 Msr.Uint32 = InternalMemEncryptSevStatus ();
120
121 return Msr.Bits.SevBit ? TRUE : FALSE;
122}
123
129UINT64
130EFIAPI
132 VOID
133 )
134{
135 SEC_SEV_ES_WORK_AREA *SevEsWorkArea;
136
137 SevEsWorkArea = GetSevEsWorkArea ();
138 if (SevEsWorkArea == NULL) {
139 return 0;
140 }
141
142 return SevEsWorkArea->EncryptionMask;
143}
144
151BOOLEAN
152EFIAPI
154 VOID
155 )
156{
158
159 Msr.Uint32 = InternalMemEncryptSevStatus ();
160
161 return Msr.Bits.DebugVirtualization ? TRUE : FALSE;
162}
163
179RETURN_STATUS
180EFIAPI
182 OUT UINTN *BaseAddress,
183 OUT UINTN *NumberOfPages
184 )
185{
186 return RETURN_UNSUPPORTED;
187}
UINT64 UINTN
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define RETURN_UNSUPPORTED
Definition: Base.h:1081
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define OUT
Definition: Base.h:284
#define FixedPcdGet32(TokenName)
Definition: PcdLib.h:92
BOOLEAN EFIAPI MemEncryptSevEsDebugVirtualizationIsEnabled(VOID)
UINT64 EFIAPI MemEncryptSevGetEncryptionMask(VOID)
BOOLEAN EFIAPI MemEncryptSevSnpIsEnabled(VOID)
BOOLEAN EFIAPI MemEncryptSevIsEnabled(VOID)
RETURN_STATUS EFIAPI MemEncryptSevLocateInitialSmramSaveStateMapPages(OUT UINTN *BaseAddress, OUT UINTN *NumberOfPages)
BOOLEAN EFIAPI MemEncryptSevEsIsEnabled(VOID)
STATIC UINT32 EFIAPI InternalMemEncryptSevStatus(VOID)
STATIC SEC_SEV_ES_WORK_AREA *EFIAPI GetSevEsWorkArea(VOID)