]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agocontrib/lua: update to 5.4.2
Kyle Evans [Thu, 14 Jan 2021 05:56:18 +0000 (23:56 -0600)]
contrib/lua: update to 5.4.2

Merge commit '0ea45b9cd43ce1247eb3eee9bfd5cee3d19068e7' into main

3 years agonewvers.sh: set to ALPHA1 as part of the 13.0 cycle
Glen Barber [Thu, 14 Jan 2021 00:01:30 +0000 (19:01 -0500)]
newvers.sh: set to ALPHA1 as part of the 13.0 cycle

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agoarm64: fix early devmap assertion
Mitchell Horne [Wed, 13 Jan 2021 18:30:50 +0000 (14:30 -0400)]
arm64: fix early devmap assertion

The purpose of this KASSERT is to ensure that we do not run out of space
in the early devmap. However, the devmap grew beyond its initial size of
2MB in r336519, and this assertion did not grow with it.

A devmap mapping of a 1080p framebuffer requires 1920x1080 bytes, or
1.977 MB, so it is just barely able to fit without triggering the
assertion, provided no other devices are mapped before it. With the
addition of `options GDB` in GENERIC by bbfa199cbc16, the uart is now
mapped for the purposes of a debug port, before mapping the framebuffer.
The presence of both these conditions pushes the selected virtual
address just below the threshold, triggering the assertion.

To fix this, use the correct size of the devmap, defined by
PMAP_MAPDEV_EARLY_SIZE. Since this code is shared with RISC-V, define
it for that platform as well (although it is a different size).

PR: 25241
Reported by: gbe
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoEnable accelerated AES-XTS software crypto in GENERIC.
John Baldwin [Wed, 13 Jan 2021 21:13:01 +0000 (13:13 -0800)]
Enable accelerated AES-XTS software crypto in GENERIC.

In particular, using GELI on a root filesystem will only use
accelerated software crypto drivers if they are available before the
root filesystem is mounted.  While these modules can be loaded from
the loader, including them in GENERIC provides a better out-of-the-box
experience for users.

Both aesni(4) and armv8crypto(4) provide accelerated implementations
of the default cipher used by GELI (AES-XTS) in addition to other
ciphers.

Reviewed by: mhorne, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D28100

3 years agopf tests: pass NULL buffer to DIOCRCLRTSTATS
Kristof Provost [Wed, 13 Jan 2021 18:41:07 +0000 (19:41 +0100)]
pf tests: pass NULL buffer to DIOCRCLRTSTATS

As discovered by syzcaller this used to provoke panics.

MFC after: 1 week

3 years agopf: Don't hold PF_RULES_WLOCK during copyin() on DIOCRCLRTSTATS
Kristof Provost [Wed, 13 Jan 2021 18:30:01 +0000 (19:30 +0100)]
pf: Don't hold PF_RULES_WLOCK during copyin() on DIOCRCLRTSTATS

We cannot hold a non-sleepable lock during copyin(). This means we can't
safely count the table, so instead we fall back to the pf_ioctl_maxcount
used in other ioctls to protect against overly large requests.

Reported by: syzbot+81e380344d4a6c37d78a@syzkaller.appspotmail.com
MFC after: 1 week

3 years agoRevert "loader.efi: disable workaround for serial console on non-x86"
Toomas Soome [Wed, 13 Jan 2021 18:18:35 +0000 (20:18 +0200)]
Revert "loader.efi: disable workaround for serial console on non-x86"

This patch is creating some issues, reverting it.

This reverts commit 8b18395487506d3602205e5844e0b67ba0c0dc80.

3 years agodwwdt: Add PNP info for the driver
Emmanuel Vadot [Wed, 13 Jan 2021 17:41:34 +0000 (18:41 +0100)]
dwwdt: Add PNP info for the driver

3 years agoAdd driver for Synopsys Designware Watchdog timer.
Emmanuel Vadot [Wed, 13 Jan 2021 17:23:51 +0000 (18:23 +0100)]
Add driver for Synopsys Designware Watchdog timer.

This driver supports some arm and arm64 boards equipped with
"snps,dw-wdt"-compatible watchdog device.
Tested on RK3399-based board (RockPro64).
Once started watchdog device cannot be stopped.
Interrupt handler has mode to kick watchdog even when software does not do it
properly.
This can be controlled via sysctl: dev.dwwdt.prevent_restart.
Also - driver handles system shutdown and prevents from restart when system
is asked to reboot.

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

3 years agoloader.efi: initial terminal size should base on UEFI terminal size
Toomas Soome [Wed, 13 Jan 2021 17:05:51 +0000 (19:05 +0200)]
loader.efi: initial terminal size should base on UEFI terminal size

We do select font based on desired terminal size, we do query
UEFI terminal size with conout->QueryMode(), but by mistake, the fallback
values are used.

3 years agoSwitch the arm64 pcpu to a global register variable
Andrew Turner [Mon, 11 Jan 2021 15:43:39 +0000 (15:43 +0000)]
Switch the arm64 pcpu to a global register variable

This removes an unneeded instruction to move the pointer from x18 to a
temporary register.

Reviewed by: emaste
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26971

3 years agoCreate a stack frame when needed in the arm64 kernel
Andrew Turner [Tue, 12 Jan 2021 14:18:59 +0000 (14:18 +0000)]
Create a stack frame when needed in the arm64 kernel

When building the arm64 kernel for use with dtrace or hwpmc we need
to include a stack frame so they can extract a stack trace.

As with amd64 also build a stack frame in modules.

Sponsored by: Innovate UK

3 years agoRevert "x86 busdma_bounce: do not make assumptions about alignment of malloc(9) results."
Konstantin Belousov [Wed, 13 Jan 2021 15:40:54 +0000 (17:40 +0200)]
Revert "x86 busdma_bounce: do not make assumptions about alignment of malloc(9) results."

