Commit Graph

18793 Commits

Author SHA1 Message Date
Brooks Davis
638c5fa8df syscalls: normalize (get|set)rlimit
Declare normal <foo>_args structs rather than going out of the way
to declare __<foo>_args.

Reviewed by:	kib, imp
2021-11-29 22:04:42 +00:00
Brooks Davis
c2996f8ad9 syscalls: regen 2021-11-29 22:04:42 +00:00
Brooks Davis
ba4e5253a3 syscalls: normalize orecvfrom and ogetsockname
Declare o<foo>_args rather than reusing the equivalent <foo>_args
structs.  Avoiding the addition of a new type isn't worth the
gratutious differences.

Reviewed by:	kib, imp
2021-11-29 22:04:42 +00:00
Brooks Davis
28f0471884 uipc: rework recvfrom, getsockname, getpeername
Stop using <foo>_args structs as part of internal kernel APIs.  Add
a kern_recvfrom and adjust getsockname and getpeername's equivalent
functions to take individual arguments rather than a uap pointer.

Adopt a convention from CheriBSD that a function interacting with
userspace pointers and sitting between the sys_<foo> syscall and
kern_<foo> implementation is named user_<foo>.

Reviewed by:	kib, imp
2021-11-29 22:04:41 +00:00
Brooks Davis
3660e76a22 syscalls: correct a couple style issues
Reviewed by:	kib, imp
2021-11-29 22:04:41 +00:00
Brooks Davis
33f9ea209e syscalls: add missing SAL annotations
freebsd7_shmctl was missing an annotation

Reviewed by:	kib, imp
2021-11-29 22:04:41 +00:00
Konstantin Belousov
08bb51f8d6 shutdown: unmount filesystems after swapoff
Swap on file requires operational underlying mount, otherwise
swapoff_all() is guaranteed to panic due to the default strategy VOP for
reclaimed vnodes.

Reported and tested by:	peterj
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33147
2021-11-29 18:38:02 +02:00
Konstantin Belousov
4f924a786a linker_kldload_busy(): allow recursion
Some drivers recursively loads modules by explicit calls to kldload
during initialization, which might occur during kldload.

PR:	259748
Reported and tested by:	thj
Reviewed by:	markj
Sponsored by:	Nvidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32972
2021-11-28 10:36:09 +02:00
Mateusz Guzik
e511bd1406 vfs: fully lockless v_writecount adjustment
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D33128
2021-11-27 23:07:26 +00:00
Mateusz Guzik
4dcdf3987c vfs: replace the MNTK_TEXT_REFS flag with VIRF_TEXT_REF
This allows to stop maintaing the VI_TEXT_REF flag and consequently
opens up fully lockless v_writecount adjustment.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D33127
2021-11-27 23:07:25 +00:00
Mateusz Guzik
054f5815c5 vfs: plug a set-but-not-used var in kern_alternate_path
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-11-26 12:22:09 +00:00
Mateusz Guzik
3ffcfa599e vfs: add vop_stdadd_writecount_nomsync
This avoids needing to inspect the mount point every time.

Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D33125
2021-11-26 12:06:08 +00:00
Mateusz Guzik
7e1d3eefd4 vfs: remove the unused thread argument from NDINIT*
See b4a58fbf64 ("vfs: remove cn_thread")

Bump __FreeBSD_version to 1400043.
2021-11-25 22:50:42 +00:00
Mateusz Guzik
c40fee6f7d vfs: drop the always curthread argument from kern_alternate_path 2021-11-25 22:50:42 +00:00
Mark Johnston
b11e6fd75b link_elf_obj: Process global ifunc relocs after other global relocs
This is needed to ensure that resolvers that reference global symbols
return correct results.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33120
2021-11-25 16:53:27 -05:00
Brooks Davis
be67ea40c5 freebsd32: generate from sys/kern/syscalls.master
This avoids the need to keep a freebsd32-specific syscalls.master
in sync with the default ABI.  As evidenced by the number of commits
required to sync the two, it is extremely easy for them to get out
of sync due to misunderstandings and user errors.

Reviewed by:	kevans, kib
2021-11-22 22:36:58 +00:00
Brooks Davis
799ce8b8d2 syscalls: annotate args pointing to long, pointer, or time_t
Add _Contains_ annotations indicating that the data pointed to by a
pointer argument contains types that vary between FreeBSD ABIs. The
supported set is long (including size_t), pointer (including
intptr_t), and time_t.  The first two vary between 32- and 64-bit
ABIs.  The laste betwen i386 and everything else.

