diff options
-rw-r--r-- | changes/ticket40843 | 3 | ||||
-rw-r--r-- | changes/ticket40844 | 4 | ||||
-rw-r--r-- | src/ext/equix/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/ext/equix/hashx/src/virtual_memory.c | 14 | ||||
-rw-r--r-- | src/ext/equix/hashx/src/virtual_memory.h | 5 | ||||
-rw-r--r-- | src/ext/equix/src/context.c | 4 |
6 files changed, 27 insertions, 4 deletions
diff --git a/changes/ticket40843 b/changes/ticket40843 new file mode 100644 index 0000000000..3af63a9164 --- /dev/null +++ b/changes/ticket40843 @@ -0,0 +1,3 @@ + o Minor bugfix (NetBSD, compilation): + - Fix compilation issue on NetBSD by avoiding an unnecessary dependency on + "huge" page mappings in Equi-X. Fixes bug 40843; bugfix on 0.4.8.1-alpha.
\ No newline at end of file diff --git a/changes/ticket40844 b/changes/ticket40844 new file mode 100644 index 0000000000..73d3bb2b76 --- /dev/null +++ b/changes/ticket40844 @@ -0,0 +1,4 @@ + o Minor bugfix (NetBSD, testing): + - Fix test failures in "crypto/hashx" and "slow/crypto/equix" on x86_64 + and aarch64 NetBSD hosts, by adding support for PROT_MPROTECT() flags. + Fixes bug 40844; bugfix on 0.4.8.1-alpha.
\ No newline at end of file diff --git a/src/ext/equix/CMakeLists.txt b/src/ext/equix/CMakeLists.txt index 3c4606566f..a9d0665408 100644 --- a/src/ext/equix/CMakeLists.txt +++ b/src/ext/equix/CMakeLists.txt @@ -11,6 +11,7 @@ set(EQUIX_VERSION_STR "${EQUIX_VERSION}.${EQUIX_VERSION_MINOR}.${EQUIX_VERSION_P project(equix) add_definitions(-DHASHX_SIZE=8) +add_definitions(-DEQUIX_SUPPORT_HUGEPAGES) add_subdirectory("hashx") diff --git a/src/ext/equix/hashx/src/virtual_memory.c b/src/ext/equix/hashx/src/virtual_memory.c index e9df825c9f..2dff6f7552 100644 --- a/src/ext/equix/hashx/src/virtual_memory.c +++ b/src/ext/equix/hashx/src/virtual_memory.c @@ -18,6 +18,11 @@ #define PAGE_READWRITE (PROT_READ | PROT_WRITE) #define PAGE_EXECUTE_READ (PROT_READ | PROT_EXEC) #define PAGE_EXECUTE_READWRITE (PROT_READ | PROT_WRITE | PROT_EXEC) +#if defined(__NetBSD__) && defined(PROT_MPROTECT) +#define PAGE_MMAP_PROT (PAGE_READWRITE | PROT_MPROTECT(PROT_EXEC)) +#else +#define PAGE_MMAP_PROT PAGE_READWRITE +#endif #endif #ifdef HASHX_WIN @@ -57,7 +62,7 @@ void* hashx_vm_alloc(size_t bytes) { #ifdef HASHX_WIN mem = VirtualAlloc(NULL, bytes, MEM_COMMIT, PAGE_READWRITE); #else - mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + mem = mmap(NULL, bytes, PAGE_MMAP_PROT, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); if (mem == MAP_FAILED) return NULL; #endif @@ -85,6 +90,7 @@ bool hashx_vm_rx(void* ptr, size_t bytes) { return page_protect(ptr, bytes, PAGE_EXECUTE_READ); } +#ifdef EQUIX_SUPPORT_HUGEPAGES void* hashx_vm_alloc_huge(size_t bytes) { void* mem; #ifdef HASHX_WIN @@ -106,8 +112,9 @@ void* hashx_vm_alloc_huge(size_t bytes) { #elif defined(__FreeBSD__) mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER, -1, 0); -#elif defined(__OpenBSD__) - mem = MAP_FAILED; // OpenBSD does not support huge pages +#elif defined(__OpenBSD__) || defined(__NetBSD__) + (void)bytes; + mem = MAP_FAILED; // OpenBSD and NetBSD do not support huge pages #else mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, -1, 0); @@ -118,6 +125,7 @@ void* hashx_vm_alloc_huge(size_t bytes) { #endif return mem; } +#endif /* EQUIX_SUPPORT_HUGEPAGES */ void hashx_vm_free(void* ptr, size_t bytes) { if (!ptr) { diff --git a/src/ext/equix/hashx/src/virtual_memory.h b/src/ext/equix/hashx/src/virtual_memory.h index 9780d218c2..63633bed3f 100644 --- a/src/ext/equix/hashx/src/virtual_memory.h +++ b/src/ext/equix/hashx/src/virtual_memory.h @@ -14,7 +14,10 @@ HASHX_PRIVATE void* hashx_vm_alloc(size_t size); HASHX_PRIVATE bool hashx_vm_rw(void* ptr, size_t size); HASHX_PRIVATE bool hashx_vm_rx(void* ptr, size_t size); -HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size); HASHX_PRIVATE void hashx_vm_free(void* ptr, size_t size); +#ifdef EQUIX_SUPPORT_HUGEPAGES +HASHX_PRIVATE void* hashx_vm_alloc_huge(size_t size); +#endif + #endif diff --git a/src/ext/equix/src/context.c b/src/ext/equix/src/context.c index 28edf5e104..3ae4fdf9cf 100644 --- a/src/ext/equix/src/context.c +++ b/src/ext/equix/src/context.c @@ -27,7 +27,11 @@ equix_ctx* equix_alloc(equix_ctx_flags flags) { if (flags & EQUIX_CTX_SOLVE) { if (flags & EQUIX_CTX_HUGEPAGES) { +#ifdef EQUIX_SUPPORT_HUGEPAGES ctx->heap = hashx_vm_alloc_huge(sizeof(solver_heap)); +#else + ctx->heap = NULL; +#endif } else { ctx->heap = malloc(sizeof(solver_heap)); |