]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoIntroduce the daemonfd function.
oshogbo [Sat, 23 Dec 2017 18:07:43 +0000 (18:07 +0000)]
Introduce the daemonfd function.

The daemonfd function is equivalent to the daemon(3) function expect that
arguments are descriptors. For example dhclient(8) which is sandboxed is
unable to open /dev/null to close stdio instead it's allows to fail
daemon(3) function to close the descriptors and then do it explicit in code.
Instead of such hacks we can use now daemonfd.

This API can be also helpful to migrate system to platforms like CheriBSD.

Reviewed by: brooks@, bcr@, jilles@ (earlier version)
Differential Revision: https://reviews.freebsd.org/D13433

6 years agoReverse the check to allocate the buffer if cached pointer is NULL.
kan [Sat, 23 Dec 2017 17:55:19 +0000 (17:55 +0000)]
Reverse the check to allocate the buffer if cached pointer is NULL.

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

6 years agoRemove dead store to local variable.
kan [Sat, 23 Dec 2017 16:49:57 +0000 (16:49 +0000)]
Remove dead store to local variable.

6 years agoSilence clang analyzer false positive.
kan [Sat, 23 Dec 2017 16:45:26 +0000 (16:45 +0000)]
Silence clang analyzer false positive.

clang does not know that two lookup calls will return the same
pointer, so it assumes correctly that using the old pointer
after dropping the reference to it is a bit risky.

6 years agoDo not pass NULL pointer to copyout in if_clone_list.
kan [Sat, 23 Dec 2017 16:45:24 +0000 (16:45 +0000)]
Do not pass NULL pointer to copyout in if_clone_list.

Sometimes caller is only interested in how many clones
are there and NULL pointer is passed for the destination
buffer. Do not pass it to copyout then.

6 years agoRemove dead initialization of the inode pointer.
kan [Sat, 23 Dec 2017 16:24:02 +0000 (16:24 +0000)]
Remove dead initialization of the inode pointer.

The pointer gets initialized again later in the code. This also
improves code style(9).

6 years agoRemove some trailing whitespace.
kan [Sat, 23 Dec 2017 16:24:00 +0000 (16:24 +0000)]
Remove some trailing whitespace.

Reviewed by: glebius, ae
Differential Revision: https://reviews.freebsd.org/D10386

6 years agoDo not double free the memory in if_clone.
kan [Sat, 23 Dec 2017 16:23:58 +0000 (16:23 +0000)]
Do not double free the memory in if_clone.

if_clone_attach function will drop the reference on failure  which will
free the if_clone structure. No need to do it second time.

Reviewed by: glebius, ae
Differential Revision: https://reviews.freebsd.org/D10386

6 years agoMove syscon into extres framework
kevans [Sat, 23 Dec 2017 14:30:44 +0000 (14:30 +0000)]
Move syscon into extres framework

This should help reduce confusion between syscon/syscons a little bit.
syscon is a resource generally modeled by FDT platforms, and not to be
confused with syscons.

6 years agosyscon: Introduce kobj and split out fdt bits
kevans [Sat, 23 Dec 2017 14:27:42 +0000 (14:27 +0000)]
syscon: Introduce kobj and split out fdt bits

Allow more flexibility by kobj'ifying syscon and splitting out fdt specific
bits in preparation of a move to the extres framework.

The generic fdt driver has been moved to syscon_generic.c and the fdt
requirement has been removed from the syscon interface, as is common to the
extres framework.

Reviewed by: strejda
Differential Revision: https://reviews.freebsd.org/D13521

6 years agoFix cut-and-paste error s/pccard/isa/
imp [Sat, 23 Dec 2017 07:02:45 +0000 (07:02 +0000)]
Fix cut-and-paste error s/pccard/isa/

6 years agoCreate a new ISA_PNP_INFO macro. Use this macro every where we have
imp [Sat, 23 Dec 2017 06:49:27 +0000 (06:49 +0000)]
Create a new ISA_PNP_INFO macro. Use this macro every where we have
ISA PNP card support (replace by hand version in if_ed). Move module
declarations to the end of some files. Fix PCCARD_PNP_INFO to use
nitems(). Remove some stale comments about pc98, turns out the comment
was simply wrong.

6 years agoExpand cryptic comment with inforation I've learned in the mean time
imp [Sat, 23 Dec 2017 06:11:19 +0000 (06:11 +0000)]
Expand cryptic comment with inforation I've learned in the mean time
about CIS3/CIS4, including studies I've done on my large collection of
PC Cards bought off e-bay over the years since the original entry as
well as conversations I've had at conferences.

6 years agoThese drivers have a sentinel at the end of the device list. Exclude
imp [Sat, 23 Dec 2017 05:32:20 +0000 (05:32 +0000)]
These drivers have a sentinel at the end of the device list. Exclude
it.

6 years agofopen.1: document truncation
eadler [Sat, 23 Dec 2017 05:13:39 +0000 (05:13 +0000)]
fopen.1: document truncation

This documentation truncation similar to POSIX and glibc.

PR: 202545
Reported by: intron@intron.ac

6 years agoThe device tables end with a sentinel in iflib. Don't include the
imp [Sat, 23 Dec 2017 04:50:52 +0000 (04:50 +0000)]
The device tables end with a sentinel in iflib. Don't include the
sentinel in the output.

6 years agoRemove mips MD atomic_load_64 and atomic_store_64.
kib [Fri, 22 Dec 2017 23:27:03 +0000 (23:27 +0000)]
Remove mips MD atomic_load_64 and atomic_store_64.

The only users of the functions were db_read_bytes() and
db_write_bytes() ddb(4) interfaces.  Replace the calls with direct
reads and writes, which are automatically atomic on 64bits and n32.

Note that removed assembler implementation for mips32 is not atomic
anyway.

Reviewed by: jhb
Discussed with: imp
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13586

6 years agoDrop the NetBSD rcs tag introduced in r326868.
sevan [Fri, 22 Dec 2017 21:54:39 +0000 (21:54 +0000)]
Drop the NetBSD rcs tag introduced in r326868.

Approved by:    bcr (mentor)
Differential Revision:  https://reviews.freebsd.org/D13511

6 years agoFix typos from last commit, these should have been #.
imp [Fri, 22 Dec 2017 20:48:49 +0000 (20:48 +0000)]
Fix typos from last commit, these should have been #.

6 years agoAdd AHCI/XHCI device IDs found on AMD Ryzen+B350 system.
mav [Fri, 22 Dec 2017 20:44:21 +0000 (20:44 +0000)]
Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system.

MFC after: 2 weeks

6 years agocxgbe(4): Do not forward interrupts to queues with freelists. This
np [Fri, 22 Dec 2017 19:10:19 +0000 (19:10 +0000)]
cxgbe(4): Do not forward interrupts to queues with freelists.  This
leaves the firmware event queue (fwq) as the only queue that can take
interrupts for others.

This simplifies cfg_itype_and_nqueues and queue allocation in the driver
at the cost of a little (never?) used configuration.  It also allows
service_iq to be split into two specialized variants in the future.

MFC after: 2 months
Sponsored by: Chelsio Communications

6 years agoUse '#' rather than some made up name for fields we want to ignore.
imp [Fri, 22 Dec 2017 17:53:27 +0000 (17:53 +0000)]
Use '#' rather than some made up name for fields we want to ignore.

6 years agoUpdate HISTORY section for the atomic(9) page.
kib [Fri, 22 Dec 2017 17:52:38 +0000 (17:52 +0000)]
Update HISTORY section for the atomic(9) page.

In collaboration with: alc
Sponsored by: The FreeBSD Foundation (kib)
MFC after: 1 week

6 years agoSPDX: Reverse License ID tags from the lmc driver.
pfg [Fri, 22 Dec 2017 17:15:02 +0000 (17:15 +0000)]
SPDX: Reverse License ID tags from the lmc driver.

While the BSD-2-Clause license is there, the GPLv2 is also present.
I am unsure of the implications of having both licenses as they are here.

I'll just leave it untagged and open for interpretation.

6 years agoNeed to NULL terminate this list. It worked before by accidental data
imp [Fri, 22 Dec 2017 17:13:54 +0000 (17:13 +0000)]
Need to NULL terminate this list. It worked before by accidental data
in the module following it that terminated the search.

6 years agoPC Card PNP tables are terminated by a NULL sentinel. This shouldn't
imp [Fri, 22 Dec 2017 16:59:50 +0000 (16:59 +0000)]
PC Card PNP tables are terminated by a NULL sentinel. This shouldn't
be recorded in the linker hints, so subtract one to omit it.

6 years agoAdd soft float abi caching form armv7, it would allow people with old
kevlo [Fri, 22 Dec 2017 01:46:25 +0000 (01:46 +0000)]
Add soft float abi caching form armv7,  it would allow people with old
binaries to run them.

Reviewed by: imp

6 years agoFix mips build after introduction of MD definitions of atomic_load_64
kib [Thu, 21 Dec 2017 23:39:00 +0000 (23:39 +0000)]
Fix mips build after introduction of MD definitions of atomic_load_64
and atomic_store_64.

The MD definitions are provided for LP64 only, while mips also uses
them for 32bit and n32.  Only define mips variants for 32bit and n32
and change the syntax to match common definitions.

Note that this commit does not fix 32bit asm implementation to follow
new KBI, this will be fixed later.  The functions are only used for 8
byte ddb accesses so the known bug does not prevent normal kernel
operations.

Sponsored by: The FreeBSD Foundation

6 years agoFix build for LP64 arches with gcc.
kib [Thu, 21 Dec 2017 23:08:10 +0000 (23:08 +0000)]
Fix build for LP64 arches with gcc.

gcc complaints that the comparision is always false due to the value
range, and the cast does not prevent the analysis.  Split the LP64
vs. ILP32 clamping as a workaround.

Sponsored by: The FreeBSD Foundation

6 years agoFix build for kernels with SCHED_4BSD.
kib [Thu, 21 Dec 2017 23:05:13 +0000 (23:05 +0000)]
Fix build for kernels with SCHED_4BSD.

Sponsored by: The FreeBSD Foundation

6 years agoWhen -v is specified with -p dev, print the same verbose output as
imp [Thu, 21 Dec 2017 19:19:43 +0000 (19:19 +0000)]
When -v is specified with -p dev, print the same verbose output as
when listing the whole tree. The list, however, is from the requested
device to the root (so it backwards from the normal tree).

Sponsored by: Netflix

6 years agoFix markup and bump .Dd.
imp [Thu, 21 Dec 2017 18:58:14 +0000 (18:58 +0000)]
Fix markup and bump .Dd.

6 years agoImplement "-p dev" to print the path to the given device back to the
imp [Thu, 21 Dec 2017 18:51:47 +0000 (18:51 +0000)]
Implement "-p dev" to print the path to the given device back to the
nexus. With redirection, could also be used to test if the device
exists in the device tree.

Sponsored by: Netflix

6 years agoRecognize a pending virtual interrupt while emulating the halt instruction.
tychon [Thu, 21 Dec 2017 18:30:11 +0000 (18:30 +0000)]
Recognize a pending virtual interrupt while emulating the halt instruction.

Reviewed by: grehan, rgrimes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13573

6 years agopatch: further cleanup to git-style diffs.
pfg [Thu, 21 Dec 2017 16:25:33 +0000 (16:25 +0000)]
patch: further cleanup to git-style diffs.

Fix adding and removing files with git-style a/ b/ diffs: only skip
six letters if they actually match "--- a/" and "+++ b/" instead of
laxer checks.

Obtained from: OpenBSD (CVS 1.59)

6 years agopatch: rejname[] is also -r option buffer, and should be PATH_MAX.
pfg [Thu, 21 Dec 2017 16:19:10 +0000 (16:19 +0000)]
patch: rejname[] is also -r option buffer, and should be PATH_MAX.

Obtained from: OpenBSD (CVS 1.64)

6 years agocxgbe(4): Read the MFG diags version from the VPD and make it available
np [Thu, 21 Dec 2017 15:19:43 +0000 (15:19 +0000)]
cxgbe(4):  Read the MFG diags version from the VPD and make it available
in the sysctl MIB.

MFC after: 1 week
Sponsored by: Chelsio Communications

6 years ago[boot/efi] scan all display modes rather than sequential try-fail way
mizhka [Thu, 21 Dec 2017 12:21:35 +0000 (12:21 +0000)]
[boot/efi] scan all display modes rather than sequential try-fail way

This patch allows to scan all display modes in boot1 as loader does.

Before system tried to select optimal display mode by sequential scan of
modes and if error then stop scanning. This way is not good, because
if mode N is not present, mode N+1 may exist.

In loader we use conout->Mode->MaxMode to identify maximum number of modes.
This commit is to use same way in boot1 as in loader.

Reported by: Andrey Pustovetov <andrey.pustovetov@gmail.com>
Reviewed by: tsoome
Differential Revision: https://reviews.freebsd.org/D13541

6 years agoMake truss work for CloudABI executables on i386.
ed [Thu, 21 Dec 2017 09:21:40 +0000 (09:21 +0000)]
Make truss work for CloudABI executables on i386.

The system call convention is different from i386 binaries running on
FreeBSD/amd64, but this is not noticeable by executables. On
FreeBSD/amd64, the vDSO already does padding of arguments and return
values to 64-bit values. On i386, it does not, meaning that system call
return values are simply stored in registers.

6 years agoUse resume_cpus() instead of restart_cpus() to resume from ACPI suspension.
bde [Thu, 21 Dec 2017 09:17:48 +0000 (09:17 +0000)]
Use resume_cpus() instead of restart_cpus() to resume from ACPI suspension.
restart_cpus() worked well enough by accident.  Before this set of fixes,
resume_cpus() used the same cpuset (started_cpus, meaning CPUs directed to
restart) as restart_cpus().  resume_cpus() waited for the wrong cpuset
(stopped_cpus) to become empty, but since mixtures of stopped and suspended
CPUs are not close to working, stopped_cpus must be empty when resuming so
the wait is null -- restart_cpus just allows the other CPUs to restart and
returns without waiting.

Fix resume_cpus() to wait on a non-wrong cpuset for the ACPI case, and
add further kludges to try to keep it working for the XEN case.  It
was only used for XEN.  It waited on suspended_cpus.  This works for
XEN.  However, for ACPI, resuming is a 2-step process.  ACPI has already
woken up the other CPUs and removed them from suspended_cpus.  This
fix records the move by putting them in a new cpuset resuming_cpus.
Waiting on suspended_cpus would give the same null wait as waiting on
stopped_cpus.  Wait on resuming_cpus instead.

Add a cpuset toresume_cpus to map the CPUs being told to resume to keep
this separate from the cpuset started_cpus for mapping the CPUs being told
to restart.  Mixtures of stopped and suspended/resuming CPUs are still far
from working.  Describe new and some old cpusets in comments.

Add further kludges to cpususpend_handler() to try to avoid breaking it
for XEN.  XEN doesn't use resumectx(), so it doesn't use the second
return path for savectx(), and it goes from the suspended state directly
to the restarted state, while ACPI resume goes through the resuming state.
Enter the resuming state early for all cases so that resume_cpus can test
for being in this state and not have to worry about the intermediate
!suspended state for ACPI only.

Reviewed by: kib

6 years agoProvide a nda man page. Add cross referneces. Bump dates.
imp [Thu, 21 Dec 2017 04:23:00 +0000 (04:23 +0000)]
Provide a nda man page. Add cross referneces. Bump dates.
Also, CAM is a storage subsystem, not a SCSI/ATA one these days.

Sponsored by: Netflix

6 years agoBump number that's an insane number of devices from 1,000 to 10,000. I
imp [Thu, 21 Dec 2017 04:21:59 +0000 (04:21 +0000)]
Bump number that's an insane number of devices from 1,000 to 10,000. I
have access to machines that are pushing 400 devices. When 1,000 was
selected, it was rare to get even 40 or 50 devices. Bump the limit by
10x to keep up with the times.