These will be used to detect which syscalls require handling on
particular ABIs.

Reviewed by:	kevans, kib
2021-11-22 22:36:58 +00:00
Brooks Davis
6b7c23a026 syscalls: regen 2021-11-22 22:36:57 +00:00
Brooks Davis
6eefabd4ca syscalls: improve nstat, nfstat, nlstat
Optionally return errors when truncating dev_t, ino_t, and nlink_t.
In the interest of code reuse, use freebsd11_cvtstat() to perform the
truncation and error handling and then convert the resulting struct
freebsd11_stat to struct nstat.

Add missing freebsd32 compat syscalls. These syscalls require
translation because struct nstat contains four instances of struct
timespec which in turn contains a time_t and a long.

Reviewed by:	kib
2021-11-22 22:36:56 +00:00
Brooks Davis
151ddfec6f freebsd32: add _'s to _umtx_(un)lock
This aligns with the default ABI's configuration.

Reviewed by:	kib
2021-11-22 22:36:55 +00:00
Brooks Davis
d330857439 syscalls: regen 2021-11-22 22:36:54 +00:00
Brooks Davis
00e0a4c0d7 syscalls: abort2 doesn't return so declare as void
Reviewed by:	kib
2021-11-22 22:36:54 +00:00
Brooks Davis
4b2e1f1480 syscalls: umask returns a mode_t
Reviewed by:	kib
2021-11-22 22:36:54 +00:00
Brooks Davis
27f5b514a0 syscalls: update a few return types to ssize_t
Reviewed by:	kib
2021-11-22 22:36:54 +00:00
Brooks Davis
717e7fb27a syscalls: struct ucontext4 -> struct freebsd4_ucontext
This aligns with struct freebsd4_ucontext32 in freebsd32.

Reviewed by:	kib
2021-11-22 22:36:54 +00:00
Brooks Davis
e58e9a8cbd syscalls: regen 2021-11-22 22:36:54 +00:00
Brooks Davis
d8bd949beb sys___sysctl: regularize argument struct
Let makesyscalls generate the normal struct __sysctl_args structure.
It works fine.

Reviewed by:	kib
2021-11-22 22:36:54 +00:00
Brooks Davis
97e4bec56d syscalls: regen 2021-11-22 22:36:53 +00:00
Brooks Davis
88dfcfa2a0 sys_sigaltstack: use struct sigaltstack arg
This is idential to stack_t and more amenable to prepending "32" to
for freebsd32.

Reviewed by:	kib
2021-11-22 22:36:53 +00:00
Robert Wing
8981a100e6 mount: retire kernel_vmount()
The last usage of this function was removed in e3b1c847a4.

There are no in-tree consumers of kernel_vmount().

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D32607
2021-11-20 10:22:28 -09:00
Mark Johnston
3339950117 timecounter: Initialize tc_lock earlier
Hyper-V wants to register its MSR-based timecounter during
SI_SUB_HYPERVISOR, before SI_SUB_LOCK, since an emulated 8254 may not be
available for DELAY().  So we cannot use MTX_SYSINIT to initialize the
timecounter lock.

PR:		259878
Reviewed by:	kib
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33014
2021-11-19 17:29:28 -05:00
Mitchell Horne
588ab3c774 Allow minidumps to be performed on the live system
Add a boolean parameter to minidumpsys(), to indicate a live dump. When
requested, take a snapshot of important global state, and pass this to
the machine-dependent minidump function. For now this includes the
kernel message buffer, and the bitset of pages to be dumped. Beyond
this, we don't take much action to protect the integrity of the dump
from changes in the running system.

A new function msgbuf_duplicate() is added for snapshotting the message
buffer. msgbuf_copy() is insufficient for this purpose since it marks
any new characters it finds as read.

For now, nothing can actually trigger a live minidump. A future patch
will add the mechanism for this. For simplicity and safety, live dumps
are disallowed for mips.

Reviewed by:	markj, jhb
MFC after:	2 weeks
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D31993
2021-11-19 15:05:53 -04:00
Mitchell Horne
1adebe3cd6 minidump: Parameterize minidumpsys()
The minidump code is written assuming that certain global state will not
change, and rightly so, since it executes from a kernel debugger
context. In order to support taking minidumps of a live system, we
should allow copies of relevant global state that is likely to change to
be passed as parameters to the minidumpsys() function.

