]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agopvclock: Add 'struct pvclock' API
Adam Fenn [Sat, 7 Aug 2021 20:01:46 +0000 (13:01 -0700)]
pvclock: Add 'struct pvclock' API

Consolidate more hypervisor-agnostic functionality behind a new 'struct
pvclock' API.

This should also make it easier to subsequently add hypervisor-agnostic
vDSO timekeeping support.

Also, perform some clean-up:
    - Remove 'pvclock_get_last_cycles()'; do not allow external access
      to 'pvclock_last_systime' since this is not necessary.
    - Consolidate/simplify wall and system time reading codepaths.
    - Ensure correct ordering within wall and system time reading
      codepaths via 'atomic(9)' and 'rdtsc_ordered()' rather than via
      'rmb()'.
    - Remove some extra newlines.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31418

2 years agox86: files: Make sys/x86/x86/pvclock.c optional
Adam Fenn [Wed, 4 Aug 2021 15:10:43 +0000 (08:10 -0700)]
x86: files: Make sys/x86/x86/pvclock.c optional

Make inclusion of `sys/x86/x86/pvclock.c` contingent on that of its
dependents.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D31417

2 years agox86: cpufunc: Add rdtsc_ordered()
Adam Fenn [Wed, 28 Jul 2021 17:12:00 +0000 (10:12 -0700)]
x86: cpufunc: Add rdtsc_ordered()

Add a variant of 'rdtsc()' that performs the ordered version of 'rdtsc'
appropriate for the invoking x86 variant.

Also, expose the 'lfence'-ed and 'mfence'-ed 'rdtsc()' variants needed
by 'rdtsc_ordered()' for general use.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31416

2 years agox86: cpufunc: Add rdtscp_aux()
Adam Fenn [Mon, 26 Jul 2021 19:59:55 +0000 (12:59 -0700)]
x86: cpufunc: Add rdtscp_aux()

Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX'
value read by 'rdtscp'.

Sponsored By: Juniper Networks, Inc.
Sponsored By: Klara, Inc.
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D31415

2 years agomd5(1): Fix a typo in the manual page
Gordon Bergling [Sat, 14 Aug 2021 12:48:39 +0000 (14:48 +0200)]
md5(1): Fix a typo in the manual page

- s/compatibilty/compatibility/

MFC after: 5 days

2 years agoFix a typo that was introduced while fixing a typo
Gordon Bergling [Sat, 14 Aug 2021 12:30:59 +0000 (14:30 +0200)]
Fix a typo that was introduced while fixing a typo

- s/enrtry/entry/

MFC after: 5 days

2 years agoFix a common typo in source code comments
Gordon Bergling [Sat, 14 Aug 2021 12:17:48 +0000 (14:17 +0200)]
Fix a common typo in source code comments

- s/aligment/alignment/

MFC after: 5 days

2 years agoFix a common typo in source code comments
Gordon Bergling [Sat, 14 Aug 2021 12:08:46 +0000 (14:08 +0200)]
Fix a common typo in source code comments

- s/definitons/definitions/

MFC after: 5 days

2 years agoAdd test for fstatat(pipefd, AT_EMPTY_PATH)
Konstantin Belousov [Sat, 14 Aug 2021 10:33:18 +0000 (13:33 +0300)]
Add test for fstatat(pipefd, AT_EMPTY_PATH)

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoFix a common typo in a comment
Gordon Bergling [Sat, 14 Aug 2021 11:29:51 +0000 (13:29 +0200)]
Fix a common typo in a comment

- s/enrty/entry/

MFC after: 5 days

2 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 08:08:49 +0000 (10:08 +0200)]
Fix a few typos in source code comments

- s/procesing/processing/

MFC after: 5 days

2 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 07:39:17 +0000 (09:39 +0200)]
Fix a few typos in source code comments

- s/posbile/possible/

MFC after: 5 days

2 years agoFix a few typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 07:06:09 +0000 (09:06 +0200)]
Fix a few typos in source code comments

- s/becase/because/

MFC after: 5 days

2 years agoFix some common typos in source code comments
Gordon Bergling [Sat, 14 Aug 2021 06:55:58 +0000 (08:55 +0200)]
Fix some common typos in source code comments

- s/struture/structure/
- s/structre/structure/

MFC after: 5 days

2 years agoaio: revert the workaround for bug 251828 in the tests
Alan Somers [Fri, 13 Aug 2021 22:59:10 +0000 (16:59 -0600)]
aio: revert the workaround for bug 251828 in the tests

This bug is no longer reproducible in 14.0-CURRENT and 13.0-RELEASE

Do not MFC to stable/12 !

PR: 251828
Reported by: markj
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D31535

2 years agofstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH
Konstantin Belousov [Fri, 13 Aug 2021 17:40:10 +0000 (20:40 +0300)]
fstatat(2): handle non-vnode file descriptors for AT_EMPTY_PATH

Set NIRES_EMPTYPATH earlies, to have use of EMPTYPATH recorded even if
we are going to return error.  When namei_setup() refused to accept dirfd,
which is not of the vnode type, and indicated by ENOTDIR error return,
fall back to kern_fstat(dirfd).

Reported by: dchagin
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31530

2 years agomgb: update Microchip URLs
Ed Maste [Fri, 13 Aug 2021 20:57:04 +0000 (16:57 -0400)]
mgb: update Microchip URLs

Sponsored by: The FreeBSD Foundation

