From fadc6b967eb4c5b621d6eb9c1e1a65faff60922b Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Fri, 5 Jul 2024 15:19:01 +0000 Subject: [PATCH] Unwind mutex workaround --- include/ccf/pal/locking.h | 47 +-------------------------------------- 1 file changed, 1 insertion(+), 46 deletions(-) diff --git a/include/ccf/pal/locking.h b/include/ccf/pal/locking.h index 3358e06a6fdd..4ad04e94cb96 100644 --- a/include/ccf/pal/locking.h +++ b/include/ccf/pal/locking.h @@ -11,62 +11,17 @@ namespace ccf::pal { -#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE) - /** * Virtual enclaves and the host code share the same PAL. - * This PAL takes no dependence on OpenEnclave, but also does not apply - * security hardening. */ using Mutex = std::mutex; +#if !defined(INSIDE_ENCLAVE) || defined(VIRTUAL_ENCLAVE) static inline void speculation_barrier() {} - #else - - /** - * Temporary workaround until the fix for - * https://github.com/openenclave/openenclave/issues/4555 is available in a - * release. - */ - class MutexImpl - { - private: - pthread_spinlock_t sl; - - public: - MutexImpl() - { - pthread_spin_init(&sl, PTHREAD_PROCESS_PRIVATE); - } - - ~MutexImpl() - { - pthread_spin_destroy(&sl); - } - - void lock() - { - pthread_spin_lock(&sl); - } - - bool try_lock() - { - return pthread_spin_trylock(&sl) == 0; - } - - void unlock() - { - pthread_spin_unlock(&sl); - } - }; - - using Mutex = MutexImpl; - static inline void speculation_barrier() { oe_lfence(); } - #endif } \ No newline at end of file