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