我们如何 运行 并行处理不同 enclaves 中的两个函数?

How can we run two functions in different enclaves in parallel?

我是英特尔 SGX 的初学者。我想知道 SGX 是否支持 运行 并行在不同 Enclave 中的两个函数?例如,功能 A 在飞地 En_A 中,功能 B 在飞地 En_B 中。应用程序是否可以并行调用函数 A 和 B?

提前致谢!

是的,这是可能的。

The SGX design supports having multiple enclaves on a system at the same time, which is a necessity in multi-process environments. This is achieved by having the EPC split into 4 KB pages that can be assigned to different enclaves. The EPC uses the same page size as the architecture’s address translation feature.

(source)

查看 Intel SGX SDK docs (page 92) 您可以看到 sgx_create_enclave 函数通过采用唯一的 enclave_id:

来区分 enclave 实例
sgx_status_t sgx_create_enclave (
    const char *file_name,
    const int debug,
    sgx_launch_token_t *launch_token,
    int *launch_token_updated,
    sgx_enclave_id_t *enclave_id,    // here
    sgx_misc_attribute_t *misc_attr
);

应用程序使用这些飞地 ID 使用不受信任的代理函数进行 ECALL 调用:

// demo.edl
enclave {
    trusted {
        public void get_secret([out] secret_t* secret);
    };
}

// generated function signature
sgx_status_t get_secret(sgx_enclave_id_t eid, secret_t* secret);

您可以在 page 27

上找到完整的解释