TianoCore EDK2 master
Loading...
Searching...
No Matches
CcExitVeHandler.c File Reference

Go to the source code of this file.

Data Structures

union  MSR_DATA
 
union  REX
 
union  MODRM
 
struct  CPUID_DATA
 
struct  MMIO_EXIT_PARSED_INSTRUCTION
 

Macros

#define TDX_MMIO_READ   0
 
#define TDX_MMIO_WRITE   1
 
#define TDX_DECODER_BUG_ON(x)
 

Functions

STATIC UINT64 EFIAPI CpuIdExit (IN EFI_SYSTEM_CONTEXT_X64 *Regs, IN TDCALL_VEINFO_RETURN_DATA *Veinfo)
 
STATIC UINT64 EFIAPI IoExit (IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN TDCALL_VEINFO_RETURN_DATA *Veinfo)
 
STATIC UINT64 ReadMsrExit (IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN TDCALL_VEINFO_RETURN_DATA *Veinfo)
 
STATIC UINT64 WriteMsrExit (IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN TDCALL_VEINFO_RETURN_DATA *Veinfo)
 
STATIC VOID EFIAPI TdxDecodeInstruction (IN UINT8 *Rip, IN UINT32 Length)
 
STATIC EFI_STATUS TdxMmioReadWrite (IN UINT32 MmioSize, IN UINT32 ReadOrWrite, IN UINT64 GuestPA, IN UINT64 *Val)
 
STATIC EFI_STATUS ParseMmioExitInstructions (IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN OUT CC_INSTRUCTION_DATA *InstructionData, OUT MMIO_EXIT_PARSED_INSTRUCTION *ParsedInstruction)
 
STATIC UINT64 EFIAPI MmioExit (IN OUT EFI_SYSTEM_CONTEXT_X64 *Regs, IN TDCALL_VEINFO_RETURN_DATA *Veinfo)
 
EFI_STATUS EFIAPI CcExitHandleVe (IN OUT EFI_EXCEPTION_TYPE *ExceptionType, IN OUT EFI_SYSTEM_CONTEXT SystemContext)
 

Detailed Description

Copyright (c) 2021, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CcExitVeHandler.c.

Macro Definition Documentation

◆ TDX_DECODER_BUG_ON

#define TDX_DECODER_BUG_ON (   x)
Value:
if ((x)) { \
TdxDecodeInstruction(Rip); \
TdVmCall(TDVMCALL_HALT, 0, 0, 0, 0, 0); \
CpuDeadLoop (); \
}

Definition at line 238 of file CcExitVeHandler.c.

◆ TDX_MMIO_READ

#define TDX_MMIO_READ   0

Definition at line 18 of file CcExitVeHandler.c.

◆ TDX_MMIO_WRITE

#define TDX_MMIO_WRITE   1

Definition at line 19 of file CcExitVeHandler.c.

Function Documentation

◆ CcExitHandleVe()

EFI_STATUS EFIAPI CcExitHandleVe ( IN OUT EFI_EXCEPTION_TYPE ExceptionType,
IN OUT EFI_SYSTEM_CONTEXT  SystemContext 
)

Handle a #VE exception.

Performs the necessary processing to handle a #VE exception.

Parameters
[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#VE not supported, (new) exception value to propagate provided
EFI_PROTOCOL_ERROR#VE handling failed, (new) exception value to propagate provided

Definition at line 684 of file CcExitVeHandler.c.

◆ CpuIdExit()

STATIC UINT64 EFIAPI CpuIdExit ( IN EFI_SYSTEM_CONTEXT_X64 Regs,
IN TDCALL_VEINFO_RETURN_DATA Veinfo 
)

Handle an CPUID event.

Use the TDVMCALL instruction to handle cpuid #ve

Parameters
[in,out]Regsx64 processor context
[in]VeinfoVE Info
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 66 of file CcExitVeHandler.c.

◆ IoExit()

STATIC UINT64 EFIAPI IoExit ( IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN TDCALL_VEINFO_RETURN_DATA Veinfo 
)

Handle an IO event.

Use the TDVMCALL instruction to handle either an IO read or an IO write.

Parameters
[in,out]Regsx64 processor context
[in]VeinfoVE Info
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 100 of file CcExitVeHandler.c.

◆ MmioExit()

STATIC UINT64 EFIAPI MmioExit ( IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN TDCALL_VEINFO_RETURN_DATA Veinfo 
)

Handle an MMIO event.

Use the TDVMCALL instruction to handle either an mmio read or an mmio write.

Parameters
[in,out]Regsx64 processor context
[in]VeinfoVE Info
Return values
0Event handled successfully

Definition at line 590 of file CcExitVeHandler.c.

◆ ParseMmioExitInstructions()

STATIC EFI_STATUS ParseMmioExitInstructions ( IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN OUT CC_INSTRUCTION_DATA InstructionData,
OUT MMIO_EXIT_PARSED_INSTRUCTION ParsedInstruction 
)

Parse the MMIO instructions.

Parameters
RegsPointer to the EFI_SYSTEM_CONTEXT_X64 which includes the instructions
InstructionDataPointer to the CC_INSTRUCTION_DATA
ParsedInstructionPointer to the parsed instruction data
Return values
EFI_SUCCESSSuccessfully parsed the instructions
OthersOther error as indicated

Definition at line 314 of file CcExitVeHandler.c.

◆ ReadMsrExit()

STATIC UINT64 ReadMsrExit ( IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN TDCALL_VEINFO_RETURN_DATA Veinfo 
)

Handle an READ MSR event.

Use the TDVMCALL instruction to handle msr read

Parameters
[in,out]Regsx64 processor context
[in]VeinfoVE Info
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 174 of file CcExitVeHandler.c.

◆ TdxDecodeInstruction()

STATIC VOID EFIAPI TdxDecodeInstruction ( IN UINT8 *  Rip,
IN UINT32  Length 
)

Definition at line 223 of file CcExitVeHandler.c.

◆ TdxMmioReadWrite()

STATIC EFI_STATUS TdxMmioReadWrite ( IN UINT32  MmioSize,
IN UINT32  ReadOrWrite,
IN UINT64  GuestPA,
IN UINT64 *  Val 
)

Tdx MMIO access via TdVmcall.

Parameters
MmioSizeSize of the MMIO access
ReadOrWriteRead or write operation
GuestPAGuest physical address
ValPointer to the value which is read or written
Return values
EFI_SUCCESSSuccessfully access the mmio
OthersOther errors as indicated

Definition at line 258 of file CcExitVeHandler.c.

◆ WriteMsrExit()

STATIC UINT64 WriteMsrExit ( IN OUT EFI_SYSTEM_CONTEXT_X64 Regs,
IN TDCALL_VEINFO_RETURN_DATA Veinfo 
)

Handle an WRITE MSR event.

Use the TDVMCALL instruction to handle msr write

Parameters
[in,out]Regsx64 processor context
[in]VeinfoVE Info
Return values
0Event handled successfully
Returns
New exception value to propagate

Definition at line 204 of file CcExitVeHandler.c.