]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agocam(4): preserve alloc_flags when copying CCBs
Edward Tomasz Napierala [Tue, 6 Jul 2021 08:23:25 +0000 (09:23 +0100)]
cam(4): preserve alloc_flags when copying CCBs

Before UMA CCBs, all CCBs were of the same size, and could
be trivially copied using bcopy(9).  Now we have to preserve
alloc_flags, otherwise we might end up attempting to free
stack-allocated CCB to UMA; we also need to take CCB size
into account.

This fixes kernel panic which would occur when trying to access
a stopped (as in, SCSI START STOP, also "ctladm stop") SCSI device.

Reported By: Gary Jennejohn <gljennjohn@gmail.com>
Tested By: Gary Jennejohn <gljennjohn@gmail.com>
Reviewed By: imp
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D31054

2 years agoenetc: Add support for 2.5G fixed-link speed
Wojciech Macek [Tue, 6 Jul 2021 07:01:30 +0000 (09:01 +0200)]
enetc: Add support for 2.5G fixed-link speed

With the v5.13 device-tree update speed of the CPU switch port was
changed to 2.5G. Reflect that in the driver.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group

2 years agonvme(4): Report NPWA before NPWG as stripesize.
Alexander Motin [Tue, 6 Jul 2021 02:19:48 +0000 (22:19 -0400)]
nvme(4): Report NPWA before NPWG as stripesize.

New Samsung 980 SSDs report Namespace Preferred Write Alignment of
8 (4KB) and Namespace Preferred Write Granularity of 32 (16KB).
My quick tests show that 16KB is a minimal sequential write size
when the SSD reaches peak IOPS, so writing much less is very slow.
But writing slightly less or slightly more does not change much,
so it seems not so much a size granularity as minimum I/O size.

Thinking about different stripesize consumers:
 - Partition alignment should be based on NPWA by definition.
 - ZFS ashift in part of forcing alignment of all I/Os should also
be based on NPWA.  In part of forcing size granularity, if really
needed, it may be set to NPWG, but too big value can make ZFS too
space-inefficient, and the 16KB is actually the biggest supported
value there now.
 - ZFS recordsize/volblocksize could potentially be tuned up toward
NPWG to work as I/O size granularity, but enabled compression makes
it too fuzzy.  And those are normally user-configurable things.
 - ZFS I/O aggregation code could definitely use Optimal Write Size
value and may be NPWG, but we don't have fields in GEOM now to report
the minimal and optimal I/O sizes, and even maximal is not reported
outside GEOM DISK to be used by ZFS.

MFC after: 1 week

2 years agoOn a failed fcmpset don't pointlessly repeat tests
Alan Cox [Sun, 4 Jul 2021 05:20:42 +0000 (00:20 -0500)]
On a failed fcmpset don't pointlessly repeat tests

In a few places, on a failed compare-and-set, both the amd64 pmap and
the arm64 pmap repeat tests on bits that won't change state while the
pmap is locked.  Eliminate some of these unnecessary tests.

Reviewed by: andrew, kib, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31014

2 years agoriscv: Implement non-stub __vdso_gettc and __vdso_gettimekeep
Jessica Clarke [Mon, 5 Jul 2021 15:16:53 +0000 (16:16 +0100)]
riscv: Implement non-stub __vdso_gettc and __vdso_gettimekeep

PR: 256905
Reviewed by: arichardson, mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30963

2 years agogeom_label: Remove an old sysinstall(8) workaround
Jessica Clarke [Mon, 5 Jul 2021 15:15:32 +0000 (16:15 +0100)]
geom_label: Remove an old sysinstall(8) workaround

We removed sysinstall(8) back in 2011, so this workaround should be long
since unnecessary. This workaround can end up breaking cases that are
hit in the real world, such as dd'ing a small pre-built disk image to a
large partition that you intend to grow on first boot and uses a UFS
disk label for / in its /etc/fstab (as the only reliable thing a raw UFS
image can reference).

Reviewed by: imp, mckusick
Differential Revision: https://reviews.freebsd.org/D30825

2 years agorman: Remove an outdated comment that no longer applies
Jessica Clarke [Mon, 5 Jul 2021 15:15:03 +0000 (16:15 +0100)]
rman: Remove an outdated comment that no longer applies

Since commit 2dd1bdf1834c in 2016 the r_start and r_end fields have been
rman_res_t, which was briefly unsigned long, but commit da1b038af9f9
changed the typedef to be uintmax_t instead. C99 is also something we
assume these days.

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

2 years agoloader: Fix dtb loading
Emmanuel Vadot [Mon, 5 Jul 2021 13:50:39 +0000 (15:50 +0200)]
loader: Fix dtb loading

When calling file_findfile with only a type it returns
the first file matching the type. But in fdt_apply_overlays we
then iterate on the next files and try loading them as dtb overlays.
Fix this by checking the type one more time.

Sponsored by: Diablotin Systems
Reported by: Mark Millard <marklmi@yahoo.com>

2 years agopf: padalign global locks found in pf.c
Mateusz Guzik [Mon, 5 Jul 2021 09:26:29 +0000 (11:26 +0200)]
pf: padalign global locks found in pf.c

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agoarmv7: allwinner: Add aw_r_intc driver
Emmanuel Vadot [Mon, 5 Jul 2021 09:38:23 +0000 (11:38 +0200)]
armv7: allwinner: Add aw_r_intc driver

This is also needed after the 5.13 dts update.

Sponsored by: Diablotin Systems
Reported by: Mark Millard <marklmi@yahoo.com>

2 years agopf: allow table stats clearing and reading with ruleset rlock
Mateusz Guzik [Fri, 2 Jul 2021 12:55:57 +0000 (14:55 +0200)]
pf: allow table stats clearing and reading with ruleset rlock

Instead serialize against these operations with a dedicated lock.

Prior to the change, When pushing 17 mln pps of traffic, calling
DIOCRGETTSTATS in a loop would restrict throughput to about 7 mln.  With
the change there is no slowdown.

Reviewed by: kp (previous version)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopf: depessimize table handling
Mateusz Guzik [Fri, 2 Jul 2021 11:19:56 +0000 (13:19 +0200)]
pf: depessimize table handling

Creating tables and zeroing their counters induces excessive IPIs (14
per table), which in turns kills single- and multi-threaded performance.

Work around the problem by extending per-CPU counters with a general
counter populated on "zeroing" requests -- it stores the currently found
sum. Then requests to report the current value are the sum of per-CPU
counters subtracted by the saved value.

Sample timings when loading a config with 100k tables on a 104-way box:

stock:

pfctl -f tables100000.conf  0.39s user 69.37s system 99% cpu 1:09.76 total
pfctl -f tables100000.conf  0.40s user 68.14s system 99% cpu 1:08.54 total

patched:

pfctl -f tables100000.conf  0.35s user 6.41s system 99% cpu 6.771 total
pfctl -f tables100000.conf  0.48s user 6.47s system 99% cpu 6.949 total

Reviewed by: kp (previous version)
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agostress2: Wait for the "swap" program to terminate
Peter Holm [Mon, 5 Jul 2021 07:16:32 +0000 (09:16 +0200)]
stress2: Wait for the "swap" program to terminate

2 years agostress2: Limit scope of rm(1) wildcard in cleanup.
Peter Holm [Mon, 5 Jul 2021 07:14:05 +0000 (09:14 +0200)]
stress2: Limit scope of rm(1) wildcard in cleanup.

Reviewed by:  rgrimes

2 years agofreebsd-tips: Fix the description of fetch(1) to match the command
Li-Wen Hsu [Mon, 5 Jul 2021 02:14:25 +0000 (10:14 +0800)]
freebsd-tips: Fix the description of fetch(1) to match the command

Reported by: jrtc27
MFC with: ffe6afc4f0121f1909f2fa88694228f771dd3fcb

2 years agoBump __FreeBSD_version to 1400025 for LinuxKPI change.
Vladimir Kondratyev [Mon, 5 Jul 2021 00:22:19 +0000 (03:22 +0300)]
Bump __FreeBSD_version to 1400025 for LinuxKPI change.

2 years agoLinuxKPI: Implement sequence counters and sequential locks
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:55 +0000 (03:20 +0300)]
LinuxKPI: Implement sequence counters and sequential locks

as a thin wrapper around native version found in sys/seqc.h.
This replaces out-of-base GPLv2-licensed code used by drm-kmod.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D31006

2 years agoLinuxKPI: Implement strscpy
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:42 +0000 (03:20 +0300)]
LinuxKPI: Implement strscpy

strscpy copies the src string, or as much of it as fits, into the dst
buffer.  The dst buffer is always NUL terminated, unless it's zero-sized.
strscpy returns the number of characters copied (not including the
trailing NUL) or -E2BIG if len is 0 or src was truncated.

Currently drm-kmod replaces strscpy with strncpy that is not quite
correct as strncpy does not NUL-terminate truncated strings and returns
different values on exit.

Reviewed by: hselasky, imp, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D31005

2 years agoLinuxKPI: Use macro for implementation of some dma_map_* functions
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:23 +0000 (03:20 +0300)]
LinuxKPI: Use macro for implementation of some dma_map_* functions

This allows to remove unimplemented attrs parameter which type differs
between Linux kernel versions and to compile both drm-kmod and ofed
callers unmodified.
Also convert it to 'unsigned long' type to match modern Linuxes.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30932

2 years agoLinuxKPI: Implement irq_work_sync() routine.
Vladimir Kondratyev [Mon, 5 Jul 2021 00:20:06 +0000 (03:20 +0300)]
LinuxKPI: Implement irq_work_sync() routine.

irq_work_sync() performs draining of irq_work task.
Required by drm-kmod.

Reviewed by: hselasky
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30818

2 years agoLinuxKPI: Do not wait for a grace period in rcu_barrier()
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:50 +0000 (03:19 +0300)]
LinuxKPI: Do not wait for a grace period in rcu_barrier()

Linux docs explicitly state that this is not required [1]:

"Important note: The rcu_barrier() function is not, repeat, not,
obligated to wait for a grace period.  It is instead only required to
wait for RCU callbacks that have already been posted.  Therefore, if
there are no RCU callbacks posted anywhere in the system, rcu_barrier()
is within its rights to return immediately.  Even if there are
callbacks posted, rcu_barrier() does not necessarily need to wait for
a grace period."

[1] https://www.kernel.org/doc/Documentation/RCU/Design/Requirements/Requirements.html

Reviewed by: emaste, hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30809

2 years agoLinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:35 +0000 (03:19 +0300)]
LinuxKPI: Add compiler barriers to list_for_each_entry_lockless macro

so this list-traversal primitive may safely run concurrently with the
_rcu list-mutation primitives such as list_add_rcu() as long as the
traversal is guarded by rcu_read_lock().

Do it by reusing the "list_for_each_entry_rcu" macro which does the same.
On Linux it implements some additional lockdep stuff which we skip.

