diff --git a/src/enclave/enclave_init.c b/src/enclave/enclave_init.c index c1efe1fd8..f601bf6b8 100644 --- a/src/enclave/enclave_init.c +++ b/src/enclave/enclave_init.c @@ -105,8 +105,7 @@ static void _enter_user_space( int argc, char** argv, void* stack, - size_t num_ethreads, - struct timespec clock_res[4]) + size_t num_ethreads) { extern void* __oe_get_isolated_image_entry_point(void); extern const void* __oe_get_isolated_image_base(); @@ -139,7 +138,6 @@ typedef struct startmain_args { int argc; char** argv; - struct timespec clock_res[8]; } startmain_args_t; @@ -164,8 +162,7 @@ static int app_main_thread(void* args_) args->argc, args->argv, &sgxlkl_enclave_state.elf64_stack, - sgxlkl_enclave_state.config->ethreads, - args->clock_res); + sgxlkl_enclave_state.config->ethreads); #else /* Launch stage 3 dynamic linker, passing in top of stack to overwrite. * The dynamic linker will then load the application proper; here goes! */ @@ -238,13 +235,6 @@ int __libc_init_enclave(int argc, char** argv) init_sysconf(cfg->ethreads, cfg->ethreads); - struct timespec tmp[8] = {0}; - for (size_t i = 0; i < 8; i++) - { - tmp[i].tv_sec = hex_to_int(cfg->clock_res[i].resolution, 8); - tmp[i].tv_nsec = hex_to_int(cfg->clock_res[i].resolution + 8, 8); - } - size_t max_lthreads = cfg->max_user_threads * sizeof(*__scheduler_queue.buffer); max_lthreads = next_power_of_2(max_lthreads); @@ -266,7 +256,6 @@ int __libc_init_enclave(int argc, char** argv) static startmain_args_t args; args.argc = argc; args.argv = argv; - memcpy(args.clock_res, tmp, sizeof(args.clock_res)); if (lthread_create(<, NULL, kernel_main_thread, &args) != 0) sgxlkl_fail("Failed to create lthread for kernel_main_thread()\n"); diff --git a/src/main-oe/serialize_enclave_config.c b/src/main-oe/serialize_enclave_config.c index 2943c2913..4cf735fee 100644 --- a/src/main-oe/serialize_enclave_config.c +++ b/src/main-oe/serialize_enclave_config.c @@ -136,20 +136,6 @@ static json_obj_t* encode_string_array( return res; } -static json_obj_t* encode_clock_res( - const char* key, - const sgxlkl_clock_res_config_t* clock_res) -{ - json_obj_t* res = create_json_array(key, 8); - for (size_t i = 0; i < 8; i++) - { - res->array[i] = create_json_objects(NULL, 1); - res->array[i]->objects[0] = - create_json_string("resolution", clock_res[i].resolution); - } - return res; -} - static json_obj_t* encode_root( const char* key, const sgxlkl_enclave_root_config_t* root) @@ -449,7 +435,7 @@ void serialize_enclave_config( // Catch modifications to sgxlkl_enclave_config_t early. If this fails, // the code above/below needs adjusting for the added/removed settings. _Static_assert( - sizeof(sgxlkl_enclave_config_t) == 464, + sizeof(sgxlkl_enclave_config_t) == 328, "sgxlkl_enclave_config_t size has changed"); #define FPFBOOL(N) root->objects[cnt++] = encode_boolean(#N, config->N) @@ -484,7 +470,6 @@ void serialize_enclave_config( FPFU64(espins); FPFU64(esleep); FPFU64(ethreads); - root->objects[cnt++] = encode_clock_res("clock_res", config->clock_res); FPFBOOL(fsgsbase); FPFBOOL(verbose); diff --git a/src/main-oe/sgxlkl_run_oe.c b/src/main-oe/sgxlkl_run_oe.c index e30cb84ad..9de35eb76 100644 --- a/src/main-oe/sgxlkl_run_oe.c +++ b/src/main-oe/sgxlkl_run_oe.c @@ -792,34 +792,6 @@ void get_libsgxlkl_user_path(char* path_buf, size_t len) find_lib("libsgxlkl-user.so", path_buf, len); } -void mk_clock_res_string(int clock) -{ - sgxlkl_enclave_config_t* econf = &sgxlkl_host_state.enclave_config; - size_t sz = sizeof(sgxlkl_clock_res_config_t); - struct timespec tmpt; - char tmps[8 * 2 * 2 + 1]; - clock_getres(clock, &tmpt); - snprintf(tmps, sizeof(tmps), "%08lx%08lx", tmpt.tv_sec, tmpt.tv_nsec); - memcpy(econf->clock_res[clock].resolution, tmps, sz); -} - -void set_clock_res(bool have_enclave_config) -{ - /* The enclave config file has a specified default for these settings, - * so we auto-detect them only if we don't have an enclave config file. - */ - - if (!have_enclave_config) - { - mk_clock_res_string(CLOCK_REALTIME); - mk_clock_res_string(CLOCK_MONOTONIC); - mk_clock_res_string(CLOCK_MONOTONIC_RAW); - mk_clock_res_string(CLOCK_REALTIME_COARSE); - mk_clock_res_string(CLOCK_MONOTONIC_COARSE); - mk_clock_res_string(CLOCK_BOOTTIME); - } -} - static void rdfsbase_sigill_handler(int sig, siginfo_t* si, void* data) { rdfsbase_caused_sigill = 1; @@ -1883,7 +1855,6 @@ int main(int argc, char* argv[], char* envp[]) econf->kernel_cmd); bool have_enclave_config_file = enclave_config_path != NULL; - set_clock_res(have_enclave_config_file); sgxlkl_host_state.shared_memory.env = envp; set_tls(have_enclave_config_file); register_hds(root_hd); diff --git a/src/shared/sgxlkl_enclave_config.c b/src/shared/sgxlkl_enclave_config.c index df49bfea4..4cda4bfc6 100644 --- a/src/shared/sgxlkl_enclave_config.c +++ b/src/shared/sgxlkl_enclave_config.c @@ -301,7 +301,7 @@ static json_result_t json_read_callback( else if (MATCH("wg.peers")) ALLOC_ARRAY( wg.num_peers, wg.peers, sgxlkl_enclave_wg_peer_config_t); - else if (!(MATCH("clock_res"))) + else FAIL("unknown json array '%s'\n", make_path(parser)); break; case JSON_REASON_END_ARRAY: @@ -359,17 +359,6 @@ static json_result_t json_read_callback( JU64("espins", cfg->espins); JU64("esleep", cfg->esleep); - JPATHT("clock_res.resolution", JSON_TYPE_STRING, { - if (strlen(un->string) != 16) - FAIL("invalid length of value for clock_res item"); - i = json_get_array_index(parser); - if (i == -1) - FAIL("invalid array index\n"); - if (i >= 8) - FAIL("too many values for clock_res"); - memcpy(&cfg->clock_res[i].resolution, un->string, 17); - }); - JPATHT("mode", JSON_TYPE_STRING, { cfg->mode = string_to_sgxlkl_enclave_mode_t(un->string); }); @@ -481,7 +470,7 @@ void sgxlkl_read_enclave_config( // Catch modifications to sgxlkl_enclave_config_t early. If this fails, // the code above/below needs adjusting for the added/removed settings. _Static_assert( - sizeof(sgxlkl_enclave_config_t) == 464, + sizeof(sgxlkl_enclave_config_t) == 328, "sgxlkl_enclave_config_t size has changed"); if (!from) @@ -589,4 +578,4 @@ void sgxlkl_free_enclave_config(sgxlkl_enclave_config_t* config) bool is_encrypted(sgxlkl_enclave_mount_config_t* cfg) { return cfg->key || cfg->key_id || cfg->fresh_key; -} \ No newline at end of file +} diff --git a/tests/tools/sgx-lkl-cfg/create/enclave-config-complete-ref.json b/tests/tools/sgx-lkl-cfg/create/enclave-config-complete-ref.json index 1c48f1d14..008fc1c15 100644 --- a/tests/tools/sgx-lkl-cfg/create/enclave-config-complete-ref.json +++ b/tests/tools/sgx-lkl-cfg/create/enclave-config-complete-ref.json @@ -41,32 +41,6 @@ "max_user_threads": 256, "espins": 500, "esleep": 16000, - "clock_res": [ - { - "resolution": "0000000000000001" - }, - { - "resolution": "0000000000000001" - }, - { - "resolution": "0000000000000000" - }, - { - "resolution": "0000000000000000" - }, - { - "resolution": "0000000000000001" - }, - { - "resolution": "00000000003d0900" - }, - { - "resolution": "00000000003d0900" - }, - { - "resolution": "0000000000000001" - } - ], "stacksize": 524288, "mmap_files": "shared", "oe_heap_pagecount": 8192, diff --git a/tools/schemas/enclave-config.schema.json b/tools/schemas/enclave-config.schema.json index 9bfd78628..ec5d3f02d 100644 --- a/tools/schemas/enclave-config.schema.json +++ b/tools/schemas/enclave-config.schema.json @@ -81,18 +81,6 @@ "EXIT_STATUS_NONE" ] }, - "sgxlkl_clock_res_config_t": { - "type": "object", - "properties": { - "resolution": { - "type": "string", - "minLength": 16, - "maxLength": 16, - "pattern": "^[0-9A-Fa-f]+$", - "default": "0000000000000000" - } - } - }, "sgxlkl_enclave_mount_config_t": { "type": "object", "description": "Disk configuration", @@ -394,41 +382,6 @@ "default": 16000, "overridable": "SGXLKL_ESLEEP" }, - "clock_res": { - "type": "array", - "description": "", - "minLength": 8, - "maxLength": 8, - "items": { - "$ref": "#/definitions/sgxlkl_clock_res_config_t" - }, - "default": [ - { - "resolution": "0000000000000001" - }, - { - "resolution": "0000000000000001" - }, - { - "resolution": "0000000000000000" - }, - { - "resolution": "0000000000000000" - }, - { - "resolution": "0000000000000001" - }, - { - "resolution": "00000000003d0900" - }, - { - "resolution": "00000000003d0900" - }, - { - "resolution": "0000000000000001" - } - ] - }, "stacksize": { "$ref": "#/definitions/safe_size_t", "description": "Stack size of in-enclave user-level threads.",