Commit graph

131165 commits

Author SHA1 Message Date
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
Mark Johnston 06ef60525f 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
2020-02-13 23:18:35 +00:00
Mark Johnston cefc92e1a2 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
2020-02-13 23:15:21 +00:00
John Baldwin ff8c6681c8 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
2020-02-13 23:04:11 +00:00
John Baldwin ca3b3c573e 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
2020-02-13 22:55:45 +00:00
Mateusz Guzik 6ebab6bad2 vfs: use mac fastpath for lookup, open, read, write, mmap 2020-02-13 22:22:55 +00:00
Mateusz Guzik 7b2ff0dcb2 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.
2020-02-13 22:22:15 +00:00
Mateusz Guzik 91061084d1 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.
2020-02-13 22:19:17 +00:00
Mateusz Guzik e6081fe899 Inline jailed().
It is constantly called from priv_check.
2020-02-13 22:16:30 +00:00
Mateusz Guzik 8bdcfb10d3 Annotate suser_enabled as __read_mostly
It is read a lot in priv code.
2020-02-13 22:16:02 +00:00
Jeff Roberson 1f2a6b8501 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
2020-02-13 21:10:17 +00:00
Jeff Roberson 543117bed8 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
2020-02-13 20:58:51 +00:00
Jeff Roberson a4d50e49da Add more precise SMR entry asserts. 2020-02-13 20:50:21 +00:00
Dimitry Andric f750d0d60d 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
2020-02-13 19:29:57 +00:00
Dimitry Andric bc7d20c424 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.
2020-02-13 19:25:49 +00:00
Konstantin Belousov 4e012582d3 hyperv: Add Hygon Dhyana support.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23563
2020-02-13 19:12:07 +00:00
Konstantin Belousov 100eced555 ecc_inject: Add Hygon Dhyana support.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23561
2020-02-13 19:10:51 +00:00
Konstantin Belousov decf9c5ff6 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
2020-02-13 19:09:24 +00:00
Konstantin Belousov 4afea6b4e0 amdpm: Add Hygon Dhyana support.
Submitted by:	Pu Wen <puwen@hygon.cn>
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D23557
2020-02-13 19:07:42 +00:00
Konstantin Belousov caab504277 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
2020-02-13 19:03:12 +00:00
Hans Petter Selasky d4028678f2 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
2020-02-13 16:03:12 +00:00
Michael Tuexen a357466592 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
2020-02-13 15:14:46 +00:00
Michael Tuexen 33f8cfdfe4 Whitespace cleanup. No functional change.
Sponsored by:		Netflix, Inc.
2020-02-13 13:58:34 +00:00
Warner Losh efb17c5a54 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@
2020-02-13 03:37:11 +00:00
Warner Losh 0c8ea9e567 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
2020-02-13 01:23:44 +00:00
Warner Losh a8d238cd6d Export the current da flags as bitfield
Export the current flags. They can be useful to other programs wanting to do
special thigns for removable or similar devices.

Differential Revision: https://reviews.freebsd.org/D23417
2020-02-13 01:23:32 +00:00
Mateusz Guzik 9fd552ada1 netipsec: fix a mismatched uma_zfree -> uma_zfree_pcpu
PR:		244077
Reported by:	lwhsu
Fixes: r357805 ("amd64: store per-cpu allocations subtracted by __pcpu")
2020-02-12 20:18:29 +00:00
Kyle Evans b30ab6d8fe sys/kern sysent: re-add dependency on capabilities.conf
r356868 inadvertently removed this, so changes to capabilities.conf were no
longer considered for being outdated.
2020-02-12 19:06:34 +00:00
Ed Maste fe16bad415 regen sysent after r357831, r357838
Capability mode changes allowing fdatasync and getloginclass.

Sponsored by:	The FreeBSD Foundation
2020-02-12 19:05:10 +00:00
Ed Maste e953765f15 Allow getloginclass in capability mode
As with e.g. getgroups and getlogin it allows querying current process
credential state.

Reported by:	sigsys@gmail.com via kevans
Sponsored by:	The FreeBSD Foundation
2020-02-12 18:59:00 +00:00
Ed Maste 9cdfb2d69a Allow fdatasync in capability mode
fdatasync is essentially a subset of fsync (and may be exactly fsync,
depending on filesystem and development effort) and operates only on
a provided fd.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-02-12 17:12:26 +00:00
Michael Tuexen 56ccb48fd6 Don't panic under INVARIANTS when we can't allocate memory for storing
a vtag in time wait.
This issue was found by running syzkaller.

MFC after:		1 week
2020-02-12 17:05:10 +00:00
Michael Tuexen ca3de626ec Mark the socket as disconnected when freeing the association the first
time.
This issue was found by running syzkaller.

MFC after:		1 week
2020-02-12 17:02:15 +00:00
Randall Stewart 348404bce1 Lets get the real correct version.. gessh. I need
more coffee evidently.

Sponsored by:	Netflix
2020-02-12 15:26:56 +00:00
Mitchell Horne 9ce0b407c2 Implement vm.pmap.kernel_maps for RISC-V
This is taken from the arm64 version, with the following simplifications:

- Our current pmap implementation uses a 3-level paging scheme
- The "mode" field has been omitted since RISC-V PTEs don't encode
  typical mode attributes

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D23594
2020-02-12 14:06:02 +00:00