This reverts commit 8f54940f019ca586bcfbf189ef9974eeb0a8194a.
The free needs to be called on the address returned by malloc,
not the realigned address.

Noted by: andrew
Sponsored by: The FreeBSD Foundation

3 years agovfs: set NC_KEEPPOSENTRY alongside NOCACHE when creating a file
Mateusz Guzik [Wed, 13 Jan 2021 14:53:55 +0000 (15:53 +0100)]
vfs: set NC_KEEPPOSENTRY alongside NOCACHE when creating a file

Arguably the entire NOCACHE logic should get retired, in the meantime
at least prevent the code from evicting existing entries.

3 years agofd: add refcount argument to falloc_noinstall
Mateusz Guzik [Wed, 13 Jan 2021 14:16:38 +0000 (15:16 +0100)]
fd: add refcount argument to falloc_noinstall

This lets callers avoid atomic ops by initializing the count to required
value from the get go.

While here add falloc_abort to backpedal from this without having to
fdrop.

3 years agox86 busdma_bounce: do not make assumptions about alignment of malloc(9) results.
Konstantin Belousov [Mon, 11 Jan 2021 23:42:30 +0000 (01:42 +0200)]
x86 busdma_bounce: do not make assumptions about alignment of malloc(9) results.

Reported by: dim
Reviewed by: dim, jah
Tested by: dim, pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28108

3 years agox86 budma_bounce: style.
Konstantin Belousov [Mon, 11 Jan 2021 23:42:04 +0000 (01:42 +0200)]
x86 budma_bounce: style.

Reviewed by: dim, jah
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28108

3 years agoVariable declarations are since C99 and r363250 allowed inside for-loops.
Hans Petter Selasky [Wed, 13 Jan 2021 11:27:04 +0000 (12:27 +0100)]
Variable declarations are since C99 and r363250 allowed inside for-loops.
Partial revert of bafb68265672.

Suggested by: mmel@

3 years agolinux: mute the "unsupported prctl option 23" warnings
Edward Tomasz Napierala [Tue, 12 Jan 2021 14:47:44 +0000 (14:47 +0000)]
linux: mute the "unsupported prctl option 23" warnings

Make the PR_CAPBSET_READ prctl(2) return EINVAL without logging
any warnings; this is way too noisy with Focal.

Sponsored by: The FreeBSD Foundation

3 years agoRemove redundant rtinit() calls from tuntap.
Alexander V. Chernikov [Mon, 11 Jan 2021 23:31:37 +0000 (23:31 +0000)]
Remove redundant rtinit() calls from tuntap.

Removed code iterates over if_addrhead and tries to remove
 routes for each ifa.
This is exactly the thing that if_purgeaddrs() do, and
 if_purgeaddr() is already called in the end.

Reviewed by: glebius
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D28106

3 years agoMap IPv6 link-local prefix to the link-local ifa.
Alexander V. Chernikov [Tue, 12 Jan 2021 23:14:03 +0000 (23:14 +0000)]
Map IPv6 link-local prefix to the link-local ifa.

Currently we create link-local route by creating an always-on IPv6 prefix
 in the prefix list. This prefix is not tied to the link-local ifa.

This leads to the following problems:

First, when flushing interface addresses we skip on-link route, leaving
 fe80::/64 prefix on the interface without any IPv6 addresses.
Second, when creating and removing link-local alias we lose fe80::/64 prefix
 from the routing table.

Fix this by attaching link-local prefix to the ifa at the initial creation.

Reviewed by: hrs
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D28129

3 years agolinux: bump the default version from 3.10.0 to 3.17.0
Edward Tomasz Napierala [Wed, 13 Jan 2021 09:59:08 +0000 (09:59 +0000)]
linux: bump the default version from 3.10.0 to 3.17.0

This is required for Qt5, as found in Ubuntu Focal.  The library contains
the minimum kernel version encoded in an ELF note; this makes rtld ignore
it altogether, with a confusing error message.  Without it, things fail
like this:

$ konsole: error while loading shared libraries: libQt5Core.so.5: cannot
open shared object file: No such file or directory

For reference, the Qt kernel version requirements can be found at:
https://github.com/qt/qtbase/blob/dev/src/corelib/global/minimum-linux_p.h

Sponsored by: The FreeBSD Foundation
Reviewed By: emaste
Differential Revision: https://reviews.freebsd.org/D28105

3 years agoFix for off-by-one in GPIO driver after r368585.
Hans Petter Selasky [Tue, 12 Jan 2021 17:46:09 +0000 (18:46 +0100)]
Fix for off-by-one in GPIO driver after r368585.
While at it declare the iteration variable outside the for-loop
to appease older compilers.

Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoelftcl: add -i flag to ignore unknown flags
Ed Maste [Wed, 13 Jan 2021 03:24:52 +0000 (22:24 -0500)]
elftcl: add -i flag to ignore unknown flags

This may allow an identical elfctl invocation to be used on multiple
FreeBSD versions, with features not implemented on older releases being
silently ignored.

PR: 252629 (related)
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28130

3 years agovfs: use finstall_refed in openat
Mateusz Guzik [Tue, 12 Jan 2021 16:11:15 +0000 (17:11 +0100)]
vfs: use finstall_refed in openat

This avoids 2 atomic ops in the common case: 1 to grab an extra
reference and 1 to release it.

3 years agofd: add finstall_refed
Mateusz Guzik [Tue, 12 Jan 2021 16:05:27 +0000 (17:05 +0100)]
fd: add finstall_refed

Can be used to consume an already existing reference and consequently
avoid atomic ops.

3 years agofd: provide a dedicated closef variant for unix socket code
Mateusz Guzik [Tue, 12 Jan 2021 15:13:27 +0000 (16:13 +0100)]
fd: provide a dedicated closef variant for unix socket code

This avoids testing for td != NULL.

