]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoGeneralise the arm64 ASID allocator.
andrew [Wed, 26 Feb 2020 11:50:24 +0000 (11:50 +0000)]
Generalise the arm64 ASID allocator.

The requirements of an Address Space ID allocator and a Virtual Machine ID
allocator are similar. Generalise the former code so it can be used with
the latter.

Reviewed by: alc (previous version)
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D23831

4 years agoStart to support multiple stages in the arm64 pmap.
andrew [Wed, 26 Feb 2020 11:47:24 +0000 (11:47 +0000)]
Start to support multiple stages in the arm64 pmap.

On arm64 the stage 1 and stage 2 pte formats are similar enough we can
reuse the pmap code for both. As they are only similar and not identical
we need to know if we are managing stage 1 or stage 2 tables.

Add an enum to store this information and a check to make sure it is
set to stage 1 when we manage stage 1 pte fields.

Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D23830

4 years agoAdd more arm64 CTR_EL0 register fields
andrew [Wed, 26 Feb 2020 11:29:03 +0000 (11:29 +0000)]
Add more arm64 CTR_EL0 register fields

While here make the _SIZE macros return the size in bytes, not the log2
of the size

Sponsored by: Innovate UK

4 years agobridge: Move locking defines into if_bridge.c
kp [Wed, 26 Feb 2020 08:47:18 +0000 (08:47 +0000)]
bridge: Move locking defines into if_bridge.c

The locking defines for if_bridge used to live in if_bridgevar.h, but
they're only ever used by the bridge implementation itself (in
if_bridge.c). Moving them into the .c file.

Reported by: philip, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23808

4 years agoRevert r358309 after r358311.
lwhsu [Wed, 26 Feb 2020 04:54:50 +0000 (04:54 +0000)]
Revert r358309 after r358311.

PR: 244393
Sponsored by: The FreeBSD Foundation

4 years agoAdd a note about deleted files in OpenSSH upgrade instructions
emaste [Tue, 25 Feb 2020 22:15:25 +0000 (22:15 +0000)]
Add a note about deleted files in OpenSSH upgrade instructions

4 years ago[PowerPC] [Book-E] Remove obsolete interrupt binding workaround
bdragon [Tue, 25 Feb 2020 22:03:30 +0000 (22:03 +0000)]
[PowerPC] [Book-E] Remove obsolete interrupt binding workaround

Remove an old workaround that is no longer necessary since rS343824.

There used to be a problem with FMan interrupts firing on multiple CPUS
at the same time.

This ended up being due to multicast interrupts being unsupported in the
Freescale PIC (so instead of using a selection algorithm, it would do some
unspecified action, such as interrupting multiple cpus at random.)

Reviewed by: jhibbits
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D23829

4 years agoGeneralize resources freeing in sendfile with different scenarios.
glebius [Tue, 25 Feb 2020 19:29:05 +0000 (19:29 +0000)]
Generalize resources freeing in sendfile with different scenarios.
Now we execute sendfile_iodone() in all possible cases, which
guarantees that vm_object_pip_wakeup() is called and sfio structure
is freed.

At the beginning of sendfile initialize sfio->m to NULL, that would
indicate that the mbuf chain either doesn't exist, or belongs to the
syscall (not to I/O completion).  Fill sfio->m only at a point when
we are positive that there are I/Os ongoing and before releasing
syscall's reference on sfio.

In sendfile_iodone() perform vm_object_pip_wakeup() once last
reference is released, then check for sfio->m.  NULL pointer
indicates that we need only to free the memory.

Reviewed by: jtl, gallatin

4 years agoMake ktls_frame() never fail. Caller must supply correct mbufs.
glebius [Tue, 25 Feb 2020 19:26:40 +0000 (19:26 +0000)]
Make ktls_frame() never fail.  Caller must supply correct mbufs.
This makes sendfile code a bit simplier.

4 years agoSYSCTL_ROOT_NODE should use the SYSCTL_ENFORCE_FLAGS macro too.
kaktus [Tue, 25 Feb 2020 19:12:40 +0000 (19:12 +0000)]
SYSCTL_ROOT_NODE should use the SYSCTL_ENFORCE_FLAGS macro too.

Approved by: kib (mentor, blanket)

