From 22d9bd0c456a18bbf04b0e2da7ae4128449eb19d Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Wed, 10 Mar 2021 18:00:57 +0100 Subject: [PATCH] UserspaceEmulator: Do not pass MAP_FIXED to Kernel Since there is usually no correlation between guest memory-layout and UE memory-layout, this option does not make any sense. Especially since we provide nullptr. --- Userland/DevTools/UserspaceEmulator/MmapRegion.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index ce73cfd3a7..09541580d4 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -56,7 +56,9 @@ NonnullOwnPtr MmapRegion::create_anonymous(u32 base, u32 size, u32 p NonnullOwnPtr MmapRegion::create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset, String name) { - auto data = (u8*)mmap_with_name(nullptr, size, prot, flags, fd, offset, name.is_empty() ? nullptr : name.characters()); + // Since we put the memory to an arbitrary location, do not pass MAP_FIXED to the Kernel. + auto real_flags = flags & ~MAP_FIXED; + auto data = (u8*)mmap_with_name(nullptr, size, prot, real_flags, fd, offset, name.is_empty() ? nullptr : name.characters()); VERIFY(data != MAP_FAILED); auto shadow_data = (u8*)mmap_initialized(size, 1, "MmapRegion ShadowData"); auto region = adopt_own(*new MmapRegion(base, size, prot, data, shadow_data));