aboutsummaryrefslogtreecommitdiff
path: root/bsd-user
AgeCommit message (Collapse)Author
2023-09-20bsd-user: spelling fixesMichael Tokarev
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Warner Losh <imp@bsdimp.com>
2023-09-08trace-events: Fix the name of the tracing.rst fileThomas Huth
The file has been converted to .rst a while ago - make sure that the references in the trace-events files are pointing to the right location now. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2023-08-31bulk: Do not declare function prototypes using 'extern' keywordPhilippe Mathieu-Daudé
By default, C function prototypes declared in headers are visible, so there is no need to declare them as 'extern' functions. Remove this redundancy in a single bulk commit; do not modify: - meson.build (used to check function availability at runtime) - pc-bios/ - libdecnumber/ - tests/ - *.c Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <20230605175647.88395-5-philmd@linaro.org>
2023-08-30bsd-user: Move PRAGMA_DISABLE_PACKED_WARNING etc to qemu.hWarner Losh
For the moment, move PRAGMA_DISABLE_PACKED_WARNING and PRAGMA_ENABLE_PACKED_WARNING back to bsd-user/qemu.h. Of course, these should be in compiler.h, but that interferes with too many things at the moment, so take one step back to unbreak clang linux-user builds first. Use the exact same version that's in linux-user/qemu.h since that's what should be in compiler.h. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2023-08-28bsd-user: Add missing break after do_bsd_preadvWarner Losh
Without it, we'd call preadv, then write with weird parameters, which is clearly not ideal... Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Fixes: 770d8abae7 ("bsd-user/bsd-file.h: Meat of the write system calls") Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230820045419.89691-1-imp@bsdimp.com>
2023-08-28bsd-user: Add getdents and fcntl related system callsWarner Losh
Add glue to call the following syscalls to the freebsd_syscall: freebsd11_getdents getdirentries freebsd11_getdirentries fcntl Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add glue for statfs related system callsWarner Losh
Add glue to call the following syscalls to the freebsd_syscall: freebsd11_statfs statfs freebsd11_fstatfs fstatfs freebsd11_getfsstat getfsstat Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Add glue for getfh and related syscallsWarner Losh
Add glue to call the following syscalls to the freebsd_syscall: getfh lgetfh fhopen freebsd11_fhstat freebsd11_fhstatfs fhstat fhstatfs Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Add glue for the freebsd11_stat syscallsWarner Losh
Add glue to call the freebsd11_stat syscalls to the freebsd_syscall: freebsd11_stat freebsd11_lstat freebsd11_fstat freebsd11_fstatat freebsd11_nstat, freebsd11_nfstat, freebsd11_nlstat fstatat fstat Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add os-stat.c to the buildKarim Taha
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement do_freebsd_realpathat syscallMikaël Urankar
Signed-off-by: Mikaël Urankar <mikael.urankar@gmail.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement freebsd11 netbsd stat related syscallsMichal Meloun
Forward declaration of the nstat syscalls: nstat nlstat nfstat Co-authored-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement freebsd11 getdirents related syscallsMichal Meloun
Implement the freebsd11 variant of the following syscalls: getdirentries(2) Co-authored-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement freebsd11 statfs related syscallsMichal Meloun
Implement the freebsd11 variant of the following syscalls: statfs(2) fstatfs(2) getfsstat(2) Co-authored-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement freebsd11 fstat and fhstat related syscallsMichal Meloun
Implement the freebsd11 variant of the following syscalls: fstat(2) fstatat(2) fhstat(2) fhstatfs(2) Co-authored-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement freebsd11 stat related syscallsMichal Meloun
Rename the following syscalls to the freebsd11 variant: do_freebsd_lstat -> do_freebsd11_lstat do_freebsd_stat -> do_freebsd11_stat Co-authored-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement stat related syscallsStacey Son
Implement the following syscalls: fcntl(2) Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement getdents related syscallsStacey Son
Implement the following syscalls: getdents(2) getdirecentries(2) Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement statfs related syscallsStacey Son
Implement the following syscalls: statfs(2) fstatfs(2) getfsstat(2) Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement statfh related syscallsStacey Son
Implement the following syscalls: getfh(2) lgetfh(2) fhopen(2) fhstat(2) fhstatfs(2) Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement stat related syscallsStacey Son
Implement the following syscalls: stat(2) lstat(2) fstat(2) fstatat(2) nstat nfstat nlstat Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-uesr: Implement h2t_freebsd_stat and h2t_freebsd_statfs functionsMichal Meloun
They are the 64-bit variants of h2t_freebsd11_stat and h2t_freebsd11_statfs, respectively Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement target_to_host_fcntl_cmdStacey Son
Implement the stat conversion functions: target_to_host_fcntl_cmd Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement h2t_freebds11_statfsStacey Son
Implement the stat conversion functions: h2t_freebds11_statfs Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement h2t_freebsd_fhandle t2h_freebsd_fhandleStacey Son
Implement the stat conversion functions: h2t_freebsd_fhandle t2h_freebsd_fhandle Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Implement h2t_freebsd11_stat h2t_freebsd_nstatStacey Son
Implement the stat conversion functions: h2t_freebsd11_stat h2t_freebsd_nstat Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Rename target_freebsd_time_t to target_time_tWarner Losh
This is necessary for future code using target_time_t, in bsd-user/syscall_defs. Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Define safe_fcntl macro in bsd-user/syscall_defs.hKyle Evans
Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add struct target_freebsd_fhandle and fcntl flagsStacey Son
Add struct target_freebsd_fhandle and fcntl flags to bsd-user/syscall_defs.h Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add struct target_statfsMichal Meloun
Add struct target_statfs to bsd-user/syscall_defs.h Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add structs target_freebsd11_{nstat,statfs}Stacey Son
Add structs target_freebsd11_nstat and target_freebsd11_statfs to bsd-user/syscall_defs.h Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Add struct target_stat to bsd-user/syscall_defs.hMichal Meloun
Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Add struct target_freebsd11_stat to bsd-user/syscall_defsStacey Son
Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org> Singed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Declarations of h2t and t2h conversion functions.Stacey Son
Declarations of functions that convert between host and target structs. Co-authored-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user; Update the definitions of __put_user and __get_user macrosWarner Losh
Use __builtin_choose_expr to avoid type promotion from ?: in __put_user_e and __get_user_e macros. Copied from linux-user/qemu.h, originally by Blue Swirl. Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Move _WANT_FREEBSD macros to include/qemu/osdep.hWarner Losh
move _WANT_FREEBSD macros from bsd-user/freebsd/os-syscall.c to include/qemu/osdep.h in order to pull some struct defintions needed later in the build. Signed-off-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com> Acked-by: Richard Henderson <richard.henderson@linaro.org>
2023-08-28bsd-user: Remove image_info.start_brkRichard Henderson
This has the same value is image_info.brk, which is also logged, and is otherwise unused. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230818175736.144194-4-richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Remove image_info.mmapRichard Henderson
This value is unused. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230818175736.144194-3-richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-28bsd-user: Remove ELF_START_MMAP and image_info.start_mmapRichard Henderson
The start_mmap value is write-only. Remove the field and the defines that populated it. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <20230818175736.144194-2-richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Signed-off-by: Warner Losh <imp@bsdimp.com>
2023-08-09linux-user: Use ARRAY_SIZE with bitmask_transtblRichard Henderson
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>
2023-08-06bsd-user: Remove last_brkRichard Henderson
This variable is unused. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-07-31bsd-user: Specify host page alignment if none specifiedWarner Losh
We're hitting an assert when we pass in alignment == 0 since that's not a power of two. so pass in the ideal page size. Signed-off-by: Warner Losh <imp@bsdimp.com> Message-Id: <20230728162927.5009-1-imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-07-31bsd-user: Allocate guest virtual address spaceRichard Henderson
With reserved_va, mmap.c expects to have pre-allocated host address space for the entire guest address space. When combined with the -B command-line option, ensure that the chosen address does not overlap anything else. Ensure that mmap_next_start is within reserved_va, as we use it within mmap.c without checking. Reviewed by: Warner Losh <imp@bsdimp.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230727161148.444988-1-richard.henderson@linaro.org>
2023-07-23include/exec: Add WITH_MMAP_LOCK_GUARDRichard Henderson
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2023-07-15accel/tcg: Return bool from page_check_rangeRichard Henderson
Replace the 0/-1 result with true/false. Invert the sense of the test of all callers. Document the function. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20230707204054.8792-25-richard.henderson@linaro.org>
2023-07-15bsd-user: Use page_find_range_empty for mmap_find_vma_reservedRichard Henderson
Use the interval tree to find empty space, rather than probing each page in turn. Cc: Warner Losh <imp@bsdimp.com> Cc: Kyle Evans <kevans@freebsd.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-bt: Warner Losh <imp@bsdimp.com> Message-Id: <20230707204054.8792-18-richard.henderson@linaro.org>
2023-07-15bsd-user: Use page_check_range_empty for MAP_EXCLRichard Henderson
The previous check returned -1 when any page within [start, start+len) is unmapped, not when all are unmapped. Cc: Warner Losh <imp@bsdimp.com> Cc: Kyle Evans <kevans@freebsd.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-Id: <20230707204054.8792-11-richard.henderson@linaro.org>
2023-06-26target/i386: implement SYSCALL/SYSRET in 32-bit emulatorsPaolo Bonzini
AMD supports both 32-bit and 64-bit SYSCALL/SYSRET, but the TCG only exposes it for 64-bit targets. For system emulation just reuse the helper; for user-mode emulation the ABI is the same as "int $80". The BSDs does not support any fast system call mechanism in 32-bit mode so add to bsd-user the same stub that FreeBSD has for 64-bit compatibility mode. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-06-13linux-user, bsd-user: Preserve incoming order of environment variables in ↵Andreas Schwab
the target Do not reverse the order of environment variables in the target environ array relative to the incoming environ order. Some testsuites depend on a specific order, even though it is not defined by any standard. Signed-off-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-Id: <mvmlejfsivd.fsf@suse.de> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2023-06-01*-user: remove the guest_user_syscall tracepointsAlex Bennée
This is pure duplication now. Both bsd-user and linux-user have builtin strace support and we can also track syscalls via the plugins system. Reviewed-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20230526165401.574474-2-alex.bennee@linaro.org Message-Id: <20230524133952.3971948-2-alex.bennee@linaro.org> [Remove unused variable in do_freebsd_syscall() reported by Richard Henderson. --Stefan] Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>