]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoVirtIO: Make sure the guest knows the TRIM alignment requirements
Allan Jude [Thu, 5 Nov 2020 17:10:14 +0000 (17:10 +0000)]
VirtIO: Make sure the guest knows the TRIM alignment requirements

If bhyve is used to emulate 512e access in guest OS, then discard addresses should be properly aligned.
Otherwise ioctl DIOCGDELETE fails for 512b requires on devices with 4K sector size.
see g_dev_ioctl() in sys/geom/geom_dev.c

Submitted by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
MFC after: 1 week
Sponsored by: vStack.com
Differential Revision: https://reviews.freebsd.org/D27075

3 years agopmcstat: fix PPC kernel symbol resolution
Leandro Lupori [Thu, 5 Nov 2020 16:47:23 +0000 (16:47 +0000)]
pmcstat: fix PPC kernel symbol resolution

PowerPC kernel is of DYN type and it has a base address where it is
initially loaded, before being relocated. As the start address passed to
pmcstat_image_link() is where the kernel was relocated to, but the symbols
always use the original base address, we need to subtract it to get the
correct offset.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26114

3 years agolibpmc: add support for POWER8/9 PMCs
Leandro Lupori [Thu, 5 Nov 2020 16:41:28 +0000 (16:41 +0000)]
libpmc: add support for POWER8/9 PMCs

This change adds support for POWER8/9 performance counters.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26113

3 years ago[PowerPC] hwpmc: add support for POWER8/9 PMCs
Leandro Lupori [Thu, 5 Nov 2020 16:36:39 +0000 (16:36 +0000)]
[PowerPC] hwpmc: add support for POWER8/9 PMCs

This change adds support for POWER8 and POWER9 PMCs (bare metal and
pseries).
All PowerISA 2.07B non-random events are supported.

Implementation was based on that of PPC970.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26110

3 years agomalloc: add a helper returning size allocated for given request
Mateusz Guzik [Thu, 5 Nov 2020 16:21:21 +0000 (16:21 +0000)]
malloc: add a helper returning size allocated for given request

Sample usage: kernel modules can decide whether to stick to malloc or
create their own zone.

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

3 years agocryptotest: Add qat(4) coverage
Mark Johnston [Thu, 5 Nov 2020 16:00:57 +0000 (16:00 +0000)]
cryptotest: Add qat(4) coverage

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoAdd firmware modules for qat(4)
Mark Johnston [Thu, 5 Nov 2020 16:00:30 +0000 (16:00 +0000)]
Add firmware modules for qat(4)

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoAdd qat(4)
Mark Johnston [Thu, 5 Nov 2020 15:55:23 +0000 (15:55 +0000)]
Add qat(4)

This provides an OpenCrypto driver for Intel QuickAssist devices.  The
driver was initially ported from NetBSD and comes with a few
improvements:
- support for GMAC/AES-GCM, AES-CTR and AES-XTS, and support for
  SHA/HMAC-authenticated encryption
- support for detaching the driver
- various bug fixes
- DH895X support

Discussed with: jhb
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)
Differential Revision: https://reviews.freebsd.org/D26963

3 years agoRationalize per-cpu zones.
Mateusz Guzik [Thu, 5 Nov 2020 15:08:56 +0000 (15:08 +0000)]
Rationalize per-cpu zones.

The 2 provided zones had inconsistent naming between each other
("int" and "64") and other allocator zones (which use bytes).

Follow malloc by naming them "pcpu-" + size in bytes.

This is a step towards replacing ad-hoc per-cpu zones with
general slabs.

3 years ago[PowerPC] Make PPC 970 PMC SPRs the standard ones
Leandro Lupori [Thu, 5 Nov 2020 14:15:50 +0000 (14:15 +0000)]
[PowerPC] Make PPC 970 PMC SPRs the standard ones

And add a _74XX suffix to 74XX SPRs.

This is a preparation for adding support to POWER8/9 PMCs, which have most
SPRs equal to 970 ones.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26532

3 years agopoll/select: change selfd_zone into a malloc type
Mateusz Guzik [Thu, 5 Nov 2020 12:24:37 +0000 (12:24 +0000)]
poll/select: change selfd_zone into a malloc type

On a sample box vmstat -z shows:

ITEM                   SIZE  LIMIT     USED     FREE      REQ
64:                      64,      0, 10437844367538,3698187229
selfd:                   64,      0,    1520,   13726,182729008

But at the same time:
vm.uma.selfd.keg.domain.1.pages: 121
vm.uma.selfd.keg.domain.0.pages: 121

Thus 242 pages got pulled even though the malloc zone would likely accomodate
the load without using extra memory.

3 years agovfs: change nt_zone into a malloc type
Mateusz Guzik [Thu, 5 Nov 2020 12:06:50 +0000 (12:06 +0000)]
vfs: change nt_zone into a malloc type

Elements are small in size and allocated for short periods.

3 years agotmpfs: reorder struct tmpfs_node to shrink it by 8 bytes
Mateusz Guzik [Thu, 5 Nov 2020 11:24:45 +0000 (11:24 +0000)]
tmpfs: reorder struct tmpfs_node to shrink it by 8 bytes

The reduction (232 -> 224 bytes) allows UMA to fit one more item (17 -> 18)
per slab as reported in vm.uma.TMPFS_node.keg.ipers.

3 years agoStop trying to bounce in memory allocated by bus dma
Andrew Turner [Thu, 5 Nov 2020 09:55:55 +0000 (09:55 +0000)]
Stop trying to bounce in memory allocated by bus dma

