]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoAdd function getlocalbase() to libutil.
se [Wed, 18 Nov 2020 19:44:30 +0000 (19:44 +0000)]
Add function getlocalbase() to libutil.

This function returns the path to the local software base directory, by
default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.h
when building the world).

The value returned can be overridden by 2 methods:

- the LOCALBASE environment variable (ignored by SUID programs)
- else a non-default user.localbase sysctl value

Reviewed by: hps (earlier version)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D27236

3 years agoipheth(4): Fix for iOS 14
lwhsu [Wed, 18 Nov 2020 19:35:30 +0000 (19:35 +0000)]
ipheth(4): Fix for iOS 14

Fix USB tethering for iOS 14.

Inspired by: https://github.com/libimobiledevice/libimobiledevice/issues/1038

PR: 249979
Reviewed by: hselasky
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27250

3 years agomsun tests: use standard floating-point exception flags on lrint and fenv tests
alfredo [Wed, 18 Nov 2020 19:23:30 +0000 (19:23 +0000)]
msun tests: use standard floating-point exception flags on lrint and fenv tests

Some platforms have additional architecture-specific floating-point flags.
Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags,
so make sure to mask them appropriately.

This makes test pass on PowerPC64.

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

3 years agomergemaster: handle symbolic links during update.
imp [Wed, 18 Nov 2020 19:22:24 +0000 (19:22 +0000)]
mergemaster: handle symbolic links during update.

/etc/os-release is now a symbolic link to a generated file. Make
mergemaster cope with symbolic links generically. I'm no longer
a big mergemaster user, so this has only been lightly tested
by me, though Kimura-san has ran it through its paces.

Submitted by: Yasushiro KIMURA-san
PR: 242212
MFC After: 2 weeks

3 years agoWhen elftoolchain's objcopy (or strip) is rewriting a file in-place,
dim [Wed, 18 Nov 2020 18:40:58 +0000 (18:40 +0000)]
When elftoolchain's objcopy (or strip) is rewriting a file in-place,
make it create the temporary file in the same directory as the source
file by default, instead of always using $TMPDIR or /tmp. If creating
that file fails because the directory is not writable, also fallback to
$TMPDIR or /tmp.

This has also been submitted upstream as:
https://sourceforge.net/p/elftoolchain/tickets/597/

Reported by: cem
PR: 250872
MFC after: 2 weeks

3 years agoFix octeon_pmc post-r334827
jhibbits [Wed, 18 Nov 2020 17:37:01 +0000 (17:37 +0000)]
Fix octeon_pmc post-r334827

MFC after: 3 days
Sponsored by: Juniper Networks, Inc

3 years agoFix a few nits in vn_printf().
jhb [Wed, 18 Nov 2020 16:21:37 +0000 (16:21 +0000)]
Fix a few nits in vn_printf().

- Mask out recently added VV_* bits to avoid printing them twice.

- Keep VI_LOCKed on the same line as the rest of the flags.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27261

3 years agoUpdate ENA driver version to v2.3.0
mw [Wed, 18 Nov 2020 15:25:38 +0000 (15:25 +0000)]
Update ENA driver version to v2.3.0

The v2.3.0 introduces new ena_com layer, ENI metrics updates and SPDX
license tags.

Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27120

3 years agoFix mandoc lint warnings.
n_hibma [Wed, 18 Nov 2020 15:23:43 +0000 (15:23 +0000)]
Fix mandoc lint warnings.

3 years agoRename descriptions of the supported ENA devices
mw [Wed, 18 Nov 2020 15:20:01 +0000 (15:20 +0000)]
Rename descriptions of the supported ENA devices

Some of the PCI ID were described as ENA with LLQ support - it's not
fully accurate and because of that, their names were changed.

Instead of LLQ, use RSERV0 for the description of those devices.

Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27119

3 years agoAdd ENI metrics for the ENA driver
mw [Wed, 18 Nov 2020 15:17:55 +0000 (15:17 +0000)]
Add ENI metrics for the ENA driver

The new HAL allows the driver to read extra ENI stats. Exact meaning of
each of them can be found in base/ena_defs/ena_admin_defs.h file and
structure ena_admin_eni_stats.

Those stats are being updated inside of the timer service, which is
executed every second.
ENI metrics are turned off by default. They can be enabled, using the
sysctl node: dev.ena.X.eni_metrics.update_delay
0 value in this node means that the update is turned off. Other values
determine how many seconds must pass, before ENI metrics will be
updated.

They can be acquired, using sysctl:

sysctl dev.ena.X.eni_metrics

Where X stands for the interface number.

Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision: https://reviews.freebsd.org/D27118

3 years agoAdd SPDX license tag to the ENA driver files
mw [Wed, 18 Nov 2020 15:07:34 +0000 (15:07 +0000)]
Add SPDX license tag to the ENA driver files

Refering to guide: https://wiki.freebsd.org/SPDX the SPDX tag should not
replace the standard license text, however it should be added over the
standard license text to make the automation easier.

Because of that, the old license was kept, but the SPDX tag was added
on top of every ENA driver file.

Submited by:    Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27117

3 years agoAdd Rx offsets support for the ENA driver
mw [Wed, 18 Nov 2020 15:02:12 +0000 (15:02 +0000)]
Add Rx offsets support for the ENA driver

For the first descriptor in a chain the data may start at an offset.
It is optional feature of some devices, so the driver must ack that
it supports it.

The data pointer of the mbuf is simply shifted by the given value.

Submitted by:   Maciej Bielski <mba@semihalf.com>
Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27116

