diff --git a/libc/calls/pledge-linux.c b/libc/calls/pledge-linux.c index 2bb52c038..d36684bfd 100644 --- a/libc/calls/pledge-linux.c +++ b/libc/calls/pledge-linux.c @@ -1641,7 +1641,6 @@ static privileged void AllowMmapExec(struct Filter *f) { // // - MAP_LOCKED (0x02000) // - MAP_NONBLOCK (0x10000) -// - MAP_HUGETLB (0x40000) // static privileged void AllowMmapNoexec(struct Filter *f) { static const struct sock_filter fragment[] = { @@ -1650,7 +1649,7 @@ static privileged void AllowMmapNoexec(struct Filter *f) { /*L2*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, ~(PROT_READ | PROT_WRITE)), /*L3*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 8 - 4), /*L4*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(args[3])), // flags - /*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x52000), + /*L5*/ BPF_STMT(BPF_ALU | BPF_AND | BPF_K, 0x12000), /*L6*/ BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 0, 1), /*L7*/ BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), /*L8*/ BPF_STMT(BPF_LD | BPF_W | BPF_ABS, OFF(nr)), diff --git a/libc/intrin/describemapflags.c b/libc/intrin/describemapflags.c index 7c207d2e3..5ff541b37 100644 --- a/libc/intrin/describemapflags.c +++ b/libc/intrin/describemapflags.c @@ -30,6 +30,7 @@ const char *(DescribeMapFlags)(char buf[64], int x) { {MAP_SHARED, "SHARED"}, // {MAP_FIXED, "FIXED"}, // {MAP_FIXED_NOREPLACE, "FIXED_NOREPLACE"}, // + {MAP_HUGETLB, "HUGETLB"}, // {MAP_CONCEAL, "CONCEAL"}, // {MAP_LOCKED, "LOCKED"}, // {MAP_NORESERVE, "NORESERVE"}, // diff --git a/libc/sysv/consts.sh b/libc/sysv/consts.sh index 1242f1e4a..696b94040 100755 --- a/libc/sysv/consts.sh +++ b/libc/sysv/consts.sh @@ -230,6 +230,7 @@ syscon mmap MAP_NORESERVE 0x00004000 0x00004000 0x00000040 0x00000040 0 syscon mmap MAP_POPULATE 0x00008000 0x00008000 0 0 0x00040000 0 0 0 # MAP_PREFAULT_READ on FreeBSD; can avoid madvise(MADV_WILLNEED) on private file mapping syscon mmap MAP_NONBLOCK 0x00010000 0x00010000 0 0 0 0 0 0 syscon mmap MAP_SYNC 0x00080000 0x00080000 0 0 0 0 0 0 # perform synchronous page faults for mapping (Linux 4.15+) +syscon mmap MAP_HUGETLB 0x00040000 -1 -1 -1 -1 -1 -1 -1 # make it inherit across execve() syscon mmap MAP_INHERIT -1 -1 -1 -1 -1 -1 0x00000080 -1 # make it inherit across execve() syscon mmap MAP_HASSEMAPHORE 0 0 0x00000200 0x00000200 0x00000200 0 0x00000200 0 # does it matter on x86? syscon mmap MAP_NOSYNC 0 0 0 0 0x00000800 0 0 0 # flush to physical media only when necessary rather than gratuitously; be sure to use write() rather than ftruncate() with this! diff --git a/libc/sysv/consts/MAP_HUGETLB.S b/libc/sysv/consts/MAP_HUGETLB.S new file mode 100644 index 000000000..5062efe09 --- /dev/null +++ b/libc/sysv/consts/MAP_HUGETLB.S @@ -0,0 +1,2 @@ +#include "libc/sysv/consts/syscon.internal.h" +.syscon mmap,MAP_HUGETLB,0x00040000,-1,-1,-1,-1,-1,-1,-1 diff --git a/libc/sysv/consts/map.h b/libc/sysv/consts/map.h index 04008f4cd..c1e3fbc58 100644 --- a/libc/sysv/consts/map.h +++ b/libc/sysv/consts/map.h @@ -13,6 +13,7 @@ extern const int MAP_FILE; extern const int MAP_FIXED; extern const int MAP_FIXED_NOREPLACE; extern const int MAP_HASSEMAPHORE; +extern const int MAP_HUGETLB; extern const int MAP_INHERIT; extern const int MAP_JIT; extern const int MAP_LOCKED; diff --git a/third_party/dlmalloc/platform.inc b/third_party/dlmalloc/platform.inc index 25c80f416..d7733a657 100644 --- a/third_party/dlmalloc/platform.inc +++ b/third_party/dlmalloc/platform.inc @@ -111,7 +111,7 @@ #if (MORECORE_CONTIGUOUS || defined(WIN32)) #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ #else /* MORECORE_CONTIGUOUS */ -#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) +#define DEFAULT_GRANULARITY ((size_t)256U * (size_t)1024U) #endif /* MORECORE_CONTIGUOUS */ #endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD