]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoAdd pthread_peekjoin_np(3).
kib [Sat, 15 Feb 2020 23:25:39 +0000 (23:25 +0000)]
Add pthread_peekjoin_np(3).

The function allows to peek at the thread exit status and even see
return value, without joining (and thus finally destroying) the target
thread.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation (kib)
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D23676

4 years agosem_remove(): fix the loop that compacts sem array on semaphores removal.
kib [Sat, 15 Feb 2020 23:19:23 +0000 (23:19 +0000)]
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

4 years agosem_remove(): add some asserts.
kib [Sat, 15 Feb 2020 23:18:02 +0000 (23:18 +0000)]
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

4 years agoUse designated initializers for seminfo.
kib [Sat, 15 Feb 2020 23:15:42 +0000 (23:15 +0000)]
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

4 years agoufs: use faster lockgmr entry points in ffs_lock
mjg [Sat, 15 Feb 2020 21:48:48 +0000 (21:48 +0000)]
ufs: use faster lockgmr entry points in ffs_lock

4 years agocommitters-ports.dot: add myself as a ports committer
kevans [Sat, 15 Feb 2020 21:21:13 +0000 (21:21 +0000)]
committers-ports.dot: add myself as a ports committer

4 years agofetch(3): don't leak sockshost on failure
kevans [Sat, 15 Feb 2020 19:47:49 +0000 (19:47 +0000)]
fetch(3): don't leak sockshost on failure

fetch_socks5_getenv will allocate memory for the host (or set it to NULL) in
all cases through the function; the caller is responsible for freeing it if
we end up allocating.

While I'm here, I've eliminated a label that just jumps to the next line...

4 years agofetch(3): fix regression in IPv6:port spec from r357977
kevans [Sat, 15 Feb 2020 19:39:50 +0000 (19:39 +0000)]
fetch(3): fix regression in IPv6:port spec from r357977

In case the port was specified, we never actually populated *host. Do so
now.

Pointy hat: kevans

4 years agofetch(3): move bits of fetch_socks5_getenv around
kevans [Sat, 15 Feb 2020 19:31:40 +0000 (19:31 +0000)]
fetch(3): move bits of fetch_socks5_getenv around

This commit separates out port parsing and validation from grabbing the host
from the env var. The only related bit really is that we need to be more
specific with the delimiter in the IPv6 case.

4 years agoMerge r357970 from the clang1000-import branch:
dim [Sat, 15 Feb 2020 19:15:24 +0000 (19:15 +0000)]
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

4 years agorandom(6): Re-add undocumented support for floating point denominators
cem [Sat, 15 Feb 2020 19:13:37 +0000 (19:13 +0000)]
random(6): Re-add undocumented support for floating point denominators

And document it in the manual page.

PR: 244139
Submitted by: Keith White <kwhite AT site.uottawa.ca> (earlier version)

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (4 of many)
kaktus [Sat, 15 Feb 2020 18:57:49 +0000 (18:57 +0000)]
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

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
kaktus [Sat, 15 Feb 2020 18:54:59 +0000 (18:54 +0000)]
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

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (2 of many)
kaktus [Sat, 15 Feb 2020 18:52:12 +0000 (18:52 +0000)]
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

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (1 of many)
kaktus [Sat, 15 Feb 2020 18:48:38 +0000 (18:48 +0000)]
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

4 years agoThe KASSERT is too strict: revert r357897
imp [Sat, 15 Feb 2020 18:14:23 +0000 (18:14 +0000)]
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.

4 years agofetch(3): Add SOCKS5 support
kevans [Sat, 15 Feb 2020 18:03:16 +0000 (18:03 +0000)]
fetch(3): Add SOCKS5 support

This change adds SOCKS5 support to the library fetch(3) and updates the man
page.

Details: Within the fetch_connect() function, fetch(3) checks if the
SOCKS5_PROXY environment variable is set. If so, it connects to this host
rather than the end-host. It then initializes the SOCKS5 connection in
accordance with RFC 1928 and returns the resulting conn_t (file descriptor)
for usage by the regular FTP/HTTP handlers.

Design Decision: This change defaults all DNS resolutions through the proxy
by sending all IPs as hostnames. Going forward, another feature might be to
create another environmental variable to toggle resolutions through the
proxy or not..

One may set the SOCKS5_PROXY environment variable in any of the formats:

SOCKS5_PROXY=proxy.example.com
SOCKS5_PROXY=proxy.example.com:1080
SOCKS5_PROXY=192.0.2.0
SOCKS5_PROXY=198.51.100.0:1080
SOCKS5_PROXY=[2001:db8::1]
SOCKS5_PROXY=[2001:db8::2]:1080

Then perform a request with fetch(1).

(note by kevans)
I've since been informed that Void Linux/xbps has a fork of libfetch that
also implements SOCKS5. I may compare/contrast the two in the mid-to-near
future.

Submitted by: Farhan Khan <farhan farhan codes>
Differential Revision: https://reviews.freebsd.org/D18908

4 years agoMake ping6(1) return code consistent with the man page.
melifaro [Sat, 15 Feb 2020 15:39:53 +0000 (15:39 +0000)]
Make ping6(1) return code consistent with the man page.
 When every sendto() call originated by ping6(1) fails, current code always
 returns 2 ("transmission was successful but no responses were received")
 which is incorrect. Return EX_OSERR instead as in many cases it indicates
 some kernel-level problems.

MFC after: 3 weeks

4 years agovfs: make write suspension mandatory
mjg [Sat, 15 Feb 2020 13:00:39 +0000 (13:00 +0000)]
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.

4 years agoMFV: r357927
jkim [Sat, 15 Feb 2020 03:47:25 +0000 (03:47 +0000)]
MFV: r357927

Merge ACPICA 20200214.

4 years agocapsicum: use new helpers
mjg [Sat, 15 Feb 2020 01:30:27 +0000 (01:30 +0000)]
capsicum: use new helpers

4 years agokqueue: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:30:13 +0000 (01:30 +0000)]
kqueue: use new capsicum helpers

4 years agocloudabi: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:29:58 +0000 (01:29 +0000)]
cloudabi: use new capsicum helpers

4 years agosctp: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:29:40 +0000 (01:29 +0000)]
sctp: use new capsicum helpers

4 years agovm: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:29:07 +0000 (01:29 +0000)]
vm: use new capsicum helpers

4 years agofd: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:28:55 +0000 (01:28 +0000)]
fd: use new capsicum helpers

4 years agovfs: use new capsicum helpers
mjg [Sat, 15 Feb 2020 01:28:42 +0000 (01:28 +0000)]
vfs: use new capsicum helpers

4 years agocapsicum: add cap_rights_init_zero, cap_rights_init_one, cap_rights_set_one
mjg [Sat, 15 Feb 2020 01:28:06 +0000 (01:28 +0000)]
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.

4 years agoConsolidate read code for timecounters and fix possible overflow in
kib [Fri, 14 Feb 2020 23:27:45 +0000 (23:27 +0000)]
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

4 years agovfs: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:18:32 +0000 (23:18 +0000)]
vfs: remove no longer needed atomic_load_ptr casts

4 years agofd: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:18:22 +0000 (23:18 +0000)]
fd: remove no longer needed atomic_load_ptr casts

4 years agokcov: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:18:03 +0000 (23:18 +0000)]
kcov: remove no longer needed atomic_load_ptr casts

4 years agoi386: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:17:37 +0000 (23:17 +0000)]
i386: remove no longer needed atomic_load_ptr casts

4 years agoarm64: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:17:18 +0000 (23:17 +0000)]
arm64: remove no longer needed atomic_load_ptr casts

4 years agoamd64: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:17:03 +0000 (23:17 +0000)]
amd64: remove no longer needed atomic_load_ptr casts

4 years agovm: remove no longer needed atomic_load_ptr casts
mjg [Fri, 14 Feb 2020 23:16:29 +0000 (23:16 +0000)]
vm: remove no longer needed atomic_load_ptr casts

4 years agoMake atomic_load_ptr type-aware
mjg [Fri, 14 Feb 2020 23:15:41 +0000 (23:15 +0000)]
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.

4 years agoUpdate version in openssh FREEBSD-vendor metadata
emaste [Fri, 14 Feb 2020 22:32:33 +0000 (22:32 +0000)]
Update version in openssh FREEBSD-vendor metadata

It appears that FREEBSD-vendor is an idea that never really took off
and we should probably just remove it, but until then we might as well
record the correct version.

4 years agomips: fix kernel build after r357804
kevans [Fri, 14 Feb 2020 20:25:04 +0000 (20:25 +0000)]
mips: fix kernel build after r357804

Drop the padding down the size of a single uintptr_t to account for
pc_zpcpu_offset

4 years agoUpdate OpenSSH upgrade instructions to use https, not ftp
emaste [Fri, 14 Feb 2020 19:33:50 +0000 (19:33 +0000)]
Update OpenSSH upgrade instructions to use https, not ftp

ftp://ftp.openbsd.org/ does not work.

4 years agoRemove /usr/include/ssp from BSD.include.dist after r356356
dim [Fri, 14 Feb 2020 19:31:24 +0000 (19:31 +0000)]
Remove /usr/include/ssp from BSD.include.dist after r356356

This avoids having to delete it every time with "make delete-old".

PR: 242950
MFC after: 2 weeks
X-MFC-With: r356356

4 years agoUpgrade to OpenSSH 7.9p1.
emaste [Fri, 14 Feb 2020 19:06:59 +0000 (19:06 +0000)]
Upgrade to OpenSSH 7.9p1.

MFC after: 2 months
Sponsored by: The FreeBSD Foundation

4 years agosshd: add upgrade process note about TCP wrappers
emaste [Fri, 14 Feb 2020 18:59:50 +0000 (18:59 +0000)]
sshd: add upgrade process note about TCP wrappers

We need to add user-facing deprecation notices for TCP wrappers; start
with a note in the upgrade process docmentation.

Sponsored by: The FreeBSD Foundation

4 years agodtc: re-apply r353961, r354115
kevans [Fri, 14 Feb 2020 18:50:03 +0000 (18:50 +0000)]
dtc: re-apply r353961, r354115