Sponsored by: Netflix

6 years agoRemove MD atomic_load_{32,64,int,long,ptr}(9) obsolete since the addition
marius [Thu, 21 Dec 2017 01:27:32 +0000 (01:27 +0000)]
Remove MD atomic_load_{32,64,int,long,ptr}(9) obsolete since the addition
of (conflicting) MI ones in r326971.

6 years agoDon't call tcp_lro_rx() unless hardware verified TCP/UDP csum
shurd [Thu, 21 Dec 2017 01:22:36 +0000 (01:22 +0000)]
Don't call tcp_lro_rx() unless hardware verified TCP/UDP csum

It seems that tcp_lro_rx() doesn't verify TCP checksums, so
if there are bad checksums in the packets caused by invalid data, the
invalid data will pass through without errors.

This was noticed with the igb driver and a specific internet host:
fetch http://www.mpfr.org/mpfr-current/mpfr-3.1.6.tar.xz -o test.bin && sha256 test.bin
Would result in a different value sometimes.

This ends up making LRO require RXCSUM to be enabled, and RXCSUM to
support TCP and UDP checksums.

PR: 224346
Reported by: gjb
Reviewed by: sbruno
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D13561

6 years agoixgbe(4): Fix build error on i386.
erj [Thu, 21 Dec 2017 00:35:14 +0000 (00:35 +0000)]
ixgbe(4): Fix build error on i386.

Reported by: markj

6 years agoIf a temporary mapping is made to support EARLY_PRINTF, undo that mapping
ian [Wed, 20 Dec 2017 22:19:11 +0000 (22:19 +0000)]
If a temporary mapping is made to support EARLY_PRINTF, undo that mapping
after cninit() runs, otherwise we leave a bogus device-memory mapping in
userspace VA in the kernel pmap forever.

Pointed out by: cognet

6 years agoAllow pmap_kremove() to remove 1MB section mappings as well as 4K pages.
ian [Wed, 20 Dec 2017 22:17:27 +0000 (22:17 +0000)]
Allow pmap_kremove() to remove 1MB section mappings as well as 4K pages.
This will allow it to undo temporary device mappings such as those made
with pmap_preboot_map_attr().

Reviewed by: cognet

6 years agoRestore the ability to use EARLY_PRINTF support during most of initarm().
ian [Wed, 20 Dec 2017 20:46:12 +0000 (20:46 +0000)]
Restore the ability to use EARLY_PRINTF support during most of initarm().

The real kernel page tables are set up much earlier in initarm() now than
they were when early printf support was first added, and they end up undoing
the mapping made in locore.S for early printf support.  This re-adds the
mapping after switching to the new/real kernel page tables, making early
printf work again right after switching to them.

6 years agoRemove arm-specific implementations of atomic_load/store_xxx() now that
ian [Wed, 20 Dec 2017 20:41:51 +0000 (20:41 +0000)]
Remove arm-specific implementations of atomic_load/store_xxx() now that
they are provided by sys/atomic_common.h.

6 years agoRevert r327005 - SPDX tags for license similar to BSD-2-Clause.
pfg [Wed, 20 Dec 2017 20:25:28 +0000 (20:25 +0000)]
Revert r327005 - SPDX tags for license similar to BSD-2-Clause.

After consultation with SPDX experts and their matching guidelines[1],
the licensing doesn't exactly match the BSD-2-Clause. It yet remains to be
determined if they are equivalent or if there is a recognized license that
matches but it is safer to just revert the tags.

Let this also be a reminder that on FreeBSD, SPDX tags are only advisory
and have no legal value (but IANAL).

Pointyhat to: pfg
Thanks to: Rodney Grimes, Gary O'Neall

[1] https://spdx.org/spdx-license-list/matching-guidelines

6 years agoAdd nvme wiring example
imp [Wed, 20 Dec 2017 19:14:20 +0000 (19:14 +0000)]
Add nvme wiring example
Add NVMe and MMC/SD card support info.

Sponsored by: Netflix

6 years agoSimplify the code a bit.
imp [Wed, 20 Dec 2017 19:14:16 +0000 (19:14 +0000)]
Simplify the code a bit.

Replace clumsy for(;;) { if (foo) break; ...} with simpler
while (!foo) { ... }.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13546

6 years agoDocument new pci device hints wiring.
imp [Wed, 20 Dec 2017 19:14:11 +0000 (19:14 +0000)]
Document new pci device hints wiring.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13546

6 years agoAdd device location wiring to the pci bus.
imp [Wed, 20 Dec 2017 19:14:05 +0000 (19:14 +0000)]
Add device location wiring to the pci bus.

This allows one to specify, for example, that if there's an igb card
in bus 12, slot 0, function 0, it should be assigned igb5. If there
isn't, or there's one in a different slot, normal numbering rules
apply (hinted units are skipped). Adding 'hint.igb.5.at="pci12:0:0"'
or 'hint.igb.5.at="pci0:12:0:0"' to /boot/device.hints will accomplish
this. The double quotes are important.

The kernel only accepts the strings (in shell notation):
pci$d:$b:$s:$f
and pci$b:$s:$f
where $d is the pci domain, $b is the pci bus number, $s is the slot
number and $f is the function number. A string compare is done with
the current device to avoid another string parser in the kernel. All
numbers are unsigned decimal without leading zeros.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13546

