TianoCore EDK2 master
Loading...
Searching...
No Matches
AmdSvsmLib.c File Reference
#include <Base.h>
#include <Uefi.h>
#include <Library/BaseMemoryLib.h>
#include <Library/AmdSvsmLib.h>
#include <Register/Amd/Msr.h>
#include <Register/Amd/Svsm.h>

Go to the source code of this file.

Macros

#define PAGES_PER_2MB_ENTRY   512
 

Functions

STATIC VOID SnpTerminate (VOID)
 
STATIC UINTN SvsmMsrProtocol (IN OUT SVSM_CALL_DATA *SvsmCallData)
 
BOOLEAN EFIAPI AmdSvsmIsSvsmPresent (VOID)
 
UINT8 EFIAPI AmdSvsmSnpGetVmpl (VOID)
 
UINT64 EFIAPI AmdSvsmSnpGetCaa (VOID)
 
STATIC VOID SvsmPvalidate (IN SNP_PAGE_STATE_CHANGE_INFO *Info)
 
STATIC VOID BasePvalidate (IN SNP_PAGE_STATE_CHANGE_INFO *Info)
 
VOID EFIAPI AmdSvsmSnpPvalidate (IN SNP_PAGE_STATE_CHANGE_INFO *Info)
 
STATIC EFI_STATUS SvsmVmsaRmpAdjust (IN SEV_ES_SAVE_AREA *Vmsa, IN UINT32 ApicId, IN BOOLEAN SetVmsa)
 
STATIC EFI_STATUS BaseVmsaRmpAdjust (IN SEV_ES_SAVE_AREA *Vmsa, IN BOOLEAN SetVmsa)
 
EFI_STATUS EFIAPI AmdSvsmSnpVmsaRmpAdjust (IN SEV_ES_SAVE_AREA *Vmsa, IN UINT32 ApicId, IN BOOLEAN SetVmsa)
 

Detailed Description

SVSM Support Library.

Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file AmdSvsmLib.c.

Macro Definition Documentation

◆ PAGES_PER_2MB_ENTRY

#define PAGES_PER_2MB_ENTRY   512

Definition at line 16 of file AmdSvsmLib.c.

Function Documentation

◆ AmdSvsmIsSvsmPresent()

BOOLEAN EFIAPI AmdSvsmIsSvsmPresent ( VOID  )

Report the presence of an Secure Virtual Services Module (SVSM).

Determines the presence of an SVSM.

Return values
TRUEAn SVSM is present
FALSEAn SVSM is not present

Definition at line 130 of file AmdSvsmLib.c.

◆ AmdSvsmSnpGetCaa()

UINT64 EFIAPI AmdSvsmSnpGetCaa ( VOID  )

Report the Calling Area address (CAA) for the BSP of the SEV-SNP guest.

If an SVSM is present, the CAA for the BSP is returned.

Returns
The CAA

Definition at line 174 of file AmdSvsmLib.c.

◆ AmdSvsmSnpGetVmpl()

UINT8 EFIAPI AmdSvsmSnpGetVmpl ( VOID  )

Report the VMPL level at which the SEV-SNP guest is running.

Determines the VMPL level at which the guest is running. If an SVSM is not present, then it must be VMPL0, otherwise return what is reported by the SVSM.

Returns
The VMPL level

Definition at line 153 of file AmdSvsmLib.c.

◆ AmdSvsmSnpPvalidate()

VOID EFIAPI AmdSvsmSnpPvalidate ( IN SNP_PAGE_STATE_CHANGE_INFO Info)

Perform a PVALIDATE operation for the page ranges specified.

Validate or rescind the validation of the specified pages.

Parameters
[in]InfoPointer to a page state change structure

Definition at line 373 of file AmdSvsmLib.c.

◆ AmdSvsmSnpVmsaRmpAdjust()