Memory allocated by bus_dmamem_alloc will take into account any alignment
requirements of the CPU it's running on. Stop trying to bounce in this case
as there is no bounce zone allocated.

Reported by: manu, tuexen
Tested by: manu
Sponsored by: Innovate UK

3 years agoRestrict locale settings to the file they occur in
Stefan Eßer [Thu, 5 Nov 2020 08:58:21 +0000 (08:58 +0000)]
Restrict locale settings to the file they occur in

This prevents LANG= in an included file from affecting the interpretation
of month and day names in the including file.

Make the internal pre-processor accept white space between the "#" at
the start of the line and the keyword for better compatibility with cpp.

Add support for the cpp keywords #warning and #error.

MFC after: 3 days

3 years agoAdd sbuf streaming mode to pseudofs(9), use in linprocfs(5)
Conrad Meyer [Thu, 5 Nov 2020 06:48:51 +0000 (06:48 +0000)]
Add sbuf streaming mode to pseudofs(9), use in linprocfs(5)

Add a pseudofs node flag 'PFS_AUTODRAIN', which automatically emits sbuf
contents to the caller when the sbuf buffer fills.  This is only
permissible if the corresponding PFS node fill function can sleep
whenever it appends to the sbuf.

linprocfs' /proc/self/maps node happens to meet this requirement.
Streaming out the file as it is composed avoids truncating the output
and also avoids preallocating a very large buffer.

Reviewed by: markj; earlier version: emaste, kib, trasz
Differential Revision: https://reviews.freebsd.org/D27047

3 years agoimgact_binmisc: fix up some minor nits
Kyle Evans [Thu, 5 Nov 2020 04:19:48 +0000 (04:19 +0000)]
imgact_binmisc: fix up some minor nits

- Removed a bunch of redundant headers
- Don't explicitly initialize to 0
- The !error check prior to setting imgp->interpreter_name is redundant, all
  error paths should and do return or go to 'done'. We have larger problems
  otherwise.

3 years agozfs: lz4: add optional kmem_alloc support
Mateusz Guzik [Thu, 5 Nov 2020 03:25:23 +0000 (03:25 +0000)]
zfs: lz4: add optional kmem_alloc support

lz4 port from illumos to Linux added a 16KB per-CPU cache to accommodate for
the missing 16KB malloc. FreeBSD supports this size, making the extra cache
harmful as it can't share buckets.

3 years agofd: make all f_count uses go through refcount_*
Mateusz Guzik [Thu, 5 Nov 2020 02:12:33 +0000 (02:12 +0000)]
fd: make all f_count uses go through refcount_*

3 years agofd: hide _fdrop 0 count check behind INVARIANTS
Mateusz Guzik [Thu, 5 Nov 2020 02:12:08 +0000 (02:12 +0000)]
fd: hide _fdrop 0 count check behind INVARIANTS

While here use refcount_load and make sure to report the tested value.

3 years agoriscv: set kernel_pmap hart mask more precisely
Mitchell Horne [Thu, 5 Nov 2020 00:52:52 +0000 (00:52 +0000)]
riscv: set kernel_pmap hart mask more precisely

In pmap_bootstrap(), we fill kernel_pmap->pm_active since it is
invariably active on all harts. However, this marks it as active even
for harts that don't exist in the system, which can cause issue when the
mask is passed to the SBI firmware via sbi_remote_sfence_vma().
Specifically, the SBI spec allows SBI_ERR_INVALID_PARAM to be returned
when an invalid hart is set in the mask.

The latest version of OpenSBI does not have this issue, but v0.6 does,
and this is triggering a recently added KASSERT in CI. Switch to only
setting bits in pm_active for harts that enter the system.

Reported by: Jenkins
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27080

3 years agoFix UMA alignment for COP2 context structure.
Justin Hibbits [Wed, 4 Nov 2020 23:29:27 +0000 (23:29 +0000)]
Fix UMA alignment for COP2 context structure.

UMA alignment needs specified as (power-of-2) - 1, not power-of-2.

Discussed with: gonzo
MFC after: 3 days

3 years agofix the docs, this was always wrong... In some cases, DISTDIR is set
John-Mark Gurney [Wed, 4 Nov 2020 23:26:15 +0000 (23:26 +0000)]
fix the docs, this was always wrong...  In some cases, DISTDIR is set
automatically by tools via /etc/make.conf, so remind people (me) where
to find where it's set..

It would be nice for someone to document what DISTDIR is better than:
where the file for a distribution gets installed

3 years agopipe: whitespace nit in previous
Mateusz Guzik [Wed, 4 Nov 2020 23:17:41 +0000 (23:17 +0000)]
pipe: whitespace nit in previous

3 years agopipe: fix POLLHUP handling if no events were specified
Mateusz Guzik [Wed, 4 Nov 2020 23:11:54 +0000 (23:11 +0000)]
pipe: fix POLLHUP handling if no events were specified

Linux allows polling without any events specified and it happens to be the case
in FreeBSD as well. POLLHUP has to be delivered regardless of the event mask
and this works fine if the condition is already present. However, if it is
missing, selrecord is only called if the eventmask has relevant bits set. This
in particular leads to a conditon where pipe_poll can return 0 events and
neglect to selrecord, while kern_poll takes it as an indication it has to go to
sleep, but then there is nobody to wake it up.

While the problem seems systemic to *_poll handlers the least we can do is fix
it up for pipes.

Reported by: Jeremie Galarneau <jeremie.galarneau at efficios.com>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27094