3 years agoAdjust ENA driver files to latest ena-com changes
mw [Wed, 18 Nov 2020 14:59:22 +0000 (14:59 +0000)]
Adjust ENA driver files to latest ena-com changes

* Use the new API of ena_trace_*
* Fix typo syndrom --> syndrome
* Remove validation of the Rx req ID (already performed in the ena-com)
* Remove usage of deprecated ENA_ASSERT macro

Submitted by:   Ido Segev <idose@amazon.com>
Submitted by:   Michal Krawczyk <mk@semihalf.com>
Obtained from:  Semihalf
Sponsored by:   Amazon, Inc
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D27115

3 years agoLACP: When suppressing distributing, return ENOBUFS
gallatin [Wed, 18 Nov 2020 14:55:49 +0000 (14:55 +0000)]
LACP: When suppressing distributing, return ENOBUFS

When links come and go, lacp goes into a "suppress distributing" mode
where it drops traffic for 3 seconds. When in this mode, lagg/lacp
historiclally drops traffic with ENETDOWN. That return value causes TCP
to close any connection where it gets that value back from the lower
parts of the stack.  This means that any TCP connection with active
traffic during a 3-second windown when an LACP link comes or goes
would get closed.

TCP treats return values of ENOBUFS as transient errors, and re-schedules
transmission later. So rather than returning ENETDOWN, lets
return ENOBUFS instead.  This allows TCP connections to be preserved.

I've tested this by repeatedly bouncing links on a Netlfix CDN server
under a moderate (20Gb/s) load and overved ENOBUFS reported back to
the TCP stack (as reported by a RACK TCP sysctl).

Reviewed by: jhb, jtl, rrs
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27188

3 years agoFix completion descriptors alignment for the ENA
mw [Wed, 18 Nov 2020 14:50:12 +0000 (14:50 +0000)]
Fix completion descriptors alignment for the ENA

The latest generation hardware requires IO CQ (completion queue)
descriptors memory to be aligned to a 4K. It needs that feature for
the best performance.

Allocating unaligned descriptors will have a big performance impact as
the packet processing in a HW won't be optimized properly. For that
purpose adjust ena_dma_alloc() to support it.

It's a critical fix, especially for the arm64 EC2 instances.

Submitted by: Ido Segev <idose@amazon.com>
Obtained from: Amazon, Inc
MFC after: 1 week
Differential revision:  https://reviews.freebsd.org/D27114

3 years agoAllow LinuxKPI types to be used in bootloaders, by checking for the
hselasky [Wed, 18 Nov 2020 13:47:11 +0000 (13:47 +0000)]
Allow LinuxKPI types to be used in bootloaders, by checking for the
_STANDALONE definition.

No functional change intended.

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

3 years agoAdd missing header file when building the LinuxKPI module separately.
hselasky [Wed, 18 Nov 2020 13:45:32 +0000 (13:45 +0000)]
Add missing header file when building the LinuxKPI module separately.

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

3 years agoFix build of USB bootloader code by adding checks for _STANDALONE being defined.
hselasky [Wed, 18 Nov 2020 13:22:22 +0000 (13:22 +0000)]
Fix build of USB bootloader code by adding checks for _STANDALONE being defined.
Currently the USB bootloader code is not part of buildworld.

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

3 years agonfs: Mark unused statistics variable as reserved
asomers [Wed, 18 Nov 2020 04:35:49 +0000 (04:35 +0000)]
nfs: Mark unused statistics variable as reserved

FreeBSD's NFS exporter has long exported some unused statistics fields.
Revision r366992 removed them from nfsstat. This revision renames those
fields in the kernel's exported structures to make it clear to other
consumers that they are unused.

Reported by: emaste
Reviewed by: emaste
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D27258

3 years agoMove ecmd memory allocation itto separate DMA tag.
mav [Wed, 18 Nov 2020 03:43:03 +0000 (03:43 +0000)]
Move ecmd memory allocation itto separate DMA tag.

Ecmd memory is not directly related to the request queue, only referenced
from it sometimes in target mode.  Separate allocation should be easier
in case of fragmented memory and can be skipped when target is not built.

MFC after: 1 month

3 years ago_umtx_op: fix robust lists after r367744
kevans [Wed, 18 Nov 2020 03:30:31 +0000 (03:30 +0000)]
_umtx_op: fix robust lists after r367744

A copy-pasto left us copying in 24-bytes at the address of the rb pointer
instead of the intended target.

Reported by: sigsys@gmail.com
Sighing: kevans

3 years agoRemove bus_dma locking/sleeping when not needed.
mav [Wed, 18 Nov 2020 02:54:05 +0000 (02:54 +0000)]
Remove bus_dma locking/sleeping when not needed.

MFC after: 1 month

3 years agoDon't allocate full XCMD_SIZE (512 bytes) on stack.
mav [Wed, 18 Nov 2020 02:12:51 +0000 (02:12 +0000)]
Don't allocate full XCMD_SIZE (512 bytes) on stack.

We need only 24 bytes (fcp_rsp_iu_t) there for isp_put_fcp_rsp_iu().

MFC after: 1 month

3 years agoRestore identification of VDEVs using non-native block size.
cy [Wed, 18 Nov 2020 01:18:45 +0000 (01:18 +0000)]
Restore identification of VDEVs using non-native block size.

    NAME         STATE     READ WRITE CKSUM
    dsk02        ONLINE       0     0     0
      mirror-0   ONLINE       0     0     0
        ada1s4a  ONLINE       0     0     0
        ada2s4a  ONLINE       0     0     0  block size: 512B configured,
     4096B native

Reviewed by: tsoome (previous FreeBSD phab version)
Differential Revision: https://reviews.freebsd.org/D26880

