Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/hotspot/os/linux/gc/x/xSyscall_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define MPOL_F_ADDR (1<<1)
#endif

#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0x100000
#endif

class XSyscall : public AllStatic {
public:
static int memfd_create(const char* name, unsigned int flags);
Expand Down
4 changes: 4 additions & 0 deletions src/hotspot/os/linux/gc/z/zSyscall_linux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define MPOL_F_ADDR (1<<1)
#endif

#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0x100000
#endif

class ZSyscall : public AllStatic {
public:
static int memfd_create(const char* name, unsigned int flags);
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/os/posix/gc/x/xVirtualMemory_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "gc/x/xAddress.inline.hpp"
#include "gc/x/xVirtualMemory.hpp"
#include "logging/log.hpp"
#ifdef LINUX
#include "gc/x/xSyscall_linux.hpp"
#endif

#include <sys/mman.h>
#include <sys/types.h>
Expand All @@ -38,7 +41,9 @@ void XVirtualMemoryManager::pd_initialize_after_reserve() {
}

bool XVirtualMemoryManager::pd_reserve(uintptr_t addr, size_t size) {
const uintptr_t res = (uintptr_t)mmap((void*)addr, size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
const int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE LINUX_ONLY(|MAP_FIXED_NOREPLACE);

const uintptr_t res = (uintptr_t)mmap((void*)addr, size, PROT_NONE, flags, -1, 0);
if (res == (uintptr_t)MAP_FAILED) {
// Failed to reserve memory
return false;
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/os/posix/gc/z/zVirtualMemory_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include "gc/z/zAddress.inline.hpp"
#include "gc/z/zVirtualMemory.hpp"
#include "logging/log.hpp"
#ifdef LINUX
#include "gc/z/zSyscall_linux.hpp"
#endif

#include <sys/mman.h>
#include <sys/types.h>
Expand All @@ -38,7 +41,9 @@ void ZVirtualMemoryManager::pd_initialize_after_reserve() {
}

bool ZVirtualMemoryManager::pd_reserve(zaddress_unsafe addr, size_t size) {
void* const res = mmap((void*)untype(addr), size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
const int flags = MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE LINUX_ONLY(|MAP_FIXED_NOREPLACE);

void* const res = mmap((void*)untype(addr), size, PROT_NONE, flags, -1, 0);
if (res == MAP_FAILED) {
// Failed to reserve memory
return false;
Expand Down