TianoCore EDK2 master
VmgExitVcHandler.c File Reference

Go to the source code of this file.

Data Structures

struct  SEV_ES_INSTRUCTION_MODRM_EXT
 
struct  SEV_ES_INSTRUCTION_SIB_EXT
 
struct  SEV_ES_INSTRUCTION_OPCODE_EXT
 
struct  SEV_ES_INSTRUCTION_DATA
 

Typedefs

typedef UINT64(* NAE_EXIT) (GHCB *Ghcb, EFI_SYSTEM_CONTEXT_X64 *Regs, SEV_ES_INSTRUCTION_DATA *InstructionData)
 
struct {
   UINT32   EaxIn
 
   UINT32   EcxIn
 
   UINT64   Unused
 
   UINT64   Unused2
 
   UINT32   Eax
 
   UINT32   Ebx
 
   UINT32   Ecx
 
   UINT32   Edx
 
   UINT64   Reserved
 
SEV_SNP_CPUID_FUNCTION
 
struct {
   UINT32   Count
 
   UINT32   Reserved1
 
   UINT64   Reserved2
 
   SEV_SNP_CPUID_FUNCTION   function [0]
 
SEV_SNP_CPUID_INFO
 

Enumerations

enum  SEV_ES_INSTRUCTION_MODE { LongMode64Bit = 0 , LongModeCompat32Bit , LongModeCompat16Bit }
 
enum  SEV_ES_INSTRUCTION_SIZE { Size8Bits = 0 , Size16Bits , Size32Bits , Size64Bits }
 
enum  SEV_ES_INSTRUCTION_SEGMENT {
  SegmentEs = 0 , SegmentCs , SegmentSs , SegmentDs ,
  SegmentFs , SegmentGs
}
 
enum  SEV_ES_INSTRUCTION_REP { RepNone = 0 , RepZ , RepNZ }
 

Functions

STATIC UINT64GetRegisterPointer (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN UINT8 Register)
 
STATIC VOID UpdateForDisplacement (IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData, IN UINTN Size)
 
STATIC BOOLEAN IsRipRelative (IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 GetEffectiveMemoryAddress (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC VOID DecodeModRm (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC VOID DecodePrefixes (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 InstructionLength (IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC VOID InitInstructionData (IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData, IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs)
 
STATIC UINT64 UnsupportedExit (IN GHCB *Ghcb, IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 ValidateMmioMemory (IN GHCB *Ghcb, IN UINTN MemoryAddress, IN UINTN MemoryLength)
 
STATIC UINT64 MmioExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 MwaitExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 MonitorExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 WbinvdExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 RdtscpExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 VmmCallExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 MsrExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 IoioExitInfo (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 IoioExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 InvdExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC BOOLEAN GetCpuidHyp (IN OUT GHCB *Ghcb, IN UINT32 EaxIn, IN UINT32 EcxIn, IN UINT64 XCr0, IN OUT UINT32 *Eax, IN OUT UINT32 *Ebx, IN OUT UINT32 *Ecx, IN OUT UINT32 *Edx, IN OUT UINT64 *Status, IN OUT BOOLEAN *UnsupportedExit)
 
STATIC BOOLEAN SnpEnabled (VOID)
 
STATIC BOOLEAN GetCpuidXSaveSize (IN UINT64 XFeaturesEnabled, IN UINT32 XSaveBaseSize, IN OUT UINT32 *XSaveSize, IN BOOLEAN Compacted)
 
STATIC BOOLEAN IsFunctionIndexed (IN UINT32 EaxIn)
 
STATIC BOOLEAN GetCpuidFw (IN OUT GHCB *Ghcb, IN UINT32 EaxIn, IN UINT32 EcxIn, IN UINT64 XCr0, IN OUT UINT32 *Eax, IN OUT UINT32 *Ebx, IN OUT UINT32 *Ecx, IN OUT UINT32 *Edx, IN OUT UINT64 *Status, IN OUT BOOLEAN *Unsupported)
 
STATIC UINT64 CpuidExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 RdpmcExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 RdtscExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 Dr7WriteExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
STATIC UINT64 Dr7ReadExit (IN OUT GHCB *Ghcb, IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN SEV_ES_INSTRUCTION_DATA *InstructionData)
 
EFI_STATUS EFIAPI InternalVmgExitHandleVc (IN OUT GHCB *Ghcb, IN OUT EFI_EXCEPTION_TYPE *ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
 
VOID EFIAPI VmgExitIssueAssert (IN OUT SEV_ES_PER_CPU_DATA *SevEsData)
 

Detailed Description

X64 #VC Exception Handler functon.

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

Definition in file VmgExitVcHandler.c.

Typedef Documentation

◆ NAE_EXIT

typedef UINT64(* NAE_EXIT) (GHCB *Ghcb, EFI_SYSTEM_CONTEXT_X64 *Regs, SEV_ES_INSTRUCTION_DATA *InstructionData)

Definition at line 127 of file VmgExitVcHandler.c.

Enumeration Type Documentation

◆ SEV_ES_INSTRUCTION_MODE

enum SEV_ES_INSTRUCTION_MODE

Definition at line 25 of file VmgExitVcHandler.c.

◆ SEV_ES_INSTRUCTION_REP

enum SEV_ES_INSTRUCTION_REP

Definition at line 56 of file VmgExitVcHandler.c.

◆ SEV_ES_INSTRUCTION_SEGMENT

enum SEV_ES_INSTRUCTION_SEGMENT

Definition at line 44 of file VmgExitVcHandler.c.

◆ SEV_ES_INSTRUCTION_SIZE

enum SEV_ES_INSTRUCTION_SIZE

Definition at line 34 of file VmgExitVcHandler.c.

Function Documentation

◆ CpuidExit()

STATIC UINT64 CpuidExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a CPUID event.

Use VMGEXIT instruction or CPUID table to handle a CPUID event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1952 of file VmgExitVcHandler.c.

◆ DecodeModRm()

STATIC VOID DecodeModRm ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN OUT SEV_ES_INSTRUCTION_DATA InstructionData 
)

Decode a ModRM byte.

Examine the instruction parsing context to decode a ModRM byte and the SIB byte, if present.

Parameters
[in]Regsx64 processor context
[in,out]InstructionDataInstruction parsing context

Definition at line 388 of file VmgExitVcHandler.c.

◆ DecodePrefixes()

STATIC VOID DecodePrefixes ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN OUT SEV_ES_INSTRUCTION_DATA InstructionData 
)

Decode instruction prefixes.

Parse the instruction data to track the instruction prefixes that have been used.

Parameters
[in]Regsx64 processor context
[in,out]InstructionDataInstruction parsing context

Definition at line 448 of file VmgExitVcHandler.c.

◆ Dr7ReadExit()

STATIC UINT64 Dr7ReadExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a DR7 register read event.

Use the VMGEXIT instruction to handle a DR7 read event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully

Definition at line 2182 of file VmgExitVcHandler.c.

◆ Dr7WriteExit()

STATIC UINT64 Dr7WriteExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a DR7 register write event.

Use the VMGEXIT instruction to handle a DR7 write event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 2129 of file VmgExitVcHandler.c.

◆ GetCpuidFw()

STATIC BOOLEAN GetCpuidFw ( IN OUT GHCB *  Ghcb,
IN UINT32  EaxIn,
IN UINT32  EcxIn,
IN UINT64  XCr0,
IN OUT UINT32 Eax,
IN OUT UINT32 Ebx,
IN OUT UINT32 Ecx,
IN OUT UINT32 Edx,
IN OUT UINT64 Status,
IN OUT BOOLEAN Unsupported 
)

Fetch CPUID leaf/function via SEV-SNP CPUID table.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in]EaxInEAX input for cpuid instruction
[in]EcxInECX input for cpuid instruction
[in]Xcr0InXCR0 at time of cpuid instruction
[in,out]EaxPointer to store leaf's EAX value
[in,out]EbxPointer to store leaf's EBX value
[in,out]EcxPointer to store leaf's ECX value
[in,out]EdxPointer to store leaf's EDX value
[in,out]StatusPointer to store status from VMGEXIT (always 0 unless return value indicates failure)
[in,out]UnsupportedPointer to store indication of unsupported VMGEXIT (always false unless return value indicates failure)
Return values
TRUECPUID leaf fetch successfully.
FALSEError occurred while fetching CPUID leaf. Callers should Status and Unsupported and handle accordingly if they indicate a more precise error condition.

Definition at line 1773 of file VmgExitVcHandler.c.

◆ GetCpuidHyp()

STATIC BOOLEAN GetCpuidHyp ( IN OUT GHCB *  Ghcb,
IN UINT32  EaxIn,
IN UINT32  EcxIn,
IN UINT64  XCr0,
IN OUT UINT32 Eax,
IN OUT UINT32 Ebx,
IN OUT UINT32 Ecx,
IN OUT UINT32 Edx,
IN OUT UINT64 Status,
IN OUT BOOLEAN UnsupportedExit 
)

Fetch CPUID leaf/function via hypervisor/VMGEXIT.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in]EaxInEAX input for cpuid instruction
[in]EcxInECX input for cpuid instruction
[in]Xcr0InXCR0 at time of cpuid instruction
[in,out]EaxPointer to store leaf's EAX value
[in,out]EbxPointer to store leaf's EBX value
[in,out]EcxPointer to store leaf's ECX value
[in,out]EdxPointer to store leaf's EDX value
[in,out]StatusPointer to store status from VMGEXIT (always 0 unless return value indicates failure)
[in,out]UnsupportedPointer to store indication of unsupported VMGEXIT (always false unless return value indicates failure)
Return values
TRUECPUID leaf fetch successfully.
FALSEError occurred while fetching CPUID leaf. Callers should Status and Unsupported and handle accordingly if they indicate a more precise error condition.

Definition at line 1570 of file VmgExitVcHandler.c.

◆ GetCpuidXSaveSize()

STATIC BOOLEAN GetCpuidXSaveSize ( IN UINT64  XFeaturesEnabled,
IN UINT32  XSaveBaseSize,
IN OUT UINT32 XSaveSize,
IN BOOLEAN  Compacted 
)

Calculate the total XSAVE area size for enabled XSAVE areas

Parameters
[in]XFeaturesEnabledBit-mask of enabled XSAVE features/areas as indicated by XCR0/MSR_IA32_XSS bits
[in]XSaveBaseSizeBase/legacy XSAVE area size (e.g. when XCR0 is 1)
[in,out]XSaveSizePointer to storage for calculated XSAVE area size
[in]CompactedWhether or not the calculation is for the normal XSAVE area size (leaf 0xD,0x0,EBX) or compacted XSAVE area size (leaf 0xD,0x1,EBX)
Return values
TRUEXSAVE size calculation was successful.
FALSEXSAVE size calculation was unsuccessful.

Definition at line 1665 of file VmgExitVcHandler.c.

◆ GetEffectiveMemoryAddress()

STATIC UINT64 GetEffectiveMemoryAddress ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Return the effective address of a memory operand.

Examine the instruction parsing context to obtain the effective memory address of a memory operand.

Parameters
[in]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Returns
The memory operand effective address

Definition at line 299 of file VmgExitVcHandler.c.

◆ GetRegisterPointer()

STATIC UINT64 * GetRegisterPointer ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN UINT8  Register 
)

Return a pointer to the contents of the specified register.

Based upon the input register, return a pointer to the registers contents in the x86 processor context.

Parameters
[in]Regsx64 processor context
[in]RegisterRegister to obtain pointer for
Returns
Pointer to the contents of the requested register

Definition at line 173 of file VmgExitVcHandler.c.

◆ InitInstructionData()

STATIC VOID InitInstructionData ( IN OUT SEV_ES_INSTRUCTION_DATA InstructionData,
IN GHCB *  Ghcb,
IN EFI_SYSTEM_CONTEXT_X64 Regs 
)

Initialize the instruction parsing context.

Initialize the instruction parsing context, which includes decoding the instruction prefixes.

Parameters
[in,out]InstructionDataInstruction parsing context
[in]GhcbPointer to the Guest-Hypervisor Communication Block
[in]Regsx64 processor context

Definition at line 578 of file VmgExitVcHandler.c.

◆ InstructionLength()

STATIC UINT64 InstructionLength ( IN SEV_ES_INSTRUCTION_DATA InstructionData)

Determine instruction length

Return the total length of the parsed instruction.

Parameters
[in]InstructionDataInstruction parsing context
Returns
Length of parsed instruction

Definition at line 557 of file VmgExitVcHandler.c.

◆ InternalVmgExitHandleVc()

EFI_STATUS EFIAPI InternalVmgExitHandleVc ( IN OUT GHCB *  Ghcb,
IN OUT EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext 
)

Handle a #VC exception.

Performs the necessary processing to handle a #VC exception.

Parameters
[in,out]GhcbPointer to the GHCB
[in,out]ExceptionTypePointer to an EFI_EXCEPTION_TYPE to be set as value to use on error.
[in,out]SystemContextPointer to EFI_SYSTEM_CONTEXT
Return values
EFI_SUCCESSException handled
EFI_UNSUPPORTED#VC not supported, (new) exception value to propagate provided
EFI_PROTOCOL_ERROR#VC handling failed, (new) exception value to propagate provided

Definition at line 2230 of file VmgExitVcHandler.c.

◆ InvdExit()

STATIC UINT64 InvdExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a INVD event.

Use the VMGEXIT instruction to handle a INVD event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1534 of file VmgExitVcHandler.c.

◆ IoioExit()

STATIC UINT64 IoioExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle an IOIO event.

Use the VMGEXIT instruction to handle an IOIO event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1440 of file VmgExitVcHandler.c.

◆ IoioExitInfo()

STATIC UINT64 IoioExitInfo ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN OUT SEV_ES_INSTRUCTION_DATA InstructionData 
)

Build the IOIO event information.

The IOIO event information identifies the type of IO operation to be performed by the hypervisor. Build this information based on the instruction data.

Parameters
[in]Regsx64 processor context
[in,out]InstructionDataInstruction parsing context
Returns
IOIO event information value

Definition at line 1305 of file VmgExitVcHandler.c.

◆ IsFunctionIndexed()

STATIC BOOLEAN IsFunctionIndexed ( IN UINT32  EaxIn)

Check if a CPUID leaf/function is indexed via ECX sub-leaf/sub-function

Parameters
[in]EaxInEAX input for cpuid instruction
Return values
FALSEcpuid leaf/function is not indexed by ECX input
TRUEcpuid leaf/function is indexed by ECX input

Definition at line 1724 of file VmgExitVcHandler.c.

◆ IsRipRelative()

STATIC BOOLEAN IsRipRelative ( IN SEV_ES_INSTRUCTION_DATA InstructionData)

Determine if an instruction address if RIP relative.

Examine the instruction parsing context to determine if the address offset is relative to the instruction pointer.

Parameters
[in]InstructionDataInstruction parsing context
Return values
TRUEInstruction addressing is RIP relative
FALSEInstruction addressing is not RIP relative

Definition at line 271 of file VmgExitVcHandler.c.

◆ MmioExit()

STATIC UINT64 MmioExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN OUT SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle an MMIO event.

Use the VMGEXIT instruction to handle either an MMIO read or an MMIO write.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in,out]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 706 of file VmgExitVcHandler.c.

◆ MonitorExit()

STATIC UINT64 MonitorExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a MONITOR event.

Use the VMGEXIT instruction to handle a MONITOR event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1095 of file VmgExitVcHandler.c.

◆ MsrExit()

STATIC UINT64 MsrExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle an MSR event.

Use the VMGEXIT instruction to handle either a RDMSR or WRMSR event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1244 of file VmgExitVcHandler.c.

◆ MwaitExit()

STATIC UINT64 MwaitExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a MWAIT event.

Use the VMGEXIT instruction to handle a MWAIT event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1063 of file VmgExitVcHandler.c.

◆ RdpmcExit()

STATIC UINT64 RdpmcExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a RDPMC event.

Use the VMGEXIT instruction to handle a RDPMC event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 2044 of file VmgExitVcHandler.c.

◆ RdtscExit()

STATIC UINT64 RdtscExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a RDTSC event.

Use the VMGEXIT instruction to handle a RDTSC event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 2088 of file VmgExitVcHandler.c.

◆ RdtscpExit()

STATIC UINT64 RdtscpExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a RDTSCP event.

Use the VMGEXIT instruction to handle a RDTSCP event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1154 of file VmgExitVcHandler.c.

◆ SnpEnabled()

STATIC BOOLEAN SnpEnabled ( VOID  )

Check if SEV-SNP enabled.

Return values
TRUESEV-SNP is enabled.
FALSESEV-SNP is disabled.

Definition at line 1635 of file VmgExitVcHandler.c.

◆ UnsupportedExit()

STATIC UINT64 UnsupportedExit ( IN GHCB *  Ghcb,
IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Report an unsupported event to the hypervisor

Use the VMGEXIT support to report an unsupported event to the hypervisor.

Parameters
[in]GhcbPointer to the Guest-Hypervisor Communication Block
[in]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Returns
New exception value to propagate

Definition at line 607 of file VmgExitVcHandler.c.

◆ UpdateForDisplacement()

STATIC VOID UpdateForDisplacement ( IN OUT SEV_ES_INSTRUCTION_DATA InstructionData,
IN UINTN  Size 
)

Update the instruction parsing context for displacement bytes.

Parameters
[in,out]InstructionDataInstruction parsing context
[in]SizeThe instruction displacement size

Definition at line 247 of file VmgExitVcHandler.c.

◆ ValidateMmioMemory()

STATIC UINT64 ValidateMmioMemory ( IN GHCB *  Ghcb,
IN UINTN  MemoryAddress,
IN UINTN  MemoryLength 
)

Validate that the MMIO memory access is not to encrypted memory.

Examine the pagetable entry for the memory specified. MMIO should not be performed against encrypted memory. MMIO to the APIC page is always allowed.

Parameters
[in]GhcbPointer to the Guest-Hypervisor Communication Block
[in]MemoryAddressMemory address to validate
[in]MemoryLengthMemory length to validate
Return values
0Memory is not encrypted
Returns
New exception value to propogate

Definition at line 646 of file VmgExitVcHandler.c.

◆ VmgExitIssueAssert()

VOID EFIAPI VmgExitIssueAssert ( IN OUT SEV_ES_PER_CPU_DATA SevEsData)

Routine to allow ASSERT from within #VC.

Parameters
[in,out]SevEsDataPointer to the per-CPU data

Definition at line 2344 of file VmgExitVcHandler.c.

◆ VmmCallExit()

STATIC UINT64 VmmCallExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a VMMCALL event.

Use the VMGEXIT instruction to handle a VMMCALL event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1199 of file VmgExitVcHandler.c.

◆ WbinvdExit()

STATIC UINT64 WbinvdExit ( IN OUT GHCB *  Ghcb,
IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN SEV_ES_INSTRUCTION_DATA InstructionData 
)

Handle a WBINVD event.

Use the VMGEXIT instruction to handle a WBINVD event.

Parameters
[in,out]GhcbPointer to the Guest-Hypervisor Communication Block
[in,out]Regsx64 processor context
[in]InstructionDataInstruction parsing context
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 1129 of file VmgExitVcHandler.c.

Variable Documentation

◆ Count

UINT32 Count

Definition at line 153 of file VmgExitVcHandler.c.

◆ Eax

UINT32 Eax

Definition at line 142 of file VmgExitVcHandler.c.

◆ EaxIn

UINT32 EaxIn

Definition at line 138 of file VmgExitVcHandler.c.

◆ Ebx

UINT32 Ebx

Definition at line 143 of file VmgExitVcHandler.c.

◆ Ecx

UINT32 Ecx

Definition at line 144 of file VmgExitVcHandler.c.

◆ EcxIn

UINT32 EcxIn

Definition at line 139 of file VmgExitVcHandler.c.

◆ Edx

UINT32 Edx

Definition at line 145 of file VmgExitVcHandler.c.

◆ function

SEV_SNP_CPUID_FUNCTION function[0]

Definition at line 156 of file VmgExitVcHandler.c.

◆ Reserved

UINT64 Reserved

Definition at line 146 of file VmgExitVcHandler.c.

◆ Reserved1

UINT32 Reserved1

Definition at line 154 of file VmgExitVcHandler.c.

◆ Reserved2

UINT64 Reserved2

Definition at line 155 of file VmgExitVcHandler.c.

◆ Unused

UINT64 Unused

Definition at line 140 of file VmgExitVcHandler.c.

◆ Unused2

UINT64 Unused2

Definition at line 141 of file VmgExitVcHandler.c.