Also move the macro to linux/rculist.h where it resides on Linux.

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30795

2 years agoLinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave
Vladimir Kondratyev [Mon, 5 Jul 2021 00:19:01 +0000 (03:19 +0300)]
LinuxKPI: Change flags parameter type of atomic_dec_and_lock_irqsave

On Linux atomic_dec_and_lock_irqsave is a wrapper macro which provides
a reference to third parameter rather than parameter value itself to
implementation routine called _atomic_dec_and_lock_irqsave [1].

While here, implement a fast path.

[1] https://github.com/torvalds/linux/blob/master/include/linux/spinlock.h#L476

Reviewed by: hselasky
Differential revision: https://reviews.freebsd.org/D30781

2 years agoLinuxKPI: Add #defines required by drm-kmod v5.5
Vladimir Kondratyev [Mon, 5 Jul 2021 00:18:47 +0000 (03:18 +0300)]
LinuxKPI: Add #defines required by drm-kmod v5.5

Reviewed by: hselasky, manu
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30767

2 years agoLinuxKPI: Allow kmem_cache_free() to be called from critical sections
Vladimir Kondratyev [Mon, 5 Jul 2021 00:18:14 +0000 (03:18 +0300)]
LinuxKPI: Allow kmem_cache_free() to be called from critical sections

as it is required by i915kms driver from Linux kernel v 5.5.
This is done with asynchronous freeing of requested memory areas from
taskqueue thread. As memory to be freed is reused to store linked list
entry, backing UMA zone item size is rounded up to pointer size.

While here, make struct linux_kmem_cache private to LKPI to reduce amount
of BSD headers included by linux/slab.h and switch RCU code to usage of
LKPI's linux_irq_work_tq taskqueue to avoid injection of current into
system-wide taskqueue_fast thread context.

Submitted by: nc (initial version for drm-kmod)
Reviewed by: manu, nc
Differential revision: https://reviews.freebsd.org/D30760

2 years agolibalias: Remove a stray directive
Lutz Donnerhacke [Sun, 4 Jul 2021 15:54:45 +0000 (17:54 +0200)]
libalias: Remove a stray directive

Removal of a preprocessor line was missed during development.
Do it now and MFC it together with the other patches.

MFC after: 2 days

2 years agolibalias: Rewrite HISTORY
Lutz Donnerhacke [Sun, 4 Jul 2021 15:46:47 +0000 (17:46 +0200)]
libalias: Rewrite HISTORY

Fix the history entry (wrong year) and add the missing recent work.
MFC together with the other patches.

MFC after: 2 days

2 years agoman7: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:07:23 +0000 (22:07 +0800)]
man7: Update FreeBSD.org URLs

MFC after: 3 days

2 years agoshare/misc: Update FreeBSD.org URLs
Li-Wen Hsu [Sun, 4 Jul 2021 14:04:33 +0000 (22:04 +0800)]
share/misc: Update FreeBSD.org URLs

MFC after: 3 days

2 years agofreebsd-tips: Use a fetchable URL as example
Li-Wen Hsu [Sun, 4 Jul 2021 14:00:46 +0000 (22:00 +0800)]
freebsd-tips: Use a fetchable URL as example

MFC after: 3 days

2 years agofreebsd-update: Update URL of supported platforms information
Li-Wen Hsu [Sun, 4 Jul 2021 13:45:08 +0000 (21:45 +0800)]
freebsd-update: Update URL of supported platforms information

MFC after: 3 days

3 years agolibalias: Fix API bug on initialization
Lutz Donnerhacke [Sat, 3 Jul 2021 21:03:07 +0000 (23:03 +0200)]
libalias: Fix API bug on initialization

The kernel part of ipfw(8) does initialize LibAlias uncondistionally
with an zeroized port range (allowed ports from 0 to 0).  During
restucturing of libalias, port ranges are used everytime and are
therefor initialized with different values than zero.  The secondary
initialization from ipfw (and probably others) overrides the new
default values and leave the instance in an unfunctional state.  The
obvious solution is to detect such reinitializations and use the new
default value instead.

MFC after: 3 days

3 years agoAdd efitable(8), a userspace tool to fetch and parse EFI tables
Pavel Balaev [Thu, 1 Jul 2021 16:29:36 +0000 (19:29 +0300)]
Add efitable(8), a userspace tool to fetch and parse EFI tables

Only ESRT and PROP tables are handled at the moment.

Submitted by: Pavel Balaev <pavel.balaev@3mdeb.com>
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30104

3 years agoEFI RT: resurrect EFIIOC_GET_TABLE
Pavel Balaev [Thu, 1 Jul 2021 16:27:25 +0000 (19:27 +0300)]
EFI RT: resurrect EFIIOC_GET_TABLE

Make it work, but change the interface to be safe for non-root users. In
particular, right now interface only works for the tables which can be
minimally parsed by kernel to determine the table size. Then, userspace can
query the table size, after that it provides a buffer of needed size
and kernel copies out just table to userspace.

Main advantage is that user no longer need to be able to read /dev/mem,
the disadvantage is the need to have minimal parsers aware of the table
types.  Right now the parsers are implemented for ESRT and PROP tables.

Future extension of the present interface might be a return of only
the table physical address, in case kernel does not have suitable
parser yet. Then, a privileged user could read the table from /dev/mem.
This extension, which logically equivalent to the old (non-worked)
EFIIOC_GET_TABLE variant, is not implemented until needed.

Submitted by: Pavel Balaev <pavel.balaev@3mdeb.com>
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D30104

