435c042f | 07-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Remove duplicate CPU_LOG_PAGE from probe_guest_base
The proper logging for probe_guest_base is in the main function. There is no need to duplicate that in the subroutines.
Reviewed-by:
linux-user: Remove duplicate CPU_LOG_PAGE from probe_guest_base
The proper logging for probe_guest_base is in the main function. There is no need to duplicate that in the subroutines.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
3ce3dd8c | 06-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
util/selfmap: Rewrite using qemu/interval-tree.h
We will want to be able to search the set of mappings. For this patch, the two users iterate the tree in order.
Signed-off-by: Richard Henderson <ri
util/selfmap: Rewrite using qemu/interval-tree.h
We will want to be able to search the set of mappings. For this patch, the two users iterate the tree in order.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
5f4e5b34 | 03-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Use zero_bss for PT_LOAD with no file contents too
If p_filesz == 0, then vaddr_ef == vaddr. We can reuse the code in zero_bss rather than incompletely duplicating it in load_elf_image.
linux-user: Use zero_bss for PT_LOAD with no file contents too
If p_filesz == 0, then vaddr_ef == vaddr. We can reuse the code in zero_bss rather than incompletely duplicating it in load_elf_image.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
2d385be6 | 03-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Do not adjust zero_bss for host page size
Rely on target_mmap to handle guest vs host page size mismatch.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.d
linux-user: Do not adjust zero_bss for host page size
Rely on target_mmap to handle guest vs host page size mismatch.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
e3d97d5c | 03-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Do not adjust image mapping for host page size
Remove TARGET_ELF_EXEC_PAGESIZE, and 3 other TARGET_ELF_PAGE* macros based off of that. Rely on target_mmap to handle guest vs host page s
linux-user: Do not adjust image mapping for host page size
Remove TARGET_ELF_EXEC_PAGESIZE, and 3 other TARGET_ELF_PAGE* macros based off of that. Rely on target_mmap to handle guest vs host page size mismatch.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
1f356e8c | 02-Aug-2023 |
Helge Deller <deller@gmx.de> |
linux-user: Adjust initial brk when interpreter is close to executable
While we attempt to load a ET_DYN executable far away from TASK_UNMAPPED_BASE, we are not completely in control of the address
linux-user: Adjust initial brk when interpreter is close to executable
While we attempt to load a ET_DYN executable far away from TASK_UNMAPPED_BASE, we are not completely in control of the address space layout. If the interpreter lands close to the executable, leaving insufficient heap space, move brk.
Tested-by: Helge Deller <deller@gmx.de> Signed-off-by: Helge Deller <deller@gmx.de> [rth: Re-order after ELF_ET_DYN_BASE patch so that we do not "temporarily break" tsan, and also to minimize the changes required. Remove image_info.reserve_brk as unused.] Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
1ea06ded | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Use elf_et_dyn_base for ET_DYN with interpreter
Follow the lead of the linux kernel in fs/binfmt_elf.c, in which an ET_DYN executable which uses an interpreter (usually a PIE executable)
linux-user: Use elf_et_dyn_base for ET_DYN with interpreter
Follow the lead of the linux kernel in fs/binfmt_elf.c, in which an ET_DYN executable which uses an interpreter (usually a PIE executable) is loaded away from where the interpreter itself will be loaded.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
ad25051b | 03-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Use MAP_FIXED_NOREPLACE for initial image mmap
Use this as extra protection for the guest mapping over any qemu host mappings.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge
linux-user: Use MAP_FIXED_NOREPLACE for initial image mmap
Use this as extra protection for the guest mapping over any qemu host mappings.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
da2b71fa | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Define ELF_ET_DYN_BASE in $guest/target_mman.h
Copy each guest kernel's default value, then bound it against reserved_va or the host address space.
Tested-by: Helge Deller <deller@gmx.d
linux-user: Define ELF_ET_DYN_BASE in $guest/target_mman.h
Copy each guest kernel's default value, then bound it against reserved_va or the host address space.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
2d708164 | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Define TASK_UNMAPPED_BASE in $guest/target_mman.h
Provide default values that are as close as possible to the values used by the guest's kernel.
Tested-by: Helge Deller <deller@gmx.de>
linux-user: Define TASK_UNMAPPED_BASE in $guest/target_mman.h
Provide default values that are as close as possible to the values used by the guest's kernel.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
c8fb5cf9 | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Adjust task_unmapped_base for reserved_va
Ensure that the chosen values for mmap_next_start and task_unmapped_base are within the guest address space.
Tested-by: Helge Deller <deller@gm
linux-user: Adjust task_unmapped_base for reserved_va
Ensure that the chosen values for mmap_next_start and task_unmapped_base are within the guest address space.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
50a00122 | 08-Aug-2023 |
Paolo Bonzini <pbonzini@redhat.com> |
linux-user: cleanup unused linux-user/include/host directories
Alpha and 31-bit s390 lack the assembly fragment to handle signals occurring at the same time as system calls, so they cannot run linux
linux-user: cleanup unused linux-user/include/host directories
Alpha and 31-bit s390 lack the assembly fragment to handle signals occurring at the same time as system calls, so they cannot run linux-user emulation anymore. Drop the host-signal.h files for them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20230808120303.585509-3-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
f140823c | 08-Aug-2023 |
Paolo Bonzini <pbonzini@redhat.com> |
configure: fix detection for x32 linux-user
x32 uses the same signal handling fragments as x86_64, since host_arch is set to x86_64 when Meson runs. Remove the unnecessary forwarder and set the hos
configure: fix detection for x32 linux-user
x32 uses the same signal handling fragments as x86_64, since host_arch is set to x86_64 when Meson runs. Remove the unnecessary forwarder and set the host_arch variable properly in configure.
Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Acked-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Ilya Leoshkevich <iii@linux.ibm.com> Tested-by: Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20230808120303.585509-2-pbonzini@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
62cbf081 | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Remove last_brk
This variable is unused.
Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.hender
linux-user: Remove last_brk
This variable is unused.
Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
0662a626 | 02-Aug-2023 |
Richard Henderson <richard.henderson@linaro.org> |
linux-user: Properly set image_info.brk in flatload
The heap starts at "brk" not "start_brk". With this fixed, image_info.start_brk is unused and may be removed.
Tested-by: Helge Deller <deller@gm
linux-user: Properly set image_info.brk in flatload
The heap starts at "brk" not "start_brk". With this fixed, image_info.start_brk is unused and may be removed.
Tested-by: Helge Deller <deller@gmx.de> Reviewed-by: Helge Deller <deller@gmx.de> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
2aea137a | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Do not align brk with host page size
do_brk() minimizes calls into target_mmap() by aligning the address with host page size, which is potentially larger than the target page size. Howev
linux-user: Do not align brk with host page size
do_brk() minimizes calls into target_mmap() by aligning the address with host page size, which is potentially larger than the target page size. However, the current implementation of this optimization has two bugs:
- The start of brk is rounded up with the host page size while brk advertises an address aligned with the target page size as the beginning of brk. This makes the beginning of brk unmapped. - Content clearing after mapping is flawed. The size to clear is specified as HOST_PAGE_ALIGN(brk_page) - brk_page, but brk_page is aligned with the host page size so it is always zero.
This optimization actually has no practical benefit. It makes difference when brk() is called multiple times with values in a range of the host page size. However, sophisticated memory allocators try to avoid to make such frequent brk() calls. For example, glibc 2.37 calls brk() to shrink the heap only when there is a room more than 128 KiB. It is rare to have a page size larger than 128 KiB if it happens.
Let's remove the optimization to fix the bugs and make the code simpler.
Fixes: 86f04735ac ("linux-user: Fix brk() to release pages") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1616 Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-7-akihiko.odaki@daynix.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
cb9d5d1f | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Do nothing if too small brk is specified
Linux 6.4.7 does nothing when a value smaller than the initial brk is specified.
Fixes: 86f04735ac ("linux-user: Fix brk() to release pages") Re
linux-user: Do nothing if too small brk is specified
Linux 6.4.7 does nothing when a value smaller than the initial brk is specified.
Fixes: 86f04735ac ("linux-user: Fix brk() to release pages") Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-6-akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
e69e032d | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Use MAP_FIXED_NOREPLACE for do_brk()
MAP_FIXED_NOREPLACE can ensure the mapped address is fixed without concerning that the new mapping overwrites something else.
Signed-off-by: Akihiko
linux-user: Use MAP_FIXED_NOREPLACE for do_brk()
MAP_FIXED_NOREPLACE can ensure the mapped address is fixed without concerning that the new mapping overwrites something else.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-5-akihiko.odaki@daynix.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
c6cc059e | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Do not call get_errno() in do_brk()
Later the returned value is compared with -1, and negated errno is not expected.
Fixes: 00faf08c95 ("linux-user: Don't use MAP_FIXED in do_brk()") Re
linux-user: Do not call get_errno() in do_brk()
Later the returned value is compared with -1, and negated errno is not expected.
Fixes: 00faf08c95 ("linux-user: Don't use MAP_FIXED in do_brk()") Reviewed-by: Helge Deller <deller@gmx.de> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-4-akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
ddcdd8c4 | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Fix MAP_FIXED_NOREPLACE on old kernels
The man page states: > Note that older kernels which do not recognize the MAP_FIXED_NOREPLACE > flag will typically (upon detecting a collision wit
linux-user: Fix MAP_FIXED_NOREPLACE on old kernels
The man page states: > Note that older kernels which do not recognize the MAP_FIXED_NOREPLACE > flag will typically (upon detecting a collision with a preexisting > mapping) fall back to a “non-MAP_FIXED” type of behavior: they will > return an address that is different from the requested address. > Therefore, backward-compatible software should check the returned > address against the requested address. https://man7.org/linux/man-pages/man2/mmap.2.html
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-3-akihiko.odaki@daynix.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
c3dd50da | 02-Aug-2023 |
Akihiko Odaki <akihiko.odaki@daynix.com> |
linux-user: Unset MAP_FIXED_NOREPLACE for host
Passing MAP_FIXED_NOREPLACE to host will fail for reserved_va because the address space is reserved with mmap. Replace it with MAP_FIXED in that case.
linux-user: Unset MAP_FIXED_NOREPLACE for host
Passing MAP_FIXED_NOREPLACE to host will fail for reserved_va because the address space is reserved with mmap. Replace it with MAP_FIXED in that case.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20230802071754.14876-2-akihiko.odaki@daynix.com> [rth: Expand inline commentary.] Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
4333f092 | 03-Aug-2023 |
Nathan Egge <negge@xiph.org> |
linux-user/elfload: Set V in ELF_HWCAP for RISC-V
Set V bit for hwcap if misa is set.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793 Signed-off-by: Nathan Egge <negge@xiph.org> Review
linux-user/elfload: Set V in ELF_HWCAP for RISC-V
Set V bit for hwcap if misa is set.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1793 Signed-off-by: Nathan Egge <negge@xiph.org> Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Tested-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Message-Id: <20230803131424.40744-1-negge@xiph.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
38dd78c4 | 28-Jul-2023 |
Helge Deller <deller@gmx.de> |
linux-user/armeb: Fix __kernel_cmpxchg() for armeb
Commit 7f4f0d9ea870 ("linux-user/arm: Implement __kernel_cmpxchg with host atomics") switched to use qatomic_cmpxchg() to swap a word with the memo
linux-user/armeb: Fix __kernel_cmpxchg() for armeb
Commit 7f4f0d9ea870 ("linux-user/arm: Implement __kernel_cmpxchg with host atomics") switched to use qatomic_cmpxchg() to swap a word with the memory content, but missed to endianess-swap the oldval and newval values when emulating an armeb CPU, which expects words to be stored in big endian in the guest memory.
The bug can be verified with qemu >= v7.0 on any little-endian host, when starting the armeb binary of the upx program, which just hangs without this patch.
Cc: qemu-stable@nongnu.org Signed-off-by: Helge Deller <deller@gmx.de> Reported-by: "Markus F.X.J. Oberhumer" <markus@oberhumer.com> Reported-by: John Reiser <jreiser@BitWagon.com> Closes: https://github.com/upx/upx/issues/687 Message-Id: <ZMQVnqY+F+5sTNFd@p100> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
show more ...
|
990ef918 | 17-Jul-2023 |
Richard Henderson <richard.henderson@linaro.org> |
include/exec: Add WITH_MMAP_LOCK_GUARD
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> |
4ea3fa99 | 22-Jul-2023 |
Michael Tokarev <mjt@tls.msk.ru> |
Revert "linux-user: Fix qemu-arm to run static armhf binaries"
This reverts commit 518f32221af759a29500ac172c4c857bef142067.
It is causing similar segfaults at least on aarch64, ppc64el and s390x.
Revert "linux-user: Fix qemu-arm to run static armhf binaries"
This reverts commit 518f32221af759a29500ac172c4c857bef142067.
It is causing similar segfaults at least on aarch64, ppc64el and s390x. Let's revert this one for now and analyze what's going on later.
Reopens: https://bugs.debian.org/1040981 Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
show more ...
|