]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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

3 years agonfsd: add KASSERTs to nfsm_trimtrailing() for M_EXTPG mbufs
Rick Macklem [Sun, 10 Jan 2021 21:50:15 +0000 (13:50 -0800)]
nfsd: add KASSERTs to nfsm_trimtrailing() for M_EXTPG mbufs

Add KASSERTS to nfsm_trimtrailing() to confirm the sanity of
the arguments for the M_EXTPG case.

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

3 years agorc.conf(5): describe devmatch rc variables
Mitchell Horne [Sun, 10 Jan 2021 20:53:59 +0000 (16:53 -0400)]
rc.conf(5): describe devmatch rc variables

Reviewed by: imp, gbe (manpages)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D28048

3 years agocgem: add 64-bit support
Thomas Skibo [Sun, 10 Jan 2021 20:18:41 +0000 (16:18 -0400)]
cgem: add 64-bit support

Add 64-bit address support to Cadence CGEM Ethernet driver for use in
other SoCs such as the Zynq UltraScale+ and SiFive HighFive Unleashed.

Reviewed by: philip, 0mp (manpages)
Differential Revision: https://reviews.freebsd.org/D24304

3 years agoPrefer the use of vm_page_domain() to vm_phys_domain().
Alan Cox [Sun, 10 Jan 2021 08:51:33 +0000 (02:51 -0600)]
Prefer the use of vm_page_domain() to vm_phys_domain().

When we already have the vm page in hand, use vm_page_domain() instead
of vm_phys_domain().  The former has a trivial constant-time
implementation whereas the latter iterates over the mem_affinity array.

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

3 years agohid: Add recently imported drivers to NOTES
Vladimir Kondratyev [Sat, 9 Jan 2021 12:07:19 +0000 (15:07 +0300)]
hid: Add recently imported drivers to NOTES

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

3 years agohid: fix extraneous SYSCTL_ADD_INT() options revealed by LINT build
Vladimir Kondratyev [Sat, 9 Jan 2021 12:06:01 +0000 (15:06 +0300)]
hid: fix extraneous SYSCTL_ADD_INT() options revealed by LINT build

Reviewed by: hselasky (as part of D28060)

3 years agore: netmap: enable/disable krings on interface reinit
Vincenzo Maffione [Sun, 10 Jan 2021 15:09:05 +0000 (15:09 +0000)]
re: netmap: enable/disable krings on interface reinit

This prevents krings from being used during an interface
reset, and notifies the active applications.
See also 1d238b07d5d4d9660ae0.

MFC after:      1 week

3 years agoiflib: fix build failure in case DEV_NETMAP is not defined
Vincenzo Maffione [Sun, 10 Jan 2021 14:42:49 +0000 (14:42 +0000)]
iflib: fix build failure in case DEV_NETMAP is not defined

This addresses the build failure introduced by
3d65fd97e85ab807f3baa62.

MFC with: 3d65fd97e85ab807f3baa62

3 years agonetmap: vtnet: enable/disable krings on any interface reinit
Vincenzo Maffione [Sun, 10 Jan 2021 14:09:00 +0000 (14:09 +0000)]
netmap: vtnet: enable/disable krings on any interface reinit

See 3d65fd97e85ab807f3b for a detailed explanation.

PR:             252453
MFC after:      1 week

3 years agoiflib: add assert to prevent out-of-bounds array access
Vincenzo Maffione [Sun, 10 Jan 2021 13:49:51 +0000 (13:49 +0000)]
iflib: add assert to prevent out-of-bounds array access

The iflib_queues_alloc() allocates isc_nrxqs iflib_dma_info structs
for each rxqset, and links each struct to a different free list.
As a result, it must be isc_nrxqs >= isc_nfl (plus the completion
queue, if present).
Add an assertion to make this constraint explicit.

MFC after: 2 weeks

3 years agoTrack pipe(2) reads and writes as rusage message receives and sends, a
Robert Watson [Fri, 1 Jan 2021 13:04:46 +0000 (13:04 +0000)]
Track pipe(2) reads and writes as rusage message receives and sends, a
feature misplaced during the transition from BSD 4.4's socket implementation
to the optimised FreeBSD pipe implementation.

MFC after: 1 week
Reviewed by: arichardson, imp
Differential Revision: https://reviews.freebsd.org/D27878

