xref: /qemu/linux-user/user-mmap.h (revision 225a206c)
15423e6d3SPeter Maydell /*
25423e6d3SPeter Maydell  * user-mmap.h: prototypes for linux-user guest binary loader
35423e6d3SPeter Maydell  *
45423e6d3SPeter Maydell  *  This program is free software; you can redistribute it and/or modify
55423e6d3SPeter Maydell  *  it under the terms of the GNU General Public License as published by
65423e6d3SPeter Maydell  *  the Free Software Foundation; either version 2 of the License, or
75423e6d3SPeter Maydell  *  (at your option) any later version.
85423e6d3SPeter Maydell  *
95423e6d3SPeter Maydell  *  This program is distributed in the hope that it will be useful,
105423e6d3SPeter Maydell  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
115423e6d3SPeter Maydell  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
125423e6d3SPeter Maydell  *  GNU General Public License for more details.
135423e6d3SPeter Maydell  *
145423e6d3SPeter Maydell  *  You should have received a copy of the GNU General Public License
155423e6d3SPeter Maydell  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
165423e6d3SPeter Maydell  */
175423e6d3SPeter Maydell 
185423e6d3SPeter Maydell #ifndef LINUX_USER_USER_MMAP_H
195423e6d3SPeter Maydell #define LINUX_USER_USER_MMAP_H
205423e6d3SPeter Maydell 
21c8fb5cf9SRichard Henderson /*
22c8fb5cf9SRichard Henderson  * Guest parameters for the ADDR_COMPAT_LAYOUT personality
23c8fb5cf9SRichard Henderson  * (at present this is the only layout supported by QEMU).
24c8fb5cf9SRichard Henderson  *
25c8fb5cf9SRichard Henderson  * TASK_UNMAPPED_BASE: For mmap without hint (addr != 0), the search
26c8fb5cf9SRichard Henderson  * for unused virtual memory begins at TASK_UNMAPPED_BASE.
27c8fb5cf9SRichard Henderson  *
28da2b71faSRichard Henderson  * ELF_ET_DYN_BASE: When the executable is ET_DYN (i.e. PIE), and requires
29da2b71faSRichard Henderson  * an interpreter (i.e. not -static-pie), use ELF_ET_DYN_BASE instead of
30da2b71faSRichard Henderson  * TASK_UNMAPPED_BASE for selecting the address of the executable.
31da2b71faSRichard Henderson  * This provides some distance between the executable and the interpreter,
32da2b71faSRichard Henderson  * which allows the initial brk to be placed immediately after the
33da2b71faSRichard Henderson  * executable and also have room to grow.
34da2b71faSRichard Henderson  *
35da2b71faSRichard Henderson  * task_unmapped_base, elf_et_dyn_base: When the guest address space is
36da2b71faSRichard Henderson  * limited via -R, the values of TASK_UNMAPPED_BASE and ELF_ET_DYN_BASE
37da2b71faSRichard Henderson  * must be adjusted to fit.
38c8fb5cf9SRichard Henderson  */
39c8fb5cf9SRichard Henderson extern abi_ulong task_unmapped_base;
40da2b71faSRichard Henderson extern abi_ulong elf_et_dyn_base;
41c8fb5cf9SRichard Henderson 
42c8fb5cf9SRichard Henderson /*
43c8fb5cf9SRichard Henderson  * mmap_next_start: The base address for the next mmap without hint,
44c8fb5cf9SRichard Henderson  * increased after each successful map, starting at task_unmapped_base.
45c8fb5cf9SRichard Henderson  * This is an optimization within QEMU and not part of ADDR_COMPAT_LAYOUT.
46c8fb5cf9SRichard Henderson  */
47c8fb5cf9SRichard Henderson extern abi_ulong mmap_next_start;
48c8fb5cf9SRichard Henderson 
495423e6d3SPeter Maydell int target_mprotect(abi_ulong start, abi_ulong len, int prot);
505423e6d3SPeter Maydell abi_long target_mmap(abi_ulong start, abi_ulong len, int prot,
5155baec0fSRichard Henderson                      int flags, int fd, off_t offset);
525423e6d3SPeter Maydell int target_munmap(abi_ulong start, abi_ulong len);
535423e6d3SPeter Maydell abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size,
545423e6d3SPeter Maydell                        abi_ulong new_size, unsigned long flags,
555423e6d3SPeter Maydell                        abi_ulong new_addr);
56892a4f6aSIlya Leoshkevich abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice);
575423e6d3SPeter Maydell abi_ulong mmap_find_vma(abi_ulong, abi_ulong, abi_ulong);
585423e6d3SPeter Maydell void mmap_fork_start(void);
595423e6d3SPeter Maydell void mmap_fork_end(int child);
605423e6d3SPeter Maydell 
61225a206cSRichard Henderson abi_ulong target_shmat(CPUArchState *cpu_env, int shmid,
62225a206cSRichard Henderson                        abi_ulong shmaddr, int shmflg);
63225a206cSRichard Henderson abi_long target_shmdt(abi_ulong shmaddr);
64225a206cSRichard Henderson 
655423e6d3SPeter Maydell #endif /* LINUX_USER_USER_MMAP_H */
66