Upstream commit: 3928ec53395fcc26be7844dd6b63df757166c281
Reviewed-by: Matt Macy <mmacy@FreeBSD.org>
Reviewed-by: Toomas Soome <tsoome@me.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed off by: Cy Schubert <cy@FreeBSD.org>
Closes #11088

3 years agolinux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES
cem [Tue, 17 Nov 2020 21:20:11 +0000 (21:20 +0000)]
linux(4) clone(2): Correctly handle CLONE_FS and CLONE_FILES

The two flags are distinct and it is impossible to correctly handle clone(2)
without the assistance of fork1().  This change depends on the pwddesc split
introduced in r367777.

I've added a fork_req flag, FR2_SHARE_PATHS, which indicates that p_pd
should be treated the opposite way p_fd is (based on RFFDG flag).  This is a
little ugly, but the benefit is that existing RFFDG API is preserved.
Holding FR2_SHARE_PATHS disabled, RFFDG indicates both p_fd and p_pd are
copied, while !RFFDG indicates both should be cloned.

In Chrome, clone(2) is used with CLONE_FS, without CLONE_FILES, and expects
independent fd tables.

The previous conflation of CLONE_FS and CLONE_FILES was introduced in
r163371 (2006).

Discussed with: markj, trasz (earlier version)
Differential Revision: https://reviews.freebsd.org/D27016

3 years agoSplit out cwd/root/jail, cmask state from filedesc table
cem [Tue, 17 Nov 2020 21:14:13 +0000 (21:14 +0000)]
Split out cwd/root/jail, cmask state from filedesc table

No functional change intended.

Tracking these structures separately for each proc enables future work to
correctly emulate clone(2) in linux(4).

__FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof.

Reviewed by: kib
Discussed with: markj, mjg
Differential Revision: https://reviews.freebsd.org/D27037

3 years agounix(4): Enhance LOCAL_CREDS_PERSISTENT ABI
cem [Tue, 17 Nov 2020 20:01:21 +0000 (20:01 +0000)]
unix(4): Enhance LOCAL_CREDS_PERSISTENT ABI

As this ABI is still fresh (r367287), let's correct some mistakes now:

- Version the structure to allow for future changes
- Include sender's pid in control message structure
- Use a distinct control message type from the cmsgcred / sockcred mess

Discussed with: kib, markj, trasz
Differential Revision: https://reviews.freebsd.org/D27084

3 years agolinprocfs(5): Add rudimentary /proc/<pid>/mountinfo
cem [Tue, 17 Nov 2020 19:56:47 +0000 (19:56 +0000)]
linprocfs(5): Add rudimentary /proc/<pid>/mountinfo

This is used by some Linux programs using filehandles (r367773) to locate
the mountpoint for a given fsid.

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

3 years ago'make sysent' for r367773
cem [Tue, 17 Nov 2020 19:53:59 +0000 (19:53 +0000)]
'make sysent' for r367773

X-MFC-With: r367773

3 years agolinux(4): Implement name_to_handle_at(), open_by_handle_at()
cem [Tue, 17 Nov 2020 19:51:47 +0000 (19:51 +0000)]
linux(4): Implement name_to_handle_at(), open_by_handle_at()

They are similar to our getfhat(2) and fhopen(2) syscalls.

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

3 years agouplcom: add ATen/Prolific USB-232 Controller D USB ID
emaste [Tue, 17 Nov 2020 18:28:20 +0000 (18:28 +0000)]
uplcom: add ATen/Prolific USB-232 Controller D USB ID

PR: 251166
Submitted by: marcus
MFC after: 2 weeks

3 years ago[nvmecontrol] Fix type signedness warning-to-error on gcc-6.4
adrian [Tue, 17 Nov 2020 17:12:28 +0000 (17:12 +0000)]
[nvmecontrol] Fix type signedness warning-to-error on gcc-6.4

This fixes a type signedness comparison warning-to-error on
gcc-6.4. The ternary operation casts it right but the actual
assignment doesn't.

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

3 years ago[cddl] Fix lz4 function definitions to not tri pup compile.
adrian [Tue, 17 Nov 2020 17:11:07 +0000 (17:11 +0000)]
[cddl] Fix lz4 function definitions to not tri pup compile.

This tripped up in llvm compilation on amd64 noting that lz4_init/lz4_fini
were lacking in being previously defined.

Reviewed by: emaste, freqlabs, brooks
Differential Revision: https://reviews.freebsd.org/D27240

3 years agoPartially revert r367756 (chpass(1) synopsis changes)
0mp [Tue, 17 Nov 2020 16:54:12 +0000 (16:54 +0000)]
Partially revert r367756 (chpass(1) synopsis changes)

Let's have two entries in the synopsis:
- chpass now lists options which can be used for non-NIS-specific
  functionalities.
- ypchpass additionally lists the NIS-specific flags.

Technically, it is an artificial distinction, as chpass and ypchpass behave
identically. Nevertheless, it might help navigating the synopsis section.

Reviewed by: imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27251

3 years agoStop using NVME_MAX_XFER_SIZE constant.
mav [Tue, 17 Nov 2020 16:34:58 +0000 (16:34 +0000)]
Stop using NVME_MAX_XFER_SIZE constant.

This constant depends on MAXPHYS and does not respect device capabilities.
Use proper dynamic ioctl(NVME_GET_MAX_XFER_SIZE) instead.

MFC after: 1 month

3 years agosyscon: Add syscon_get_by_ofw_node
manu [Tue, 17 Nov 2020 14:59:58 +0000 (14:59 +0000)]
syscon: Add syscon_get_by_ofw_node

