]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c
OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix erase blocks for SEV-ES
[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
38 IN OUT GHCB *Ghcb,\r
39 IN UINT64 ExitCode,\r
40 IN UINT64 ExitInfo1,\r
41 IN UINT64 ExitInfo2\r
42 )\r
43{\r
44 GHCB_EVENT_INJECTION Event;\r
45\r
46 Event.Uint64 = 0;\r
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
60 The base library function does nothing.\r
61\r
62 @param[in, out] Ghcb A pointer to the GHCB\r
63\r
64**/\r
65VOID\r
66EFIAPI\r
67VmgInit (\r
68 IN OUT GHCB *Ghcb\r
69 )\r
70{\r
71}\r
72\r
73/**\r
74 Perform post-VMGEXIT cleanup.\r
75\r
76 Performs the necessary steps to cleanup after invoking VMGEXIT. Must be\r
77 called after obtaining needed fields within the GHCB.\r
78\r
79 The base library function does nothing.\r
80\r
81 @param[in, out] Ghcb A pointer to the GHCB\r
82\r
83**/\r
84VOID\r
85EFIAPI\r
86VmgDone (\r
87 IN OUT GHCB *Ghcb\r
88 )\r
89{\r
90}\r
91\r
8a7ca992
TL
92/**\r
93 Marks a field at the specified offset as valid in the GHCB.\r
94\r
95 The ValidBitmap area represents the areas of the GHCB that have been marked\r
96 valid. Set the bit in ValidBitmap for the input offset.\r
97\r
98 @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Block\r
99 @param[in] Offset Qword offset in the GHCB to mark valid\r
100\r
101**/\r
102VOID\r
103EFIAPI\r
104VmgSetOffsetValid (\r
105 IN OUT GHCB *Ghcb,\r
106 IN GHCB_REGISTER Offset\r
107 )\r
108{\r
109}\r
110\r
111/**\r
112 Checks if a specified offset is valid in the GHCB.\r
113\r
114 The ValidBitmap area represents the areas of the GHCB that have been marked\r
115 valid. Return whether the bit in the ValidBitmap is set for the input offset.\r
116\r
117 @param[in] Ghcb A pointer to the GHCB\r
118 @param[in] Offset Qword offset in the GHCB to mark valid\r
119\r
120 @retval TRUE Offset is marked valid in the GHCB\r
121 @retval FALSE Offset is not marked valid in the GHCB\r
122\r
123**/\r
124BOOLEAN\r
125EFIAPI\r
126VmgIsOffsetValid (\r
127 IN GHCB *Ghcb,\r
128 IN GHCB_REGISTER Offset\r
129 )\r
130{\r
131 return FALSE;\r
132}\r
133\r
87149787
TL
134/**\r
135 Handle a #VC exception.\r
136\r
137 Performs the necessary processing to handle a #VC exception.\r
138\r
139 The base library function returns an error equal to VC_EXCEPTION,\r
140 to be propagated to the standard exception handling stack.\r
141\r
142 @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set\r
143 as value to use on error.\r
144 @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT\r
145\r
146 @retval EFI_SUCCESS Exception handled\r
147 @retval EFI_UNSUPPORTED #VC not supported, (new) exception value to\r
148 propagate provided\r
149 @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception value to\r
150 propagate provided\r
151\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155VmgExitHandleVc (\r
156 IN OUT EFI_EXCEPTION_TYPE *ExceptionType,\r
157 IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
158 )\r
159{\r
160 *ExceptionType = VC_EXCEPTION;\r
161\r
162 return EFI_UNSUPPORTED;\r
163}\r