]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agosockstat: add break that was forgot in 328279
manu [Tue, 23 Jan 2018 14:33:19 +0000 (14:33 +0000)]
sockstat: add break that was forgot in 328279

Reported by: garga@
MFC after: 1 week
X-MFC With: 328279
Sponsored by: Gandi.net

6 years agoextfs: Remove unused variables.
pfg [Tue, 23 Jan 2018 14:17:04 +0000 (14:17 +0000)]
extfs: Remove unused variables.

Found by: scan-build
Reviewed by: fsu
Differential Revision: https://reviews.freebsd.org/D14017

6 years agosockstat: Add -q option to suppress the header line
manu [Tue, 23 Jan 2018 13:03:47 +0000 (13:03 +0000)]
sockstat: Add -q option to suppress the header line

MFC after: 1 week
Sponsored by: Gandi.net

6 years agoPowerNV: send MSI_EOI always after MSI unmask
wma [Tue, 23 Jan 2018 08:07:00 +0000 (08:07 +0000)]
PowerNV: send MSI_EOI always after MSI unmask

MSI/MSI-x interrupts are edge-triggered. If an interrupt
arrives when IRQ line is masked, it will be lost and will
never recover. Perform MSI_EOI always after unmask to give
a chance for PHB/XICS to send an interrupt again if MSI/MSI-x
pending bit is set in MSI/MSI-x BAR space.

Submitted by:          Wojciech Macek <wma@semihalf.org>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies

6 years agoDocument how to load nmdm(4) from a kernel module.
delphij [Tue, 23 Jan 2018 03:36:49 +0000 (03:36 +0000)]
Document how to load nmdm(4) from a kernel module.

Submitted by: kevlo
MFC after: 2 weeks

6 years agoIncrement the route table gen count after a modify
rstone [Tue, 23 Jan 2018 03:15:44 +0000 (03:15 +0000)]
Increment the route table gen count after a modify

Increment the route table generation count after modifying a
route.  This signals back to TCP connections that they need to
update their L2 caches as the gateway for their route may have
changed.  This is a heavier hammer than is needed, strictly
speaking, but route changes will be unlikely enough that the
performance effects of invalidating all connection route caches
should be negligible.

MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13990
Reviewed by: karels

6 years agoReduce code duplication for inpcb route caching
rstone [Tue, 23 Jan 2018 03:15:39 +0000 (03:15 +0000)]
Reduce code duplication for inpcb route caching

Add a new macro to clear both the L3 and L2 route caches, to
hopefully prevent future instances where only the L3 cache was
cleared when both should have been.

MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13989
Reviewed by: karels

6 years agoInvalidate inpcb LLE cache if cached route is invalidated
rstone [Tue, 23 Jan 2018 03:15:39 +0000 (03:15 +0000)]
Invalidate inpcb LLE cache if cached route is invalidated

When the inpcb route cache is invalidated after a change to the
routing tables, we need to invalidate the LLE cache as well.
Previous to this change packets for the connection would continue
to use the old L2 information from the old L3 gateway, and the
packets for the connection would likely be blackholed.

MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13988
Reviewed by: karels

6 years agoFix 64-bit booke kernel builds after the ldscript changes
jhibbits [Tue, 23 Jan 2018 02:52:12 +0000 (02:52 +0000)]
Fix 64-bit booke kernel builds after the ldscript changes

Commits r326203 and r326978 broke 64-bit booke kernels by introducing a 1MB
zero-pad between the ELF header and the start of the kernel.  This didn't
cause a build failure, but caused kernels to need to be loaded into memory
1MB lower, which could easily break scripts expecting previous behavior.
This change matches the similar change made to AIM in r327358.

6 years agomlock(2): correct documentation for error conditions.
asomers [Mon, 22 Jan 2018 21:45:54 +0000 (21:45 +0000)]
mlock(2): correct documentation for error conditions.

The man page is years out of date regarding errors. Our implementation _does_
allow unaligned addresses, and it _does_not_ check for negative lengths,
because the length is unsigned. It checks for overflow instead.

Update the tests accordingly.

Reviewed by: bcr
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D13826

6 years agoixv(4): Stop setting editing ifnet flags in ixv_if_init()
erj [Mon, 22 Jan 2018 20:56:21 +0000 (20:56 +0000)]
ixv(4): Stop setting editing ifnet flags in ixv_if_init()

In iflib, the device-specific init() function isn't supposed to edit
the struct ifnet driver flags. If it does, it'll cause an MPASS() assert
in iflib to fail.

PR: 225312
Reported by: bhughes@

6 years agoFix compat32 for sysctl net.PF_ROUTE...NET_RT_IFLISTL.
kib [Mon, 22 Jan 2018 20:49:17 +0000 (20:49 +0000)]
Fix compat32 for sysctl net.PF_ROUTE...NET_RT_IFLISTL.

Route messages are aligned to the host long type alignment, which
breaks 32bit.

Reported and tested by: lwhsu
Diagnosed by: Yuri Pankov <yuripv@icloud.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agolibregex: Add a symbol map
kevans [Mon, 22 Jan 2018 18:40:19 +0000 (18:40 +0000)]
libregex: Add a symbol map

kib points out that trying to re-use symbol versioning from libc is dirty
and wrong. The implementation in libregex is incompatible by design with the
implementation in libc. Using the symbol versions from libc can and likely
will cause confusions for linkers and bring unexpected behavior for
consumers that unwillingly (transitively) link against libregex.

Reported by: kib

6 years agoThis comment is bogus. This is a legit release.
imp [Mon, 22 Jan 2018 17:47:49 +0000 (17:47 +0000)]
This comment is bogus. This is a legit release.

Reviewed by: scottl@, ken@
Sponsored by: Netflix

6 years agodrm2: Basic use of mallocarray(9).
pfg [Mon, 22 Jan 2018 15:55:51 +0000 (15:55 +0000)]
drm2: Basic use of mallocarray(9).

These functions deal the same type of overflows we do with mallocarray(9).
Using our mallocarray will panic, which different from the previous
behavior (returning NULL), but neither behavior is more correct.

As a sidenote, drm_calloc_large() is not currently used at all.

Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D13835

6 years agoForgot to add the skeleton BCM283x Clock Manager
phk [Mon, 22 Jan 2018 08:33:59 +0000 (08:33 +0000)]
Forgot to add the skeleton BCM283x Clock Manager

Reminded by: lwhsu

6 years agoAdd skeleton manual page for bcm283x_pwm
phk [Mon, 22 Jan 2018 07:43:54 +0000 (07:43 +0000)]
Add skeleton manual page for bcm283x_pwm

(Feel free to improve this)

6 years agoForgot to edit copy&pasted copyright blurb.
phk [Mon, 22 Jan 2018 07:15:24 +0000 (07:15 +0000)]
Forgot to edit copy&pasted copyright blurb.

