Commit Graph

131199 Commits

Author SHA1 Message Date
Mateusz Guzik
c615009461 vfs: check early for VCHR in vput_final to short-circuit in the common case
Otherwise the compiler inlines v_decr_devcount which keps getting jumped over
in the common case of not dealing with a device.
2020-02-16 03:16:28 +00:00
Mateusz Guzik
890611286e refcount: add missing release fence to refcount_release_if_gt
The CPU succeeding in releasing the not last reference can still have pending
stores to the object protected by the affected counter. This opens a time
window where another CPU can release the last reference and free the object,
resulting in use-after-free. On top of that this prevents the compiler from
generating more accesses to the object regardless of how atomic_fcmpset_rel_int
is implemented (of course as long as it provides the release semantic).

Reviewed by:	markj
2020-02-16 03:14:55 +00:00
Jeff Roberson
6d88d784f8 Slightly restructure uma_zalloc* to generate better code from clang and
reduce duplication among zalloc functions.

Reviewed by:	markj
Discussed with:	mjg
Differential Revision:	https://reviews.freebsd.org/D23672
2020-02-16 01:07:19 +00:00
Matt Macy
45035becfe Add zfree to zero allocation before free
Key and cookie management typically wants to
avoid information leaks by explicitly zeroing
before free. This routine simplifies that by
permitting consumers to do so without carrying
the size around.

Reviewed by:	jeff@, jhb@
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D22790
2020-02-16 00:12:53 +00:00
Matt Macy
bbb7a2c7c3 Add chacha20poly1305 support to crypto build
This is a dependency for in-kernel wireguard.

Reviewed by:	cem@
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D23689
2020-02-16 00:03:09 +00:00
Konstantin Belousov
a7b61c0af1 sem_remove(): fix the loop that compacts sem array on semaphores removal.
As written now, it copies random kernel memory from beyond the bounds
of the array.

Reported and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23694
2020-02-15 23:19:23 +00:00
Konstantin Belousov
4cb6ea7e8e sem_remove(): add some asserts.
Assert that sema[idx] allocation from sem[] is sane.
Also assert that sem_mtx is owned, it protects the SEM_ALLOC flag.

Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23694
2020-02-15 23:18:02 +00:00
Konstantin Belousov
8095050846 Use designated initializers for seminfo.
Reviewed by:	markj
Tested by:	pho
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23694
2020-02-15 23:15:42 +00:00
Mateusz Guzik
4d51e175f9 ufs: use faster lockgmr entry points in ffs_lock 2020-02-15 21:48:48 +00:00
Dimitry Andric
bacffcd4b1 Merge r357970 from the clang1000-import branch:
Fix the following -Werror warning from clang 10.0.0 in hptmv(4):

sys/dev/hptmv/ioctl.c:240:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                        _vbus_p=pArray->pVBus;
                        ^
sys/dev/hptmv/ioctl.c:237:10: note: previous statement is here
                if(!mIsArray(pArray))
                ^

This is because the return statement after the if statement was not
indented.  (Note that this file has been idented assuming 4-space tabs.)

