freebsd.git
5 years agotop(1): Convert process listing to sbuf too
eadler [Sat, 23 Jun 2018 22:45:20 +0000 (22:45 +0000)]
top(1): Convert process listing to sbuf too

This also fixes -mio with 'T' set (thread-id instead of process-id).

This can go further by removing the existing sprintf, and using sbuf
directly. This will be done in a followup commit.

5 years agotop(1): Use basename instead of a homegrown alternative
eadler [Sat, 23 Jun 2018 22:45:18 +0000 (22:45 +0000)]
top(1): Use basename instead of a homegrown alternative

5 years agoDocument libcasper_service.
oshogbo [Sat, 23 Jun 2018 20:12:30 +0000 (20:12 +0000)]
Document libcasper_service.

Reviewed by: bcr@
Differential Revision: https://reviews.freebsd.org/D15766

5 years agoDocument multi variants of *prop_alloc functions
gonzo [Sat, 23 Jun 2018 20:05:07 +0000 (20:05 +0000)]
Document multi variants of *prop_alloc functions

Add documentation and symlinks for OF_getprop_alloc_multi
and OF_getencprop_alloc_multi functions.

Also while here fix copy-pasted .Dt value and add one more
failure condition for OF_getencprop_alloc.

5 years agoBump .Dd value after r335585
gonzo [Sat, 23 Jun 2018 19:30:29 +0000 (19:30 +0000)]
Bump .Dd value after r335585

5 years agoFix invalid OF_getencprop_alloc usage in fdt_pinctrl(9)
gonzo [Sat, 23 Jun 2018 19:01:05 +0000 (19:01 +0000)]
Fix invalid OF_getencprop_alloc usage in fdt_pinctrl(9)

r332341 introduced OF_getencprop_alloc_multi that should be used
instead of OF_getencprop_alloc to get multi-cell properties.
Fix example to reflect this change.

5 years agoaesni(4): Fix {de,en}crypt operations that allocated a buffer
cem [Sat, 23 Jun 2018 18:20:17 +0000 (18:20 +0000)]
aesni(4): Fix {de,en}crypt operations that allocated a buffer

aesni(4) allocates a contiguous buffer for the data it processes if the
provided input was not already virtually contiguous, and copies the input
there.  It performs encryption or decryption in-place.

r324037 removed the logic that then copied the processed data back to the
user-provided input buffer, breaking {de,enc}crypt for mbuf chains or
iovecs with more than a single descriptor.

PR: 228094 (probably, not confirmed)
Submitted by: Sean Fagan <kithrup AT me.com>
Reported by: Emeric POUPON <emeric.poupon AT stormshield.eu>
X-MFC-With: 324037
Security: could result in plaintext being output by "encrypt"
operation

5 years agoaesni(4): Support CRD_F_KEY_EXPLICIT OCF mode
cem [Sat, 23 Jun 2018 17:24:19 +0000 (17:24 +0000)]
aesni(4): Support CRD_F_KEY_EXPLICIT OCF mode

PR: 227788
Reported by: eadler@

5 years agoaw_mmc: Fix style(9) after r335476
manu [Sat, 23 Jun 2018 15:05:21 +0000 (15:05 +0000)]
aw_mmc: Fix style(9) after r335476

5 years agoallwinner: clkng: Correct mux width and flags
manu [Sat, 23 Jun 2018 15:03:54 +0000 (15:03 +0000)]
allwinner: clkng: Correct mux width and flags

The test for checking if the clock have a mux was inverted and the mask
to calculate the parent index was wrong was wrong too.
It means that upon creation the incorrect parent was resolved as the current
one and upon reparent the switch was never made.

Pointy hat (lots of them): manu

5 years agoRe-count available PV entries after reclaiming a PV chunk.
markj [Sat, 23 Jun 2018 10:41:52 +0000 (10:41 +0000)]
Re-count available PV entries after reclaiming a PV chunk.

The call to reclaim_pv_chunk() in reserve_pv_entries() may free a
PV chunk with free entries belonging to the current pmap.  In this
case we must account for the free entries that were reclaimed, or
reserve_pv_entries() may return without having reserved the requested
number of entries.

Reviewed by: alc, kib
Tested by: pho (previous version)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15911

5 years agoSort uma_zone fields according to 64 byte cache line with adjacent line
jeff [Sat, 23 Jun 2018 08:10:09 +0000 (08:10 +0000)]
Sort uma_zone fields according to 64 byte cache line with adjacent line
prefetch on 64bit architectures.  Prior to this, two lines were needed
for the fast path and each line may fetch an unused adjacent neighbor.
 - Move fields used by the fast path into a single line.
 - Move constants into the adjacent line which is mostly used for
   the spare bucket alloc 'medium path'.
 - Unpad the mtx which is only used by the fast path and place it in
   a line with rarely used data.  This aligns the cachelines better and
   eliminates 128 bytes of wasted space.

This gives a 45% improvement on a will-it-scale test on a 24 core machine.

Reviewed by: mmacy

5 years agoepoch(9): Don't trigger taskq enqueue before the grouptaskqs are setup
mmacy [Sat, 23 Jun 2018 07:14:08 +0000 (07:14 +0000)]
epoch(9): Don't trigger taskq enqueue before the grouptaskqs are setup

If EARLY_AP_STARTUP is not defined it is possible for an epoch to be
allocated prior to it being possible to call epoch_call without
issue.

Based on patch by andrew@

PR: 229014
Reported by: andrew

5 years agoRevert r334843, and partially revert r335180.
glebius [Sat, 23 Jun 2018 06:53:53 +0000 (06:53 +0000)]
Revert r334843, and partially revert r335180.

tcp_outflags[] were defined since 4BSD and are defined nowadays in
all its descendants. Removing them breaks third party application.

