]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMake zfsd(8) build obey CFLAGS.
trasz [Wed, 10 Apr 2019 13:42:37 +0000 (13:42 +0000)]
Make zfsd(8) build obey CFLAGS.

Reviewed by: imp
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19865

5 years agoAdd a smoke test QEMU boot script for CI
emaste [Wed, 10 Apr 2019 13:41:34 +0000 (13:41 +0000)]
Add a smoke test QEMU boot script for CI

Reviewed by: imp, lwhsu (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19661

5 years agoar: implement support for /SYM64/ 64-bit archives
emaste [Wed, 10 Apr 2019 13:13:34 +0000 (13:13 +0000)]
ar: implement support for /SYM64/ 64-bit archives

PR: 234454
Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by: imp (earlier)
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18793

5 years agofix cache_lookup's documentation
asomers [Wed, 10 Apr 2019 13:02:33 +0000 (13:02 +0000)]
fix cache_lookup's documentation

cache_lookup's documentation got dislocated by r324378. Relocate and expand
it.

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

5 years agoImprove vnode lock assertions.
trasz [Wed, 10 Apr 2019 10:21:14 +0000 (10:21 +0000)]
Improve vnode lock assertions.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agourtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)
avos [Wed, 10 Apr 2019 08:17:56 +0000 (08:17 +0000)]
urtw(4), otus(4), iwi(4): allow to set non-default MAC address via ifconfig(8)

Tested with Netgear WG111 v3 (RTL8187B, urtw(4)), STA mode.

MFC after: 1 week

5 years agoRevert r346017 pending compiled-in zfs fix
crees [Wed, 10 Apr 2019 07:51:13 +0000 (07:51 +0000)]
Revert r346017 pending compiled-in zfs fix

PR: 237172
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D18670

5 years agoAlways report file with incorrect hash.
sjg [Tue, 9 Apr 2019 22:20:11 +0000 (22:20 +0000)]
Always report file with incorrect hash.

5 years agoObvious comment correction.
glebius [Tue, 9 Apr 2019 22:15:39 +0000 (22:15 +0000)]
Obvious comment correction.

5 years agoRefine r330113 to honor the ProducerConsumer flag most of the time.
jhb [Tue, 9 Apr 2019 21:18:02 +0000 (21:18 +0000)]
Refine r330113 to honor the ProducerConsumer flag most of the time.

While it is true that the ACPI spec says that the flag is only valid
on Extended Address Space Descriptors, examples of other descriptors
in the spec use the ProducerConsumer flag explicitly, and real
hardware uses it as well.  In fact, even in the ASL of the Thunder X2
for which r330113 was a workaround, some devices use this flag on
non-Extended Address Space Descriptors correctly.  Instead, only
ignore the flag for resources associated with the UART devices on the
Thunder X2 using the "ARMH0011" HID to identify these devices.

This should fix regressions from ignoring this flag in other contexts
such as Hyper-V.

PR: 235876
Reported by: Wei Hu <weh@microsoft.com>
Tested by: emaste (Thunder X2)
MFC after: 2 weeks

5 years agoAdd vn_fsync_buf().
kib [Tue, 9 Apr 2019 20:20:04 +0000 (20:20 +0000)]
Add vn_fsync_buf().

Provide a convenience function to avoid the hack with filling fake
struct vop_fsync_args and then calling vop_stdfsync().

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoFix dirty buf exhaustion easily triggered with msdosfs.
kib [Tue, 9 Apr 2019 19:55:02 +0000 (19:55 +0000)]
Fix dirty buf exhaustion easily triggered with msdosfs.

If truncate(2) is performed on msdosfs file, which extends the file by
system-depended large amount, fs creates corresponding amount of dirty
delayed-write buffers, which can consume all buffers.  Such buffers
cannot be flushed by the bufdaemon because the ftruncate() thread owns
the vnode lock.  So the system runs out of free buffers, and even
truncate() thread starves, which means deadlock because it owns the
vnode lock.

Fix this by doing vnode fsync in extendfile() when low memory or low
buffers condition detected, which flushes all dirty buffers belonging
to the file being extended.

Note that the more usual fallback to bawrite() does not work
acceptable in this situation, because it would only allow one buffer
to be recycled.  Other filesystems, most important UFS, do not allow
userspace to create arbitrary amount of dirty delayed-write buffers
without feedback, so bawrite() is good enough for them.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoDon't pre-reserve resources for CPU devices when they are set.
jhb [Tue, 9 Apr 2019 19:22:08 +0000 (19:22 +0000)]
Don't pre-reserve resources for CPU devices when they are set.

CPUs can use shared (RF_SHAREABLE) resources for the I/O port used for
entering and exiting C states.  If this I/O port is included in an ACPI
system resource device, then this happens to still work, but if the port
wasn't part of a system resource device, only the first CPU could allocate
the I/O port and use C states since resource_list_reserve() was always
allocating the resource from nexus0 without RF_SHAREABLE.  By avoiding
the reservation, the flags from the bus_alloc_resource() in the CPU driver
(which include RF_SHAREABLE) are honored.

PR: 236513
Reported by: stockhausen@collogia.de
Sleuthing by: avg
Reviewed by: avg
MFC after: 2 weeks

