diff --git a/rune/libenclave/internal/runtime/pal/skeleton/Makefile b/rune/libenclave/internal/runtime/pal/skeleton/Makefile index dd082817dfa0677c2faf69c385ebce9cc093d06b..df753625b567d3bd8864535e39c94083cac3f462 100644 --- a/rune/libenclave/internal/runtime/pal/skeleton/Makefile +++ b/rune/libenclave/internal/runtime/pal/skeleton/Makefile @@ -10,11 +10,14 @@ ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \ HOST_LDFLAGS := -fPIC -shared -Wl,-Bsymbolic IS_OOT_DRIVER := $(shell [ ! -e /dev/isgx ]) +IS_SGX_FLC := $(shell lscpu | grep -q sgx_lc) TEST_CUSTOM_PROGS := $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss $(OUTPUT)/liberpal-skeleton.so $(OUTPUT)/signing_key.pem ifeq ($(IS_OOT_DRIVER),1) TEST_CUSTOM_PROGS += $(OUTPUT)/encl.token +else ifeq ($(IS_SGX_FLC),) + TEST_CUSTOM_PROGS += $(OUTPUT)/encl.token endif all: $(TEST_CUSTOM_PROGS) diff --git a/rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c b/rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c index 81e68e48c8ddd93382fdbad23e948d0a948983b2..8dffd065f328f3f5418039a77135648768a5a414 100644 --- a/rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c +++ b/rune/libenclave/internal/runtime/pal/skeleton/liberpal-skeleton.c @@ -31,6 +31,7 @@ static struct sgx_secs secs; static bool initialized = false; static char *sgx_dev_path; static bool is_oot_driver; +static bool no_sgx_flc = false; /* * For SGX in-tree driver, dev_fd cannot be closed until an enclave instance * intends to exit. @@ -221,7 +222,7 @@ static bool encl_build(struct sgx_secs *secs, void *bin, unsigned long bin_size, goto out_map; } - if (is_oot_driver) { + if (is_oot_driver || no_sgx_flc) { struct sgx_enclave_init_with_token ioc; ioc.addr = secs->base; ioc.sigstruct = (uint64_t)sigstruct; @@ -359,6 +360,37 @@ static bool load_token(const char *path, void *token) return true; } +static void check_opts(const char *opt) +{ + if (!strcmp(opt, "no-sgx-flc")) + no_sgx_flc = true; +} + +static void parse_args(const char *args) +{ + char *a = strdup(args); + if (!a) + return; + + char *opt = strtok(a, " "); + check_opts(opt); + + if (!opt) { + free(a); + return; + } + + do { + char *opt = strtok(NULL, " "); + if (!opt) + break; + + check_opts(opt); + } while (1); + + free(a); +} + int pal_get_version(void) { return 1; @@ -376,6 +408,8 @@ int pal_init(pal_attr_t *attr) off_t bin_size; void *bin; + parse_args(attr->args); + detect_driver_type(); if (!encl_data_map(IMAGE, &bin, &bin_size))