MFC after:	3 days
2020-02-15 19:15:24 +00:00
Pawel Biernacki
b40598c539 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (4 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	kib
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23625
X-Generally looks fine:	jhb
2020-02-15 18:57:49 +00:00
Pawel Biernacki
39a3542bef Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	hselasky, kib, zeising
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23631
2020-02-15 18:54:59 +00:00
Pawel Biernacki
f8d2b1f3f7 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	hselasky, kib
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23632
2020-02-15 18:52:12 +00:00
Pawel Biernacki
e0d69c5a88 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (1 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked). Use it in
preparation for a general review of all nodes.
This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Reviewed by:	kib, trasz
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23640
2020-02-15 18:48:38 +00:00
Dimitry Andric
ceba62b93d Fix the following -Werror warning from clang 10.0.0 in hptmv(4):
sys/dev/hptmv/ioctl.c:240:4: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
                        _vbus_p=pArray->pVBus;
                        ^
sys/dev/hptmv/ioctl.c:237:10: note: previous statement is here
                if(!mIsArray(pArray))
                ^

This is because the return statement after the if statement was not
indented.  (Note that this file has been idented assuming 4-space tabs.)

MFC after:	3 days
2020-02-15 18:37:26 +00:00
Warner Losh
3750f5ff89 The KASSERT is too strict: revert r357897
It's valid for a periph to be removed with outstanding transactions on the
device. In CAM, multiple periphs attach to a single device. There's no interlock
to prevent one of these going away while other periphs have outstanding CCBs and
it's not an error either. Remove this overly agressive KASSERT to prevent
false-positive panics when devices depart.
2020-02-15 18:14:23 +00:00
Mateusz Guzik
074ad60a4c vfs: make write suspension mandatory
At the time opt-in was introduced adding yourself as a writer was esrializing
across the mount point. Nowadays it is fully per-cpu, the only impact being
a small single-threaded hit on top of what's there right now.

Vast majority of the overhead stems from the call to VOP_GETWRITEMOUNT which
has is done regardless.

Should someone want to microoptimize this single-threaded they can coalesce
looking the mount up with adding a write to it.
2020-02-15 13:00:39 +00:00
Jung-uk Kim
ec0234b4c2 MFV: r357927
Merge ACPICA 20200214.
2020-02-15 03:47:25 +00:00
Mateusz Guzik
eb40664d83 capsicum: use new helpers 2020-02-15 01:30:27 +00:00
Mateusz Guzik
445faddf7f kqueue: use new capsicum helpers 2020-02-15 01:30:13 +00:00
Mateusz Guzik
5af9cdaf8a cloudabi: use new capsicum helpers 2020-02-15 01:29:58 +00:00
Mateusz Guzik
6b25673f3f sctp: use new capsicum helpers 2020-02-15 01:29:40 +00:00
Mateusz Guzik
3379d2f926 vm: use new capsicum helpers 2020-02-15 01:29:07 +00:00
Mateusz Guzik
32a86c44ee fd: use new capsicum helpers 2020-02-15 01:28:55 +00:00
Mateusz Guzik
e126c5a3e8 vfs: use new capsicum helpers 2020-02-15 01:28:42 +00:00
Mateusz Guzik
fad5873462 capsicum: add cap_rights_init_zero, cap_rights_init_one, cap_rights_set_one
... which allow the compiler to generate relevant code in place without
resorting to calling to a routine at runtime.
2020-02-15 01:28:06 +00:00
Konstantin Belousov
6cf2362e2c Consolidate read code for timecounters and fix possible overflow in
bintime()/binuptime().

The algorithm to read the consistent snapshot of current timehand is
repeated in each accessor, including the details proper rollup
detection and synchronization with the writer.  In fact there are only
two different kind of readers: one for bintime()/binuptime() which has
to do the in-place calculation, and another kind which fetches some
member from struct timehand.

Extract the logic into type-checked macros, GETTHBINTIME() for bintime
calculation, and GETTHMEMBER() for safe read of a structure' member.
This way, the synchronization is only written in bintime_off() and
getthmember().

In bintime_off(), use overflow-safe calculation of th_scale *
delta(timecounter).  In tc_windup, pre-calculate the min delta value
which overflows and require slow algorithm, into the new timehands
th_large_delta member.

This part with overflow fix was written by Bruce Evans.

Reported by:	Mark Millard <marklmi@yahoo.com> (the overflow issue)
Tested by:	pho
Discussed with:	emaste
Sponsored by:	The FreeBSD Foundation (kib)
MFC after:	3 weeks
2020-02-14 23:27:45 +00:00
Mateusz Guzik
df0d5a2a85 vfs: remove no longer needed atomic_load_ptr casts 2020-02-14 23:18:32 +00:00
Mateusz Guzik
8f86349f8b fd: remove no longer needed atomic_load_ptr casts 2020-02-14 23:18:22 +00:00
Mateusz Guzik
5bc6a91f54 kcov: remove no longer needed atomic_load_ptr casts 2020-02-14 23:18:03 +00:00
Mateusz Guzik
4ef55e371a i386: remove no longer needed atomic_load_ptr casts 2020-02-14 23:17:37 +00:00
Mateusz Guzik
f50a2474b7 arm64: remove no longer needed atomic_load_ptr casts 2020-02-14 23:17:18 +00:00
Mateusz Guzik
a201ef9d82 amd64: remove no longer needed atomic_load_ptr casts 2020-02-14 23:17:03 +00:00
Mateusz Guzik
23ed568caa vm: remove no longer needed atomic_load_ptr casts 2020-02-14 23:16:29 +00:00
Mateusz Guzik
082a6b2a92 Make atomic_load_ptr type-aware
Returned value has type based on the argument, meaning consumers no longer
have to cast in the commmon case.

This commit keeps the kernel compilable without patching the rest.
2020-02-14 23:15:41 +00:00
Kyle Evans
1881ae23a3 mips: fix kernel build after r357804
Drop the padding down the size of a single uintptr_t to account for
pc_zpcpu_offset
2020-02-14 20:25:04 +00:00
Pawel Biernacki
96592b7a07 sysctl(9): properly use xor in ENFORCE_FLAGS macro
Assert on not specifying any of the (soon to be) required flags as well
 as specifying both of them.

Pointed out by:	cem, hselasky
Reviewed by:	hselasky, kib
Approved by:	kib (mentor)
Differential Revision:	https://reviews.freebsd.org/D23678
2020-02-14 16:56:59 +00:00
Alexander Motin
0d9cef0a94 Add support for Hygon NTB PCI device in ntb_hw_amd driver.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23565
2020-02-14 15:04:56 +00:00
Alexander Motin
a6da07a319 Add Hygon PCI ID and description for AHCI SATA controller.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D23556
2020-02-14 14:55:40 +00:00
Mateusz Guzik
ed8cd4795c amd64: only check for error != 0 in the inlined part of l1d flush check
this replaces the following near the syscall exit:
cmp    $0x39,%rax
ja     0xffffffff8108f82c
movabs $0x200001800060005,%rcx
bt     %rax,%rcx
jae    0xffffffff8108f82c

with:
test   %edi,%edi
jne    0xffffffff8091a49c
2020-02-14 13:14:19 +00:00
Mateusz Guzik
2f7292437d Merge audit and systrace checks
This further shortens the syscall routine by not having to re-check after
the system call.
2020-02-14 13:09:41 +00:00
Mateusz Guzik
0e84a878c0 Annotate branches in the syscall path
This in particular significantly shortens amd64_syscall, which otherwise
keeps jumping forward over 2KB of code in total.

Note some of these branches should be either eliminated altogether or
coalesced.
2020-02-14 13:08:46 +00:00
Mateusz Guzik
ba8dd40bb1 lockmgr: add a change missed in r357907 2020-02-14 11:56:50 +00:00
Mateusz Guzik
6ed30ea4c0 fd: annotate finstall with prediction branches 2020-02-14 11:22:12 +00:00
Mateusz Guzik
c1b57fa7d3 lockmgr: rename lock_fast_path to lock_flags
The routine is not much of a fast path and the flags name better describes
its purpose.
2020-02-14 11:21:28 +00:00
Mateusz Guzik
943c4932f3 lockmgr: retire the unused lockmgr_unlock_fast_path routine 2020-02-14 11:20:25 +00:00
Kyle Evans
0f5f49eff7 u_char -> vm_prot_t in a couple of places, NFC
The latter is a typedef of the former; the typedef exists and these bits are
representing vmprot values, so use the correct type.

Submitted by:	sigsys@gmail.com
MFC after:	3 days
2020-02-14 02:22:08 +00:00
Hans Petter Selasky
144d6690b5 Exclude modifier keys from keyboard repeat logic.
This restores USB keyboard driver behaviour prior to r357861.

Requested by:	jkim@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-02-14 00:29:21 +00:00
Warner Losh
2100c6d00f Add a KASSERT that there's no outstanding CCBs when we call camperiphfree. We
know that if there are any outstanding CCBs, then when they dereference the path
that's freed at the bottom of camperiphfree there will be some flavor of
panic. This moves that eventual panic to a traceback of when we free the last
reference on the device, which is earlier but may not be early enough.
2020-02-14 00:13:23 +00:00
Warner Losh
1f4fa9156d xpt_release_simq_timeout is unused. Remove it. 2020-02-14 00:12:59 +00:00