5 years agopci_cfgreg.c: Use io port config access for early boot time.
kib [Tue, 9 Apr 2019 18:07:17 +0000 (18:07 +0000)]
pci_cfgreg.c: Use io port config access for early boot time.

Some early PCIe chipsets are explicitly listed in the white-list to
enable use of the MMIO config space accesses, perhaps because ACPI
tables were not reliable source of the base MCFG address at that time.
For that chipsets, MCFG base was read from the known chipset MCFGbase
config register.

During very early stage of boot, when access to the PCI config space
is performed (see e.g. pci_early_quirks.c), we cannot map 255MB of
registers because the method used with pre-boot pmap overflows initial
kernel page tables.

Move fallback to read MCFGbase to the attachment method of the
x86/legacy device, which removes code duplication, and results in the
use of io accesses until MCFG is parsed or legacy attach called.

For amd64, pre-initialize cfgmech with CFGMECH_1, right now we
dynamically assign CFGMECH_1 to it anyway, and remove checks for
CFGMECH_NONE.

There is a mention in the Intel documentation for corresponding
chipsets that OS must use either io port or MMIO access method, but we
already break this rule by reading MCFGbase register, so one more
access seems to be innocent.

Reported by: longwitz@incore.de
PR: 236838
Reviewed by: avg (other version), jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19833

5 years agoPolish netmap(4) testcases a bit
ngie [Tue, 9 Apr 2019 17:52:11 +0000 (17:52 +0000)]
Polish netmap(4) testcases a bit

1. Not all kernels have netmap(4) support. Check for netmap(4) support before
   attempting to run the tests via the `PLAIN_REQUIRE_KERNEL_MODULE(..)` macro.
2. Libraries shouldn't be added to LDFLAGS; they should be added to LIBADD
   instead. This allows the build system to evaluate dependencies for sanity.
3. Sort some of the Makefile variables per bsd.README.

1., in particular, will resolve failures when running this testcase on kernels
lacking netmap(4) support, e.g., the i386 GENERIC kernels on ^/stable/11 and
^/stable/12.

PR: 237129
Reviewed by: vmaffione
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19864

5 years agoFix geli device cleanup
ngie [Tue, 9 Apr 2019 16:20:36 +0000 (16:20 +0000)]
Fix geli device cleanup

Final cleanup routines shouldn't be called from testcases; it should be called
from the testcase cleanup routine.

Furthermore, `geli_test_cleanup` should take care of cleaning up geli providers
and the memory disks used for the geli providers. `geli_test_cleanup` will always
be executed whereas the equivalent logic in `geli_test_body`, may not have been
executed if the test failed prior to the logic being run.

Prior to this change, the test case was trying to clean up `$md` twice: once in
at the end of the test case body function, and the other in the cleanup function.
The cleanup function logic was failing because there wasn't anything to clean up
in the cleanup function and the errors weren't being ignored.

This fixes FreeBSD test suite runs after r345864.

PR: 237128
Reviewed by: asomers, pjd
Approved by: emaste (mentor)
MFC with: r345864
Differential Revision: https://reviews.freebsd.org/D19854

5 years agoFix a typo when sanity checking in the bootstrap-tools target
ngie [Tue, 9 Apr 2019 16:17:31 +0000 (16:17 +0000)]
Fix a typo when sanity checking in the bootstrap-tools target

The path is incorrect for the linker in the error message. It should have been
/usr/bin/ld, not /usr/bin/cc .