4 years agoWhen sendfile_swapin() sweeps through pages in search for a bogus page
glebius [Tue, 25 Feb 2020 19:11:20 +0000 (19:11 +0000)]
When sendfile_swapin() sweeps through pages in search for a bogus page
skip first and last pages.  This is a micro optimisation.

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (16 of many)
kaktus [Tue, 25 Feb 2020 19:04:39 +0000 (19:04 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (16 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.

Mark all obvious cases as MPSAFE.

Reviewed by: royger
Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23638

4 years agoFix IBRS for machines with IBRS_ALL capability.
kib [Tue, 25 Feb 2020 17:26:10 +0000 (17:26 +0000)]
Fix IBRS for machines with IBRS_ALL capability.

When turning IBRS mitigation using sysctl, as opposed to loader tunable,
send IPI to tweak MSR on all cores.  Right now code only performed MSR write
onr the CPU where sysctl was run.

Properly report hw.ibrs_active for IBRS_ALL.  Split hw_ibrs_ibpb_active out
from ibrs_active, to keep the current semantic of guiding kernel entry and
exit handlers.

Reported and tested by: mav
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agostyle.9: update C99 commentary
emaste [Tue, 25 Feb 2020 17:18:59 +0000 (17:18 +0000)]
style.9: update C99 commentary

Make style.9 read as a current statement of C99 preferences, rather than a
description of ongoing changes to our preferred style.  Alsu use the short
form "ISO C99" on the 2nd and later instances rather than repeating the
unwieldy `ISO/IEC 9899:1999 ("ISO C99")` each time.

Reviewed by: cem, imp, jhb, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23648

4 years agoip6_output: fix regression introduced in r358167 for ipv6 fragmentation
bz [Tue, 25 Feb 2020 15:03:41 +0000 (15:03 +0000)]
ip6_output: fix regression introduced in r358167 for ipv6 fragmentation

When moving the calculations for the optlen into the if (opt) block
which deals with possible extension headers I failed to initialise
unfragpartlen to the ipv6 header length if there were no extension
headers present.  Correct that mistake to make IPv6 fragment length
calculcations work again.

Reported by: hselasky, kp
OKed by: hselasky, kp
MFC after: 3 days
X-MFC with: r358167
PR: 244393

4 years agoUse hid_get_data_unsigned() instead of hid_get_data() when reading the
hselasky [Tue, 25 Feb 2020 12:56:06 +0000 (12:56 +0000)]
Use hid_get_data_unsigned() instead of hid_get_data() when reading the
key-codes from the USB keyboard. Negative key-codes are currently skipped.

While at it use the bit size value provided by the HID location structure
instead of assuming a value of 8.

This fixes a regression issue after r357861.

Reported by: Minoru TANABE <kotanabe3@gmail.com>
PR: 224592
PR: 233884
MFC after: 3 days
Sponsored by: Mellanox Technologies

4 years agoTemporarily skip failing test case sys.netpfil.pf.fragmentation.v6
lwhsu [Tue, 25 Feb 2020 11:56:54 +0000 (11:56 +0000)]
Temporarily skip failing test case sys.netpfil.pf.fragmentation.v6

PR: 244393
Sponsored by: The FreeBSD Foundation

4 years agoBefore issing the REMOVE_DEVICE command to the firmware, make sure that all
imp [Tue, 25 Feb 2020 04:27:23 +0000 (04:27 +0000)]
Before issing the REMOVE_DEVICE command to the firmware, make sure that all
commands have completed.

It's not OK to force complete any pending commands before we send the
REMOVE_DEVICE. Instead, make sure that all pending commands are complete before
sending that. By trying to second guess the firmware here, we run the risk of
completing commands twice, which leads to corruption.

This removes the forced completion of commands introduced in r218811. So it's a
partial backout of that commit, but replaces it with a more rebust
mechanism. Either these commands will complete due to the TARGET RESET, or they
will timeout and be aborted, but they will all complete.

Add assert that all commands are complete to REMOVE_DEVICE completion
routine. We attempt to assure this programatically, so we shouldn't have any
commands in the queue because we've waited for them all. Any commands that make
it into our action routine after we mark the target in removal will complete
immediately with an error.

When we're removing a target that's not a volume, advertise up the stack that
it's actually gone, as opposed to having a transient selection error we should
retry. Do this both in the action routine, and when we get a notification of an
aborted command. We don't do this for volumes because the driver tries hard not
to advertise to the OS a volume has disappeared.

Apply these changes to both mpr and mps since they are based on quite similar
designs.

Discussed with: scottl@
Differential Revision: https://reviews.freebsd.org/D23768

4 years ago[PowerPC] [Book-E] Fix dpaa interrupt binding.
bdragon [Tue, 25 Feb 2020 03:35:52 +0000 (03:35 +0000)]
[PowerPC] [Book-E] Fix dpaa interrupt binding.

After the network epoch was added, we lost the ability to migrate the
ithread in the middle of dispatch, as being in the network epoch will pin
the current thread (for safety reasons.)

Luckily, we don't actually have to do this workaround in the first place,
as we can just bind it to the correct cpu when we preallocate it.

Pass dev through to XX_PreallocAndBindIntr() and actually bind it to the
cpu like it was supposed to in the first place, instad of leaving it
floating and moving it to the correct cpu the first time it fires.

This fixes panics while bringing up dtsec on my X5000.

Reviewed by: jhibbits
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D23826

4 years agoUnbreak the 32-bit powerpc builds
jhibbits [Tue, 25 Feb 2020 02:42:43 +0000 (02:42 +0000)]
Unbreak the 32-bit powerpc builds

Force unsigned integer usage by casting to vm_offset_t, to avoid integer
overflow, from r358305

4 years agopowerpc/booke: Use a pseudo-DMAP for the device mappings on booke64
jhibbits [Tue, 25 Feb 2020 01:40:22 +0000 (01:40 +0000)]
powerpc/booke: Use a pseudo-DMAP for the device mappings on booke64

Since powerpc64 has such a large virtual address space, significantly larger
than its physical address space, take advantage of this, and create yet
another DMAP-like instance for the device mappings.  In this case, the
device mapping "DMAP" is in the 0x8000000000000000 - 0xc000000000000000
range, so as not to overlap the physical memory DMAP.

This will allow us to add TLB1 entry coalescing in the future, especially
useful for things like the radeonkms driver, which maps parts of the GPU at
a time, but eventually maps all of it, using up a lot of TLB1 entries (~40).

4 years ago[PowerPC] Fix LLD10 linking of ofw loader on ppc
bdragon [Tue, 25 Feb 2020 00:45:09 +0000 (00:45 +0000)]
[PowerPC] Fix LLD10 linking of ofw loader on ppc

Before this change, LLD10 was creating several extra PT_LOAD sections,
which OFW does not understand.

Like we do for the kernel already, specify the program headers manually.

Additionally, to work around a crash in our base ld.bfd, we need to
actually assign something to the output section. LLD does not need this.

One side effect of this change is the removal of the GNU_STACK header.
This is more correct, since we are using a statically-allocated stack and
RWX mappings across the board this early in boot.

Reviewed by: jhibbits, Fangrui Song <i@maskray.me>
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D23778

4 years agoAlthough most of the NIC drivers are epoch ready, due to peer pressure
glebius [Mon, 24 Feb 2020 21:07:30 +0000 (21:07 +0000)]
Although most of the NIC drivers are epoch ready, due to peer pressure
switch over to opt-in instead of opt-out for epoch.

Instead of IFF_NEEDSEPOCH, provide IFF_KNOWSEPOCH. If driver marks
itself with IFF_KNOWSEPOCH, then ether_input() would not enter epoch
when processing its packets.

Now this will create recursive entrance in epoch in >90% network
drivers, but will guarantee safeness of the transition.

Mark several tested drivers as IFF_KNOWSEPOCH.

Reviewed by: hselasky, jeff, bz, gallatin
Differential Revision: https://reviews.freebsd.org/D23674

4 years agosmsc: remove pre-FreeBSD-10 compat support
emaste [Mon, 24 Feb 2020 19:50:28 +0000 (19:50 +0000)]
smsc: remove pre-FreeBSD-10 compat support

Sponsored by: The FreeBSD Foundation

4 years agomuge: fix rxcsum enable test
emaste [Mon, 24 Feb 2020 19:48:29 +0000 (19:48 +0000)]
muge: fix rxcsum enable test

if_capabilities indicates capabilities supported by the hardware;
if_capenable which are enabled.  Note that rx checksum is still disabled
in the driver at compile time.

Submitted by: Johannes <iz-rpi04@hs-karlsruhe.de>
MFC after: 2 weeks

4 years agoFix IPv6 checksums when exthdrs are present.
bz [Mon, 24 Feb 2020 19:12:20 +0000 (19:12 +0000)]
Fix IPv6 checksums when exthdrs are present.

In two places in ip6_output we are doing (delayed) checksum calculations.
The initial logic came from SCTP in r205075,205104 and later I copied
and adjusted it for the TCP|UDP case in r235958.
The problem was that the original SCTP offsets were already wrong for any
case with extension headers present given IPv6 extension headers are not
part of the pseudo checksum calculations.
The later changes do not help in case there is checksum offloading as for
extension headers (incl. fragments) we do currrently never offload as we
have no infrastructure to know whether the NIC can handle these cases.

Correct the offsets for delayed checksum calculations and properly handle
mbuf flags.  In addition harmonize the almost identical duplicate code.

While here eliminate the now unneeded variable hlen and add an always
missing mtod() call in the 1-b and 3 cases after the introduction of
the mb_unmapped_to_ext() calls.

Reported by: Francis Dupont (fdupont isc.org)
PR: 243675
MFC after: 6 days
Reviewed by: markj (earlier version), gallatin
Differential Revision: https://reviews.freebsd.org/D23760

4 years agoSplit out the stage 1 pte bits and add the stage 2 bits
andrew [Mon, 24 Feb 2020 16:45:31 +0000 (16:45 +0000)]
Split out the stage 1 pte bits and add the stage 2 bits

In preperation for adding bhyve support to arm64 we need to split the
stage 1 and stage 2 pte fields to allow future changes to create stage 2
page tables.

MFC after: 1 month
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D23669

4 years agoAdd a soft-float riscv kernel config
imp [Mon, 24 Feb 2020 16:42:44 +0000 (16:42 +0000)]
Add a soft-float riscv kernel config

GENERICSF is just like GENERIC, only creates a soft-float kernel. Omit it from the
universe build for now.

Reviewed by: philip
Differential Revision: https://reviews.freebsd.org/D23812

4 years agoOnly compile clear_fpu state code when we're building with options FPE.
imp [Mon, 24 Feb 2020 16:41:29 +0000 (16:41 +0000)]
Only compile clear_fpu state code when we're building with options FPE.

Soft float kernels build without floating point, and will fail to build if we
try to include floating point code.

Obtained from: kp@

4 years agoCreate ../compile
imp [Mon, 24 Feb 2020 16:41:16 +0000 (16:41 +0000)]
Create ../compile

Give up the battle to keep extra files in $MACHINE/compile to keep the file in
the tree. Instead, create CDIR (usually ../compile) if it doesn't exist when
we're using a default build location (eg, not using -d). If it does, we do
nothing. This only affects people that do old-school builds, but it's bit me a
dozen times since last summer so time to fix the bug.

4 years agodebug_monitor: Avoid setting the PSR_D flag for 32bits binaries.
cognet [Mon, 24 Feb 2020 16:25:11 +0000 (16:25 +0000)]
debug_monitor: Avoid setting the PSR_D flag for 32bits binaries.

In dbg_monitor_exit(), avoid setting the PSR_D bit if the process is
a 32bits binary. PSR_D is an aarch64-only flags, and for aarch32 processes,
it means "run in big endian".
This should make COMPAT_FREEBSD32 run much better on arm64.

4 years agoRework and simplify Tx DMA mapping in ENA
mw [Mon, 24 Feb 2020 15:35:31 +0000 (15:35 +0000)]
Rework and simplify Tx DMA mapping in ENA

Driver working in LLQ mode in some cases can send only few last segments
of the mbuf using DMA engine, and the rest of them are sent to the
device using direct PCI transaction. To map the only necessary data, two DMA
maps were used. That solution was very rough and was causing a bug - if
both maps were used (head_map and seg_map), there was a race in between
two flows on two queues and the device was receiving corrupted
data which could be further received on the other host if the Tx cksum
offload was enabled.

As it's ok to map whole mbuf and then send to the device only needed
segments, the design was simplified to use only single DMA map.

The driver version was updated to v2.1.1 as it's important bug fix.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (15 of many)
kaktus [Mon, 24 Feb 2020 10:51:26 +0000 (10:51 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (15 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.

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (14 of many)
kaktus [Mon, 24 Feb 2020 10:47:18 +0000 (10:47 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (14 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23639

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (13 of many)
kaktus [Mon, 24 Feb 2020 10:45:22 +0000 (10:45 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (13 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23635

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (12 of many)
kaktus [Mon, 24 Feb 2020 10:42:56 +0000 (10:42 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (12 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23637

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (11 of many)
kaktus [Mon, 24 Feb 2020 10:41:22 +0000 (10:41 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (11 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23636

4 years agoarm64: rockchip: rk808: Only init regulator not enabled
manu [Mon, 24 Feb 2020 10:40:35 +0000 (10:40 +0000)]
arm64: rockchip: rk808: Only init regulator not enabled

If a regulator is already enabled, do not set its value to the minimum
supported on the board.
This fixes booting on rock64 where we set some regulator to the minimal value
while the IPs needs more based on what the bootloader configured.

MFC after: 1 week

4 years agoarm64: rockchip: rk_i2c: Bump to DELAY to 1000
manu [Mon, 24 Feb 2020 10:38:38 +0000 (10:38 +0000)]
arm64: rockchip: rk_i2c: Bump to DELAY to 1000

In polling mode with use DELAY to wait for interrupts. The value was
too low for RK3328.

MFC after: 1 week

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (10 of many)
kaktus [Mon, 24 Feb 2020 10:37:56 +0000 (10:37 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (10 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23629

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (8 of many)
kaktus [Mon, 24 Feb 2020 10:35:58 +0000 (10:35 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (8 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23628

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (8 of many)
kaktus [Mon, 24 Feb 2020 10:33:51 +0000 (10:33 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (8 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.

Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23627

4 years agoAlways check return value from acpi_GetInteger() after r358219.
hselasky [Mon, 24 Feb 2020 09:31:30 +0000 (09:31 +0000)]
Always check return value from acpi_GetInteger() after r358219.
If a failure happens reading the lid state, assume the lid is opened.

Suggested by: cem @
Differential Revision: https://reviews.freebsd.org/D23724
PR: 240881
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoThe last argument to swp_pager_getswapspace is always 1. Remove that argument.
dougm [Mon, 24 Feb 2020 04:01:09 +0000 (04:01 +0000)]
The last argument to swp_pager_getswapspace is always 1. Remove that argument.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D23810

4 years agoBump CONFIGVERS to 600017.
imp [Sun, 23 Feb 2020 23:39:55 +0000 (23:39 +0000)]
Bump CONFIGVERS to 600017.

This change reflects the ability to change machine_arch in a config file. This
is useful for including one config in another and changing the machine_arch
in the second one.

4 years agoRelax machine directives a little.
imp [Sun, 23 Feb 2020 23:36:56 +0000 (23:36 +0000)]
Relax machine directives a little.

Currently, you can have multiple machine directives if they are otherwise
identical. Relax this so that only the machinename part is the same. This allows
one to change the machine arch in a different config file you've included easily.

4 years agoWebsite announcement of the 9.0 release wasn't a Valentine's day accident.
sevan [Sun, 23 Feb 2020 23:29:53 +0000 (23:29 +0000)]
Website announcement of the 9.0 release wasn't a Valentine's day accident.

4 years agoUse MACHINE_ARCH instead of TARGET_ARCH
imp [Sun, 23 Feb 2020 19:04:15 +0000 (19:04 +0000)]
Use MACHINE_ARCH instead of TARGET_ARCH

TARGET_ARCH is only for use in Makefile.inc1 contexts. MACHINE_ARCH is the
preferred thing to set.  Makefile.inc1 sets MACHINE_ARCH in the cross build
case, and make sets it in the native build case. This will fix anybody doing a
native build. Add a comment for why we have to do this dance so when/if the
problem with CFLAGS is fixed for the kernel this workaround can be removed.

4 years agoAllow swap_pager_putpages() to allocate one block at a time.
markj [Sun, 23 Feb 2020 17:59:51 +0000 (17:59 +0000)]
Allow swap_pager_putpages() to allocate one block at a time.

The minimum allocation size of 4 blocks is an old policy that came with
the "new" swap pager in r42957.  Since then the blist allocator has
gotten better at reducing fragmentation; for example, with r349777 it
can return a range that spans multiple leaves.  When swap space is close
to being exhaused, the minimum of 4 blocks most likely exacerbates
memory pressure, so reduce it to 1.

Reported by: alc
Tested by: pho
Reviewed by: alc, dougm, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23763

4 years agoloader: alloc_pread() should set errno if malloc fails
tsoome [Sun, 23 Feb 2020 15:21:15 +0000 (15:21 +0000)]
loader: alloc_pread() should set errno if malloc fails

We may want to find out why alloc_pread() failed.

4 years agosys/kern: quiet -Wwrite-strings
rlibby [Sun, 23 Feb 2020 03:32:16 +0000 (03:32 +0000)]
sys/kern: quiet -Wwrite-strings

Quiet a variety of Wwrite-strings warnings in sys/kern at low-impact
sites.  This patch avoids addressing certain others which would need to
plumb const through structure definitions.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D23798

4 years agovfs: quiet -Wwrite-strings
rlibby [Sun, 23 Feb 2020 03:32:11 +0000 (03:32 +0000)]
vfs: quiet -Wwrite-strings

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D23797

4 years agosys/vm: quiet -Wwrite-strings
rlibby [Sun, 23 Feb 2020 03:32:04 +0000 (03:32 +0000)]
sys/vm: quiet -Wwrite-strings

Discussed with: kib
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D23796

4 years agoAdd NetBSD 9.0 using the date the releng announcement was made.
sevan [Sat, 22 Feb 2020 23:36:10 +0000 (23:36 +0000)]
Add NetBSD 9.0 using the date the releng announcement was made.
NetBSD-7 branch wont be receiving any more releases.

4 years agoFix NFS client deadlock when read reports truncated node.
kib [Sat, 22 Feb 2020 20:50:30 +0000 (20:50 +0000)]
Fix NFS client deadlock when read reports truncated node.

If node attribute returned in the reply for read rpc indicate
truncation, and it happens that the vnode is exclusively locked,
update of the node attributes would try to shrink vnode size.  Since
during the read some vnode pages were busied by the reading thread,
vnode_pager_setsize() deadlocks waiting for the busy state owned by
the caller.

Use a thread-local flag to indicate that NFS read owns some (s)busy
pages states and postpone the call to vnode_pager_setsize() until the
thread relinguishes the ownership.

Diagnosed by: rlibby
Tested by: pho, rlibby
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoAdd td_pflags2, yet another thread-private flags word.
kib [Sat, 22 Feb 2020 20:43:04 +0000 (20:43 +0000)]
Add td_pflags2, yet another thread-private flags word.

There is no more free bits in td_pflags.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoAdd myself (salvadore) as a ports committer
salvadore [Sat, 22 Feb 2020 17:56:09 +0000 (17:56 +0000)]
Add myself (salvadore) as a ports committer

Approved by: gerald (mentor)

4 years agoConstify uma_zcache_create() and uma_zsecond_create()'s "name" argument.
markj [Sat, 22 Feb 2020 17:44:28 +0000 (17:44 +0000)]
Constify uma_zcache_create() and uma_zsecond_create()'s "name" argument.

It is already internally handled as a pointer to a const string, in
particular by uma_zcreate().

Fix indentation while here.

MFC after: 1 week

4 years agovm_radix: prefer __builtin_unreachable() to an unreachable panic()
kevans [Sat, 22 Feb 2020 16:20:04 +0000 (16:20 +0000)]
vm_radix: prefer __builtin_unreachable() to an unreachable panic()

This provides the needed hint to GCC and offers an annotation for readers to
observe that it's in-fact impossible to hit this point. We'll get hit with a
a -Wswitch error if the enum applicable to the switch above were to get
expanded without the new value(s) being handled.

4 years agoriscv: Set MACHINE_ARCH correctly
kp [Sat, 22 Feb 2020 13:23:27 +0000 (13:23 +0000)]
riscv: Set MACHINE_ARCH correctly

MACHINE_ARCH sets the hw.machine_arch sysctl in the kernel. In userspace
it sets MACHINE_ARCH in bmake, which bsd.cpu.mk uses to configure the
target ABI for ports.

For riscv64sf builds (i.e. soft-float) that needs to be riscv64sf, but
the sysctl didn't reflect that. It is static.

Set the define from the riscv makefile so that we correctly reflect our
actual build (i.e. riscv64 or riscv64sf), depending on what TARGET_ARCH
we were built with.

That still doesn't satisfy userspace builds (e.g. bmake), so check if
we're building with a software-floating point toolchain there. That
check doesn't work in the kernel, because it never uses floating point.

Reviewed by: philip (previous version), mhorne
Sponsored by: Axiado
Differential Revision: https://reviews.freebsd.org/D23741

4 years agobsdbox: fix build
kevans [Sat, 22 Feb 2020 04:02:07 +0000 (04:02 +0000)]
bsdbox: fix build

We've grown to also require libthr and libprivatestd to be explicitly linked
in here, so do this now to fix freebsd-wifi-build.

Submitted by: Pavel Timofeev <timp87 gmail com>

4 years agoAdd an atomic-free tick moderated lazy update variant of SMR.
jeff [Sat, 22 Feb 2020 03:44:10 +0000 (03:44 +0000)]
Add an atomic-free tick moderated lazy update variant of SMR.

This enables very cheap read sections with free-to-use latencies and memory
overhead similar to epoch.  On a recent AMD platform a read section cost
1ns vs 5ns for the default SMR.  On Xeon the numbers should be more like 1
ns vs 11.  The memory consumption should be proportional to the product
of the free rate and 2*1/hz while normal SMR consumption is proportional
to the product of free rate and maximum read section time.

While here refactor the code to make future additions more
straightforward.

Name the overall technique Global Unbound Sequences (GUS) and adjust some
comments accordingly.  This helps distinguish discussions of the general
technique (SMR) vs this specific implementation (GUS).

Discussed with: rlibby, markj

4 years agosh: fix read builtin on 32-bit systems
kevans [Sat, 22 Feb 2020 03:14:05 +0000 (03:14 +0000)]
sh: fix read builtin on 32-bit systems

Specifically, any system with a 32-bit size_t; -residue is calculated as a
32-bit *then* promoted to the 64-bit off_t and the result is ultimately
wrong. This resulted in what would appear to be truncated output, as only
the first line would be read.

Correct it by just making residue an off_t to begin with, since this is what
lseek will take anyways.

Reported by: antoine, dim
Triaged by: cem
Tested by: kevans
X-MFC-With: r358152

4 years agopowerpc/booke: Fix handling of pvh_global_lock and pmap lock
jhibbits [Sat, 22 Feb 2020 01:31:06 +0000 (01:31 +0000)]
powerpc/booke: Fix handling of pvh_global_lock and pmap lock

ptbl_alloc() is expected to return with the pvh_global_lock and pmap
lock held.  However, it will return with them unlocked if nosleep is
specified.

Along with this, fix lock ordering of pvh_global_lock with respect to
the pmap lock in other places.

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

4 years agoWe pass a pointer to the flags to dabitsysctl, not an integer. Adjust the
imp [Fri, 21 Feb 2020 22:44:22 +0000 (22:44 +0000)]
We pass a pointer to the flags to dabitsysctl, not an integer. Adjust the
handler to accept a poitner to a u_int. To make the type of the softc flags
stable and defined, make it a u_int. Cast the enum types to u_int for arg2 so
when passing to dabitsysctl it's a u_int.

Noticed by: emax@
Differential Revision: https://reviews.freebsd.org/D23785

4 years agoFix formatting for tps values between 99.95 and 99.99; previously
trasz [Fri, 21 Feb 2020 20:57:32 +0000 (20:57 +0000)]
Fix formatting for tps values between 99.95 and 99.99; previously
it would display as "100.0", breaking vertical alignment.

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

4 years agofetch(3): plug some leaks
kevans [Fri, 21 Feb 2020 18:21:57 +0000 (18:21 +0000)]
fetch(3): plug some leaks

In the successful case, sockshost is not freed prior to return.

The failure case can now be hit after fetch_reopen(), which was not true
before. Thus, we need to make sure to clean up all of the conn resources
which will also close sd. For all of the points prior to fetch_reopen(), we
continue to just close sd.

CID: 14195981419616

4 years agox86/identcpu.c whitespace cleanup.
kib [Fri, 21 Feb 2020 16:55:28 +0000 (16:55 +0000)]
x86/identcpu.c whitespace cleanup.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoprint_svm_info: decode a CPUID 0x8000000a.edx bit 20.
kib [Fri, 21 Feb 2020 16:41:17 +0000 (16:41 +0000)]
print_svm_info: decode a CPUID 0x8000000a.edx bit 20.

This is SVM features word, the bit is defined in "PPR for AMD Family
17h Model 31h B0", document 55803 Rev 0.54.

N.B. GuesSpecCtl (no 't') is the spelling from the document.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 3 days

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (7 of many)
kaktus [Fri, 21 Feb 2020 16:32:17 +0000 (16:32 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (7 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.

Mark all low hanging fruits as MPSAFE.

Reviewed by: markj
Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23626

4 years agoMark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (6 of many)
kaktus [Fri, 21 Feb 2020 16:23:00 +0000 (16:23 +0000)]
Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (6 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.

Mark all nodes in pf, pfsync and carp as MPSAFE.

Reviewed by: kp
Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23634

4 years agoFix broken MLX5_IB_INDEX() macro in mlx5ib(4).
hselasky [Fri, 21 Feb 2020 10:14:02 +0000 (10:14 +0000)]
Fix broken MLX5_IB_INDEX() macro in mlx5ib(4).

The index should be computed as distance from arg[0] and not
the beginning of struct mlx5_ib_congestion .

While at it fix a use of zero length array to avoid depending
on undefined compiler behaviour.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoMake sure the ACPI lid state is updated during boot and after resume.
hselasky [Fri, 21 Feb 2020 09:52:20 +0000 (09:52 +0000)]
Make sure the ACPI lid state is updated during boot and after resume.
While at it update the sysctl(9) description for the lid state.

Differential Revision: https://reviews.freebsd.org/D23724
PR: 240881
Submitted by: Yuri Pankov <yuripv@yuripv.me>
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoBump _FreeBSD_version after the recent linuxkpi changes
manu [Fri, 21 Feb 2020 09:29:56 +0000 (09:29 +0000)]
Bump _FreeBSD_version after the recent linuxkpi changes

4 years agolinuxkpi: Move shmem related functions in it's own file
manu [Fri, 21 Feb 2020 09:28:45 +0000 (09:28 +0000)]
linuxkpi: Move shmem related functions in it's own file

For drmkpi (D23085) we don't want the Linux struct file as we don't emulate
everything. Also the prototypes should be in shmem_fs.h to have 100%
compatibility with Linux.

Reviewed by: hselasky
MFC after: Maybe
Differential Revision: https://reviews.freebsd.org/D23764

4 years agoncurses: set the proper version in the updating message
bapt [Fri, 21 Feb 2020 08:00:42 +0000 (08:00 +0000)]
ncurses: set the proper version in the updating message

Reported by: @jlduran (github)

4 years agoRework second part of r357558. Unroll the macro and allocate memory in
glebius [Fri, 21 Feb 2020 04:18:15 +0000 (04:18 +0000)]
Rework second part of r357558.  Unroll the macro and allocate memory in
sleepable manner before entering the epoch for the send.

4 years agoRevert one half of previous change r357558. Don't enter the epoch on
glebius [Fri, 21 Feb 2020 04:10:41 +0000 (04:10 +0000)]
Revert one half of previous change r357558.  Don't enter the epoch on
sends to control socket.  Control socket messages can run constructors
of nodes and other stuff that is allowed to M_WAITOK.

PR: 244241

4 years agovfs: stop duplicating vnode work in audit during path lookup
mjg [Fri, 21 Feb 2020 01:44:31 +0000 (01:44 +0000)]
vfs: stop duplicating vnode work in audit during path lookup

Duplicating the work was putting an avoidable requirement that the filedesc
lock is held across the entire operation (otherwise by the time audit reads
vnode pointers another thread in the same process can chdir somewhere else,
making audit log things using different vnode than the one which will be
used for actual lookup).

Do the obvious thing and pass down vnodes which will be used.

4 years agoaudit: provide audit_canon_path variant which accepts vnodes
mjg [Fri, 21 Feb 2020 01:40:49 +0000 (01:40 +0000)]
audit: provide audit_canon_path variant which accepts vnodes

4 years agoaudit: simplify path resolving logic
mjg [Fri, 21 Feb 2020 01:40:20 +0000 (01:40 +0000)]
audit: simplify path resolving logic

4 years agoaudit: rely on use count instead of hold count in audit_canon_path
mjg [Fri, 21 Feb 2020 01:39:51 +0000 (01:39 +0000)]
audit: rely on use count instead of hold count in audit_canon_path

4 years agoclamp kernel dump compression level when using gzip
vangyzen [Thu, 20 Feb 2020 23:53:48 +0000 (23:53 +0000)]
clamp kernel dump compression level when using gzip

If the configured compression level for kernel dumps
it outside the supported range, clamp it to the closest
supported level.  Previously, dumpon would fail.

zstd already does this internally, so the compressor
needs no change.

Reviewed by: cem markj
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23765

4 years agotruncate(2): extending the file is required by POSIX 2008
vangyzen [Thu, 20 Feb 2020 23:47:09 +0000 (23:47 +0000)]
truncate(2): extending the file is required by POSIX 2008

Update the man page to mention that extending a file with truncate(2)
is required by POSIX as of 2008.

Reviewed by: bcr
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23354

4 years agodtc: remove unknown option printf, since getopt will print it
bcran [Thu, 20 Feb 2020 21:29:59 +0000 (21:29 +0000)]
dtc: remove unknown option printf, since getopt will print it

Since we don't set opterr to 0, getopt prints a message when it
encounters an unknown/invalid option. We therefore don't need to
print our own message in the default handler.

Reviewed by: kevans, theraven
Differential Revision: https://reviews.freebsd.org/D23662

4 years agoFix a bug in r358168, do not call sigfastblock_setpend() under a mutex.
kib [Thu, 20 Feb 2020 21:25:12 +0000 (21:25 +0000)]
Fix a bug in r358168, do not call sigfastblock_setpend() under a mutex.

PR: 244250
Reported and tested by: lwhsu
Sponsored by: The FreeBSD Foundation

4 years ago- Implement -h (human readable) for the size of the underlying block disk.
csjp [Thu, 20 Feb 2020 21:12:10 +0000 (21:12 +0000)]
- Implement -h (human readable) for the size of the underlying block disk.
  Currently, the size of the swap device is unconditionally reported using
  blocks, even if -h has been used.
- While here, switch to CONVERT_BLOCKS() instead of CONVERT() which will
  avoid overflowing size counters (in human readable form see: r196244)
- Update the column headers to reflect that a size is being reported instead
  of the block size units being used

Before:

$ swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/swapfs   1048576        0  1048576     0%
$

After:

$ swapinfo -h
Device           Size     Used    Avail Capacity
/dev/gpt/swapfs    1.0G       0B     1.0G     0%
$

Differential Revision: https://reviews.freebsd.org/D23758
Reviewed by: kevans
MFC after: 3 weeks

4 years agobhyve: enable virtio-net mergeable rx buffers for tap(4)
vmaffione [Thu, 20 Feb 2020 21:07:23 +0000 (21:07 +0000)]
bhyve: enable virtio-net mergeable rx buffers for tap(4)

This patch adds a new netbe_peek_recvlen() function to the net
backend API. The new function allows the virtio-net receive code
to know in advance how many virtio descriptors chains will be
needed to receive the next packet. As a result, the implementation
of the virtio-net mergeable rx buffers feature becomes efficient,
so that we can enable it also with the tap(4) backend. For the
tap(4) backend, a bounce buffer is introduced to implement the
peeck_recvlen() callback, which implies an additional packet copy
on the receive datapath. In the future, it should be possible to
remove the bounce buffer (and so the additional copy), by
obtaining the length of the next packet from kevent data.

Reviewed by:    grehan, aleksandr.fedorov@itglobal.com
MFC after:      1 week
Differential Revision: https://reviews.freebsd.org/D23472

4 years agovirtio: Pass the interrupt type in mmio mode
kp [Thu, 20 Feb 2020 17:26:08 +0000 (17:26 +0000)]
virtio: Pass the interrupt type in mmio mode

When we register an interrupt handler we need to pass the intr_type along in
bus_setup_intr().

The interrupt type matters because it is used to decide if we need to enter
NET_EPOCH. That meant that vtmmio-based if_vtnet did not, which led to panics
with INVARIANTS set.

Sponsored by: Axiado

4 years agolinuxkpi: Add str_has_prefix
manu [Thu, 20 Feb 2020 17:20:50 +0000 (17:20 +0000)]
linuxkpi: Add str_has_prefix

This function test if the string str begins with the string pointed
at by prefix.

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23767

4 years agolinuxkpi: Add list_is_first function
manu [Thu, 20 Feb 2020 17:19:16 +0000 (17:19 +0000)]
linuxkpi: Add list_is_first function

This function just test if the element is the first of the list.

Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23766

4 years agoPrint out some newly added PCIe extended capabilities and subclasses.
kib [Thu, 20 Feb 2020 17:10:25 +0000 (17:10 +0000)]
Print out some newly added PCIe extended capabilities and subclasses.

Taken from
https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week

4 years agoAdd more values for PCI capabilities, PCIe extended capabilities, and subclasses.
kib [Thu, 20 Feb 2020 17:08:52 +0000 (17:08 +0000)]
Add more values for PCI capabilities, PCIe extended capabilities, and subclasses.

Taken from
https://pcisig.com/sites/default/files/files/PCI_Code-ID_r_1_11__v24_Jan_2019.pdf

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after: 1 week

4 years agomake sysent for r358172 ("vfs: add realpathat syscall")
mjg [Thu, 20 Feb 2020 16:58:57 +0000 (16:58 +0000)]
make sysent for r358172 ("vfs: add realpathat syscall")

4 years agovfs: add realpathat syscall
mjg [Thu, 20 Feb 2020 16:58:19 +0000 (16:58 +0000)]
vfs: add realpathat syscall

realpath(3) is used a lot e.g., by clang and is a major source of getcwd
and fstatat calls. This can be done more efficiently in the kernel.

This works by performing a regular lookup while saving the name and found
parent directory. If the terminal vnode is a directory we can resolve it using
usual means. Otherwise we can use the name saved by lookup and resolve the
parent.

See the review for sample syscall counts.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23574

4 years agoUse OLD_LIBS instead of OLD_FILES so the user get a chance to keep them around if...
bapt [Thu, 20 Feb 2020 16:38:30 +0000 (16:38 +0000)]
Use OLD_LIBS instead of OLD_FILES so the user get a chance to keep them around if needed

Reported by: tijl

4 years agoRevert r358153: it is causing unexpected issues with the build system.
pfg [Thu, 20 Feb 2020 15:52:36 +0000 (15:52 +0000)]
Revert r358153: it is causing unexpected issues with the build system.

4 years agoRemove an unused timer type.
tuexen [Thu, 20 Feb 2020 15:37:44 +0000 (15:37 +0000)]
Remove an unused timer type.

MFC after: 1 week

4 years agoDo not read sigfastblock word on syscall entry.
kib [Thu, 20 Feb 2020 15:34:02 +0000 (15:34 +0000)]
Do not read sigfastblock word on syscall entry.

On machines with SMAP, fueword executes two serializing instructions
which can be seen in microbenchmarks.

As a measure to restore microbenchmark numbers, only read the word on
the attempt to deliver signal in ast().  If the word is set, signal is
not delivered and word is kept, preventing interruption of
interruptible sleeps by signals until userspace calls
sigfastblock(UNBLOCK) which clears the word.

This way, the spurious EINTR that userspace can see while in critical
section is on first interruptible sleep, if a signal is pending, and
on signal posting.  It is believed that it is not important for rtld
and lbithr critical sections.  It might be visible for the application
code e.g. for the callback of dl_iterate_phdr(3), but again the belief
is that the non-compliance is acceptable.  Most important is that the
retry of the sleeping syscall does not interrupt unless additional
signal is posted.

For now I added the knob kern.sigfastblock_fetch_always to enable the
word read on syscall entry to be able to diagnose possible issues due
to spurious EINTR.

While there, do some code restructuting to have all sigfastblock()
handling located in kern_sig.c.

Reviewed by: jeff
Discussed with: mjg
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D23622

4 years agoip6_output: improve extension header handling
bz [Thu, 20 Feb 2020 10:56:12 +0000 (10:56 +0000)]
ip6_output: improve extension header handling

Move IPv6 source address checks from after extension header heandling
to the top of the function. If we do not pass these checks there is
no reason to do a lot of work upfront.

Fold extension header preparations and length calculations together into
a single branch and macro rather than doing them sequentially.
Likewise move extension header concatination into a single branch block
only doing it if we recorded any extension header length length.

Reviewed by: melifaro (earlier version), markj, gallatin
Sponsored by: Netflix (partially, originally)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D23740