]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoRe-wrap the text at 80 columns after fixing the indent in the prior commit.
ian [Fri, 26 Jul 2019 17:58:46 +0000 (17:58 +0000)]
Re-wrap the text at 80 columns after fixing the indent in the prior commit.

4 years agoMerge libcxxrt master f96846efbfd508f66d91fcbbef5dd808947c7f6d.
dim [Fri, 26 Jul 2019 16:55:06 +0000 (16:55 +0000)]
Merge libcxxrt master f96846efbfd508f66d91fcbbef5dd808947c7f6d.

Interesting fixes:
f96846e Fix std::size_t -> size_t to unbreak build against libc++ 6.0.0
6f4cfa2 Fix the uncaught exception count with rethrowing (PR 239265)
db54f53 Added C++14-specific operator delete (#47)

PR: 239265
MFC after: 3 days

4 years agoRewrite the comments that explain swapon_trim() to make them more
dougm [Fri, 26 Jul 2019 15:18:11 +0000 (15:18 +0000)]
Rewrite the comments that explain swapon_trim() to make them more
comprehensible.

Suggested by: rpokala
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D21034

4 years agoFix a bug introduced with parallel mounting of zfs
bapt [Fri, 26 Jul 2019 13:12:33 +0000 (13:12 +0000)]
Fix a bug introduced with parallel mounting of zfs

Incorporate a fix from zol:
https://github.com/zfsonlinux/zfs/commit/ab5036df1ccbe1b18c1ce6160b5829e8039d94ce

commit log from upstream:
 Fix race in parallel mount's thread dispatching algorithm

Strategy of parallel mount is as follows.

1) Initial thread dispatching is to select sets of mount points that
 don't have dependencies on other sets, hence threads can/should run
 lock-less and shouldn't race with other threads for other sets. Each
 thread dispatched corresponds to top level directory which may or may
 not have datasets to be mounted on sub directories.

2) Subsequent recursive thread dispatching for each thread from 1)
 is to mount datasets for each set of mount points. The mount points
 within each set have dependencies (i.e. child directories), so child
 directories are processed only after parent directory completes.

The problem is that the initial thread dispatching in
zfs_foreach_mountpoint() can be multi-threaded when it needs to be
single-threaded, and this puts threads under race condition. This race
appeared as mount/unmount issues on ZoL for ZoL having different
timing regarding mount(2) execution due to fork(2)/exec(2) of mount(8).
`zfs unmount -a` which expects proper mount order can't unmount if the
mounts were reordered by the race condition.

There are currently two known patterns of input list `handles` in
`zfs_foreach_mountpoint(..,handles,..)` which cause the race condition.

1) #8833 case where input is `/a /a /a/b` after sorting.
 The problem is that libzfs_path_contains() can't correctly handle an
 input list with two same top level directories.
 There is a race between two POSIX threads A and B,
  * ThreadA for "/a" for test1 and "/a/b"
  * ThreadB for "/a" for test0/a
 and in case of #8833, ThreadA won the race. Two threads were created
 because "/a" wasn't considered as `"/a" contains "/a"`.

2) #8450 case where input is `/ /var/data /var/data/test` after sorting.
 The problem is that libzfs_path_contains() can't correctly handle an
 input list containing "/".
 There is a race between two POSIX threads A and B,
  * ThreadA for "/" and "/var/data/test"
  * ThreadB for "/var/data"
 and in case of #8450, ThreadA won the race. Two threads were created
 because "/var/data" wasn't considered as `"/" contains "/var/data"`.
 In other words, if there is (at least one) "/" in the input list,
 the initial thread dispatching must be single-threaded since every
 directory is a child of "/", meaning they all directly or indirectly
 depend on "/".

In both cases, the first non_descendant_idx() call fails to correctly
determine "path1-contains-path2", and as a result the initial thread
dispatching creates another thread when it needs to be single-threaded.
Fix a conditional in libzfs_path_contains() to consider above two.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
PR: 237517, 237397, 239243
Submitted by: Matthew D. Fuller <fullermd@over-yonder.net> (by email)
MFC after: 3 days

4 years agoUpdate mandoc to cvs snapshot 2019-07-23
bapt [Fri, 26 Jul 2019 10:00:33 +0000 (10:00 +0000)]
Update mandoc to cvs snapshot 2019-07-23

This snapshot among other things includes a fix for a crash of mandoc with empty
tbl reported by rea@ (his regression test has been incorporated upstream)

MFC after: 3 weeks

