]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agorc.firewall: Merge two identical conditions into one.
Mark Johnston [Thu, 23 Jul 2020 15:03:28 +0000 (15:03 +0000)]
rc.firewall: Merge two identical conditions into one.

No functional change intended.

PR: 247949
Submitted by: Jose Luis Duran <jlduran@gmail.com>
MFC after: 1 week

3 years agoAdd missing newlines.
Alexander Motin [Thu, 23 Jul 2020 14:33:25 +0000 (14:33 +0000)]
Add missing newlines.

MFC after: 3 days

3 years agoMFOpenZFS: Fix zpool history unbounded memory usage
Mark Johnston [Thu, 23 Jul 2020 14:21:45 +0000 (14:21 +0000)]
MFOpenZFS: Fix zpool history unbounded memory usage

In original implementation, zpool history will read the whole history
before printing anything, causing memory usage goes unbounded. We fix
this by breaking it into read-print iterations.

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: Matt Ahrens <matt@delphix.com>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #9516

Note, this change changes the libzfs.so ABI by modifying the prototype
of zpool_get_history().  Since libzfs is effectively private to the base
system it is anticipated that this will not be a problem.

PR: 247557
Obtained from: OpenZFS
Reported and tested by: Sam Vaughan <samjvaughan@gmail.com>
Discussed with: freqlabs
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25745
openzfs/zfs@7125a109dcc55628336ff3f58e59e503f4d7694d

3 years agocuse: Stop checking for failures from malloc(M_WAITOK).
Mark Johnston [Thu, 23 Jul 2020 14:03:37 +0000 (14:03 +0000)]
cuse: Stop checking for failures from malloc(M_WAITOK).

PR: 240545
Submitted by: Andrew Reiter <arr@watson.org>
Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25765

3 years agontb: Stop checking for failures from malloc(M_WAITOK).
Mark Johnston [Thu, 23 Jul 2020 14:03:24 +0000 (14:03 +0000)]
ntb: Stop checking for failures from malloc(M_WAITOK).

PR: 240545
Submitted by: Andrew Reiter <arr@watson.org>
Reviewed by: cem, mav
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25768

3 years agovm: annotate swap_reserved with __exclusive_cache_line
Mateusz Guzik [Thu, 23 Jul 2020 08:42:16 +0000 (08:42 +0000)]
vm: annotate swap_reserved with __exclusive_cache_line

The counter keeps being updated all the time and variables read afterwards
share the cacheline. Note this still fundamentally does not scale and needs
to be replaced, in the meantime gets a bandaid.

brk1_processes -t 52 ops/s:
before: 8598298
after:  9098080

3 years agoDetect and handle an invalid reassembly constellation, which results in
Michael Tuexen [Thu, 23 Jul 2020 01:35:24 +0000 (01:35 +0000)]
Detect and handle an invalid reassembly constellation, which results in
a memory leak.

Thanks to Felix Weinrank for finding this issue using fuzz testing the
userland stack.

MFC after: 1 week

3 years agoCorrect a type-mismatch between xdr_long and the variable "bad".
Brooks Davis [Wed, 22 Jul 2020 23:39:58 +0000 (23:39 +0000)]
Correct a type-mismatch between xdr_long and the variable "bad".

Way back in r28911 (August 1997, CVS rev 1.22) we imported a NetBSD
information leak fix via OpenBSD.  Unfortunatly we failed to track the
followup commit that fixed the type of the error code.  Apply the change
from int to long now.

Reviewed by: emaste
Found by: CHERI
Obtained from: CheriBSD
MFC after: 3 days
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25779

3 years agoUse SI_ORDER_(FOURTH|FIFTH) rather than bespoke versions.
Brooks Davis [Wed, 22 Jul 2020 23:35:41 +0000 (23:35 +0000)]
Use SI_ORDER_(FOURTH|FIFTH) rather than bespoke versions.

No functional change.

When these SYSINITs were added these macros didn't exist.

Reviewed by: imp
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25758

3 years agoModify writing to mirrored pNFS DSs to prepare for use of ext_pgs mbufs.
Rick Macklem [Wed, 22 Jul 2020 23:33:37 +0000 (23:33 +0000)]
Modify writing to mirrored pNFS DSs to prepare for use of ext_pgs mbufs.

This patch modifies writing to mirrored pNFS DSs slightly so that there is
only one m_copym() call for a mirrored pair instead of two of them.
This call replaces the custom nfsm_copym() call, which is no longer needed
and deleted by this patch. The patch does introduce a new nfsm_split()
function that only calls m_split() for the non-ext_pgs case.
The semantics of nfsm_uiombuflist() is changed to include code that nul
pads the generated mbuf list. This was done by nfsm_copym() prior to this patch.

The main reason for this change is that it allows the data to be a list
of ext_pgs mbufs, since the m_copym() is for the entire mbuf list.
This support will be added in a future commit.

This patch only affects writing to mirrored flexible file layout pNFS servers.

3 years agoAdd missing space after switch.
John Baldwin [Wed, 22 Jul 2020 22:51:14 +0000 (22:51 +0000)]
Add missing space after switch.

Reviewed by: br, emaste
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25778

3 years agoAvoid reading one byte before the path buffer.
Brooks Davis [Wed, 22 Jul 2020 21:44:51 +0000 (21:44 +0000)]
Avoid reading one byte before the path buffer.