5 years agotop(1): show CPU state breakdown on first run
eadler [Sat, 23 Jun 2018 03:17:11 +0000 (03:17 +0000)]
top(1): show CPU state breakdown on first run

There is no documented reason for this not to be shown on the first run.
I can't find any good reason, and it breaks batch mode.

PR: 218889
Submitted by: "Jeremy C. Reed" <reed@reedmedia.net>

5 years agoUse 'mv -f' in rc.d/ntpd to avoid spuriously halting the boot.
ian [Sat, 23 Jun 2018 02:42:08 +0000 (02:42 +0000)]
Use 'mv -f' in rc.d/ntpd to avoid spuriously halting the boot.

The final 'mv' to install a fetched leap-list file can fail (due to a
readonly fs, or schg flags, for example), and that leads to mv(1)
prompting the user, stopping the boot process.  Instead, use mv -f
to supress the prompting, and if verbose mode is on, emit a warning
that the existing file cannot be replaced.

PR: 219255

5 years agopowerpc64: Fix stack setup in dbtrap
jhibbits [Sat, 23 Jun 2018 01:42:34 +0000 (01:42 +0000)]
powerpc64: Fix stack setup in dbtrap

r330610 relocated the DMAP from the base of memory to the base of the fourth
quadrant of memory.  This broke synthetic traps, such as KDB forced
breakpoints.  Use GET_TOCBASE() so the DMAP offset is handled.

Submitted by: git_bdragon.rkt0.net
Differential Revision: https://reviews.freebsd.org/D15973

5 years agoSet the slotid and ND_HASSLOTID flag for NFSv4.1 sequenced operations.
rmacklem [Sat, 23 Jun 2018 00:48:45 +0000 (00:48 +0000)]
Set the slotid and ND_HASSLOTID flag for NFSv4.1 sequenced operations.

Most NFSv4.1 compound RPCs start with a Sequence operation. For these
cases, save the slotid and note that it is saved by setting ND_HASSLOTID.
This is used by r335568 to free up the session slot and disable it.

MFC after: 2 weeks

5 years agoDefine ND_HASSLOTID needed by r335568.
rmacklem [Sat, 23 Jun 2018 00:37:15 +0000 (00:37 +0000)]
Define ND_HASSLOTID needed by r335568.

r335568 uses a flag called ND_HASSLOTID to indicate that the slotid is set,
so it can free and invalidate it.
This flag needs to be set, which will be done in a subsequent commit.

MFC after: 2 weeks

5 years agopf: Support "return" statements in passing rules when they fail.
kp [Fri, 22 Jun 2018 21:59:30 +0000 (21:59 +0000)]
pf: Support "return" statements in passing rules when they fail.

Normally pf rules are expected to do one of two things: pass the traffic or
block it. Blocking can be silent - "drop", or loud - "return", "return-rst",
"return-icmp". Yet there is a 3rd category of traffic passing through pf:
Packets matching a "pass" rule but when applying the rule fails. This happens
when redirection table is empty or when src node or state creation fails. Such
rules always fail silently without notifying the sender.

Allow users to configure this behaviour too, so that pf returns an error packet
in these cases.

PR: 226850
Submitted by: Kajetan Staszkiewicz <vegeta tuxpowered.net>
MFC after: 1 week
Sponsored by: InnoGames GmbH

5 years agoFix the handling of NFSv4.1 sessions for "soft" mounts.
rmacklem [Fri, 22 Jun 2018 21:37:20 +0000 (21:37 +0000)]
Fix the handling of NFSv4.1 sessions for "soft" mounts.

When a "soft" mount is used for NFSv4.1, an RPC that fails without completing
will leave a slot in the NFSv4.1 session in an indeterminate state.
As such, all that can be done is free up the slot while making is no longer
usable.
A "soft" NFSv4.1 mount is not recommended in general, since it will leave
Open/Lock state in an indeterminate state. An exception is a pNFS mount of
a DS, since there are no Opens/Locks done for them except file creates
where loss of the Open state does not matter.
The patch also makes connections to DSs soft, so that they will fail when
a DS is non-functional or network partitioned, allowing the pNFS MDS to disable
the DS for a mirrored configuration.
This patch should not affect normal "hard" NFSv4.1 mounts.

MFC after: 2 weeks

5 years agoChange the NFSv4.1 pNFS client so that it returns the DS error in layoutreturn.
rmacklem [Fri, 22 Jun 2018 21:25:27 +0000 (21:25 +0000)]
Change the NFSv4.1 pNFS client so that it returns the DS error in layoutreturn.

When the NFSv4.1 pNFS client gets an error for a DS I/O operation using a
Flexible File layout, it returns the layout with an error.
This patch changes the code slightly, so that it returns the layout for all
errors except EACCES and lets the MDS decide what to do based on the error.
It also makes a couple of changes to nfscl_layoutrecall() to ensure that
the first layoutreturn(s) will have the error in the reply.
Plus, the patch adds a wakeup() so that the "nfscl" thread won't wait 1sec
before doing the LayoutReturn.
Tested against the pNFS service.
This patch should not affect non-pNFS use of the client.
The unused "dsp" argument will be used by a future patch that disables the
connection to the DS when possible.

MFC after: 2 weeks

5 years agoAdd "mountcritremote" to the REQUIRE line for nfsd.
rmacklem [Fri, 22 Jun 2018 20:58:51 +0000 (20:58 +0000)]
Add "mountcritremote" to the REQUIRE line for nfsd.

For a pNFS MDS server, there must be mounts done to the DSs before the
nfsd is started. Adding the REQUIRE line makes sure these are done.
If there are NFS mounts in /etc/fstab that cannot be completed before
the nfsd starts, the "bg" mount option can still be used to handle that.
I do not believe this should cause problems for non-pNFS NFS servers.
(I have requested a review by rc@, but it is still pending.)