I missed in final review of r357923's diff that these ones hadn't yet been
sent upstream and inadvertently reverted them. =-( Re-apply now.

4 years agoPull in latest fixes from dtc, up to 0060471
kevans [Fri, 14 Feb 2020 18:46:34 +0000 (18:46 +0000)]
Pull in latest fixes from dtc, up to 0060471

This includes a small battery of /memreserve/ fixes to make sure dtc is
properly writing these regions into the output file and reading them back
out.

As of this update, dtc will now also assume common defaults for -I/-O if
only one is specified; namely, dts for one implies dtb for the other and
vice versa (Requested by: jhibbits, preserves GPL dtc behavior too).

MFC after: 1 week

4 years agoopenssh: add a note about libwrap in config.h
emaste [Fri, 14 Feb 2020 17:05:35 +0000 (17:05 +0000)]
openssh: add a note about libwrap in config.h

LIBWRAP is defined by the Makefile based on MK_TCP_WRAPPERS and should
not be defined in config.h.

PR: 210141
Sponsored by: The FreeBSD Foundation

4 years agosysctl(9): properly use xor in ENFORCE_FLAGS macro
kaktus [Fri, 14 Feb 2020 16:56:59 +0000 (16:56 +0000)]
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

4 years agoAdd support for Hygon NTB PCI device in ntb_hw_amd driver.
mav [Fri, 14 Feb 2020 15:04:56 +0000 (15:04 +0000)]
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

4 years agoAdd Hygon PCI ID and description for AHCI SATA controller.
mav [Fri, 14 Feb 2020 14:55:40 +0000 (14:55 +0000)]
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

4 years agocommitters-ports: add koobs@ information, somewhat belatedly
kevans [Fri, 14 Feb 2020 14:03:44 +0000 (14:03 +0000)]
committers-ports: add koobs@ information, somewhat belatedly

4 years agoamd64: only check for error != 0 in the inlined part of l1d flush check
mjg [Fri, 14 Feb 2020 13:14:19 +0000 (13:14 +0000)]
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

4 years agoMerge audit and systrace checks
mjg [Fri, 14 Feb 2020 13:09:41 +0000 (13:09 +0000)]
Merge audit and systrace checks

This further shortens the syscall routine by not having to re-check after
the system call.

4 years agoAnnotate branches in the syscall path
mjg [Fri, 14 Feb 2020 13:08:46 +0000 (13:08 +0000)]
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.

4 years agor357895: fix typo in the relocation name for i386 IRELATIVE.
kib [Fri, 14 Feb 2020 12:59:27 +0000 (12:59 +0000)]
r357895: fix typo in the relocation name for i386 IRELATIVE.

Reported by: antoine
Sponsored by: The FreeBSD Foundation
MFC after: 6 days

4 years agolockmgr: add a change missed in r357907
mjg [Fri, 14 Feb 2020 11:56:50 +0000 (11:56 +0000)]
lockmgr: add a change missed in r357907

4 years agofd: annotate finstall with prediction branches
mjg [Fri, 14 Feb 2020 11:22:12 +0000 (11:22 +0000)]
fd: annotate finstall with prediction branches

4 years agolockmgr: rename lock_fast_path to lock_flags
mjg [Fri, 14 Feb 2020 11:21:28 +0000 (11:21 +0000)]
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.

4 years agolockmgr: retire the unused lockmgr_unlock_fast_path routine
mjg [Fri, 14 Feb 2020 11:20:25 +0000 (11:20 +0000)]
lockmgr: retire the unused lockmgr_unlock_fast_path routine

4 years agoAdd basic IPDIVERT tests.
melifaro [Fri, 14 Feb 2020 09:36:35 +0000 (09:36 +0000)]
Add basic IPDIVERT tests.

Reviewed by: lwhsu,kp
Differential Revision: https://reviews.freebsd.org/D23316

4 years agoProperly fix GCC build in r357867
lwhsu [Fri, 14 Feb 2020 09:25:29 +0000 (09:25 +0000)]
Properly fix GCC build in r357867

Submitted by: kib
Sponsored by: The FreeBSD Foundation

4 years agoncurses: correct check for gcc >= 5.0
kevans [Fri, 14 Feb 2020 04:16:22 +0000 (04:16 +0000)]
ncurses: correct check for gcc >= 5.0

The hack in question is intended to workaround seemingly bogus #line markers
in cpp output. As far as I can tell, llvm cpp doesn't do this by default, so
there's no reason to add -P.

In our /bin/sh, the main incantation should be placed in a sub-shell in
order to properly pipe the output to fgrep.

The main motivation for this change is admittedly to stop emitting the noise
about clang not being gcc in make -s buildworld

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22952

4 years agou_char -> vm_prot_t in a couple of places, NFC
kevans [Fri, 14 Feb 2020 02:22:08 +0000 (02:22 +0000)]
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

4 years agoExclude modifier keys from keyboard repeat logic.
hselasky [Fri, 14 Feb 2020 00:29:21 +0000 (00:29 +0000)]
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

4 years agoAdd a KASSERT that there's no outstanding CCBs when we call camperiphfree. We
imp [Fri, 14 Feb 2020 00:13:23 +0000 (00:13 +0000)]
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.

4 years agoxpt_release_simq_timeout is unused. Remove it.
imp [Fri, 14 Feb 2020 00:12:59 +0000 (00:12 +0000)]
xpt_release_simq_timeout is unused. Remove it.

4 years agoHandle non-plt IRELATIVE relocations, at least for x86.
kib [Thu, 13 Feb 2020 23:42:09 +0000 (23:42 +0000)]
Handle non-plt IRELATIVE relocations, at least for x86.

lld 10.0 seems to generate this relocation for rdtsc_mb() ifunc in our libc.

Reported, reviewed, and tested by: dim (amd64, previous version)
Discussed with: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23652

4 years agoReturn success, instead of ESRCH, from pthread_cancel(3) applied to the
kib [Thu, 13 Feb 2020 23:22:12 +0000 (23:22 +0000)]
Return success, instead of ESRCH, from pthread_cancel(3) applied to the
exited but not yet joined thread.

Before, if the thread exited but was not yet joined, we returned
ESRCH.

According to IEEE Std 1003.1™-2017 recommendation in the
description of pthread_cancel(3):
  If an implementation detects use of a thread ID after the end of its
  lifetime, it is recommended that the function should fail and report
  an [ESRCH] error.
So it seems desirable to not return ESRCH until the lifetime of the
thread ID ends.  According to the section 2.9.2 Thread IDs,
  The lifetime of a thread ID ends after the thread terminates if it
  was created with the detachstate attribute set to
  PTHREAD_CREATE_DETACHED or if pthread_detach() or pthread_join()
  has been called for that thread.
In other words, lifetime for thread ID of exited but not yet joined thread
did not ended yet.

Prompted by: cperciva
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoFix handling of WAITFAIL in vm_page_grab() and vm_page_grab_pages().
markj [Thu, 13 Feb 2020 23:18:35 +0000 (23:18 +0000)]
Fix handling of WAITFAIL in vm_page_grab() and vm_page_grab_pages().

After sleeping through a memory shortage, we must return NULL rather
than retry.

Discussed with: jeff
Reported by: pho
Sponsored by: The FreeBSD Foundation

4 years agoUpdate the zone-global count of cached items in bucket_cache_reclaim().
markj [Thu, 13 Feb 2020 23:15:21 +0000 (23:15 +0000)]
Update the zone-global count of cached items in bucket_cache_reclaim().

This was missed in r351673.  The count is used to enfore cache limits,
which are rarely used.

Discussed with: jeff
Sponsored by: The FreeBSD Foundation

4 years agoDon't check the auth algorithm for GCM.
jhb [Thu, 13 Feb 2020 23:04:11 +0000 (23:04 +0000)]
Don't check the auth algorithm for GCM.

The upstream OpenSSL changes only set the cipher for GCM since the
authentication is redundant, and changes to OCF will soon remove the
GCM authentication algorithm constants entirely for the same reason.
In addition, ktls_create_session() already validates these fields and
wouldn't pass down an invalid auth_algorithm value to any drivers or
ktls backends.

Reviewed by: hselasky
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23671

4 years agoRemove the per-TXQ tls_wrs stat.
jhb [Thu, 13 Feb 2020 22:55:45 +0000 (22:55 +0000)]
Remove the per-TXQ tls_wrs stat.

It duplicated the kern_tls_records stat and was not conditional on NIC
TLS being enabled.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D23670

4 years agovfs: use mac fastpath for lookup, open, read, write, mmap
mjg [Thu, 13 Feb 2020 22:22:55 +0000 (22:22 +0000)]
vfs: use mac fastpath for lookup, open, read, write, mmap

4 years agoPartially decompose priv_check by adding priv_check_cred_vfs_generation
mjg [Thu, 13 Feb 2020 22:22:15 +0000 (22:22 +0000)]
Partially decompose priv_check by adding priv_check_cred_vfs_generation

During buildkernel there are very frequent calls to priv_check and they
all are for PRIV_VFS_GENERATION (coming from stat/fstat).

This results in branching on several potential privileges checking if
perhaps that's the one which has to be evaluated.

Instead of the kitchen-sink approach provide a way to have commonly used
privs directly evaluated.

4 years agomac: implement fast path for checks
mjg [Thu, 13 Feb 2020 22:19:17 +0000 (22:19 +0000)]
mac: implement fast path for checks

All checking routines walk a linked list of all modules in order to determine
if given hook is installed. This became a significant problem after mac_ntpd
started being loaded by default.

Implement a way perform checks for select hooks by testing a boolean.

Use it for priv_check and priv_grant, which are constantly called from priv_check.

The real fix would use hotpatching, but the above provides a way to know when
to do it.

4 years agoInline jailed().
mjg [Thu, 13 Feb 2020 22:16:30 +0000 (22:16 +0000)]
Inline jailed().

It is constantly called from priv_check.

4 years agoAnnotate suser_enabled as __read_mostly
mjg [Thu, 13 Feb 2020 22:16:02 +0000 (22:16 +0000)]
Annotate suser_enabled as __read_mostly

It is read a lot in priv code.

4 years agoSince r357804 pcpu zones are required to use zalloc_pcpu(). Prior to this
jeff [Thu, 13 Feb 2020 21:10:17 +0000 (21:10 +0000)]
Since r357804 pcpu zones are required to use zalloc_pcpu().  Prior to this
it was only required if you were zeroing.  Switch to these interfaces.

Reviewed by: mjg

4 years agoFix a case where ub_seq would fail to be set if the cross bucket was
jeff [Thu, 13 Feb 2020 20:58:51 +0000 (20:58 +0000)]
Fix a case where ub_seq would fail to be set if the cross bucket was
flushed due to memory pressure.

Reviewed by: markj
Differential Revision: http://reviews.freebsd.org/D23614

4 years agoAdd more precise SMR entry asserts.
jeff [Thu, 13 Feb 2020 20:50:21 +0000 (20:50 +0000)]
Add more precise SMR entry asserts.

4 years agodiff: fix segfault with --tabsize and no/malformed argument
kevans [Thu, 13 Feb 2020 20:23:55 +0000 (20:23 +0000)]
diff: fix segfault with --tabsize and no/malformed argument

--tabsize was previously listed as optional_argument, but didn't account for
the optionality of it in the argument handling. This is irrelevant -- the
manpage doesn't indicate that the argument is optional, and indeed there's
no clear interpretation of omitting the argument because there's no other
side effect of --tabsize.

The "malformed" argument part of the header on this message is simply
referring to usage like this:

% diff --tabsize 4 A B

With an optional_argument, the argument must be attached to the parameter
directly (e.g. --tabsize=4), so the argument is effectively NULL with the
above invocation as if no argument had been passed.

PR: 243974
Submitted by: fehmi noyan isi <fnoyanisi yahoo com> (diff.c portion)
MFC after: 3 days

4 years agoMerge r357872 from the clang1000-import branch:
dim [Thu, 13 Feb 2020 19:29:57 +0000 (19:29 +0000)]
Merge r357872 from the clang1000-import branch:

Disable new clang 10.0.0 warnings about misleading indentation in ce(4)
and cp(4).

These are false positives, since some of the driver source has been
deliberately obfuscated.

MFC after: 3 days

4 years agoMerge r357864 from the clang1000-import branch:
dim [Thu, 13 Feb 2020 19:28:30 +0000 (19:28 +0000)]
Merge r357864 from the clang1000-import branch:

Fix the following -Werror warning from clang 10.0.0 in sconfig:

sbin/sconfig/sconfig.c:909:5: error: misleading indentation; statement is not part of the previous 'else' [-Werror,-Wmisleading-indentation]
                                exit (-1);
                                ^
sbin/sconfig/sconfig.c:907:6: note: previous statement is here
                        } else
                          ^