3 years ago[wpa] Add support for hostapd/wpa_supplicant when WITHOUT_CRYPT=YES
Adrian Chadd [Mon, 4 Jan 2021 20:39:53 +0000 (12:39 -0800)]
[wpa] Add support for hostapd/wpa_supplicant when WITHOUT_CRYPT=YES
is enabled.

This builds wpa_supplicant / hostpad using internal encryption routines
rather than using libcrypt.

This has been supported in wpa for years now, however since we use
local makefiles for this, we bitrotted dependencies and configuration
options.

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

3 years agovm_map_protect: allow to set prot and max_prot in one go.
Konstantin Belousov [Tue, 12 Jan 2021 12:43:39 +0000 (14:43 +0200)]
vm_map_protect: allow to set prot and max_prot in one go.

This prevents a situation where other thread modifies map entries
permissions between setting max_prot, then relocking, then setting prot,
confusing the operation outcome.  E.g. you can get an error that is not
possible if operation is performed atomic.

Also enable setting rwx for max_prot even if map does not allow to set
effective rwx protection.

Reviewed by: brooks, markj (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28117

3 years agoif_wg: fix modules load on !x86
Mitchell Horne [Tue, 12 Jan 2021 21:38:21 +0000 (17:38 -0400)]
if_wg: fix modules load on !x86

Only x86 provides optimized implementations via the blake2 module. The
software "reference" implementation is already included in the crypto(4)
module, we can drop the extra MODULE_DEPEND for other platforms.

Without this change, if_wg.ko could not be loaded due to the missing
dependency.

PR: 252156
Reported by: gbe
Sponsored by: The FreeBSD Foundation

3 years agonetmap: pkt-gen: fix offset hex formatting
Vincenzo Maffione [Tue, 12 Jan 2021 22:02:28 +0000 (22:02 +0000)]
netmap: pkt-gen: fix offset hex formatting

PR: 252594
Reported by: brpoole@vt.edu
MFC after: 3 days

3 years agonfs-over-tls: handle res.gid.gid_val correctly for memory allocation
Rick Macklem [Tue, 12 Jan 2021 21:59:52 +0000 (13:59 -0800)]
nfs-over-tls: handle res.gid.gid_val correctly for memory allocation

When the server side nfs-over-tls does an upcall to rpc.tlsservd(8)
for the handshake and the rpc.tlsservd "-u" command line option has
been specified, a list of gids may be returned.
The list will be returned in malloc'd memory pointed to by
res.gid.gid_val. To ensure the malloc occurs, res.gid.gid_val must
be NULL before the call. Then, the malloc'd memory needs to be free'd.
mem_free() just calls free(9), so a NULL pointer argument is fine
and a length argument == 0 is ok, since the "len" argument is not used.

This bug would have only affected nfs-over-tls and only when
rpc.tlsservd(8) is running with the "-u" command line option.

3 years agocasper: convert macros to inline functions
Mariusz Zaborski [Tue, 12 Jan 2021 18:38:10 +0000 (19:38 +0100)]
casper: convert macros to inline functions

In libcasper, the first argument to the function is a structure that
represents a connection to Casper. On systems without Casper, macros
are used to interpose the Casper functions to standard libc ones.
This may cause errors/warnings that the variable is not used.
With the inline function, there is no such problem.

I omitted this file in: 8c121177f063a187534dcd475b136c34474802cd

3 years agoFix for use-after-free in if_ure(4) driver.
Hans Petter Selasky [Tue, 12 Jan 2021 13:13:14 +0000 (14:13 +0100)]
Fix for use-after-free in if_ure(4) driver.

When detaching the if_ure(4) driver, the TX active USB transfer array may
point to freed USB transfers. Given that the number of USB transfers is
very low, simply start all transfers every time there is a packet to
keep safe from use-after-free.

PR: 252608
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoriscv pmap: add some pv list assertions
mhorne [Wed, 4 Nov 2020 17:51:10 +0000 (13:51 -0400)]
riscv pmap: add some pv list assertions

Ensure that we don't end up with a superpage in the vm_page_t's pv list.

This may help with debugging the panic reported in PR 250866, in which
l3 in pmap_remove_write() was found to be NULL. Adding a KASSERT to this
function will help narrow down the cause of this panic the next time it
occurs.

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

3 years agovfs: extend vfs:namei:lookup:return probe with nameidata
Mateusz Guzik [Tue, 12 Jan 2021 13:09:55 +0000 (13:09 +0000)]
vfs: extend vfs:namei:lookup:return probe with nameidata

3 years agovfs: add NDFREE_NOTHING and convert several NDFREE_PNBUF callers
Mateusz Guzik [Tue, 12 Jan 2021 11:36:30 +0000 (12:36 +0100)]
vfs: add NDFREE_NOTHING and convert several NDFREE_PNBUF callers

Check the comment above the routine for reasoning.

3 years agoConvert remaining cap_rights_init users to cap_rights_init_one
Mateusz Guzik [Tue, 12 Jan 2021 12:11:26 +0000 (12:11 +0000)]
Convert remaining cap_rights_init users to cap_rights_init_one

semantic patch:

@@

expression rights, r;

@@

- cap_rights_init(&rights, r)
+ cap_rights_init_one(&rights, r)

3 years agoHandle using a sub instruction in the arm64 fbt
Andrew Turner [Tue, 12 Jan 2021 12:14:09 +0000 (12:14 +0000)]
Handle using a sub instruction in the arm64 fbt

Some stack frames are too large for a store pair instruction we already
detect in the arm64 fbt code. Add support for handling subtracting the
stack pointer directly.

Sponsored by: Innovate UK

3 years agoOnly allow a store through sp in the arm64 fbt
Andrew Turner [Tue, 12 Jan 2021 11:37:06 +0000 (11:37 +0000)]
Only allow a store through sp in the arm64 fbt

When searching for an instruction to patch out in the arm64 function
boundary trace we search for a store pair with a write back. This
instruction is commonly used to store two registers to the stack
and update the stack pointer to hold space for more.

This works in many cases, however not all functions use this, e.g.
when the stack frame is too large. In these cases we may find another
instruction of the same type that doesn't store through the stack
pointer. Filter these instructions out and assume if we see one we
are past the function prologue.

Reported by: rwatson
Sponsored by: Innovate UK

3 years agoBump __FreeBSD_version after linuxkpi changes
Emmanuel Vadot [Tue, 12 Jan 2021 11:07:49 +0000 (12:07 +0100)]
Bump __FreeBSD_version after linuxkpi changes

3 years agolinuxkpi: add kernel_fpu_begin/kernel_fpu_end
Emmanuel Vadot [Tue, 12 Jan 2021 11:02:38 +0000 (12:02 +0100)]
linuxkpi: add kernel_fpu_begin/kernel_fpu_end

With newer AMD GPUs (>=Navi,Renoir) there is FPU context usage in the
amdgpu driver.
The `kernel_fpu_begin/end` implementations in drm did not even allow nested
begin-end blocks.

Submitted by: Greg V
Reviewed By: manu, hselasky
Differential Revision: https://reviews.freebsd.org/D28061

3 years agolinuxkpi: Add shrinker support
Emmanuel Vadot [Tue, 22 Dec 2020 18:15:01 +0000 (19:15 +0100)]
linuxkpi: Add shrinker support

A driver can register a shrinker that will be called when the kernel
wants to free some memory.
Add support for that in linuxkpi and call the registered shrinkers
when the lowmem event is triggered.

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

3 years agolinuxkpi: Add more pci functions needed by DRM
Emmanuel Vadot [Thu, 10 Dec 2020 16:47:11 +0000 (17:47 +0100)]
linuxkpi: Add more pci functions needed by DRM

 -pci_get_class : This function search for a matching pci device based on
   the class/subclass and returns a newly created pci_dev.
 - pci_{save,restore}_state : This is analogous to ours with the same name
 - pci_is_root_bus : Return true if this is the root bus
 - pci_get_domain_bus_and_slot : This function search for a matching pci
   device based on domain, bus and slot/function concat into a single
   unsigned int (devfn) and returns a newly created pci_dev
 - pci_bus_{read,write}_config* : Read/Write to the config space.

While here add some helper function to alloc and fill the pci_dev struct.

Reviewed by:   hselasky, bz (older version)
Differential Revision:    https://reviews.freebsd.org/D27550

3 years agopci: Add pci_find_class_from
Emmanuel Vadot [Thu, 10 Dec 2020 17:38:41 +0000 (18:38 +0100)]
pci: Add pci_find_class_from

pci_find_class_from help finding one or multiple device matching
a class and subclass.
If the from argument is not null we will first loop in the device list
until we find the matching device and only then start to check if the
class/subclass matches.

Reviewed by:   jhb
Differential Revision: https://reviews.freebsd.org/D27549

3 years agoloader.efi: disable workaround for serial console on non-x86
Toomas Soome [Mon, 11 Jan 2021 20:07:06 +0000 (22:07 +0200)]
loader.efi: disable workaround for serial console on non-x86

As efi console is drawn and with functional comconsole driver,
we can use proper terminal emulator on efi framebuffer console.

3 years agoloader.efi: reworked framebuffer setup
Toomas Soome [Mon, 11 Jan 2021 21:54:23 +0000 (21:54 +0000)]
loader.efi: reworked framebuffer setup

Pass gfx_state to efi_find_framebuffer(), so we can pick between
GOP and UGA in efi_find_framebuffer(), also we can then
set up struct gen_fb in gfx_state from efifb and isolate efi fb data
processing into framebuffer.c.

This change does allow us to clean up efi_cons_init() and reduce
BS->LocateProtocol() calls.

A little downside is that we now need to translate gen_fb back to
efifb in bootinfo.c (for passing to kernel), and we need to add few
-I options to CFLAGS.

3 years agolibthr malloc: support recursion on thr_malloc_umtx.
Konstantin Belousov [Tue, 12 Jan 2021 09:02:37 +0000 (11:02 +0200)]
libthr malloc: support recursion on thr_malloc_umtx.

One possible way the recursion can happen is during fork: suppose
that fork is called from early code that did not triggered
jemalloc(3) initialization yet. Then we lock thr_malloc lock, and
call malloc_prefork() that might require initialization of jemalloc
pthread_mutexes, calling into libthr malloc. It is safe to allow
recursion for this occurence.

PR: 252579
Reported by: Vasily Postnicov <shamaz.mazum@gmail.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agosigfastblock: do not skip cursig/postsig loop in ast()
Konstantin Belousov [Mon, 11 Jan 2021 01:22:44 +0000 (03:22 +0200)]
sigfastblock: do not skip cursig/postsig loop in ast()

Even if sigfastblock block is non-zero, non-blockable signals must be
checked on ast and delivered now.  This also affects debugger ability
to attach, because issignal() also calls ptracestop() if there is
a pending stop for debugee.

Instead of checking for sigfastblock, and either setting PENDING flag
for usermode or doing signal delivery loop, always do the loop after
checking, and then handle PENDING bit. issignal() already does the right
thing for fast-blocked case, allowing only STOPs and SIGKILL delivery to
happen.

Reported by: Vasily Postnicov <shamaz.mazum@gmail.com>, markj
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28089

3 years agosigfastblock_setpend(): do not set PEND user flag unless TDP_SIGFASTPENDING is set.
Konstantin Belousov [Mon, 11 Jan 2021 17:07:10 +0000 (19:07 +0200)]
sigfastblock_setpend(): do not set PEND user flag unless TDP_SIGFASTPENDING is set.

User pending bit should not be set if kernel did not noted a pending signal.

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

3 years agodtrace: Blacklist riscv exception handlers for fbt
Kristof Provost [Mon, 11 Jan 2021 20:23:22 +0000 (21:23 +0100)]
dtrace: Blacklist riscv exception handlers for fbt

We can't safely instrument those exception handlers, so blacklist them.

Test case: dtrace -n :::

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

3 years agoamd64: fix tlb shootdown when all cpus are passed in the bitmap
Mateusz Guzik [Tue, 12 Jan 2021 08:47:32 +0000 (08:47 +0000)]
amd64: fix tlb shootdown when all cpus are passed in the bitmap

Right now the routine leaves the current CPU in the map, later tripping
on an assert when filling in the scoreboard: panic: IPI scoreboard is
zero, initiator 1 target 1

Instead pre-check if all CPUs are present in the map and remember that
outcome for later.

Fixes: 7eaea04a5bb1dc86 ("amd64: compare TLB shootdown target to all_cpus")
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D28111

3 years agovmspace_fork: preserve wx settings in the child vm map after fork
Konstantin Belousov [Tue, 12 Jan 2021 06:09:59 +0000 (08:09 +0200)]
vmspace_fork: preserve wx settings in the child vm map after fork

Noted by: markj
Sponsored by: The FreeBSD Foundation

3 years agolio_listio: validate aio_lio_opcode
Alan Somers [Sun, 10 Jan 2021 03:23:05 +0000 (20:23 -0700)]
lio_listio: validate aio_lio_opcode

Previously, we would accept any kind of LIO_* opcode, including ones
that were intended for in-kernel use only like LIO_SYNC (which is not
defined in userland).  The situation became more serious with
022ca2fc7fe08d51f33a1d23a9be49e6d132914e.  After that revision, setting
aio_lio_opcode to LIO_WRITEV or LIO_READV would trigger an assertion.

Note that POSIX does not specify what should happen if aio_lio_opcode is
invalid.

MFC-with: 022ca2fc7fe08d51f33a1d23a9be49e6d132914e
Reviewed by: jhb, tmunro, 0mp
Differential Revision: <https://reviews.freebsd.org/D28078

3 years agoICMP checksum test: Fix for big endian
Charlie Root [Tue, 12 Jan 2021 01:56:12 +0000 (18:56 -0700)]
ICMP checksum test: Fix for big endian

The in_cksum tests originally tried to simulate a BE environment by
swapping the byte order of the input.  But that's overcomplicated, and
didn't actually work on real BE hardware.  The correct testing strategy
is just to test on the native endianness, and run the tests in both BE
and LE environments.

Submitted by: Renato Riolino <renato.riolino@eldorado.org.br>
Reviewed By: asomers
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23193

3 years agoamd64: compare TLB shootdown target to all_cpus
Andrew Gallatin [Tue, 12 Jan 2021 01:03:37 +0000 (20:03 -0500)]
amd64: compare TLB shootdown target to all_cpus

On amd64, the pmap code passes all_cpus to
smp_targeted_tlb_shootdown() when unmapping from the
kernel pmap.  This function has an optimized path to send IPIs
to all but itself, which it intends to do when the target
is all cpus.   However, we need to compare the target cpu mask
with all_cpus, rather than using CPU_ISFULLSET().  Comparing with
CPU_ISFULLSET() will only work when we have MAXCPU cpus active in
the system, otherwise, we'll be sending repeated IPIs, rather than
a single IPI to all CPUs but ourself.

Fixing this should reduce the time spent in native_lapic_ipi_wait()
as we will be sending ipis in parallel, rather than one-by-one.
This is confirmed by dtrace.

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

3 years agobsdconfig: correct utilties typo
Ed Maste [Mon, 11 Jan 2021 13:49:56 +0000 (08:49 -0500)]
bsdconfig: correct utilties typo

3 years agoEliminate lock order reversal in UFS ffs_unmount().
Kirk McKusick [Tue, 12 Jan 2021 00:44:41 +0000 (16:44 -0800)]
Eliminate lock order reversal in UFS ffs_unmount().

UFS uses a new "mntfs" pseudo file system which provides private
device vnodes for a file system to safely access its disk device.
The original device vnode is saved in um_odevvp to hold the exclusive
lock on the device so that any attempts to open it for writing will
fail. But it is otherwise unused and has its BO_NOBUFS flag set to
enforce that file systems using mntfs vnodes do not accidentally
use the original devfs vnode. When the file system is unmounted,
um_odevvp is no longer needed and is released.

The lock order reversal happens because device vnodes must be locked
before UFS vnodes. During unmount, the root directory vnode lock
is held. When when calling vrele() on um_odevvp, vrele() attempts to
exclusive lock um_odevvp causing the lock order reversal. The problem
is eliminated by doing a non-blocking exclusive lock on um_odevvp
which will always succeed since there are no users of um_odevvp.
With um_odevvp locked, it can be released using vput which does not
attempt to do a blocking exclusive lock request and thus avoids the
lock order reversal.

Sponsored by: Netflix

3 years ago[skip ci] Delete an accidentally-committed comment
Alan Somers [Tue, 12 Jan 2021 00:01:22 +0000 (17:01 -0700)]
[skip ci] Delete an accidentally-committed comment

MFC-With: 19cca0b9613d7c3058e41baf0204245119732235

3 years agorctl(4): support throttling resource usage to 0
Jason A. Harmening [Wed, 30 Dec 2020 23:29:44 +0000 (15:29 -0800)]
rctl(4): support throttling resource usage to 0

For rate-based resources that support throttling (e.g.
readiops/writeips), this fixes a divide-by-zero panic when rctl(8)
passes 0 as the throttle value.  For these resources, treat
zero-throttle requests as requests to suspend forward progress as long
as possible using the duration specified in
kern.racct.rctl.throttle_max.

PR: 251803
Reported by: chris@cretaforce.gr
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27858

3 years agoUse rn_match instead of doing indirect calls in fib_algo.
Alexander V. Chernikov [Mon, 11 Jan 2021 23:11:55 +0000 (23:11 +0000)]
Use rn_match instead of doing indirect calls in fib_algo.

Relevant inet/inet6 code has the control over deciding what
 the RIB lookup function currently is. With that in mind,
 explicitly set it to the current value (rn_match) in the
 datapath lookups. This avoids cost on indirect call.

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

3 years agoexec_new_vmspace: print useful error message on ctty if stack cannot be mapped.
Konstantin Belousov [Mon, 11 Jan 2021 18:51:07 +0000 (20:51 +0200)]
exec_new_vmspace: print useful error message on ctty if stack cannot be mapped.

After old vmspace is destroyed during execve(2), but before the new space
is fully constructed, an error during image activation cannot be returned
because there is no executing program to receive it.

In the relatively common case of failure to map stack, print some hints
on the control terminal.  Note that user has enough knobs to cause stack
mapping error, and this is the most common reason for execve(2) aborting
the process.

Requested by: jhb
Reviewed by: emaste, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28050

3 years agoImplement enforcing write XOR execute mapping policy.
Konstantin Belousov [Fri, 8 Jan 2021 22:40:04 +0000 (00:40 +0200)]
Implement enforcing write XOR execute mapping policy.

It is checked in vm_map_insert() and vm_map_protect() that PROT_WRITE |
PROT_EXEC are never specified together, if vm_map has MAP_WX flag set.
FreeBSD control flag allows specific binary to request WX exempt, and
there are per ABI boolean sysctls kern.elf{32,64}.allow_wx to enable/
disable globally.

Reviewed by: emaste, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28050

3 years agopnglite: should use ntohl
Toomas Soome [Mon, 11 Jan 2021 19:42:44 +0000 (21:42 +0200)]
pnglite: should use ntohl

Replace manual conversion with ntohl()

3 years agopf: quiet debugging printfs
Kristof Provost [Mon, 11 Jan 2021 18:28:01 +0000 (19:28 +0100)]
pf: quiet debugging printfs

Only log these when debugging output is enabled.

3 years agopfctl: Another set skip <group> fix
Kristof Provost [Mon, 11 Jan 2021 13:09:08 +0000 (14:09 +0100)]
pfctl: Another set skip <group> fix

When retrieving the list of group members we cannot simply use
ifa_lookup(), because it expects the interface to have an IP (v4 or v6)
address. This means that interfaces with no address are not found.
This presents as interfacing being alternately marked as skip and not
whenever the rules are re-loaded.

Happily we only need to fix ifa_grouplookup(). Teach it to also accept
AF_LINK (i.e. interface) node_hosts.

PR:      250994
MFC after: 3 days

3 years agoarm64: Add armv8crpyto and ossl to NOTES.
John Baldwin [Mon, 11 Jan 2021 22:27:09 +0000 (14:27 -0800)]
arm64: Add armv8crpyto and ossl to NOTES.

Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D28099

3 years agoarm64: Don't disable options GDB in LINT.
John Baldwin [Mon, 11 Jan 2021 22:26:59 +0000 (14:26 -0800)]
arm64: Don't disable options GDB in LINT.

Reviewed by: mhorne
Differential Revision: https://reviews.freebsd.org/D28098

3 years agoloader.efi: efifb_mask_from_pixfmt is missing PixelBltOnly
Toomas Soome [Mon, 11 Jan 2021 19:16:42 +0000 (21:16 +0200)]
loader.efi: efifb_mask_from_pixfmt is missing PixelBltOnly

We are missing way to set RGB masks for BLT only framebuffer.

3 years agonetmap: vtnet: fix RX initialization after netmap_reset()
Vincenzo Maffione [Mon, 11 Jan 2021 21:38:32 +0000 (21:38 +0000)]
netmap: vtnet: fix RX initialization after netmap_reset()

At device reset, we must not publish those netmap receive buffers
that are owned by userspace (nm_kr_rxspace).

MFC after: 1 week

3 years agolibthr: wrap pdfork(2), same as fork(2).
Konstantin Belousov [Sun, 10 Jan 2021 19:22:49 +0000 (21:22 +0200)]
libthr: wrap pdfork(2), same as fork(2).

Without wrapping, rtld services and malloc(3) are not guaranteed
to operate correctly in the forked child.

Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28088

3 years agoamd64 pmap: do not sleep in pmap_allocpte_alloc() with zero referenced page table...
Konstantin Belousov [Sat, 2 Jan 2021 22:27:20 +0000 (00:27 +0200)]
amd64 pmap: do not sleep in pmap_allocpte_alloc() with zero referenced page table page.

Otherwise parallel pmap_allocpte_alloc() for nearby va might also fail
allocating page table page and free the page under us.  The end result is
that we could dereference unmapped pte when doing cleanup after sleep.

Instead, on allocation failure, first free everything, only then we can
drop pmap mutex and sleep safely, right before returning to caller.
Split inner non-sleepable part of the pmap_allocpte_alloc() into a new
helper pmap_allocpte_nosleep().

Reviewed by: markj
Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27956

3 years agoamd64 pmap: rename _pmap_allocpte() to pmap_allocpte_alloc().
Konstantin Belousov [Sat, 9 Jan 2021 19:40:45 +0000 (21:40 +0200)]
amd64 pmap: rename _pmap_allocpte() to pmap_allocpte_alloc().

The function performs actual allocation of pte, as opposed to
pmap_allocpte() that uses existing free pte if pt page is already
there. This also moves function out of namespace similar to a language
reserved.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27956

3 years agoamd64 pmap: Remove wrong __unused annotation from the va argument.
Konstantin Belousov [Sat, 9 Jan 2021 20:21:34 +0000 (22:21 +0200)]
amd64 pmap: Remove wrong __unused annotation from the va argument.

Noted by: alc
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27956

3 years agoamd64 pmap: fix NULL deref in pmap_mincore().
Konstantin Belousov [Tue, 5 Jan 2021 15:36:37 +0000 (17:36 +0200)]
amd64 pmap: fix NULL deref in pmap_mincore().

pmap_pdpe() might return NULL, check for it.

Reviewed by: markj
Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27956

3 years agoFollow-up on 51da4b19be1. When booting a system with WITHOUT_IPFILTER
Gleb Smirnoff [Mon, 11 Jan 2021 20:36:54 +0000 (12:36 -0800)]
Follow-up on 51da4b19be1. When booting a system with WITHOUT_IPFILTER
the following warning printed at boot time:

  rcorder: requirement `ipfs' in file `/etc/rc.d/netif' has no providers.

Close that using BEFORE rather than REQUIRE for writing down
dependencies of optional components.

3 years agoBump amount of queued packets in for unresolved ARP/NDP entries to 16.
Alexander V. Chernikov [Mon, 11 Jan 2021 19:50:21 +0000 (19:50 +0000)]
Bump amount of queued packets in for unresolved ARP/NDP entries to 16.

Currently default behaviour is to keep only 1 packet per unresolved entry.
Ability to queue more than one packet was added 10 years ago, in r215207,
 though the default value was kep intact.

Things have changed since that time. Systems tend to initiate multiple
 connections at once for a variety of reasons.
For example, recent kern/252278 bug report describe happy-eyeball DNS
 behaviour sending multiple requests to the DNS server.

The primary driver for upper value for the queue length determination is
 memory consumption. Remote actors should not be able to easily exhaust
 local memory by sending packets to unresolved arp/ND entries.

For now, bump value to 16 packets, to match Darwin implementation.

The proper approach would be to switch the limit to calculate memory
 consumption instead of packet count and limit based on memory.

We should MFC this with a variation of D22447.

Reviewers: #manpages, #network, bz, emaste

Reviewed By: emaste, gbe(doc), jilles(doc)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D28068

3 years agondis: Per user request, delay removal to 14
Brooks Davis [Mon, 11 Jan 2021 18:11:49 +0000 (18:11 +0000)]
ndis: Per user request, delay removal to 14

We will remove ndis shortly after the 13 branch.

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

3 years agoxen: remove .swp file from public headers
Roger Pau Monné [Mon, 11 Jan 2021 17:13:57 +0000 (18:13 +0100)]
xen: remove .swp file from public headers

Should have never been there in the first place.

3 years agoAdd missing rcvar name for os-release.
Gleb Smirnoff [Mon, 11 Jan 2021 16:36:37 +0000 (08:36 -0800)]
Add missing rcvar name for os-release.

3 years agocgem: update 64-bit check
Mitchell Horne [Mon, 11 Jan 2021 00:30:41 +0000 (20:30 -0400)]
cgem: update 64-bit check

The cgem(4) driver was updated to support 64-bit bus addressing in
facdd1cd2045. However, the committed version determines this in an
un-idiomatic way. Change the compile-time conditional to check
BUS_SPACE_MAXADDR, rather than comparing int and pointer sizes.

Reported by: jrtc27

3 years agoChanges that improve DTrace FBT reliability on freebsd/arm64:
Robert Watson [Sat, 9 Jan 2021 08:38:11 +0000 (08:38 +0000)]
Changes that improve DTrace FBT reliability on freebsd/arm64:

- Implement a dtrace_getnanouptime(), matching the existing
  dtrace_getnanotime(), to avoid DTrace calling out to a potentially
  instrumentable function.

  (These should probably both be under KDTRACE_HOOKS.  Also, it's not clear
  to me that they are correct implementations for the DTrace thread time
  functions they are used in .. fixes for another commit.)

- Don't allow FBT to instrument functions involved in EL1 exception handling
  that are involved in FBT trap processing: handle_el1h_sync() and
  do_el1h_sync().

- Don't allow FBT to instrument DDB and KDB functions, as that makes it
  rather harder to debug FBT problems.

Prior to these changes, use of FBT on FreeBSD/arm64 rapidly led to kernel
panics due to recursion in DTrace.

Reliable FBT on FreeBSD/arm64 is reliant on another change from @andrew to
have the aarch64 instrumentor more carefully check that instructions it
replaces are against the stack pointer, which can otherwise lead to memory
corruption.  That change remains under review.

MFC after: 2 weeks
Reviewed by: andrew, kp, markj (earlier version), jrtc27 (earlier version)
Differential revision: https://reviews.freebsd.org/D27766

3 years agoxen/privcmd: implement the restrict ioctl
Roger Pau Monne [Thu, 25 Jun 2020 17:16:04 +0000 (19:16 +0200)]
xen/privcmd: implement the restrict ioctl

Use an interface compatible with the Linux one so that the user-space
libraries already using the Linux interface can be used without much
modifications.

This allows an open privcmd instance to limit against which domains it
can act upon.

Sponsored by: Citrix Systems R&D

3 years agoxen/privcmd: implement the dm op ioctl
Roger Pau Monne [Thu, 25 Jun 2020 16:25:29 +0000 (18:25 +0200)]
xen/privcmd: implement the dm op ioctl

Use an interface compatible with the Linux one so that the user-space
libraries already using the Linux interface can be used without much
modifications.

This allows user-space to make use of the dm_op family of hypercalls,
which are used by device models.

Sponsored by: Citrix Systems R&D

3 years agoxen/privcmd: implement the map resource ioctl
Roger Pau Monne [Tue, 23 Jun 2020 09:36:19 +0000 (11:36 +0200)]
xen/privcmd: implement the map resource ioctl

The interface is mostly the same as the Linux ioctl, so that we don't
need to modify the user-space libraries that make use of it.

The ioctl is just a proxy for the XENMEM_acquire_resource hypercall.

Sponsored by: Citrix Systems R&D

3 years agoxen/privcmd: split setup of virtual address range into helper
Roger Pau Monné [Mon, 4 Jan 2021 17:59:14 +0000 (18:59 +0100)]
xen/privcmd: split setup of virtual address range into helper

Preparatory change for further additions that will also make use of
the same code. No functional change.

Sponsored by: Citrix Systems R&D

3 years agoxen/privcmd: make some integers unsigned
Roger Pau Monné [Mon, 4 Jan 2021 18:03:09 +0000 (19:03 +0100)]
xen/privcmd: make some integers unsigned

There's no reason for them to be signed. No functional change.

Sponsored by: Citrix Systems R&D

3 years agoxen: update interface headers
Roger Pau Monné [Wed, 30 Dec 2020 11:31:12 +0000 (12:31 +0100)]
xen: update interface headers

This is a verbatim copy of the public headers from Xen 4.14.1.

No functional change intended.

Sponsored by: Citrix Systems R&D

3 years agopkgbase: correct typo in System Accounting Utilities
Ed Maste [Mon, 11 Jan 2021 13:42:47 +0000 (08:42 -0500)]
pkgbase: correct typo in System Accounting Utilities

Reported by: avg, N. J. Mann

3 years agohid: quiet -Wswitch
Ryan Libby [Mon, 11 Jan 2021 05:53:15 +0000 (21:53 -0800)]
hid: quiet -Wswitch

Gcc builds complained that not all switch cases are handled.  Add
default cases to appease gcc.

Reviewed by: hselasky (previous version), wulf
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28082

3 years agopf: quiet -Wredundant-decls for pf_get_ruleset_number
Ryan Libby [Mon, 11 Jan 2021 05:53:15 +0000 (21:53 -0800)]
pf: quiet -Wredundant-decls for pf_get_ruleset_number

In e86bddea9fe62d5093a1942cf21950b3c5ca62e5 sys/netpfil/pf/pf.h grew a
declaration of pf_get_ruleset_number.  Now delete the old declaration
from sys/net/pfvar.h.

Reviewed by: kp
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28081

3 years agodtrace tests: fix prototypes for gcc build
Ryan Libby [Mon, 11 Jan 2021 05:53:15 +0000 (21:53 -0800)]
dtrace tests: fix prototypes for gcc build

 - quiet -Wstrict-prototypes
 - provide prototypes for weak aliases

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D28036

3 years agopkgbase: Rename -acct package System Accounting Utilities
Ed Maste [Mon, 11 Jan 2021 03:27:56 +0000 (22:27 -0500)]
pkgbase: Rename -acct package System Accounting Utilities

Man pages for these tools refer to 'system accounting'.

3 years agoUse static initializers for fib algo to shift initialization
Alexander V. Chernikov [Mon, 11 Jan 2021 00:16:54 +0000 (00:16 +0000)]
Use static initializers for fib algo to shift initialization
 to ealier stage. This allows to register modules loaded at
 boot time.

Reported by: olivier

3 years agocmp: fix -s (silent) when used with skip offsets
Ed Maste [Mon, 11 Jan 2021 00:02:56 +0000 (19:02 -0500)]
cmp: fix -s (silent) when used with skip offsets

-s causes cmp to print nothing for differing files, for use when only
the exit status is of interest.

-z compares the file size first, for regular files, and fails the
comparison early if they do not match.

Prior to this change -s implied -z as an optimization, but this is not
valid when file offsets are specified.  Now, enable the -z optimization
for -s only if both skip arguments are not provided / 0.

Note that using -z with differing skip values will currently always
fail.  We may want to compare size1 - skip1 with size2 - skip2 instaead,
and in any case the man page should be clarified.

PR: 252542
Fixes: 3e6902efc802ab57fc4e9bf798f2d271b152e7f9
Reported by: William Ahern
Reviewed by: markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28071

3 years agocmp: use C99 bool for flags
Ed Maste [Mon, 11 Jan 2021 00:02:55 +0000 (19:02 -0500)]
cmp: use C99 bool for flags

MFC after: 1 week
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28072

3 years agolibdtrace: Format USDT symbols correctly based on symbol binding
Mark Johnston [Sun, 10 Jan 2021 22:46:32 +0000 (17:46 -0500)]
libdtrace: Format USDT symbols correctly based on symbol binding

Before we did not handle weak symbols correctly, sometimes resulting in
link errors from dtrace -G when processing object files where functions
with weak aliases contain USDT probes.

Reported by: rlibby
Tested by: rlibby
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agonetmap: restore hwofs and support it in iflib
Vincenzo Maffione [Sun, 10 Jan 2021 22:49:37 +0000 (22:49 +0000)]
netmap: restore hwofs and support it in iflib

Restore the hwofs functionality temporarily disabled by
7ba6ecf216fb15e8b147db2 to prevent issues with iflib.
This patch brings the necessary changes to iflib to
enable howfs to allow interface restarts without
disrupting netmap applications actively using its
rings.
After this change, it becomes possible for multiple
non-cooperating netmap applications to use non-overlapping
subsets of the available netmap rings without clashing
with each other.

PR: 252453
MFC after: 1 week

3 years agoloader: term_image_display() should test screen_buffer
Toomas Soome [Sun, 10 Jan 2021 19:56:34 +0000 (21:56 +0200)]
loader: term_image_display() should test screen_buffer

Make sure screen_buffer is not NULL.

3 years agox86 tsc: mark %eax as earlyclobber in tscp_get_timecount_low().
Konstantin Belousov [Sun, 10 Jan 2021 22:05:49 +0000 (00:05 +0200)]
x86 tsc: mark %eax as earlyclobber in tscp_get_timecount_low().

i386 codegen insists on preloading tc_priv into register on i386, and
this register cannot be %eax because RDTSCP instruction clobbers it
before it is used.

Reported and tested by: dim
MFC after: 6 days
Sponsored by: The FreeBSD Foundation