summaryrefslogtreecommitdiffstats
path: root/bsd-user
Commit message (Collapse)AuthorAgeFilesLines
* bsd-user: Catch up with sys/param.h requirement for machine/pmap.hMuhammad Moinur Rahman2022-10-262-0/+2
| | | | | | | | | | Some versions of FreeBSD now require sys/param.h for machine/pmap.h on x86. Include them here to meet that requirement. It does no harm on older versions, so there's no need to #ifdef it. Signed-off-by: Muhammad Moinur Rahman <bofh@FreeBSD.org> Reviewed-by: John Baldwin <jhb@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com>
* accel/tcg: Call tb_invalidate_phys_page for PAGE_RESETRichard Henderson2022-10-261-2/+0Star
| | | | | | | | | | | | | | | | | When PAGE_RESET is set, we are replacing pages with new content, which means that we need to invalidate existing cached data, such as TranslationBlocks. Perform the reset invalidate while we're doing other invalidates, which allows us to remove the separate invalidates from the user-only mmap/munmap/mprotect routines. In addition, restrict invalidation to PAGE_EXEC pages. Since cdf713085131, we have validated PAGE_EXEC is present before translation, which means we can assume that if the bit is not present, there are no translations to invalidate. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Remove stray 'inline' from do_bsd_closeWarner Losh2022-07-021-1/+1
| | | | | | | | In the last series, I inadvertantly didn't remove this inline, but did all the others. Remove it for consistency. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement undeleteWarner Losh2022-07-022-0/+17
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement pathconf, lpathconf and fpathconfWarner Losh2022-07-022-0/+44
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement mkfifo and mkfifoatWarner Losh2022-07-022-0/+35
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement chroot and flockWarner Losh2022-07-022-0/+27
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement chflags, lchflags and fchflagsWarner Losh2022-07-022-0/+44
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement chown, fchown, lchown and fchownatWarner Losh2022-07-022-0/+64
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement freebsd11_mknod, freebsd11_mknodat and mknodatWarner Losh2022-07-022-0/+60
| | | | | | | | | | | These implement both the old-pre INO64 mknod variations, as well as the now current INO64 variant. Make direct syscall calls for these older syscalls to avloid too many dependencies. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Michal Meloun <mmel@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: implement chmod, fchmod, lchmod and fchmodatWarner Losh2022-07-022-0/+62
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement symlink, symlinkat, readlink and readlinkatWarner Losh2022-07-022-0/+90
| | | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement mount, umount and nmountWarner Losh2022-07-022-0/+65
| | | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement acct and syncWarner Losh2022-06-142-0/+31
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement trunctate and ftruncateWarner Losh2022-06-142-0/+37
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement dup and dup2Warner Losh2022-06-142-0/+20
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement rmdir and undocumented __getcwdWarner Losh2022-06-142-0/+37
| | | | | | | | | | Implemenet rmdir and __getcwd. __getcwd is the undocumented back end to getcwd(3). Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement mkdir and mkdiratWarner Losh2022-06-142-0/+35
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement link, linkat, unlink and unlinkatWarner Losh2022-06-132-0/+70
| | | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement rename and renameatWarner Losh2022-06-132-0/+53
| | | | | | | | | Plus the helper LOCK_PATH2 and UNLOCK_PATH2 macros. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement chdir and fchdirWarner Losh2022-06-132-0/+27
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement revoke, access, eaccess and faccessatWarner Losh2022-06-132-0/+69
| | | | | | Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement fdatasync, fsync and close_fromWarner Losh2022-06-132-0/+31
| | | | | | | | | Implement fdatasync(2), fsync(2) and close_from(2). Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Implement open, openat and closeWarner Losh2022-06-133-0/+69
| | | | | | | | | | | Add the open, openat and close system calls. We need to lock paths, so implmenent that as well. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/os-syscall.c: Implement exitWarner Losh2022-06-112-0/+49
| | | | | | | | | | Implement the exit system call. Bring in bsd-proc.h to contain all the process system call implementation and helper routines. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Kyle Evans <kevans@FreeBSD.org>
* bsd-user/bsd-file.h: Meat of the write system callsWarner Losh2022-06-112-0/+106
| | | | | | | | | | Implement write, writev, pwrite and pwritev and connect them to the system call dispatch routine. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/bsd-file.h: Add implementations for read, pread, readv and preadvWarner Losh2022-06-112-0/+107
| | | | | | | | | | Implement do_bsd_{read,pread,readv,preadv}. Connect them to the system call table. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/os-syscall.c: Tracing and error boilerplateWarner Losh2022-06-111-4/+40
| | | | | | | | | | | | Add in the tracing and this system call not implemented boilerplate. Do this by moving the guts of do_freebsd_syscall to freebsd_syscall. Put the tracing in the wrapper function. Since freebsd_syscall is a singleton static function, it will almost certainly be inlined. Fix comments that referred to do_syscall since that was renamed some tie ago. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/os-syscall.c: unlock_iovecWarner Losh2022-06-111-0/+14
| | | | | | | Releases the references to the iovec created by lock_iovec. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/os-syscall.c: lock_iovecWarner Losh2022-06-111-0/+102
| | | | | | | | | | | | | | lock_iovec will lock an I/O vec and the memory to which it refers and create a iovec in the host space that refers to it, with full error unwinding. Add helper_iovec_unlock to unlock the partially locked iovec in case there's an error. The code will be used in iovec_unlock when that is committed. Note: memory handling likely could be rewritten to use q_autofree. That will be explored in the future since what we have now works well enough. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* Clean up decorations and whitespace around header guardsMarkus Armbruster2022-05-112-2/+2
| | | | | | | | Cleaned up with scripts/clean-header-guards.pl. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220506134911.2856099-5-armbru@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* Clean up ill-advised or unusual header guardsMarkus Armbruster2022-05-1147-141/+157
| | | | | | | | | | | | | | | | | | Leading underscores are ill-advised because such identifiers are reserved. Trailing underscores are merely ugly. Strip both. Our header guards commonly end in _H. Normalize the exceptions. Macros should be ALL_CAPS. Normalize the exception. Done with scripts/clean-header-guards.pl. include/hw/xen/interface/ and tools/virtiofsd/ left alone, because these were imported from Xen and libfuse respectively. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220506134911.2856099-3-armbru@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* Clean up header guards that don't match their file nameMarkus Armbruster2022-05-114-13/+12Star
| | | | | | | | | | | | | Header guard symbols should match their file name to make guard collisions less likely. Cleaned up with scripts/clean-header-guards.pl, followed by some renaming of new guard symbols picked by the script to better ones. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220506134911.2856099-2-armbru@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> [Change to generated file ebpf/rss.bpf.skeleton.h backed out]
* compiler.h: replace QEMU_NORETURN with G_NORETURNMarc-André Lureau2022-04-211-1/+2
| | | | | | | | | | | | | G_NORETURN was introduced in glib 2.68, fallback to G_GNUC_NORETURN in glib-compat. Note that this attribute must be placed before the function declaration (bringing a bit of consistency in qemu codebase usage). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-Id: <20220420132624.2439741-20-marcandre.lureau@redhat.com>
* include: rename qemu-common.h qemu/help-texts.hMarc-André Lureau2022-04-211-1/+1
| | | | | | | Suggested-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Warner Losh <imp@bsdimp.com> Message-Id: <20220420132624.2439741-7-marcandre.lureau@redhat.com>
* Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into stagingRichard Henderson2022-04-211-1/+0Star
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cleanup sysemu/tcg.h usage. Fix indirect lowering vs cond branches Remove ATOMIC_MMU_IDX Add tcg_constant_ptr # -----BEGIN PGP SIGNATURE----- # # iQFRBAABCgA7FiEEekgeeIaLTbaoWgXAZN846K9+IV8FAmJgW38dHHJpY2hhcmQu # aGVuZGVyc29uQGxpbmFyby5vcmcACgkQZN846K9+IV8tpggApfg2CDI0bRMDBh0g # 04/xwNnzHuSa84/ocMOMUfD5pvBblUmeTH8fAwqcAPDM/EEZwWZl2V1bYzuIrbmR # 8zV+r1cOenDF5Tz8PWfy8XssinTVtTWh/TE0XNV9R/SbEM9eMsjHNu5osKVuLuq1 # rnHWZf8LuY7xGsy4GYqPN0dLE6HtQOfpj/eLGRAj9mZ7re0jKeWg3GdxYoiYDmks # NKmNHYcWD+SjjFvXlOafniQsHbBZmQc/qp7AShG/+VcYY9o1VfncWD6I2dV13RdB # N7++ZhGyQR4NOVo6CN1zLKhfuJqzH2q+qJ7vQ3xtXNAk53LGQ91zjoE+3KaJTrcy # dmnLUw== # =aKdS # -----END PGP SIGNATURE----- # gpg: Signature made Wed 20 Apr 2022 12:14:07 PM PDT # gpg: using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F # gpg: issuer "richard.henderson@linaro.org" # gpg: Good signature from "Richard Henderson <richard.henderson@linaro.org>" [ultimate] * tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu: tcg: Add tcg_constant_ptr accel/tcg: Remove ATOMIC_MMU_IDX tcg: Fix indirect lowering vs TCG_OPF_COND_BRANCH Don't include sysemu/tcg.h if it is not necessary Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
| * Don't include sysemu/tcg.h if it is not necessaryThomas Huth2022-04-201-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | This header only defines the tcg_allowed variable and the tcg_enabled() function - which are not required in many files that include this header. Drop the #include statement there. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20220315144107.1012530-1-thuth@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
* | bsd-user: Use qemu_set_log_filename_flagsRichard Henderson2022-04-201-9/+9
| | | | | | | | | | | | | | | | Perform all logfile setup in one step. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-29-richard.henderson@linaro.org>
* | bsd-user: Expand log_page_dump inlineRichard Henderson2022-04-201-14/+23
| | | | | | | | | | | | | | | | | | We have extra stuff to log at the same time. Hoist the qemu_log_trylock/unlock to the caller and use fprintf. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-22-richard.henderson@linaro.org>
* | util/log: Pass Error pointer to qemu_set_logRichard Henderson2022-04-201-1/+1
| | | | | | | | | | | | | | | | | | Do not force exit within qemu_set_log; return bool and pass an Error value back up the stack as per usual. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-5-richard.henderson@linaro.org>
* | util/log: Drop manual log bufferingRichard Henderson2022-04-201-1/+0Star
|/ | | | | | | | | | | | | | This buffering was introduced during the Paleozoic: 9fa3e853531. There has never been an explanation as to why we may not allow glibc to allocate the file buffer itself. We certainly have many other uses of mmap and malloc during user-only startup, so presumably whatever the issue was, it has been fixed during the preceeding 18 years. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220417183019.755276-2-richard.henderson@linaro.org>
* Remove qemu-common.h include from most unitsMarc-André Lureau2022-04-062-2/+0Star
| | | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-33-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Replace qemu_real_host_page variables with inlined functionsMarc-André Lureau2022-04-062-2/+2
| | | | | | | | | | | | Replace the global variables with inlined helper functions. getpagesize() is very likely annotated with a "const" function attribute (at least with glibc), and thus optimization should apply even better. This avoids the need for a constructor initialization too. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220323155743.1585078-12-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Replace TARGET_WORDS_BIGENDIANMarc-André Lureau2022-04-061-1/+1
| | | | | | | | | | | | Convert the TARGET_WORDS_BIGENDIAN macro, similarly to what was done with HOST_BIG_ENDIAN. The new TARGET_BIG_ENDIAN macro is either 0 or 1, and thus should always be defined to prevent misuse. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Suggested-by: Halil Pasic <pasic@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220323155743.1585078-8-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Replace GCC_FMT_ATTR with G_GNUC_PRINTFMarc-André Lureau2022-03-221-1/+1
| | | | | | | | One less qemu-specific macro. It also helps to make some headers/units only depend on glib, and thus moved in standalone projects eventually. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
* bsd-user: Add safe system call macrosWarner Losh2022-02-271-0/+47
| | | | | | | | | Add a series of macros to create system call macros that go via the safe_syscall path. Signed-off-by: Kyle Evans <kevans@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: Define target_arg64Warner Losh2022-02-271-0/+13
| | | | | | | | | | | | target_arg64 is a generic way to extract 64-bits from a pair of arguments. On 32-bit platforms, it returns them joined together as appropriate. On 64-bit platforms, it returns the first arg because it's already 64-bits. Signed-off-by: Stacey Son <sson@FreeBSD.org> Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user: introduce target.hWarner Losh2022-02-274-0/+64
| | | | | | | | | | | | | | | | Create target.h. This file is intended to be simple and describe basic things about the architecture. If something is a basic feature of the architecture, it belongs here. Should we need something that's per-BSD there will be a target-os.h that will live in the per-bsd directories. Define regpairs_aligned to reflect whether or not registers are 'paired' for 64-bit arguments or not. This will be false for all 64-bit targets, and will be true on those architectures that pair (currently just armv7 and powerpc on FreeBSD 14.x). Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/bsd-file.h: Implementation details for the filesystem callsWarner Losh2022-02-272-0/+32
| | | | | | | | | | An include file that pulls in all the definitions needed for the file related system calls. This also includes the host definitions to implement the system calls and some helper routines to lock/unlock different aspects of the system call arguments. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
* bsd-user/freebsd/os-syscall.c: Add get_errno and host_to_target_errnoWarner Losh2022-02-262-2/+24
| | | | | | | | | | | | Add the helper functions get_errno and host_to_target_errno. get_errno returns either the system call results, or the -errno when system call indicates failure by returning -1. Host_to_target_errno returns errno (since on FreeBSD they are the same on all architectures) along with a comment about why it's the identity. Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Kyle Evans <kevans@FreeBSD.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>