This allow to get a syscon node defined under a specific fdt node (which isn't
always the device one).

3 years agoarm64: allwinner: Init the Display Engine clock
manu [Tue, 17 Nov 2020 14:58:30 +0000 (14:58 +0000)]
arm64: allwinner: Init the Display Engine clock

In case u-boot was compiled without video support set the PLL
to 432Mhz (which allow us to use most of the HDMI resolution for
tcon) and set it as the parent for the DE clock.

3 years agoarm: allwinner: Add DE2 Clock support for H3 SoC
manu [Tue, 17 Nov 2020 14:57:34 +0000 (14:57 +0000)]
arm: allwinner: Add DE2 Clock support for H3 SoC

While here also enable the clock and deassert the reset

3 years agovchiq: Rename timer func so they do not conflict with linuxkpi
manu [Tue, 17 Nov 2020 14:41:23 +0000 (14:41 +0000)]
vchiq: Rename timer func so they do not conflict with linuxkpi

3 years agoWhen copying types from one CTF container to another, ensure that we
jtl [Tue, 17 Nov 2020 14:07:27 +0000 (14:07 +0000)]
When copying types from one CTF container to another, ensure that we
always copy intrinsic data types before copying bitfields which are
based on those types. This ensures the type ordering in the destination
CTF container matches the assumption made elsewhere in the CTF code
that instrinsic data types will always appear before bitfields based on
those types.

This resolves the following error message some users have seen after
r366908:
    "/usr/lib/dtrace/ipfw.d", line 121: failed to copy type of 'ip6p':
    Conflicting type is already defined

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

3 years agoAdd legacy debug/test interfaces for kvm unit tests.
grehan [Tue, 17 Nov 2020 13:14:04 +0000 (13:14 +0000)]
Add legacy debug/test interfaces for kvm unit tests.

Implement the legacy debug/test interfaces expected by KVM-unit-tests'
realmode, emulator, and ioapic tests.

Submitted by: adam_fenn.io
Reviewed by: markj, grehan
Approved by: grehan (bhyve)
MFC after: 3 weeks
Relnotes: Yes
Differential Revision: https://reviews.freebsd.org/D27130

3 years ago[POWERPC] msun: fix incorrect flag in fesetexceptflag
alfredo [Tue, 17 Nov 2020 12:36:59 +0000 (12:36 +0000)]
[POWERPC] msun: fix incorrect flag in fesetexceptflag

Fix incorrect mask being used when FE_INVALID bit is wanted by user.
The problem was noticed thanks to msun fenv tests.

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

3 years ago[POWERPC] fix signal race condition
alfredo [Tue, 17 Nov 2020 12:33:12 +0000 (12:33 +0000)]
[POWERPC] fix signal race condition

r367416 should have called save_fpu() before kern_sigprocmask to avoid
race condition

Thanks jhibbits and bdragon for pointing it out

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

3 years agoAdd an example for the -s flag
0mp [Tue, 17 Nov 2020 12:04:29 +0000 (12:04 +0000)]
Add an example for the -s flag

MFC after: 2 weeks

3 years ago[PowerPC] Don't overwrite vm.pmap sysctl node
luporl [Tue, 17 Nov 2020 11:36:31 +0000 (11:36 +0000)]
[PowerPC] Don't overwrite vm.pmap sysctl node

After r367417, both mmu_oea64 and mmu_radix were defining the vm.pmap
sysctl node, resulting in the later definition hiding the properties of
the previous one. Avoid this issue by defining vm.pmap in a common
source file and declaring it where needed.

This change also standardizes the tunable name used to enable superpages
and change its default to disabled on radix MMU, because it still has some
issues with superpages.

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

3 years agoImprove readability of the lists of options
0mp [Tue, 17 Nov 2020 10:57:28 +0000 (10:57 +0000)]
Improve readability of the lists of options

- Sort options alphabetically
- Add missing arguments (e.g., "list" to -a)
- Adjust the width of Bl

MFC after: 1 week

3 years agoClean up the synopsis section & fix mandoc warnings
0mp [Tue, 17 Nov 2020 10:48:01 +0000 (10:48 +0000)]
Clean up the synopsis section & fix mandoc warnings

The synopsis section had two very similar entries. The flags documented by
the first one were a strict subset of the second one. Let's just keep only
the second entry for simplicity.

MFC after: 1 week

3 years agoStop calling gic_v3_detach when we haven't called gic_v3_attach
andrew [Tue, 17 Nov 2020 10:27:42 +0000 (10:27 +0000)]
Stop calling gic_v3_detach when we haven't called gic_v3_attach

The former tries to dereference memory allocated by the latter. If counting
the redistributor fails it may try to dereference memory that was never
allocated.

Sponsored by: Innovate UK

3 years agoAllow the GICv3 ACPI driver to attach to a GICv4
andrew [Tue, 17 Nov 2020 10:17:18 +0000 (10:17 +0000)]
Allow the GICv3 ACPI driver to attach to a GICv4

The same driver works on both, allow the driver to attach to a GICv4
controller with the ACPI attachment.

Reported by: Andrey Fesenko <f0andrey_gmail.com>
Sponsored by: Innovate UK

3 years agoFix !COMPAT_FREEBSD32 kernel build
kevans [Tue, 17 Nov 2020 04:22:10 +0000 (04:22 +0000)]
Fix !COMPAT_FREEBSD32 kernel build

One of the last shifts inadvertently moved these static assertions out of a
COMPAT_FREEBSD32 block, which the relevant definitions are limited to.

Fix it.

Pointy hat: kevans