6 years agoReturn domain, bus, slot, and function for the transport settings in
imp [Wed, 20 Dec 2017 19:13:55 +0000 (19:13 +0000)]
Return domain, bus, slot, and function for the transport settings in
PATH_INQ requests for nvme.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13546

6 years agoAdd a new kernel config option, MD_ROOT_READONLY, which forces on the
ian [Wed, 20 Dec 2017 18:23:22 +0000 (18:23 +0000)]
Add a new kernel config option, MD_ROOT_READONLY, which forces on the
MD_READONLY flag for the md device automatically instantiated during
kernel init for an mdroot filesystem.

Note that there is specifically and by design no tunable or sysctl
control over this feature.  Without this option, you already have control
over whether the mdroot fs is writeable using vfs.root.mountfrom.options
from loader(8), the root_rw_mount rcvar, and by using "mount -u[rw] /"
or equivelent on the fly.  This option is being added to provide a way
to make the mdroot fs truly immutable before userland code begins running.

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

6 years agoixgbe(4): Convert driver to use iflib
erj [Wed, 20 Dec 2017 18:15:06 +0000 (18:15 +0000)]
ixgbe(4): Convert driver to use iflib

Initial update to the ixgbe PF and VF drivers to support the iflib interface.

The PF driver version is bumped to 4.0.0, and the VF driver version is bumped to 2.0.0.

Special thanks to sbruno@ for the support in helping make this conversion happen.

Submitted by: Jeb Cramer <cramerj@intel.com>, Krzysztof Galazka (Chris) <krzysztof.galazka@intel.com>, Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Reviewed by: sbruno@, shurd@, #IntelNetworking
Tested by: Jeffrey Pieper <jeffrey.e.pieper@intel.com>, Sergey Kozlov <kozlov.sergey.404@gmail.com>
Sponsored by: Limelight Networks, Intel Corporation
Differential Revision: https://reviews.freebsd.org/D11727

6 years agoDon't ignore trailing spaces after numerical IP addresses.
ume [Wed, 20 Dec 2017 17:44:31 +0000 (17:44 +0000)]
Don't ignore trailing spaces after numerical IP addresses.

PR: 224403
Reported by: Michael Kaufmann
Reviewed by: Michael Kaufmann
MFC after: 1 week

6 years agoIncrease default MAXDSIZ to 32G on powerpc64
jhibbits [Wed, 20 Dec 2017 16:49:45 +0000 (16:49 +0000)]
Increase default MAXDSIZ to 32G on powerpc64

Linking LLVM now seems to require more than 1GB data size, so increase the
default to 32G, which matches amd64.

Reviewed by: nwhitehorn

6 years agoFlesh out the reason for the need for tmpfs a little.
imp [Wed, 20 Dec 2017 16:02:11 +0000 (16:02 +0000)]
Flesh out the reason for the need for tmpfs a little.

Sponsored by: Netflix

6 years agoSave others some forehead damange by noting that -r require tmpfs.
brd [Wed, 20 Dec 2017 15:21:29 +0000 (15:21 +0000)]
Save others some forehead damange by noting that -r require tmpfs.

Reviewed by: bapt

6 years agoMake truss(8) work for 32-bit CloudABI executables on ARM64.
ed [Wed, 20 Dec 2017 13:13:10 +0000 (13:13 +0000)]
Make truss(8) work for 32-bit CloudABI executables on ARM64.

This change effectively merges the existing 64-bit support for ARM64
with the 32-on-64-bit support for AMD64.

6 years agoAdd missing `;`
lwhsu [Wed, 20 Dec 2017 06:08:16 +0000 (06:08 +0000)]
Add missing `;`

Approved by: kevlo

6 years agoSupport attaching tx queues to cpus
shurd [Wed, 20 Dec 2017 01:03:34 +0000 (01:03 +0000)]
Support attaching tx queues to cpus

This will attempt to use a different thread/core on the same L2
cache when possible, or use the same cpu as the rx thread when not.
If SMP isn't enabled, don't go looking for cores to use. This is mostly
useful when using shared TX/RX queues.

Reviewed by: sbruno
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D12446

6 years agoDon't return early for non-failure for one of the EMLINK checks.
jhb [Tue, 19 Dec 2017 23:54:44 +0000 (23:54 +0000)]
Don't return early for non-failure for one of the EMLINK checks.

r326987 enabled two #if 0'd-out EMLINK checks in zfs_link_create() for
link overflow.  However, one of the checks (when the vnode adding a link
is a directory such as for mkdir) always returned even if the link did not
overflow.  Change this to only return early if it needs to report an
EMLINK error.

Reported by: db, shurd
Sponsored by: Chelsio Communications

6 years agoReplace one more LINK_MAX with NFS_LINK_MAX missed in r326991.
jhb [Tue, 19 Dec 2017 22:43:39 +0000 (22:43 +0000)]
Replace one more LINK_MAX with NFS_LINK_MAX missed in r326991.

Sponsored by: Chelsio Communications

6 years agoUpdate link count handling in fuse for post-ino64.
jhb [Tue, 19 Dec 2017 22:40:54 +0000 (22:40 +0000)]
Update link count handling in fuse for post-ino64.

Set FUSE_LINK_MAX to UINT32_MAX instead of LINK_MAX to match the maximum
link count possible in the 'nlink' field of 'struct fuse_attr'.

Sponsored by: Chelsio Communications

6 years agoSPDX: These are fundamentally BSD-2-Clause.
pfg [Tue, 19 Dec 2017 22:40:16 +0000 (22:40 +0000)]
SPDX: These are fundamentally BSD-2-Clause.

