2 Public header file for the VMGEXIT Support library class.
4 This library class defines some routines used when invoking the VMGEXIT
5 instruction in support of SEV-ES and to handle #VC exceptions.
7 Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #ifndef __VMG_EXIT_LIB_H__
13 #define __VMG_EXIT_LIB_H__
15 #include <Protocol/DebugSupport.h>
16 #include <Register/Amd/Ghcb.h>
22 Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and
23 then handles the return actions.
25 @param[in, out] Ghcb A pointer to the GHCB
26 @param[in] ExitCode VMGEXIT code to be assigned to the SwExitCode
28 @param[in] ExitInfo1 VMGEXIT information to be assigned to the
29 SwExitInfo1 field of the GHCB.
30 @param[in] ExitInfo2 VMGEXIT information to be assigned to the
31 SwExitInfo2 field of the GHCB.
33 @retval 0 VMGEXIT succeeded.
34 @return Exception number to be propagated, VMGEXIT
35 processing did not succeed.
48 Perform pre-VMGEXIT initialization/preparation.
50 Performs the necessary steps in preparation for invoking VMGEXIT. Must be
51 called before setting any fields within the GHCB.
53 @param[in, out] Ghcb A pointer to the GHCB
63 Perform post-VMGEXIT cleanup.
65 Performs the necessary steps to cleanup after invoking VMGEXIT. Must be
66 called after obtaining needed fields within the GHCB.
68 @param[in, out] Ghcb A pointer to the GHCB
78 Marks a specified offset as valid in the GHCB.
80 The ValidBitmap area represents the areas of the GHCB that have been marked
81 valid. Set the bit in ValidBitmap for the input offset.
83 @param[in, out] Ghcb A pointer to the GHCB
84 @param[in] Offset Qword offset in the GHCB to mark valid
91 IN GHCB_REGISTER Offset
95 Checks if a specified offset is valid in the GHCB.
97 The ValidBitmap area represents the areas of the GHCB that have been marked
98 valid. Return whether the bit in the ValidBitmap is set for the input offset.
100 @param[in] Ghcb A pointer to the GHCB
101 @param[in] Offset Qword offset in the GHCB to mark valid
103 @retval TRUE Offset is marked valid in the GHCB
104 @retval FALSE Offset is not marked valid in the GHCB
111 IN GHCB_REGISTER Offset
115 Handle a #VC exception.
117 Performs the necessary processing to handle a #VC exception.
119 The base library function returns an error equal to VC_EXCEPTION,
120 to be propagated to the standard exception handling stack.
122 @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set
123 as value to use on error.
124 @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT
126 @retval EFI_SUCCESS Exception handled
127 @retval EFI_UNSUPPORTED #VC not supported, (new) exception value to
129 @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception value to
136 IN OUT EFI_EXCEPTION_TYPE
*ExceptionType
,
137 IN OUT EFI_SYSTEM_CONTEXT SystemContext