3 years agosys/proc.h: improve comment for new TDP2 flag
kevans [Tue, 17 Nov 2020 04:06:35 +0000 (04:06 +0000)]
sys/proc.h: improve comment for new TDP2 flag

This was suggested by kib and integrated locally, but somehow did not make
it into the committed version.

3 years agoumtx_op: reduce redundancy required for compat32
kevans [Tue, 17 Nov 2020 03:36:58 +0000 (03:36 +0000)]
umtx_op: reduce redundancy required for compat32

All of the compat32 variants are substantially the same, save for
copyin/copyout (mostly). Apply the same kind of technique used with kevent
here by having the syscall routines supply a umtx_copyops describing the
operations needed.

umtx_copyops carries the bare minimum needed- size of timespec and
_umtx_time are used for determining if copyout is needed in the sem2_wait
case.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27222

3 years ago_umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE
kevans [Tue, 17 Nov 2020 03:34:01 +0000 (03:34 +0000)]
_umtx_op: fix a compat32 bug in UMTX_OP_NWAKE_PRIVATE

Specifically, if we're waking up some value n > BATCH_SIZE, then the
copyin(9) is wrong on the second iteration due to upp being the wrong type.
upp is currently a uint32_t**, so upp + pos advances it by twice as many
elements as it should (host pointer size vs. compat32 pointer size).

Fix it by just making upp a uint32_t*; it's still technically a double
pointer, but the distinction doesn't matter all that much here since we're
just doing arithmetic on it.

Add a test case that demonstrates the problem, placed with the libthr tests
since one messing with _umtx_op should be running these tests. Running under
compat32, the new test case will hang as threads after the first 128 get
missed in the wake. it's not immediately clear how to hit it in practice,
since pthread_cond_broadcast() uses a smaller (sleepq batch?) size observed
to be around ~50 -- I did not spend much time digging into it.

The uintptr_t change makes no functional difference, but i've tossed it in
since it's more accurate (semantically).

Reported by: Andrew Gierth (andrew_tao173.riddles.org.uk, inspection)
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27231

3 years ago_umtx_op: document UMTX_OP_SEM2_WAIT copyout behavior
kevans [Tue, 17 Nov 2020 03:26:56 +0000 (03:26 +0000)]
_umtx_op: document UMTX_OP_SEM2_WAIT copyout behavior

This clever technique to get a time remaining back was added to support sem_clockwait_np.

Reviewed by: kib, vangyzen
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27160

3 years agovmem: trivial warning and style fixes.
kib [Tue, 17 Nov 2020 02:18:34 +0000 (02:18 +0000)]
vmem: trivial warning and style fixes.

Add __unused to some args.
Change type of the iterator variables to match loop control.
Remove excessive {}.

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

3 years agocpuset: reorder so that cs_mask does not share cacheline with cs_ref
mjg [Tue, 17 Nov 2020 00:04:30 +0000 (00:04 +0000)]
cpuset: reorder so that cs_mask does not share cacheline with cs_ref

3 years agocpuset: refcount-clean
mjg [Tue, 17 Nov 2020 00:04:05 +0000 (00:04 +0000)]
cpuset: refcount-clean

3 years agoIntroduce IOMMU support for arm64 platform.
br [Mon, 16 Nov 2020 21:55:52 +0000 (21:55 +0000)]
Introduce IOMMU support for arm64 platform.

This adds an arm64 iommu interface and a driver for Arm System Memory
Management Unit version 3.2 (ARM SMMU v3.2) specified in ARM IHI 0070C
document.

Hardware overview is provided in the header of smmu.c file.

The support is disabled by default. To enable add 'options IOMMU' to your
kernel configuration file.

The support was developed on Arm Neoverse N1 System Development Platform
(ARM N1SDP), kindly provided by ARM Ltd.

Currently, PCI-based devices and ACPI platforms are supported only.
The support was tested on IOMMU-enabled Marvell SATA controller,
Realtek Ethernet controller and a TI xHCI USB controller with a low to
medium load only.

Many thanks to Konstantin Belousov for help forming the generic IOMMU
framework that is vital for this project; to Andrew Turner for adding
IOMMU support to MSI interrupt code; to Mark Johnston for help with SMMU
page management; to John Baldwin for explaining various IOMMU bits.

Reviewed by: mmel
Relnotes: yes
Sponsored by: DARPA / AFRL
Sponsored by: Innovate UK (Digital Security by Design programme)
Differential Revision: https://reviews.freebsd.org/D24618

3 years agoAdd a guard for broken SUBDIR.${MK_FOO} use
brooks [Mon, 16 Nov 2020 19:15:11 +0000 (19:15 +0000)]
Add a guard for broken SUBDIR.${MK_FOO} use

Check for the variable SUBDIR. and error as it usually means someone
forgot to include src.opts.mk.

This guard from CheriBSD found the bugs in r367655 and r367728.

Reviewed by: bdrewery, arichardson
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27211

3 years agobsdiff: fix off-by-one error
mhorne [Mon, 16 Nov 2020 18:41:49 +0000 (18:41 +0000)]
bsdiff: fix off-by-one error

The program reads oldsize bytes from oldfile, and proceeds to initialize
a suffix array of oldsize elements using divsufsort(). As per the
function's API [1], array indices 0 through n-1 are initialized.

Later, search() is called, but with index bounds [0, n]. Depending on
the contents of the malloc'd buffer, accessing this uninitialized index
at the end of can result in a segmentation fault. Fix this by passing
oldsize-1 to search(), limiting the search bounds to [0, n-1].