5 years agoStill parse messages that don't contain an RFC 3164 timestamp.
ed [Fri, 22 Jun 2018 20:53:39 +0000 (20:53 +0000)]
Still parse messages that don't contain an RFC 3164 timestamp.

The changes made in r326573 required that messages always start with an
RFC 3164 timestamp. It looks like certain devices, but also certain
logging libraries (Python 3's "logging" package) simply don't generate
RFC 3164 formatted messages containing a timestamp.

Make timestamps optional again. When the timestamp is missing, also
assume that the message contains no hostname. The first word of the
message likely already belongs to the message payload.

PR: 229236
Reported by: Michael Grimm & Marek Zarychta
Reviewed by: glebius (cursory)
MFC after: 1 week

5 years agoAdd spigen(4) fdt data overlays for RPI-B, RPI-2.
ian [Fri, 22 Jun 2018 20:45:40 +0000 (20:45 +0000)]
Add spigen(4) fdt data overlays for RPI-B, RPI-2.

By adding spigen-rpi{2,-b}.dtso to fdt_overlays= in loader.conf, the fdt data
will set up the correct pinmux and device nodes to create a spigen(4) device
for each available chipselect pin.

Submitted by: Bob Frazier
Differential Revision: https://reviews.freebsd.org/D15067

5 years agoEliminate a spurious panic on non-SMP systems (occurred on shutdown/reboot).
ian [Fri, 22 Jun 2018 20:22:26 +0000 (20:22 +0000)]
Eliminate a spurious panic on non-SMP systems (occurred on shutdown/reboot).

5 years agoRevert r335449 and add needed MK_LLD_BOOTSTRAP check for SRCS_MIW.
bdrewery [Fri, 22 Jun 2018 17:58:56 +0000 (17:58 +0000)]
Revert r335449 and add needed MK_LLD_BOOTSTRAP check for SRCS_MIW.

This effectively reverts r335449 and changes the previous MK_LLD_IS_LD
to a MK_LLD_BOOTSTRAP check.  If !TOOLS_PREFIX then these sources are
always built for llvm-objdump, lld, and llvm-cov.  When TOOLS_PREFIX
is set then they are only needed if lld is being bootstrapped.

Reported by: dim
Pointyhat to: bdrewery
Sponsored by: Dell EMC

5 years agoDon't bail out when we find primary and secondary bootblocks miscompare.
delphij [Fri, 22 Jun 2018 16:18:19 +0000 (16:18 +0000)]
Don't bail out when we find primary and secondary bootblocks miscompare.
We do not have code to fix this situation, and the mismatch does not
prevent the kernel driver from consuming the file system, and some factory
formatted SD cards seem to have a garbage backup block.

This makes the code match to its comments (replacing pfatal with pwarn).

Inspired by: NetBSD r1.13
Inspired by: https://android.googlesource.com/platform/external/fsck_msdos/+/b47b16353f3db228711dded9f7c975b820059ddc
MFC after: 2 weeks

5 years agoAdd support for selectively enabling LLVM targets
dim [Fri, 22 Jun 2018 15:00:00 +0000 (15:00 +0000)]
Add support for selectively enabling LLVM targets

This makes it possible, through src.conf(5) settings, to select which
LLVM targets you want to build during buildworld.  The current list is:

* (WITH|WITHOUT)_LLVM_TARGET_AARCH64
* (WITH|WITHOUT)_LLVM_TARGET_ARM
* (WITH|WITHOUT)_LLVM_TARGET_MIPS
* (WITH|WITHOUT)_LLVM_TARGET_POWERPC
* (WITH|WITHOUT)_LLVM_TARGET_SPARC
* (WITH|WITHOUT)_LLVM_TARGET_X86

To not influence anything right now, all of these are on by default, in
situations where clang is enabled.

Selectively turning a few targets off manually should work.  Turning on
only one target should work too, even if that target does not correspond
to the build architecture.  (In that case, LLVM_NATIVE_ARCH will not be
defined, and you can only use the resulting clang executable for
cross-compiling.)

I performed a few measurements on one of the FreeBSD.org reference
machines, building clang from scratch, with all targets enabled, and
with only the x86 target enabled.  The latter was ~12% faster in real
time (on a 32-core box), and ~14% faster in user time.  For a full
buildworld the difference will probably be less pronounced, though.

Reviewed by: bdrewery
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D11077

5 years agoImprove the accuracy of the POSIX "process CPU-time" clocks by adding the
cperciva [Fri, 22 Jun 2018 10:23:32 +0000 (10:23 +0000)]
Improve the accuracy of the POSIX "process CPU-time" clocks by adding the
used portion of the current thread's time slice if the current thread
belongs to the process being queried (i.e., if clock_gettime is invoked
with a clock ID of CLOCK_PROCESS_CPUTIME_ID or the value provided by
passing getpid(2) to clock_getcpuclockid(3)).

The CLOCK_VIRTUAL and CLOCK_PROF timers already make this adjustment via
long-standing code in calcru(), but since those timers are not specified
by POSIX it seems useful to add it here so that the higher accuracy is
available to code which aims to be portable.

PR: 228669
Reported by: Graham Percival
Reviewed by: kib
MFC after: 1 week

5 years agotop(1): increase warnings
eadler [Fri, 22 Jun 2018 10:20:21 +0000 (10:20 +0000)]
top(1): increase warnings

top(1) now builds without cast-qual warnings, so remove the exemption
for that.

Tested with clang, gcc7, gcc9

5 years agotop(1): garbage collect
eadler [Fri, 22 Jun 2018 10:17:12 +0000 (10:17 +0000)]
top(1): garbage collect

- remove a now-unused function
- remove needless indirection of handle type

5 years agotop(1): increase size of 'C' column
eadler [Fri, 22 Jun 2018 10:17:10 +0000 (10:17 +0000)]
top(1): increase size of 'C' column

On machines with more than 99 CPUs make room to display the entire
number.

Requested by: cperciva

5 years agotop(1): remove special handling of load > 5
eadler [Fri, 22 Jun 2018 09:45:18 +0000 (09:45 +0000)]
top(1): remove special handling of load > 5

When the load is "high" (an arbitrary value) top(1) previously moved the
cursor to the top-left of the screen as an acknowledgment. In practice,
on modern machines, even relatively slow ones, it looked more like a
glitch. Remove the logic.

5 years agotop(1): reimplement header formatting as sbuf
eadler [Fri, 22 Jun 2018 09:21:01 +0000 (09:21 +0000)]
top(1): reimplement header formatting as sbuf

The current header formatting is a giant format string that changes
global state during the format process.

Make the following changes:
- use sbuf to build up the header rather than use the above
pseudo-dynamic one
- Change name length to 10
- Reduce size of RES and SIZE by making humanize more aggressive
- Restore a version number line to the copyright. This may be required
by the copyright (and may not be; its unclear)

This is also a pre-req to implementing TOPCOLOR from newer versions of
top(1)

Discussed with: allanjude, rpolka, danfe, rgrimes
Differential Revision: https://reviews.freebsd.org/D15801

5 years agosu(1): build with WARNS=6
eadler [Fri, 22 Jun 2018 09:10:50 +0000 (09:10 +0000)]
su(1): build with WARNS=6

Tested with full make universe

5 years agoepoch.9: bump Dd
eadler [Fri, 22 Jun 2018 06:05:19 +0000 (06:05 +0000)]
epoch.9: bump Dd

ref D15961

5 years agoepoch.9: fix some style and speeling issues
eadler [Fri, 22 Jun 2018 06:04:22 +0000 (06:04 +0000)]
epoch.9: fix some style and speeling issues

Reported by: Yutaro Hayakawa <yhayakawa3720@gmail.com> (spelling)
Differential Revision: https://reviews.freebsd.org/D15961

5 years agoEliminate gcc "shadowed declaration" warnings by using idx rather than
ian [Fri, 22 Jun 2018 03:40:03 +0000 (03:40 +0000)]
Eliminate gcc "shadowed declaration" warnings by using idx rather than
index as a variable name.

Reported by: manu@

5 years agoaudit(4): add tests for Sys V semaphore operations
asomers [Fri, 22 Jun 2018 02:56:03 +0000 (02:56 +0000)]
audit(4): add tests for Sys V semaphore operations

Submitted by: aniketp
MFC after: 2 weeks
Sponsored by: Google, Inc. (GSoC 2018)
Differential Revision: https://reviews.freebsd.org/D15897

5 years agoAdd spi(8), a utility for communicating with a device on a SPI bus from
ian [Fri, 22 Jun 2018 01:59:19 +0000 (01:59 +0000)]
Add spi(8), a utility for communicating with a device on a SPI bus from
userland, conceptually similar to what i2c(8) provides for i2c devices.

Submitted by: Bob Frazier
Differential Revision: https://reviews.freebsd.org/D15029

5 years agoLet -s actually work.
bdrewery [Fri, 22 Jun 2018 01:10:05 +0000 (01:10 +0000)]
Let -s actually work.

MFC after: 2 weeks
Sponsored by: Dell EMC

5 years agoAdd a counter to limit the number of disabled DSs for a mirrored pNFS MDS.
rmacklem [Fri, 22 Jun 2018 00:55:39 +0000 (00:55 +0000)]
Add a counter to limit the number of disabled DSs for a mirrored pNFS MDS.

This patch adds a counter that limits the number of disabled mirrored DSs
to mirror level - 1.  It also makes a small change that keeps a Write that
has failed with EACCES when attempted by a client to a DS from disabling
the DS.
This patch only affects the pNFS server.

5 years agoepoch(9): make non-preemptible variant work early boot
mmacy [Fri, 22 Jun 2018 00:47:18 +0000 (00:47 +0000)]
epoch(9): make non-preemptible variant work early boot

5 years agotop(1): behave as documented for -t
eadler [Fri, 22 Jun 2018 00:02:36 +0000 (00:02 +0000)]
top(1): behave as documented for -t

Show top itself by default, unless -t is specified.

5 years agoFix output of linprocfs stat entry
chuck [Fri, 22 Jun 2018 00:02:05 +0000 (00:02 +0000)]
Fix output of linprocfs stat entry

The Linux /proc/stat entry has grown over time

 v2.5.41 <
   user, nice, system, idle
 v2.5.41
   user, nice, system, idle, iowait, irq
 v2.6.11
   user, nice, system, idle, iowait, irq, softirq, steal
 v2.6.24
   user, nice, system, idle, iowait, irq, softirq, steal, guest
 v2.6.32 >
   user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice

Some applications (e.g. nodejs) depend on the correct number of entries
and will abort otherwise.

Fix is to print the correct number of entries based on the value of
osrelease set either in sysctl or the jail settings. Change is similar
to approach used by illumos.

Reviewed by: emaste, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15858

5 years agoFix the Linux kernel version number calculation
chuck [Fri, 22 Jun 2018 00:02:03 +0000 (00:02 +0000)]
Fix the Linux kernel version number calculation

The Linux compatibility code was converting the version number (e.g.
2.6.32) in two different ways and then comparing the results.

The linux_map_osrel() function converted MAJOR.MINOR.PATCH similar to
what FreeBSD does natively. I.e. where major=v0, minor=v1, and patch=v2
    v = v0 * 1000000 + v1 * 1000 + v2;

The LINUX_KERNVER() macro, on the other hand, converted the value with
bit shifts. I.e. where major=a, minor=b, and patch=c
    v = (((a) << 16) + ((b) << 8) + (c))

The Linux kernel uses the later format via the KERNEL_VERSION() macro in
include/generated/uapi/linux/version.h

Fix is to use the LINUX_KERNVER() macro in linux_map_osrel() as well as
in the .trans_osrel functions.

PR: 229209
Reviewed by: emaste, cem, imp (mentor)
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15952

5 years agosubr_hints: Fix acpi unit hinting (at the very least)
kevans [Thu, 21 Jun 2018 21:50:00 +0000 (21:50 +0000)]
subr_hints: Fix acpi unit hinting (at the very least)

The refactoring in r335479 overlooked the fact that the dynamic kenv can
also be switched to if hintmode == 0. This is problematic because the
checkmethod bits are only ever ran once, but it worked previously because
the use_kenv was a global state and the first lookup would enable it if
occurring after the dynamic environment has been setup.

Extending our local definition of use_kenv to include all non-STATIC
hintmodes as long as the dynamic_kenv is setup fixes this. We still have
potential issues if the dynamic kenv comes up while we're doing an anchored
search through the environment, but this is not much of a concern right now
because:

1.) The dynamic environment comes up super early in boot, just after kmem