Reviewed by: emaste
Approved by: emaste (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19852

5 years agolibc: update strstr implementation to match musl
emaste [Tue, 9 Apr 2019 15:52:18 +0000 (15:52 +0000)]
libc: update strstr implementation to match musl

musl commits:
122d67f846cb0be2c9e1c3880db9eb9545bbe38c
0239cd0681e889a269fb7691f60e81ef8d081e6b
8f5a820d147da36bcdbddd201b35d293699dacd8

Submitted by: David CARLIER <devnexen_gmail.com>
Obtained from: musl
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19834

5 years agoFactor out section loading into a separate function.
trasz [Tue, 9 Apr 2019 15:24:38 +0000 (15:24 +0000)]
Factor out section loading into a separate function.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19846

5 years agoIn some cases like NanoPI R1, its second USB ethernet
ganbold [Tue, 9 Apr 2019 13:54:08 +0000 (13:54 +0000)]
In some cases like NanoPI R1, its second USB ethernet
RTL8152 (chip version URE_CHIP_VER_4C10) doesn't
have hardwired MAC address, in other words, it is all zeros.
This commit fixes it by setting random MAC address
when MAC address is all zeros.

Reviewed by: kevlo
Differential Revision: https://reviews.freebsd.org/D19856

5 years agoioatcontrol(8) crc-copy flag bug and misc usage tweak
tychon [Tue, 9 Apr 2019 10:33:18 +0000 (10:33 +0000)]
ioatcontrol(8) crc-copy flag bug and misc usage tweak

Reviewed by: cem
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19855

5 years agoRemove spurious comma.
trasz [Tue, 9 Apr 2019 10:17:24 +0000 (10:17 +0000)]
Remove spurious comma.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years ago.Xr protect(1) and proccontrol(1) from procctl(2).
trasz [Tue, 9 Apr 2019 10:09:59 +0000 (10:09 +0000)]
.Xr protect(1) and proccontrol(1) from procctl(2).

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

5 years agoStyle only change: Prefer $() to ``
imp [Mon, 8 Apr 2019 18:25:14 +0000 (18:25 +0000)]
Style only change: Prefer $() to ``

$() is more modern and also nests. Convert the mix of styles to using
only the former (although the latter was more common). It's the more
dominant style in other shell scripts these days as well.

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

5 years agoExercise some care before sending SIGHUP to mountd.
kib [Mon, 8 Apr 2019 18:16:49 +0000 (18:16 +0000)]
Exercise some care before sending SIGHUP to mountd.

Reviewed by: antoine, emaste, oshogbo
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19847

5 years agoHandle races when remounting UFS volume from ro to rw.
kib [Mon, 8 Apr 2019 15:20:05 +0000 (15:20 +0000)]
Handle races when remounting UFS volume from ro to rw.

In particular, ensure that writers are not unleashed before SU
structures are initialized.  Also, correctly handle MNT_ASYNC before
this.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoRefactor ELF interpreter loading into a separate function.
trasz [Mon, 8 Apr 2019 14:31:07 +0000 (14:31 +0000)]
Refactor ELF interpreter loading into a separate function.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19741

5 years agoIn the unlinkat syscall, the operation is performed on the directory
oshogbo [Mon, 8 Apr 2019 14:23:52 +0000 (14:23 +0000)]
In the unlinkat syscall, the operation is performed on the directory
descriptor, not the file descriptor. The file descriptor is used only for
verification so do not expect any additional capabilities on it.

Reported by: antoine
Tested by: antoine
Discussed with: kib, emaste, bapt
Sponsored by: Fudo Security

5 years agoFix URE_WDT6_SET_MODE value in the register definition.
ganbold [Mon, 8 Apr 2019 13:40:46 +0000 (13:40 +0000)]
Fix URE_WDT6_SET_MODE value in the register definition.
Both linux and u-boot sources for RTL8152 driver has this value.
RTL8152 USB ethernet is used in NanoPI R1 board as second ethernet.
This fixes for me RTL8152 USB ethernet not detected problem after
reboot on NanoPI R1 board.

Both NetBSD and OpenBSD have a wrong value so far.

5 years agoFix copying of MEMBUFs to MEMBUFs. This case was implemented by using
bde [Mon, 8 Apr 2019 04:54:15 +0000 (04:54 +0000)]
Fix copying of MEMBUFs to MEMBUFs.  This case was implemented by using
the same code as the VIDBUF8 case, so it only worked for depths <= 8.
The 2 directions for copying between VIDBUFs and MEMBUFs worked by using
a Read/Write organization which makes the destination a VIDBUF so the
MEMBUF case was not reached, and the VIDBUF cases have already been fixed.

Fix this by removing "optimizations" for the VIDBUF8 case so that the
MEMBUF case can fall through to the general (non-segmented) case.  The
optimizations were to duplicate code for the VIDBUF8 case so as to
avoid 2 multiplications by 1 at runtime.  This optimization is not useful
since the multiplications are not in the inner loop.

Remove the same "optimization" for the VIDBUF8S case.  It was even less
useful there since it duplicated more to do relatively less.

5 years agoFix restoring the geometry when recovering from an error. Just restore the
bde [Mon, 8 Apr 2019 04:07:37 +0000 (04:07 +0000)]
Fix restoring the geometry when recovering from an error.  Just restore the
previous geometry, and don't do extra work to calculate the default geometry
so as to reset to that.

5 years agostrings: disable Casper support while building native-xtools
oshogbo [Mon, 8 Apr 2019 03:35:47 +0000 (03:35 +0000)]
strings: disable Casper support while building native-xtools

Reported by: Charlie Li
Tested by: Charlie Li

5 years agoMake RELDATE be on a single line.
imp [Sun, 7 Apr 2019 21:01:02 +0000 (21:01 +0000)]
Make RELDATE be on a single line.

All variable assignments that start in column 1 have to be on a single
line for amd to build due to as weird dependency there (most likely it
can be fixed to use the new VARS_ONLY feature, but it isn't
today). usr.sbin/amd/include/Makefile calls
usr.sbin/amd/include/newvers.sh which does:
eval `LC_ALL=C egrep '^[A-Z]+=' $1 | grep -v COPYRIGHT`
which is where that requirement comes from. It handles COPYRIGHT since
that's an exception. Rather than add additional exceptions, cope with
the long line in newvers.sh instead. Note: it no longer needs to
filter COPYRIGHT because the assignment doesn't start in column 1
anymore.

I had done a universe when I had an earlier version of r346018 that
had it as one line. When I changed it to multi-line as suggested in
the review, I only built kernels on a couple of architectures to make
sure it didn't break anything.

Add comment to newvers.sh noting this.

Obviously, this unbreaks the amd build.

5 years agoRISC-V: initialize pcpu slightly earlier
mhorne [Sun, 7 Apr 2019 20:12:24 +0000 (20:12 +0000)]
RISC-V: initialize pcpu slightly earlier

In certain scenarios, it is possible for PCPU data to be
accessed before it has been initialized (e.g. during printf
if the kernel was built with the TSLOG option).

Initialize the PCPU pointer for hart 0 at the beginning of
initriscv() rather than near the end.

Reviewed by: markj
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D19726

5 years agoUse default shell assignment rather more complicated if then
imp [Sun, 7 Apr 2019 18:39:55 +0000 (18:39 +0000)]
Use default shell assignment rather more complicated if then
construct.

Discussed with: emaste@, allanjude@ (changes (or not) based on their feedback)
Differential Revision: https://reviews.freebsd.org/D19797

5 years agoRemove now unnecessary kldstat check before attempting to load modules.
crees [Sun, 7 Apr 2019 18:31:45 +0000 (18:31 +0000)]
Remove now unnecessary kldstat check before attempting to load modules.

Since r233109, kldload has the -n option, which silently ignores options
that are already loaded.

https://lists.freebsd.org/pipermail/freebsd-rc/2018-December/003899.html

Note that this script no longer reports if the module is already loaded,
but it could be argued this wasn't particularly useful information.

PR: docs/234248
Reviewed by: bcr (docs), kib, rgrimes (visual)
Approved by: jilles
Differential Revision: https://reviews.freebsd.org/D18670

5 years agoAdd option to build LLVM RISC-V target
mhorne [Sun, 7 Apr 2019 18:24:26 +0000 (18:24 +0000)]
Add option to build LLVM RISC-V target

Reviewed by: emaste, dim
Approved by: markj (mentor)
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D19759

5 years agoAdd g_label_flashmap.c to the module, should have been part of r345480.
ian [Sun, 7 Apr 2019 16:33:22 +0000 (16:33 +0000)]
Add g_label_flashmap.c to the module, should have been part of r345480.

Reported by: Jia-Shiun Li <jiashiun@gmail.com>

5 years agoBump FreeBSD version after r345982.
oshogbo [Sun, 7 Apr 2019 16:07:41 +0000 (16:07 +0000)]
Bump FreeBSD version after r345982.

Reported by: Shawn Webb <shawn.webb@hardenedbsd.org>
Discussed with: imp, cy, rgrimes

5 years agoStop compiling bhyve(8) with -O0.
markj [Sun, 7 Apr 2019 14:30:17 +0000 (14:30 +0000)]
Stop compiling bhyve(8) with -O0.

DEBUG_FLAGS is always added to CFLAGS.  This setting appears to be
accidental and came in with r243327.

Reviewed by: anish, emaste, jhb, rgrimes
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19787

5 years agoFix indentation.
markj [Sun, 7 Apr 2019 14:28:02 +0000 (14:28 +0000)]
Fix indentation.

No functional change intended.

Reviewed by: bcran, jhb, rgrimes
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19786

5 years agoSet the p_oppid field of orphans when exiting.
markj [Sun, 7 Apr 2019 14:26:14 +0000 (14:26 +0000)]
Set the p_oppid field of orphans when exiting.

Such processes will be reparented to the reaper when the current
parent is done with them (i.e., ptrace detached), so p_oppid must be
updated accordingly.

Add a regression test to exercise this code path.  Previously it
would not be possible to reap an orphan with a stale oppid.

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

5 years agoloader: command_lsefi: ret can be used uninitialized
tsoome [Sun, 7 Apr 2019 14:07:28 +0000 (14:07 +0000)]
loader: command_lsefi: ret can be used uninitialized

MFC after: 1w

5 years agoloader: add file_remove() function to undo file_insert_tail().
tsoome [Sun, 7 Apr 2019 13:36:17 +0000 (13:36 +0000)]
loader: add file_remove() function to undo file_insert_tail().

346002 did miss the fact that we do not only undo the loadaddr, but also
we need to remove the inserted module. Implement file_remove() to do the job.

MFC after: 1w

5 years agoloader: mod_loadkld() error: we previously assumed 'last_file' could be null
tsoome [Sun, 7 Apr 2019 12:20:17 +0000 (12:20 +0000)]
loader: mod_loadkld() error: we previously assumed 'last_file' could be null

The last_file variable is used to reset the loadaddr variable back to original
value; however, it is possible the last_file is NULL, so we can not blindly
trust it. But then again, we can just save the original loadaddr and use
the saved value for recovery.

MFC after: 1w

5 years agoloader: file_addmetadata() should check for memory allocation
tsoome [Sun, 7 Apr 2019 12:10:19 +0000 (12:10 +0000)]
loader: file_addmetadata() should check for memory allocation

malloc() can return NULL.

MFC after: 1w

5 years agoloader: remove pointer checks before free() in module.c
tsoome [Sun, 7 Apr 2019 11:55:11 +0000 (11:55 +0000)]
loader: remove pointer checks before free() in module.c

free() does check for NULL argument, remove duplicate checks.

MFC after: 1w

5 years agoloader: file_addmodule should check for memory allocation
tsoome [Sun, 7 Apr 2019 11:50:41 +0000 (11:50 +0000)]
loader: file_addmodule should check for memory allocation

strdup() can return NULL.

MFC after: 1w

5 years agoloader: malloc+bzero is calloc
tsoome [Sun, 7 Apr 2019 11:48:41 +0000 (11:48 +0000)]
loader: malloc+bzero is calloc

Replace malloc+bzero in module.c with calloc.

MFC after: 1w

5 years agoGive new home to the comment from ppt_pci_reset(), explaining a nuance
kib [Sun, 7 Apr 2019 08:58:09 +0000 (08:58 +0000)]
Give new home to the comment from ppt_pci_reset(), explaining a nuance
of power reset.

Noted by: soralx@cydem.org
Sponsored by: Mellanox Technologies
MFC after: 12 days

5 years agoMFV r345988:
cy [Sat, 6 Apr 2019 23:35:23 +0000 (23:35 +0000)]
MFV r345988:

Update sqlite3-3.26.0 (3260000) --> sqlite3-3.27.1 (3270100)

MFC after: 2 weeks

5 years agoDelete the BUGS entry related to failing when jails are enabled.
rmacklem [Sat, 6 Apr 2019 22:14:03 +0000 (22:14 +0000)]
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.

PR: 205193
MFC after: 2 weeks

5 years agoFix nfsuserd so that it handles the mapped localhost address when jails
rmacklem [Sat, 6 Apr 2019 22:05:51 +0000 (22:05 +0000)]
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.

Tested by: freebsd@danielengel.com (earlier version)
PR: 205193
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19218

5 years agokern/subr_pctrie: Fix mismatched signedness in assertion comparison
cem [Sat, 6 Apr 2019 21:56:24 +0000 (21:56 +0000)]
kern/subr_pctrie: Fix mismatched signedness in assertion comparison

'tos' is an index into an array and never holds a negative value.  Correct
its signedness to match PCTRIE_LIMIT, which it is compared to in assertions.

No functional change (kills a warning).

5 years agoAdd INET6 support for the upcalls to the nfsuserd daemon.
rmacklem [Sat, 6 Apr 2019 21:53:46 +0000 (21:53 +0000)]
Add INET6 support for the upcalls to the nfsuserd daemon.

The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get
updates to the username<->uid and groupname<->gid mappings.
A change to AF_LOCAL last year had to be reverted, since it could result
in vnode locking issues on the AF_LOCAL socket.
This patch adds INET6 support and the required #ifdef INET and INET6
to the code.

Requested by: bz
PR: 205193
Reviewed by: bz, rgrimes
MFC after: 2 weeks
Differential Revision: http://reviews.freebsd.org/D19218

5 years agokern/subr_pctrie: Convert old-style boolean_t to plain "bool"
cem [Sat, 6 Apr 2019 20:38:44 +0000 (20:38 +0000)]
kern/subr_pctrie: Convert old-style boolean_t to plain "bool"

No functional change.

5 years agofusefs: fix a panic on mount
asomers [Sat, 6 Apr 2019 18:04:04 +0000 (18:04 +0000)]
fusefs: fix a panic on mount

Don't page fault if the file descriptor provided with "-o fd" is invalid.
This is a merge of r345419 from the projects/fuse2 branch.

Reviewed by: ngie
Tested by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19836

5 years agoAdd firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf
ae [Sat, 6 Apr 2019 17:21:05 +0000 (17:21 +0000)]
Add firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf

Reported by: Andrey Fesenko
X-MFC after: r345450

5 years agoUse funlinkat in pidfile to ensure we are removing the right file.
oshogbo [Sat, 6 Apr 2019 11:24:43 +0000 (11:24 +0000)]
Use funlinkat in pidfile to ensure we are removing the right file.

5 years agoRegen after r345982.
oshogbo [Sat, 6 Apr 2019 09:37:10 +0000 (09:37 +0000)]
Regen after r345982.

5 years agoIntroduce funlinkat syscall that always us to check if we are removing
oshogbo [Sat, 6 Apr 2019 09:34:26 +0000 (09:34 +0000)]
Introduce funlinkat syscall that always us to check if we are removing
the file associated with the given file descriptor.

Reviewed by: kib, asomers
Reviewed by: cem, jilles, brooks (they reviewed previous version)
Discussed with: pjd, and many others
Differential Revision: https://reviews.freebsd.org/D14567

5 years agoMFV: r345969
jkim [Sat, 6 Apr 2019 06:02:42 +0000 (06:02 +0000)]
MFV: r345969

Import ACPICA 20190405.

5 years agoWrite string constant differently to improve readability.
delphij [Sat, 6 Apr 2019 03:42:15 +0000 (03:42 +0000)]
Write string constant differently to improve readability.

Reported by: rgrimes
Reviewed by: rgrimes, emaste
MFC after: 13 days
Differential Revision: https://reviews.freebsd.org/D19829

5 years agopowerpc/powernv: Fix major bugs in opal_flash
jhibbits [Sat, 6 Apr 2019 02:39:56 +0000 (02:39 +0000)]
powerpc/powernv: Fix major bugs in opal_flash

* The BIO bio_data may not be page aligned.  Only the base address of each
  page worth of data is extracted to pass to OPAL.  Without page alignment
  it can scribble over random memory when finishing the page read.  Fix this
  by short-reading the first page to properly align for full page reads.
* Fix the definition of OPAL_FLASH_ERASE.
* Properly handle the async message result, as now returned from r345974.

5 years agopowerpc/powernv: Fix issues in opal_async
jhibbits [Sat, 6 Apr 2019 02:31:01 +0000 (02:31 +0000)]
powerpc/powernv: Fix issues in opal_async

* Properly return the full opal_msg from an async completion.
* Don't keep bugging OPAL, wait 100us or so.  With some minor changes to
  DELAY() to drop to very low priority, the thread won't hog the CPU while
  polling for the async completion.

5 years agonetwork.subr: improve configuration of cloned gif(4) interfaces
eugen [Fri, 5 Apr 2019 22:45:08 +0000 (22:45 +0000)]
network.subr: improve configuration of cloned gif(4) interfaces

ifconfig(8) syntax allows to specify only single address_family,
so we need additional invocation of ifconfig to support configuration
of cloned gif interface that may use different address families
for its internal and external addresses.

Also, ifconfig(8) does not allow to omit "inet6" keyword for address family
specifying IPv6 addresses as outer addresses of the interface.

Also, address_family is not "parameter" and it has to go before parameters
including "tunnel" keyword, so "ifconfig gif0 tunnel inet6 $oip1 $oip2" would be
wrong syntax and only "ifconfig gif0 inet6 tunnel $oip1 $oip2" is right.

With this change, the following works:

gifconfig_gif0="inet6 2a00::1 2a01::1"
ifconfig_gif0="inet 10.0.0.1 10.0.0.2 netmask 255.255.255.252"

MFC after: 2 weeks

5 years agoFix gcc warning about shadowed global.
kib [Fri, 5 Apr 2019 20:12:19 +0000 (20:12 +0000)]
Fix gcc warning about shadowed global.

Sponsored by: Mellanox Technologies
MFC after: 2 weeks

5 years agoEmergency fix for NULL deref in xo_xml_leader_len
phil [Fri, 5 Apr 2019 19:42:54 +0000 (19:42 +0000)]
Emergency fix for NULL deref in xo_xml_leader_len

5 years agoImplement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:32:26 +0000 (19:32 +0000)]
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd DEV_RESET /dev/devctl2 ioctl.
kib [Fri, 5 Apr 2019 19:31:26 +0000 (19:31 +0000)]
Add DEV_RESET /dev/devctl2 ioctl.