They just omit the introductory line and numbering.

6 years agoRework pathconf handling for FIFOs.
jhb [Tue, 19 Dec 2017 22:39:05 +0000 (22:39 +0000)]
Rework pathconf handling for FIFOs.

On the one hand, FIFOs should respect other variables not supported by
the fifofs vnode operation (such as _PC_NAME_MAX, _PC_LINK_MAX, etc.).
These values are fs-specific and must come from a fs-specific method.
On the other hand, filesystems that support FIFOs are required to
support _PC_PIPE_BUF on directory vnodes that can contain FIFOs.
Given this latter requirement, once the fs-specific VOP_PATHCONF
method supports _PC_PIPE_BUF for directories, it is also suitable for
FIFOs permitting a single VOP_PATHCONF method to be used for both
FIFOs and non-FIFOs.

To that end, retire all of the FIFO-specific pathconf methods from
filesystems and change FIFO-specific vnode operation switches to use
the existing fs-specific VOP_PATHCONF method.  For fifofs, set it's
VOP_PATHCONF to VOP_PANIC since it should no longer be used.

While here, move _PC_PIPE_BUF handling out of vop_stdpathconf() so that
only filesystems supporting FIFOs will report a value.  In addition,
only report a valid _PC_PIPE_BUF for directories and FIFOs.

Discussed with: bde
Reviewed by: kib (part of a larger patch)
MFC after: 1 month
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D12572

6 years agoAdd log messages for unknown and unhandled phy types
shurd [Tue, 19 Dec 2017 22:15:46 +0000 (22:15 +0000)]
Add log messages for unknown and unhandled phy types

Previously, it silently only supported auto, instead, log a message
indicating why only auto is supported.

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Sponsored by: Broadcom Limited
Differential Revision: https://reviews.freebsd.org/D13358

6 years agoOn Link up & down, update media types
shurd [Tue, 19 Dec 2017 22:06:25 +0000 (22:06 +0000)]
On Link up & down, update media types

It's possible to change the SFP module when link is down, which would
change the available media types.  This is part of D13358.

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Sponsored by: Broadcom Limited

6 years agoSupport short HWRM commands
shurd [Tue, 19 Dec 2017 21:07:30 +0000 (21:07 +0000)]
Support short HWRM commands

New Stratus bnxt devices require support for short HWRM commands for VFs
to function.  Enable their use, but only use them if it's both supported
and required... prefer the long HWRM commands when possible.

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Sponsored by: Broadcom Limited
Differential Revision: https://reviews.freebsd.org/D13269?id=36180

6 years agoDon't populate NVRAM sysctls for VFs
shurd [Tue, 19 Dec 2017 20:32:45 +0000 (20:32 +0000)]
Don't populate NVRAM sysctls for VFs

Only the PF allows NVRAM interaction on bnxt devices.

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Sponsored by: Broadcom Limited

6 years agoUpdate tmpfs link count handling for ino64.
jhb [Tue, 19 Dec 2017 20:19:07 +0000 (20:19 +0000)]
Update tmpfs link count handling for ino64.

Add a new TMPFS_LINK_MAX to use in place of LINK_MAX for link overflow
checks and pathconf() reporting.  Rather than storing a full 64-bit
link count, just use a plain int and use INT_MAX as TMPFS_LINK_MAX.

Discussed with: bde
Reviewed by: kib (part of a larger patch)
Sponsored by: Chelsio Communications

6 years agoHonor NANDFS_LINK_MAX for post-ino64.
jhb [Tue, 19 Dec 2017 20:17:07 +0000 (20:17 +0000)]
Honor NANDFS_LINK_MAX for post-ino64.

This uses NANDFS_LINK_MAX instead of LINK_MAX for link overflow checks
and the value reported by pathconf() / fpathconf().

Sponsored by: Chelsio Communications

6 years agoReport INT_MAX for LINK_MAX for devfs' VOP_PATHCONF().
jhb [Tue, 19 Dec 2017 20:07:57 +0000 (20:07 +0000)]
Report INT_MAX for LINK_MAX for devfs' VOP_PATHCONF().

devfs uses int's for link counts internally and already reports the the
full link count via stat() post ino64.

Sponsored by: Chelsio Communications

6 years agoUse FUSE_LINK_MAX for LINK_MAX in fuse' VOP_PATHCONF().
jhb [Tue, 19 Dec 2017 19:57:55 +0000 (19:57 +0000)]
Use FUSE_LINK_MAX for LINK_MAX in fuse' VOP_PATHCONF().

Should have included this in r326993.

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoHandle _PC_FILESIZEBITS and _PC_SYMLINK_MAX for devfs' VOP_PATHCONF().
jhb [Tue, 19 Dec 2017 19:53:34 +0000 (19:53 +0000)]
Handle _PC_FILESIZEBITS and _PC_SYMLINK_MAX for devfs' VOP_PATHCONF().

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoMove NAME_MAX, LINK_MAX, and CHOWN_RESTRICTED out of vop_stdpathconf().
jhb [Tue, 19 Dec 2017 19:51:36 +0000 (19:51 +0000)]
Move NAME_MAX, LINK_MAX, and CHOWN_RESTRICTED out of vop_stdpathconf().

Having all filesystems fall through to default values isn't always correct
and these values can vary for different filesystem implementations.  Most
of these changes just use the existing default values with a few exceptions:
- Don't report CHOWN_RESTRICTED for ZFS since it doesn't do the exact
  permissions check this claims for chown().
