Add some type safety to other pagemap accesses.
Introduce a descriptor for the pagemap config and check that the source descriptor is compatible with the destination type.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#define USE_RESERVE_MULTIPLE 1
|
||||
#define NO_BOOTSTRAP_ALLOCATOR
|
||||
#define IS_ADDRESS_SPACE_CONSTRAINED
|
||||
#define SNMALLOC_EXPOSE_PAGEMAP
|
||||
#define SNMALLOC_NAME_MANGLE(a) enclave_##a
|
||||
// Redefine the namespace, so we can have two versions.
|
||||
#define snmalloc snmalloc_enclave
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#undef IS_ADDRESS_SPACE_CONSTRAINED
|
||||
#define SNMALLOC_NAME_MANGLE(a) host_##a
|
||||
#define NO_BOOTSTRAP_ALLOCATOR
|
||||
#define SNMALLOC_EXPOSE_PAGEMAP
|
||||
// Redefine the namespace, so we can have two versions.
|
||||
#define snmalloc snmalloc_host
|
||||
#include "../../../override/malloc.cc"
|
||||
#include "../../../override/malloc.cc"
|
||||
|
||||
@@ -32,6 +32,11 @@ extern "C" void host_free(void*);
|
||||
extern "C" void* enclave_malloc(size_t);
|
||||
extern "C" void enclave_free(void*);
|
||||
|
||||
extern "C" void*
|
||||
enclave_snmalloc_get_global_pagemap(snmalloc::PagemapConfig const**);
|
||||
extern "C" void*
|
||||
host_snmalloc_get_global_pagemap(snmalloc::PagemapConfig const**);
|
||||
|
||||
using namespace snmalloc;
|
||||
int main()
|
||||
{
|
||||
@@ -42,6 +47,10 @@ int main()
|
||||
oe_end = (uint8_t*)oe_base + size;
|
||||
std::cout << "Allocated region " << oe_base << " - " << oe_end << std::endl;
|
||||
|
||||
// Call these functions to trigger asserts if the cast-to-self doesn't work.
|
||||
enclave_snmalloc_get_global_pagemap(nullptr);
|
||||
host_snmalloc_get_global_pagemap(nullptr);
|
||||
|
||||
auto a = host_malloc(128);
|
||||
auto b = enclave_malloc(128);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user