diff options
author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2020-01-24 12:08:23 +0000 |
---|---|---|
committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2020-01-24 12:08:23 +0000 |
commit | 618b55c2e2edf8fc20f6ee6ebde1e8a4eed637e9 (patch) | |
tree | d8919a41dc8a70747577bc8336428493e44bd95c /sys | |
parent | b3fb13eb55ba3112eab8d6eb702ed2be762c642a (diff) | |
download | src-618b55c2e2edf8fc20f6ee6ebde1e8a4eed637e9.tar.gz src-618b55c2e2edf8fc20f6ee6ebde1e8a4eed637e9.zip |
Make linux(4) handle MAP_32BIT.
This unbreaks Mono (mono-devel-4.6.2.7+dfsg-1ubuntu1 from Ubuntu Bionic);
previously would crash on "amd64_is_imm32" assert.
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23306
Notes
Notes:
svn path=/head/; revision=357076
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/linux/linux_mmap.c | 9 | ||||
-rw-r--r-- | sys/compat/linux/linux_mmap.h | 1 |
2 files changed, 9 insertions, 1 deletions
diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c index 59f7176d3996..1949f3055c8e 100644 --- a/sys/compat/linux/linux_mmap.c +++ b/sys/compat/linux/linux_mmap.c @@ -113,6 +113,14 @@ linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot, if (flags & LINUX_MAP_GROWSDOWN) bsd_flags |= MAP_STACK; +#if defined(__amd64__) + /* + * According to the Linux mmap(2) man page, "MAP_32BIT flag + * is ignored when MAP_FIXED is set." + */ + if ((flags & LINUX_MAP_32BIT) && (flags & LINUX_MAP_FIXED) == 0) + bsd_flags |= MAP_32BIT; + /* * PROT_READ, PROT_WRITE, or PROT_EXEC implies PROT_READ and PROT_EXEC * on Linux/i386 if the binary requires executable stack. @@ -121,7 +129,6 @@ linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot, * * XXX. Linux checks that the file system is not mounted with noexec. */ -#if defined(__amd64__) linux_fixup_prot(td, &prot); #endif diff --git a/sys/compat/linux/linux_mmap.h b/sys/compat/linux/linux_mmap.h index a694dc05799d..8dc123526f21 100644 --- a/sys/compat/linux/linux_mmap.h +++ b/sys/compat/linux/linux_mmap.h @@ -39,6 +39,7 @@ #define LINUX_MAP_PRIVATE 0x0002 #define LINUX_MAP_FIXED 0x0010 #define LINUX_MAP_ANON 0x0020 +#define LINUX_MAP_32BIT 0x0040 #define LINUX_MAP_GROWSDOWN 0x0100 #define LINUX_PROT_GROWSDOWN 0x01000000 |