This happens when there's only one component (e.g. "/foo"). This
(mostly-harmless) bug has been present since June 1990 when it was
commited to mountd.c SCCS version 5.9.

Note: the bug is on the second changed line, the first line is changed
for visual consistency.

Reviewed by: cem, emaste, mckusick, rmacklem
Found with: CHERI
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D25759

3 years agoUntie nmi_handle_intr() from DEV_ISA.
Alexander Motin [Wed, 22 Jul 2020 20:15:21 +0000 (20:15 +0000)]
Untie nmi_handle_intr() from DEV_ISA.

The only part of nmi_handle_intr() depending on ISA is isa_nmi(), which is
already wrapped.  Entering debugger on NMI does not really depend on ISA.

MFC after: 2 weeks

3 years agommccam: Add support for 1.2V and 1.8V eMMC
Emmanuel Vadot [Wed, 22 Jul 2020 19:08:05 +0000 (19:08 +0000)]
mmccam: Add support for 1.2V and 1.8V eMMC

If the card reports that it support 1.2V or 1.8V signaling switch to this voltage.

Submitted by: kibab

3 years agommccam: Add support for 1.8V sdcard
Emmanuel Vadot [Wed, 22 Jul 2020 19:04:45 +0000 (19:04 +0000)]
mmccam: Add support for 1.8V sdcard

If the card reports that it support 1.8V signaling switch to this voltage.
While here update the list of mode for mmccam.

Submitted by: kibab

3 years agoaw_mmc: Start a mmccam discovery when the CD handler is called.
Emmanuel Vadot [Wed, 22 Jul 2020 18:33:36 +0000 (18:33 +0000)]
aw_mmc: Start a mmccam discovery when the CD handler is called.

Submitted by: kibab

3 years agommccam: Add a generic mmccam_start_discovery function
Emmanuel Vadot [Wed, 22 Jul 2020 18:30:17 +0000 (18:30 +0000)]
mmccam: Add a generic mmccam_start_discovery function

This is a generic function start a scan request for the given
cam_sim.
Other driver can now just use this function to request a new rescan.

Submitted by: kibab

3 years agommccam: Use a sbuf for the mmc ident function
Emmanuel Vadot [Wed, 22 Jul 2020 18:21:37 +0000 (18:21 +0000)]
mmccam: Use a sbuf for the mmc ident function

While here fix a typo.

3 years agoFix sys.geom.class.eli.onetime_test.onetime after r363402
Li-Wen Hsu [Wed, 22 Jul 2020 17:37:11 +0000 (17:37 +0000)]
Fix sys.geom.class.eli.onetime_test.onetime after r363402

PR: 247954
X-MFC with: r363402
Sponsored by: The FreeBSD Foundation

3 years agommc_xpt: Fix debug messages
Emmanuel Vadot [Wed, 22 Jul 2020 17:36:28 +0000 (17:36 +0000)]
mmc_xpt: Fix debug messages

PROBE_RESET was printed for PROBE_IDENTIFY, fix this.
While here add one for the PROBE_RESET.

Submitted by: kibab

3 years agopkg-bootstrap: complain on improper `pkg bootstrap` usage
Kyle Evans [Wed, 22 Jul 2020 17:33:35 +0000 (17:33 +0000)]
pkg-bootstrap: complain on improper `pkg bootstrap` usage

Right now, the bootstrap will gloss over things like pkg bootstrap -x or
pkg bootstrap -f pkg. Make it more clear that this is incorrect, and hint
at the correct formatting.

Reported by: jhb (IIRC via IRC)
Approved by: bapt, jhb, manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D24750

3 years agousb(4): Stop checking for failures from malloc(M_WAITOK).
Mark Johnston [Wed, 22 Jul 2020 14:32:47 +0000 (14:32 +0000)]
usb(4): Stop checking for failures from malloc(M_WAITOK).

Handle the fact that parts of usb(4) can be compiled into the boot
loader, where M_WAITOK does not guarantee a successful allocation.

PR: 240545
Submitted by: Andrew Reiter <arr@watson.org> (original version)
Reviewed by: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25706

3 years agoAdd tests for "add", "change" and "delete" functionality of /sbin/route.
Tom Jones [Wed, 22 Jul 2020 13:49:54 +0000 (13:49 +0000)]
Add tests for "add", "change" and "delete" functionality of /sbin/route.

Add tests to cover "add", "change" and "delete" functionality of /sbin/route
for ipv4 and ipv6. These tests for the existing route tool are the first step
towards creating libroute.

Submitted by:   Ahsan Barkati
Sponsored by:   Google, Inc. (GSoC 2020)
Reviewed by:    kp, thj
Approved by:    bz (mentor)
MFC after:      1 month
Differential Revision:  https://reviews.freebsd.org/D25220

3 years agogeli(8): Add missing commands in the EXAMPLES section
Gordon Bergling [Wed, 22 Jul 2020 13:00:56 +0000 (13:00 +0000)]
geli(8): Add missing commands in the EXAMPLES section

- Add a missing 'geli attach' command
- Fix the passphrase prompt for a 'geli attach' command

Reported by: Fabian Keil <freebsd-listen at fabiankeil dot de>
Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D25761

