Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
Remove MAP_FILE flag usages
Browse files Browse the repository at this point in the history
`MAP_FILE` is deprecated, ignored and actually equals to `0`.

Signed-off-by: Borys Popławski <[email protected]>
  • Loading branch information
boryspoplawski authored and mkow committed Sep 6, 2021
1 parent 91d3e82 commit 4f0e5ef
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 16 deletions.
4 changes: 2 additions & 2 deletions LibOS/shim/src/bookkeep/shim_vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 31,8 @@
/* Filter flags that will be saved in `struct shim_vma`. For example there is no need for saving
* MAP_FIXED or unsupported flags. */
static int filter_saved_flags(int flags) {
return flags & (MAP_SHARED | MAP_SHARED_VALIDATE | MAP_PRIVATE | MAP_ANONYMOUS | MAP_FILE
| MAP_GROWSDOWN | MAP_HUGETLB | MAP_HUGE_2MB | MAP_HUGE_1GB | MAP_STACK
return flags & (MAP_SHARED | MAP_SHARED_VALIDATE | MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN
| MAP_HUGETLB | MAP_HUGE_2MB | MAP_HUGE_1GB | MAP_STACK
| VMA_UNMAPPED | VMA_INTERNAL | VMA_TAINTED);
}

Expand Down
4 changes: 0 additions & 4 deletions LibOS/shim/src/fs/chroot/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 690,7 @@ static int chroot_mmap(struct shim_handle* hdl, void** addr, size_t size, int pr

int pal_prot = LINUX_PROT_TO_PAL(prot, flags);

#if MAP_FILE == 0
if (flags & MAP_ANONYMOUS)
#else
if (!(flags & MAP_FILE))
#endif
return -EINVAL;

return pal_to_unix_errno(DkStreamMap(hdl->pal_handle, addr, pal_prot, offset, size));
Expand Down
5 changes: 0 additions & 5 deletions LibOS/shim/src/shim_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 820,6 @@ static void parse_mmap_flags(struct print_buf* buf, va_list* ap) {
flags &= ~MAP_ANONYMOUS;
}

if (flags & MAP_FILE) {
buf_puts(buf, "|MAP_FILE");
flags &= ~MAP_FILE;
}

if (flags & MAP_FIXED) {
buf_puts(buf, "|MAP_FIXED");
flags &= ~MAP_FIXED;
Expand Down
2 changes: 1 addition & 1 deletion LibOS/shim/test/regression/mmap_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 37,7 @@ int main(int argc, const char** argv) {
}

volatile unsigned char* a =
mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, fileno(fp), 0);
mmap(NULL, page_size * 2, PROT_READ | PROT_WRITE, MAP_PRIVATE, fileno(fp), 0);
if (a == MAP_FAILED) {
perror("mmap");
return 1;
Expand Down
3 changes: 1 addition & 2 deletions Pal/src/host/Linux-SGX/sgx_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 168,7 @@ static int load_enclave_binary(sgx_arch_secs_t* secs, int fd, unsigned long base

if (c->mapend > c->mapstart) {
void* addr = (void*)DO_SYSCALL(mmap, NULL, c->mapend - c->mapstart,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, fd,
c->mapoff);
PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, c->mapoff);

if (IS_PTR_ERR(addr)) {
ret = PTR_TO_ERR(addr);
Expand Down
5 changes: 3 additions & 2 deletions Pal/src/host/Linux/db_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 151,11 @@ static int file_map(PAL_HANDLE handle, void** addr, int prot, uint64_t offset, u
/* this address is used. don't over-map it later */
handle->file.map_start = NULL;
}
int flags = MAP_FILE | PAL_MEM_FLAGS_TO_LINUX(0, prot) | (mem ? MAP_FIXED : 0);
int flags = PAL_MEM_FLAGS_TO_LINUX(0, prot) | (mem ? MAP_FIXED : 0);
prot = PAL_PROT_TO_LINUX(prot);

/* The memory will always be allocated with flag MAP_PRIVATE and MAP_FILE */
/* The memory will always be allocated with flag MAP_PRIVATE. */
// TODO: except it will not since `assert(flags & MAP_PRIVATE)` fails on LTP
mem = (void*)DO_SYSCALL(mmap, mem, size, prot, flags, fd, offset);

if (IS_PTR_ERR(mem))
Expand Down

0 comments on commit 4f0e5ef

Please sign in to comment.