@@ -61,15 +61,27 @@ const (
6161 // Use of this runtime environment is only allowed if DebugDontBlameOasis flag is set.
6262 RuntimeEnvironmentSGXMock RuntimeEnvironment = "sgx-mock"
6363
64- // RuntimeEnvironmentELF specifies to run the runtime in the OS address space.
65- //
66- // Use of this runtime environment is only allowed if DebugDontBlameOasis flag is set.
67- RuntimeEnvironmentELF RuntimeEnvironment = "elf"
68-
6964 // RuntimeEnvironmentAuto specifies to run the runtime in the most appropriate location.
7065 RuntimeEnvironmentAuto RuntimeEnvironment = "auto"
7166)
7267
68+ // TEESelectMode is the selection mode for the Trusted Execution Environment (TEE).
69+ type TEESelectMode string
70+
71+ const (
72+ // TEESelectModeAuto specifies that the runtime should run in the most appropriate TEE.
73+ TEESelectModeAuto TEESelectMode = ""
74+
75+ // TEESelectModeNone specifies that the runtime should run without using any TEE.
76+ TEESelectModeNone TEESelectMode = "none"
77+
78+ // TEESelectModeSGX specifies that the runtime should run in an SGX environment.
79+ TEESelectModeSGX TEESelectMode = "sgx"
80+
81+ // TEESelectModeTDX specifies that the runtime should run in a TDX environment.
82+ TEESelectModeTDX TEESelectMode = "tdx"
83+ )
84+
7385// Config is the runtime registry configuration structure.
7486type Config struct {
7587 // Runtimes is the list of runtimes to configure.
@@ -84,10 +96,11 @@ type Config struct {
8496 // Path to the sandbox binary (bubblewrap).
8597 SandboxBinary string `yaml:"sandbox_binary,omitempty"`
8698
87- // Path to SGXS runtime loader binary (for SGX runtimes).
99+ // Path to SGX runtime loader binary (for SGX runtimes).
88100 SGXLoader string `yaml:"sgx_loader,omitempty"`
89101
90102 // The runtime environment (sgx, elf, auto).
103+ // NOTE: This may go away in the future, use `DebugMockTEE` instead.
91104 Environment RuntimeEnvironment `yaml:"environment,omitempty"`
92105
93106 // History pruner configuration.
@@ -122,6 +135,11 @@ type Config struct {
122135 //
123136 // If not specified, a default value is used.
124137 MaxBundleSize string `yaml:"max_bundle_size,omitempty"`
138+
139+ // DebugMockTEE enables mocking of the Trusted Execution Environment (TEE).
140+ //
141+ // This flag can only be used if the DebugDontBlameOasis flag is set.
142+ DebugMockTEE bool `yaml:"debug_mock_tee,omitempty"`
125143}
126144
127145// GetComponent returns the configuration for the given component
@@ -170,16 +188,61 @@ type RuntimeConfig struct {
170188 Repositories []string `yaml:"repositories,omitempty"`
171189}
172190
191+ // Validate validates the runtime configuration.
192+ func (c * RuntimeConfig ) Validate () error {
193+ for _ , comp := range c .Components {
194+ if err := comp .Validate (); err != nil {
195+ return err
196+ }
197+ }
198+ return nil
199+ }
200+
173201// ComponentConfig is the component configuration.
174202type ComponentConfig struct {
175203 // ID is the component identifier.
176204 ID component.ID `yaml:"id"`
177205
206+ // TEE specifies the kind of Trusted Execution Environment (TEE)
207+ // in which the component should run (none, sgx, tdx).
208+ //
209+ // If not provided, the TEE kind is selected automatically.
210+ TEE TEESelectMode `yaml:"tee,omitempty"`
211+
178212 // Disabled specifies whether the component is disabled. If a component is specified and not
179213 // disabled, it is enabled.
180214 Disabled bool `yaml:"disabled,omitempty"`
181215}
182216
217+ // Validate validates the component configuration.
218+ func (c * ComponentConfig ) Validate () error {
219+ switch c .TEE {
220+ case TEESelectModeAuto :
221+ case TEESelectModeNone :
222+ case TEESelectModeSGX :
223+ case TEESelectModeTDX :
224+ default :
225+ return fmt .Errorf ("unknown TEE select mode: %s" , c .TEE )
226+ }
227+
228+ return nil
229+ }
230+
231+ // TEEKind returns the kind of Trusted Execution Environment (TEE)
232+ // in which the component should run, if it is specified.
233+ func (c * ComponentConfig ) TEEKind () (component.TEEKind , bool ) {
234+ switch c .TEE {
235+ case TEESelectModeNone :
236+ return component .TEEKindNone , true
237+ case TEESelectModeSGX :
238+ return component .TEEKindSGX , true
239+ case TEESelectModeTDX :
240+ return component .TEEKindTDX , true
241+ default :
242+ return 0 , false
243+ }
244+ }
245+
183246// UnmarshalYAML implements yaml.Unmarshaler.
184247func (c * ComponentConfig ) UnmarshalYAML (value * yaml.Node ) error {
185248 switch value .ShortTag () {
@@ -231,7 +294,6 @@ func (c *Config) Validate() error {
231294 return fmt .Errorf ("sgx_loader must be set when using sgx environment" )
232295 }
233296 case RuntimeEnvironmentSGXMock :
234- case RuntimeEnvironmentELF :
235297 case RuntimeEnvironmentAuto :
236298 default :
237299 return fmt .Errorf ("unknown runtime environment: %s" , c .Environment )
@@ -251,6 +313,12 @@ func (c *Config) Validate() error {
251313 return fmt .Errorf ("cannot specify more than 128 instances for load balancing" )
252314 }
253315
316+ for _ , rt := range c .Runtimes {
317+ if err := rt .Validate (); err != nil {
318+ return err
319+ }
320+ }
321+
254322 return nil
255323}
256324
0 commit comments