The intent was to group the exit() call with the previous fprintf()
call.

MFC after: 3 days

4 years agohyperv: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:12:07 +0000 (19:12 +0000)]
hyperv: Add Hygon Dhyana support.

Submitted by: Pu Wen <puwen@hygon.cn>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23563

4 years agoecc_inject: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:10:51 +0000 (19:10 +0000)]
ecc_inject: Add Hygon Dhyana support.

Submitted by: Pu Wen <puwen@hygon.cn>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23561

4 years agoamdsbwd, intpm: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:09:24 +0000 (19:09 +0000)]
amdsbwd, intpm: Add Hygon Dhyana support.

Initialize the FCH SMBus controller for Hygon Dhyana CPU.
Set the vendor of the FCH description via the exact CPU vendor.

Submitted by: Pu Wen <puwen@hygon.cn>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23558

4 years agoamdpm: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:07:42 +0000 (19:07 +0000)]
amdpm: Add Hygon Dhyana support.

Submitted by: Pu Wen <puwen@hygon.cn>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23557

4 years agoFix GCC build.
lwhsu [Thu, 13 Feb 2020 19:05:19 +0000 (19:05 +0000)]
Fix GCC build.

Sponsored by: The FreeBSD Foundation

4 years agobhyve, bhyvectl: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:05:14 +0000 (19:05 +0000)]
bhyve, bhyvectl: Add Hygon Dhyana support.