2 years agoar: remove duplicate function declaration in header
Ed Maste [Fri, 13 Aug 2021 19:36:13 +0000 (15:36 -0400)]
ar: remove duplicate function declaration in header

Sponsored by: The FreeBSD Foundation

2 years agoar: diff reduction against ELF Tool Chain
Ed Maste [Fri, 13 Aug 2021 15:17:24 +0000 (11:17 -0400)]
ar: diff reduction against ELF Tool Chain

Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive
directly.

(This was originally committed in d20e9e02db3d but reverted due to a
regression, now fixed with an update from cy@.)

Obtained from: ELF Tool Chain
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31496

2 years agoufs rename: ensure that the result of ufs_checkpath() is stable
Konstantin Belousov [Fri, 6 Aug 2021 01:03:19 +0000 (04:03 +0300)]
ufs rename: ensure that the result of ufs_checkpath() is stable

ufs_rename() calls ufs_checkpath() to ensure that the target directory
is not a child of the source.  If not, rename would create a loop.
For instance:
source->X1->X2->target
and if source moved under target, we get corrupted filesystem.
Suppose that we initially have
source->X1 .... and X2->target
where X1 is not on path from root to X2.  Then ufs_checkpath() accepts
the inodes, but there is nothing preventing parallel rename of X2 to become
under X1, after checkpath finished.

Ensure stability of ufs_checkpath() result by taking a per-mount sx in
ufs_rename right before ufs_checkpath() and till the end.

Reviewed by: chs, mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

2 years agoStyle: wrap the long line, definition of ufs_checkpath()
Konstantin Belousov [Sun, 1 Aug 2021 17:56:33 +0000 (20:56 +0300)]
Style: wrap the long line, definition of ufs_checkpath()

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoar: diff reduction against ELF Tool Chain
Ed Maste [Thu, 12 Aug 2021 19:37:25 +0000 (15:37 -0400)]
ar: diff reduction against ELF Tool Chain

Drop exit status from bsdar_errc.  ELF Tool Chain always returns
EXIT_FAILURE in bsdar_errc.

Recommit of one part of d20e9e02db3d / review D31496.

Obtained from: ELF Tool Chain
Sponsored by: The FreeBSD Foundation

2 years agoarc4random: Avoid KMSAN false positives from pre-seeding results
Mark Johnston [Fri, 13 Aug 2021 13:52:05 +0000 (09:52 -0400)]
arc4random: Avoid KMSAN false positives from pre-seeding results

If code calls arc4random(), and our RNG is not yet seeded and
random_bypass_before_seeding is true, we'll compute a key using the
SHA256 hash of some hopefully hard-to-predict data, including the
contents of an uninitialized stack buffer (which is also the output
buffer).

When KMSAN is enabled, this use of uninitialized state propagtes through
to the arc4random() output, resulting in false positives.  To address
this, lie to KMSAN and explicitly mark the buffer as initialized.