EFI_STATUS EFIAPI AmdSvsmSnpVmsaRmpAdjust ( IN SEV_ES_SAVE_AREA Vmsa,
IN UINT32  ApicId,
IN BOOLEAN  SetVmsa 
)

Perform an RMPADJUST operation to alter the VMSA setting of a page.

Add or remove the VMSA attribute for a page.

Parameters
[in]VmsaPointer to an SEV-ES save area page
[in]ApicIdAPIC ID associated with the VMSA
[in]SetVmsaBoolean indicator as to whether to set or or clear the VMSA setting for the page
Return values
EFI_SUCCESSRMPADJUST operation successful
EFI_UNSUPPORTEDOperation is not supported
EFI_INVALID_PARAMETERRMPADJUST operation failed, an invalid parameter was supplied

Definition at line 492 of file AmdSvsmLib.c.

◆ BasePvalidate()

STATIC VOID BasePvalidate ( IN SNP_PAGE_STATE_CHANGE_INFO Info)

Perform a native PVALIDATE operation for the page ranges specified.

Validate or rescind the validation of the specified pages.

Parameters
[in]InfoPointer to a page state change structure

Definition at line 303 of file AmdSvsmLib.c.

◆ BaseVmsaRmpAdjust()

STATIC EFI_STATUS BaseVmsaRmpAdjust ( IN SEV_ES_SAVE_AREA Vmsa,
IN BOOLEAN  SetVmsa 
)

Perform a native RMPADJUST operation to alter the VMSA setting of a page.

Add or remove the VMSA attribute for a page.

Parameters
[in]VmsaPointer to an SEV-ES save area page
[in]SetVmsaBoolean indicator as to whether to set or or clear the VMSA setting for the page
Return values
EFI_SUCCESSRMPADJUST operation successful
EFI_INVALID_PARAMETERRMPADJUST operation failed, an invalid parameter was supplied

Definition at line 447 of file AmdSvsmLib.c.

◆ SnpTerminate()

STATIC VOID SnpTerminate ( VOID  )

Issue a GHCB termination request for termination.

Request termination using the GHCB MSR protocol.

Definition at line 26 of file AmdSvsmLib.c.

◆ SvsmMsrProtocol()

STATIC UINTN SvsmMsrProtocol ( IN OUT SVSM_CALL_DATA *  SvsmCallData)

Issue an SVSM request.

Invokes the SVSM to process a request on behalf of the guest.

Parameters
[in,out]SvsmCallDataPointer to the SVSM call data
Returns
Contents of RAX upon return from VMGEXIT

Definition at line 58 of file AmdSvsmLib.c.

◆ SvsmPvalidate()

STATIC VOID SvsmPvalidate ( IN SNP_PAGE_STATE_CHANGE_INFO Info)

Issue an SVSM request to perform the PVALIDATE instruction.

Invokes the SVSM to process the PVALIDATE instruction on behalf of the guest to validate or invalidate the memory range specified.

Parameters
[in]InfoPointer to a page state change structure

Definition at line 196 of file AmdSvsmLib.c.

◆ SvsmVmsaRmpAdjust()

STATIC EFI_STATUS SvsmVmsaRmpAdjust ( IN SEV_ES_SAVE_AREA Vmsa,
IN UINT32  ApicId,
IN BOOLEAN  SetVmsa 
)

Perform an RMPADJUST operation to alter the VMSA setting of a page.

Add or remove the VMSA attribute for a page.

Parameters
[in]VmsaPointer to an SEV-ES save area page
[in]ApicIdAPIC ID associated with the VMSA
[in]SetVmsaBoolean indicator as to whether to set or or clear the VMSA setting for the page
Return values
EFI_SUCCESSRMPADJUST operation successful
EFI_UNSUPPORTEDOperation is not supported
EFI_INVALID_PARAMETERRMPADJUST operation failed, an invalid parameter was supplied

Definition at line 398 of file AmdSvsmLib.c.