3 years agonetmap: iflib: enable/disable krings on any interface reinit
Vincenzo Maffione [Sun, 10 Jan 2021 12:00:30 +0000 (12:00 +0000)]
netmap: iflib: enable/disable krings on any interface reinit

Since 1d238b07d5d4d9660ae0e0, krings are disabled before
a reinit cycle triggered by iflib_netmap_register.
However, this operation is actually necessary also for
any interface reinit triggered by other causes (i.e.,
ifconfig commands).
We achieve this goal by moving the krings enable/disable
operation inside iflib_stop() and iflib_init_locked().

Once here, this change also removes some redundant operations
from iflib_netmap_register(), that are already performed by
iflib_stop().

PR: 252453
MFC after: 1 week

3 years agofileargs: add support for realpath
Mariusz Zaborski [Sun, 10 Jan 2021 11:44:06 +0000 (12:44 +0100)]
fileargs: add support for realpath

3 years agolibc: implement rtld_get_stack_prot() for real
Konstantin Belousov [Sun, 10 Jan 2021 03:05:42 +0000 (05:05 +0200)]
libc: implement rtld_get_stack_prot() for real

which makes stack prot correct for non-main threads created by binaries
with statically linked libthr.

Cache result, but do not engage into the full double-checked locking,
since calculation of the return value is idempotent.

PR: 252549
Reported and reviewed by: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D28075

3 years agojail: Simplify handling of prison_deref()
Jamie Gritton [Sun, 10 Jan 2021 05:05:06 +0000 (21:05 -0800)]
jail: Simplify handling of prison_deref()

Track the the current lock/reference state in a single variable,
rather than deducing the proper prison_deref() flags from a
combination of equations and hard-coded values.

3 years agotmpfs open: assert that there is no double-init of f_data.
Konstantin Belousov [Thu, 7 Jan 2021 16:34:02 +0000 (18:34 +0200)]
tmpfs open: assert that there is no double-init of f_data.

Sponsored by: The FreeBSD Foundation

3 years agotmpfs_free_tmp(): explicitly assert that tmp is locked
Konstantin Belousov [Tue, 5 Jan 2021 18:53:45 +0000 (20:53 +0200)]
tmpfs_free_tmp(): explicitly assert that tmp is locked

Despite TMPFS_UNLOCK() is done in both paths later, unlocking not locked
mutex provides different failure mode.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agotmpfs: make M_TMPFSMNT static to tmpfs_vfsops.c
Konstantin Belousov [Tue, 5 Jan 2021 18:52:42 +0000 (20:52 +0200)]
tmpfs: make M_TMPFSMNT static to tmpfs_vfsops.c

This malloc type is only used in this file.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agox86 vdso gettc: Add RDTSCP support
Konstantin Belousov [Wed, 6 Jan 2021 15:05:09 +0000 (17:05 +0200)]
x86 vdso gettc: Add RDTSCP support

Detect and use RDTSCP if available, instead of fence+RDTSC.  For AMD Zens+,
use LFENCE+RDTSC instead of RDTSCP (or MFENCE;RDTSC previously).

Reviewed by: gallatin, markj
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27986

3 years agox86 vdso gettc: eliminate duplicated code in ifunc selectors.
Konstantin Belousov [Wed, 6 Jan 2021 15:00:48 +0000 (17:00 +0200)]
x86 vdso gettc: eliminate duplicated code in ifunc selectors.

Create array of rdtsc selectors and provide helper that calculate the
index into the selectors array.

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

3 years agox86 vdso gettc: reorganize ifunctions.
Konstantin Belousov [Tue, 5 Jan 2021 21:14:11 +0000 (23:14 +0200)]
x86 vdso gettc: reorganize ifunctions.

Instead of providing ifuncs for each kind of fence, define ifuncs
that combine fence and invocation of RDTSC.  This refactoring makes
introduction of RDTSCP use possible.

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

3 years agotsc: add RDTSCP or faster variants of get_timecount()
Konstantin Belousov [Tue, 5 Jan 2021 21:00:14 +0000 (23:00 +0200)]
tsc: add RDTSCP or faster variants of get_timecount()

Use it in preference of Xfenced RDTSC if RDTSCP is supported. It is
recommended by both Intel and AMD. But, on AMD Zens and newer use
LFENCE, as recommended by AMD [*]. In particular, this means that now
AMD CPUs use more appropriate fence instead of too harsh MFENCe.