6 years agoAdd a skeleton Clock Manager for RPi2/3, and use that from pwm
phk [Mon, 22 Jan 2018 07:10:30 +0000 (07:10 +0000)]
Add a skeleton Clock Manager for RPi2/3, and use that from pwm
instead of frobbing the registers directly.

As a hack the bcm2835_pwm kmod presently ignores the 'status="disabled"'
in the RPI3 DTB, assuming that if you load the kld you probably
want the PWM to work.

6 years agoMFV r328255: 8972 zfs holds: In scripted mode, do not pad columns with spaces
mav [Mon, 22 Jan 2018 06:00:45 +0000 (06:00 +0000)]
MFV r328255: 8972 zfs holds: In scripted mode, do not pad columns with spaces

illumos/illumos-gate@e9b7d6e7f7a6477679a35b73eb3934b096b3dd39

https://www.illumos.org/issues/8972:
'zfs holds -H' does not properly output content in scripted mode. It uses a
tab instead of two spaces, but it still pads column widths with spaces when
it should not.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Allan Jude <allanjude@freebsd.org>

6 years agoMFV r328253: 8835 Speculative prefetch in ZFS not working for misaligned reads
mav [Mon, 22 Jan 2018 05:57:14 +0000 (05:57 +0000)]
MFV r328253: 8835 Speculative prefetch in ZFS not working for misaligned reads

illumos/illumos-gate@5cb8d943bc8513c6230589aad5a409d58b0297cb

https://www.illumos.org/issues/8835:
Sequential reads not aligned to block size are not detected by ZFS
prefetcher as sequential, killing prefetch and severely hurting
performance.  It is caused by dmu_zfetch() in case of misaligned
sequential accesses being called with overlap of one block.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Allan Jude <allanjude@freebsd.org>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Alexander Motin <mav@FreeBSD.org>

6 years agoMFV r328251: 8652 Tautological comparisons with ZPROP_INVAL
mav [Mon, 22 Jan 2018 05:52:39 +0000 (05:52 +0000)]
MFV r328251: 8652 Tautological comparisons with ZPROP_INVAL

illumos/illumos-gate@4ae5f5f06c6c2d1db8167480f7d9e3b5378ba2f2

https://www.illumos.org/issues/8652:
Clang and GCC prefer to use unsigned ints to store enums. With Clang, that
causes tautological comparison warnings when comparing a zfs_prop_t or
zpool_prop_t variable to the macro ZPROP_INVAL. It's likely that error
handling code is being silently removed as a result.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Alan Somers <asomers@gmail.com>

6 years agoMFV r328249:
mav [Mon, 22 Jan 2018 04:37:04 +0000 (04:37 +0000)]
MFV r328249:
8641 "zpool clear" and "zinject" don't work on "spare" or "replacing" vdevs

illumos/illumos-gate@2ba5f978a4f9b02da9db1b8cdd9ea5498eb00ad9

https://www.illumos.org/issues/8641:
"zpool clear" and "zinject -d" can both operate on specific vdevs, either
leaf or interior. However, due to an oversight, neither works on a "spare"
or "replacing" vdev. For example:

sudo zpool create foo raidz1 c1t5000CCA000081D61d0 c1t5000CCA000186235d0 spare c
1t5000CCA000094115d0
sudo zpool replace foo c1t5000CCA000186235d0 c1t5000CCA000094115d0
$ zpool status foo pool: foo
state: ONLINE
scan: resilvered 81.5K in 0h0m with 0 errors on Fri Sep 8 10:53:03 2017
config:

NAME                         STATE     READ WRITE CKSUM
        foo                          ONLINE       0     0     0
          raidz1-0                   ONLINE       0     0     0
            c1t5000CCA000081D61d0    ONLINE       0     0     0
            spare-1                  ONLINE       0     0     0
              c1t5000CCA000186235d0  ONLINE       0     0     0
              c1t5000CCA000094115d0  ONLINE       0     0     0
        spares
          c1t5000CCA000094115d0      INUSE     currently in use
$ sudo zinject -d spare-1 -A degrade foo
cannot find device 'spare-1' in pool 'foo'
$ sudo zpool clear foo spare-1
cannot clear errors for spare-1: no such device in pool

Even though there was nothing to clear, those commands shouldn't have
reported an error. by contrast, trying to clear "raidz1-0" works just fine:
$ sudo zpool clear foo raidz1-0

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Alan Somers <asomers@gmail.com>

6 years agoMFV r328247: 8959 Add notifications when a scrub is paused or resumed
mav [Mon, 22 Jan 2018 04:31:48 +0000 (04:31 +0000)]
MFV r328247: 8959 Add notifications when a scrub is paused or resumed

illumos/illumos-gate@301fd1d6f25595cd8c6d6795f39c72d97aff8cd9

Reviewed by: Alek Pinchuk <pinchuk.alek@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Sean Eric Fagan <sef@ixsystems.com>

6 years agoMFV r328245: 8856 arc_cksum_is_equal() doesn't take into account ABD-logic
mav [Mon, 22 Jan 2018 04:23:48 +0000 (04:23 +0000)]
MFV r328245: 8856 arc_cksum_is_equal() doesn't take into account ABD-logic

illumos/illumos-gate@01a059ee0cdece49f47fd4d70086dd5bc7d0b0ff

https://www.illumos.org/issues/8856:
arc_cksum_is_equal() calls zio_push_transform() that requires abd_t*
(second arg), but a void* is passed.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Roman Strashkin <roman.strashkin@nexenta.com>

6 years agousr.sbin/service: Fix -j to not be order dependant
kevans [Mon, 22 Jan 2018 03:38:10 +0000 (03:38 +0000)]
usr.sbin/service: Fix -j to not be order dependant

The introduced -j option is highly dependant on the ordering of arguments,
and it exhibited broken behavior in some other circumstances. Fix these
issues, and simplify the feature by removing the unneessary double parsing
of options.

Reviewed by: jilles
Differential Revision: https://reviews.freebsd.org/D13952

6 years agolibregex: Drop WARNS to 2 to match libc
kevans [Mon, 22 Jan 2018 03:12:26 +0000 (03:12 +0000)]
libregex: Drop WARNS to 2 to match libc

It's become clear that my armv7 builds didn't catch all of the warnings that
other builds are picking up, drop WARNS to 2 to match libc until they're all
caught.

6 years agoAdd missing patch from r328240
kevans [Mon, 22 Jan 2018 02:58:33 +0000 (02:58 +0000)]
Add missing patch from r328240

regcomp uses some libc internal collation bits that are not available in the
libregex context. It's easy enough to bring in the needed parts that can
work in a libregex world, so do so.

Pointy hat to: me

6 years agoAdd libregex, connect it to the build
kevans [Mon, 22 Jan 2018 02:44:41 +0000 (02:44 +0000)]
Add libregex, connect it to the build

libregex is a regex(3) implementation intended to feature GNU extensions and
any other non-POSIX compliant extensions that are deemed worthy.