Reviewed by: cem (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31510

2 years agong_bridge: Use M_NOWAIT when allocating memory in the newhook routine
Mark Johnston [Fri, 13 Aug 2021 13:49:43 +0000 (09:49 -0400)]
ng_bridge: Use M_NOWAIT when allocating memory in the newhook routine

newhook can be invoked by ngthread, which runs in a network epoch
section and is thus not permitted to perform M_WAITOK allocations.

Reported by: Jenkins
Reviewed by: donner, afedorov
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31486

2 years agoipsec: fix race condition in key.c
Wojciech Macek [Fri, 13 Aug 2021 10:52:38 +0000 (12:52 +0200)]
ipsec: fix race condition in key.c

Small patch that fixes a race condition in sys/netipsec/key.c

Obtained from: Stormshield
Differential revision: https://reviews.freebsd.org/D31271

2 years agortld: Round down relro_size
Konstantin Belousov [Thu, 12 Aug 2021 02:45:15 +0000 (05:45 +0300)]
rtld: Round down relro_size

lld rounds up p_memsz(PT_GNU_RELRO) to satisfy common-page-size. If the
page size is smaller than common-page-size, rounding up relro_size may
incorrectly make some RW pages read-only.

GNU ld, gold, and ld.lld ensures p_vaddr+p_memsz is a multiple of
common-page-size. While max-page-size >= system the page size,
common-page-size can be smaller than the system page size.

Submitted by: MaskRay
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31498

2 years agousr.bin/ghä-bc, contrib/bc: update to version 5.0.0
Stefan Eßer [Tue, 10 Aug 2021 08:42:54 +0000 (10:42 +0200)]
usr.bin/ghä-bc, contrib/bc: update to version 5.0.0

Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4

This is a new major release with a number of changes and extensions:

- Limited the number of temporary numbers and made the space for them
  static so that allocating more space for them cannot fail.
- Allowed integers with non-zero scale to be used with power, places,
  and shift operators.
- Added greatest common divisor and least common multiple to lib2.bc.
- Made bc and dc UTF-8 capable.
- Added the ability for users to have bc and dc quit on SIGINT.
- Added the ability for users to disable prompt and TTY mode by
  environment variables.
- Added the ability for users to redefine keywords.
- Added dc's modular exponentiation and divmod to bc.
- Added the ability to assign strings to variables and array elements
  and pass them to functions in bc.
- Added dc's asciify command and stream printing to bc.
- Added bitwise and, or, xor, left shift, right shift, reverse,
  left rotate, right rotate, and mod functions to lib2.bc.
- Added the functions s2u(x) and s2un(x,n), to lib2.bc.

MFC after: 1 week

2 years agomroute: fix locking issues
Wojciech Macek [Wed, 11 Aug 2021 07:04:20 +0000 (09:04 +0200)]
mroute: fix locking issues

In some cases the code may fall into deadlock.
Avoid calling epoch_wait when W-lock is taken.

Sponsored by: Stormshield
Obtained from: Semihalf

2 years agolinux(4): Improve comment.
Dmitry Chagin [Fri, 13 Aug 2021 08:36:42 +0000 (11:36 +0300)]
linux(4): Improve comment.

Reported by: pfg
MFC after: 2 weeks

2 years agoipsec: Return error code if no matching SA was found
Kornel Duleba [Fri, 13 Aug 2021 07:35:08 +0000 (09:35 +0200)]
ipsec: Return error code if no matching SA was found

If we matched SP to a packet, but no associated SA was found
ipsec4_allocsa will return NULL while setting error=0.
This resulted in use after free and potential kernel panic.
Return EINPROGRESS if the case described above instead.

Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D30994

2 years agoipsec: Check PMTU before sending a frame.
Kornel Duleba [Fri, 13 Aug 2021 07:20:46 +0000 (09:20 +0200)]
ipsec: Check PMTU before sending a frame.

If an encapsulated frame is going to have DF bit set check its desitnitions'
PMTU and if it won't fit drop it and:

Generate ICMP 3/4 message if the packet was to be forwarded.
Return EMSGSIZE error otherwise.

Obtained from: Semihalf
Sponsored by: Stormshield
Differential revision: https://reviews.freebsd.org/D30993

2 years agonfsd: Fix sanity check for NFSv4.2 Allocate operations
Rick Macklem [Thu, 12 Aug 2021 23:48:28 +0000 (16:48 -0700)]
nfsd: Fix sanity check for NFSv4.2 Allocate operations

The NFSv4.2 Allocate operation sanity checks the aa_offset
and aa_length arguments.  Since they are assigned to variables
of type off_t (signed) it was possible for them to be negative.
It was also possible for aa_offset+aa_length to exceed OFF_MAX
when stored in lo_end, which is uint64_t.

This patch adds checks for these cases to the sanity check.

Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31511

2 years agoclang: Fix inverted condition in llvm.build.mk
Jessica Clarke [Thu, 12 Aug 2021 22:53:30 +0000 (23:53 +0100)]
clang: Fix inverted condition in llvm.build.mk

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week

2 years agotools/build/cross-build: Fix building libllvmminimal on Linux
Jessica Clarke [Thu, 12 Aug 2021 22:50:48 +0000 (23:50 +0100)]
tools/build/cross-build: Fix building libllvmminimal on Linux

There is a __used member in glibc's posix_spawn_file_actions_t in
spawn.h, so we must temporarily undefine __used when including it,
otherwise Support/Unix/Program.inc fails to build. This is based on
similar handling for __unused in other headers.

Fixes: 31ba4ce8898f ("Allow bootstrapping llvm-tblgen on macOS and Linux")
MFC after: 1 week

2 years agobsd.compiler.mk: Fix cross-building from non-FreeBSD
Jessica Clarke [Thu, 12 Aug 2021 22:45:09 +0000 (23:45 +0100)]
bsd.compiler.mk: Fix cross-building from non-FreeBSD

On non-FreeBSD, the various MACHINE variables for the host when
bootstrapping can be missing or not match FreeBSD's naming, causing
bsd.endian.mk to be unable to infer the endianness. Work around this by
assuming it's unsupported.

Note that we can't check BOOTSTRAPPING here as Makefile.inc1 includes
bsd.compiler.mk before that is set, and so we are unable to catch errors
during buildworld itself when cross-building and bsd.endian.mk failed,
but such errors should also show up when building on FreeBSD.

Fixes: 47363e99d3d3 ("Enable compressed debug on little-endian targets")

2 years agoRevert "ar: diff reduction against ELF Tool Chain"
Ed Maste [Thu, 12 Aug 2021 18:26:37 +0000 (14:26 -0400)]
Revert "ar: diff reduction against ELF Tool Chain"

This reverts commit d20e9e02db3dde383c3de1ce8cec3a8c35b3eee6.
It caused port build failures.

Reported by: cy

2 years agocxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close.
John Baldwin [Thu, 12 Aug 2021 15:48:14 +0000 (08:48 -0700)]
cxgbei: Wait for the final CPL to be received in icl_cxgbei_conn_close.

A socket in the FIN_WAIT_1 state is marked disconnected by
do_close_con_rpl() even though there might still receive data pending.
This is because the socket at that point has set SBS_CANTRCVMORE which
causes the protocol layer to discard any data received before the FIN.
However, icl_cxgbei_conn_close needs to wait until all the data has
been discarded.  Replace the wait for SS_ISDISCONNECTED with instead
waiting for final_cpl_received() to be called.

Reported by: Jithesh Arakkan @ Chelsio
Sponsored by: Chelsio Communications

2 years agoparam.h: Bump __FreeBSD_version to 1400030
Ka Ho Ng [Thu, 12 Aug 2021 14:59:41 +0000 (22:59 +0800)]
param.h: Bump __FreeBSD_version to 1400030

Commit a638dc4ebc8e expands VOP_DEALLOCATE(9)'s parameters list. File
system modules and modules calling VOP_DEALLOCATE(9) need to be rebuilt.

Commit 454bc887f250 introduces fspacectl(2) SPACECTL_DEALLOC support for
POSIX shared memory.

Sponsored by: The FreeBSD Foundation

2 years agouipc_shm: Implements fspacectl(2) support
Ka Ho Ng [Thu, 12 Aug 2021 15:01:02 +0000 (23:01 +0800)]
uipc_shm: Implements fspacectl(2) support

This implements fspacectl(2) support on shared memory objects. The
semantic of SPACECTL_DEALLOC is equivalent to clearing the backing
store and free the pages within the affected range. If the call
succeeds, subsequent reads on the affected range return all zero.

tests/sys/posixshm/posixshm_tests.c is expanded to include a
fspacectl(2) functional test.

Sponsored by: The FreeBSD Foundation
Reviewed by: kevans, kib
Differential Revision: https://reviews.freebsd.org/D31490

2 years agovfs: Add ioflag to VOP_DEALLOCATE(9)
Ka Ho Ng [Thu, 12 Aug 2021 14:58:52 +0000 (22:58 +0800)]
vfs: Add ioflag to VOP_DEALLOCATE(9)

The addition of ioflag allows callers passing
IO_SYNC/IO_DATASYNC/IO_DIRECT down to the file system implementation.
The vop_stddeallocate fallback implementation is updated to pass the
ioflag to the file system implementation. vn_deallocate(9) internally is
also changed to pass ioflag to the VOP_DEALLOCATE call.

Sponsored by: The FreeBSD Foundation
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D31500

2 years agowpa: Add wpa_cli action file event
Cy Schubert [Thu, 12 Aug 2021 13:38:21 +0000 (06:38 -0700)]
wpa: Add wpa_cli action file event

Yan Zhong at FreeBSD Foundation is working on a wireless network
configuratior for an experimental FreeBSD installer. The new installer
requires an event to detect when connecting to a network fails due to a
bad password. When this happens a WPA-EVENT-TEMP-DISABLED event is
triggered. This patch passes the event to an action file provided by
the new experimental installer.

Submitted by: Yang Zhong <yzhong () freebsdfoundation.org>
Reviewed by: assumed to be reviewed by emaste (and cy)
MFC after: 1 week

2 years agohms(4): Fix a typo in sysctl description
Gordon Bergling [Thu, 12 Aug 2021 13:37:47 +0000 (15:37 +0200)]
hms(4): Fix a typo in sysctl description

- s/threshhold/threshold/

MFC after: 3 days

2 years agolinux(4): Remove clone3 and faccessat2 from dummy.
Dmitry Chagin [Thu, 12 Aug 2021 13:07:21 +0000 (16:07 +0300)]
linux(4): Remove clone3 and faccessat2 from dummy.

MFC after: 2 weeks

2 years agoMerge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h
NagaChaitanya Vellanki [Thu, 12 Aug 2021 10:45:22 +0000 (18:45 +0800)]
Merge common parts of i386 and amd64's ieeefp.h into x86/x86_ieeefp.h

MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D26292

2 years agovfs: Add get_write_ioflag helper to calculate ioflag
Ka Ho Ng [Thu, 12 Aug 2021 09:35:34 +0000 (17:35 +0800)]
vfs: Add get_write_ioflag helper to calculate ioflag

Converted vn_write to use this helper.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D31513

2 years agoloader: cstyle cleanup of userboot/devicename.c
Toomas Soome [Wed, 11 Aug 2021 07:07:28 +0000 (10:07 +0300)]
loader: cstyle cleanup of userboot/devicename.c

No functional changes intended.

MFC after: 1 week

2 years agolinux(4): Remove the unnecessary spaces.
Dmitry Chagin [Thu, 12 Aug 2021 08:58:33 +0000 (11:58 +0300)]
linux(4): Remove the unnecessary spaces.

MFC after: 2 weeks

2 years agofork: Remove the unnecessary spaces.
Dmitry Chagin [Thu, 12 Aug 2021 08:58:17 +0000 (11:58 +0300)]
fork: Remove the unnecessary spaces.

MFC after: 2 weeks

2 years agolinux(4): Move ff variable initialization from declaration.
Dmitry Chagin [Thu, 12 Aug 2021 08:57:16 +0000 (11:57 +0300)]
linux(4): Move ff variable initialization from declaration.

Modern style(9) allows variables initialization where they are declared,
but in this case initialization obfuscate the code.

MFC after: 2 weeks

2 years agolinux(4): Verify that higher 32bits of exit_signal in clone3 are unset.
Dmitry Chagin [Thu, 12 Aug 2021 08:56:51 +0000 (11:56 +0300)]
linux(4): Verify that higher 32bits of exit_signal in clone3 are unset.

MFC after: 2 weeks

2 years agolinux(4): Return ENOSYS for unsupported clone3 option bits.
Dmitry Chagin [Thu, 12 Aug 2021 08:56:36 +0000 (11:56 +0300)]
linux(4): Return ENOSYS for unsupported clone3 option bits.

Differential Revision: https://reviews.freebsd.org/D31483
MFC after: 2 weeks

2 years agolinux(4): Add LINUX_RATELIMIT_MSG macro for future use.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:55 +0000 (11:55 +0300)]
linux(4): Add LINUX_RATELIMIT_MSG macro for future use.