- Use NANDFS_NAME_LEN for NAME_MAX for nandfs.
- Don't report a LINK_MAX of 0 on smbfs.  Now fail with EINVAL to
  indicate hard links aren't supported.

Requested by: bde (though perhaps not this exact implementation)
Reviewed by: kib (earlier version)
MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoembed_mfs: support embedding mfs into loader
emaste [Tue, 19 Dec 2017 19:44:06 +0000 (19:44 +0000)]
embed_mfs: support embedding mfs into loader

The script originally supported embedding an mfs into ELF files or any
other type of file, because it searched for magic strings to mark the
beginning and end of the embeddable section. It was later modified to
read the section offset and length via readelf, which made it work for
ELF only. Restore the ability to update arbitrary file types by using
the readelf technique for ELF, and the magic string technique for all
others (including PE/COFF files like loader.efi).

Submitted by: Zakary Nafziger <worldofzak@gmail.com>
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D12746

6 years agoUpdate NFS to handle larger link counts post ino64.
jhb [Tue, 19 Dec 2017 19:18:48 +0000 (19:18 +0000)]
Update NFS to handle larger link counts post ino64.

- Define a NFS_LINK_MAX as UINT32_MAX to match the wire protocol.
- Use NFS_LINK_MAX instead of LINK_MAX as the fallback value reported
  for a PATHCONF RPC by the NFS server.
- Use NFS_LINK_MAX instead of LINK_MAX as the default value reported
  by the NFS client pathconf() if not overridden by the NFS server.
- When reading the link count out of an RPC reply, read the full 32
  bits instead of the lower 16 bits.

Reviewed by: rmacklem (earlier version)
Sponsored by: Chelsio Communications

6 years agoHandle _PC_FILESIZEBITS and _PC_NO_TRUNC for smbfs' VOP_PATHCONF().
jhb [Tue, 19 Dec 2017 19:14:01 +0000 (19:14 +0000)]
Handle _PC_FILESIZEBITS and _PC_NO_TRUNC for smbfs' VOP_PATHCONF().

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoSupport _PC_FILESIZEBITS in msdosfs' VOP_PATHCONF().
jhb [Tue, 19 Dec 2017 19:10:00 +0000 (19:10 +0000)]
Support _PC_FILESIZEBITS in msdosfs' VOP_PATHCONF().

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoAdd a custom VOP_PATHCONF method for fuse.
jhb [Tue, 19 Dec 2017 19:09:06 +0000 (19:09 +0000)]
Add a custom VOP_PATHCONF method for fuse.

This method handles _PC_FILESIZEBITS, _PC_SYMLINK_MAX, and _PC_NO_TRUNC.
For other values it defers to vop_stdpathconf().

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoAdjust ZFS' link count handling for ino64.
jhb [Tue, 19 Dec 2017 19:07:24 +0000 (19:07 +0000)]
Adjust ZFS' link count handling for ino64.

- Define a ZFS_LINK_MAX as the ZFS version of LINK_MAX which is set to
  UINT64_MAX to match the on-disk format.
- Enable the currently #if 0'd code to check for link overflows and
  return EMLINK.
- Don't clamp the link count reported in stat() to LINK_MAX as that is
  still the 16-bit limit, but report the full link counts.  Also,
  avoid possibly overflowing the reported link count to 0 when adjusting
  the link count to account for ".snapshot".
- Update the LINK_MAX reported by pathconf() to report ZFS_LINK_MAX
  rather than LINK_MAX (but clamped to LONG_MAX for 32-bit systems).

Reviewed by: avg (earlier version)
Sponsored by: Chelsio Communications

6 years agoAdd a custom VOP_PATHCONF method for fdescfs.
jhb [Tue, 19 Dec 2017 18:20:38 +0000 (18:20 +0000)]
Add a custom VOP_PATHCONF method for fdescfs.

The method handles NAME_MAX and LINK_MAX explicitly.  For all other
pathconf variables, the method passes the request down to the underlying
file descriptor.  This requires splitting a kern_fpathconf() syscallsubr
routine out of sys_fpathconf().  Also, to avoid lock order reversals with
vnode locks, the fdescfs vnode is unlocked around the call to
kern_fpathconf(), but with the usecount of the vnode bumped.

MFC after: 1 month
Sponsored by: Chelsio Communications

6 years agoAdd byte swapping in bnxt_cfg_async_cr() request
shurd [Tue, 19 Dec 2017 18:12:18 +0000 (18:12 +0000)]
Add byte swapping in bnxt_cfg_async_cr() request

The firmware is always in little endian, use htole*() for all request fields
larger than one byte.

Submitted by: Bhargava Chenna Marreddy <bhargava.marreddy@broadcom.com>
Sponsored by: Broadcom Limited

6 years agoUpdate Matthew Macy contact info
shurd [Tue, 19 Dec 2017 17:59:00 +0000 (17:59 +0000)]
Update Matthew Macy contact info

Email address has changed, uses consistent name (Matthew, not Matt)

Reported by: Matthew Macy <mmacy@mattmacy.io>
Differential Revision: https://reviews.freebsd.org/D13537

6 years agoAvoid using bioq_* in gmirror.
markj [Tue, 19 Dec 2017 17:13:04 +0000 (17:13 +0000)]
Avoid using bioq_* in gmirror.