3 years agoMake the tests work without COMPAT_FREEBSD12 in kernel.
Jung-uk Kim [Wed, 4 Nov 2020 22:41:54 +0000 (22:41 +0000)]
Make the tests work without COMPAT_FREEBSD12 in kernel.

sysctl 'kern.cryptodevallowsoft' was renamed to 'kern.crypto.allow_soft' in
r359374 and the prevous one is only available in kernel built with
"options COMPAT_FREEBSD12".

3 years agoAdd regression tests for conditions and comments
Stefan Eßer [Wed, 4 Nov 2020 22:29:01 +0000 (22:29 +0000)]
Add regression tests for conditions and comments

Fix one case where #else was not corerctly processed and simplify the
conditions logic.

Fix parsing of day and month names in the locale specified in the calendar
file. The previous version would expect those names to match the locale of
the user.

Mention that comments are now correctly processed and that // is supported
in addition to /* ... */.

MFC after: 3 days

3 years agoatkbdc(4): Add quirk for "System76 lemur Pro" laptops.
Vladimir Kondratyev [Wed, 4 Nov 2020 21:52:10 +0000 (21:52 +0000)]
atkbdc(4): Add quirk for "System76 lemur Pro" laptops.

Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
and unconditionally sets a number of quirks to workaround known issues.

Exclude "System76" laptops from this set as they appeared to be a
traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
Chromebook platform makes keyboard on this devices inoperable.

"Purism Librem" laptops may require the same exclusion too.

PR: 250711
Reported by: nick.lott@gmail.com
MFC after: 2 weeks

3 years agoUnbreak buildworld after r367339.
Edward Tomasz Napierala [Wed, 4 Nov 2020 21:39:04 +0000 (21:39 +0000)]
Unbreak buildworld after r367339.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoBump __FreeBSD_version after rms changes
Mateusz Guzik [Wed, 4 Nov 2020 21:23:25 +0000 (21:23 +0000)]
Bump __FreeBSD_version after rms changes

3 years agozfs: use rms lock for teardown handling
Mateusz Guzik [Wed, 4 Nov 2020 21:22:41 +0000 (21:22 +0000)]
zfs: use rms lock for teardown handling

This deserializes otherwise non-contending operations.

The previous scheme of using 17 locks hashed by curthread runs into
conflicts very quickly.

3 years agozfs: macroify teardown handling
Mateusz Guzik [Wed, 4 Nov 2020 21:19:54 +0000 (21:19 +0000)]
zfs: macroify teardown handling

3 years agozfs: rename teardown inactive macros to mimick rrm convention
Mateusz Guzik [Wed, 4 Nov 2020 21:19:25 +0000 (21:19 +0000)]
zfs: rename teardown inactive macros to mimick rrm convention

3 years agozfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros
Mateusz Guzik [Wed, 4 Nov 2020 21:18:51 +0000 (21:18 +0000)]
zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros

They are expected to fail only in corner cases.

3 years agozfs: even up assert
Mateusz Guzik [Wed, 4 Nov 2020 21:18:27 +0000 (21:18 +0000)]
zfs: even up assert

3 years agorms: fixup concurrent writer handling and add more features
Mateusz Guzik [Wed, 4 Nov 2020 21:18:08 +0000 (21:18 +0000)]
rms: fixup concurrent writer handling and add more features

Previously the code had one wait channel for all pending writers.
This could result in a buggy scenario where after a writer switches
the lock mode form readers to writers goes off CPU, another writer
queues itself and then the last reader wakes up the latter instead
of the former.

Use a separate channel.

While here add features to reliably detect whether curthread has
the lock write-owned. This will be used by ZFS.

3 years agodtb/rockchip: Add rockpi-4 to the build
Emmanuel Vadot [Wed, 4 Nov 2020 20:15:14 +0000 (20:15 +0000)]
dtb/rockchip: Add rockpi-4 to the build

We boot on this board to add the dtb to the build.

Requested by: Daniel Engberg <daniel.engberg.lists@pyret.net>

3 years agoAdd linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.
Edward Tomasz Napierala [Wed, 4 Nov 2020 19:54:18 +0000 (19:54 +0000)]
Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.
This will be used by fuse(4).

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

3 years agoPlug minor memory leak in dwc3 USB2/USB3 controller.
Emmanuel Vadot [Wed, 4 Nov 2020 18:23:59 +0000 (18:23 +0000)]
Plug minor memory leak in dwc3 USB2/USB3 controller.

OF_getprop_alloc called earlier requires corresponding OF_prop_free to release allocated memory.

Submitted by: kjopek@gmail.com
Differential Revision: https://reviews.freebsd.org/D27085

3 years agoMake vector-related functions in libcxxrt's demangler static
Dimitry Andric [Wed, 4 Nov 2020 17:51:09 +0000 (17:51 +0000)]
Make vector-related functions in libcxxrt's demangler static

Follow-up to r367323 by re-adding static to a number of the functions
copied from elftc's libelftc_vstr.c. This was requested by upstream.

PR: 250702
MFC after: 3 days

3 years agoamd64: Make it easier to configure exception stack sizes
Mark Johnston [Wed, 4 Nov 2020 16:42:20 +0000 (16:42 +0000)]
amd64: Make it easier to configure exception stack sizes

The amd64 kernel handles certain types of exceptions on a dedicated
stack.  Currently the sizes of these stacks are all hard-coded to
PAGE_SIZE, but for at least NMI handling it can be useful to use larger
stacks.  Add constants to intr_machdep.h to make this easier to tweak.

No functional change intended.

Reviewed by: kib
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27076