Differential Revision: https://reviews.freebsd.org/D31488
MFC after: 2 weeks

2 years agolinux(4): Implement CLONE_CLEAR_SIGHAND option bit.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:35 +0000 (11:55 +0300)]
linux(4): Implement CLONE_CLEAR_SIGHAND option bit.

CLONE_CLEAR_SIGHAND is designed to reset all signal handlers of the child
not set to SIG_IGN to SIG_DFL.

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D31481
MFC after: 2 weeks

2 years agolinux(4): Add CLONE_PIDFD option bit.
Dmitry Chagin [Thu, 12 Aug 2021 08:55:24 +0000 (11:55 +0300)]
linux(4): Add CLONE_PIDFD option bit.

Differential revision: https://reviews.freebsd.org/D31478
MFC after: 2 weeks

2 years agoEnable arm64 SError exceptions in the kernel
Andrew Turner [Mon, 9 Aug 2021 16:30:44 +0000 (16:30 +0000)]
Enable arm64 SError exceptions in the kernel

These are needed to signal to the kernel when a Reliability,
Availability, and Serviceability (RAS) exception has triggered.

Reviewed by: mhorne
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31477

2 years agoAdd the Apple arm64 implementer ID
Andrew Turner [Wed, 11 Aug 2021 15:30:44 +0000 (16:30 +0100)]
Add the Apple arm64 implementer ID

