+++ /dev/null
-/** @file\r
- Public header file for the VMGEXIT Support library class.\r
-\r
- This library class defines some routines used when invoking the VMGEXIT\r
- instruction in support of SEV-ES and to handle #VC exceptions.\r
-\r
- Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#ifndef __VMG_EXIT_LIB_H__\r
-#define __VMG_EXIT_LIB_H__\r
-\r
-#include <Protocol/DebugSupport.h>\r
-#include <Register/Amd/Ghcb.h>\r
-\r
-#define VE_EXCEPTION 20\r
-\r
-/**\r
- Perform VMGEXIT.\r
-\r
- Sets the necessary fields of the GHCB, invokes the VMGEXIT instruction and\r
- then handles the return actions.\r
-\r
- @param[in, out] Ghcb A pointer to the GHCB\r
- @param[in] ExitCode VMGEXIT code to be assigned to the SwExitCode\r
- field of the GHCB.\r
- @param[in] ExitInfo1 VMGEXIT information to be assigned to the\r
- SwExitInfo1 field of the GHCB.\r
- @param[in] ExitInfo2 VMGEXIT information to be assigned to the\r
- SwExitInfo2 field of the GHCB.\r
-\r
- @retval 0 VMGEXIT succeeded.\r
- @return Exception number to be propagated, VMGEXIT\r
- processing did not succeed.\r
-\r
-**/\r
-UINT64\r
-EFIAPI\r
-VmgExit (\r
- IN OUT GHCB *Ghcb,\r
- IN UINT64 ExitCode,\r
- IN UINT64 ExitInfo1,\r
- IN UINT64 ExitInfo2\r
- );\r
-\r
-/**\r
- Perform pre-VMGEXIT initialization/preparation.\r
-\r
- Performs the necessary steps in preparation for invoking VMGEXIT. Must be\r
- called before setting any fields within the GHCB.\r
-\r
- @param[in, out] Ghcb A pointer to the GHCB\r
- @param[in, out] InterruptState A pointer to hold the current interrupt\r
- state, used for restoring in VmgDone ()\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VmgInit (\r
- IN OUT GHCB *Ghcb,\r
- IN OUT BOOLEAN *InterruptState\r
- );\r
-\r
-/**\r
- Perform post-VMGEXIT cleanup.\r
-\r
- Performs the necessary steps to cleanup after invoking VMGEXIT. Must be\r
- called after obtaining needed fields within the GHCB.\r
-\r
- @param[in, out] Ghcb A pointer to the GHCB\r
- @param[in] InterruptState An indicator to conditionally (re)enable\r
- interrupts\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VmgDone (\r
- IN OUT GHCB *Ghcb,\r
- IN BOOLEAN InterruptState\r
- );\r
-\r
-/**\r
- Marks a specified offset as valid in the GHCB.\r
-\r
- The ValidBitmap area represents the areas of the GHCB that have been marked\r
- valid. Set the bit in ValidBitmap for the input offset.\r
-\r
- @param[in, out] Ghcb A pointer to the GHCB\r
- @param[in] Offset Qword offset in the GHCB to mark valid\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-VmgSetOffsetValid (\r
- IN OUT GHCB *Ghcb,\r
- IN GHCB_REGISTER Offset\r
- );\r
-\r
-/**\r
- Checks if a specified offset is valid in the GHCB.\r
-\r
- The ValidBitmap area represents the areas of the GHCB that have been marked\r
- valid. Return whether the bit in the ValidBitmap is set for the input offset.\r
-\r
- @param[in] Ghcb A pointer to the GHCB\r
- @param[in] Offset Qword offset in the GHCB to mark valid\r
-\r
- @retval TRUE Offset is marked valid in the GHCB\r
- @retval FALSE Offset is not marked valid in the GHCB\r
-\r
-**/\r
-BOOLEAN\r
-EFIAPI\r
-VmgIsOffsetValid (\r
- IN GHCB *Ghcb,\r
- IN GHCB_REGISTER Offset\r
- );\r
-\r
-/**\r
- Handle a #VC exception.\r
-\r
- Performs the necessary processing to handle a #VC exception.\r
-\r
- The base library function returns an error equal to VC_EXCEPTION,\r
- to be propagated to the standard exception handling stack.\r
-\r
- @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set\r
- as value to use on error.\r
- @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT\r
-\r
- @retval EFI_SUCCESS Exception handled\r
- @retval EFI_UNSUPPORTED #VC not supported, (new) exception value to\r
- propagate provided\r
- @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception value to\r
- propagate provided\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VmgExitHandleVc (\r
- IN OUT EFI_EXCEPTION_TYPE *ExceptionType,\r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
- );\r
-\r
-/**\r
- Handle a #VE exception.\r
-\r
- Performs the necessary processing to handle a #VE exception.\r
-\r
- The base library function returns an error equal to VE_EXCEPTION,\r
- to be propagated to the standard exception handling stack.\r
-\r
- @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE to be set\r
- as value to use on error.\r
- @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT\r
-\r
- @retval EFI_SUCCESS Exception handled\r
- @retval EFI_UNSUPPORTED #VE not supported, (new) exception value to\r
- propagate provided\r
- @retval EFI_PROTOCOL_ERROR #VE handling failed, (new) exception value to\r
- propagate provided\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-VmTdExitHandleVe (\r
- IN OUT EFI_EXCEPTION_TYPE *ExceptionType,\r
- IN OUT EFI_SYSTEM_CONTEXT SystemContext\r
- );\r
-\r
-#endif\r