Submitted by: Pu Wen <puwen@hygon.cn>
Reviewed by: jhb
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23554

4 years agovmm: Add Hygon Dhyana support.
kib [Thu, 13 Feb 2020 19:03:12 +0000 (19:03 +0000)]
vmm: Add Hygon Dhyana support.

Submitted by: Pu Wen <puwen@hygon.cn>
Discussed with: grehan
Reviewed by: jhb (previous version)
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D23553

4 years agoaddr2line: use stdbool.h header for bool
emaste [Thu, 13 Feb 2020 16:17:05 +0000 (16:17 +0000)]
addr2line: use stdbool.h header for bool

Presumably a bool definition is obtained via header contamination on
FreeBSD-CURRENT.  Found while trying to upstream FreeBSD addr2line
changes - the FreeBSD 11.2 CI build failed there.

Reported by: Cirrus-CI, upstream ELF Tool Chain
MFC with: r357844
Sponsored by: The FreeBSD Foundation

4 years agoImprove USB gaming keyboard support.
hselasky [Thu, 13 Feb 2020 16:03:12 +0000 (16:03 +0000)]
Improve USB gaming keyboard support.

Add support for decoding pressed keys as a bitmap. The keys in the
bitmap are described in the interface specific HID descriptor. Some
keyboards even have multiple input interfaces, only using the bitmap
method when the event array is full. That typically means when more
than seven keys are pressed simultaneously.