This patch does the work of parameterizing this function, by adding a
struct minidumpstate argument. For now, this struct allows for copies of
the kernel message buffer, and the bitset that tracks which pages should
be dumped (vm_page_dump). Follow-up changes will actually make use of
these arguments.

Notably, dump_avail[] does not need a snapshot, since it is not expected
to change after system initialization.

The existing minidumpsys() definitions are renamed, and a thin MI
wrapper is added to kern_dump.c, which handles the construction of
the state struct. Thus, calling minidumpsys() remains as simple as
before.

Reviewed by:	kib, markj, jhb
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D31989
2021-11-19 15:05:52 -04:00
Gordon Bergling
15b5c347f1 sched_ule(4): Fix two typo in source code comments
- s/conditons/conditions/
- s/unconditonally/unconditionally/

MFC after:	3 days
2021-11-19 19:13:28 +01:00
Wuyang Chung
8587d75255 Correct the name of the second parameter of biowait to wmesg
This parameter is passed directly to msleep, and the name of the msleep
parameter is wmesg. Make them match.

Pull Request: https://github.com/freebsd/freebsd-src/pull/557
2021-11-18 23:26:33 -07:00
Konstantin Belousov
a7e4eb1422 Kernel linkers: some style
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D32878
2021-11-18 15:56:23 +02:00
Alex Richardson
4082b189d2 elf*_brand_inuse: Change return type to bool.
Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33052
2021-11-17 15:51:40 -08:00
Alex Richardson
1962164584 imgact_elf: Use bool instead of boolean_t.
Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33051
2021-11-17 15:51:29 -08:00
Brooks Davis
265a4b8341 freebsd32: semid_t -> int32_t
semid_t is historically an intptr_t so it should be an int32_t.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
2b9d052d3e freebsd32: fix getfsstat sign extension bugs
Add freebsd32 versions of getfsstat and freebsd11_getfsstat so that
bufsize is properly sign-extended if a negative value is passed.
Reject negative values before passing to kern_getfsstat as a size_t.

Reviewed by:	kevans
2021-11-17 20:12:26 +00:00
Brooks Davis
e02f64d9b8 freebsd32: add real abort2
Previously, the code would copy twice as many pointers as specified
and print pairs of them a single 64-bit pointer.

abort2 doesn't return so make the return type void

freebsd32_abort2 is in it's own file with a 2-clause BSD license
based on a discussion with Wojciech many years ago.

Reviewed by:	kevans
2021-11-17 20:12:25 +00:00
Brooks Davis
0ebea13928 freebsd32: include __ in semctl names
This mirrors sys/kern/syscall.master and will simplify generation
of freebsd32 files.

Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
d35a771660 freebsd32: sync _umtx_op args with default ABI
Reviewed by:	kevans
2021-11-17 20:12:24 +00:00
Brooks Davis
3b0cd7e503 freebsd32: rename old SysV IPC types
Move the 32 from ...32_old to ..._old32 to aid automatic generation.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
e5b0997650 freebsd32: add a union semun_old32
Use this for COMPAT7 support.  In practice it's the same as
union semun32 since the pointers become uint32_t's the it's more
symetric and is the logical thing to generate from semun_old.

Reviewed by:	kevans
2021-11-17 20:12:23 +00:00
Brooks Davis
85d1d2a675 syscalls: use struct siginfo rather than siginfo_t
This allows freebsd32 to use struct siginfo32 with an automatable
conversion.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
f503288262 syscalls: fix type of osendmsg
osendmsg takes an struct omsghdr * not a void *.

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
2385f4d172 syscalls: use __socklen_t as appropriate
No functional change as __socklen_t is an int.

Obtained from:	CheriBSD

Reviewed by:	kevans
2021-11-17 20:12:22 +00:00
Brooks Davis
b64f3dc26c syscalls: [gs]etitimer takes an int which
Match the function decleration which takes an int not a signed int.
No functional change as the range of valid values is 0-2.

Obtained from: CheriBSD

Reviewed by:	kevans
2021-11-17 20:12:21 +00:00
Brooks Davis
b7fd86118f syscalls: sprinkle in const values
Add missing const qualifiers to a number of syscall arguments.

Obtained from:	CheriBSD

Reviewed by:	kevans
2021-11-17 20:12:21 +00:00