This bug is a result of r303285, which introduced divsufsort() as an
alternate suffix sorting function to the existing qsufsort(). It seems
that qsufsort() did initialize the final empty element, meaning it could
be safely accessed. This difference in the implementations was missed at
the time.

[1] https://github.com/y-256/libdivsufsort

Discussed with: cperciva
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26911

3 years agomalloc: make malloc_large closer to standalone
mjg [Mon, 16 Nov 2020 17:56:58 +0000 (17:56 +0000)]
malloc: make malloc_large closer to standalone

This moves entire large alloc handling out of all consumers, apart from
deciding to go there.

This is a step towards creating a fast path.

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

3 years agoAdd missing includes of src.opts.mk
brooks [Mon, 16 Nov 2020 17:20:35 +0000 (17:20 +0000)]
Add missing includes of src.opts.mk

Without this "SUBDIR.${MK_TESTS}=tests" would always expand to
"SUBDIR.=tests" resulting in the tests not being built.

Sponsored by: DARPA

3 years agoFix a bug in assertion: entry flags also includes IOMMU_MAP_ENTRY_UNMAPPED.
br [Mon, 16 Nov 2020 15:37:09 +0000 (15:37 +0000)]
Fix a bug in assertion: entry flags also includes IOMMU_MAP_ENTRY_UNMAPPED.
The entry->flags field is initialized in iommu_gas_init_domain().

Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D27235

3 years agoAdd device_t member to struct iommu.
br [Mon, 16 Nov 2020 15:29:52 +0000 (15:29 +0000)]
Add device_t member to struct iommu.

This is needed on arm64 for the interface between iommu framework
and iommu controller drivers.

Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D27229

3 years agoimx7gpc: Remove unused functions
manu [Mon, 16 Nov 2020 11:54:38 +0000 (11:54 +0000)]
imx7gpc: Remove unused functions

3 years agodwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel
manu [Mon, 16 Nov 2020 11:53:36 +0000 (11:53 +0000)]
dwmmc: dwmmc_switch_vccq is only used in MMCCAM kernel

Silence the build for non MMCCAM kernel

3 years agoRevert "When building on Ubuntu bootstrap bmake with bash as the default shell"
arichardson [Mon, 16 Nov 2020 11:38:51 +0000 (11:38 +0000)]
Revert "When building on Ubuntu bootstrap bmake with bash as the default shell"

This reverts r365950 since the latest bmake update includes fixes for the test
failures that prompted the change.

3 years agoMake mlx5_cmd_exec_cb() a safe API in mlx5core.
hselasky [Mon, 16 Nov 2020 10:15:03 +0000 (10:15 +0000)]
Make mlx5_cmd_exec_cb() a safe API in mlx5core.

APIs that have deferred callbacks should have some kind of cleanup
function that callers can use to fence the callbacks. Otherwise things
like module unloading can lead to dangling function pointers, or worse.

The IB MR code is the only place that calls this function and had a
really poor attempt at creating this fence. Provide a good version in
the core code as future patches will add more places that need this
fence.

Linux commit:
e355477ed9e4f401e3931043df97325d38552d54

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

3 years agoReport EQE data upon CQ completion in mlx5core.
hselasky [Mon, 16 Nov 2020 10:10:53 +0000 (10:10 +0000)]
Report EQE data upon CQ completion in mlx5core.

Report EQE data upon CQ completion to let upper layers use this data.

Linux commit:
4e0e2ea1886afe8c001971ff767f6670312a9b04

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

3 years agoEnhance the mlx5_core_create_cq() function in mlx5core.
hselasky [Mon, 16 Nov 2020 10:06:10 +0000 (10:06 +0000)]
Enhance the mlx5_core_create_cq() function in mlx5core.

Enhance mlx5_core_create_cq() to get the command out buffer from the
callers to let them use the output.

Linux commit:
38164b771947be9baf06e78ffdfb650f8f3e908e

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

3 years agoUse mlx5core to create/destroy all Dynamically Connected Targets, DCTs.
hselasky [Mon, 16 Nov 2020 10:03:18 +0000 (10:03 +0000)]
Use mlx5core to create/destroy all Dynamically Connected Targets, DCTs.

To prevent a hardware memory leak when a DEVX DCT object is destroyed
without calling drain DCT before, (e.g. under cleanup flow), need to
manage its creation and destruction via mlx5 core.

Linux commit:
c5ae1954c47d3fd8815bd5a592aba18702c93f33

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

3 years agoFix error handling order in create_kernel_qp in mlx5ib.
hselasky [Mon, 16 Nov 2020 10:00:21 +0000 (10:00 +0000)]
Fix error handling order in create_kernel_qp in mlx5ib.

Make sure order of cleanup is exactly the opposite of initialization.

Linux commit:
f4044dac63e952ac1137b6df02b233d37696e2f5

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

3 years agoselect: call seltdfini on process and thread exit
mjg [Mon, 16 Nov 2020 03:12:21 +0000 (03:12 +0000)]
select: call seltdfini on process and thread exit

Since thread_zone is marked NOFREE the thread_fini callback is never
executed, meaning memory allocated by seltdinit is never released.

Adding the call to thread_dtor is not sufficient as exiting processes
cache the main thread.

3 years agoselect: replace reference counting with memory barriers in selfd
mjg [Mon, 16 Nov 2020 03:09:18 +0000 (03:09 +0000)]
select: replace reference counting with memory barriers in selfd

Refcounting was added to combat a race between selfdfree and doselwakup,
but it adds avoidable overhead.

selfdfree detects it can free the object by ->sf_si == NULL, thus we can
ensure that the condition only holds after all accesses are completed.

