зеркало из https://github.com/microsoft/snmalloc.git
Added SGX AAL. (#149)
This commit is contained in:
Родитель
4246d9a065
Коммит
f301fdd2a0
|
@ -7,7 +7,12 @@
|
|||
#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
|
||||
defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(_M_AMD64)
|
||||
# define PLATFORM_IS_X86
|
||||
# if defined(SNMALLOC_SGX)
|
||||
# define PLATFORM_IS_X86_SGX
|
||||
# define SNMALLOC_NO_AAL_BUILTINS
|
||||
# else
|
||||
# define PLATFORM_IS_X86
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__arm__) || defined(__aarch64__)
|
||||
|
@ -93,6 +98,8 @@ namespace snmalloc
|
|||
|
||||
#if defined(PLATFORM_IS_X86)
|
||||
# include "aal_x86.h"
|
||||
#elif defined(PLATFORM_IS_X86_SGX)
|
||||
# include "aal_x86_sgx.h"
|
||||
#elif defined(PLATFORM_IS_ARM)
|
||||
# include "aal_arm.h"
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
# include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) && !defined(OPEN_ENCLAVE)
|
||||
#if defined(__linux__)
|
||||
# include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <immintrin.h>
|
||||
# include <intrin.h>
|
||||
#else
|
||||
# include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \
|
||||
defined(_M_AMD64)
|
||||
# define SNMALLOC_VA_BITS_64
|
||||
#else
|
||||
# define SNMALLOC_VA_BITS_32
|
||||
#endif
|
||||
|
||||
namespace snmalloc
|
||||
{
|
||||
/**
|
||||
* x86-specific architecture abstraction layer minimised for use
|
||||
* inside SGX enclaves.
|
||||
*/
|
||||
class AAL_x86_sgx
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Bitmap of AalFeature flags
|
||||
*/
|
||||
static constexpr uint64_t aal_features = IntegerPointers;
|
||||
|
||||
/**
|
||||
* On pipelined processors, notify the core that we are in a spin loop and
|
||||
* that speculative execution past this point may not be a performance gain.
|
||||
*/
|
||||
static inline void pause()
|
||||
{
|
||||
_mm_pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue a prefetch hint at the specified address.
|
||||
*/
|
||||
static inline void prefetch(void* ptr)
|
||||
{
|
||||
_mm_prefetch(reinterpret_cast<const char*>(ptr), _MM_HINT_T0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a cycle counter value.
|
||||
* Not guaranteed inside an enclave, so just always return 0.
|
||||
* This is only used for benchmarking inside snmalloc.
|
||||
*/
|
||||
static inline uint64_t tick()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
using AAL_Arch = AAL_x86_sgx;
|
||||
} // namespace snmalloc
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
#define SNMALLOC_SGX
|
||||
#define OPEN_ENCLAVE
|
||||
#define OPEN_ENCLAVE_SIMULATION
|
||||
#define USE_RESERVE_MULTIPLE 1
|
||||
|
|
Загрузка…
Ссылка в новой задаче