Sponsored by: The FreeBSD Foundation

2 years agoSort the arm64 cpu_implementers list by name
Andrew Turner [Wed, 11 Aug 2021 15:29:09 +0000 (16:29 +0100)]
Sort the arm64 cpu_implementers list by name

We perform a linear search, so make it easier to add new entries in the
correct place.

Sponsored by: The FreeBSD Foundation

2 years agolinux(4): Regen for clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:50:22 +0000 (11:50 +0300)]
linux(4): Regen for clone3 system call.

MFC after: 2 weeks

2 years agolinux(4): Implement clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:49:36 +0000 (11:49 +0300)]
linux(4): Implement clone3 system call.

clone3 system call is used by glibc-2.34.

Differential revision: https://reviews.freebsd.org/D31475
MFC after: 2 weeks

2 years agolinux(4): Add struct clone_args for future clone3 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:49:01 +0000 (11:49 +0300)]
linux(4): Add struct clone_args for future clone3 system call.

In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

Differential revision: https://reviews.freebsd.org/D31474
MFC after: 2 weeks

2 years agolinux(4): Regen for clone syscall.
Dmitry Chagin [Thu, 12 Aug 2021 08:47:31 +0000 (11:47 +0300)]
linux(4): Regen for clone syscall.

MFC after: 2 weeks

2 years agolinux(4): Change clone syscall definition to match Linux actual one.
Dmitry Chagin [Thu, 12 Aug 2021 08:46:36 +0000 (11:46 +0300)]
linux(4): Change clone syscall definition to match Linux actual one.

Differential revision: https://reviews.freebsd.org/D31473
MFC after: 2 weeks

2 years agofork: Allow ABI to specify fork return values for child.
Dmitry Chagin [Thu, 12 Aug 2021 08:45:25 +0000 (11:45 +0300)]
fork: Allow ABI to specify fork return values for child.

At least Linux x86 ABI's does not use carry bit and expects that the dx register
is preserved. For this add a new sv_set_fork_retval hook and call it from cpu_fork().

Add a short comment about touching dx in x86_set_fork_retval(), for more details
see phab comments from kib@ and imp@.

Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D31472
MFC after: 2 weeks

2 years agolinux(4): Plug in aarch64 fcntl flags.
Dmitry Chagin [Thu, 12 Aug 2021 08:42:50 +0000 (11:42 +0300)]
linux(4): Plug in aarch64 fcntl flags.

Fixes opendir() libc function.

Differential Revision: https://reviews.freebsd.org/D31357
MFC after: 2 weeks

2 years agolinux(4): Regen for faccessat2 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:41:35 +0000 (11:41 +0300)]
linux(4): Regen for faccessat2 system call.

MFC after: 2 weeks

2 years agolinux(4): Implement faccessat2 system call.
Dmitry Chagin [Thu, 12 Aug 2021 08:40:42 +0000 (11:40 +0300)]
linux(4): Implement faccessat2 system call.

It's used by bash on arm64 with glibc-2.32.

Reviewed by: trasz
Differential Revision: https://reviews.freebsd.org/D31345
MFC after: 2 weeks

2 years agolinux(4): Fix futex copyrights.
Dmitry Chagin [Thu, 12 Aug 2021 08:36:24 +0000 (11:36 +0300)]
linux(4): Fix futex copyrights.

As no more NetBSD code in futexes exists replace NetBSD copyrights by
standard FreeBSD 2 clause license.
Add Roman Divacky's copyrights as an author of the robust futexes.

Differential revision: https://reviews.freebsd.org/D31347
MFC after: 2 weeks

2 years agovmm: Fix wrong assert in ivhd_dev_add_entry
Ka Ho Ng [Thu, 12 Aug 2021 07:54:40 +0000 (15:54 +0800)]
vmm: Fix wrong assert in ivhd_dev_add_entry

The correct condition is to check the number of ivhd entries fit into
the array.

Reported by: bz
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31514

2 years agoloader: fix multiboot loading on UEFI
Roger Pau Monné [Wed, 11 Aug 2021 14:55:10 +0000 (16:55 +0200)]
loader: fix multiboot loading on UEFI