3 years agolinux(4): implement PR_SET_NO_NEW_PRIVS
Edward Tomasz Napierala [Sat, 3 Jul 2021 07:41:59 +0000 (08:41 +0100)]
linux(4): implement PR_SET_NO_NEW_PRIVS

This makes prctl(2) support PR_SET_NO_NEW_PRIVS, by mapping it
to the native PROC_NO_NEW_PRIVS_CTL procctl(2).

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30973

3 years agolinux(4): implement coredumps on arm64
Edward Tomasz Napierala [Sat, 3 Jul 2021 07:05:44 +0000 (08:05 +0100)]
linux(4): implement coredumps on arm64

Previously they only worked on amd64.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30975

3 years agohdaa: update pin patch configurations
K Staring [Sat, 3 Jul 2021 06:15:49 +0000 (00:15 -0600)]
hdaa: update pin patch configurations

A number of structural changes:
  - Use decimal nid numbers instead of hex
  - updated the branch to incoorporate the suggestions made in the
    ALC280 pull request github thread
  - Convert magic pin values into strings.
  - Also update hdaa_patches to use clearer enums..
  - made pin patch type enum clearer, add macro for 'string' type
    patches
  - Added pin_patch structures to separate data from logic.
  - Integrated Realtek patches into new structure.

These incorporate fixes for ALC255, ALC256, ALC260, ALC262, ALC268,
ALC269, ALC280, ALC282, ALC283, ALC286, ALC290, ALC293, ALC296, ALC2880

And have definitions for a number of Dell and HP laptops.

Much of this data has been mined fromt he tables in the Linux driver.

imp squashed these into one commit because the changes from the github
pull requests no longer cleanly apply individually and made light style
changes after feedback from jhb.

Pull Request: https://github.com/freebsd/freebsd-src/pull/139
Pull Request: https://github.com/freebsd/freebsd-src/pull/140
Pull Request: https://github.com/freebsd/freebsd-src/pull/141
Pull Request: https://github.com/freebsd/freebsd-src/pull/142
Pull Request: https://github.com/freebsd/freebsd-src/pull/143
Pull Request: https://github.com/freebsd/freebsd-src/pull/144
Pull Request: https://github.com/freebsd/freebsd-src/pull/145
Pull Request: https://github.com/freebsd/freebsd-src/pull/146
Pull Request: https://github.com/freebsd/freebsd-src/pull/147
Pull Request: https://github.com/freebsd/freebsd-src/pull/148
Pull Request: https://github.com/freebsd/freebsd-src/pull/149
Pull Request: https://github.com/freebsd/freebsd-src/pull/150
Differential Revision: https://reviews.freebsd.org/D30619

3 years agohardclock.9: Refine some details
Warner Losh [Fri, 2 Jul 2021 23:09:19 +0000 (17:09 -0600)]
hardclock.9: Refine some details

Refine mistakes from adaptaton of NetBSD's hardclock man page to
FreeBSD:
o clarify what usermode means
o clarify how often hardclock is called
o remove Xr callout(9) since that's done elsewhere

Reviewed by: mav@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30982

3 years agolibalias: Avoid uninitialized expiration
Lutz Donnerhacke [Fri, 2 Jul 2021 23:02:53 +0000 (01:02 +0200)]
libalias: Avoid uninitialized expiration

The expiration time of direct address mappings is explicitly
uninitialized.  Expire times are always compared during housekeeping.
Despite the uninitialized value does not harm, it's simpler to just
set it to a reasonable default.  This was detected during valgrinding
the test suite.

MFC after: 3 days

3 years agoRevert libunwind change to fix backtrace segfault on aarch64
Dimitry Andric [Fri, 2 Jul 2021 22:35:42 +0000 (00:35 +0200)]
Revert libunwind change to fix backtrace segfault on aarch64

Revert commit 22b615a96593 from llvm git (by Daniel Kiss):

  [libunwind] Support for leaf function unwinding.

  Unwinding leaf function is useful in cases when the backtrace finds a
  leaf function for example when it caused a signal.
  This patch also add the support for the DW_CFA_undefined because it marks
  the end of the frames.

  Ryan Prichard provided code for the tests.

  Reviewed By: #libunwind, mstorsjo

  Differential Revision: https://reviews.llvm.org/D83573

  Reland with limit the test to the x86_64-linux target.

Bisection has shown that this particular upstream commit causes programs
using backtrace(3) on aarch64 to segfault. This affects the lang/rust
port, for instance. Until we can upstream to fix this problem, revert
the commit for now.

Reported by: mikael
PR: 256864

3 years agotests/libalias: Bugfix in used variables
Lutz Donnerhacke [Fri, 2 Jul 2021 21:58:16 +0000 (23:58 +0200)]
tests/libalias: Bugfix in used variables

Fix two copy and waste errors (referencing the wrong variable).

MFC after: 3 days

3 years agolibalias: Fix splay comparsion bug
Lutz Donnerhacke [Fri, 2 Jul 2021 21:41:25 +0000 (23:41 +0200)]
libalias: Fix splay comparsion bug

Comparing elements in a tree requires transitiviy.  If a < b and b < c
then a must be smaller than c.  This way the tree elements are always
pairwise comparable.

Tristate comparsion functions returning values lower, equal, or
greater than zero, are usually implemented by a simple subtraction of
the operands.  If the size of the operands are equal to the size of
the result, integer modular arithmetics kick in and violates the
transitivity.

Example:
Working on byte with 0, 120, and 240. Now computing the differences:
  120 -   0 = 120
  240 - 120 = 120
  240 -   0 = -16