4 years agoImplement pmap_advise(). (Without a working pmap_advise() implementation
alc [Fri, 26 Jul 2019 05:07:09 +0000 (05:07 +0000)]
Implement pmap_advise().  (Without a working pmap_advise() implementation
madvise(MADV_DONTNEED) and madvise(MADV_FREE) are NOPs.)

Reviewed by: markj
X-MFC after: r350004
Differential Revision: https://reviews.freebsd.org/D21062

4 years agoAdd device temperature reporting into CTL.
mav [Fri, 26 Jul 2019 03:49:16 +0000 (03:49 +0000)]
Add device temperature reporting into CTL.

The values to report can be set via LUN options.  It can be useful for
testing, and also required for Drive Maintenance 2016 feature set.

MFC after: 2 weeks

4 years agoAdd reporting of SCSI Feature Sets VPD page from SPC-5.
mav [Fri, 26 Jul 2019 01:49:28 +0000 (01:49 +0000)]
Add reporting of SCSI Feature Sets VPD page from SPC-5.

CTL implements all defined feature sets except Drive Maintenance 2016,
which is not very applicable to such a virtual device, and implemented
only partially now.  But may be it could be fixed later at least for
completeness.

MFC after: 2 weeks

4 years agoif_tuntap(4): Add TUNGIFNAME
kevans [Thu, 25 Jul 2019 22:23:34 +0000 (22:23 +0000)]
if_tuntap(4): Add TUNGIFNAME

This effectively just moves TAPGIFNAME into common ioctl territory.

MFC after: 3 days

4 years agoSimplify the handling of superpages in pmap_clear_modify(). Specifically,
alc [Thu, 25 Jul 2019 22:02:55 +0000 (22:02 +0000)]
Simplify the handling of superpages in pmap_clear_modify().  Specifically,
if a demotion succeeds, then all of the 4KB page mappings within the
superpage-sized region must be valid, so there is no point in testing the
validity of the 4KB page mapping that is going to be write protected.

Deindent the nearby code.

Reviewed by: kib, markj
Tested by: pho (amd64, i386)
X-MFC after: r350004 (this change depends on arm64 dirty bit emulation)
Differential Revision: https://reviews.freebsd.org/D21027

4 years agoWiden the type for to.
imp [Thu, 25 Jul 2019 20:26:21 +0000 (20:26 +0000)]
Widen the type for to.

The timeout field in the CAPS register is defined to be 8 bits, so its type was
uint8_t. We recently started adding 1 to it to cope with rogue devices that
listed 0 timeout time (which is impossible). However, in so doing, other devices
that list 0xff (for a 2 minute timeout) were broken when adding 1
overflowed. Widen the type to be uint32_t like its source register to avoid the
issue.

Reported by: bapt@

4 years agoMake `camcontrol sanitize` support also ATA devices.
mav [Thu, 25 Jul 2019 18:48:31 +0000 (18:48 +0000)]
Make `camcontrol sanitize` support also ATA devices.

ATA sanitize is functionally identical to SCSI, just uses different
initiation commands and status reporting mechanism.

While there, make kernel better handle sanitize commands and statuses.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agolibsysdecode: use the proper include directory
emaste [Thu, 25 Jul 2019 17:10:17 +0000 (17:10 +0000)]
libsysdecode: use the proper include directory

Reported by: cy
Reviewed by: lwhsu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21068

4 years agoFix grammar nit in copy_file_range docs
bjk [Thu, 25 Jul 2019 15:43:15 +0000 (15:43 +0000)]
Fix grammar nit in copy_file_range docs

Bytes are countable, so we have fewer of them, not less of them.

4 years agoFix indentation (spaces->tab).
ian [Thu, 25 Jul 2019 15:31:15 +0000 (15:31 +0000)]
Fix indentation (spaces->tab).

Reported by: garga@

4 years agopowerpc: Improve pvo allocation code
luporl [Thu, 25 Jul 2019 15:27:05 +0000 (15:27 +0000)]
powerpc: Improve pvo allocation code

Added allocation retry loop in alloc_pvo_entry(), to wait for
memory to become available if the caller specifies the M_WAITOK flag.

Also, the loop in moa64_enter() was removed, as moea64_pvo_enter()
never returns ENOMEM. It is alloc_pvo_entry() memory allocation that
can fail and must be retried.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D21035

4 years agoWorkaround the build failure on platforms have lib32 after r350301
lwhsu [Thu, 25 Jul 2019 07:57:01 +0000 (07:57 +0000)]
Workaround the build failure on platforms have lib32 after r350301

Error message:

make[5]: make[5]: don't know how to make /usr/obj/usr/src/amd64.amd64/obj-lib32/tmp/sys/netinet/in.h. Stop

make[5]: stopped in /usr/src/lib/libsysdecode

Sponsored by: The FreeBSD Foundation

4 years agor350320 committed the wrong version of generated syscall.mk.
rmacklem [Thu, 25 Jul 2019 06:48:30 +0000 (06:48 +0000)]
r350320 committed the wrong version of generated syscall.mk.

This commit is for the correct version. (The incorrect one had the order
of the last two entries reversed, due to my testing with copy_file_range
at 568 instead of 569.) This misordering should not have been a problem,
but is now fixed.

4 years agoUpdate the generated syscall.mk for copy_file_range(2).
rmacklem [Thu, 25 Jul 2019 06:35:21 +0000 (06:35 +0000)]
Update the generated syscall.mk for copy_file_range(2).

I missed this file for commit r350316.

4 years agoCreate a man page for VOP_COPY_FILE_RANGE(9).
rmacklem [Thu, 25 Jul 2019 06:20:00 +0000 (06:20 +0000)]
Create a man page for VOP_COPY_FILE_RANGE(9).

r350315 created a Linux compatible copy_file_range(2) syscall.
It uses a VOP method called VOP_COPY_FILE_RANGE so that file systems,
such as the NFSv4.2 client can do file system specific copying.
For NFSv4.2, this allows the copying to be done locally on the NFS server,
avoiding transferring the data across the wire twice.

This is a new man page (content changed).

Reviewed by: kib, asomers
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D20584

4 years agoAdd an entry for copy_file_range(2) to unistd.h.
rmacklem [Thu, 25 Jul 2019 06:10:44 +0000 (06:10 +0000)]
Add an entry for copy_file_range(2) to unistd.h.

copy_file_range(2) is a Linux compatible syscall created by r350315.

Reviewed by: kib, asomers
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D20584

4 years agoAdd libc support for the copy_file_range(2) syscall added by r350315.
rmacklem [Thu, 25 Jul 2019 06:05:49 +0000 (06:05 +0000)]
Add libc support for the copy_file_range(2) syscall added by r350315.

copy_file_range.2 is a new man page (content change).

Reviewed by: kib, asomers
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D20584

4 years agoUpdate the generated syscall files for copy_file_range(2) added by
rmacklem [Thu, 25 Jul 2019 05:55:55 +0000 (05:55 +0000)]
Update the generated syscall files for copy_file_range(2) added by
r350315.

4 years agoAdd kernel support for a Linux compatible copy_file_range(2) syscall.
rmacklem [Thu, 25 Jul 2019 05:46:16 +0000 (05:46 +0000)]
Add kernel support for a Linux compatible copy_file_range(2) syscall.

This patch adds support to the kernel for a Linux compatible
copy_file_range(2) syscall and the related VOP_COPY_FILE_RANGE(9).
This syscall/VOP can be used by the NFSv4.2 client to implement the
Copy operation against an NFSv4.2 server to do file copies locally on
the server.
The vn_generic_copy_file_range() function in this patch can be used
by the NFSv4.2 server to implement the Copy operation.
Fuse may also me able to use the VOP_COPY_FILE_RANGE() method.

vn_generic_copy_file_range() attempts to maintain holes in the output
file in the range to be copied, but may fail to do so if the input and
output files are on different file systems with different _PC_MIN_HOLE_SIZE
values.

Separate commits will be done for the generated syscall files and userland
changes. A commit for a compat32 syscall will be done later.

Reviewed by: kib, asomers (plus comments by brooks, jilles)
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D20584

4 years agospecial-case getvfsbyname(3) for fusefs(5)
asomers [Thu, 25 Jul 2019 03:55:05 +0000 (03:55 +0000)]
special-case getvfsbyname(3) for fusefs(5)

fusefs file systems may have a fsname subtype (set by mount_fusefs's "-o
subtype" option) that gets appended to the fsname as returned by statfs(2).
The subtype is set on a per-mount basis so it isn't part of the struct
vfsconf. Special-case getvfsbyname to match either the full "fusefs.foobar"
or short "fusefs" fsname.

This is a merge of r348007, r348054, and r350093 from projects/fuse2

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

4 years agopowerpc/pmap64: Make moea64 statistics optional
jhibbits [Thu, 25 Jul 2019 03:47:27 +0000 (03:47 +0000)]
powerpc/pmap64: Make moea64 statistics optional

Summary:
It turns out statistics accounting is very expensive in the pmap driver,
and doesn't seem necessary in the common case.  Make this optional
behind a MOEA64_STATS #define, which one can set if they really need
statistics.

This saves ~7-8% on buildworld time on a POWER9.

Found by bdragon.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D20903

4 years agoFix the fix to the logic bug. Upon further testing, the bug is that we shadoow
imp [Wed, 24 Jul 2019 23:08:49 +0000 (23:08 +0000)]
Fix the fix to the logic bug. Upon further testing, the bug is that we shadoow
opt.vendor with vendor. We shouldn't. Delete the latter and use the former
everywhere and restore the prior logic which is now correct.

4 years agoFix the turnstile_lock() KPI.
markj [Wed, 24 Jul 2019 23:04:59 +0000 (23:04 +0000)]
Fix the turnstile_lock() KPI.

turnstile_{lock,unlock}() were added for use in epoch.  turnstile_lock()
returned NULL to indicate that the calling thread had lost a race and
the turnstile was no longer associated with the given lock, or the lock
owner.  However, reader-writer locks may not have a designated owner,
in which case turnstile_lock() would return NULL and
epoch_block_handler_preempt() would leak spinlocks as a result.

Apply a minimal fix: return the lock owner as a separate return value.

Reviewed by: kib
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21048

4 years agoFix several related coverity issues:
imp [Wed, 24 Jul 2019 23:04:26 +0000 (23:04 +0000)]
Fix several related coverity issues:

Make sure to always free shortopts and lopts when returning.
Fix minor logic bug to guard against NULLs properly.

CID: 140365414036561403658

4 years agoDocument r350307.
markj [Wed, 24 Jul 2019 22:57:17 +0000 (22:57 +0000)]
Document r350307.

Sponsored by: The FreeBSD Foundation

4 years agoRemove cap_random(3).
markj [Wed, 24 Jul 2019 22:50:43 +0000 (22:50 +0000)]
Remove cap_random(3).

Now that we have a way to obtain entropy in capability mode
(getrandom(2)), libcap_random is obsolete.  Remove it.

Bump __FreeBSD_version in case anything happens to use it, though I've
found no consumers.

Reviewed by: delphij, emaste, oshogbo
Relnotes: yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21033

4 years agoiflib: fix dangling device softc pointer
erj [Wed, 24 Jul 2019 21:43:41 +0000 (21:43 +0000)]
iflib: fix dangling device softc pointer

Commit text by Jake:
If a driver's IFDI_ATTACH_PRE function fails, the iflib_device_register
function will free the ctx pointer. However, it does not reset the
device softc pointer to NULL.

This will result in memory corruption as a future access to the now
invalid pointer will corrupt memory that is later allocated on top of
the same memory location.

The iflib_device_deregister function correctly resets the softc pointer
by using device_set_softc().

This clears up the invalid dangling pointer and prevents memory
corruption that could lead to a panic or undefined behavior if the
device's driver failed to attach.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: erj@, gallatin@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21003

4 years agoenable ig4_acpi on aarch64
emaste [Wed, 24 Jul 2019 21:26:17 +0000 (21:26 +0000)]
enable ig4_acpi on aarch64

The already-listed APMC0D0F ID belongs to the Ampere eMAG aarch64
platform, but ACPI support was not even built on aarch64.

Submitted by: Greg V <greg_unrelenting.technology>
Differential Revision: https://reviews.freebsd.org/D21059

4 years agocirrus.yml: use OVMF.fd from uefi-edk2-qemu-x86_64 package
emaste [Wed, 24 Jul 2019 21:08:30 +0000 (21:08 +0000)]
cirrus.yml: use OVMF.fd from uefi-edk2-qemu-x86_64 package

Sponsored by: The FreeBSD Foundation

4 years agolibsysdecode: add explicit dependencies on recently changed headers
emaste [Wed, 24 Jul 2019 21:06:19 +0000 (21:06 +0000)]
libsysdecode: add explicit dependencies on recently changed headers

r349369 removed IP_MIN_MEMBERSHIPS and IPV6_MIN_MEMBERSHIPS, and r349893
removed TCP_RACK_SESS_CWV. libsysdecode lacked dependencies to trigger a
rebuild of tables.h.

Add explicit dependencies as a workaround to address these specific
cases; a holistic solution is still needed.

Sponsored by: The FreeBSD Foundation

4 years agoTemporarily skip flakey test case
lwhsu [Wed, 24 Jul 2019 17:41:40 +0000 (17:41 +0000)]
Temporarily skip flakey test case
sys.kern.ptrace_test.ptrace__follow_fork_parent_detached_unrelated_debugger

PR: 239425
Sponsored by: The FreeBSD Foundation

4 years agopf: zero output buffer in pfioctl
emaste [Wed, 24 Jul 2019 16:51:14 +0000 (16:51 +0000)]
pf: zero output buffer in pfioctl

Avoid potential structure padding leak.

Reported by: Vlad Tsyrklevich <vlad@tsyrklevich.net>
Reviewed by: kp
MFC after: 3 days
Security: Potential kernel memory disclosure
Sponsored by: The FreeBSD Foundation

4 years agoAllow set MTU more than 1500 bytes.
krion [Wed, 24 Jul 2019 16:10:20 +0000 (16:10 +0000)]
Allow set MTU more than 1500 bytes.

Submitted by: Alexandr Fedorov <aleksandr.fedorov_itglobal_dot_com>
Approved by: jhb, rgrimes
Sponsored by: ITGlobal.com
Differential Revision: https://reviews.freebsd.org/D19422

4 years agoRemove a redundant offset computation in elf_load_section().
markj [Wed, 24 Jul 2019 15:18:05 +0000 (15:18 +0000)]
Remove a redundant offset computation in elf_load_section().

With r344705 the offset is always zero.

Submitted by: Wuyang Chung <wuyang.chung1@gmail.com>

4 years agoAdd c++14 and c++17 to COMPILER_FEATURES
asomers [Wed, 24 Jul 2019 15:10:09 +0000 (15:10 +0000)]
Add c++14 and c++17 to COMPILER_FEATURES

This will be used to gate the fusefs tests. It's a partial merge of r348281
from projects/fuse2.

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

4 years agopkgbase: Add the sub stage-packages targets to TGTS
manu [Wed, 24 Jul 2019 08:00:00 +0000 (08:00 +0000)]
pkgbase: Add the sub stage-packages targets to TGTS

This helps when you don't want to run the dependencies targets.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D20955

4 years agoDon't use .Xr for things that have no man page.
kevlo [Wed, 24 Jul 2019 07:07:46 +0000 (07:07 +0000)]
Don't use .Xr for things that have no man page.

4 years agoVOP_FSYNC.9: update copyright after r345677
asomers [Tue, 23 Jul 2019 23:14:57 +0000 (23:14 +0000)]
VOP_FSYNC.9: update copyright after r345677

MFC after: 2 weeks
MFC-With: r345677
Sponsored by: The FreeBSD Foundation

4 years agoAdd a sysctl variable ts_offset_per_conn to change the computation
tuexen [Tue, 23 Jul 2019 21:28:20 +0000 (21:28 +0000)]
Add a sysctl variable ts_offset_per_conn to change the computation
of the TCP TS offset from taking the IP addresses and the TCP port
numbers into account to a version just taking only the IP addresses
into account. This works around broken middleboxes or endpoints.
The default is to keep the behaviour, which is also the behaviour
recommended in RFC 7323.

Reported by: devgs@ukr.net
Reviewed by: rrs@
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D20980

4 years agomqueuefs: fix struct file leak
emaste [Tue, 23 Jul 2019 20:59:36 +0000 (20:59 +0000)]
mqueuefs: fix struct file leak

In some error cases we previously leaked a stuct file.

Submitted by: mjg, markj

4 years agoMake `camcontrol hpa` and `camcontrol ama` trigger reprobe.
mav [Tue, 23 Jul 2019 19:42:03 +0000 (19:42 +0000)]
Make `camcontrol hpa` and `camcontrol ama` trigger reprobe.

This makes OS automatically see the disk's new disk size.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoFix the register layout for the Buffer Descript List Entry. It
scottl [Tue, 23 Jul 2019 18:40:07 +0000 (18:40 +0000)]
Fix the register layout for the Buffer Descript List Entry.  It
got jumbled around during some other cleanups and was causing
audio failures on some guests.

PR: 239341
Reported by: shamaz.mazum@gmail.com

4 years agoDon't hold a mutex while calling sbwait. This was found by syzkaller.
tuexen [Tue, 23 Jul 2019 18:31:07 +0000 (18:31 +0000)]
Don't hold a mutex while calling sbwait. This was found by syzkaller.

Submitted by: rrs@
Reported by: markj@
MFC after: 1 week

4 years agoixgbe(4): Fix enabling/disabling and reconfiguration of queues
erj [Tue, 23 Jul 2019 18:14:32 +0000 (18:14 +0000)]
ixgbe(4): Fix enabling/disabling and reconfiguration of queues

- Wrong order of casting and bit shift caused that enabling and disabling
  queues didn't work properly for queues number larger than 32. Use literals
  with right suffix instead.

- TX ring tail address was not updated during reinitiailzation of TX
  structures. It could block sending traffic.

- Also remove unused variables 'eims' and 'active_queues'.

Submitted by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Reviewed by: erj@
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D20826

4 years agoFix a LOR in SCTP which was found by running syzkaller.
tuexen [Tue, 23 Jul 2019 18:07:36 +0000 (18:07 +0000)]
Fix a LOR in SCTP which was found by running syzkaller.

Submitted by: rrs@
Reported by: markj@
MFC after: 1 week

4 years agopciconf: report PCI Gen4 speeds
gallatin [Tue, 23 Jul 2019 16:28:17 +0000 (16:28 +0000)]
pciconf: report PCI Gen4 speeds

PCIe gen4 runs at 16GT/s.  Report this as
the speed of Gen4 links.

Reviewed by: imp
MFC after: 7 days
Sponsored by: Netflix

4 years agobhyve: correct out-of-bounds read in XHCI device emulation
emaste [Tue, 23 Jul 2019 16:27:36 +0000 (16:27 +0000)]
bhyve: correct out-of-bounds read in XHCI device emulation

Add appropriate bounds checks on the epid and streamid fields in the
device doorbell registers.

admbugs: 919
Submitted by: jhb
Reported by: Reno Robert <renorobert@gmail.com>
Reviewed by: markj
Approved by: so
Security: out-of-bounds read

4 years agoUpdate refcount(9).
kib [Tue, 23 Jul 2019 16:11:38 +0000 (16:11 +0000)]
Update refcount(9).

Describe missed functions.
Give some hint about refcount_release(9) memory ordering guarantees.

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

4 years agoAs with r350241 use the new UL macro on the main register mask.
andrew [Tue, 23 Jul 2019 14:52:46 +0000 (14:52 +0000)]
As with r350241 use the new UL macro on the main register mask.

MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoEnsure the arm64 ID register fields are 64 bit types.
andrew [Tue, 23 Jul 2019 14:40:37 +0000 (14:40 +0000)]
Ensure the arm64 ID register fields are 64 bit types.

Previously only some of the ID register fields were 64 bit. To allow
for a script to generate these mark them all 64 bit. To allow for their
use in assembly we need to use the UINT64_C macro via a new UL macro
to stop the lines from being too long.

MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D20977

4 years agoEliminate rmlock from ipfw's BPF code.
ae [Tue, 23 Jul 2019 12:52:36 +0000 (12:52 +0000)]
Eliminate rmlock from ipfw's BPF code.

After r343631 pfil hooks are invoked in net_epoch_preempt section,
this allows to avoid extra locking. Add NET_EPOCH_ASSER() assertion
to each ipfw_bpf_*tap*() call to require to be called from inside
epoch section.

Use NET_EPOCH_WAIT() in ipfw_clone_destroy() to wait until it becomes
safe to free() ifnet. And use on-stack ifnet pointer in each
ipfw_bpf_*tap*() call to avoid NULL pointer dereference in case when
V_*log_if global variable will become NULL during ipfw_bpf_*tap*() call.

Sponsored by: Yandex LLC

4 years agoTemporarily skip flakey test case
lwhsu [Tue, 23 Jul 2019 09:39:27 +0000 (09:39 +0000)]
Temporarily skip flakey test case
sys.kern.ptrace_test.ptrace__parent_sees_exit_after_child_debugger

PR: 239399
Sponsored by: The FreeBSD Foundation

4 years agoTemporarily skip flakey test case
lwhsu [Tue, 23 Jul 2019 09:19:58 +0000 (09:19 +0000)]
Temporarily skip flakey test case
sys.kern.ptrace_test.ptrace__follow_fork_both_attached_unrelated_debugger

PR: 239397
Sponsored by: The FreeBSD Foundation

4 years agoTemporarily skip flakey test case
lwhsu [Tue, 23 Jul 2019 07:56:42 +0000 (07:56 +0000)]
Temporarily skip flakey test case
sys.kern.ptrace_test.ptrace__PT_KILL_competing_stop

PR: 220841
Sponsored by: The FreeBSD Foundation

4 years agoMake CAM ATA stack handle disk resizes.
mav [Tue, 23 Jul 2019 02:11:14 +0000 (02:11 +0000)]
Make CAM ATA stack handle disk resizes.

While for ATA disks resize is even more rare situation than for SCSI, it
may happen in case of HPA or AMA being used.  Make ATA XPT report minor
IDENTIFY DATA change to upper layers with AC_GETDEV_CHANGED, and ada(4)
periph driver handle that event, recalculating all the disk properties and
signalling resize to GEOM.  Since ATA has no mechanism of UNIT ATTENTIONs,
like SCSI, it has no way to detect that something has changed.  That is why
this functionality depends on explicit reprobe via XPT_REPROBE_LUN call.

MFC after: 2 weeks
Relnotes: yes
Sponsored by: iXsystems, Inc.

4 years agopowerpc: Unbreak 64-bit pmap from 350206
jhibbits [Mon, 22 Jul 2019 22:59:50 +0000 (22:59 +0000)]
powerpc: Unbreak 64-bit pmap from 350206

oldpvo is never explicitly NULL'd by moea64_pvo_enter(), so don't check for
NULL to do anything, only check error.

PR: 239372
Reported by: Francis Little

4 years agoCorrect spelling, partion -> partition.
ian [Mon, 22 Jul 2019 22:41:44 +0000 (22:41 +0000)]
Correct spelling, partion -> partition.

4 years agoarm: ti: Add a driver for ti,sysc bus
manu [Mon, 22 Jul 2019 21:55:33 +0000 (21:55 +0000)]
arm: ti: Add a driver for ti,sysc bus

ti,sysc is a simple-bus like driver.
Add a driver for it so child nodes can attach.

4 years agoarm: ti: Get the hwmods property from the parent node
manu [Mon, 22 Jul 2019 21:53:58 +0000 (21:53 +0000)]
arm: ti: Get the hwmods property from the parent node

Since the Linux 5.0 dts the ti,hwmods property is on the parent
ti.sysc node.

4 years agoata_xpt: Use the correct union member when accessing valid.
brooks [Mon, 22 Jul 2019 21:07:58 +0000 (21:07 +0000)]
ata_xpt: Use the correct union member when accessing valid.

In principle this should not matter as it's a union and they point to
the same memory location but based on the code above we should be
accessing .sata and not .ata.

Submitted by: arichardson
Reviewed by: scottl, imp
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21002

4 years ago[skip ci] Fix the comment for cache_purge(9)
asomers [Mon, 22 Jul 2019 21:03:52 +0000 (21:03 +0000)]
[skip ci] Fix the comment for cache_purge(9)

This is a merge of r348738 from projects/fuse2

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoRemove the USE_RFC2292BIS option and reap dead code
asomers [Mon, 22 Jul 2019 20:11:33 +0000 (20:11 +0000)]
Remove the USE_RFC2292BIS option and reap dead code

This option was imported as part of the KAME project in r62627 (in 2000).
It was turned on unconditionally in r121472 (in 2003) and has been on ever
since. The old alternative code has bitrotted. Reap the dead code.

Reported by: Ján Sučan <jansucan@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20938

4 years agoAllow "update" option to be used in the fstab(5). Document possible use case.
sobomax [Mon, 22 Jul 2019 20:04:55 +0000 (20:04 +0000)]
Allow "update" option to be used in the fstab(5). Document possible use case.

Approved by: mckusick
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D18586

4 years agoTemporarily skip sys.netpfil.pf.forward.{v4,v6} and sys.netpfil.pf.set_tos.v4
lwhsu [Mon, 22 Jul 2019 18:54:26 +0000 (18:54 +0000)]
Temporarily skip sys.netpfil.pf.forward.{v4,v6} and sys.netpfil.pf.set_tos.v4
on i386 as they are flakey on it

PR: 239380
Sponsored by: The FreeBSD Foundation

4 years agoFix URL.
lwhsu [Mon, 22 Jul 2019 18:43:46 +0000 (18:43 +0000)]
Fix URL.

Sponsored by: The FreeBSD Foundation

4 years agoTemporarily skip lib.libc.regex.exhaust_test.regcomp_too_big and
lwhsu [Mon, 22 Jul 2019 18:42:55 +0000 (18:42 +0000)]
Temporarily skip lib.libc.regex.exhaust_test.regcomp_too_big and
lib.libregex.exhaust_test.regcomp_too_big on i386 as they are flakey on it

PR: 237450
Sponsored by: The FreeBSD Foundation

4 years agoBe consistent about temporary variable use in adjacent loops.
brooks [Mon, 22 Jul 2019 18:27:17 +0000 (18:27 +0000)]
Be consistent about temporary variable use in adjacent loops.

Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA, AFRL

4 years agoWakeup the application when doing PD-API for unordered DATA chunks.
tuexen [Mon, 22 Jul 2019 18:11:35 +0000 (18:11 +0000)]
Wakeup the application when doing PD-API for unordered DATA chunks.
Work done with rrs@.

MFC after: 1 week

4 years agomptutil: emit a warning on big-endian architectures
emaste [Mon, 22 Jul 2019 17:25:35 +0000 (17:25 +0000)]
mptutil: emit a warning on big-endian architectures

It is known to be broken.

PR: 162513
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoUnify BTL parsing for `camcontrol debug` and `reset`.
mav [Mon, 22 Jul 2019 17:08:18 +0000 (17:08 +0000)]
Unify BTL parsing for `camcontrol debug` and `reset`.

This makes `camcontrol debug` also allow peripheral device specification.

While there, make BTL parser more strict and switch from strtok() to
strsep().

MFC after: 2 weeks

4 years agoRemove unused header.
br [Mon, 22 Jul 2019 16:50:37 +0000 (16:50 +0000)]
Remove unused header.

Sponsored by: DARPA, AFRL

4 years agoo Add support for BERI IOMMU device
br [Mon, 22 Jul 2019 16:01:20 +0000 (16:01 +0000)]
o Add support for BERI IOMMU device
o Add an experimental IOMMU support to xDMA framework

The BERI IOMMU device is the part of CHERI device-model project [1]. It
translates memory addresses for various BERI peripherals modelled in
software. It accepts FreeBSD/mips64 page directories format and manages
BERI TLB.

1. https://github.com/CTSRD-CHERI/device-model

Sponsored by: DARPA, AFRL

4 years agoTemporarily skip flakey test case
lwhsu [Mon, 22 Jul 2019 10:37:56 +0000 (10:37 +0000)]
Temporarily skip flakey test case
sys.kern.ptrace_test.ptrace__follow_fork_child_detached_unrelated_debugger

PR: 239292
Sponsored by: The FreeBSD Foundation

4 years agoarm: Use -O2 instead of -O as optimization flag
manu [Mon, 22 Jul 2019 10:17:59 +0000 (10:17 +0000)]
arm: Use -O2 instead of -O as optimization flag

When using Clang -O is equivalent to -O2, change it -O2 to make it
consistent with other platforms.

Reference: https://clang.llvm.org/docs/ClangCommandLineReference.html#optimization-level

Submitted by: Daniel Engberg (daniel.engberg.lists@pyret.net)
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D21021

4 years agoVOP_PATHCONF.9: correct the type of the retval argument
asomers [Mon, 22 Jul 2019 04:14:53 +0000 (04:14 +0000)]
VOP_PATHCONF.9: correct the type of the retval argument

It was changed from int to register_t in r22521 and from register_t to long
in r328099, but the man page wasn't updated either time.

MFC after: 2 weeks

4 years agopowerpc64/mmu: Make moea64_pvo_enter() return if an entry already exists
jhibbits [Mon, 22 Jul 2019 03:11:54 +0000 (03:11 +0000)]
powerpc64/mmu: Make moea64_pvo_enter() return if an entry already exists

Summary:
Instead of searching for a PVO entry before adding, take advantage of
the fact that RB_INSERT() returns NULL if it inserts, and the existing entry if
an entry exists, without inserting a new entry.  This saves an extra tree
traversal in the cases where the PVO does not exist.

Reviewed by: luporl
Differential Revision: https://reviews.freebsd.org/D20944

4 years agoSwitch the rest of the refcount(9) functions to bool return type.
kib [Sun, 21 Jul 2019 20:16:48 +0000 (20:16 +0000)]
Switch the rest of the refcount(9) functions to bool return type.

There are some explicit comparisions of refcount_release(9) result
with 0/1, which are fine.

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

4 years agoAdd support for setting the aging/frequency-offset register via sysctl.
ian [Sun, 21 Jul 2019 17:14:39 +0000 (17:14 +0000)]
Add support for setting the aging/frequency-offset register via sysctl.

The 2127 and 2129 chips support a frequency tuning value in the range of
-7 through +8 PPM; add a sysctl handler to read and set the value.

4 years agoWith the introduction of software dirty bit emulation for managed mappings,
alc [Sun, 21 Jul 2019 17:00:19 +0000 (17:00 +0000)]
With the introduction of software dirty bit emulation for managed mappings,
we should test ATTR_SW_DBM, not ATTR_AP_RW, to determine whether to set
PGA_WRITEABLE.  In effect, we are currently setting PGA_WRITEABLE based on
whether the dirty bit is preset, not whether the mapping is writeable.
Correct this mistake.

Reviewed by: markj
X-MFC with: r350004
Differential Revision: https://reviews.freebsd.org/D21013

4 years agoLink fileargs_lstat.3.
markj [Sun, 21 Jul 2019 16:35:49 +0000 (16:35 +0000)]
Link fileargs_lstat.3.

Sponsored by: The FreeBSD Foundation

4 years agoFix userspace build after r350199.
kib [Sun, 21 Jul 2019 16:24:40 +0000 (16:24 +0000)]
Fix userspace build after r350199.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoCheck and avoid overflow when incrementing fp->f_count in
kib [Sun, 21 Jul 2019 15:07:12 +0000 (15:07 +0000)]
Check and avoid overflow when incrementing fp->f_count in
fget_unlocked() and fhold().

On sufficiently large machine, f_count can be legitimately very large,
e.g. malicious code can dup same fd up to the per-process
filedescriptors limit, and then fork as much as it can.
On some smaller machine, I see
kern.maxfilesperproc: 939132
kern.maxprocperuid: 34203
which already overflows u_int.  More, the malicious code can create
transient references by sending fds over unix sockets.

I realized that this check is missed after reading
https://secfault-security.com/blog/FreeBSD-SA-1902.fd.html

Reviewed by: markj (previous version), mjg
Tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D20947

4 years agoMark Felder has stepped down from portmgr and ports-secteam
rene [Sun, 21 Jul 2019 11:07:39 +0000 (11:07 +0000)]
Mark Felder has stepped down from portmgr and ports-secteam

4 years agoIntroduce pmap_store(), and use it to replace pmap_load_store() in places
alc [Sun, 21 Jul 2019 03:26:26 +0000 (03:26 +0000)]
Introduce pmap_store(), and use it to replace pmap_load_store() in places
where the page table entry was previously invalid.  (Note that I did not
replace pmap_load_store() when it was followed by a TLB invalidation, even
if we are not using the return value from pmap_load_store().)

Correct an error in pmap_enter().  A test for determining when to set
PGA_WRITEABLE was always true, even if the mapping was read only.

In pmap_enter_l2(), when replacing an empty kernel page table page by a
superpage mapping, clear the old l2 entry and issue a TLB invalidation.  My
reading of the ARM architecture manual leads me to believe that the TLB
could hold an intermediate entry referencing the empty kernel page table
page even though it contains no valid mappings.

Replace a couple direct uses of atomic_clear_64() by the new
pmap_clear_bits().

In a couple comments, replace the term "paging-structure caches", which is
an Intel-specific term for the caches that hold intermediate entries in the
page table, with wording that is more consistent with the ARM architecture
manual.

Reviewed by: markj
X-MFC after: r350004
Differential Revision: https://reviews.freebsd.org/D20998

4 years agopowerpc: Remove an unnecessary #ifdef guard from slb.c
jhibbits [Sun, 21 Jul 2019 03:19:54 +0000 (03:19 +0000)]
powerpc: Remove an unnecessary #ifdef guard from slb.c

slb.c is only compiled for powerpc64, so no need for the #ifdef in this block.

4 years agoTreat any inode with bad content as unknown (i.e., ask if it should
mckusick [Sat, 20 Jul 2019 21:39:32 +0000 (21:39 +0000)]
Treat any inode with bad content as unknown (i.e., ask if it should
be cleared).

Sponsored by: Netflix

4 years agoWhen running with journaled soft updates, some updated inodes were not
mckusick [Sat, 20 Jul 2019 21:20:40 +0000 (21:20 +0000)]
When running with journaled soft updates, some updated inodes were not
having their check hashes recomputed which resulted in spurious inode
check-hash errors when the system came back up after a crash.

Reported by:  Alan Somers
Sponsored by: Netflix

4 years agoRewrite the nxprtc chip init to extend battery life by using power-saving
ian [Sat, 20 Jul 2019 21:10:27 +0000 (21:10 +0000)]
Rewrite the nxprtc chip init to extend battery life by using power-saving
features offered by the chips.

For 2127 and 2129 chips, fix the detection of when chip-init is needed.  The
chip config needs to be reset whenever power was lost, but the logic was
wrong for 212x chips (it only worked for 8523).  Now the "oscillator
stopped" bit rather than the power manager mode is used to detect startup
after powerfail.

For all chips, disable the clock output pin.

For chips that have a timestamp/tamper-monitor feature, turn off monitoring
of the timestamp trigger pin.

The 8523, 2127, and 2129 chips have a "power manager" feature that offers
several options.  We've been using the default mode which enables
everything.  Now the code sets the power manager options to

 - direct-switch (when Vdd < Vbat, without extra threshold check)
 - no battery monitor
 - no external powerfail monitor

This reduces the current draw while running on battery from 1930nA to 880nA,
which should roughly double the lifespan of the battery under load.

Because battery checking is a nice thing to have, the code now does a check
at startup, and then once a day after that, instead of checking continuously
(but only actually reporting at startup).  The battery check is now done by
setting the power manager back to default mode, sleeping briefly while it
makes a voltage measurement, then switching back to power-saving mode.

4 years agomotd: Generate from template to /var/run
cem [Sat, 20 Jul 2019 20:56:31 +0000 (20:56 +0000)]
motd: Generate from template to /var/run

Update login(1), its manual pages, similar utilities, and motd.5 to refer to
the new location.

Suggested by: delphij@ (re: r349256)
Reviewed by: bcr (manpages), delphij
Differential Revision: https://reviews.freebsd.org/D20721

4 years agoIn trimming on startup, invoke swapon before closing the fd used for
dougm [Sat, 20 Jul 2019 20:47:07 +0000 (20:47 +0000)]
In trimming on startup, invoke swapon before closing the fd used for
trimming so that a geli device isn't detached before swapon is
invoked.

Submitted by: sigsys_gmail.com
Discussed with: alc
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D21006

4 years agoRename vm_page_{import,release}() to vm_page_zone_{import,release}().
markj [Sat, 20 Jul 2019 18:25:41 +0000 (18:25 +0000)]
Rename vm_page_{import,release}() to vm_page_zone_{import,release}().

I would like to use the name vm_page_release() for a different purpose,
and vm_page_{import,release}() are local to vm_page.c.

Reviewed by: kib
MFC after: 1 week

4 years agopowerpc/SPE: Enable SPV bit for EFSCFD instruction emulation
jhibbits [Sat, 20 Jul 2019 18:22:01 +0000 (18:22 +0000)]
powerpc/SPE: Enable SPV bit for EFSCFD instruction emulation

EFSCFD (floating point single convert from double) emulation requires saving
the high word of the register, which uses SPE instructions.  Enable the SPE
to avoid an SPV Unavailable exception.

MFC after: 1 week

4 years agodtso: allwinner: Add an overlay for H3 i2c0
manu [Sat, 20 Jul 2019 17:42:46 +0000 (17:42 +0000)]
dtso: allwinner: Add an overlay for H3 i2c0

Most of the H3 boards don't enable i2c as it is unused.
Add an overlay so it's easier for user to use i2c device.

4 years agoexpand_number(3) parses suffixes, not prefixes.
jhb [Sat, 20 Jul 2019 16:03:54 +0000 (16:03 +0000)]
expand_number(3) parses suffixes, not prefixes.

While here, tidy the opening sentence a bit.

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20791

4 years agoImprove the precision of bhyve's vPIT.
jhb [Sat, 20 Jul 2019 15:59:49 +0000 (15:59 +0000)]
Improve the precision of bhyve's vPIT.

Use 'struct bintime' instead of 'sbintime_t' to manage times in vPIT
to postpone rounding to final results rather than intermediate
results.  In tests performed by Joyent, this reduced the error measured
by Linux guests by 59 ppm.

Smart OS bug: https://smartos.org/bugview/OS-6923
Submitted by: Patrick Mooney
Reviewed by: rgrimes
Obtained from: SmartOS / Joyent
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20335