Peter Maydell | 5423e6d | 2021-09-08 16:44:01 +0100 | [diff] [blame] | 1 | /* |
| 2 | * user-mmap.h: prototypes for linux-user guest binary loader |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef LINUX_USER_USER_MMAP_H |
| 19 | #define LINUX_USER_USER_MMAP_H |
| 20 | |
Richard Henderson | c8fb5cf | 2023-08-02 14:25:27 -0700 | [diff] [blame] | 21 | /* |
| 22 | * Guest parameters for the ADDR_COMPAT_LAYOUT personality |
| 23 | * (at present this is the only layout supported by QEMU). |
| 24 | * |
| 25 | * TASK_UNMAPPED_BASE: For mmap without hint (addr != 0), the search |
| 26 | * for unused virtual memory begins at TASK_UNMAPPED_BASE. |
| 27 | * |
Richard Henderson | da2b71f | 2023-08-02 15:17:33 -0700 | [diff] [blame] | 28 | * ELF_ET_DYN_BASE: When the executable is ET_DYN (i.e. PIE), and requires |
| 29 | * an interpreter (i.e. not -static-pie), use ELF_ET_DYN_BASE instead of |
| 30 | * TASK_UNMAPPED_BASE for selecting the address of the executable. |
| 31 | * This provides some distance between the executable and the interpreter, |
| 32 | * which allows the initial brk to be placed immediately after the |
| 33 | * executable and also have room to grow. |
| 34 | * |
| 35 | * task_unmapped_base, elf_et_dyn_base: When the guest address space is |
| 36 | * limited via -R, the values of TASK_UNMAPPED_BASE and ELF_ET_DYN_BASE |
| 37 | * must be adjusted to fit. |
Richard Henderson | c8fb5cf | 2023-08-02 14:25:27 -0700 | [diff] [blame] | 38 | */ |
| 39 | extern abi_ulong task_unmapped_base; |
Richard Henderson | da2b71f | 2023-08-02 15:17:33 -0700 | [diff] [blame] | 40 | extern abi_ulong elf_et_dyn_base; |
Richard Henderson | c8fb5cf | 2023-08-02 14:25:27 -0700 | [diff] [blame] | 41 | |
| 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 | |
Peter Maydell | 5423e6d | 2021-09-08 16:44:01 +0100 | [diff] [blame] | 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, |
Richard Henderson | 55baec0 | 2023-07-07 21:40:41 +0100 | [diff] [blame] | 51 | int flags, int fd, off_t offset); |
Peter Maydell | 5423e6d | 2021-09-08 16:44:01 +0100 | [diff] [blame] | 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); |
Ilya Leoshkevich | 892a4f6 | 2022-06-21 16:42:05 +0200 | [diff] [blame] | 56 | abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice); |
Peter Maydell | 5423e6d | 2021-09-08 16:44:01 +0100 | [diff] [blame] | 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); |
| 60 | |
Richard Henderson | 225a206 | 2023-08-20 09:24:14 -0700 | [diff] [blame] | 61 | abi_ulong target_shmat(CPUArchState *cpu_env, int shmid, |
| 62 | abi_ulong shmaddr, int shmflg); |
| 63 | abi_long target_shmdt(abi_ulong shmaddr); |
| 64 | |
Peter Maydell | 5423e6d | 2021-09-08 16:44:01 +0100 | [diff] [blame] | 65 | #endif /* LINUX_USER_USER_MMAP_H */ |