It performs BUS_RESET_CHILD() on the parental bus and the specified
device.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoRemove single-use DEV_RESET() macro.
kib [Fri, 5 Apr 2019 19:27:51 +0000 (19:27 +0000)]
Remove single-use DEV_RESET() macro.

It conflicts with the sys/bus.h DEV_XXX namespace.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoImplement resets for PCI buses and PCIe bridges.
kib [Fri, 5 Apr 2019 19:25:26 +0000 (19:25 +0000)]
Implement resets for PCI buses and PCIe bridges.

For PCI device (i.e. child of a PCI bus), reset tries FLR if
implemented and worked, and falls to power reset otherwise.

For PCIe bus (child of a PCIe bridge or root port), reset
disables PCIe link and then re-trains it, performing what is known as
link-level reset.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoProvide newbus infrastructure for initiating device reset.
kib [Fri, 5 Apr 2019 18:09:22 +0000 (18:09 +0000)]
Provide newbus infrastructure for initiating device reset.

The methods BUS_RESET_PREPARE(), BUS_RESET(), and BUS_RESET_POST()
should be implemented by bus which can provide reset to a device.  The
methods are described in inline doxygen comments.

Code only provides BUS_RESET_PREPARE() and BUS_RESET_POST() helpers
instead of default implementation, because actual bus needs to handle
device state around reset, while helpers provide the other half of
typical prepare/post code.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agoAdd __BEGIN_DECLS/__END_DECLS braces to libdevctl header.
kib [Fri, 5 Apr 2019 17:54:31 +0000 (17:54 +0000)]
Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

