Various fixes for OE (#418)
* Add default for getting chunk allocator state Makes the API same between the two configurations. * Reduce address space usage for Open Enclave * Fix OE Pal concept * Add support for Pal not to provide time. The lazy return of pages to the OS uses a simple time based heuristic. This enables a PAL to not support time, and return the memory to a central pool immediately. * Update src/backend/backend.h Co-authored-by: Amaury Chamayou <amaury@xargs.fr> Co-authored-by: Amaury Chamayou <amaury@xargs.fr>
This commit is contained in:
committed by
GitHub
parent
91919f6014
commit
dc542cdc9d
@@ -28,7 +28,7 @@ namespace snmalloc
|
||||
* The features exported by this PAL.
|
||||
*/
|
||||
static constexpr uint64_t pal_features =
|
||||
AlignedAllocation | LazyCommit | Entropy;
|
||||
AlignedAllocation | LazyCommit | Entropy | Time;
|
||||
|
||||
/*
|
||||
* `page_size`
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace snmalloc
|
||||
* whether low memory conditions are still in effect.
|
||||
*/
|
||||
LowMemoryNotification = (1 << 0),
|
||||
|
||||
/**
|
||||
* This PAL natively supports allocation with a guaranteed alignment. If
|
||||
* this is not supported, then we will over-allocate and round the
|
||||
@@ -51,22 +52,31 @@ namespace snmalloc
|
||||
* `request()` method that takes only a size.
|
||||
*/
|
||||
AlignedAllocation = (1 << 1),
|
||||
|
||||
/**
|
||||
* This PAL natively supports lazy commit of pages. This means have large
|
||||
* allocations and not touching them does not increase memory usage. This is
|
||||
* exposed in the Pal.
|
||||
*/
|
||||
LazyCommit = (1 << 2),
|
||||
|
||||
/**
|
||||
* This Pal does not support allocation. All memory used with this Pal
|
||||
* should be pre-allocated.
|
||||
*/
|
||||
NoAllocation = (1 << 3),
|
||||
|
||||
/**
|
||||
* This Pal provides a source of Entropy
|
||||
*/
|
||||
Entropy = (1 << 4),
|
||||
|
||||
/**
|
||||
* This Pal provides a millisecond time source
|
||||
*/
|
||||
Time = (1 << 5),
|
||||
};
|
||||
|
||||
/**
|
||||
* Flag indicating whether requested memory should be zeroed.
|
||||
*/
|
||||
@@ -76,6 +86,7 @@ namespace snmalloc
|
||||
* Memory should not be zeroed, contents are undefined.
|
||||
*/
|
||||
NoZero,
|
||||
|
||||
/**
|
||||
* Memory must be zeroed. This can be lazily allocated via a copy-on-write
|
||||
* mechanism as long as any load from the memory returns zero.
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace snmalloc
|
||||
* ever use.
|
||||
*/
|
||||
template<SNMALLOC_CONCEPT(PALNoAllocBase) BasePAL>
|
||||
struct PALNoAlloc : public PalTimerDefaultImpl<BasePAL>
|
||||
struct PALNoAlloc : public BasePAL
|
||||
{
|
||||
/**
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
@@ -38,7 +38,7 @@ namespace snmalloc
|
||||
|
||||
static constexpr size_t page_size = BasePAL::page_size;
|
||||
|
||||
static constexpr size_t address_bits = Aal::address_bits;
|
||||
static constexpr size_t address_bits = BasePAL::address_bits;
|
||||
|
||||
/**
|
||||
* Print a stack trace.
|
||||
|
||||
@@ -19,6 +19,8 @@ namespace snmalloc
|
||||
UNUSED(str);
|
||||
oe_abort();
|
||||
}
|
||||
static constexpr size_t address_bits = Aal::address_bits;
|
||||
static constexpr size_t page_size = Aal::smallest_page_size;
|
||||
};
|
||||
|
||||
using OpenEnclaveBasePAL = PALNoAlloc<OpenEnclaveErrorHandler>;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace snmalloc
|
||||
* POSIX systems are assumed to support lazy commit. The build system checks
|
||||
* getentropy is available, only then this PAL supports Entropy.
|
||||
*/
|
||||
static constexpr uint64_t pal_features = LazyCommit
|
||||
static constexpr uint64_t pal_features = LazyCommit | Time
|
||||
#if defined(SNMALLOC_PLATFORM_HAS_GETENTROPY)
|
||||
| Entropy
|
||||
#endif
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace snmalloc
|
||||
* Bitmap of PalFeatures flags indicating the optional features that this
|
||||
* PAL supports. This PAL supports low-memory notifications.
|
||||
*/
|
||||
static constexpr uint64_t pal_features = LowMemoryNotification | Entropy
|
||||
static constexpr uint64_t pal_features = LowMemoryNotification | Entropy |
|
||||
Time
|
||||
# if defined(PLATFORM_HAS_VIRTUALALLOC2) && !defined(USE_SYSTEMATIC_TESTING)
|
||||
| AlignedAllocation
|
||||
# endif
|
||||
|
||||
Reference in New Issue
Block a user