From 0252f98d606d64459ccb4c71fb48c2ed387cfce8 Mon Sep 17 00:00:00 2001 From: "zongmin.gu" Date: Thu, 4 Feb 2021 10:22:28 +0800 Subject: [PATCH] Enable exception test cases under simulation mode --- src/pal/src/pal_api.c | 6 ------ src/pal/src/pal_enclave.c | 6 ------ src/pal/src/pal_sig_handler.c | 3 --- test/exit_group/main.c | 7 ------- test/signal/main.c | 12 ------------ 5 files changed, 34 deletions(-) diff --git a/src/pal/src/pal_api.c b/src/pal/src/pal_api.c index 7820fc0c..9ff82b8d 100644 --- a/src/pal/src/pal_api.c +++ b/src/pal/src/pal_api.c @@ -107,13 +107,10 @@ int occlum_pal_init(const struct occlum_pal_attr *attr) { goto on_destroy_enclave; } -// FIXME -#ifndef SGX_MODE_SIM if (pal_interrupt_thread_start() < 0) { PAL_ERROR("Failed to start the interrupt thread: %s", errno2str(errno)); goto on_destroy_enclave; } -#endif if (pal_run_init_process() < 0) { PAL_ERROR("Failed to run the init process: %s", errno2str(errno)); @@ -230,13 +227,10 @@ int occlum_pal_destroy(void) { int ret = 0; -// FIXME -#ifndef SGX_MODE_SIM if (pal_interrupt_thread_stop() < 0) { ret = -1; PAL_WARN("Cannot stop the interrupt thread: %s", errno2str(errno)); } -#endif if (pal_destroy_enclave() < 0) { ret = -1; diff --git a/src/pal/src/pal_enclave.c b/src/pal/src/pal_enclave.c index 3cbc1dde..c4c97fc3 100644 --- a/src/pal/src/pal_enclave.c +++ b/src/pal/src/pal_enclave.c @@ -130,14 +130,8 @@ int pal_init_enclave(const char *instance_dir) { } int pal_destroy_enclave(void) { -// FIXME: Due to lack of support for enclave interrupt in simulation mode, some programs -// come across the problem that it can't exit when running in simulation mode. We have to -// fallback to the old way to exit brutely in simulation mode. -#ifndef SGX_MODE_SIM sgx_destroy_enclave(global_eid); global_eid = SGX_INVALID_ENCLAVE_ID; -#endif - return 0; } diff --git a/src/pal/src/pal_sig_handler.c b/src/pal/src/pal_sig_handler.c index 108236fd..467424ef 100644 --- a/src/pal/src/pal_sig_handler.c +++ b/src/pal/src/pal_sig_handler.c @@ -7,13 +7,10 @@ #define SIGRT_INTERRUPT 64 int pal_register_sig_handlers(void) { - // FIXME: enable interruptable signal in SIM mode -#ifndef SGX_MODE_SIM if (signal(SIGRT_INTERRUPT, SIG_IGN) == SIG_ERR) { PAL_ERROR("Failed to regiter the SIG64 handler"); return -1; } -#endif if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { PAL_ERROR("Failed to regiter the SIGPIPE handler"); diff --git a/test/exit_group/main.c b/test/exit_group/main.c index ada7cf01..9477e6a5 100644 --- a/test/exit_group/main.c +++ b/test/exit_group/main.c @@ -38,11 +38,6 @@ static void *futex_wait_thread_func(void *_) { // exit_group syscall should terminate all threads in a thread group. int test_exit_group_to_force_threads_terminate(void) { -#ifdef SGX_MODE_SIM - printf("WARNING: Skip this test case as we do not support " - "enclave interruption in SGX simulation mode\n"); - return 0; -#else // Create three types of threads that will not exit voluntarily pthread_t busyloop_thread; if (pthread_create(&busyloop_thread, NULL, busyloop_thread_func, NULL) < 0) { @@ -59,7 +54,6 @@ int test_exit_group_to_force_threads_terminate(void) { printf("ERROR: pthread_create failed\n"); return -1; } - // Sleep for a while to make sure all three threads are running useconds_t half_second = 500 * 1000; // in us usleep(half_second); @@ -68,7 +62,6 @@ int test_exit_group_to_force_threads_terminate(void) { // main function returns. If Occlum can terminate normally, this means // exit_group syscall taking effect. return 0; -#endif } // ============================================================================ diff --git a/test/signal/main.c b/test/signal/main.c index 7f704382..e8a0dcbc 100644 --- a/test/signal/main.c +++ b/test/signal/main.c @@ -236,11 +236,6 @@ int div_maybe_zero(int x, int y) { #define fxsave(addr) __asm __volatile("fxsave %0" : "=m" (*(addr))) int test_handle_sigfpe() { -#ifdef SGX_MODE_SIM - printf("WARNING: Skip this test case as we do not support " - "capturing hardware exception in SGX simulation mode\n"); - return 0; -#else // Set up a signal handler that handles divide-by-zero exception struct sigaction new_action, old_action; memset(&new_action, 0, sizeof(struct sigaction)); @@ -276,7 +271,6 @@ int test_handle_sigfpe() { THROW_ERROR("restoring old signal handler failed"); } return 0; -#endif /* SGX_MODE_SIM */ } @@ -301,11 +295,6 @@ static void handle_sigsegv(int num, siginfo_t *info, void *_context) { int test_handle_sigsegv() { -#ifdef SGX_MODE_SIM - printf("WARNING: Skip this test case as we do not support " - "capturing hardware exception in SGX simulation mode\n"); - return 0; -#else // Set up a signal handler that handles divide-by-zero exception struct sigaction new_action, old_action; memset(&new_action, 0, sizeof(struct sigaction)); @@ -329,7 +318,6 @@ int test_handle_sigsegv() { THROW_ERROR("restoring old signal handler failed"); } return 0; -#endif /* SGX_MODE_SIM */ } // ============================================================================