Reviewed by: imp (previous version), jhb (previous version)
Sponsored by: Mellanox Technologies
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D19646

5 years agobhyve: Fix NVMe data structure copy to guest
chuck [Fri, 5 Apr 2019 16:54:20 +0000 (16:54 +0000)]
bhyve: Fix NVMe data structure copy to guest

bhyve's NVMe emulation was transferring Identify data back to the guest
incorrectly causing memory corruptions. These corruptions resulted in
core dumps and other system level errors in the guest.

In their simplest form, NVMe Physical Region Page (PRP) values in
commands indicate which physical pages to use for data transfer. The
first PRP value is not required to be page aligned but does not cross a
page boundary. The second PRP value must be page aligned, does not cross
a page boundary, and need not be contiguous with PRP1.

The code was copying Identify data past the end of PRP1. This happens to
work if PRP1 and PRP2 are physically contiguous but will corrupt guest
memory in unpredictable ways if they are not.

Fix is to copy the Identify data back to the guest piecewise (i.e. for
each PRP entry). Also fix a similarly wrong problem when copying back
Log page data.

Reviewed by: imp (mentor), araujo, jhb, rgrimes, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19695

5 years agobhyve: Fix NVMe BAR size calculation
chuck [Fri, 5 Apr 2019 16:54:16 +0000 (16:54 +0000)]
bhyve: Fix NVMe BAR size calculation