2.) This is going to get rewritten to provide a safer mechanism for the
anchored searches, ensuring that we continue using the same environment
chain (dynamic env or static fallback) for all anchored search invocations

Reported by: mmamcy
X-MFC-With: r335479

5 years agoIncorporate bus and chip select numbers into spigen(4) cdev names. Rather
ian [Thu, 21 Jun 2018 21:16:26 +0000 (21:16 +0000)]
Incorporate bus and chip select numbers into spigen(4) cdev names.  Rather
than assigning spigen device names in order of creation, this uses a device
name that corresponds to the owning spibus and chip-select index.

Example: /dev/spigen0.1 would be a child of spibus0, and use cs = 1

The intent is for systems like Raspberry Pi to have a consistent way of
using an SPI interface with a specific cs value from a user application.
Otherwise, there is no consistent way of knowing which cs pin will be
assigned to a particular spigen device. The alternative is to specify
everything in "the right order" in an overlay file, which is less than
ideal. Additionally, this duplicates (to some extent) the way Linux handles
a similar situation with their 'spidev' device, so it would be somewhat
familiar to those who also use Linux.

A new kernel config option, SPIGEN_LEGACY_CDEVNAME, causes the driver to
also create /dev/spigenN device name aliases, with N incrementing in the
order of device instantiation.  This is provided to ease the transition
for existing systems using the original naming convention (particularly
when these changes are MFC'd to stable branches).

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

5 years agolinux_clone_thread: mark new thread as TDB_BORN.
kib [Thu, 21 Jun 2018 21:15:04 +0000 (21:15 +0000)]
linux_clone_thread: mark new thread as TDB_BORN.

So that the ptrace code will catch it and report it to attached
debugger.  Enables debugging of threaded Linux binaries with FreeBSD
debugger.

Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com>
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15880

5 years agofork: avoid endless wait with PTRACE_FORK and RFSTOPPED.
kib [Thu, 21 Jun 2018 21:12:49 +0000 (21:12 +0000)]
fork: avoid endless wait with PTRACE_FORK and RFSTOPPED.

An RFSTOPPED thread can't clean TDB_STOPATFORK, which is done in the
fork_return() in its context, so parent is stuck forever.  Triggered
when trying to ptrace linux process.  Instead of waiting for the new
thread to clear TDB_STOPATFORK, tag it as traced and reparent to the
debugger in do_fork(), and let it only notify the debugger when run.

Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com>
Reviewed by: jhb
MFC after: 1 week
X-MFC-Note: keep p_dbgwait placeholder intact
Differential revision: https://reviews.freebsd.org/D15857

5 years agoUpdate proc->p_ptevents annotation to reflect the actual locking.
kib [Thu, 21 Jun 2018 21:07:25 +0000 (21:07 +0000)]
Update proc->p_ptevents annotation to reflect the actual locking.

Submitted by: Yanko Yankulov <yanko.yankulov@gmail.com>
Reviewed by: jhb
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D15954

5 years agoThis adds in an optimization so that we only walk one
rrs [Thu, 21 Jun 2018 21:03:58 +0000 (21:03 +0000)]
This adds in an optimization so that we only walk one
time through the mbuf chain during copy and TSO limiting.
It is used by both Rack and now the FreeBSD stack.
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D15937

5 years agoraw_ip: validate inp in both loops
mmacy [Thu, 21 Jun 2018 20:18:23 +0000 (20:18 +0000)]
raw_ip: validate inp in both loops

Continuation of r335497. Also move the lock acquisition up to
validate before referencing inp_cred.

Reported by: pho

5 years agoin_pcblookup_hash: validate inp before return
mmacy [Thu, 21 Jun 2018 18:40:15 +0000 (18:40 +0000)]
in_pcblookup_hash: validate inp before return

Post r335356 it is possible to have an inpcb on the hash lists that is
partially torn down. Validate before using. Also as a side effect of this
change the lock ordering issue between hash lock and inpcb no longer exists
allowing some simplification.

Reported by: pho@

5 years agoSync strlcpy with userland version, again
cem [Thu, 21 Jun 2018 17:35:13 +0000 (17:35 +0000)]
Sync strlcpy with userland version, again

No functional change.

Please remember to update libkern copies of libc functions when you update
libc.

Sponsored by: Dell EMC Isilon

5 years agoraw_ip: validate inp
mmacy [Thu, 21 Jun 2018 17:24:10 +0000 (17:24 +0000)]
raw_ip: validate inp

Post r335356 it is possible to have an inpcb on the hash lists that is
partially torn down. Validate before using.

Reported by: pho

5 years agoMinor comment fix d_namelen -> d_namlen
bdrewery [Thu, 21 Jun 2018 16:40:07 +0000 (16:40 +0000)]
Minor comment fix d_namelen -> d_namlen

5 years agoino64 uses 8 byte padding now.
bdrewery [Thu, 21 Jun 2018 16:39:38 +0000 (16:39 +0000)]
ino64 uses 8 byte padding now.

5 years agoFix the build post-PMCR addition.
jhibbits [Thu, 21 Jun 2018 15:59:05 +0000 (15:59 +0000)]
Fix the build post-PMCR addition.

Submitted by: lwhsu

5 years agoxen: check if there are clients waiting in gnttab_end_foreign_access_references
royger [Thu, 21 Jun 2018 15:47:47 +0000 (15:47 +0000)]
xen: check if there are clients waiting in gnttab_end_foreign_access_references

Without a call to check_free_callbacks() clients waiting for grant
references would not be woken up even when there are sufficient grant
references available.

The check was likely left out as a mistake when the function was first
added.

Note that other functions used to free grant references already call
check_free_callbacks.

Submitted by: pratyush
Reviewed by: royger
Differential review: https://reviews.freebsd.org/D15899

5 years agoAdd some words clarifying that rename(2) does nothing when the 'from' and
ian [Thu, 21 Jun 2018 15:21:17 +0000 (15:21 +0000)]
Add some words clarifying that rename(2) does nothing when the 'from' and
'to' args are the same file.  Wording borrowed from POSIX.1-2017, but
the freebsd code to implement this behavior was added in 2002 (r103180).

5 years agoAdd a note about using option VERBOSE_SYSINIT=0 to get the verbose code
ian [Thu, 21 Jun 2018 14:59:23 +0000 (14:59 +0000)]
Add a note about using option VERBOSE_SYSINIT=0 to get the verbose code
compiled in but disabled by default.

5 years agoAdd the rest of the files for r335481
jhibbits [Thu, 21 Jun 2018 14:30:14 +0000 (14:30 +0000)]
Add the rest of the files for r335481

Missed hooking PMCR cpufreq(4) to the build, and adding the SPR to the header.

5 years agoRename usr.bin/elfcopy to usr.bin/objcopy
emaste [Thu, 21 Jun 2018 14:28:20 +0000 (14:28 +0000)]
Rename usr.bin/elfcopy to usr.bin/objcopy

We always install ELF Tool Chain's elfcopy as objcopy, so to avoid
confusion rename the src directory containing our reach-over Makefile
to match.

Requested by: jhb
Sponsored by: The FreeBSD Foundation

5 years agoIntroduce PMCR-based cpufreq(4) driver, for IBM POWER8 and POWER9 systems
jhibbits [Thu, 21 Jun 2018 14:26:43 +0000 (14:26 +0000)]
Introduce PMCR-based cpufreq(4) driver, for IBM POWER8 and POWER9 systems

Summary: POWER8 and POWER9 use a single CPU register, per core, to change clock
speed.  Everything else is handled by the on-chip controller.  This change
necessitates a change to the cpufreq global kernel driver to bump supported
levels, as the device tree for these systems can have theoretically 256
different options.  On my POWER9 Talos, the list consists of 100 items.  At
16.67MHz intervals, that allows for a change of roughly 1.67GHz between lowest
and highest.

This has only been tested on the POWER9.  However, since they're similar, this
should work on POWER8 as well.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D15932

5 years agosubr_hints: simplify a little bit
kevans [Thu, 21 Jun 2018 14:04:02 +0000 (14:04 +0000)]
subr_hints: simplify a little bit

Some complexity exists in these bits that isn't needed. The sysctl handler,
upon change to '2', runs through the current set of hints and sets them in
the kenv.

However, this isn't at all necessary if we're pulling hints from the kenv,
static or dynamic, as the former will get added to the latter in
init_dynamic_kenv (see: kern_environment.c). We can reduce this
configuration to just adding static_hints to the kenv if we were previously
using them.

The changes in res_find are minimal and based on the observation that once
use_kenv gets set to '1' it will never be reset to '0', and it gets set to
'1' as soon as we hit fallback mode. Later work will refactor res_find a
little bit and eliminate this now-local, because it's become clear that
there's some funkiness revolving around use_kenv=1 and it being used to
imply that we're certainly looking at the dynamic_kenv.

Reviewed by: ray
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D15940

5 years agoPLIC driver was sponsored by ECATS contract, not CTSRD one.
br [Thu, 21 Jun 2018 11:52:09 +0000 (11:52 +0000)]
PLIC driver was sponsored by ECATS contract, not CTSRD one.

5 years agoAdd MMCCAM support to AllWinner MMC driver
kibab [Thu, 21 Jun 2018 11:49:21 +0000 (11:49 +0000)]
Add MMCCAM support to AllWinner MMC driver

Using MMCCAM on AllWinner boards is now possible, reaching highest
possible data transfer speed.

For now, MMCCAM doesn't scan cards on boot. This means that scanning
has to be done manually and that it's not possible to mount root FS
from MMC/SD card since there is no block device at the boot time.

For manually scanning the cards, run:
# camcontrol rescan X:0:0
Where X is the bus number (look at camcontrol devlist to determine
bus number assigned to the MMC controller).

Reviewed by: manu
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D15891

5 years agoFix uma_zalloc_pcpu_arg() operation in case of !SMP build.
br [Thu, 21 Jun 2018 11:43:54 +0000 (11:43 +0000)]
Fix uma_zalloc_pcpu_arg() operation in case of !SMP build.

Reviewed by: mjg
Sponsored by: DARPA, AFRL

5 years ago"Kernel APIs" is a misnomer; use the proper name instead.
trasz [Thu, 21 Jun 2018 08:19:11 +0000 (08:19 +0000)]
"Kernel APIs" is a misnomer; use the proper name instead.

Suggested by: kib@, ian@
MFC after: 2 weeks

5 years agoDon't leak tmpstr.
delphij [Thu, 21 Jun 2018 07:42:28 +0000 (07:42 +0000)]
Don't leak tmpstr.

MFC after: 2 weeks

5 years agoudp_ctlinput: don't refer to unpcb after we drop the lock
mmacy [Thu, 21 Jun 2018 06:10:52 +0000 (06:10 +0000)]
udp_ctlinput: don't refer to unpcb after we drop the lock

Reported by: pho@

5 years agoDon't remove loader.conf(5) when built WITHOUT_FORTH
kevans [Thu, 21 Jun 2018 05:28:00 +0000 (05:28 +0000)]
Don't remove loader.conf(5) when built WITHOUT_FORTH

The new stand/ structure installs loader.conf(5) and defaults/loader.conf
regardless of interpreter. The only thing gating installation now is
MK_BOOT.

Reported by: eadler

5 years agoMakefile.inc1: rename build metadata file to toolchain-metadata.mk
emaste [Thu, 21 Jun 2018 02:15:50 +0000 (02:15 +0000)]
Makefile.inc1: rename build metadata file to toolchain-metadata.mk

The metadata file contains more than just compiler metadata.

Discussed with: bdrewery

5 years agoixl(4): Fix gcc build errors
erj [Wed, 20 Jun 2018 22:16:46 +0000 (22:16 +0000)]
ixl(4): Fix gcc build errors

By removing redundant function declarations.

Reported by: ci.freebsd.org via Mark Millard <marklmi@yahoo.com>
MFC after: 1 month

5 years agoPermit the kernel environment to set an array of numeric values for a single
hselasky [Wed, 20 Jun 2018 20:04:20 +0000 (20:04 +0000)]
Permit the kernel environment to set an array of numeric values for a single
sysctl(9) node.

Reviewed by: kib@, imp@, jhb@
Differential Revision: https://reviews.freebsd.org/D15802
MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoOnly look for NOTES as needed.
bdrewery [Wed, 20 Jun 2018 19:45:04 +0000 (19:45 +0000)]
Only look for NOTES as needed.

Sponsored by: Dell EMC

5 years agoacpidump.8: include NFIT in the man page list of tables
emaste [Wed, 20 Jun 2018 19:40:54 +0000 (19:40 +0000)]
acpidump.8: include NFIT in the man page list of tables

Was missed in r321298.

Reported by: Ben Widawsky (in review D15931)
MFC after: 1 week

5 years agoAdd debug.verbose_sysinit tunable for VERBOSE_SYSINIT
kevans [Wed, 20 Jun 2018 19:23:56 +0000 (19:23 +0000)]
Add debug.verbose_sysinit tunable for VERBOSE_SYSINIT

VERBOSE_SYSINIT is currently an all-or-nothing option. debug.verbose_sysinit
adds an option to have the code compiled in but quiet by default so that
getting this information from a device in the field doesn't necessarily
require distributing a recompiled kernel.

Its default is VERBOSE_SYSINIT's value as defined in the kernconf. As such,
the default behavior for simply omitting or including this option is
unchanged.

MFC after: 1 week

5 years agoCorrect path to removed asf(8) binary.
jhb [Wed, 20 Jun 2018 19:22:33 +0000 (19:22 +0000)]
Correct path to removed asf(8) binary.

5 years agoImprove wording.
trasz [Wed, 20 Jun 2018 19:16:51 +0000 (19:16 +0000)]
Improve wording.

MFC after: 2 weeks

5 years agousr.bin/ar: use standard 2-Clause FreeBSD license
emaste [Wed, 20 Jun 2018 18:43:17 +0000 (18:43 +0000)]
usr.bin/ar: use standard 2-Clause FreeBSD license

Many licenses on ar files contained small variations from the standard
FreeBSD license text. To avoid license proliferation switch to the usual
2-clause FreeBSD license after obtaining permission from all copyright
holders.

Approved by: jkoshy, kaiw, kientzle
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14561

5 years agoReduce exec and fstat overhead for non-build targets.
bdrewery [Wed, 20 Jun 2018 17:20:39 +0000 (17:20 +0000)]
Reduce exec and fstat overhead for non-build targets.

This is mostly targetting 'make showconfig' and 'make test-system-*' for
the benefit of makeman and universe-one-clang work.

Sponsored by: Dell EMC

5 years agoRegenerate for SYSTEM_LINKER
bdrewery [Wed, 20 Jun 2018 16:15:03 +0000 (16:15 +0000)]
Regenerate for SYSTEM_LINKER

5 years agoAdd WITH_SYSTEM_LINKER, on by default, that avoids building lld when possible.
bdrewery [Wed, 20 Jun 2018 16:10:14 +0000 (16:10 +0000)]
Add WITH_SYSTEM_LINKER, on by default, that avoids building lld when possible.

This works similar to WITH_SYSTEM_COMPILER added in r300354.  It only
supports lld via WITH_LLD_BOOTSTRAP.

When both SYSTEM_COMPILER and SYSTEM_LINKER logic passes then libclang
will not build in cross-tools.  If either check fails though then
libclang is built.

The .info is reworked to notify when libclang will be built since if
either clang or lld needs to be rebuilt, but not the other, the
notification can lead to confusion on why "clang is building".

-fuse-ld= is not used with this method so some combinations of compiler
and linker are expected to fail.

A new 'make test-system-linker' target is added to see the logic results.

Makefile.inc1:
  CROSS_BINUTILS_PREFIX support had to be moved higher up so that XLD
  could be set and MK_LLD_BOOTSTRAP disabled before checking SYSTEM_LINKER
  logic as done with SYSTEM_COMPILER.  This also required moving where
  bsd.linker.mk was read since XLD needs to be set before parsing it.  This
  creates a situation where src.opts.mk can not test LINKER_FEATURES or
  add LLD_BOOTSTAP to BROKEN_OPTIONS.

Reviewed by: emaste (earlier version)
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D15894

5 years agoFix sources needed for lld.
bdrewery [Wed, 20 Jun 2018 16:10:10 +0000 (16:10 +0000)]
Fix sources needed for lld.

lld always needs these DWARF sources, as well as other default and extra
tools. XDL seems to be the best fit list.

Remove MK_LLD_IS_LD check from SRCS_MIW which is now reduced to just a
few files for llvm-objdump.

Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D15915

5 years agoRework WITHOUT_LLD/TOOLCHAIN fix from r327892 for cross-tools.
bdrewery [Wed, 20 Jun 2018 16:10:07 +0000 (16:10 +0000)]
Rework WITHOUT_LLD/TOOLCHAIN fix from r327892 for cross-tools.

MK_LLD is for the installed lld while MK_LLD_BOOTSTRAP is for the build
tool.  For WITH_SYSTEM_LINKER it is necesarry to separate the logic of
these two.  When building libllvm TOOLS_PREFIX will be defined and
MK_LLD_BOOTSTRAP should be checked instead.

Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D15837

5 years agoRework how the ld link is handled in WORLDTMP from r322811.
bdrewery [Wed, 20 Jun 2018 16:10:02 +0000 (16:10 +0000)]
Rework how the ld link is handled in WORLDTMP from r322811.

LLD_BOOTSTRAP (build) is independent of LLD_IS_LD (installed) so they
should not be based on each other.

This is related to upcoming WITH_SYSTEM_LINKER work.

Reviewed by: emaste
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D15836

5 years agoAdd pmap_mapdev_attr for arm64
manu [Wed, 20 Jun 2018 16:07:35 +0000 (16:07 +0000)]
Add pmap_mapdev_attr for arm64

This is needed for efifb.
arm and ricv pmap (the two arch with arm64 that uses subr_devmap) have very
different implementation so for now only add this for arm64.

Tested with efifb on Pine64 with a few other patches.

Reviewed by: cognet
Differential Revision: https://reviews.freebsd.org/D15294

5 years agoif_rk_dwc: Disable setting delays for now
manu [Wed, 20 Jun 2018 15:27:09 +0000 (15:27 +0000)]
if_rk_dwc: Disable setting delays for now

The values for tx/rx delays differs accross the different DTS.
Mainline Linux set it to 0x24/0x18
Mostly-Vendor u-boot (the one maintained and developped) to 0x18/0x18
Mostly-Vendor linux (the one maintained and developped) to 0x26/0x11

By experience only 0x18/0x18 works so until the issue is resolved rely on
the bootloader settings.

5 years agork_gpio: Read the correct register for gpio read
manu [Wed, 20 Jun 2018 14:46:07 +0000 (14:46 +0000)]
rk_gpio: Read the correct register for gpio read

Reported by: jmcneill

5 years agoif_rk_dwc: Fix delays handling
manu [Wed, 20 Jun 2018 14:45:26 +0000 (14:45 +0000)]
if_rk_dwc: Fix delays handling

The property are named {t,r}x_delay and not {t,r}-delay.
The upper bits of the register are a mask of which bits is allowed
to be written, set it otherwise we write nothing.
OF_getencprop returns <0 = for an error.

Pointy Hat: myself
Reported by: jmcneill (delay and mask bits)

5 years agoAttach dev.cpu nodes on powerpc SMT cores, using only the first found thread
jhibbits [Wed, 20 Jun 2018 13:30:35 +0000 (13:30 +0000)]
Attach dev.cpu nodes on powerpc SMT cores, using only the first found thread

Summary: In order to use cpufreq(4), a dev.cpu attachment must be created.  If
the IBM property is found denoting SMT, attach only to the first thread setup,
so that a cpufreq device can bind.

Reviewed by: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D15921

5 years agoInstead of using hand-rolled loops where not needed switch them
bz [Wed, 20 Jun 2018 11:42:06 +0000 (11:42 +0000)]
Instead of using hand-rolled loops where not needed switch them
to FOREACH_PROC_IN_SYSTEM() to have a single pattern to look for.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D15916

5 years agoMove the SYSINIT to allow userspace access to the ARM generic timer later
andrew [Wed, 20 Jun 2018 11:13:10 +0000 (11:13 +0000)]
Move the SYSINIT to allow userspace access to the ARM generic timer later
in the boot. It doesn't need to be early, so move it to the SI_ORDER_ANY
stage of SI_SUB_SMP.

Sponsored by: DARPA, AFRL

5 years agoMove the SMCCC SYSINIT later in the boot so the psci driver has attached.
andrew [Wed, 20 Jun 2018 10:57:29 +0000 (10:57 +0000)]
Move the SMCCC SYSINIT later in the boot so the psci driver has attached.

Sponsored by: DARPA, AFRL

5 years agoFix the SMCCC signatures, they are all 32-bit calls. This fixes SMCCC
andrew [Wed, 20 Jun 2018 10:02:50 +0000 (10:02 +0000)]
Fix the SMCCC signatures, they are all 32-bit calls. This fixes SMCCC
version detection.

Sponsored by: DARPA, AFRL

5 years agoSometimes it is helpful to get the path for a vnode.
bz [Wed, 20 Jun 2018 08:34:29 +0000 (08:34 +0000)]
Sometimes it is helpful to get the path for a vnode.
Implement a ddb function walking the namecache to do this.

Reviewed by: jhb, mjg
Inspired by: gdb macro from jhb (old version)
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D14898

5 years agoFix build breakage in veriexec for 32-bit architectures.
stevek [Wed, 20 Jun 2018 06:54:38 +0000 (06:54 +0000)]
Fix build breakage in veriexec for 32-bit architectures.

fsid_t and ino_t are 64-bit entities, use uintmax_t typecast to ensure we
can print it on 32-bit or 64-bit architectures by using the %ju format for
prints.

Obtained from: Juniper Networks, Inc.