3 years agolockmgr: add adaptive spinning
Mateusz Guzik [Wed, 22 Jul 2020 12:30:31 +0000 (12:30 +0000)]
lockmgr: add adaptive spinning

It is very conservative. Only spinning when LK_ADAPTIVE is passed, only on
exclusive lock and never when any waiters are present. buffer cache is remains
not spinning.

This reduces total sleep times during buildworld etc., but it does not shorten
total real time (culprits are contention in the vm subsystem along with slock +
upgrade which is not covered).

For microbenchmarks: open3_processes -t 52 (open/close of the same file for
writing) ops/s:
before: 258845
after: 801638

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D25753

3 years agoConsistently use gctl_get_provider instead of home-grown variants.
Xin LI [Wed, 22 Jul 2020 02:15:21 +0000 (02:15 +0000)]
Consistently use gctl_get_provider instead of home-grown variants.

Reviewed by: cem, imp
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D25739

3 years agogctl_get_class, gctl_get_geom and gctl_get_provider: provide feedback
Xin LI [Wed, 22 Jul 2020 02:14:27 +0000 (02:14 +0000)]
gctl_get_class, gctl_get_geom and gctl_get_provider: provide feedback
when the requested argument is missing.

Reviewed by: cem
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D25738

3 years agolibbe: annotate lbh as __unused in be_is_auto_snapshot_name
Kyle Evans [Wed, 22 Jul 2020 02:09:10 +0000 (02:09 +0000)]
libbe: annotate lbh as __unused in be_is_auto_snapshot_name

lbh is included for consistency with other functions and in case
future work needs to use it, but it is currently unused. Mark it,
and a post-OpenZFS-import world will be able to raise WARNS of
libbe to the default (pending some minor changes to openzfs libzfs).

MFC after: 3 days

3 years agogetty appears to date from 3rd edition research unix. That's the oldest man page
Warner Losh [Wed, 22 Jul 2020 00:44:47 +0000 (00:44 +0000)]
getty appears to date from 3rd edition research unix. That's the oldest man page
on TUHS and its 'unix 1972' restoration effort has assembler sources that look
like simpler version of what's in the 5th edition.

3 years agoINTRNG: only shuffle for !EARLY_AP_STARTUP
Mitchell Horne [Tue, 21 Jul 2020 22:47:02 +0000 (22:47 +0000)]
INTRNG: only shuffle for !EARLY_AP_STARTUP

During device attachment, all interrupt sources will bind to the BSP,
as it is the only processor online. This means interrupts must be
redistributed ("shuffled") later, during SI_SUB_SMP.

For the EARLY_AP_STARTUP case, this is no longer true. SI_SUB_SMP will
execute much earlier, meaning APs will be online and available before
devices begin attachment, and there will therefore be nothing to
shuffle.

All PIC-conforming interrupt controllers will handle this early
distribution properly, except for RISC-V's PLIC. Make the necessary
tweak to the PLIC driver.

While here, convert irq_assign_cpu from a boolean_t to a bool.

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

3 years agoTransition from rtrequest1_fib() to rib_action().
Alexander V. Chernikov [Tue, 21 Jul 2020 19:56:13 +0000 (19:56 +0000)]
Transition from rtrequest1_fib() to rib_action().

Remove all variations of rtrequest <rtrequest1_fib, rtrequest_fib,
 in6_rtrequest, rtrequest_fib> and their uses and switch to
 to rib_action(). This is part of the new routing KPI.

Submitted by: Neel Chauhan <neel AT neelc DOT org>
Differential Revision: https://reviews.freebsd.org/D25546

3 years agoFix geli's null cipher, and add a test case
Alan Somers [Tue, 21 Jul 2020 19:18:29 +0000 (19:18 +0000)]
Fix geli's null cipher, and add a test case

PR: 247954
Submitted by: jhb (sys), asomers (tests)
Reviewed by: jhb (tests), asomers (sys)
MFC after: 2 weeks
Sponsored by: Axcient