3 years agoEnsure make delete-old does not unlink the llvm-cxxfilt and its manpage,
dim [Sun, 15 Nov 2020 22:49:28 +0000 (22:49 +0000)]
Ensure make delete-old does not unlink the llvm-cxxfilt and its manpage,
after r367304 and r367324, when WITH_LLVM_CXXFILT is enabled.

Noticed by: "Herbert J. Skuhra" <herbert@gojira.at>
MFC after: 3 days
X-MFC-With: r367304

3 years agoRevert the whole getlocalbase() set of changes while a different design is
scottl [Sun, 15 Nov 2020 20:24:59 +0000 (20:24 +0000)]
Revert the whole getlocalbase() set of changes while a different design is
hashed out.

3 years agozfsboot: add prototype for main()
tsoome [Sun, 15 Nov 2020 14:04:27 +0000 (14:04 +0000)]
zfsboot: add prototype for main()

Some compilers are complaining about missing prototype.

PR: 251150
Reported by: markiyan.kushnir@gmail.com

3 years agoFix regression in AHCI controller settings.
grehan [Sun, 15 Nov 2020 12:59:24 +0000 (12:59 +0000)]
Fix regression in AHCI controller settings.

When the AHCI code was reworked to use FreeBSD struct
definitions, the valid element was mis-transcribed resulting
in the UMDA capability being hidden. This prevented Illumos
from using AHCI disk/cdrom drives.

Fix by using definitions that match the code pre-rework.

PR: 250924
Submitted by: Rolf Stalder
Reported by: Rolf Stalder
MFC after: 3 days

3 years agoFix the previous revision, it suffered from an incomplete change to the
scottl [Sun, 15 Nov 2020 07:50:29 +0000 (07:50 +0000)]
Fix the previous revision, it suffered from an incomplete change to the
getlocalbase API.  Also don't erroneously subtract the lenth from the
buffer a second time.

3 years agoBecause getlocalbase() returns -1 on error, it needs to use a signed type
scottl [Sun, 15 Nov 2020 07:48:52 +0000 (07:48 +0000)]
Because getlocalbase() returns -1 on error, it needs to use a signed type
internally.  Do that, and make sure that conversations between signed and
unsigned don't overflow

3 years agosched: fix an incorrect comparison in sched_lend_user_prio_cond
mjg [Sun, 15 Nov 2020 01:54:44 +0000 (01:54 +0000)]
sched: fix an incorrect comparison in sched_lend_user_prio_cond

Compare with sched_lend_user_prio.

3 years agocred: annotate credbatch_process argument as unused
mjg [Sat, 14 Nov 2020 19:56:11 +0000 (19:56 +0000)]
cred: annotate credbatch_process argument as unused

Fixes libprocstat compilation as zfs defines _KERNEL.

3 years agozfs: disable periodic arc updates
mjg [Sat, 14 Nov 2020 19:23:07 +0000 (19:23 +0000)]
zfs: disable periodic arc updates

They are only there to provide less innacurate statistics for debuggers.
However, this is quite heavy-weight and instead it would be better to
teach debuggers how to obtain the necessary information.

3 years agothread: batch credential freeing
mjg [Sat, 14 Nov 2020 19:22:02 +0000 (19:22 +0000)]
thread: batch credential freeing

3 years agothread: batch resource limit free calls
mjg [Sat, 14 Nov 2020 19:21:46 +0000 (19:21 +0000)]
thread: batch resource limit free calls

3 years agothread: rework tid batch to use helpers
mjg [Sat, 14 Nov 2020 19:20:58 +0000 (19:20 +0000)]
thread: rework tid batch to use helpers

3 years agocred: reorder cr_audit to be closer to the lock
mjg [Sat, 14 Nov 2020 19:20:37 +0000 (19:20 +0000)]
cred: reorder cr_audit to be closer to the lock

This makes cr_uid avoid sharing.

3 years agothread: pad tid lock
mjg [Sat, 14 Nov 2020 19:19:27 +0000 (19:19 +0000)]
thread: pad tid lock

On a kernel with other changes this bumps 104-way thread creation/destruction
from 0.96 mln ops/s to 1.1 mln ops/s.

3 years agoChange the default locale to C.UTF-8
bapt [Sat, 14 Nov 2020 19:16:39 +0000 (19:16 +0000)]
Change the default locale to C.UTF-8

The C.UTF-8 locales is the same as the actual C locale except it does support
the unicode character set. But the collation etc are still the same as the C
locale one.

Reviewed by: many
Approved by: many
Differential Revision: https://reviews.freebsd.org/D26973

3 years agoFix a problem with r367686 related to the use of ssize_t. Not sure how this
scottl [Sat, 14 Nov 2020 19:04:36 +0000 (19:04 +0000)]
Fix a problem with r367686 related to the use of ssize_t.  Not sure how this
escaped prior testing, but it should be better now.

Reported by: lots

3 years agoMakefile: re-wordsmith the blurb about xtoolchain ports
kevans [Sat, 14 Nov 2020 18:06:35 +0000 (18:06 +0000)]
Makefile: re-wordsmith the blurb about xtoolchain ports

The new version only includes a specific version once, and uses the one
that's currently advised by tinderbox: -gcc6.

It also advises just installing the pkg, but mentions in a side-note at the
end where to find the source in the ports tree.

Reviewed by: jrtc27
Suggested by: jhb (use default from tinderbox)
Differential Revision: https://reviews.freebsd.org/D26820

3 years agoReplace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3
scottl [Sat, 14 Nov 2020 18:01:14 +0000 (18:01 +0000)]
Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3

Reviewed by: imp, se