gmirror does not perform any sorting of I/O requests, so the bioq API
doesn't provide any advantages over plain TAILQs. The API also does not
provide operations needed by an upcoming change.

No functional change intended. The diff shrinks the geom_mirror.ko
text and the gmirror softc slightly.

Tested by: pho (part of a larger patch)
MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoDocument the semantics of atomic_thread_fence operations.
alc [Tue, 19 Dec 2017 17:07:50 +0000 (17:07 +0000)]
Document the semantics of atomic_thread_fence operations.

Add atomic_load_<type> and atomic_store_<type>, and explain why they
exist.

Define the synchronizes-with relationship and its effects.

Reorder and revise some of the existing text.  For example, more
precisely describe when ordinary accesses are atomic.

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

6 years agoThe highest-order bit of the bootloader cookie is 1, with the result that
nwhitehorn [Tue, 19 Dec 2017 16:45:40 +0000 (16:45 +0000)]
The highest-order bit of the bootloader cookie is 1, with the result that
the 32-bit cookie can be sign-extended on its way out of the loader and
through Open Firmware. If sign-extended, the in-kernel check of its value
would fail on 64-bit systems, resulting in a mountroot prompt. Solve this
by telling the kernel to ignore the high-order bits.

PR: kern/224437
Submitted by: Gustavo Romero

6 years agoMake __startkernel line up with KERNBASE, so that the math to compute the
nwhitehorn [Tue, 19 Dec 2017 15:50:46 +0000 (15:50 +0000)]
Make __startkernel line up with KERNBASE, so that the math to compute the
applied relocation offset in link_elf.c works as intended. We may want to
revisit how that works in future, for example by having elf_reloc_self()
actually store the numbers it is using rather than computing them later,
but this fixes symbol lookup after r326203.

Reported by: andreast@
Pointy hat to: me

6 years agomlx5en: Avoid SFENCe on x86
kib [Tue, 19 Dec 2017 14:11:41 +0000 (14:11 +0000)]
mlx5en: Avoid SFENCe on x86

The IA32 memory model guarantees that all writes are seen in the program
order.  Also, any access to the uncacheable memory flushes the store
buffers.  As the consequence, SFENCE instruction is (almost) never needed,
in particular, it is not needed to ensure the correct order of updates as
seen by a PCIe device.

Use atomic_thread_fence_rel() instead of wb() to only emit compiler barriers
on x86 there.  Other architectures get the right barrier instruction as
well.

Reviewed by: hselasky
Sponsored by: Mellanox Technologies
MFC after: 1 week

6 years agoPerform all accesses to uma_reclaim_needed using atomic(9) KPI.
kib [Tue, 19 Dec 2017 10:06:55 +0000 (10:06 +0000)]
Perform all accesses to uma_reclaim_needed using atomic(9) KPI.

Reviewed by: alc, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13534

6 years agoUse atomic_load(9) to read ppsinfo sequence numbers.
kib [Tue, 19 Dec 2017 10:05:45 +0000 (10:05 +0000)]
Use atomic_load(9) to read ppsinfo sequence numbers.

In this case volatile qualifiers enusre that a compiler does not
optimize the accesses out.

Reviewed by: alc, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13534

6 years agoAdd atomic_load(9) and atomic_store(9) operations.
kib [Tue, 19 Dec 2017 09:59:20 +0000 (09:59 +0000)]
Add atomic_load(9) and atomic_store(9) operations.

They provide relaxed-ordered atomic access semantic.  Due to the
FreeBSD memory model, the operations are syntaxical wrappers around
the volatile accesses.  The volatile qualifier is used to ensure that
the access not optimized out and in turn depends on the volatile
semantic as implemented by supported compilers.

The motivation for adding the operation is to help people coming from
other systems or knowing the C11/C++ standards where atomics have
special type and require use of the special access operations.  It is
still the case that FreeBSD requires plain load and stores of aligned
integer types to be atomic.

Suggested by: jhb
Reviewed by: alc, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13534

6 years agoWhen doing a dump, the scheduler is normally not running, so this
imp [Tue, 19 Dec 2017 04:13:22 +0000 (04:13 +0000)]
When doing a dump, the scheduler is normally not running, so this
changed worked to capture dumps for me. However, the test for
SCHEDULER_STOPPED() isn't right. We can also call the dump routine
from ddb, in which case the scheduler is still running. This leads to
an assertion panic that we're sleeping when we shouldn't. Instead, use
the proper test for dumping or not. This brings us in line with other
places that do special things while we're doing polled I/O like this.

Noticed by: pho@
Differential Revision: https://reviews.freebsd.org/D13531

6 years agoNo need to use relative paths like this here.
imp [Tue, 19 Dec 2017 04:06:07 +0000 (04:06 +0000)]
No need to use relative paths like this here.

Sponsored by: Netflix

6 years agoHoist btx include stuff to i386/Makefile.inc
imp [Tue, 19 Dec 2017 04:06:02 +0000 (04:06 +0000)]
Hoist btx include stuff to i386/Makefile.inc

Sponsored by: Netflix

6 years agoInteract is always called with NULL. Simplify code a little by
imp [Tue, 19 Dec 2017 04:05:55 +0000 (04:05 +0000)]
Interact is always called with NULL. Simplify code a little by
removing this argument, and expanding when rc is NULL. This
effectively completes the back out of custom scripts for tftp booted
loaders from r269153 that was started in r292344 with the new path
tricks that obsoleted it.

Submitted by: Netflix