3 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
Dimitry Andric [Tue, 21 Jul 2020 17:34:05 +0000 (17:34 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
10.0.1 final (aka llvmorg-10.0.1-0-gef32c611aa2).

There were no changes since rc2, except in the upstream regression
tests, which we do not ship.

Relnotes: yes
MFC after: immediately (no material changes except tag)

3 years agoAvoid code duplicaiton by using ipi_selected().
Alexander Motin [Tue, 21 Jul 2020 17:18:38 +0000 (17:18 +0000)]
Avoid code duplicaiton by using ipi_selected().

MFC after: 2 weeks

3 years ago[skip ci] document close_range(2) as async-signal-safe
Alan Somers [Tue, 21 Jul 2020 16:46:40 +0000 (16:46 +0000)]
[skip ci] document close_range(2) as async-signal-safe

Reviewed by: bcr (manpages)
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D25513

3 years agoFix style and comment around concave/convex regions in TCP cubic.
Richard Scheffenegger [Tue, 21 Jul 2020 16:21:52 +0000 (16:21 +0000)]
Fix style and comment around concave/convex regions in TCP cubic.

In cubic, the concave region is when snd_cwnd starts growing slower
towards max_cwnd (cwnd at the time of the congestion event), and
the convex region is when snd_cwnd starts to grow faster and
eventually appearing like slow-start like growth.

PR: 238478
Reviewed by: tuexen (mentor), rgrimes (mentor)
Approved by: tuexen (mentor), rgrimes (mentor)
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D24657

3 years agonetstat(1): Add EXAMPLES section
Fernando ApesteguĂ­a [Tue, 21 Jul 2020 16:17:23 +0000 (16:17 +0000)]
netstat(1): Add EXAMPLES section

* Add small EXAMPLES section
* Fix warning reported by mandoc (./netstat.1:747:2: WARNING: skipping paragraph
  macro: Pp before Ss)

Approved by: manpages (gbe)
Differential Revision: https://reviews.freebsd.org/D25212

3 years agotraceroute6: Fix most warnings at the default WARNS level.
Mark Johnston [Tue, 21 Jul 2020 15:03:36 +0000 (15:03 +0000)]
traceroute6: Fix most warnings at the default WARNS level.

Fix some style issues as well.  Leave -Wno-cast-aligned set for now, as
most of the warnings come casts of CMSG_DATA(), which does provide
sufficient alignment in practice.

Submitted by: Shubh Gupta <shubh@freebsd.org>
Sponsored by: Google (GSOC 2020)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25603

3 years agolockmgr: denote recursion with a bit in lock value
Mateusz Guzik [Tue, 21 Jul 2020 14:42:22 +0000 (14:42 +0000)]
lockmgr: denote recursion with a bit in lock value

This reduces excessive reads from the lock.

Tested by: pho

3 years agolockmgr: rewrite upgrade to stop always dropping the lock
Mateusz Guzik [Tue, 21 Jul 2020 14:41:25 +0000 (14:41 +0000)]
lockmgr: rewrite upgrade to stop always dropping the lock

This matches rw and sx locks.

3 years agolockmgr: add a helper for reading the lock value
Mateusz Guzik [Tue, 21 Jul 2020 14:39:20 +0000 (14:39 +0000)]
lockmgr: add a helper for reading the lock value

3 years agoOnly write to VIRTIO_MMIO_GUEST_PAGE_SIZE with virtio mmio version 1
Andrew Turner [Tue, 21 Jul 2020 14:25:36 +0000 (14:25 +0000)]
Only write to VIRTIO_MMIO_GUEST_PAGE_SIZE with virtio mmio version 1

This register is only defined for the legacy v1 interface so only write
to it when interacting with a legacy device.

Sponsored by: Innovate UK

3 years agoMove sys/iommu.h to dev/iommu/ as a part of generic IOMMU busdma backend.
Ruslan Bukin [Tue, 21 Jul 2020 13:50:10 +0000 (13:50 +0000)]
Move sys/iommu.h to dev/iommu/ as a part of generic IOMMU busdma backend.

Reviewed by: kib
Sponsored by: DARPA/AFRL
Differential Revision: https://reviews.freebsd.org/D25750

3 years agoMove the Intel DMAR busdma backend to a generic place so
Ruslan Bukin [Tue, 21 Jul 2020 10:38:51 +0000 (10:38 +0000)]
Move the Intel DMAR busdma backend to a generic place so
it can be used on other IOMMU systems.

Reviewed by: kib
Sponsored by: DARPA/AFRL
Differential Revision: https://reviews.freebsd.org/D25720

3 years agodtrace/fbt: fix return probe arguments on arm
Andriy Gapon [Tue, 21 Jul 2020 07:41:36 +0000 (07:41 +0000)]
dtrace/fbt: fix return probe arguments on arm

arg0 should be an offset of the return point within the function, arg1
should be the return value.  Previously the return probe had arguments as
if for the entry probe.

Tested on armv7.

andrew noted that the same problem seems to be present on arm64, mips,
and riscv.
I am not sure if I will get around to fixing those.  So, platform users
or anyone looking to make a contribution please be aware of this
opportunity.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25685

3 years agogpioiic: never drive lines active high
Andriy Gapon [Tue, 21 Jul 2020 07:35:03 +0000 (07:35 +0000)]
gpioiic: never drive lines active high

I2C communication is done by a combination of driving a line low or
letting it float, so that it is either pulled up or driven low by
another party.

r355276 besides the stated goal of the change -- using the new GPIO API
-- also changed the logic, so that active state is signaled by actively
driving a line.

That worked with iicbb prior to r362042, but stopped working after that
commit on at least some hardware.  My guess that the breakage was
related to getting an ACK bit.  A device expected to be able to drive
SDA actively low, but controller was actively driving it high for some
time.

Anyway, this change seems to fix the problem.
Tested using gpioiic on Orange Pi PC Plus with HTU21 sensor.

Reported by: Nick Kostirya <nikolay.kostirya@i11.co>
Reviewed by: manu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25684

3 years agoFix some regressions with the zgrep(1) wrapper.
Craig Leres [Mon, 20 Jul 2020 23:57:53 +0000 (23:57 +0000)]
Fix some regressions with the zgrep(1) wrapper.

 - Handle whitespace with long flags that take arguments:

echo 'foo bar' > test
zgrep --regexp='foo bar' test

 - Do not hang reading from stdin with patterns in a file:

echo foobar > test
echo foo > pattern
zgrep -f pattern test
zgrep --file=pattern test

 - Handle any flags after -e:

echo foobar > test
zgrep -e foo --ignore-case < test

These two are still outstanding problems:

 - Does not handle flags that take an argument if there is no
   whitespace:

zgrep -enfs /etc/rpc

 - When more than one -e pattern used matching should occur for all
   patterns (similar to multiple patterns supplied with -f file).
   Instead only the last pattern is used for matching:

zgrep -e rex -e nfs /etc/rpc

   (This problem is masked in the unpatched version by the "any
   flags after -e" problem.)

Add tests for the above problems.

Update the mange and add references to gzip(1) and zstd(1) and also
document the remaining known problems.

PR: 247126
Approved by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D25613

3 years agoAdd MODULE_VERSION to TCP loadable congestion control modules.
Richard Scheffenegger [Mon, 20 Jul 2020 23:47:27 +0000 (23:47 +0000)]
Add MODULE_VERSION to TCP loadable congestion control modules.

Without versioning information, using preexisting loader /
linker code is not easily possible when another module may
have dependencies on pre-loaded modules, and also doesn't
allow the automatic loading of dependent modules.

No functional change of the actual modules.

Reviewed by: tuexen (mentor), rgrimes (mentor)
Approved by: tuexen (mentor), rgrimes (mentor)
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D25744

3 years agoDon't dynamically allocate data structures for KTLS crypto requests.
John Baldwin [Mon, 20 Jul 2020 22:32:39 +0000 (22:32 +0000)]
Don't dynamically allocate data structures for KTLS crypto requests.

Allocate iovec arrays and struct cryptop and struct ocf_operation
objects on the stack to reduce avoid the overhead of malloc().

These structures are all small enough to fit on the stack of the KTLS
worker threads.

Reviewed by: gallatin
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25692

3 years agoiflib: initialize netmap with the correct number of descriptors
Vincenzo Maffione [Mon, 20 Jul 2020 21:08:56 +0000 (21:08 +0000)]
iflib: initialize netmap with the correct number of descriptors

In case the network device has a RX or TX control queue, the correct
number of TX/RX descriptors is contained in the second entry of the
isc_ntxd (or isc_nrxd) array, rather than in the first entry.
This case is correctly handled by iflib_device_register() and
iflib_pseudo_register(), but not by iflib_netmap_attach().
If the first entry is larger than the second, this can result in a
panic. This change fixes the bug by introducing two helper functions
that also lead to some code simplification.

PR: 247647
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D25541

3 years agoadd a few tests for sendfile.
Chuck Silvers [Mon, 20 Jul 2020 20:36:32 +0000 (20:36 +0000)]
add a few tests for sendfile.

Reviewed by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25431

3 years agolibdwarf: Hide SHT_NOBITS sections.
Mark Johnston [Mon, 20 Jul 2020 18:22:38 +0000 (18:22 +0000)]
libdwarf: Hide SHT_NOBITS sections.

gnu_debuglink external debug files will contain an .eh_frame section of
type SHT_NOBITS.  libdwarf does not handle such sections (or rather, it
expects all debug sections to not have type SHT_NOBITS).  Avoid loading
SHT_NOBITS sections, to be consistent with SGI libdwarf's handling of
this case.

PR: 239516
Diagnosed by: Paco Pascal <me@pacopascal.com>
Reviewed by: emaste (previous version)
Event: July 2020 Bugathon
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25626

3 years agocrypto(9): Stop checking for failures from malloc(M_WAITOK).
Mark Johnston [Mon, 20 Jul 2020 17:44:13 +0000 (17:44 +0000)]
crypto(9): Stop checking for failures from malloc(M_WAITOK).

PR: 240545
Submitted by: Andrew Reiter <arr@watson.org>
Reviewed by: cem, delphij, jhb
MFC after: 1 week
Event: July 2020 Bugathon

3 years agoFix a memory leak in dsl_scan_visitbp().
Mark Johnston [Mon, 20 Jul 2020 17:05:44 +0000 (17:05 +0000)]
Fix a memory leak in dsl_scan_visitbp().

This should be triggered only if arc_read() fails, i.e., quite rarely.
The same logic is already present in OpenZFS.

PR: 247445
Submitted by: jdolecek@NetBSD.org
MFC after: 1 week

3 years agopadlock: fix Via Padlock with 192-bit keys
Alan Somers [Mon, 20 Jul 2020 16:12:14 +0000 (16:12 +0000)]
padlock: fix Via Padlock with 192-bit keys

It's been broken since a typo in r359374

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D25710

3 years agoext2fs: Stop checking for failures from malloc(M_WAITOK).
Mark Johnston [Mon, 20 Jul 2020 14:28:26 +0000 (14:28 +0000)]
ext2fs: Stop checking for failures from malloc(M_WAITOK).

PR: 240545
Submitted by: Andrew Reiter <arr@watson.org>
Reviewed by: fsu
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25707

3 years agogeli(8): Add an example on how to use geli(8) with a file as encrypted storage
Gordon Bergling [Mon, 20 Jul 2020 13:24:50 +0000 (13:24 +0000)]
geli(8): Add an example on how to use geli(8) with a file as encrypted storage

Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25741

3 years agozpool(8): Fix a few typos regarding 'inverval' -> 'interval'
Gordon Bergling [Mon, 20 Jul 2020 13:01:19 +0000 (13:01 +0000)]
zpool(8): Fix a few typos regarding 'inverval' -> 'interval'

PR: 248068
Submitted by: PauAmma <pauamma at gundo dot com>
Reviewed by: bcr (mentor)
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D25719

3 years agotests/sys/opencrypto: use python3
Alan Somers [Mon, 20 Jul 2020 12:47:15 +0000 (12:47 +0000)]
tests/sys/opencrypto: use python3

python2 will be EOL soon

Reviewed by: lwhsu, jmg
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D25682

3 years agoFix indent for if clause.
Xin LI [Mon, 20 Jul 2020 01:55:19 +0000 (01:55 +0000)]
Fix indent for if clause.

MFC after: 2 weeks

3 years agoRevert that!
Simon J. Gerraty [Sun, 19 Jul 2020 23:56:19 +0000 (23:56 +0000)]
Revert that!

3 years agoOops missed Makefile.config
Simon J. Gerraty [Sun, 19 Jul 2020 23:54:00 +0000 (23:54 +0000)]
Oops missed Makefile.config

3 years agoriscv: look for bootargs in FDT
Mitchell Horne [Sun, 19 Jul 2020 23:34:52 +0000 (23:34 +0000)]
riscv: look for bootargs in FDT

The FDT may contain a short /chosen/bootargs string which we should pass
to boot_parse_cmdline. Notably, this allows the use of qemu's -append
option to pass things like -s to boot to single user mode.

Submitted by: Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25544

3 years agoMake efirt module dependent on MK_EFI
Mitchell Horne [Sun, 19 Jul 2020 23:19:09 +0000 (23:19 +0000)]
Make efirt module dependent on MK_EFI

MK_EFI was added to kern.opts.mk in r331099, but is currently unused.
Take advantage of that fact and gate the build of efirt behind it.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D24673

3 years agoThe ds3231 RTC chip bitmask values for 12- versus 24-hour mode were reversed,
Ian Lepore [Sun, 19 Jul 2020 18:53:19 +0000 (18:53 +0000)]
The ds3231 RTC chip bitmask values for 12- versus 24-hour mode were reversed,
flip them so that times in the 20:00:00 to 23:59:59 range read correctly.

Reported by: Dr. Rolf Jansen <freebsd-rj@obsigna.com>
Pointy hat: ian@

3 years agoSimplify non-pti syscall entry on amd64.
Konstantin Belousov [Sun, 19 Jul 2020 17:47:55 +0000 (17:47 +0000)]
Simplify non-pti syscall entry on amd64.

Limit manipulations to use %rax as scratch to the pti portion of the
syscall entry code.

Submitted by: alc
Reviewed by: markj
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25722

3 years ago[if_an] unbreak!
Adrian Chadd [Sun, 19 Jul 2020 17:27:48 +0000 (17:27 +0000)]
[if_an] unbreak!

.. I missed this when checking drivers.

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

3 years ago[net80211] missing from last commit, le whoops
Adrian Chadd [Sun, 19 Jul 2020 16:07:51 +0000 (16:07 +0000)]
[net80211] missing from last commit, le whoops

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

3 years ago[net80211] Add new privileges; restrict what can be done in a jail.
Adrian Chadd [Sun, 19 Jul 2020 15:16:27 +0000 (15:16 +0000)]
[net80211] Add new privileges; restrict what can be done in a jail.

Split the MANAGE privilege into MANAGE, SETMAC and CREATE_VAP.

+ VAP_MANAGE is everything but setting the MAC and creating a VAP.
+ VAP_SETMAC is setting the MAC address of the VAP.
  Typically you wouldn't want the jail to be able to modify this.
+ CREATE_VAP is to create a new VAP. Again, you don't want to be doing
  this in a jail, but this DOES stop being able to run some corner
  cases like Dynamic WDS (DWDS) AP in a jail/vnet. We can figure this
  bit out later.

This allows me to run wpa_supplicant in a jail after transferring
a STA VAP into it. I unfortunately can't currently set the wlan
debugging inside the jail; that would be super useful!

Reviewed by: bz
Differential Revision: https://reviews.freebsd.org/D25630

3 years agoat(1): Markup environment variables with proper macros
Allan Jude [Sun, 19 Jul 2020 14:42:13 +0000 (14:42 +0000)]
at(1): Markup environment variables with proper macros

Submitted by: debdrup
Reported by: 0mp
Reviewed by: imp
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25721

3 years agoAdd reference counts for inp/stcb/net when timers are running.
Michael Tuexen [Sun, 19 Jul 2020 12:34:19 +0000 (12:34 +0000)]
Add reference counts for inp/stcb/net when timers are running.
This avoids a use-after-free reported for the userland stack.
Thanks to Taylor Brandstetter for suggesting a patch for
the userland stack.

MFC after: 1 week

3 years agoMake linux(4) support the BLKPBSZGET ioctl. Oracle uses it.
Edward Tomasz Napierala [Sun, 19 Jul 2020 12:25:03 +0000 (12:25 +0000)]
Make linux(4) support the BLKPBSZGET ioctl.  Oracle uses it.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25694

3 years agoAdd missing bitset(9) MLINKS.
Edward Tomasz Napierala [Sun, 19 Jul 2020 12:22:32 +0000 (12:22 +0000)]
Add missing bitset(9) MLINKS.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25713

3 years agoTemporarly revert r363319 to unbreak the build.
Alexander V. Chernikov [Sun, 19 Jul 2020 10:53:15 +0000 (10:53 +0000)]
Temporarly revert r363319 to unbreak the build.

Reported by: CI
Pointy hat to: melifaro

3 years agoTransition from rtrequest1_fib() to rib_action().
Alexander V. Chernikov [Sun, 19 Jul 2020 09:29:27 +0000 (09:29 +0000)]
Transition from rtrequest1_fib() to rib_action().

Remove all variations of rtrequest <rtrequest1_fib, rtrequest_fib,
 in6_rtrequest, rtrequest_fib> and their uses and switch to
to rib_action(). This is part of the new routing KPI.

Submitted by: Neel Chauhan <neel AT neelc DOT org>
Differential Revision: https://reviews.freebsd.org/D25546

3 years agoloader: cstyle cleanup
Toomas Soome [Sun, 19 Jul 2020 06:59:09 +0000 (06:59 +0000)]
loader: cstyle cleanup

No functional changes intended.

Sponsored by: Netflix, Klara Inc.

3 years agoamd64 pmap: microoptimize local shootdowns for PCID PTI configurations
Konstantin Belousov [Sat, 18 Jul 2020 18:19:57 +0000 (18:19 +0000)]
amd64 pmap: microoptimize local shootdowns for PCID PTI configurations

When pmap operates in PTI mode, we must reload %cr3 on return to
userspace.  In non-PCID mode the reload always flushes all non-global
TLB entries and we take advantage of it by only invalidating the KPT
TLB entries (there is no cached UPT entries at all).

In PCID mode, we flush both KPT and UPT TLB explicitly, but we can
take advantage of the fact that PCID mode command to reload %cr3
includes a flag to flush/not flush target TLB.  In particular, we can
avoid the flush for UPT, instead record that load of pc_ucr3 into %cr3
on return to usermode should be flushing.  This is done by providing
either all-1s or ~CR3_PCID_MASK in pc_ucr3_load_mask.  The mask is
automatically reset to all-1s on return to usermode.

Similarly, we can avoid flushing UPT TLB on context switch, replacing
it by setting pc_ucr3_load_mask.  This unifies INVPCID and non-INVPCID
PTI ifunc, leaving only 4 cases instead of 6.  This trick is also
applicable both to the TLB shootdown IPI handlers, since handlers
interrupt the target thread.

But then we need to check pc_curpmap in handlers, and this would
reopen the same race for INVPCID machines as was fixed in r306350 for
non-INVPCID.  To not introduce the same bug, unconditionally do
spinlock_enter() in pmap_activate().

Reviewed by: alc, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D25483

3 years agoo Move iommu_test_boundary() to sys/iommu.h
Ruslan Bukin [Sat, 18 Jul 2020 13:10:31 +0000 (13:10 +0000)]
o Move iommu_test_boundary() to sys/iommu.h
o Rename DMAR -> IOMMU in comments
o Add IOMMU_PAGE_SIZE / IOMMU_PAGE_MASK macroses
o x86 only: dmar_quirks_pre_use() / dmar_instantiate_rmrr_ctxs()

Reviewed by: kib
Sponsored by: DARPA/AFRL
Differential Revision: https://reviews.freebsd.org/D25665

3 years agoRemove code which is not needed.
Michael Tuexen [Sat, 18 Jul 2020 13:10:02 +0000 (13:10 +0000)]
Remove code which is not needed.

MFC after: 1 week

3 years agobridge: Don't sleep during epoch
Kristof Provost [Sat, 18 Jul 2020 12:43:11 +0000 (12:43 +0000)]
bridge: Don't sleep during epoch

While it doesn't trigger INVARIANTS or WITNESS on head it does in stable/12.
There's also no reason for it, as we can easily report the out of memory error
to the caller (i.e. userspace). All of these can already fail.

PR: 248046
MFC after: 3 days

3 years agoMake linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,
Edward Tomasz Napierala [Sat, 18 Jul 2020 12:21:08 +0000 (12:21 +0000)]
Make linux fallocate(2) return EOPNOTSUPP, not ENOSYS, on unsupported mode,
as documented in the man page.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoBump the default linux version from 3.2.0 to 3.10.0, which corresponds
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:37:30 +0000 (11:37 +0000)]
Bump the default linux version from 3.2.0 to 3.10.0, which corresponds
to RHEL 7.  Required for DB2.

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25656

3 years agoRegen after r363304.
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:31:31 +0000 (11:31 +0000)]
Regen after r363304.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoAdd a trivial linux(4) splice(2) implementation, which simply
Edward Tomasz Napierala [Sat, 18 Jul 2020 11:28:40 +0000 (11:28 +0000)]
Add a trivial linux(4) splice(2) implementation, which simply
returns EINVAL.  Fixes grep (grep-3.1-2build1).

PR: kern/218699
Reported by: avos
Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25636

3 years agoAdd missing SysV IPC stats to linprocfs(4). Fixes 'ipcs -l',
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:56:04 +0000 (10:56 +0000)]
Add missing SysV IPC stats to linprocfs(4).  Fixes 'ipcs -l',
and also helps Oracle.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25669