The NVMe specification defines bits 13:4 of BAR0 as Reserved (i.e. 0x0).
Most drivers do not enforce this, but the Windows NVMe driver does and
will refuse to start the device (i.e. error 10) if any of these bits are
set.

The current BAR size calculation tries to minimize the amount of memory
the device reserves by scaling the BAR size by the maximum number of
queues supported by the device. But unless the device supports a large
number of queue pairs (over 1536), it will reserve too little memory.

The fix is to allocate a minimum of 16K bytes for BAR0.

Tested on Windows Server 2016 and 2019

Reviewed by: imp (mentor), araujo, jhb, bhyve
Approved by: imp (mentor), bhyve (jhb)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19676

5 years agovn_vmap_seekhole(): align running offset to the block boundary.
kib [Fri, 5 Apr 2019 16:14:16 +0000 (16:14 +0000)]
vn_vmap_seekhole(): align running offset to the block boundary.

Otherwise we might miss the last iteration where EOF appears below
unaligned noff.

Reported and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D19811

5 years agoFix mis-merge.
kib [Fri, 5 Apr 2019 16:12:35 +0000 (16:12 +0000)]
Fix mis-merge.

Amusingly, it is nop.

Noted by: trasz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
X-MFC-rev: r345702

5 years agotwsi: Use config_intrhook_oneshot instead of config_intrhook_establish
manu [Fri, 5 Apr 2019 15:53:27 +0000 (15:53 +0000)]
twsi: Use config_intrhook_oneshot instead of config_intrhook_establish