3 years agovmspace: Convert to refcount(9)
Mark Johnston [Wed, 4 Nov 2020 16:30:56 +0000 (16:30 +0000)]
vmspace: Convert to refcount(9)

This is mostly mechanical except for vmspace_exit().  There, use the new
refcount_release_if_last() to avoid switching to vmspace0 unless other
processes are sharing the vmspace.  In that case, upon switching to
vmspace0 we can unconditionally release the reference.

Remove the volatile qualifier from vm_refcnt now that accesses are
protected using refcount(9) KPIs.

Reviewed by: alc, kib, mmel
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27057

3 years agorefcount(9): Add refcount_release_if_last() and refcount_load()
Mark Johnston [Wed, 4 Nov 2020 16:30:30 +0000 (16:30 +0000)]
refcount(9): Add refcount_release_if_last() and refcount_load()

The former is intended for use in vmspace_exit().  The latter is to
encourage use of explicit loads rather than relying on the volatile
qualifier.  This works better with kernel sanitizers, which can
intercept atomic(9) calls, and makes tricky lockless code easier to read
by not forcing the reader to remember which variables are declared
volatile.

Reviewed by: kib, mjg, mmel
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27056

3 years agopmcstat: Fix a typo in the usage message
Mateusz Piotrowski [Wed, 4 Nov 2020 15:44:59 +0000 (15:44 +0000)]
pmcstat: Fix a typo in the usage message

Reviewed by: emaste
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D26082

3 years agoFix bad libbxo format strings in jls
Alex Richardson [Wed, 4 Nov 2020 14:31:52 +0000 (14:31 +0000)]
Fix bad libbxo format strings in jls

The existing format string for the empty case was trying to read varargs
values that weren't passed to xo_emit. This appears to work on x86 (since
the next argument is probably a pointer an empty string), but for CHERI
we can bound variadic arguments and detect a read past the end.

While touching these lines also use the libxo 'a' modifier to avoid having to
construct the libxo format string using asprintf.

Found by: CHERI
Reviewed By: allanjude
Differential Revision: https://reviews.freebsd.org/D26885

3 years agoacpi_video(4): mention that acpi_video should be loaded after any drm driver
Emmanuel Vadot [Wed, 4 Nov 2020 13:43:34 +0000 (13:43 +0000)]
acpi_video(4): mention that acpi_video should be loaded after any drm driver

When not adhering to this order, brightness sysctl's do not show up on some
laptop.

Submitted by:  driesm.michiels@gmail.com
Reviewed by: uqs
Differential Revision: https://reviews.freebsd.org/D26073

3 years agoarm64: implement bs_sr_<N>
Bjoern A. Zeeb [Wed, 4 Nov 2020 12:11:50 +0000 (12:11 +0000)]
arm64: implement bs_sr_<N>

Implement the bs_sr_<N> generic functions based on the generic
mips implementation calling the generic bs_w_<N> functions in a loop.

ral(4) (rt2860.c) panics in RAL_SET_REGION_4() because bs_sr_4()
is NULL.  It seems ral(4) and ti(4) might be the only consumers of
these functions I could find quickly so keeping them in C rather than asm.