The Xen kernel has no symbol tables, so calling lookup_symbol against
it triggers the following Divide by Zero fault:

Loading Xen kernel...
/boot/xen data=0x2809c8+0x149638 |
!!!! X64 Exception Type - 00(#DE - Divide Error)  CPU Apic ID - 00000000 !!!!

Fix lookup_symbol to prevent the #DE fault from happening if the
symbol table is not loaded and also fix loadfile_raw to mark multiboot
kernels as relocatable, since the only multiboot kernel supported is
Xen and was already unconditionally booted as relocatable.

Fixes: f75caed644a5 ('amd64 UEFI loader: stop copying staging area to 2M physical')
Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D31507

2 years agoxen: use correct cache attributes for Xen specific memory regions
Roger Pau Monné [Fri, 9 Apr 2021 09:31:44 +0000 (11:31 +0200)]
xen: use correct cache attributes for Xen specific memory regions

bus_activate_resource maps memory regions as uncacheable on x86, which
is more strict than required for regions allocated using xenmem_alloc,
so don't rely on bus_activate_resource and instead map the region
using pmap_mapdev_attr and VM_MEMATTR_XEN as the cache attribute.

Sponsored by: Citrix Systems R&D

2 years agodumpon: fix build on some architectures
Eric van Gyzen [Thu, 12 Aug 2021 02:27:24 +0000 (21:27 -0500)]
dumpon: fix build on some architectures

Fix a -Wsign-compare issue on some architectures.

Fixes: 96f9bd46547d6dfbaf219ab449efacacb0dacccc
Pointy hat to: me
MFC after: 1 week
Sponsored by: Dell EMC Isilon

2 years agoUPDATING: Add an entry for commit 3ad1e1c1ce20
Rick Macklem [Thu, 12 Aug 2021 01:58:00 +0000 (18:58 -0700)]
UPDATING: Add an entry for commit 3ad1e1c1ce20

2 years agonfscl: Add a Lookup+Open RPC for NFSv4.1/4.2
Rick Macklem [Thu, 12 Aug 2021 01:49:26 +0000 (18:49 -0700)]
nfscl: Add a Lookup+Open RPC for NFSv4.1/4.2

This patch adds a Lookup+Open compound RPC to the NFSv4.1/4.2
NFS client, which can be used by nfs_lookup() so that a
subsequent Open RPC is not required.
It uses the cn_flags OPENREAD, OPENWRITE added by commit c18c74a87c15.
This reduced the number of RPCs by about 15% for a kernel
build over NFS.

For now, use of Lookup+Open is only done when the "oneopenown"
mount option is used.  It may be possible for Lookup+Open to
be used for non-oneopenown NFSv4.1/4.2 mounts, but that will
require extensive further testing to determine if it works.

While here, I've added the changes to the nfscommon module
that are needed to implement the Deallocate NFSv4.2 operation.
This avoids needing another cycle of changes to the internal
KAPI between the NFS modules.

This commit has changed the internal KAPI between the NFS
modules and, as such, all need to be rebuilt from sources.
I have not bumped __FreeBSD_version, since it was bumped a
few days ago.

2 years agopowerpc/pseries: Allow radix pmap in pseries for ISA 3.0
Justin Hibbits [Thu, 12 Aug 2021 00:03:27 +0000 (19:03 -0500)]
powerpc/pseries: Allow radix pmap in pseries for ISA 3.0

ISA 3.0 allows for nested radix translations with minimal to no
involvement of the hypervisor.  This should make pseries signficantly
faster on POWER9 pseries instances, as fewer hypercalls are needed to
manage pmap now.

MFC after: 2 weeks
Relnotes: yes

2 years agoar: diff reduction against ELF Tool Chain
Ed Maste [Wed, 4 Aug 2021 13:54:17 +0000 (09:54 -0400)]
ar: diff reduction against ELF Tool Chain

- Drop exit status from bsdar_errc.  ELF Tool Chain always returns
  EXIT_FAILURE in bsdar_errc.

- Remove ar_mode_* wrappers and call ar_read_archive / ar_write_archive
  directly.

Obtained from: ELF Tool Chain
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31496

2 years agolibsecureboot: define SOPEN_MAX
Toomas Soome [Tue, 10 Aug 2021 19:46:40 +0000 (22:46 +0300)]
libsecureboot: define SOPEN_MAX

With commit 97cbd5e722389a575e820c4e03f38053308f08ea, the SOPEN_MAX
was removed from stand.h.

We would need better mechanism there.

2 years agoloader: open file list should be dynamic
Toomas Soome [Sat, 31 Jul 2021 08:09:48 +0000 (11:09 +0300)]
loader: open file list should be dynamic

Summary:
Open file list is currently created as statically allocated array (64 items).
Once this array is filled up, loader will not be able to operate with files.
In most cases, this mechanism is good enough, but the problem appears, when
we have many disks with zfs pool(s). In current loader implementation, all
discovered zfs pool configurations are kept in memory and disk devices open -
consuming the open file array. Rewrite the open file mechanism to use
dynamically allocated list.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D31364

2 years agonetdump: send key before dump, in case dump fails
Eric van Gyzen [Fri, 6 Aug 2021 15:38:51 +0000 (10:38 -0500)]
netdump: send key before dump, in case dump fails

Previously, if an encrypted netdump failed, such as due to a timeout or
network failure, the key was not saved, so a partial dump was
completely useless.

Send the key first, so the partial dump can be decrypted, because even a
partial dump can be useful.

Reviewed by: bdrewery, markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D31453

2 years agodumpon: fix encrypted dumps after commit 372557d8c3d
Eric van Gyzen [Sat, 7 Aug 2021 08:59:02 +0000 (03:59 -0500)]
dumpon: fix encrypted dumps after commit 372557d8c3d

That commit moved key generation into a child process, including
a memory allocation referenced by a structure.  The child wrote
the structure to the parent over a pipe, but did not write the
referenced allocation.  The parent read the structure from the
child and used its pointer, which was bogus in the parent.

In the child, send both chunks of data to the parent.  In the
parent, make a corresponding allocation and read both chunks.

Fixes: 372557d8c3d37dd0c1d9be56513a436393963848
Reviewed by: bdrewery, markj
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D31452

2 years agovirtio: Add KMSAN hooks for network and block devices
Mark Johnston [Wed, 11 Aug 2021 20:23:25 +0000 (16:23 -0400)]
virtio: Add KMSAN hooks for network and block devices

This ensures that host-written data is marked as initialized.

Sponsored by: The FreeBSD Foundation

2 years agoether: Add a KMSAN check for transmitted frames
Mark Johnston [Wed, 11 Aug 2021 20:23:12 +0000 (16:23 -0400)]
ether: Add a KMSAN check for transmitted frames

This helps ensure that outbound packet data is initialized per KMSAN.

Sponsored by: The FreeBSD Foundation

2 years agogeom_disk: Add KMSAN checks
Mark Johnston [Wed, 11 Aug 2021 20:22:26 +0000 (16:22 -0400)]
geom_disk: Add KMSAN checks

- In g_disk_start(), verify that the data to be written is initialized
  according to KMSAN shadow state.
- In g_disk_done(), verify that the block driver updated shadow state as
  expected, so as to catch sources of false positives early.

Sponsored by: The FreeBSD Foundation

2 years agokmsan: Export kmsan_mark_mbuf() and kmsan_mark_bio()
Mark Johnston [Wed, 11 Aug 2021 20:22:21 +0000 (16:22 -0400)]
kmsan: Export kmsan_mark_mbuf() and kmsan_mark_bio()

Sponsored by: The FreeBSD Foundation

2 years agoktls: Init reset tag task for cloned sessions
Andrew Gallatin [Wed, 11 Aug 2021 18:06:43 +0000 (14:06 -0400)]
ktls: Init reset tag task for cloned sessions

When cloning a ktls session (which is needed when we need to
switch output NICs for a NIC TLS session), we need to also
init the reset task, like we do when creating a new tls session.

Reviewed by: jhb
Sponsored by: Netflix

2 years agokdb: Handle process enumeration before procinit()
Mitchell Horne [Wed, 11 Aug 2021 17:40:01 +0000 (14:40 -0300)]
kdb: Handle process enumeration before procinit()

Make kdb_thr_first() and kdb_thr_next() return sane values if the
allproc list and pidhashtbl haven't been initialized yet. This can
happen if the debugger is entered very early on, for example with the
'-d' boot flag.

This allows remote gdb to attach at such a time, and fixes some ddb
commands like 'show threads'.

Be explicit about the static initialization of these variables. This
part has no functional change.

Reviewed by: markj, imp (previous version)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31495

2 years agoar: remove invalid extra param in bsdar_warnc calls
Ed Maste [Wed, 11 Aug 2021 17:22:23 +0000 (13:22 -0400)]
ar: remove invalid extra param in bsdar_warnc calls

A number of warnings passed an exit status code to bsdar_warnc, but it
does not take exit status (as a warning, it does not exit).

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agoRELNOTES: Add entries for KASAN and KMSAN
Mark Johnston [Wed, 11 Aug 2021 17:05:50 +0000 (13:05 -0400)]
RELNOTES: Add entries for KASAN and KMSAN

Sponsored by: The FreeBSD Foundation

2 years agoncurses: Apply a tputs() fix from patch 20210403
Mark Johnston [Wed, 11 Aug 2021 16:54:29 +0000 (12:54 -0400)]
ncurses: Apply a tputs() fix from patch 20210403

From the (substantially larger) upstream commit:
+ call delay_output_sp to handle BSD-style padding when tputs_sp is
  called, whether directly or internally, to ensure that the SCREEN
  pointer is passed correctly (reports by Henric Jungheim, Juraj
  Lutter).

This fixes bison segfaults observed when colourized output is enabled.
Thanks to jrtc27@ for identifying the upstream fix.

PR: 256731
MFC after: 3 days

2 years agostand: Add MK_PIE=no to defs.mk
Warner Losh [Wed, 11 Aug 2021 16:59:28 +0000 (10:59 -0600)]
stand: Add MK_PIE=no to defs.mk

There's no need to build both pie and non-pie .o's for stand. There's
some other build thing with MK_BEAR_SSL=yes and/or MK_LOADER_VERIEXEC=yes
that causes the pie build to fail that the 'ar' stage now. Since we don't
need the PIE stuff and the non-PIE stuff, disable PIE for the boot loader.

Reviewed by: emaste
Sponsored by: Netflix

2 years agoRead the arm64 midr register earlier
Andrew Turner [Wed, 11 Aug 2021 15:01:25 +0000 (16:01 +0100)]
Read the arm64 midr register earlier

We use the midr_el1 register to decode which CPU type we are booting
from. Read it on the secondary CPUs before waiting for the boot CPU
to release us as it will need to use it before the release.

Sponsored by: The FreeBSD Foundation

2 years agoUse arm64 sha256 intrinsics in libmd
Andrew Turner [Fri, 23 Jul 2021 09:14:03 +0000 (10:14 +0100)]
Use arm64 sha256 intrinsics in libmd

Summary:
When running on a CPU that supports the arm64 sha256 intrinsics use them
to improve perfromance of sha256 calculations.

With this changethe following improvement has been seen on an Apple M1
with FreeBS running under Parallels, with similar results on a
Neoverse-N1 r3p1.

x sha256.orig
+ sha256.arm64
+--------------------------------------------------------------------+
|++                                                               x x|
|+++                                                              xxx|
||A                                                               |A||
+--------------------------------------------------------------------+
    N           Min           Max        Median           Avg        Stddev
x   5          3.41           3.5          3.46         3.458   0.042661458
+   5          0.47          0.54           0.5         0.504   0.027018512
Difference at 95.0% confidence
        -2.954 +/- 0.0520768
        -85.4251% +/- 0.826831%
        (Student's t, pooled s = 0.0357071)

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31284

2 years agoOnly use byte register access in legacy virtio pci
Andrew Turner [Thu, 5 Aug 2021 14:36:07 +0000 (14:36 +0000)]
Only use byte register access in legacy virtio pci

Some simulators don't implement arbitrary sized memory access to the
virtio PCI registers. Follow Linux and use single byte accesses to read
and write to these registers.

Reviewed by: bryanv, emaste (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31424

2 years agovfs: Rename ioflg to ioflag in vn_deallocate
Ka Ho Ng [Wed, 11 Aug 2021 09:45:47 +0000 (17:45 +0800)]
vfs: Rename ioflg to ioflag in vn_deallocate

This includes a style fix around ioflag checking as well.

Sponsored by: The FreeBSD Foundation
Reviewed by: kib, bcr
Differential Revision: https://reviews.freebsd.org/D31505

2 years agoAdd myself (diizzy) as ports committer
Daniel Engberg [Wed, 11 Aug 2021 07:56:40 +0000 (09:56 +0200)]
Add myself (diizzy) as ports committer

Section 7.1 in Committer's Guide

Reviewed by: tcberner
Approved by: tcberner
Differential Revision: <https://reviews.freebsd.org/D31479>

2 years agoiscontrol(8): Fix a typo in a struct
Gordon Bergling [Wed, 11 Aug 2021 07:55:08 +0000 (09:55 +0200)]
iscontrol(8): Fix a typo in a struct

- s/suport/support/

MFC after: 5 days

2 years agoipfw(8): Fix a typo in an error message
Gordon Bergling [Wed, 11 Aug 2021 07:53:01 +0000 (09:53 +0200)]
ipfw(8): Fix a typo in an error message

- s/suport/support/

MFC after: 5 days

2 years agoMark some sysctls as CTLFLAG_MPSAFE.
Alexander Motin [Wed, 11 Aug 2021 02:17:53 +0000 (22:17 -0400)]
Mark some sysctls as CTLFLAG_MPSAFE.

MFC after: 2 weeks

2 years agock: Correct asm output operand widths in amd64 pointer intrinsics
Mark Johnston [Tue, 10 Aug 2021 21:23:49 +0000 (17:23 -0400)]
ck: Correct asm output operand widths in amd64 pointer intrinsics

This does not appear to change generated code with the default
toolchain.  However, KMSAN makes use of output operand specifications to
instrument inline asm, and with incorrect specifications we get false
positives in code that uses the CK_(S)LIST macros.

This was submitted upstream:
https://github.com/concurrencykit/ck/pull/175

The commit applies the same change locally to make KMSAN usable until
something equivalent is merged upstream.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agouma: Add KMSAN hooks
Mark Johnston [Tue, 10 Aug 2021 21:15:03 +0000 (17:15 -0400)]
uma: Add KMSAN hooks

For now, just hook the allocation path: upon allocation, items are
marked as initialized (absent M_ZERO).  Some zones are exempted from
this when it would otherwise raise false positives.

Use kmsan_orig() to update the origin map for UMA and malloc(9)
allocations.  This allows KMSAN to print the return address when an
uninitialized UMA item is implicated in a report.  For example:
  panic: MSan: Uninitialized UMA memory from m_getm2+0x7fe

Sponsored by: The FreeBSD Foundation

2 years agobusdma: Add KMSAN integration
Mark Johnston [Tue, 10 Aug 2021 21:14:15 +0000 (17:14 -0400)]
busdma: Add KMSAN integration

Sanitizer instrumentation of course cannot automatically update shadow
state when devices write to host memory.  KMSAN thus hooks into busdma,
both to update shadow state after a device write, and to verify that the
kernel does not publish uninitalized bytes to devices.

To implement this, when KMSAN is configured, each dmamap embeds a memory
descriptor describing the region currently loaded into the map.
bus_dmamap_sync() uses the operation flags to determine whether to
validate the loaded region or to mark it as initialized in the shadow
map.

Note that in cases where the amount of data written is less than the
buffer size, the entire buffer is marked initialized even when it is
not.  For example, if a NIC writes a 128B packet into a 2KB buffer, the
entire buffer will be marked initialized, but subsequent accesses past
the first 128 bytes are likely caused by bugs.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31338