Suggested by: ian
MFC after: 1 month
X-MFC-With: 345948

5 years agotwsi: Add interrupt mode
manu [Fri, 5 Apr 2019 14:44:23 +0000 (14:44 +0000)]
twsi: Add interrupt mode

Add the ability to use interrupts for i2c message.
We still use polling for early boot i2c transfer (for PMIC
for example) but as soon as interrupts are available use them.
On Allwinner SoC >A20 is seems that polling mode is broken for some
reason, this is now fixed by using interrupt mode.
For Allwinner also fix the frequency calculation, the one in the code
was for when the APB frequency is at 48Mhz while it is at 24Mhz on most
(all?) Allwinner SoCs. We now support both cases.

While here add more debug info when it's compiled in.

Tested On: A20, H3, A64
MFC after: 1 month

5 years agoRemove another instance of All Rights Reserved.
imp [Fri, 5 Apr 2019 14:27:48 +0000 (14:27 +0000)]
Remove another instance of All Rights Reserved.

Remove the phrase from boilerplate copyright we stick on vers.c when
we can't find the template file. In practice, this won't change a
thing, except for the case of compiling the kernel standalone w/o the
rest of a tree on a system that doesn't have
/usr/share/examples/etc/bsd-copyright installed.

5 years agoAdd mpr, mps, mpt to NOTES file
imp [Fri, 5 Apr 2019 02:54:02 +0000 (02:54 +0000)]
Add mpr, mps, mpt to NOTES file

Add these to all the architectures that these are in the GENERIC
kernel.

5 years agoFix build.
delphij [Fri, 5 Apr 2019 02:37:10 +0000 (02:37 +0000)]
Fix build.

MFC after: 2 weeks
X-MFC-With: r345900

5 years agoImplement checking of `.' and `..' entries of subdirectory.
delphij [Fri, 5 Apr 2019 02:21:16 +0000 (02:21 +0000)]
Implement checking of `.' and `..' entries of subdirectory.

Reviewed by: pfg
Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/b6ee08aadb580341a4d80943741b80de16a88b5d%5E%21/
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19824

5 years agoAdd an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
rmacklem [Thu, 4 Apr 2019 23:40:30 +0000 (23:40 +0000)]
Add an entry to UPDATING for r345895, which affects the use of nfsuserd daemons
built from head sources between July 6, 2017 and Aug. 22, 2018.

5 years agoRestore lfcl when LOSTDIR's chain was corrupted and overwritten
delphij [Thu, 4 Apr 2019 23:34:03 +0000 (23:34 +0000)]
Restore lfcl when LOSTDIR's chain was corrupted and overwritten
with invalid value.

Obtained from: Android https://android.googlesource.com/platform/external/fsck_msdos/+/4d6d6f8a3674ad67f970e2ae908d34f64e4854cf%5E%21/
MFC after: 2 weeks

5 years agosort(1): randomcoll: Skip the memory allocation entirely
cem [Thu, 4 Apr 2019 23:32:27 +0000 (23:32 +0000)]
sort(1): randomcoll: Skip the memory allocation entirely

There's no reason to order based on strcmp of ASCII digests instead of
memcmp of the raw digests.

While here, remove collision fallback.  If you collide two MD5s, they're
probably the same string anyway.  If robustness against MD5 collisions is
desired, maybe we shouldn't use MD5.

None of the behavior of sort -R is specified by POSIX, so we're free to
implement this however we like.  E.g., using a 128-bit counter and block cipher
to generate unique indices for each line of input.

PR: 230792 (2/many)
Relnotes: This will change the sort order for a given dataset with a
given seed.  Other similarly breaking changes are planned.
Sponsored by: Dell EMC Isilon

5 years agoRevert r320698, since the related userland changes were reverted by r338192.
rmacklem [Thu, 4 Apr 2019 23:30:27 +0000 (23:30 +0000)]
Revert r320698, since the related userland changes were reverted by r338192.

