aboutsummaryrefslogtreecommitdiff
path: root/util/mmap-alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/mmap-alloc.c')
-rw-r--r--util/mmap-alloc.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/util/mmap-alloc.c b/util/mmap-alloc.c
index 0e2bd7bc0e..1ddc0e2a1e 100644
--- a/util/mmap-alloc.c
+++ b/util/mmap-alloc.c
@@ -118,9 +118,12 @@ static void *mmap_reserve(size_t size, int fd)
* Activate memory in a reserved region from the given fd (if any), to make
* it accessible.
*/
-static void *mmap_activate(void *ptr, size_t size, int fd, bool readonly,
- bool shared, bool is_pmem, off_t map_offset)
+static void *mmap_activate(void *ptr, size_t size, int fd,
+ uint32_t qemu_map_flags, off_t map_offset)
{
+ const bool readonly = qemu_map_flags & QEMU_MAP_READONLY;
+ const bool shared = qemu_map_flags & QEMU_MAP_SHARED;
+ const bool sync = qemu_map_flags & QEMU_MAP_SYNC;
const int prot = PROT_READ | (readonly ? 0 : PROT_WRITE);
int map_sync_flags = 0;
int flags = MAP_FIXED;
@@ -128,7 +131,7 @@ static void *mmap_activate(void *ptr, size_t size, int fd, bool readonly,
flags |= fd == -1 ? MAP_ANONYMOUS : 0;
flags |= shared ? MAP_SHARED : MAP_PRIVATE;
- if (shared && is_pmem) {
+ if (shared && sync) {
map_sync_flags = MAP_SYNC | MAP_SHARED_VALIDATE;
}
@@ -173,9 +176,7 @@ static inline size_t mmap_guard_pagesize(int fd)
void *qemu_ram_mmap(int fd,
size_t size,
size_t align,
- bool readonly,
- bool shared,
- bool is_pmem,
+ uint32_t qemu_map_flags,
off_t map_offset)
{
const size_t guard_pagesize = mmap_guard_pagesize(fd);
@@ -199,7 +200,7 @@ void *qemu_ram_mmap(int fd,
offset = QEMU_ALIGN_UP((uintptr_t)guardptr, align) - (uintptr_t)guardptr;
- ptr = mmap_activate(guardptr + offset, size, fd, readonly, shared, is_pmem,
+ ptr = mmap_activate(guardptr + offset, size, fd, qemu_map_flags,
map_offset);
if (ptr == MAP_FAILED) {
munmap(guardptr, total);