Reported by: Steve Wheeler (https://redmine.pfsense.org/issues/11021)
Reviewed by: mmel
MFC after: 3 days

3 years agonet80211: fix a typo
Bjoern A. Zeeb [Wed, 4 Nov 2020 12:07:33 +0000 (12:07 +0000)]
net80211: fix a typo

Correct a typo referring to the wrong flags in a comment.
No functional changes.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")

3 years agoAdd the pmap.h changes missed in r367320
Andrew Turner [Wed, 4 Nov 2020 11:48:08 +0000 (11:48 +0000)]
Add the pmap.h changes missed in r367320

Reported by: bz
Sponsored by: Innovate UK

3 years agoTurn on WITH_LLVM_CXXFILT by default
Dimitry Andric [Wed, 4 Nov 2020 11:23:19 +0000 (11:23 +0000)]
Turn on WITH_LLVM_CXXFILT by default

LLVM's demangler supports more modern C++ constructs such as lambdas and
unnamed types, and is actively maintained. The command line tool is
usable as a drop-in replacement for GNU c++filt, or elftoolchain's
cxxfilt. The latter is still available by using WITHOUT_LLVM_CXXFILT, if
needed.

PR: 250702
MFC after: 2 weeks

3 years agoUpdate libcxxrt's private copy of elftoolchain demangler
Dimitry Andric [Wed, 4 Nov 2020 11:13:36 +0000 (11:13 +0000)]
Update libcxxrt's private copy of elftoolchain demangler

This updates the private copy of libelftc_dem_gnu3.c in libcxxrt with
the most recent version from upstream r3877. Similar to r367322, this
fixes a number of possible assertions, and allows it to correctly
demangle several names that it could not handle before.

PR: 250702
MFC after: 3 days

3 years agoMerge elftoolchain r3877 (by jkoshy):
Dimitry Andric [Wed, 4 Nov 2020 11:02:05 +0000 (11:02 +0000)]
Merge elftoolchain r3877 (by jkoshy):

  Incorporate fixes from Dimitry Andric:

  - Use a BUFFER_GROW() macro to avoid rounding errors in capacity
    calculations.
  - Fix a bug introduced in [r3531].
  - Fix handling of nested template parameters.

  Ticket: #581

This should fix a number of assertions on elftoolchain's cxxfilt, and
allow it to correctly demangle several names that it could not handle
before.

Obtained from: https://sourceforge.net/p/elftoolchain/code/3877/
PR: 250702
MFC after: 3 days

3 years agoFix a typo
Mateusz Piotrowski [Wed, 4 Nov 2020 10:38:25 +0000 (10:38 +0000)]
Fix a typo

3 years agoAllow the creation of 3 level page tables on arm64
Andrew Turner [Wed, 4 Nov 2020 10:21:30 +0000 (10:21 +0000)]
Allow the creation of 3 level page tables on arm64

The stage 2 arm64 page tables may need to start at a lower level. This
is because we may only be able to map a limited IPA range and trying
to use a full 4 levels will cause the CPU to fault in an unrecoverable
way.

To simplify the code we still allocate the full 4 levels, however level 0
will only ever be used to find the level 1 table used as the base. Handle
this by creating a dummy entry in the level 0 table to point to the level 1
table.

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

3 years agoRemove unnecessary __DECONST().
John Baldwin [Tue, 3 Nov 2020 22:53:23 +0000 (22:53 +0000)]
Remove unnecessary __DECONST().

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27063

3 years agoReplace some K&R function definitions with ANSI C.
John Baldwin [Tue, 3 Nov 2020 22:32:30 +0000 (22:32 +0000)]
Replace some K&R function definitions with ANSI C.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27062

3 years agoConsistently use C99 fixed-width types in the in-kernel crypto code.
John Baldwin [Tue, 3 Nov 2020 22:27:54 +0000 (22:27 +0000)]
Consistently use C99 fixed-width types in the in-kernel crypto code.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D27061

3 years agoUpdate man-page to document changes made to the calendar program.
Stefan Eßer [Tue, 3 Nov 2020 22:13:16 +0000 (22:13 +0000)]
Update man-page to document changes made to the calendar program.

MFC after: 3 days

3 years agoStyle, not functional changes:
Gleb Smirnoff [Tue, 3 Nov 2020 22:04:32 +0000 (22:04 +0000)]
Style, not functional changes:
- Improve spelling of a false check [1]
- A missing line from r367150.

Submitted by: kib

3 years agoAlways return MMC errors from mmc_handle_reply()
Ilya Bakulin [Tue, 3 Nov 2020 21:38:59 +0000 (21:38 +0000)]
Always return MMC errors from mmc_handle_reply()

There are two ways to propagate the error in MMCCAM:
 * Using cmd.error which is set by the peripheral driver;
 * Using CCB status which is... also set by the driver.

The problem is that those two error conditions don't necessarily match.
This leads to the confusion when handling the MMC reply. So enforce the consistency
by panicking if request is marked as completed successfully but MMC-level error
is present (this hints to the programming error).

Reviewed by: manu
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D26925

3 years agoAdd WITH_LLVM_CXXFILT option to install llvm-cxxfilt as c++filt
Dimitry Andric [Tue, 3 Nov 2020 19:57:28 +0000 (19:57 +0000)]
Add WITH_LLVM_CXXFILT option to install llvm-cxxfilt as c++filt

Since elftoolchain's cxxfilt is rather far behind on features, and we
ran into several bugs, add an option to use llvm-cxxfilt as an drop-in
replacement.

It supports the same options as elftoolchain cxxfilt, though it doesn't
have support for old ARM (C++ Annotated Reference Manual, not the CPU)
and GNU v2 manglings. But these are irrelevant in 2020.

Note: as we already compile the required libraries as part of libllvm,
this will not add any significant build time either.

PR: 250702
Reviewed by: emaste, yuri
Differential Revision: https://reviews.freebsd.org/D27071
MFC after: 2 weeks

3 years agolinux(4): Improve netlink diagnostics
Conrad Meyer [Tue, 3 Nov 2020 19:50:42 +0000 (19:50 +0000)]
linux(4): Improve netlink diagnostics

Add some missing netlink_family definitions and produce vaguely
human-readable error messages for those definitions, like we used to do for
just ROUTE and KOBJECT_UEVENTS.

Additionally, if we know it's a netfilter socket but didn't find it in the
table, fall back to printing that instead of the generic handler ("socket
domain 16, ...").

No change to the emulator correctness, just mildly improved diagnostics for
gaps.

3 years agosysvshm: pass relevant uap members as arguments
Brooks Davis [Tue, 3 Nov 2020 19:14:03 +0000 (19:14 +0000)]
sysvshm: pass relevant uap members as arguments

Alter shmget_allocate_segment and shmget_existing to take the values
they want from struct shmget_args rather than passing the struct
around.  In general, uap structures should only be the interface to
sys_<foo> functions.

This makes on small functional change and records the allocated space
rather than the requested space.  If this turns out to be a problem (e.g.
if software tries to find undersized segments by exact size rather than
using keys), we can correct that easily.

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

3 years agoMake linux_errtbl[] static.
Edward Tomasz Napierala [Tue, 3 Nov 2020 19:12:33 +0000 (19:12 +0000)]
Make linux_errtbl[] static.

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

3 years agobuild.7: Mention etcupdate(8) alongside mergemaster(8)
Mateusz Piotrowski [Tue, 3 Nov 2020 18:13:42 +0000 (18:13 +0000)]
build.7: Mention etcupdate(8) alongside mergemaster(8)

MFC after: 3 days

3 years agoFix a typo in the description of WITH_DEBUG_PORTS
Mateusz Piotrowski [Tue, 3 Nov 2020 18:02:02 +0000 (18:02 +0000)]
Fix a typo in the description of WITH_DEBUG_PORTS

For each origin listed in WITH_DEBUG_PORTS, the ports framework sets
WITH_DEBUG instead of WITH_DEBUG_PORTS.

MFC after: 3 days

3 years agoFix rookie mistake - it's nitems(), not sizeof().
Edward Tomasz Napierala [Tue, 3 Nov 2020 14:44:33 +0000 (14:44 +0000)]
Fix rookie mistake - it's nitems(), not sizeof().

Reported by: xtouqh_icloud.com
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoif_media.c SIOCGMEDIAX handler: improve loop
Konstantin Belousov [Tue, 3 Nov 2020 14:33:04 +0000 (14:33 +0000)]
if_media.c SIOCGMEDIAX handler: improve loop

Stop advancing counter past the current iteration number at the start
of iteration.  This removes the need of subtracting one when
calculating index for copyout, and arguably fixes off-by-one reporting
of copied out elements when copyout failed.

Reviewed by: hselasky
Sponsored by: Mellanox Technologies / NVidia Networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27073

3 years agoDocument how to set ports options via make.conf(5)
Mateusz Piotrowski [Tue, 3 Nov 2020 13:26:00 +0000 (13:26 +0000)]
Document how to set ports options via make.conf(5)

This patch is based on:
- https://lists.freebsd.org/pipermail/freebsd-ports-announce/2013-June/000062.html
- current content of /usr/ports/Mk/bsd.options.mk

PR: 194306
Reported by: Daan K. <daanknip__hotmail_com>
MFC after: 2 weeks

3 years agoReplace literal uses of /usr/local with a variable
Stefan Eßer [Tue, 3 Nov 2020 12:29:10 +0000 (12:29 +0000)]
Replace literal uses of /usr/local with a variable

The variable defaults to "/usr/local", unless sysctl returns some other
value for "user.localbase".

The value of user.localbase defaults to _PATH_LOCALBASE as defined in
paths.h and thus this commit has no immediate effect.

The purpose of this change is to make /etc/defaults/rc.conf automatically
use the value of _PATH_LOCALBASE when not set to the default value.

Reviewed by: imp, scottl
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D27014

3 years agoConsistently print calendar dates in the locale of the user
Stefan Eßer [Tue, 3 Nov 2020 12:15:08 +0000 (12:15 +0000)]
Consistently print calendar dates in the locale of the user

Calendar files that specify LANG=... to specify their character encoding did
also set the date format defined for that locale, resulting in output like:

Nov  4  Gabriel Faure dies from pneumonia in Paris, France, 1924
 4 nov.  N'oubliez pas les Charles !

After this commit the output is always printed in a consistent format
according to the user's current locale, e.g.:

Nov  4  Gabriel Faure dies from pneumonia in Paris, France, 1924
Nov  4  N'oubliez pas les Charles !

I'll open a review asking for opinions whether this format change should
be merged to -STABLE.

Relnotes: yes

3 years agoCheck that #ifdef, #ifndef, and #undef are used with a single name
Stefan Eßer [Tue, 3 Nov 2020 11:37:19 +0000 (11:37 +0000)]
Check that #ifdef, #ifndef, and #undef are used with a single name

This restores the parameter validation that has been peformed by cpp
for defining and testing of names used in conditions.

MFC after: 3 days

3 years agorc.d/zfs: Add shutdown to KEYWORDS
Mateusz Piotrowski [Tue, 3 Nov 2020 10:02:52 +0000 (10:02 +0000)]
rc.d/zfs: Add shutdown to KEYWORDS

The problem is that Without walling /etc/rc.d/zfs on shutdown, resources
associated with ZFS mounts are not freed and the jails will remain in dying
state. In addition, the dataset is now in a dangling state, as the jail it
is attached to is dying.

A known workaround for jails was to add the following lines
to /etc/jail.conf, to make sure that "service zfs stop" is run
when the jail is stopped:

    exec.stop = "/bin/sh /etc/rc.shutdown";
    exec.stop += "/usr/sbin/service zfs stop || /usr/bin/true";

While the workaround seems to be okay-ish for the jail situation, it is
still unclean. However, for physical hosts this may wreak havoc with the
pool if shared spares are used, as "zfs unshare" is never invoked on
shutdown.

PR: 147444
Submitted by: Markus Stoff <markus__stoffdv_at>
Reported by: Mykah <mburkhardt__exavault_com>
Reviewed by: cy
Approved by: cy (src)
MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27039

3 years agolinux(4) prctl(2): Implement PR_[GS]ET_DUMPABLE
Conrad Meyer [Tue, 3 Nov 2020 02:10:54 +0000 (02:10 +0000)]
linux(4) prctl(2): Implement PR_[GS]ET_DUMPABLE

Proxy the flag to the roughly analogous FreeBSD procctl 'TRACE'.

TRACE-disabled processes are not coredumped, and Linux !DUMPABLE processes
can not be ptraced.  There are some additional semantics around ownership of
files in the /proc/[pid] pseudo-filesystem, which we do not attempt to
emulate correctly at this time.

Reviewed by: markj (earlier version)
Differential Revision: https://reviews.freebsd.org/D27015

3 years agolinux(4): Emulate Linux SOL_SOCKET:SO_PASSCRED
Conrad Meyer [Tue, 3 Nov 2020 01:19:13 +0000 (01:19 +0000)]
linux(4): Emulate Linux SOL_SOCKET:SO_PASSCRED

This is required by some major linux applications, such as Chrome and
Firefox.  (As well as Electron-using applications, which are essentially
a bundled version of Chrome.)

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

3 years agounix(4): Add SOL_LOCAL:LOCAL_CREDS_PERSISTENT
Conrad Meyer [Tue, 3 Nov 2020 01:17:45 +0000 (01:17 +0000)]
unix(4): Add SOL_LOCAL:LOCAL_CREDS_PERSISTENT

This option is intended to be semantically identical to Linux's
SOL_SOCKET:SO_PASSCRED.  For now, it is mutually exclusive with the
pre-existing sockopt SOL_LOCAL:LOCAL_CREDS.

Reviewed by: markj (penultimate version)
Differential Revision: https://reviews.freebsd.org/D27011

3 years agolinux(4): style: Eliminate dead 'break' after 'return'
Conrad Meyer [Tue, 3 Nov 2020 01:10:27 +0000 (01:10 +0000)]
linux(4): style: Eliminate dead 'break' after 'return'

No functional change.

3 years agoifconfig: properly detect invalid mediaopt keywords.
Konstantin Belousov [Mon, 2 Nov 2020 21:47:34 +0000 (21:47 +0000)]
ifconfig: properly detect invalid mediaopt keywords.

When invalid keyword is specified, ifconfig(8) is silent about it,
instead random request is sent to the driver.

Before the patch:
root@r-freeb43:~ # ifconfig mce0 mediaopt -txpause,-rxpause
ifconfig: SIOCSIFMEDIA (media): Device not configured

After:
root@r-freeb43:~ # ifconfig mce0 mediaopt -txpause,-rxpause
ifconfig: unknown option: -txpause

Reviewed by: hselasky, kp
Sponsored by: Mellanox Technologies / NVidia Networking
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D27060

3 years agorelease: Add an image for CI
Emmanuel Vadot [Mon, 2 Nov 2020 21:10:49 +0000 (21:10 +0000)]
release: Add an image for CI

A lot of projects CI can't do FreeBSD tests currently.
The main reason is that the project CI infrastructure is runned on Linux
and that our images aren't modifiable from a Linux hosts.
Add a basic image specific for this case (called BASIC-CI for a lack of a
better name).
The image have no package pre-installed.
It only have a few modification to have dhcp client runned on the default
interface and sshd started with option to be able to log on without a password
as root.

Sponsored by: The FreeBSD Foundation

Reviewed by: re (gjb@)
Differential Revision: https://reviews.freebsd.org/D25598

3 years agoAdd routines for ARM System MMU (SMMU) pmap management.
Ruslan Bukin [Mon, 2 Nov 2020 19:56:15 +0000 (19:56 +0000)]
Add routines for ARM System MMU (SMMU) pmap management.

Reviewed by: markj
Discussed with: kib
Sponsored by: DARPA, Innovate UK
Differential Revision: https://reviews.freebsd.org/D26877

3 years agoTidy up the #includes. Recent changes, such as the introduction of
Alan Cox [Mon, 2 Nov 2020 19:20:06 +0000 (19:20 +0000)]
Tidy up the #includes.  Recent changes, such as the introduction of
VM_ALLOC_WAITOK and vm_page_unwire_noq(), have eliminated the need for
many of the #includes.

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

3 years agoRe-arrange some of the code to separate writable user tree variables from
Stefan Eßer [Mon, 2 Nov 2020 18:48:06 +0000 (18:48 +0000)]
Re-arrange some of the code to separate writable user tree variables from
R/O variables.

While here fix some nearby style. No functional change intended.

MFC after: 1 month

3 years agolinux(4): Quiesce unrecognized ioctl warning for F2FS query
Conrad Meyer [Mon, 2 Nov 2020 18:45:43 +0000 (18:45 +0000)]
linux(4): Quiesce unrecognized ioctl warning for F2FS query

On Linux, sqlite probes for underlying F2FS filesystems that support
certain kinds of atomic update with this ioctl.  The expected result on
non-F2FS filesystem (i.e., all FreeBSD filesystems) is any error value.

Minimally implement the ioctl and avoid the warning message.

(This shows up in Linux Chrome, which embeds sqlite.)

Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D27050

3 years agolinux(4): Deduplicate ioctl range construction with a helper macro
Conrad Meyer [Mon, 2 Nov 2020 18:45:15 +0000 (18:45 +0000)]
linux(4): Deduplicate ioctl range construction with a helper macro

No functional change.

Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D27049

3 years agopkgbase: Add incremental packages
Emmanuel Vadot [Mon, 2 Nov 2020 18:23:50 +0000 (18:23 +0000)]
pkgbase: Add incremental packages

This adds a new target update-packages which will create the new packages
compared to the last run.

This is how to use it:
At this point we cut a release
$ make buildworld ...
$ make buildkernel
$ make packages

    There is now a PKG_VERSION directory with latest link pointing to it
    Distribute the packages to server

$ something something that update the source tree
$ make buildworld ...
$ make buildkernel
$ make update-packages
You know have a PKG_VERSION directory in the REPODIR and latest link pointing to it.
In PKG_VERSION dir only the packages which differs from the latest run are
named PKG_VERSION, otherwise the old packages are there.

The process is :
Build the new packages in the PKG_VERSION directory
Compare the internal data with the PKG_VERSION_FROM version. The comparison is done
by checking the internal hash of the packages.
By default PKG_VERSION_FROM is set to what the latest link points to.
If the old and new version matches, we rm the new package and cp the old one.

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

3 years agozfs: zstd: short-circuit cleaning buffers if none exist
Mateusz Guzik [Mon, 2 Nov 2020 17:39:59 +0000 (17:39 +0000)]
zfs: zstd: short-circuit cleaning buffers if none exist

This avoids a barrage of locking every minute.

3 years agomalloc: prefix zones with malloc-
Mateusz Guzik [Mon, 2 Nov 2020 17:39:15 +0000 (17:39 +0000)]
malloc: prefix zones with malloc-

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

3 years agomalloc: export kernel zones instead of relying on them being power-of-2
Mateusz Guzik [Mon, 2 Nov 2020 17:38:08 +0000 (17:38 +0000)]
malloc: export kernel zones instead of relying on them being power-of-2

Reviewed by: markj (previous version)
Differential Revision: https://reviews.freebsd.org/D27026

3 years ago[libnetmap] Fix 32 bit compilation under gcc-6.4
Adrian Chadd [Mon, 2 Nov 2020 15:01:37 +0000 (15:01 +0000)]
[libnetmap] Fix 32 bit compilation under gcc-6.4

Use uintptr_t to cast a uint64_t to a pointer type.
Yeah, it isn't technically correct for platforms with pointers
> 64 bits, but it's fine here.

This fixes 32 bit compat library builds on amd64 and also
mips32 builds.

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

3 years agoFix for referencing file via its vnode in ibore.
Hans Petter Selasky [Mon, 2 Nov 2020 10:44:29 +0000 (10:44 +0000)]
Fix for referencing file via its vnode in ibore.

Use the native vnode lookup functions, instead of going via the LinuxKPI,
because the file referenced is typically created outside the LinuxKPI, and
the LinuxKPI's fdget() can only resolve file descriptor numbers which
were created by itself.

The vnode pointer is used as an identifier to identify XRCD handles which
are sharing resources.

This patch fixes the so-called XRCD support in ibcore for FreeBSD.
Refer to ibv_open_xrcd(3) for more information how the file descriptor
argument is used.

Reviewed by: kib@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoImprove loading of multipage aligned buffers.
Michal Meloun [Mon, 2 Nov 2020 08:26:19 +0000 (08:26 +0000)]
Improve loading of multipage aligned buffers.

The multipage alignment requirements is incompatible with many aspects
of actual busdma code. Multi-page alignment requests are incompatible
with many aspects of current busdma code. Mainly with partially bounced
buffer segments and per-page loop in bus_dmamap_load_buffer(). Because
proper implementation would be a major restructuring of the code, add
the fix only for already known uses and do KASSERT for all other cases.

For this reason, bus_dmamap_load_buffer () should take the memory allocated
by bus_dmam_alloc () as one segment bypassing per page segmentation. We can
do this because it is guaranteed that the memory is physically continuous.

Reviewed by: bz
Tested by:  imp, mv, daniel.engberg.lists_pyret.net, kjopek_gmail.com
Differential Revision: https://reviews.freebsd.org/D26735

3 years agolinux(4): Disambiguate identical ioctl errors in distinct paths
Conrad Meyer [Mon, 2 Nov 2020 06:16:11 +0000 (06:16 +0000)]
linux(4): Disambiguate identical ioctl errors in distinct paths

And stop truncating the full ioctl number in the error message.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D27048

3 years agoAdd icc (Isochronous Command Completion) ccb_ataio field.
Alexander Motin [Mon, 2 Nov 2020 01:01:41 +0000 (01:01 +0000)]
Add icc (Isochronous Command Completion) ccb_ataio field.

MFC after: 1 week

3 years agoifconfig.8: Improve formatting of -f in synopsis
Mateusz Piotrowski [Sun, 1 Nov 2020 22:50:21 +0000 (22:50 +0000)]
ifconfig.8: Improve formatting of -f in synopsis

MFC after: 3 days

3 years agoRemove Tn macros from ifconfig.8
Mateusz Piotrowski [Sun, 1 Nov 2020 22:46:43 +0000 (22:46 +0000)]
Remove Tn macros from ifconfig.8

MFC after: 3 days

3 years ago[ctld] Fix compilation under gcc-6.4
Adrian Chadd [Sun, 1 Nov 2020 21:18:21 +0000 (21:18 +0000)]
[ctld] Fix compilation under gcc-6.4

* remove dup yylex symbol; already defined in a header file
* uint64_t is always >= 0

Reviewed by: cem, imp
Differential Revision: https://reviews.freebsd.org/D27046

3 years agoDo not document default locations of the OpenBSD and NetBSD ports trees
Mateusz Piotrowski [Sun, 1 Nov 2020 20:54:02 +0000 (20:54 +0000)]
Do not document default locations of the OpenBSD and NetBSD ports trees

Our own Ports Collection is not targeting those systems at the moment,
so let's stop documenting bits specific to OpenBSD and NetBSD in the ports
documentation. Especially, that it might bit rot one day.

MFC after: 1 week

3 years agoFix psoition reporting for calendar data file in system directory
Stefan Eßer [Sun, 1 Nov 2020 20:38:35 +0000 (20:38 +0000)]
Fix psoition reporting for calendar data file in system directory

MFC after: 3 days

3 years agoFix year in 2 most recent entries (2010 -> 2020)
Stefan Eßer [Sun, 1 Nov 2020 19:13:55 +0000 (19:13 +0000)]
Fix year in 2 most recent entries (2010 -> 2020)

Reported by: mack@macktronics.com (Dan Mack)

3 years agoDocument how to use sudo for SU_CMD
Mateusz Piotrowski [Sun, 1 Nov 2020 17:27:48 +0000 (17:27 +0000)]
Document how to use sudo for SU_CMD

It is rather common for the ports users to replace su(1) with sudo(8)
within the SU_CMD variable. Let's document it in the manual page (so far
it's been hidden in a comment within bsd.commands.mk).

MFC after: 2 weeks