]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CcExitLibNull/CcExitLibNull.c
OvmfPkg/UefiCpuPkg: Add CcExit prefix to the APIs of CcExitLib
[mirror_edk2.git] / UefiCpuPkg / Library / CcExitLibNull / CcExitLibNull.c
CommitLineData
87149787 1/** @file\r
a89f558d 2 CcExit Base Support Library.\r
87149787
TL
3\r
4 Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>\r
a89f558d 5 Copyright (c) 2020 - 2022, Intel Corporation. All rights reserved.<BR>\r
87149787
TL
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
a89f558d
MX
10#include <Base.h>\r
11#include <Uefi.h>\r
12#include <Library/CcExitLib.h>\r
eddcba40 13\r
87149787
TL
14/**\r
15 Perform VMGEXIT.\r
16\r
17 Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and\r
18 then handles the return actions.\r
19\r
a89f558d
MX
20 The base library function returns an error in the form of a\r
21 GHCB_EVENT_INJECTION representing a GP_EXCEPTION.\r
22\r
87149787
TL
23 @param[in, out] Ghcb A pointer to the GHCB\r
24 @param[in] ExitCode VMGEXIT code to be assigned to the SwExitCode\r
25 field of the GHCB.\r
26 @param[in] ExitInfo1 VMGEXIT information to be assigned to the\r
27 SwExitInfo1 field of the GHCB.\r
28 @param[in] ExitInfo2 VMGEXIT information to be assigned to the\r
29 SwExitInfo2 field of the GHCB.\r
30\r
31 @retval 0 VMGEXIT succeeded.\r
32 @return Exception number to be propagated, VMGEXIT\r
33 processing did not succeed.\r
34\r
35**/\r
36UINT64\r
37EFIAPI\r
765ba5bf 38CcExitVmgExit (\r
053e878b
MK
39 IN OUT GHCB *Ghcb,\r
40 IN UINT64 ExitCode,\r
41 IN UINT64 ExitInfo1,\r
42 IN UINT64 ExitInfo2\r
a89f558d
MX
43 )\r
44{\r
45 GHCB_EVENT_INJECTION Event;\r
46\r
47 Event.Uint64 = 0;\r
48 Event.Elements.Vector = GP_EXCEPTION;\r
49 Event.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION;\r
50 Event.Elements.Valid = 1;\r
51\r
52 return Event.Uint64;\r
53}\r
87149787
TL
54\r
55/**\r
56 Perform pre-VMGEXIT initialization/preparation.\r
57\r
58 Performs the necessary steps in preparation for invoking VMGEXIT. Must be\r
59 called before setting any fields within the GHCB.\r
60\r
1b0db1ec
TL
61 @param[in, out] Ghcb A pointer to the GHCB\r
62 @param[in, out] InterruptState A pointer to hold the current interrupt\r
765ba5bf 63 state, used for restoring in CcExitVmgDone ()\r
87149787
TL
64\r
65**/\r
66VOID\r
67EFIAPI\r
765ba5bf 68CcExitVmgInit (\r
053e878b
MK
69 IN OUT GHCB *Ghcb,\r
70 IN OUT BOOLEAN *InterruptState\r
a89f558d
MX
71 )\r
72{\r
73}\r
87149787
TL
74\r
75/**\r
76 Perform post-VMGEXIT cleanup.\r
77\r
78 Performs the necessary steps to cleanup after invoking VMGEXIT. Must be\r
79 called after obtaining needed fields within the GHCB.\r
80\r
1b0db1ec
TL
81 @param[in, out] Ghcb A pointer to the GHCB\r
82 @param[in] InterruptState An indicator to conditionally (re)enable\r
83 interrupts\r
87149787
TL
84\r
85**/\r
86VOID\r
87EFIAPI\r
765ba5bf 88CcExitVmgDone (\r
053e878b
MK
89 IN OUT GHCB *Ghcb,\r
90 IN BOOLEAN InterruptState\r
a89f558d
MX
91 )\r
92{\r
93}\r
87149787 94\r
8a7ca992 95/**\r
a89f558d 96 Marks a field at the specified offset as valid in the GHCB.\r
8a7ca992
TL
97\r
98 The ValidBitmap area represents the areas of the GHCB that have been marked\r
99 valid. Set the bit in ValidBitmap for the input offset.\r
100\r
a89f558d
MX
101 @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Block\r
102 @param[in] Offset Qword offset in the GHCB to mark valid\r
8a7ca992
TL
103\r
104**/\r
105VOID\r
106EFIAPI\r
765ba5bf 107CcExitVmgSetOffsetValid (\r
053e878b
MK
108 IN OUT GHCB *Ghcb,\r
109 IN GHCB_REGISTER Offset\r
a89f558d
MX
110 )\r
111{\r
112}\r
8a7ca992
TL
113\r
114/**\r
115 Checks if a specified offset is valid in the GHCB.\r
116\r
117 The ValidBitmap area represents the areas of the GHCB that have been marked\r
118 valid. Return whether the bit in the ValidBitmap is set for the input offset.\r
119\r
120 @param[in] Ghcb A pointer to the GHCB\r
121 @param[in] Offset Qword offset in the GHCB to mark valid\r
122\r
123 @retval TRUE Offset is marked valid in the GHCB\r
124 @retval FALSE Offset is not marked valid in the GHCB\r
125\r
126**/\r
127BOOLEAN\r
128EFIAPI\r
765ba5bf 129CcExitVmgIsOffsetValid (\r
053e878b
MK
130 IN GHCB *Ghcb,\r
131 IN GHCB_REGISTER Offset\r
a89f558d
MX
132 )\r
133{\r
134 return FALSE;\r
135}\r
8a7ca992 136\r
87149787
TL
137/**\r
138 Handle a #VC exception.\r
139\r
140 Performs the necessary processing to handle a #VC exception.\r
141\r
142 The base library function returns an error equal to VC_EXCEPTION,\r
143 to be propagated to the standard exception handling stack.\r
144\r
145 @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set\r
146 as value to use on error.\r
147 @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT\r
148\r
149 @retval EFI_SUCCESS Exception handled\r
150 @retval EFI_UNSUPPORTED #VC not supported, (new) exception value to\r
151 propagate provided\r
152 @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception value to\r
153 propagate provided\r
154\r
155**/\r
156EFI_STATUS\r
157EFIAPI\r
765ba5bf 158CcExitHandleVc (\r
87149787
TL
159 IN OUT EFI_EXCEPTION_TYPE *ExceptionType,\r
160 IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
a89f558d
MX
161 )\r
162{\r
163 *ExceptionType = VC_EXCEPTION;\r
164\r
165 return EFI_UNSUPPORTED;\r
166}\r
87149787 167\r
eddcba40
MX
168/**\r
169 Handle a #VE exception.\r
170\r
171 Performs the necessary processing to handle a #VE exception.\r
172\r
eddcba40
MX
173 @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set\r
174 as value to use on error.\r
175 @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT\r
176\r
177 @retval EFI_SUCCESS Exception handled\r
178 @retval EFI_UNSUPPORTED #VE not supported, (new) exception value to\r
179 propagate provided\r
180 @retval EFI_PROTOCOL_ERROR #VE handling failed, (new) exception value to\r
181 propagate provided\r
182\r
183**/\r
184EFI_STATUS\r
185EFIAPI\r
765ba5bf 186CcExitHandleVe (\r
eddcba40
MX
187 IN OUT EFI_EXCEPTION_TYPE *ExceptionType,\r
188 IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
a89f558d
MX
189 )\r
190{\r
191 *ExceptionType = VE_EXCEPTION;\r
eddcba40 192\r
a89f558d
MX
193 return EFI_UNSUPPORTED;\r
194}\r