MFC after: 3 days

3 years agodumpfs(8): add option to only print superblock information
Robert Wing [Fri, 2 Jul 2021 22:18:17 +0000 (14:18 -0800)]
dumpfs(8): add option to only print superblock information

Add an option to dumpfs, `-s`, that only prints the super block information.

Reviewed by: chs, imp
Differential Revision: https://reviews.freebsd.org/D30881

3 years agonvme: coherently read status of completion records
Warner Losh [Fri, 2 Jul 2021 22:00:42 +0000 (16:00 -0600)]
nvme: coherently read status of completion records

Coherently read the phase bit of the status completion record. We loop
over the completion record array, looking for all the transactions in
the same phase that have been completed. In doing that, we have to be
careful to read the status field first, and if it indicates a complete
record, we need to read and process that record. Otherwise, the host
might be overtaken by device when reading this completion record,
leading to a mistaken belief that the record is in phase. This leads to
the code using old values and looking at an already completed entry, which
has no current tracker.

To work around this problem, we read the status and make sure it is in
phase, we then re-read the entire completion record guaranteeing it's
complete, valid, and consistent . In addition we resync the dmatag to
reflect changes since the prior loop for the bouncing dma case.

Reviewed by: jrtc27@, chuck@
Found by: jrtc27 (this fix is based in part on her D30995 fix)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31002

3 years agonvme: Fix alignment on nvme structures
Warner Losh [Fri, 2 Jul 2021 21:58:19 +0000 (15:58 -0600)]
nvme: Fix alignment on nvme structures

Remove __packed from nvme_command, nvme_completion and
nvme_dsm_trim. Add super-alignment to nvme_completion since it's always
at least that aligned in hardware (and in our existing uses of it
embedded in structures). It generates better code in
nvme_qpair_process_completions on riscv64 because otherwise the ABI
assumes a 4-byte alignment, and the same on all other platforms.

Reviewed by: jrtc27@, mav@, chuck@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31001

3 years agonvme: style nit
Warner Losh [Fri, 2 Jul 2021 21:58:14 +0000 (15:58 -0600)]
nvme: style nit

