Skip to content

Commit 1405d7e

Browse files
committed
user: Extract common MMAP API to 'user/mmap.h'
Keep common MMAP-related declarations in a single place. Note, this disable ThreadSafetyAnalysis on Linux for: - mmap_fork_start() - mmap_fork_end(). Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Warner Losh <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]>
1 parent 84d6626 commit 1405d7e

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

bsd-user/qemu.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
extern char **environ;
3333

3434
#include "user/thunk.h"
35+
#include "user/mmap.h"
3536
#include "target_arch.h"
3637
#include "syscall_defs.h"
3738
#include "target_syscall.h"
@@ -233,19 +234,8 @@ void print_taken_signal(int target_signum, const target_siginfo_t *tinfo);
233234
extern int do_strace;
234235

235236
/* mmap.c */
236-
int target_mprotect(abi_ulong start, abi_ulong len, int prot);
237-
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
238-
int flags, int fd, off_t offset);
239-
int target_munmap(abi_ulong start, abi_ulong len);
240-
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
241-
abi_ulong new_size, unsigned long flags,
242-
abi_ulong new_addr);
243237
int target_msync(abi_ulong start, abi_ulong len, int flags);
244-
extern abi_ulong mmap_next_start;
245-
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment);
246238
void mmap_reserve(abi_ulong start, abi_ulong size);
247-
void TSA_NO_TSA mmap_fork_start(void);
248-
void TSA_NO_TSA mmap_fork_end(int child);
249239

250240
/* main.c */
251241
extern char qemu_proc_pathname[];

include/user/mmap.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* MMAP declarations for QEMU user emulation
3+
*
4+
* SPDX-License-Identifier: GPL-2.0-or-later
5+
*/
6+
#ifndef USER_MMAP_H
7+
#define USER_MMAP_H
8+
9+
#include "user/abitypes.h"
10+
11+
/*
12+
* mmap_next_start: The base address for the next mmap without hint,
13+
* increased after each successful map, starting at task_unmapped_base.
14+
* This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT.
15+
*/
16+
extern abi_ulong mmap_next_start;
17+
18+
int target_mprotect(abi_ulong start, abi_ulong len, int prot);
19+
20+
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
21+
int flags, int fd, off_t offset);
22+
int target_munmap(abi_ulong start, abi_ulong len);
23+
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
24+
abi_ulong new_size, unsigned long flags,
25+
abi_ulong new_addr);
26+
27+
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size, abi_ulong alignment);
28+
29+
void TSA_NO_TSA mmap_fork_start(void);
30+
void TSA_NO_TSA mmap_fork_end(int child);
31+
32+
#endif

linux-user/user-mmap.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef LINUX_USER_USER_MMAP_H
1919
#define LINUX_USER_USER_MMAP_H
2020

21+
#include "user/mmap.h"
22+
2123
/*
2224
* Guest parameters for the ADDR_COMPAT_LAYOUT personality
2325
* (at present this is the only layout supported by QEMU).
@@ -39,24 +41,7 @@
3941
extern abi_ulong task_unmapped_base;
4042
extern abi_ulong elf_et_dyn_base;
4143

42-
/*
43-
* mmap_next_start: The base address for the next mmap without hint,
44-
* increased after each successful map, starting at task_unmapped_base.
45-
* This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT.
46-
*/
47-
extern abi_ulong mmap_next_start;
48-
49-
int target_mprotect(abi_ulong start, abi_ulong len, int prot);
50-
abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
51-
int flags, int fd, off_t offset);
52-
int target_munmap(abi_ulong start, abi_ulong len);
53-
abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
54-
abi_ulong new_size, unsigned long flags,
55-
abi_ulong new_addr);
5644
abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice);
57-
abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong);
58-
void mmap_fork_start(void);
59-
void mmap_fork_end(int child);
6045

6146
abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,
6247
abi_ulong shmaddr, int shmflg);

0 commit comments

Comments
 (0)