These extensions are separated out into a separate library for the sake of
not cluttering up libc further with them as well as not deteriorating the
speed (or lack thereof) of the libc implementation.

libregex is implemented as a build of the libc implementation with LIBREGEX
defined to distinguish this from a libc build. The reasons for
implementation like this are two-fold:

1.) Maintenance- This reduces the overhead induced by adding yet another
regex implementation to base.

2.) Ease of use- Flipping on GNU extensions will be as simple as linking
against libregex, and POSIX-compliant compilations can be guaranteed with a
REG_POSIX cflag that should be ignored by libc/regex and disables extensions
in libregex. It is also easier to keep REG_POSIX sane and POSIX pure when
implemented in this fashion.

Tests are added for future functionality, but left disconnected for the time
being while other testing is done.

Reviewed by: cem (previous version)
Differential Revision: https://reviews.freebsd.org/D12934

6 years agoForgot to sort here in r328238.
pfg [Mon, 22 Jan 2018 02:26:10 +0000 (02:26 +0000)]
Forgot to sort here in r328238.

6 years agoUnsign some values related to allocation.
pfg [Mon, 22 Jan 2018 02:08:10 +0000 (02:08 +0000)]
Unsign some values related to allocation.

When allocating memory through malloc(9), we always expect the amount of
memory requested to be unsigned as a negative value would either stand for
an error or an overflow.
Unsign some values, found when considering the use of mallocarray(9), to
avoid unnecessary casting. Also consider that indexes should be of
at least the same size/type as the upper limit they pretend to index.

MFC after: 3 weeks

6 years agoUse the __alloc_size2 attribute where relevant.
pfg [Mon, 22 Jan 2018 01:50:10 +0000 (01:50 +0000)]
Use the __alloc_size2 attribute where relevant.

This follows the documented use in GCC. It is basically only relevant for
calloc(3), reallocarray(3) and  mallocarray(9).

Suggested by: Mark Millard

Reference:
https://docs.freebsd.org/cgi/mid.cgi?9DE674C6-EAA3-4E8A-906F-446E74D82FC4

6 years agoMFV r328233:
mav [Mon, 22 Jan 2018 00:01:36 +0000 (00:01 +0000)]
MFV r328233:
8898 creating fs with checksum=skein on the boot pools fails ungracefully

illumos/illumos-gate@9fa2266d9a78b8366e1cd2d5f050e8b5e37d558c

https://www.illumos.org/issues/8898:
# zfs create -o checksum=skein rpool/test
internal error: Result too large
Abort (core dumped)

Not a big deal per se, but should be handled correctly.

Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Andy Stormont <astormont@racktopsystems.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

PR: 222199

6 years agoMFV r328231: 8897 zpool online -e fails assertion when run on non-leaf vdevs
mav [Sun, 21 Jan 2018 23:53:56 +0000 (23:53 +0000)]
MFV r328231: 8897 zpool online -e fails assertion when run on non-leaf vdevs

illumos/illumos-gate@9a551dd645b478816cb11251b19f5034d885bf01

https://www.illumos.org/issues/8897:
# zpool online -e test mirror-1
Assertion failed: nvlist_lookup_string(tgt, "path", &pathname) == 0, file ../common/libzfs_pool.c, line 2558, function zpool_vdev_online
Abort (core dumped)

Not a big deal per se, but should be handled gracefully, same way as 'offline' and 'online' without '-e'.

Also reported as: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221408

Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Yuri Pankov <yuri.pankov@nexenta.com>

6 years agoMFV r328229:
mav [Sun, 21 Jan 2018 23:49:17 +0000 (23:49 +0000)]
MFV r328229:
8930 zfs_zinactive: do not remove the node if the filesystem is readonly

illumos/illumos-gate@93c618e0f4932dc0bb9a9c90d8c4a5d029de5797

https://www.illumos.org/issues/8930:
We normally remove an unlinked node when its last user goes away and the
node becomes inactive. However, we should not do that if the filesystem
is mounted read-only including the case where it has its readonly
property set. The node will remain on the unlinked queue, so it will
not be leaked.

One particular scenario is when we receive an incremental stream into a
mounted read-only filesystem and that stream contains an unlinked file
(still on the unlinked queue). If that file is opened before the
receive and some time later after the receive it becomes inactive we
would remove it and, thus, modify the read-only filesystem. As a
result, the filesystem would diverge from its source and further
incremental receives would not be possible (without forcing a rollback).

Another related scenario, that may or may not be possible depending on an
OS / VFS policy, is when an open file is unlinked, then the filesystem is
remounted read-only, and then the file is closed.

Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Approved by: Gordon Ross <gwr@nexenta.com>
Author: Andriy Gapon <avg@FreeBSD.org>

6 years agoMFV r328227: 8909 8585 can cause a use-after-free kernel panic
mav [Sun, 21 Jan 2018 23:18:42 +0000 (23:18 +0000)]
MFV r328227: 8909 8585 can cause a use-after-free kernel panic

illumos/illumos-gate@94ddd0900a8838f62bba15e270649a42f4ef9f81

https://www.illumos.org/issues/8909:
There's a race condition that exists if `zil_free_lwb` races with either
`zil_commit_waiter_timeout` and/or `zil_lwb_flush_vdevs_done`.

Here's an example panic due to this bug:

> ::status
    debugging crash dump vmcore.0 (64-bit) from ip-10-110-205-40
    operating system: 5.11 dlpx-5.2.2.0_2017-12-04-17-28-32b6ba51fb (i86pc)
    image uuid: 4af0edfb-e58e-6ed8-cafc-d3e9167c7513
    panic message:
    BAD TRAP: type=e (#pf Page fault) rp=ffffff0010555970 addr=60 occurred in mo
dule "zfs" due to a NULL pointer dereference
    dump content: kernel pages only

> $c
    zio_shrink+0x12()
    zil_lwb_write_issue+0x30d(ffffff03dcd15cc0ffffff03e0730e20)
    zil_commit_waiter_timeout+0xa2(ffffff03dcd15cc0ffffff03d97ffcf8)
    zil_commit_waiter+0xf3(ffffff03dcd15cc0ffffff03d97ffcf8)
    zil_commit+0x80(ffffff03dcd15cc0, 9a9)
    zfs_write+0xc34(ffffff03dc38b140ffffff0010555e60, 40, ffffff03e00fb758, 0)
    fop_write+0x5b(ffffff03dc38b140ffffff0010555e60, 40, ffffff03e00fb758, 0)
    write+0x250(42, fffffd7ff4832000, 2000)
    sys_syscall+0x177()

If there's an outstanding lwb that's in `zil_commit_waiter_timeout`
waiting to timeout, waiting on it's waiter's CV, we must be sure not to
call `zil_free_lwb`. If we end up calling `zil_free_lwb`, then that LWB
may be freed and can result in a use-after-free situation where the
stale lwb pointer stored in the `zil_commit_waiter_t` structure of the
thread waiting on the waiter's CV is used.

A similar situation can occur if an lwb is issued to disk, and thus in
the `LWB_STATE_ISSUED` state, and `zil_free_lwb` is called while the
disk is servicing that lwb. In this situation, the lwb will be freed by
`zil_free_lwb`, which will result in a use-after-free situation when the
lwb's zio completes, and `zil_lwb_flush_vdevs_done` is called.

This race condition is prevented in `zil_close` by calling `zil_commit`
before `zil_free_lwb` is called, which will ensure all outstanding (i.e.
all lwb's in the `LWB_STATE_OPEN` and/or `LWB_STATE_ISSUED` states)
reach the `LWB_STATE_DONE` state before the lwb's are freed
(`zil_commit` will not return untill all the lwb's are
`LWB_STATE_DONE`).

Further, this race condition is prevented in `zil_sync` by only calling
`zil_free_lwb` for lwb's that do not have their `lwb_buf` pointer set.
All lwb's not in the `LWB_STATE_DONE` state will have a non-null value
for this pointer; the pointer is only cleared in
`zil_lwb_flush_vdevs_done`, at which point the lwb's state will be
changed to `LWB_STATE_DONE`.

This race is present in `zil_suspend`, leading to this bug.

At first glance, it would appear as though this would not be true
because `zil_suspend` will call `zil_commit`, just like `zil_close`, but
the problem is that `zil_suspend` will set the zilog's `zl_suspend`
field prior to calling `zil_commit`. Further, in `zil_commit`, if
`zl_suspend` is set, `zil_commit` will take a special branch of logic
and use `txg_wait_synced` instead of performing the normal `zil_commit`
logic.

This call to `txg_wait_synced` might be good enough for the data to
reach disk safely before it returns, but it does not ensure that all
outstanding lwb's reach the `LWB_STATE_DONE` state before it returns.
This is because, if there's an lwb "stuck" in
`zil_commit_waiter_timeout`, waiting for it's lwb to timeout, it will
maintain a non-null value for it's `lwb_buf` field and thus `zil_sync`
will not free that lwb. Thus, even though the lwb's data is already on
disk, the lwb will be left lingering, waiting on the CV, and will
eventually timeout and be issued to disk even though the write is
unnesseary.

So, after `zil_commit` is called from `zil_suspend`, we incorrectly
assume that there are not outstanding lwb's, and proceed to free all
lwb's found on the zilog's lwb list. As a result, we free the lwb that
will later be used `zil_commit_waiter_timeout`.

Reviewed by: John Kennedy <jwk404@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFV r328225: 8603 rename zilog's "zl_writer_lock" to "zl_issuer_lock"
mav [Sun, 21 Jan 2018 23:11:20 +0000 (23:11 +0000)]
MFV r328225: 8603 rename zilog's "zl_writer_lock" to "zl_issuer_lock"

illumos/illumos-gate@cf07d3da9915c0d22da8f59e991639f819463cef

https://www.illumos.org/issues/8603:
  To help make the ZIL's code more understandable, it was suggested that
  the zilog_t's "zl_writer_lock" field should be renamed to "zl_issuer_lock".

Reviewed by: C Fraire <cfraire@me.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Author: Prakash Surya <prakash.surya@delphix.com>

6 years agoMFV r328220: 8677 Open-Context Channel Programs
mav [Sun, 21 Jan 2018 23:02:05 +0000 (23:02 +0000)]
MFV r328220: 8677 Open-Context Channel Programs

illumos/illumos-gate@a3b2868063897ff0083dea538f55f9873eec981f

https://www.illumos.org/issues/8677
  We want to be able to run channel programs outside of synching context.
  This would greatly improve performance of channel program that just gather
  information, as we won't have to wait for synching context anymore.

  This feature should introduce the following:
  - A new command line flag in "zfs program" to specify our intention to
  run in open context.
  - A new flag/option within the channel program ioctl which selects the
  context.
  - Appropriate error handling whenever we try a channel program in
  open-context that contains zfs.sync* expressions.
  - Documentation for the new feature in the manual pages.

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Chris Williamson <chris.williamson@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>

6 years agoRename rpi_pwm to bcm283x_pwm, and build it on armv[67] and arm64.
phk [Sun, 21 Jan 2018 21:27:41 +0000 (21:27 +0000)]
Rename rpi_pwm to bcm283x_pwm, and build it on armv[67] and arm64.

Truncate ratio if period is lowered.

Tested on Rpi2 and Rpi3.

Rpi3 requires DTB->DTS->edit->DTB hack

6 years agoiconv: adding missing break
eadler [Sun, 21 Jan 2018 21:09:08 +0000 (21:09 +0000)]
iconv: adding missing break

break is probably intended and correct,
but has no correctness implications due to is94 => is96

Reviewed by: cem, jilles
Reported by: swildner@DragonFlyBSD.org
MFC After: 1 week

6 years agoDefine a new __alloc_size2 attribute to complement the exiting support.
pfg [Sun, 21 Jan 2018 20:27:47 +0000 (20:27 +0000)]
Define a new __alloc_size2 attribute to complement the exiting support.

At least on GCC7 calling __alloc_size(x) twice is not equivalent to
calling using the attribute once with two arguments. The later is the
documented use in GCC documentation so add a new alloc_size(n, x)
alternative to cover for the few places where it is used: basically:
calloc(3), reallocarray(3) and  mallocarray(9).

Submitted by: Mark Millard
MFC after: 3 days
Reference:
http://docs.freebsd.org/cgi/mid.cgi?F227842D-6BE2-4680-82E7-07906AF61CD7

6 years agoAdd missing manufacturer/serial number string descriptors.
trasz [Sun, 21 Jan 2018 17:31:31 +0000 (17:31 +0000)]
Add missing manufacturer/serial number string descriptors.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoRevert r327828, r327949, r327953, r328016-r328026, r328041:
pfg [Sun, 21 Jan 2018 15:42:36 +0000 (15:42 +0000)]
Revert r327828, r327949, r327953, r328016-r328026, r328041:
Uses of mallocarray(9).

The use of mallocarray(9) has rocketed the required swap to build FreeBSD.
This is likely caused by the allocation size attributes which put extra pressure
on the compiler.

Given that most of these checks are superfluous we have to choose better
where to use mallocarray(9). We still have more uses of mallocarray(9) but
hopefully this is enough to bring swap usage to a reasonable level.

Reported by: wosch
PR: 225197

6 years agozfs: no need to check that size of zfs_cmd_t is not greater than IOCPARM_MAX
avg [Sun, 21 Jan 2018 11:19:18 +0000 (11:19 +0000)]
zfs: no need to check that size of zfs_cmd_t is not greater than IOCPARM_MAX

Nowadays we do not pass zfs_cmd_t directly through the ioctl interface.
Instead a small zfs_iocparm_t object is passed and the command is
explicitly copied in and out.  So, the check has become irrelevant.

MFC after: 3 weeks
Sponsored by: Panzura

6 years agolimits(1): fix always true condition
eadler [Sun, 21 Jan 2018 08:48:26 +0000 (08:48 +0000)]
limits(1): fix always true condition

Reviewed by: imp
MFC After: 1 week

6 years agoregex(3): Resolve issues with higher WARNS levels
kevans [Sun, 21 Jan 2018 04:57:29 +0000 (04:57 +0000)]
regex(3): Resolve issues with higher WARNS levels

libc is set for WARNS=2, but the incoming libregex will use WARNS=6.
Sprinkle some casts and (void)bc's to alleviate the warnings that come along
with the higher WARNS level.

These 'bc' parameters could be outright removed, but as of right now they
will be used in some parts of libregex land. Silence the warnings instead
rather than flip-flopping.

6 years agotermcap: add xterm-termite
eadler [Sat, 20 Jan 2018 22:24:45 +0000 (22:24 +0000)]
termcap: add xterm-termite

Obtained from: DragonFly
MFC After: 1 week

6 years agopsm: Log syncmask[1], not syncmask[0] twice
dumbbell [Sat, 20 Jan 2018 19:04:21 +0000 (19:04 +0000)]
psm: Log syncmask[1], not syncmask[0] twice

MFC after: 1 week

6 years agolimits(1): add missing break
eadler [Sat, 20 Jan 2018 18:27:00 +0000 (18:27 +0000)]
limits(1): add missing break

Reported by: swildner@DragonFlyBSD.org
MFC After: 1 week

6 years agoUse correct symbol name in r328202.
kib [Sat, 20 Jan 2018 18:05:14 +0000 (18:05 +0000)]
Use correct symbol name in r328202.

Sponsored by: The FreeBSD Foundation
MFC after: 11 days

6 years agoUse predefined symbol for the CR3.PCID mask.
kib [Sat, 20 Jan 2018 17:46:09 +0000 (17:46 +0000)]
Use predefined symbol for the CR3.PCID mask.

Sponsored by: The FreeBSD Foundation
MFC after: 11 days

6 years agoConvert extres/phy to kobj model.
mmel [Sat, 20 Jan 2018 17:02:17 +0000 (17:02 +0000)]
Convert extres/phy to kobj model.
Similarly as other extres pseudo-drivers, implement phy by using kobj model.
This detaches it from provider device, so single device driver can export
multiple different phys. Additionally, this  allows phy to be subclassed to
more specialized drivers, like is USB OTG phy, or PCIe phy with hot-plug
capability.

Tested by: manu (previous version, on Allwinner board)
MFC after: 1 month

6 years agoSilence the gcc warning: 'op' may be used uninitialized in this function
lwhsu [Sat, 20 Jan 2018 15:37:47 +0000 (15:37 +0000)]
Silence the gcc warning: 'op' may be used uninitialized in this function

Approved by: kevans

6 years agoxen: fix IDT setup after PTI
royger [Sat, 20 Jan 2018 14:59:37 +0000 (14:59 +0000)]
xen: fix IDT setup after PTI

On amd64 the IDT handler was not set correctly when using PTI.

While there also fix the selectors to SEL_KPL.

Obtained from: kib
MFC with: r328083

6 years agoclk: Get new parent freq after set_freq
manu [Sat, 20 Jan 2018 14:47:27 +0000 (14:47 +0000)]
clk: Get new parent freq after set_freq

During set_freq a clknode might have reparent (using a better parent that
have a higher frequency for example), before refreshing the cache, re-get
the parent frequency.

Reviewed by: mmel

6 years agoRemove unused index.
trasz [Sat, 20 Jan 2018 14:05:55 +0000 (14:05 +0000)]
Remove unused index.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoAdd missing SPDX tags; the rest of the license text is the same as in other
trasz [Sat, 20 Jan 2018 14:03:55 +0000 (14:03 +0000)]
Add missing SPDX tags; the rest of the license text is the same as in other
USB templates.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoAdd usb_template(4) to RPI-B kernel config. This is to support the USB OTG
trasz [Sat, 20 Jan 2018 14:00:07 +0000 (14:00 +0000)]
Add usb_template(4) to RPI-B kernel config.  This is to support the USB OTG
functionality on Raspberry Pi 0.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13924

6 years agoAdd sysctls to control device side USB identifiers. This makes it
trasz [Sat, 20 Jan 2018 13:58:34 +0000 (13:58 +0000)]
Add sysctls to control device side USB identifiers. This makes it
possible to change string and numeric vendor and product identifiers,
as well as anything else there might be to change for a particular
device side template, eg the MAC address.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13920

6 years agoAssign map->header values to avoid boundary checks.
kib [Sat, 20 Jan 2018 12:19:02 +0000 (12:19 +0000)]
Assign map->header values to avoid boundary checks.

In several places, entry start and end field are checked, after
excluding the possibility that the entry is map->header.  By assigning
max and min values to the start and end fields of map->header in
vm_map_init, the explicit map->header checks become unnecessary.

Submitted by: Doug Moore <dougm@rice.edu>
Reviewed by: alc, kib, markj (previous version)
Tested by: pho (previous version)
MFC after: 1 week
Differential Revision:  https://reviews.freebsd.org/D13735

6 years agopsm: Don't try to detect trackpoint packets if the Elantech device has none
dumbbell [Sat, 20 Jan 2018 11:21:22 +0000 (11:21 +0000)]
psm: Don't try to detect trackpoint packets if the Elantech device has none

This fixes a panic when `EVDEV_SUPPORT` is enabled: if a trackpoint
packet was detected but there was no trackpoint, we still tried to emit an
evdev event even though the associated relative evdev device (`evdev_r`)
was not initialized.

PR: 225339
MFC after: 1 week

6 years agopsm: Skip sync check when `PSM_CONFIG_NOCHECKSYNC` is set
dumbbell [Sat, 20 Jan 2018 11:02:18 +0000 (11:02 +0000)]
psm: Skip sync check when `PSM_CONFIG_NOCHECKSYNC` is set

In psmprobe(), we set the initial `syncmask` to the vendor default value
if the `PSM_CONFIG_NOCHECKSYNC` bit is unset. However, we currently only
set it for the Elantech touchpad later in psmattach(), thus `syncmask`
is always configured.

Now, we check `PSM_CONFIG_NOCHECKSYNC` and skip sync check if it is set.
This fixes Elantech touchpad support for units which have `hascrc` set.

To clarify that, when we log the `syncmask` and `syncbits` fields, also
mention if they are actually used.

Finally, when we set `PSM_CONFIG_NOCHECKSYNC`, clear `PSM_NEED_SYNCBITS`
flag.

PR: 225338
MFC after: 1 week

6 years agood(1): Fix mis-patch from r328188
kevans [Sat, 20 Jan 2018 03:50:56 +0000 (03:50 +0000)]
od(1): Fix mis-patch from r328188

od_test.sh got duplicated erroneously when it was added in r328188. Dedup.

6 years agood(1): Fix wrong output for some corner cases in multibyte locales.
kevans [Sat, 20 Jan 2018 02:49:32 +0000 (02:49 +0000)]
od(1): Fix wrong output for some corner cases in multibyte locales.

Restore the original character to print if we used the look-ahead
buffer, but that didn't help -- we either got an illegal sequence
or still can't complete.

PR: 224552
Submitted by: Yuri Pankov
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D13963

6 years agobhnd_chipc(4): Fix leak of child device ivars by explicitly deleting
landonf [Sat, 20 Jan 2018 01:55:34 +0000 (01:55 +0000)]
bhnd_chipc(4): Fix leak of child device ivars by explicitly deleting
any children prior to detach.

With the newbus child deletion ordering changes introduced in r307518,
parent devices are now detached (and their driver set to NULL) prior to
detaching and deleting child devices; child-related bus methods (e.g.
BUS_CHILD_DETACHED, BUS_CHILD_DELETED) are no longer be dispatched to the
parent device driver after it returns 0 (success) from DEVICE_DETACH.

Sponsored by:   The FreeBSD Foundation

6 years agobhnd/bwn(4): Define a bhnd(4) softmodem device class for the v.90 modem
landonf [Fri, 19 Jan 2018 22:43:08 +0000 (22:43 +0000)]
bhnd/bwn(4): Define a bhnd(4) softmodem device class for the v.90 modem
codec core, and mark the core as unpopulated on all BCM4306 bwn(4) devices.

Sponsored by: The FreeBSD Foundation

6 years agobwn(4): Add missing BCM4306 PCI IDs.
landonf [Fri, 19 Jan 2018 22:37:48 +0000 (22:37 +0000)]
bwn(4): Add missing BCM4306 PCI IDs.

Sponsored by: The FreeBSD Foundation

6 years agobwn(4): Fix DMA translation lookup on devices limited to 30-bit host
landonf [Fri, 19 Jan 2018 22:33:25 +0000 (22:33 +0000)]
bwn(4): Fix DMA translation lookup on devices limited to 30-bit host
addressing. The host addressing constraint does not apply to device address
space, and shouldn't be passed to bhnd_get_dma_translation() as the
maximum supported device address width.

Sponsored by: The FreeBSD Foundation

6 years agobhndb_pci(4): Implement bridge support for CardBus-attached devices.
landonf [Fri, 19 Jan 2018 22:22:02 +0000 (22:22 +0000)]
bhndb_pci(4): Implement bridge support for CardBus-attached devices.

 - Extend the probe method to accept devclasses that inherit from the pci
   devclass (e.g. cardbus).
 - Some BCM4306-based CardBus adapters appear to advertise 4K SPROM, but
   only the first 2K is mapped into BAR0. We can safely assume that the
   SPROM data fits within the first 2K of the SPROM, rather than rejecting
   the SPROM mapping as invalid.

Sponsored by: The FreeBSD Foundation

6 years agoOn AIM systems without a software-managed SLB, such as POWER9 systems using
nwhitehorn [Fri, 19 Jan 2018 22:19:50 +0000 (22:19 +0000)]
On AIM systems without a software-managed SLB, such as POWER9 systems using
either hardware segment tables or radix-tree-based page tables, do not try
to install SLB entries at trap boundaries.

6 years agoDefine PHYS_TO_DMAP() and DMAP_TO_PHYS() as panics on the architectures
nwhitehorn [Fri, 19 Jan 2018 22:17:13 +0000 (22:17 +0000)]
Define PHYS_TO_DMAP() and DMAP_TO_PHYS() as panics on the architectures
(i386 and arm) that never implement them. This allows the removal of
#ifdef PHYS_TO_DMAP on code otherwise protected by a runtime check on
PMAP_HAS_DMAP. It also fixes the build on ARM and i386 after I forgot an
#ifdef in r328168.

Reported by: Milan Obuch
Pointy hat to: me

6 years agoPTI: Trap if we returned to userspace with kernel (full) page table
kib [Fri, 19 Jan 2018 22:10:29 +0000 (22:10 +0000)]
PTI: Trap if we returned to userspace with kernel (full) page table
still active.

Map userspace portion of VA in the PTI kernel-mode page table as
non-executable. This way, if we ever miss reloading ucr3 into %cr3 on
the return to usermode, the process traps instead of executing in
potentially vulnerable setup.  Catch the condition of such trap and
verify user-mode %cr3, which is saved by page fault handler.

I peek this trick in some article about Linux implementation.

Reviewed by: alc, markj (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 12 days
DIfferential revision: https://reviews.freebsd.org/D13956

6 years agobhnd(4): fix a few bugs in pwrctl/fixed-clock device support.
landonf [Fri, 19 Jan 2018 21:58:48 +0000 (21:58 +0000)]
bhnd(4): fix a few bugs in pwrctl/fixed-clock device support.

 - Do not panic on siba(4) detach when the bhnd(4) bus calls
   bhnd_get_pmu_info() on a PMU-less device.
 - Fix bhnd_pwrctl attach/detach on fixed-clock devices:
    - Treat bhnd_pwrctl_updateclk() as a no-op on fixed-clock devices.
    - Use bhnd_pwrctl_updateclk() to perform the appropriate clock
      transition on detach.

Sponsored by: The FreeBSD Foundation

6 years agobhnd_chipc(4): Fix the assignment of non-wildcard child unit numbers
landonf [Fri, 19 Jan 2018 21:36:28 +0000 (21:36 +0000)]
bhnd_chipc(4): Fix the assignment of non-wildcard child unit numbers
introduced in r326102 and r326109; all chipc children should be added with
a wildcard unit (-1).

Sponsored by: The FreeBSD Foundation

6 years agodtc(1): Update to upstream ea3c233
kevans [Fri, 19 Jan 2018 21:20:24 +0000 (21:20 +0000)]
dtc(1): Update to upstream ea3c233

Highlights of this update:
- /__local_fixups__ is now generated to be GPL dtc and libfdt compliant
- Compiling with -@ will now cause dtc to assign phandles to all labelled
  nodes
- /include/ and /incbin/ now handle absolute paths correctly
- The manpage now has information about overlays, including how to apply
  them and how to generate them
- Syntactic sugar for overlays is now supported, allowing an overlay DTS
  like:

=
/dts-v1/;
/plugin/;

&foo {
    foo,status = "okay";
};
=

to generate a fragment targetting <&foo>.

6 years agoRename "index" variable to "idx" since gcc complains that it shadows
ae [Fri, 19 Jan 2018 20:33:47 +0000 (20:33 +0000)]
Rename "index" variable to "idx" since gcc complains that it shadows
index(3) function declaration.

Reported by: lwhsu
MFC after: 2 weeks

6 years agoFix compile errors in r328165
scottl [Fri, 19 Jan 2018 19:18:14 +0000 (19:18 +0000)]
Fix compile errors in r328165

Reported by: O. Hartmann
Sponsored by: Netflix

6 years agoRemove extra copy of bootinfo.c. It's a bit rotted copy of the one in
imp [Fri, 19 Jan 2018 19:09:17 +0000 (19:09 +0000)]
Remove extra copy of bootinfo.c. It's a bit rotted copy of the one in
efi/loader.

Differential Review: https://reviews.freebsd.org/D13986

6 years agoRemove SFBUF_OPTIONAL_DIRECT_MAP and such hacks, replacing them across the
nwhitehorn [Fri, 19 Jan 2018 17:46:31 +0000 (17:46 +0000)]
Remove SFBUF_OPTIONAL_DIRECT_MAP and such hacks, replacing them across the
kernel by PHYS_TO_DMAP() as previously present on amd64, arm64, riscv, and
powerpc64. This introduces a new MI macro (PMAP_HAS_DMAP) that can be
evaluated at runtime to determine if the architecture has a direct map;
if it does not (or does) unconditionally and PMAP_HAS_DMAP is either 0 or
1, the compiler can remove the conditional logic.

As part of this, implement PHYS_TO_DMAP() on sparc64 and mips64, which had
similar things but spelled differently. 32-bit MIPS has a partial direct-map
that maps poorly to this concept and is unchanged.

Reviewed by: kib
Suggestions from: marius, alc, kib
Runtime tested on: amd64, powerpc64, powerpc, mips64

6 years agoEnable KPTI by default on amd64 for non-AMD CPUs
emaste [Fri, 19 Jan 2018 15:42:34 +0000 (15:42 +0000)]
Enable KPTI by default on amd64 for non-AMD CPUs

Kernel Page Table Isolation (KPTI) was introduced in r328083 as a
mitigation for the 'Meltdown' vulnerability.  AMD CPUs are not affected,
per https://www.amd.com/en/corporate/speculative-execution:

    We believe AMD processors are not susceptible due to our use of
    privilege level protections within paging architecture and no
    mitigation is required.

Thus default KPTI to off for AMD CPUs, and to on for others.  This may
be refined later as we obtain more specific information on the sets of
CPUs that are and are not affected.

Submitted by: Mitchell Horne
Reviewed by: cem
Relnotes: Yes
Security: CVE-2017-5754
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13971

6 years agoRevert ABI breakage to CAM that came in with MMC/SD support in r320844.
scottl [Fri, 19 Jan 2018 15:32:27 +0000 (15:32 +0000)]
Revert ABI breakage to CAM that came in with MMC/SD support in r320844.
Make it possible to retrieve mmc parameters via the XPT_GET_ADVINFO
call instead.  Convert camcontrol to the new scheme.

Reviewed by: imp. kibab
Sponsored by: Netflix
Differential Revision: D13868

6 years agolibnv: Use mallocarray(9) for the nv_calloc.
pfg [Fri, 19 Jan 2018 14:50:53 +0000 (14:50 +0000)]
libnv: Use mallocarray(9) for the nv_calloc.

6 years agoAdd new USB ID to U3G driver.
hselasky [Fri, 19 Jan 2018 13:06:36 +0000 (13:06 +0000)]
Add new USB ID to U3G driver.

PR: 134299
MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoImprove support for USB based 3G/4G/5G dongles from Huawei.
hselasky [Fri, 19 Jan 2018 12:59:14 +0000 (12:59 +0000)]
Improve support for USB based 3G/4G/5G dongles from Huawei.

PR: 192345
Sponsored by: Mellanox Technologies

6 years agoAdd UDPLite support to ipfw(4).
ae [Fri, 19 Jan 2018 12:50:03 +0000 (12:50 +0000)]
Add UDPLite support to ipfw(4).

Now it is possible to use UDPLite's port numbers in rules,
create dynamic states for UDPLite packets and see "UDPLite" for matched
packets in log.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC

6 years agoAdd to bsnmpd(1) ability to specify multiple community strings with
ae [Fri, 19 Jan 2018 08:48:14 +0000 (08:48 +0000)]
Add to bsnmpd(1) ability to specify multiple community strings with
different access rights.

By default there are two community strings with index 1 and 2, one for
read-only access and second for read-write access:

  begemotSnmpdCommunityString.0.1 = $(read)
  begemotSnmpdCommunityString.0.2 = $(write)

Now it is possible to define additional community strings using different
indexes:

  begemotSnmpdCommunityString.0.3 = "SomeString1"
  begemotSnmpdCommunityPermission.0.3 = 1
  begemotSnmpdCommunityString.0.4 = "SomeString2"
  begemotSnmpdCommunityPermission.0.4 = 2
  begemotSnmpdCommunityString.0.5 = "SomeString3"
  begemotSnmpdCommunityString.0.6 = "SomeString4"

New attribute begemotSnmpdCommunityPermission can be used to specify access
rights: 1 means "read-only" access, 2 means "read-write" access. If
attribute is not specified for some index this means "read-only" rights.

Community strings must be unique, i.e. must not be the same for different
indexes.

Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D13785

6 years agoUnbreak i386 build
cem [Fri, 19 Jan 2018 04:34:06 +0000 (04:34 +0000)]
Unbreak i386 build

The logical result of a right shift >= the width of a type is zero, but our
compiler decides this is a warning (and thus, error).  Just remove ccp(4)
from i386.

Reported by: cy
Sponsored by: Dell EMC Isilon

6 years agoRecognize mchk_calltrap as a trapframe generator.
jhb [Fri, 19 Jan 2018 01:36:25 +0000 (01:36 +0000)]
Recognize mchk_calltrap as a trapframe generator.

Should have been included in r328157.

6 years agoUse a dedicated per-CPU stack for machine check exceptions.
jhb [Thu, 18 Jan 2018 23:50:21 +0000 (23:50 +0000)]
Use a dedicated per-CPU stack for machine check exceptions.

Similar to NMIs, machine check exceptions can fire at any time and are
not masked by IF.  This means that machine checks can fire when the
kstack is too deep to hold a trap frame, or at critical sections in
trap handlers when a user %gs is used with a kernel %cs.  Use the same
strategy used for NMIs of using a dedicated per-CPU stack configured
in IST 3.  Store the CPU's pcpu pointer at the stop of the stack so
that the machine check handler can reliably find the proper value for
%gs (also borrowed from NMIs).

This should also fix a similar issue with PTI with a MC# occurring
while the CPU is executing on the trampoline stack.

While here, bypass trap() entirely and just call mca_intr().  This
avoids a bogus call to kdb_reenter() (there's no reason to try to
reenter kdb if a MC# is raised).

Reviewed by: kib
Tested by: avg (on AMD without PTI)
Differential Revision: https://reviews.freebsd.org/D13962

6 years agostand: Move sections around to fix stand/ build with ld.lld on armv7
kevans [Thu, 18 Jan 2018 22:46:47 +0000 (22:46 +0000)]
stand: Move sections around to fix stand/ build with ld.lld on armv7

When building loader bits, lld fails with the following error:
"ld: error: section: .dynamic is not contiguous with other relro sections"
on both ubldr and EFI loader.

Move .dynamic up to make ld.lld happy, adjust .got as necessary for ubldr.

Tested on: OrangePi One (ld.lld, ubldr)
Tested on: Banana Pi-M3 (ld.lld, ubldr)
Tested on: qemu-armv7 (ld.lld, EFI)
Tested on: qemu-armv7 (ld.bfd, EFI)
Tested on: Raspberry Pi 2 (ld.bfd, ubldr) [manu]
Tested on: Banana Pi-M2 (ld.bfd, ubldr) [manu]
Reviewed by: andrew, emaste, imp
Differential Revision: https://reviews.freebsd.org/D13942

6 years agoNo need for the zero width space now that I put the comma in.
imp [Thu, 18 Jan 2018 22:23:16 +0000 (22:23 +0000)]
No need for the zero width space now that I put the comma in.

6 years agoMake igor happier with this file:
imp [Thu, 18 Jan 2018 22:20:30 +0000 (22:20 +0000)]
Make igor happier with this file:
o Don't use contractions.
o Add common after e.g. where needed

6 years agoRemove two no-longer-used labels from the NMI interrupt handler.
jhb [Thu, 18 Jan 2018 22:13:53 +0000 (22:13 +0000)]
Remove two no-longer-used labels from the NMI interrupt handler.

Reviewed by: kib

6 years agoAdd ccp(4): experimental driver for AMD Crypto Co-Processor
cem [Thu, 18 Jan 2018 22:01:30 +0000 (22:01 +0000)]
Add ccp(4): experimental driver for AMD Crypto Co-Processor

* Registers TRNG source for random(4)
* Finds available queues, LSBs; allocates static objects
* Allocates a shared MSI-X for all queues.  The hardware does not have
  separate interrupts per queue.  Working interrupt mode driver.
* Computes SHA hashes, HMAC.  Passes cryptotest.py, cryptocheck tests.
* Does AES-CBC, CTR mode, and XTS.  cryptotest.py and cryptocheck pass.
* Support for "authenc" (AES + HMAC).  (SHA1 seems to result in
  "unaligned" cleartext inputs from cryptocheck -- which the engine
  cannot handle.  SHA2 seems to work fine.)
* GCM passes for block-multiple AAD, input lengths

Largely based on ccr(4), part of cxgbe(4).

Rough performance averages on AMD Ryzen 1950X (4kB buffer):
aesni:      SHA1: ~8300 Mb/s    SHA256: ~8000 Mb/s
ccp:               ~630 Mb/s    SHA256:  ~660 Mb/s  SHA512:  ~700 Mb/s
cryptosoft:       ~1800 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

As you can see, performance is poor in comparison to aesni(4) and even
cryptosoft (due to high setup cost).  At a larger buffer size (128kB),
throughput is a little better (but still worse than aesni(4)):

aesni:      SHA1:~10400 Mb/s    SHA256: ~9950 Mb/s
ccp:              ~2200 Mb/s    SHA256: ~2600 Mb/s  SHA512: ~3800 Mb/s
cryptosoft:       ~1750 Mb/s    SHA256: ~1800 Mb/s  SHA512: ~2700 Mb/s

AES performance has a similar story:

aesni:      4kB: ~11250 Mb/s    128kB: ~11250 Mb/s
ccp:               ~350 Mb/s    128kB:  ~4600 Mb/s
cryptosoft:       ~1750 Mb/s    128kB:  ~1700 Mb/s

This driver is EXPERIMENTAL.  You should verify cryptographic results on
typical and corner case inputs from your application against a known- good
implementation.

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

6 years agoPull in r322106 from upstream llvm trunk (by Alexey Bataev):
dim [Thu, 18 Jan 2018 21:46:09 +0000 (21:46 +0000)]
Pull in r322106 from upstream llvm trunk (by Alexey Bataev):

  [COST]Fix PR35865: Fix cost model evaluation for shuffle on X86.

  Summary:
  If the vector type is transformed to non-vector single type, the
  compile may crash trying to get vector information about non-vector
  type.

  Reviewers: RKSimon, spatel, mkuper, hfinkel

  Subscribers: llvm-commits

  Differential Revision: https://reviews.llvm.org/D41862

This should fix "Not a vector MVT!" errors when building the
games/dhewm3 port.

Reported by: jbeich
PR: 225271

6 years agoPull in r322016 from upstream llvm trunk (by Sanjay Patel):
dim [Thu, 18 Jan 2018 21:44:07 +0000 (21:44 +0000)]
Pull in r322016 from upstream llvm trunk (by Sanjay Patel):

  [ValueTracking] remove overzealous assert

  The test is derived from a failing fuzz test:
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5008

  Credit to @rksimon for pointing out the problem.

This should fix "Bad flavor while matching min/max" errors when building
the graphics/libsixel and science/kst2 ports.

Reported by: jbeich
PR: 225268, 225269

6 years agolld: Fix incorrect physical address on self-referencing AT command.
emaste [Thu, 18 Jan 2018 21:39:59 +0000 (21:39 +0000)]
lld: Fix incorrect physical address on self-referencing AT command.

When a section placement (AT) command references the section itself,
the physical address of the section in the ELF header was calculated
incorrectly due to alignment happening right after the location
pointer's value was captured.

The problem was diagnosed and the first version of the patch written
by Erick Reyes.

Obtained from: LLVM r322421 by Rafael Espindola

6 years agolld: Handle parsing AT(ADDR(.foo-bar)).
emaste [Thu, 18 Jan 2018 21:39:19 +0000 (21:39 +0000)]
lld: Handle parsing AT(ADDR(.foo-bar)).

The problem we had with it is that anything inside an AT is an
expression, so we failed to parse the section name because of the - in
it.

Requested by: royger
Obtained from: LLVM r322801 by Rafael Espindola

6 years agolld: Fix for ld.lld does not accept "AT" syntax for declaring LMA region
emaste [Thu, 18 Jan 2018 21:38:21 +0000 (21:38 +0000)]
lld: Fix for ld.lld does not accept "AT" syntax for declaring LMA region

AT> lma_region expression allows to specify the memory region
for section load address.

Should fix [upstream LLVM] PR35684.

LLVM review: https://reviews.llvm.org/D41397

Obtained from: LLVM r322359 by George Rimar

6 years agoAdd Elf_Nhdr definition to match NetBSD, OpenBSD, Linux
cem [Thu, 18 Jan 2018 21:19:57 +0000 (21:19 +0000)]
Add Elf_Nhdr definition to match NetBSD, OpenBSD, Linux

The mesa port started to use this type and fails to build without it.

NetBSD: http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/exec_elf.h.diff?r1=1.26&r2=1.27&f=h
OpenBSD: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/sys/exec_elf.h.diff?r1=1.21&r2=1.22&f=h

PR: 225302
Reported by: Greg V <greg AT unrelenting.technology>
Sponsored by: Dell EMC Isilon