3 years agoAdd the library function getlocalbase and its manual page. This helps to
scottl [Sat, 14 Nov 2020 17:57:50 +0000 (17:57 +0000)]
Add the library function getlocalbase and its manual page.  This helps to
unify the retrieval of the various ways that the local software base directory,
typically "/usr/local", is expressed in the system.

Reviewed by: se
Differential Revision: https://reviews.freebsd.org/D27022

3 years agoAdd a regression test for the port-selection behavior fixed in r367680.
jtl [Sat, 14 Nov 2020 15:44:28 +0000 (15:44 +0000)]
Add a regression test for the port-selection behavior fixed in r367680.

Reviewed by: markj, olivier, tuexen
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27173

3 years agoFix implicit automatic local port selection for IPv6 during connect calls.
jtl [Sat, 14 Nov 2020 14:50:34 +0000 (14:50 +0000)]
Fix implicit automatic local port selection for IPv6 during connect calls.

When a user creates a TCP socket and tries to connect to the socket without
explicitly binding the socket to a local address, the connect call
implicitly chooses an appropriate local port. When evaluating candidate
local ports, the algorithm checks for conflicts with existing ports by
doing a lookup in the connection hash table.

In this circumstance, both the IPv4 and IPv6 code look for exact matches
in the hash table. However, the IPv4 code goes a step further and checks
whether the proposed 4-tuple will match wildcard (e.g. TCP "listen")
entries. The IPv6 code has no such check.

The missing wildcard check can cause problems when connecting to a local
server. It is possible that the algorithm will choose the same value for
the local port as the foreign port uses. This results in a connection with
identical source and destination addresses and ports. Changing the IPv6
code to align with the IPv4 code's behavior fixes this problem.

Reviewed by: tuexen
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D27164

3 years agoDocument the PAGER environment variable
0mp [Sat, 14 Nov 2020 13:07:41 +0000 (13:07 +0000)]
Document the PAGER environment variable

Sometimes users want to use freebsd-update(8) in a non-interactive way and
what they often miss is that they have to set PAGER to cat(1) in order to
avoid interactive prompts from less(1).

MFC after: 4 weeks

3 years agoloader: cstyle cleanup of console.c
tsoome [Sat, 14 Nov 2020 10:56:40 +0000 (10:56 +0000)]
loader: cstyle cleanup of console.c

cstyle cleanup only, no functional changes intended.

3 years agoLinuxKPI: Exclude linux/acpi.h content on non-ACPI archs.
wulf [Sat, 14 Nov 2020 10:34:18 +0000 (10:34 +0000)]
LinuxKPI: Exclude linux/acpi.h content on non-ACPI archs.

LinuxKPI ACPI support is based on FreeBSD import of ACPICA which can be
compiled only on aarch64, amd64 and i386. Ifdef-out broken parts on our
side to avoid patching of vendor code.

This fixes drm-devel-kmod build on powerpc64(le).

Reported by: pkubaj

3 years agoHandle LoR in flush_pagedep_deps().
kib [Sat, 14 Nov 2020 05:30:10 +0000 (05:30 +0000)]
Handle LoR in flush_pagedep_deps().

When operating in SU or SU+J mode, ffs_syncvnode() might need to
instantiate other vnode by inode number while owning syncing vnode
lock.  Typically this other vnode is the parent of our vnode, but due
to renames occuring right before fsync (or during fsync when we drop
the syncing vnode lock, see below) it might be no longer parent.

More, the called function flush_pagedep_deps() needs to lock other
vnode while owning the lock for vnode which owns the buffer, for which
the dependencies are flushed.  This creates another instance of the
same LoR as was fixed in softdep_sync().

Put the generic code for safe relocking into new SU helper
get_parent_vp() and use it in flush_pagedep_deps().  The case for safe
relocking of two vnodes with undefined lock order was extracted into
vn helper vn_lock_pair().

Due to call sequence
     ffs_syncvnode()->softdep_sync_buf()->flush_pagedep_deps(),
ffs_syncvnode() indicates with ERELOOKUP that passed vnode was
unlocked in process, and can return ENOENT if the passed vnode
reclaimed.  All callers of the function were inspected.

Because UFS namei lookups store auxiliary information about directory
entry in in-memory directory inode, and this information is then used
by UFS code that creates/removed directory entry in the actual
mutating VOPs, it is critical that directory vnode lock is not dropped
between lookup and VOP.  For softdep_prelink(), which ensures that
later link/unlink operation can proceed without overflowing the
journal, calls were moved to the place where it is safe to drop
processing VOP because mutations are not yet applied.  Then, ERELOOKUP
causes restart of the whole VFS operation (typically VFS syscall) at
top level, including the re-lookup of the involved pathes.  [Note that
we already do the same restart for failing calls to vn_start_write(),
so formally this patch does not introduce new behavior.]

Similarly, unsafe calls to fsync in snapshot creation code were
plugged.  A possible view on these failures is that it does not make
sense to continue creating snapshot if the snapshot vnode was
reclaimed due to forced unmount.

It is possible that relock/ERELOOKUP situation occurs in
ffs_truncate() called from ufs_inactive().  In this case, dropping the
vnode lock is not safe.  Detect the situation with VI_DOINGINACT and
reschedule inactivation by setting VI_OWEINACT.  ufs_inactive()
rechecks VI_OWEINACT and avoids reclaiming vnode is truncation failed
this way.

In ffs_truncate(), allocation of the EOF block for partial truncation
is re-done after vnode is synced, since we cannot leave the buffer
locked through ffs_syncvnode().

In collaboration with: pho
Reviewed by: mckusick (previous version), markj
Tested by: markj (syzkaller), pho
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26136