The internals of the USB keyboard driver have been slightly reworked
to keep track of all keys in a single bitmap having 256 bits. This
bitmap is then divided into blocks of 64-bits as an optimisation.

Simplify automatic key repeat logic, because only the last key pressed
can be repeated.

PR: 224592
PR: 233884
Tested by: Alex V. Petrov <alexvpetrov@gmail.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoRevert r357343:
pfg [Thu, 13 Feb 2020 15:42:14 +0000 (15:42 +0000)]
Revert r357343:
services: Add PROFInet and EtherCAT.

Both are admitedly very niche features and no known users exist currently.
I am doing a further review/update of the services file (see D23621) and
both of these are not likely to be considered.

4 years agosesutil: fix Coverity CIDs
asomers [Thu, 13 Feb 2020 15:28:56 +0000 (15:28 +0000)]
sesutil: fix Coverity CIDs

1411604: file descriptor leak
1411586: memory leaks, null dereference on ENOMEM

Reported by: Coverity Scan
Coverity CIDs: 14116041411586
Reviewed by: trasz
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D23651

4 years agosack_newdata and snd_recover hold the same value. Therefore, use only
tuexen [Thu, 13 Feb 2020 15:14:46 +0000 (15:14 +0000)]
sack_newdata and snd_recover hold the same value. Therefore, use only
a single instance: use snd_recover also where sack_newdata was used.

Submitted by: Richard Scheffenegger
Differential Revision: https://reviews.freebsd.org/D18811

4 years agotests: Enable net tests
kp [Thu, 13 Feb 2020 14:09:09 +0000 (14:09 +0000)]
tests: Enable net tests

We have a number of tests in the net subdirectory that were not executed. List
the net directory so we run those tests.

4 years agoWhitespace cleanup. No functional change.
tuexen [Thu, 13 Feb 2020 13:58:34 +0000 (13:58 +0000)]
Whitespace cleanup. No functional change.

Sponsored by: Netflix, Inc.

4 years agoCleanup gsched tool and geom_sched.so library after r356185.
dim [Thu, 13 Feb 2020 11:00:20 +0000 (11:00 +0000)]
Cleanup gsched tool and geom_sched.so library after r356185.

4 years agoUse INT instead of string for the ints. Because the string "I" was right, the
imp [Thu, 13 Feb 2020 03:37:11 +0000 (03:37 +0000)]
Use INT instead of string for the ints. Because the string "I" was right, the
old code appeared to work. This was a cut and paste error.

Noticed by: rpokala@

4 years agoAdd myself (freqlabs) as a src committer
freqlabs [Thu, 13 Feb 2020 01:42:13 +0000 (01:42 +0000)]
Add myself (freqlabs) as a src committer

Approved by: mav (mentor)
MFC after: 3 days

4 years agoConvert rotating and unmapped_io to a DA flag
imp [Thu, 13 Feb 2020 01:23:44 +0000 (01:23 +0000)]
Convert rotating and unmapped_io to a DA flag

Rotating and unmapped_io are really da flags. Convert them to a flag so it will
be reported with the other flags for the device. Deprecate the .rotating and
.unmapped_io sysctls in FreeBSD 14 and remove the softc ints.

Differential Revision: https://reviews.freebsd.org/D23417