2 VMGEXIT Base Support Library.
4 Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/VmgExitLib.h>
16 Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and
17 then handles the return actions.
19 The base library function returns an error in the form of a
20 GHCB_EVENT_INJECTION representing a GP_EXCEPTION.
22 @param[in, out] Ghcb A pointer to the GHCB
23 @param[in] ExitCode VMGEXIT code to be assigned to the SwExitCode
25 @param[in] ExitInfo1 VMGEXIT information to be assigned to the
26 SwExitInfo1 field of the GHCB.
27 @param[in] ExitInfo2 VMGEXIT information to be assigned to the
28 SwExitInfo2 field of the GHCB.
30 @retval 0 VMGEXIT succeeded.
31 @return Exception number to be propagated, VMGEXIT
32 processing did not succeed.
44 GHCB_EVENT_INJECTION Event
;
47 Event
.Elements
.Vector
= GP_EXCEPTION
;
48 Event
.Elements
.Type
= GHCB_EVENT_INJECTION_TYPE_EXCEPTION
;
49 Event
.Elements
.Valid
= 1;
55 Perform pre-VMGEXIT initialization/preparation.
57 Performs the necessary steps in preparation for invoking VMGEXIT. Must be
58 called before setting any fields within the GHCB.
60 The base library function does nothing.
62 @param[in, out] Ghcb A pointer to the GHCB
74 Perform post-VMGEXIT cleanup.
76 Performs the necessary steps to cleanup after invoking VMGEXIT. Must be
77 called after obtaining needed fields within the GHCB.
79 The base library function does nothing.
81 @param[in, out] Ghcb A pointer to the GHCB
93 Handle a #VC exception.
95 Performs the necessary processing to handle a #VC exception.
97 The base library function returns an error equal to VC_EXCEPTION,
98 to be propagated to the standard exception handling stack.
100 @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set
101 as value to use on error.
102 @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT
104 @retval EFI_SUCCESS Exception handled
105 @retval EFI_UNSUPPORTED #VC not supported, (new) exception value to
107 @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception value to
114 IN OUT EFI_EXCEPTION_TYPE
*ExceptionType
,
115 IN OUT EFI_SYSTEM_CONTEXT SystemContext
118 *ExceptionType
= VC_EXCEPTION
;
120 return EFI_UNSUPPORTED
;