From 4f08e40fe5bca4e206fbb5eb01c379e74fe4e84c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 7 Apr 2019 00:50:26 -0400 Subject: [PATCH] move thread sealing implementation --- h_malloc.c | 58 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/h_malloc.c b/h_malloc.c index 09c0430..83d3435 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -135,35 +135,6 @@ static const char *const size_class_labels[] = { /* 2048 */ "malloc 10240", "malloc 12288", "malloc 14336", "malloc 16384" }; -int get_metadata_key(void) { -#ifdef USE_PKEY - return ro.metadata_pkey; -#else - return -1; -#endif -} - -#ifdef USE_PKEY -static inline void thread_set_metadata_access(unsigned access) { - if (ro.metadata_pkey == -1) { - return; - } - pkey_set(ro.metadata_pkey, access); -} -#endif - -static inline void thread_unseal_metadata(void) { -#ifdef USE_PKEY - thread_set_metadata_access(0); -#endif -} - -static inline void thread_seal_metadata(void) { -#ifdef USE_PKEY - thread_set_metadata_access(PKEY_DISABLE_ACCESS); -#endif -} - #define N_SIZE_CLASSES (sizeof(size_classes) / sizeof(size_classes[0])) struct size_info { @@ -948,6 +919,35 @@ static void regions_delete(struct region_metadata *region) { } } +int get_metadata_key(void) { +#ifdef USE_PKEY + return ro.metadata_pkey; +#else + return -1; +#endif +} + +#ifdef USE_PKEY +static inline void thread_set_metadata_access(unsigned access) { + if (ro.metadata_pkey == -1) { + return; + } + pkey_set(ro.metadata_pkey, access); +} +#endif + +static inline void thread_unseal_metadata(void) { +#ifdef USE_PKEY + thread_set_metadata_access(0); +#endif +} + +static inline void thread_seal_metadata(void) { +#ifdef USE_PKEY + thread_set_metadata_access(PKEY_DISABLE_ACCESS); +#endif +} + static void full_lock(void) { thread_unseal_metadata(); mutex_lock(&ro.region_allocator->lock);