- Sep 01, 2023
-
-
Richard Henderson authored
Remove the fixed size shm_regions[] array. Remove references when other mappings completely remove or replace a region. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Helge Deller <deller@gmx.de> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
If the shm region is not mapped at shmaddr, EINVAL. Do not unmap the region until the syscall succeeds. Use mmap_reserve_or_unmap to preserve reserved_va semantics. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Move the CF_PARALLEL setting outside of the mmap lock. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Helge Deller <deller@gmx.de> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Rename from do_* to target_*. Fix some minor checkpatch errors. Tested-by:
Helge Deller <deller@gmx.de> Tested-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by:
Warner Losh <imp@bsdimp.com> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
The start_mmap value is write-only. Remove the field and the defines that populated it. Logically, this has been replaced by task_unmapped_base. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Ilya Leoshkevich authored
Core dumps produced by gdb's gcore when connected to qemu's gdbstub lack stack. The reason is that gdb includes only anonymous memory in core dumps, which is distinguished by a non-0 Anonymous: value. Consider the mappings with PAGE_ANON fully anonymous, and the mappings without it fully non-anonymous. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Ilya Leoshkevich <iii@linux.ibm.com> [rth: Update for open_self_maps_* rewrite] Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by:
Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
PIE executables are usually linked at offset 0 and are relocated somewhere during load. The hiaddr needs to be adjusted to keep the brk next to the executable. Cc: qemu-stable@nongnu.org Fixes: 1f356e8c ("linux-user: Adjust initial brk when interpreter is close to executable") Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Replace the by-hand method of region identification with the official user-exec interface. Cross-check the region provided to the callback with the interval tree from read_self_maps(). Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Use dev_t instead of a string, and ino_t instead of uint64_t. The latter is likely to be identical on modern systems but is more type-correct for usage. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Helge Deller authored
Add emulation for /proc/cpuinfo for the alpha architecture. alpha output example: (alpha-chroot)root@p100:/# cat /proc/cpuinfo cpu : Alpha cpu model : ev67 cpu variation : 0 cpu revision : 0 cpu serial number : JA00000000 system type : QEMU system variation : QEMU_v8.0.92 system revision : 0 system serial number : AY00000000 cycle frequency [Hz] : 250000000 timer frequency [Hz] : 250.00 page size [bytes] : 8192 phys. address bits : 44 max. addr. space # : 255 BogoMIPS : 2500.00 platform string : AlphaServer QEMU user-mode VM cpus detected : 8 cpus active : 4 cpu active mask : 0000000000000095 L1 Icache : n/a L1 Dcache : n/a L2 cache : n/a L3 cache : n/a Signed-off-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230803214450.647040-4-deller@gmx.de> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Helge Deller authored
Add emulation for /proc/cpuinfo for arm architecture. The output below mimics output as seen on debian porterboxes. aarch64 output example: processor : 0 model name : ARMv8 Processor rev 0 (v8l) BogoMIPS : 100.00 Features : swp half thumb fast_mult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae aes pmull sha1 sha2 crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x1 CPU part : 0xd07 CPU revision : 0 arm 32-bit output example: processor : 0 model name : ARMv7 Processor rev 5 (armv7l) BogoMIPS : 100.00 Features : swp half thumb fast_mult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0f CPU part : 0xc07 CPU revision : 5 Signed-off-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230803214450.647040-3-deller@gmx.de> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Move the various open_cpuinfo functions into new files. Move the m68k open_hardware function as well. All other guest architectures get a boilerplate empty file. Tested-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
- Aug 31, 2023
-
-
Michael Tokarev authored
Signed-off-by:
Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20230823065335.1919380-18-mjt@tls.msk.ru> Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Message-ID: <20230823065335.1919380-19-mjt@tls.msk.ru> Signed-off-by:
Philippe Mathieu-Daudé <philmd@linaro.org>
-
- Aug 23, 2023
-
-
Ilya Leoshkevich authored
The vxe2 hwcap is not set for programs running in linux-user, but is set by a Linux kernel running in softmmu. Add it to the former. Signed-off-by:
Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20230804233748.218935-2-iii@linux.ibm.com> Reviewed-by:
David Hildenbrand <david@redhat.com> Reviewed-by:
Claudio Fontana <cfontana@suse.de> Reviewed-by:
Richard Henderson <richard.henderson@linaro.org> Signed-off-by:
Thomas Huth <thuth@redhat.com>
-
- Aug 09, 2023
-
-
Helge Deller authored
In qemu we catch accesses to files like /proc/cpuinfo or /proc/net/route and return to the guest contents which would be visible on a real system (instead what the host would show). This patch fixes a bug, where for example the accesses cat /proc////cpuinfo or cd /proc && cat cpuinfo will not be recognized by qemu and where qemu will wrongly show the contents of the host's /proc/cpuinfo file. Signed-off-by:
Helge Deller <deller@gmx.de> Reviewed-by:
Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20230803214450.647040-2-deller@gmx.de> Reviewed-by:
Richard Henderson <richard.henderson@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Rather than using a zero tuple to end the table, use a macro to apply ARRAY_SIZE and pass that on to the convert functions. This fixes two bugs in which the conversion functions required that both the target and host masks be non-zero in order to continue, rather than require both target and host masks be zero in order to terminate. This affected mmap_flags_tbl when the host does not support all of the flags we wish to convert (e.g. MAP_UNINITIALIZED). Mapping these flags to zero is good enough, and matches how the kernel ignores bits that are unknown. Fixes: 4b840f96 ("linux-user: Populate more bits in mmap_flags_tbl") Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
New function that rejects unsupported map types and flags. In 4b840f96 we should not have accepted MAP_SHARED_VALIDATE without actually validating the rest of the flags. Fixes: 4b840f96 ("linux-user: Populate more bits in mmap_flags_tbl") Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
- Aug 08, 2023
-
-
Richard Henderson authored
Use pgb_addr_set to probe for all of the guest addresses, not just the main executable. Handle the identity map specially and separately from the search. If /proc/self/maps is available, utilize the full power of the interval tree search, rather than a linear search through the address list. If /proc/self/maps is not available, increase the skip between probes so that we do not probe every single page of the host address space. Choose 1 MiB for 32-bit hosts (max 4k probes) and 1 GiB for 64-bit hosts (possibly a large number of probes, but the large step makes it more likely to find empty space quicker). Tested-by:
Alex Bennée <alex.bennee@linaro.org> Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
Create a set of subroutines to collect a set of guest addresses, all of which must be mappable on the host. Use this within the renamed pgb_fixed subroutine to validate the user's choice of guest_base specified by the -B command-line option. Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
The three sets of checks are identical, logically. Reviewed-by:
Alex Bennée <alex.bennee@linaro.org> Signed-off-by:
Richard Henderson <richard.henderson@linaro.org>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Helge Deller authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Paolo Bonzini authored
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>
-
Paolo Bonzini authored
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>
-
- Aug 06, 2023
-
-
Richard Henderson authored
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>
-
Richard Henderson authored
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>
-
Akihiko Odaki authored
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: 86f04735 ("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>
-
Akihiko Odaki authored
Linux 6.4.7 does nothing when a value smaller than the initial brk is specified. Fixes: 86f04735 ("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>
-
Akihiko Odaki authored
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>
-
Akihiko Odaki authored
Later the returned value is compared with -1, and negated errno is not expected. Fixes: 00faf08c ("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>
-