3 years agoFix bogomips calculation. Previously it was off by half. This was
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:53:56 +0000 (10:53 +0000)]
Fix bogomips calculation.  Previously it was off by half.  This was
verified under VMWare Fusion, comparing to what's reported under CentOS,
and by comparing numbers reported by linuxulator on T420 with a googled
up Linux cpuinfo (https://lkml.org/lkml/2011/11/29/116).

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20693

3 years agoFix two typos in flag names in /proc/cpuinfo.
Edward Tomasz Napierala [Sat, 18 Jul 2020 10:49:17 +0000 (10:49 +0000)]
Fix two typos in flag names in /proc/cpuinfo.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D25695

3 years agoMFV: r363292
Jung-uk Kim [Sat, 18 Jul 2020 07:35:34 +0000 (07:35 +0000)]
MFV: r363292

Merge ACPICA 20200717.

3 years agoShort-circuit tdfind when looking for the calling thread.
Mateusz Guzik [Sat, 18 Jul 2020 00:14:43 +0000 (00:14 +0000)]
Short-circuit tdfind when looking for the calling thread.

Common occurence with cpuset and other places.

3 years agoFix vnode_pager handling of read ahead/behind pages when a disk read fails.
Chuck Silvers [Fri, 17 Jul 2020 23:10:35 +0000 (23:10 +0000)]
Fix vnode_pager handling of read ahead/behind pages when a disk read fails.
Rather than marking the read ahead/behind pages valid even though they were
not initialized, free them using the new function vm_page_free_invalid().

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoAdd a new function vm_page_free_invalid() for freeing invalid pages
Chuck Silvers [Fri, 17 Jul 2020 23:09:36 +0000 (23:09 +0000)]
Add a new function vm_page_free_invalid() for freeing invalid pages
that might be wired.  If the page is wired then it cannot be freed now,
but the thread that eventually unwires it will free it at that point.

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoRevert my change from r361855 in favor of a better fix.
Chuck Silvers [Fri, 17 Jul 2020 23:08:01 +0000 (23:08 +0000)]
Revert my change from r361855 in favor of a better fix.

Reviewed by: markj, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D25430

3 years agoImport ACPICA 20200717.
Jung-uk Kim [Fri, 17 Jul 2020 22:53:36 +0000 (22:53 +0000)]
Import ACPICA 20200717.

3 years agodevstat(9): Update the man page to reflect the current implementation
Gordon Bergling [Fri, 17 Jul 2020 22:15:02 +0000 (22:15 +0000)]
devstat(9): Update the man page to reflect the current implementation

- Rename devstat_add_entry to devstat_new_entry
- Update the description of devstat_trans_flags
- Add manpage aliases for devstat_start_transaction_bio and devstat_end_transaction_bio

PR: 157316
Submitted by: novel
Reviewed by: cem, bcr (mentor)
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25677

3 years agomount_nfs(8): document alternate form of the gssname option
Gordon Bergling [Fri, 17 Jul 2020 21:55:24 +0000 (21:55 +0000)]
mount_nfs(8): document alternate form of the gssname option

PR: 238506
Submitted by: Greg Veldman <freebsd at gregv dot net>
Reviewed by: 0mp, bcr (mentor)
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25667

3 years agoiwm(4): Document limitations of the driver
Gordon Bergling [Fri, 17 Jul 2020 21:47:06 +0000 (21:47 +0000)]
iwm(4): Document limitations of the driver

Document that iwm(4) currently doesn't support 802.11n and 802.11ac.

PR: 247874
Submitted by: Charles Ross <cwr at sdf dot org>
Reviewed by: brueffer, markj
Approved by: brueffer
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D25666

3 years agoat(1): Fix location of at(1) crontab
Allan Jude [Fri, 17 Jul 2020 20:43:00 +0000 (20:43 +0000)]
at(1): Fix location of at(1) crontab

With r318443, atrun was moved from /etc/crontab to /etc/cron.d/at,
but the man-page was unfortunately not updated to reflect this.

PR: 248048
Submitted by: debdrup
Reported by: yoitsmeremember+fbsd at gmail.com
Reviewed by: Pau Amma <pauamma at gundo.com>
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25709

3 years agoFix incorrect byte order in ipfstat -f output.
Cy Schubert [Fri, 17 Jul 2020 19:07:59 +0000 (19:07 +0000)]
Fix incorrect byte order in ipfstat -f output.
- make sure frag is initialized to 0
- initialize ipfr_p field

NetBSD PR: 55137
Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD fil.c r1.32, ip_frag.c r1.8
MFC after: 2 weeks

3 years agopfil_run_hooks() can be called recursively, so we have to
Cy Schubert [Fri, 17 Jul 2020 19:07:56 +0000 (19:07 +0000)]
pfil_run_hooks() can be called recursively, so we have to
define FASTROUTE_RECURSION in fil.c

Submitted by: christos@NetBSD.org
Reported by: christos@NetBSD.org
Obtained from: NetBSD r1.31
MFC after: 2 weeks

3 years ago-4 and -6 only make sense with -i, -o, and -t.
Cy Schubert [Fri, 17 Jul 2020 19:07:53 +0000 (19:07 +0000)]
-4 and -6 only make sense with -i, -o, and -t.

PR: 247952
MFC after: 1 week