CHGCTX Instruction for Atomic Context Switching in TEEs

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing trusted execution environments (TEEs) face performance bottlenecks due to unoptimized exception handling, particularly with the increased scope of software running inside TEEs, leading to repeated saving and restoring of state, which impacts performance.

Innovation Solution

A new instruction, referred to as the change context instruction (CHGCTX), allows for atomic switching between execution contexts within a TEE, reducing the need for software to exit and re-enter the TEE, thereby expediting exception and other event handling.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If software exits and re-enters the TEE to handle exceptions, then exception handling is performed, but performance deteriorates due to repeated state saving and restoring

Engineering Contradiction:
Improveexception handling correctnessVSAvoidperformance
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The patent pre-allocates multiple context save areas (CSSA) within the TEE before exceptions occur. When an exception happens, the system can immediately switch to a pre-prepared context save area without exiting the TEE, eliminating the performance penalty of repeated exits and entries while maintaining proper exception handling

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces context save areas as intermediary storage within the TEE that hold execution context information. These intermediaries allow the system to preserve and restore context without requiring full TEE exits, acting as a buffer that enables efficient context switching while maintaining security boundaries

Inventive Principle:
Principle #24Intermediary (Mediator)

2Adaptability or versatility

If the scope of software running inside TEEs is increased, then versatility is improved, but device complexity increases due to unoptimized exception handling

Engineering Contradiction:
Improvesoftware scopeVSAvoidexception handling complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The patent divides the exception handling process into separate segments: context saving to pre-allocated areas, context switching via instruction, and context restoration. This segmentation allows each component to be optimized independently and reduces the overall complexity of handling diverse software workloads within the TEE

Inventive Principle:
Principle #1Segmentation

3Reliability

If repeated saving and restoring of state is performed, then exception handling is ensured, but time is lost impacting performance

Engineering Contradiction:
Improvestate managementVSAvoidexception handling time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

Context save areas are pre-allocated and prepared before exceptions occur. The system maintains multiple ready-to-use context save areas within the TEE, allowing immediate context switching without the time-consuming operations of exiting and re-entering the TEE, thus reducing exception handling time while preserving state integrity

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS20230205869A1Efficient exception handling in trusted execution environments
Publication Date: 2023.06.29 INTEL CORP
  • US20230205869A1 patent drawing
  • US20230205869A1 patent drawing
  • US20230205869A1 patent drawing

AI summary

Systems, methods, and apparatuses relating efficient exception handling in trusted execution environments are described. In an embodiment, a hardware processor includes a register, a decoder, and execution circuitry. The register has a field to be set to enable an architecturally protected execution environment at one of a plurality of contexts for code in an architecturally protected enclave in memory. The decoder is to decode an instruction having a format including a field for an opcode, the opcode to indicate that the execution circuitry is to perform a context change. The execution circuitry is to perform one or more operations corresponding to the instruction, the one or more operations including changing, within the architecturally protected enclave, from a first context to a second context.