Put the { on the same line as the struct nvme_foo when we define these
structures. It's FreeBSD standard and these were inconsistent.

Sponsored by: Netflix

3 years agocommitters-doc.dot: move myself out of alumni
Ceri Davies [Fri, 2 Jul 2021 18:42:14 +0000 (19:42 +0100)]
committers-doc.dot: move myself out of alumni

3 years agonvmem(9): install the manpage
Ceri Davies [Fri, 2 Jul 2021 18:35:59 +0000 (19:35 +0100)]
nvmem(9): install the manpage

This is being installed on all architectures in line with the OF_*
pages.

Discussed with: fernape, manu

3 years agolibpfctl: memory leak fix
Kristof Provost [Wed, 30 Jun 2021 11:02:35 +0000 (13:02 +0200)]
libpfctl: memory leak fix

We must remember to free the nvlist we create from the kernel's response
to DIOCGETSTATESNV, on every iteration.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30957

3 years agopf: getstates: avoid taking the hashrow lock if the row is empty
Kristof Provost [Tue, 29 Jun 2021 09:34:49 +0000 (11:34 +0200)]
pf: getstates: avoid taking the hashrow lock if the row is empty

Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30946

3 years agopf: Reduce the data returned in DIOCGETSTATESNV
Kristof Provost [Tue, 29 Jun 2021 08:26:40 +0000 (10:26 +0200)]
pf: Reduce the data returned in DIOCGETSTATESNV

This call is particularly slow due to the large amount of data it
returns. Remove all fields pfctl does not use. There is no functional
impact to pfctl, but it somewhat speeds up the call.

It might affect other (i.e. non-FreeBSD) code that uses the new
interface, but this call is very new, so there's unlikely to be any. No
releases contained the previous version, so we choose to live with the
ABI modification.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30944

3 years agopf tests: Stress state retrieval
Kristof Provost [Mon, 28 Jun 2021 10:48:20 +0000 (12:48 +0200)]
pf tests: Stress state retrieval

Create and retrieve 20.000 states. There have been issues with nvlists
causing very slow state retrieval. We don't impose a specific limit on
the time required to retrieve the states, but do log it. In excessive
cases the Kyua timeout will fail this test.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30943

3 years agoRemove lib/kyua from the build
Alex Richardson [Fri, 2 Jul 2021 09:18:00 +0000 (10:18 +0100)]
Remove lib/kyua from the build

I forgot to include this line in 2eb9ad427475190e87d026de4ca7fc296947f2a0.

Reported by:    Jenkins CI
MFC after:      1 week
Fixes: 2eb9ad427475190ei ("Simplify and speed up the kyua build")
3 years agoRevert "Remove lib/kyua from the build"
Alex Richardson [Fri, 2 Jul 2021 09:17:03 +0000 (10:17 +0100)]
Revert "Remove lib/kyua from the build"

Accidentally removed it from the wrong file...

This reverts commit 8ec4ba8a76aaf256942ac5996d45cc29022641ae.

3 years agoRemove lib/kyua from the build
Alex Richardson [Fri, 2 Jul 2021 08:54:11 +0000 (09:54 +0100)]
Remove lib/kyua from the build

I forgot to include this line in 2eb9ad427475190e87d026de4ca7fc296947f2a0.

Reported by: Jenkins CI
MFC after: 1 week
Fixes: 2eb9ad427475190ei ("Simplify and speed up the kyua build")

3 years agopf: make DIOCGETSTATESNV iterations killable
Mateusz Guzik [Fri, 2 Jul 2021 07:28:48 +0000 (09:28 +0200)]
pf: make DIOCGETSTATESNV iterations killable

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoktls: switch bare zone_mbuf use to m_free_raw
Mateusz Guzik [Wed, 30 Jun 2021 13:02:45 +0000 (15:02 +0200)]
ktls: switch bare zone_mbuf use to m_free_raw

Reviewed by: gallatin
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30955

3 years agoiflib: switch bare zone_mbuf use to m_free_raw
Mateusz Guzik [Wed, 30 Jun 2021 14:17:29 +0000 (16:17 +0200)]
iflib: switch bare zone_mbuf use to m_free_raw

Reviewed by: kbowling
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30961

3 years agombuf: add m_free_raw to be used instead of directly calling uma_zfree
Mateusz Guzik [Wed, 30 Jun 2021 14:15:25 +0000 (16:15 +0200)]
mbuf: add m_free_raw to be used instead of directly calling uma_zfree

The intent is to remove all direct zone_mbuf consumers so that ctor/dtor
from that zone can be reimplemented as wrappers around uma, avoiding an
indirect function call.

Reviewed by: kbowling
Discussed with: gallatin
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30959

3 years agoiflib: retire MB_DTOR_SKIP
Mateusz Guzik [Wed, 30 Jun 2021 13:09:40 +0000 (15:09 +0200)]
iflib: retire MB_DTOR_SKIP

The flag was added in 2016 but remains unused.

Reviewed by: kbowling
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30958

3 years agoSimplify and speed up the kyua build
Alex Richardson [Fri, 2 Jul 2021 08:21:04 +0000 (09:21 +0100)]
Simplify and speed up the kyua build

Instead of having multiple kyua libraries, just include the files as part
of usr.bin/kyua. Previously, we would build each kyua source up to four
times: once as a .o file and once as a .pieo. Additionally, the kyua
libraries might be built again for compat32. As all the kyua libraries
amount to 102 C++ sources the build time is significant (especially when
using an assertions enabled compiler). This change ensures that we build
306 fewer .cpp source files as part of buildworld.

Reviewed By: brooks
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30967

3 years agoproccontrol(1): implement 'nonewprivs'
Edward Tomasz Napierala [Fri, 2 Jul 2021 07:49:20 +0000 (08:49 +0100)]
proccontrol(1): implement 'nonewprivs'

This adds the 'nonewprivs' mode, corresponding to newly added
procctl(2) commands PROC_NO_NEW_PRIVS_CTL and PROC_NO_NEW_PRIVS_STATUS.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30940

3 years agodtb: rockchip: Add NanoPI-R4S and RockPI E to the build
Ganbold Tsagaankhuu [Fri, 2 Jul 2021 07:20:25 +0000 (15:20 +0800)]
dtb: rockchip: Add NanoPI-R4S and RockPI E to the build

3 years agonetstat: Fix typo
Stefan Eßer [Fri, 2 Jul 2021 06:38:42 +0000 (08:38 +0200)]
netstat: Fix typo

Correct spelling of "received packers" to "received packets".

PR: 256926
Reported by: ghuckriede@blackberry.com
MFC after: 3 days

3 years agostress2: Added a test scenario from Bug 227041
Peter Holm [Fri, 2 Jul 2021 05:24:38 +0000 (07:24 +0200)]
stress2: Added a test scenario from Bug 227041

3 years agostress2: Update the list of test not to run
Peter Holm [Fri, 2 Jul 2021 05:23:05 +0000 (07:23 +0200)]
stress2: Update the list of test not to run

3 years agostress2: Improve cleanup code
Peter Holm [Fri, 2 Jul 2021 05:22:18 +0000 (07:22 +0200)]
stress2: Improve cleanup code

3 years agorc.conf.5: -Tlint fixes.
Ceri Davies [Thu, 1 Jul 2021 21:51:37 +0000 (22:51 +0100)]
rc.conf.5: -Tlint fixes.

3 years agorc.conf.5: add .Xr to firewall(7), growfs(7), and tuning(7)
Ceri Davies [Thu, 1 Jul 2021 21:35:14 +0000 (22:35 +0100)]
rc.conf.5: add .Xr to firewall(7), growfs(7), and tuning(7)

3 years agocd(9): correct minor typo in manpage.
Ceri Davies [Thu, 1 Jul 2021 21:10:34 +0000 (22:10 +0100)]
cd(9): correct minor typo in manpage.

3 years agopfctl: cache getprotobynumber results
Mateusz Guzik [Thu, 1 Jul 2021 19:25:43 +0000 (21:25 +0200)]
pfctl: cache getprotobynumber results

As for example pfctl -ss keeps calling it, it saves a lot of overhead
from elided parsing of /etc/nsswitch.conf and /etc/protocols.

Sample result when running a pre-nvlist binary with nfs root and dumping
7 mln states:
before: 24.817u 62.993s 1:28.52 99.1%
after: 8.064u 1.117s 0:18.87 48.5%

Idea by Jim Thompson

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agomrsas(4): Report more correct maximum I/O size.
Alexander Motin [Thu, 1 Jul 2021 19:28:55 +0000 (15:28 -0400)]
mrsas(4): Report more correct maximum I/O size.

Subtract one SGE for the case of misaligned address.  Also take into
account maximum number of sectors reported by firmware, that gives
nicer 256KB limit instead of 276KB calculated from the SGE limit.

While there, remove number of I/O size checks, duplicating what is
already checked by CAM and busdma(9).

MFC after: 1 month
Sponsored by: iXsystems, Inc.

3 years agopf tests: ftp-proxy test
Kristof Provost [Thu, 1 Jul 2021 15:15:36 +0000 (17:15 +0200)]
pf tests: ftp-proxy test

Basic test case for ftp-proxy

PR: 256917
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agoftp-proxy: Revert incorrect migration to libpfctl
Kristof Provost [Thu, 1 Jul 2021 15:16:10 +0000 (17:16 +0200)]
ftp-proxy: Revert incorrect migration to libpfctl

libpfctl supports creating rules, but not (yet) adding addresses to a
pool. Adding addresses certainly does not work through adding a rule.

PR: 256917
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

3 years agodummynet: fix sysctls
Kristof Provost [Thu, 1 Jul 2021 07:42:34 +0000 (09:42 +0200)]
dummynet: fix sysctls

The sysctl nodes which use V_dn_cfg must be marked as CTLFLAG_VNET so
that we use the correct per-vnet offset

PR: 256819
Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30974

3 years agoofw_pci: fix probing for non-DT cases
Kornel Duleba [Thu, 1 Jul 2021 18:27:41 +0000 (20:27 +0200)]
ofw_pci: fix probing for non-DT cases

phandle_t is a uint32_t type, <= 0 comparison doesn't work with it as intended.
This caused the ofw_pci code to attach to PCI bus on ACPI based systems.
Since 3eae4e106ac7 ("Fix error value returned by ofw_bus_gen_get_node().")
ofw subsystem can only return -1 for invalid nodes. Use that.

MFC after: 4 weeks
Reviewed by: mw
Differential revision: https://reviews.freebsd.org/D30953

3 years agodts: fsl-ls1028a: Correct ECAM PCIE window ranges
Kornel Duleba [Thu, 1 Jul 2021 18:21:17 +0000 (20:21 +0200)]
dts: fsl-ls1028a: Correct ECAM PCIE window ranges

Currently all PCIE windows point to bus address 0x0, which does not match
the values obtained from hardware during EA.
Replace those values with CPU addresses, since in reality we
have a 1:1 mapping between the two.

This patch is queued for Linux v5.14 in linux-next tree:
6bee93d93111 "arm64: dts: fsl-ls1028a: Correct ECAM PCIE window ranges"

3 years agotegra_pcie: use switch instead of if in tegra_pcib_pex_ctrl
Ferhat Gecdogan [Thu, 1 Jul 2021 18:09:46 +0000 (20:09 +0200)]
tegra_pcie: use switch instead of if in tegra_pcib_pex_ctrl

Simplify obtaining per-port data in tegra_pcib_pex_ctrl() routine.

Reviewed by:    imp, mw
Pull Request:   https://github.com/freebsd/freebsd-src/pull/481

3 years agodts: Bump the freebsd branding version to 5.13
Emmanuel Vadot [Thu, 1 Jul 2021 16:48:44 +0000 (18:48 +0200)]
dts: Bump the freebsd branding version to 5.13

Sponsored by: Diablotin Systems

3 years agoarm64: allwinner: Add r_intc driver
Emmanuel Vadot [Thu, 1 Jul 2021 16:41:05 +0000 (18:41 +0200)]
arm64: allwinner: Add r_intc driver

The r intc interrupt controller seems to do a lot of things :
- It can handle the NMI interrupt
- It have local interrupts for some device that also can be muxed with GIC
- It can serve as an forwarder for the GIC

It's mostly used for deepsleep/wakeup if I understood correctly and we do not
support this on arm64.

For now just forward everything to the GIC so interrupts works again for device
which now have this interrupts controller set since dts v5.12

Sponsored by: Diablotin Systems

3 years agobuild.7: remove documentation of "make update"
Ceri Davies [Thu, 1 Jul 2021 15:04:33 +0000 (16:04 +0100)]
build.7: remove documentation of "make update"

update target was removed in e290182bcf3895ca659dff111bca6a077c4708b1

3 years agoImport device-tree files from Linux 5.13
Emmanuel Vadot [Thu, 1 Jul 2021 15:50:54 +0000 (17:50 +0200)]
Import device-tree files from Linux 5.13

Sponsored by: Diablotin Systems

3 years agoImport device-tree files from Linux 5.13
Emmanuel Vadot [Thu, 1 Jul 2021 15:50:17 +0000 (17:50 +0200)]
Import device-tree files from Linux 5.13

3 years agoImport device-tree files from Linux 5.12
Emmanuel Vadot [Thu, 1 Jul 2021 15:41:47 +0000 (17:41 +0200)]
Import device-tree files from Linux 5.12

Sponsored by: Diablotin Systems

3 years agoImport device-tree files from Linux 5.12
Emmanuel Vadot [Thu, 1 Jul 2021 15:39:42 +0000 (17:39 +0200)]
Import device-tree files from Linux 5.12

3 years agohz.9: update stathz for current usage
Warner Losh [Thu, 1 Jul 2021 15:32:40 +0000 (09:32 -0600)]
hz.9: update stathz for current usage

Update the stathz description to reflect reality. profhz is the only
thing we should deprecate. Add some implementation notes that describe
the optimizations made to date.

Discusssed with: emaste
Reviewed by: kib (prior), jhb (prior), gbe
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30815

3 years agoImport device-tree files from Linux 5.11
Emmanuel Vadot [Thu, 1 Jul 2021 15:20:05 +0000 (17:20 +0200)]
Import device-tree files from Linux 5.11

Sponsored by: Diablotin Systems

3 years agoSwitch the order of the ID_AA64PFR1_EL1 fields
Andrew Turner [Thu, 1 Jul 2021 00:45:39 +0000 (00:45 +0000)]
Switch the order of the ID_AA64PFR1_EL1 fields

This makes them consistent with the fields in other registers.

Sponsored by: The FreeBSD Foundation

3 years agofortune: correct documentation of default FORTUNE_PATH.
Ceri Davies [Thu, 1 Jul 2021 13:00:06 +0000 (14:00 +0100)]
fortune: correct documentation of default FORTUNE_PATH.

While here, fix a typo in a comment relating to FORTUNE_PATH

3 years agoprocctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
Edward Tomasz Napierala [Thu, 1 Jul 2021 08:11:11 +0000 (09:11 +0100)]
procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS

This introduces a new, per-process flag, "NO_NEW_PRIVS", which
is inherited, preserved on exec, and cannot be cleared.  The flag,
when set, makes subsequent execs ignore any SUID and SGID bits,
instead executing those binaries as if they not set.

The main purpose of the flag is implementation of Linux
PROC_SET_NO_NEW_PRIVS prctl(2), and possibly also unpriviledged
chroot.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30939

3 years agolinux(4): revert arm64 part of 447636e43c0
Edward Tomasz Napierala [Thu, 1 Jul 2021 08:28:01 +0000 (08:28 +0000)]
linux(4): revert arm64 part of 447636e43c0

The arm64 part of the patch was incomplete and prevented
linux64.ko from loading due to missing symbol.

Sponsored By: EPSRC

3 years agonfscl: Improve "Consider increasing kern.ipc.maxsockbuf" message
Rick Macklem [Wed, 30 Jun 2021 22:15:41 +0000 (15:15 -0700)]
nfscl: Improve "Consider increasing kern.ipc.maxsockbuf" message

When the setting of kern.ipc.maxsockbuf is less than what is
desired for I/O based on vfs.maxbcachebuf and vfs.nfs.bufpackets,
a console message of "Consider increasing kern.ipc.maxsockbuf".
is printed.

This patch modifies the message to provide a suggested value
for kern.ipc.maxsockbuf.
Note that the setting is only needed when the NFS rsize/wsize
is set to vfs.maxbcachebuf.

While here, make nfs_bufpackets global, so that it can be used
by a future patch that adds a sysctl to set the NFS server's
maximum I/O size.  Also, remove "sizeof(u_int32_t)" from the maximum
packet length, since NFS_MAXXDR is already an "overestimate"
of the actual length.

MFC after: 2 weeks

3 years agolinux(4): implement coredump support
Edward Tomasz Napierala [Wed, 30 Jun 2021 16:45:21 +0000 (17:45 +0100)]
linux(4): implement coredump support

Implement dumping core for Linux binaries on amd64, for both
32- and 64-bit executables.  Some bits are still missing.

This is based on a prototype by chuck@.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30019

3 years agolibpmc: Import AMD Zen 3 PMU events
Greg V [Wed, 30 Jun 2021 21:15:21 +0000 (18:15 -0300)]
libpmc: Import AMD Zen 3 PMU events

Reviewed by: mav, mhorne
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30965

3 years agohwpmc_arm64: add a PMCDBG to the interrupt handler
Mitchell Horne [Wed, 19 May 2021 16:29:59 +0000 (13:29 -0300)]
hwpmc_arm64: add a PMCDBG to the interrupt handler

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoarm: Make sure we can handle a thumb entry point.
Olivier Houchard [Wed, 30 Jun 2021 20:56:50 +0000 (22:56 +0200)]
arm: Make sure we can handle a thumb entry point.

Similarly to what's been done on arm64 with commit
712c060c94fd447c91b0e6218c12a431206b487a, when executing a binary, if the
entry point is a thumb symbol, then make sure we set the PSL_T flag, otherwise
the CPU will interpret it in ARM mode, and that will likely leads to an
undefined instruction.

PR: 256899
MFC after:  1 week

3 years agoObsoleteFiles.inc: add a few missed files
Antoine Brodin [Wed, 30 Jun 2021 20:34:01 +0000 (20:34 +0000)]
ObsoleteFiles.inc: add a few missed files

3 years agoAdd Thomas Munro to the committers graph
Allan Jude [Wed, 30 Jun 2021 20:09:18 +0000 (20:09 +0000)]
Add Thomas Munro to the committers graph

Reported by: gnn

3 years agolibpmc: enable pmu_utils on arm64
Mitchell Horne [Thu, 27 May 2021 20:02:04 +0000 (17:02 -0300)]
libpmc: enable pmu_utils on arm64

This allows supported libpmc to query/select from the pmu-events table,
which may have a more complete set of events than what we define
manually. A future update to these definitions should greatly improve
this support. The alias table is empty for now, until this future import
is complete.

Add the Foundation's copyright for recent work on this file.

Reviewed by: ray (slightly earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30603

3 years agohwpmc_arm64: accept raw event codes for PMC_OP_PMCALLOCATE
Mitchell Horne [Wed, 19 May 2021 16:11:33 +0000 (13:11 -0300)]
hwpmc_arm64: accept raw event codes for PMC_OP_PMCALLOCATE

Make it possible to specify event codes without an offset of
PMC_EV_ARMV8_FIRST, by setting a machine-dependent flag. This is
required to make use of event definitions from pmu-events.

Reviewed by: ray (slightly earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30602