Add comment explaining the intent of the selection logic.

Reported by: gallatin [*]
Reviewed by: gallatin, markj
Tested by: gallatin, pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27986

3 years agox86: Add rdtscp32() into cpufunc.h.
Konstantin Belousov [Sat, 9 Jan 2021 20:39:19 +0000 (22:39 +0200)]
x86: Add rdtscp32() into cpufunc.h.

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

3 years agotsc: use u_int for return type for prototype, same as in definitions.
Konstantin Belousov [Tue, 5 Jan 2021 20:44:10 +0000 (22:44 +0200)]
tsc: use u_int for return type for prototype, same as in definitions.

Reviewed by: gallatin, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27986

3 years agox86 identcpu.c: fix formatting of the comment.
Konstantin Belousov [Wed, 6 Jan 2021 14:52:27 +0000 (16:52 +0200)]
x86 identcpu.c: fix formatting of the comment.

Reviewed by: gallatin, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27986

3 years agojobc: rework detection of orphaned groups.
Konstantin Belousov [Tue, 29 Dec 2020 00:41:56 +0000 (02:41 +0200)]
jobc: rework detection of orphaned groups.

Instead of trying to maintain pg_jobc counter on each process group
update (and sometimes before), just calculate the counter when needed.
Still, for the benefit of the signal delivery code, explicitly mark
orphaned groups as such with the new process group flag.

This way we prevent bugs in the corner cases where updates to the counter
were missed due to complicated configuration of p_pptr/p_opptr/real_parent
(debugger).

Since we need to iterate over all children of the process on exit, this
change mostly affects the process group entry and leave, where we need
to iterate all process group members to detect orpaned status.

(For MFC, keep pg_jobc around but unused).

Reported by: jhb
Reviewed by: jilles
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agokinfo_proc: move job-control related data collection into a new helper.
Konstantin Belousov [Thu, 31 Dec 2020 22:46:20 +0000 (00:46 +0200)]
kinfo_proc: move job-control related data collection into a new helper.

This improves code structure and allows to put the lock asserts right
into place where the locks are needed.

Also move zeroing of the kinfo_proc structure from fill_kinfo_proc_only()
to fill_kinfo_proc(), this looks more symmetrical.

Reviewed by: jilles
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agoLock proctree in around fill_kinfo_proc().
Konstantin Belousov [Thu, 31 Dec 2020 22:29:40 +0000 (00:29 +0200)]
Lock proctree in around fill_kinfo_proc().

Proctree lock is needed for correct calculation and collection of the
job-control related data in kinfo_proc.  There was even an XXX comment
about it.

Satisfy locking and lock ordering requirements by taking proctree lock
around pass over each bucket in proc_iterate(), and in sysctl_kern_proc()
and note_procstat_proc() for individual process reporting.

Reviewed by: jilles
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agotty_wait_background: improve locking.
Konstantin Belousov [Thu, 31 Dec 2020 13:45:06 +0000 (15:45 +0200)]
tty_wait_background: improve locking.

Increase the scope of the process group lock ownership.  This ensures that
we are consistent in returning EIO for tty write from an orphan and delivery
of TTYOUT signals.

Reviewed by: jilles
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agopgrp: Prevent use after free.
Konstantin Belousov [Thu, 31 Dec 2020 13:44:32 +0000 (15:44 +0200)]
pgrp: Prevent use after free.

Often, we have a process locked and need to get locked process group.
In this case, because progress group lock is before process lock,
unlocking process allows the group to be freed.  See for instance
tty_wait_background().

Make pgrp structures allocated from nofree zone, and ensure type stability
of the pgrp mutex.

Reviewed by: jilles
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agoissignal(): when handling STOP-like signals, drop sigacts mutex earlier.
Konstantin Belousov [Thu, 31 Dec 2020 01:45:12 +0000 (03:45 +0200)]
issignal(): when handling STOP-like signals, drop sigacts mutex earlier.

Reviewed by: jilles
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871

3 years agoStyle. Improve some KASSERTs messages.
Konstantin Belousov [Thu, 31 Dec 2020 00:45:47 +0000 (02:45 +0200)]
Style.  Improve some KASSERTs messages.

Reviewed by: jilles
Tested by: pho
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27871