r338192 reverted the changes to nfsuserd so that it could use an AF_LOCAL
socket, since it resulted in a vnode locking panic().
Post r338192 nfsuserd daemons use the old AF_INET socket for upcalls and
do not use these kernel changes.
I left them in for a while, so that nfsuserd daemons built from head sources
between r320757 (Jul. 6, 2017) and r338192 (Aug. 22, 2018) would need them
by default.
This only affects head, since the changes were never MFC'd.
I will add an UPDATING entry, since an nfsuserd daemon built from head
sources between r320757 and r338192 will not run unless the "-use-udpsock"
option is specified. (This command line option is only in the affected
revisions of the nfsuserd daemon.)

I suspect few will be affected by this, since most who run systems built
from head sources (not stable or releases) will have rebuilt their nfsuserd
daemon from sources post r338192 (Aug. 22, 2018)

This is being reverted in preparation for an update to include AF_INET6
support to the code.

5 years agoRestore the ability of checking and fixing next free
delphij [Thu, 4 Apr 2019 23:16:36 +0000 (23:16 +0000)]
Restore the ability of checking and fixing next free
cluster in FSINFO that was lost in r203872.

Obtained from: NetBSD
MFC after: 2 weeks

5 years agoAdd requiered programs (cc and c++) for some lib/atf regression tests
olivier [Thu, 4 Apr 2019 20:34:17 +0000 (20:34 +0000)]
Add requiered programs (cc and c++) for some lib/atf regression tests

PR: 236889
Reviewed by: ngie
Approved by: emaste (on IRC)
MFC after: 1 month
Sponsored by: Netflix

5 years agosort(1): randomcoll: Don't sort on ENOMEM
cem [Thu, 4 Apr 2019 20:27:13 +0000 (20:27 +0000)]
sort(1): randomcoll: Don't sort on ENOMEM

PR: 230792 (1/many)
Sponsored by: Dell EMC Isilon

5 years agoif_muge: use NULL not 0 for DRIVER_MODULE pointer args
emaste [Thu, 4 Apr 2019 19:59:31 +0000 (19:59 +0000)]
if_muge: use NULL not 0 for DRIVER_MODULE pointer args

Sponsored by: The FreeBSD Foundation

5 years agoUse IN_foo() macros from sys/netinet/in.h inplace of handcrafted code
rgrimes [Thu, 4 Apr 2019 19:01:13 +0000 (19:01 +0000)]
Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code

There are a few places that use hand crafted versions of the macros
from sys/netinet/in.h making it difficult to actually alter the
values in use by these macros.  Correct that by replacing handcrafted
code with proper macro usage.

Reviewed by: karels, kristof
Approved by: bde (mentor)
MFC after: 3 weeks
Sponsored by: John Gilmore
Differential Revision: https://reviews.freebsd.org/D19317

5 years agoRewrite intro(4) man page.
ygy [Thu, 4 Apr 2019 18:52:03 +0000 (18:52 +0000)]
Rewrite intro(4) man page.

- Remove issues that no longer apply thanks to devfs
- Add language pointing out devfs's role and referencing its config
- Add a "historical notes" section and move discussion of block vs character devs to it, including pointing out the removal of block devs
- Modernize some examples

MFC after: 1 week
PR: 236970
Submitted by: andrew@tao173.riddles.org.uk
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D19799

5 years agostrings: capsicumize it
oshogbo [Thu, 4 Apr 2019 16:32:27 +0000 (16:32 +0000)]
strings: capsicumize it

Reviewed by: cem
Discussed with: emaste
Differential Revision: https://reviews.freebsd.org/D18038

5 years agoAdd cap_fileargs.h to -legacy if needed.
oshogbo [Thu, 4 Apr 2019 04:14:20 +0000 (04:14 +0000)]
Add cap_fileargs.h to -legacy if needed.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D19685

5 years agoFix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.
rmacklem [Thu, 4 Apr 2019 01:23:06 +0000 (01:23 +0000)]
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

Submitted by: peter@ifm.liu.se
MFC after: 2 weeks

5 years agoReplace read_random(9) with more appropriate arc4rand(9) KPIs
cem [Thu, 4 Apr 2019 01:02:50 +0000 (01:02 +0000)]
Replace read_random(9) with more appropriate arc4rand(9) KPIs

Reviewed by: ae, delphij
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19760

5 years agoImplement tests for online expansion:
pjd [Thu, 4 Apr 2019 00:05:36 +0000 (00:05 +0000)]
Implement tests for online expansion:
- init, init -R
- onetime, onetime -R
- 512 and 4k sectors
- encryption only
- encryption and authentication
- configure -r/-R for detached providers
- configure -r/-R for attached providers
- all keys allocated (10, 20 and 30MB provider sizes)
- keys allocated on demand (10, 20 and 30PB provider sizes)
- reading and writing to provider after expansion (10-30MB only)
- checking if metadata in old location is cleared.

Obtained from: Fudo Security

5 years agoUpdate configure tests after addition of the online expansion.
pjd [Wed, 3 Apr 2019 23:58:58 +0000 (23:58 +0000)]
Update configure tests after addition of the online expansion.

Obtained from: Fudo Security