]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agovfs: convert struct mount counters to per-cpu
mjg [Mon, 16 Sep 2019 21:37:47 +0000 (21:37 +0000)]
vfs: convert struct mount counters to per-cpu

There are 3 counters modified all the time in this structure - one for
keeping the structure alive, one for preventing unmount and one for
tracking active writers. Exact values of these counters are very rarely
needed, which makes them a prime candidate for conversion to a per-cpu
scheme, resulting in much better performance.

Sample benchmark performing fstatfs (modifying 2 out of 3 counters) on
a 104-way 2 socket Skylake system:
before:   852393 ops/s
after:  76682077 ops/s

Reviewed by: kib, jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21637

4 years agovfs: manage mnt_writeopcount with atomics
mjg [Mon, 16 Sep 2019 21:33:16 +0000 (21:33 +0000)]
vfs: manage mnt_writeopcount with atomics

See r352424.

Reviewed by: kib, jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21575

4 years agovfs: manage mnt_lockref with atomics
mjg [Mon, 16 Sep 2019 21:32:21 +0000 (21:32 +0000)]
vfs: manage mnt_lockref with atomics

See r352424.

Reviewed by: kib, jeff
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21574

4 years agovfs: manage mnt_ref with atomics
mjg [Mon, 16 Sep 2019 21:31:02 +0000 (21:31 +0000)]
vfs: manage mnt_ref with atomics

New primitive is introduced to denote sections can operate locklessly
on aspects of struct mount, but which can also be disabled if necessary.
This provides an opportunity to start scaling common case modifications
while providing stable state of the struct when facing unmount, write
suspendion or other events.

mnt_ref is the first counter to start being managed in this manner with
the intent to make it per-cpu.

Reviewed by: kib, jeff
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21425

4 years agoAdd myself (dmgk) to calendar.freebsd
dmgk [Mon, 16 Sep 2019 20:43:20 +0000 (20:43 +0000)]
Add myself (dmgk) to calendar.freebsd

Approved by: tz (mentor)
Differential Revision: https://reviews.freebsd.org/D21675

4 years agoAdd myself (dmgk) as a ports committer
dmgk [Mon, 16 Sep 2019 20:41:37 +0000 (20:41 +0000)]
Add myself (dmgk) as a ports committer

Approved by: tz (mentor)
Differential Revision: https://reviews.freebsd.org/D21672

4 years agoloader: Malloc(0) should return NULL.
tsoome [Mon, 16 Sep 2019 20:28:08 +0000 (20:28 +0000)]
loader: Malloc(0) should return NULL.

We really should not allocate anything with size 0.

4 years agoloader_4th: scan_buffer can leave empty string on stack
tsoome [Mon, 16 Sep 2019 20:26:53 +0000 (20:26 +0000)]
loader_4th: scan_buffer can leave empty string on stack

When the file processing is done, we will have string with lenght 0 in stack and we will attempt to
allocate 0 bytes.

4 years agoFix an off-by-one error from r351961
asomers [Mon, 16 Sep 2019 16:41:01 +0000 (16:41 +0000)]
Fix an off-by-one error from r351961

That revision addressed a Coverity CID that could lead to a buffer overflow,
but it had an off-by-one error in the buffer size check.

Reported by: Coverity
Coverity CID: 1405530
MFC after: 3 days
MFC-With: 351961
Sponsored by: The FreeBSD Foundation

4 years agofusefs: initialize C++ classes the Coverity way
asomers [Mon, 16 Sep 2019 15:56:21 +0000 (15:56 +0000)]
fusefs: initialize C++ classes the Coverity way

Coverity complained that I wasn't initializing some class members until the
SetUp method.  Do it in the constructor instead.

Reported by: Coverity
Coverity CIDs: 14043521404378
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agofusefs: fix some minor Coverity CIDs in the tests
asomers [Mon, 16 Sep 2019 15:44:59 +0000 (15:44 +0000)]
fusefs: fix some minor Coverity CIDs in the tests

Where open(2) is expected to fail, the tests should assert or expect that
its return value is -1.  These tests all accepted too much but happened to
pass anyway.

Reported by: Coverity
Coverity CID: 1404512140437814045041404483
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoAssert that the refcount value is not VPRC_BLOCKED in vm_page_drop().
markj [Mon, 16 Sep 2019 15:16:48 +0000 (15:16 +0000)]
Assert that the refcount value is not VPRC_BLOCKED in vm_page_drop().

VPRC_BLOCKED is a refcount flag used to indicate that a thread is
tearing down mappings of a page.  When set, it causes attempts to wire a
page via a pmap lookup to fail.  It should never represent the last
reference to a page, so assert this.

Suggested by: kib
Reviewed by: alc, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21639

4 years agoFix a race in vm_page_dequeue_deferred_free() after r352110.
markj [Mon, 16 Sep 2019 15:12:49 +0000 (15:12 +0000)]
Fix a race in vm_page_dequeue_deferred_free() after r352110.

This function loaded the page's queue index before setting PGA_DEQUEUE.
In this window the page daemon may have deactivated the page, updating
its queue index.  Make the operation atomic using vm_page_pqstate_cmpset();
the page daemon will not modify the page once it observes that PGA_DEQUEUE
is set.

Reported and tested by: pho
Reviewed by: alc, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21639

4 years agoFix a page leak in vm_page_reclaim_run().
markj [Mon, 16 Sep 2019 15:09:31 +0000 (15:09 +0000)]
Fix a page leak in vm_page_reclaim_run().

After r352110 the attempt to remove mappings of the page being replaced
may fail if the page is wired.  In this case we must free the replacement
page.

Reviewed by: alc, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21639

4 years agoFix a couple of nits in r352110.
markj [Mon, 16 Sep 2019 15:06:19 +0000 (15:06 +0000)]
Fix a couple of nits in r352110.

- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by: alc
Reviewed by: alc, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21639

4 years agoRevert r352406, which contained changes I didn't intend to commit.
markj [Mon, 16 Sep 2019 15:04:45 +0000 (15:04 +0000)]
Revert r352406, which contained changes I didn't intend to commit.

4 years agoFix a couple of nits in r352110.
markj [Mon, 16 Sep 2019 15:03:12 +0000 (15:03 +0000)]
Fix a couple of nits in r352110.

- Remove a dead variable from the amd64 pmap_extract_and_hold().
- Fix grammar in the vm_page_wire man page.

Reported by: alc
Reviewed by: alc, kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21639

4 years agofusefs: fix some minor issues with fuse_vnode_setparent
asomers [Mon, 16 Sep 2019 14:51:49 +0000 (14:51 +0000)]
fusefs: fix some minor issues with fuse_vnode_setparent

* When unparenting a vnode, actually clear the flag. AFAIK this is basically
  a no-op because we only unparent a vnode when reclaiming it or when
  unlinking.

* There's no need to call fuse_vnode_setparent during reclaim, because we're
  about to free the vnode data anyway.

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

4 years agonfscl_loadattrcache: fix rest of the cases to not call
kib [Mon, 16 Sep 2019 13:26:27 +0000 (13:26 +0000)]
nfscl_loadattrcache: fix rest of the cases to not call
vnode_pager_setsize() under the node mutex.

r248567 moved some calls of vnode_pager_setsize() after the node lock
is unlocked, do the rest now.

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

4 years agosbuf(9): fix sbuf_drain_func typedef markup
yuripv [Mon, 16 Sep 2019 13:10:03 +0000 (13:10 +0000)]
sbuf(9): fix sbuf_drain_func typedef markup

Reviewed by: 0mp (previous version)
Differential Revision: https://reviews.freebsd.org/D21569

4 years agopkgbase: Move cap_mkdb from runtime to utilities POST-INSTALL
manu [Mon, 16 Sep 2019 12:51:30 +0000 (12:51 +0000)]
pkgbase: Move cap_mkdb from runtime to utilities POST-INSTALL

Since login and login.conf moved to the utilities packages move also
the post-install related commands.

Reported by: mj-mailinglist@gmx.de
Reviewed by: bapt

4 years agoFix 20190507 UPDATING entry
kevans [Mon, 16 Sep 2019 12:44:44 +0000 (12:44 +0000)]
Fix 20190507 UPDATING entry

The rc mechanism for loading kernel modules is actually called 'kld_list',
not 'kld_load'

Reported by: yuripv

4 years agoDon't write to memory outside of the allocated array for SACK blocks.
tuexen [Mon, 16 Sep 2019 08:18:05 +0000 (08:18 +0000)]
Don't write to memory outside of the allocated array for SACK blocks.

Obtained from: rrs@
MFC after: 3 days
Sponsored by: Netflix, Inc.

4 years agoDo not use our custom completion function, it is not needed anymore
bapt [Mon, 16 Sep 2019 07:31:59 +0000 (07:31 +0000)]
Do not use our custom completion function, it is not needed anymore

4 years agoIncrease the size of the send and receive buffers for YP client rpc
kib [Mon, 16 Sep 2019 06:42:01 +0000 (06:42 +0000)]
Increase the size of the send and receive buffers for YP client rpc
calls to max allowed UDP datagram size.

Since max allowed size both for keys and values where increased, the
old sizes of around 1K cause ypmatch(3) failures, while plain maps
fetches work.

The buffers were reduced in r34146 from default UDP rpcclient values
to 1024/2304 due to the key and value size being 1K.

Reviewed by: slavash
Sponsored by: Mellanox Technologies
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D21586

4 years agoDocument logic for __DEFAULT_DEPENDENT_OPTIONS
sjg [Mon, 16 Sep 2019 00:32:23 +0000 (00:32 +0000)]
Document logic for __DEFAULT_DEPENDENT_OPTIONS

Reviewed by: stevek
Differential Revision: https://reviews.freebsd.org/D21640

4 years agoRelax TX draining in ns8250_bus_transmit().
mav [Sun, 15 Sep 2019 23:56:39 +0000 (23:56 +0000)]
Relax TX draining in ns8250_bus_transmit().

Since TX interrupt is generated when THRE is set, wait for TEMT set means
wait for full character transmission time.  At low speeds that may take
awhile, burning CPU time while holding sc_hwmtx lock, also congested.

This is partial revert of r317659.

PR: 240121
MFC after: 2 weeks

4 years agoAvoid mixing cluster numbers and sector numbers. Makes code more readable.
delphij [Sun, 15 Sep 2019 19:41:54 +0000 (19:41 +0000)]
Avoid mixing cluster numbers and sector numbers. Makes code more readable.

Obtained from: NetBSD
MFC after: 2 weeks

4 years agoApply a runtime patch to the FDT data for imx6 to fix iomuxc problems.
ian [Sun, 15 Sep 2019 19:38:15 +0000 (19:38 +0000)]
Apply a runtime patch to the FDT data for imx6 to fix iomuxc problems.

The latest imported FDT data defines a node for an iomuxc-gpr device,
which we don't support (or need, right now) in addition to the usual
iomuxc device.  Unfortunately, the dts improperly assigns overlapping
ranges of mmio space to both devices.  The -gpr device is also a syscon
and simple_mfd device.

At runtime the simple_mfd driver attaches for the iomuxc-gpr node, then
when the real iomuxc driver comes along later, it fails to attach because
it tries to allocate its register space, and it's already partially in
use by the bogus instance of simple_mfd.

This change works around the problem by simply disabling the node for
the iomuxc-gpr device, since we don't need it for anything.

4 years agoWhen the IP layer calls back into the SCTP layer to perform the SCTP
tuexen [Sun, 15 Sep 2019 18:29:45 +0000 (18:29 +0000)]
When the IP layer calls back into the SCTP layer to perform the SCTP
checksum computation, do not assume that the IP header chain and the
SCTP common header are in contiguous memory although the SCTP lays
out the mbuf chains that way. If there are IP-level options inserted
by the IP layer, the constraint is not fulfilled anymore.

This issues was found by running syzkaller. Thanks to markj@ who is
running an instance which also provides kernel dumps. This allowed me
to find this issue.

MFC after: 3 days

4 years agorangelock: add rangelock_cookie_assert
kevans [Sun, 15 Sep 2019 02:59:53 +0000 (02:59 +0000)]
rangelock: add rangelock_cookie_assert

A future change to posixshm to add file sealing (in DIFF_21391[0] and child)
will move locking out of shm_dotruncate as kern_shm_open() will require the
lock to be held across the dotruncate until the seal is actually applied.
For this, the cookie is passed into shm_dotruncate_locked which asserts
RCA_WLOCKED.

[0] Name changed to protect the innocent, hopefully, from getting autoclosed
due to this reference...

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

4 years agoMake the ti_sysc device quiet. It's an internal utility pseudo-device
ian [Sun, 15 Sep 2019 01:02:01 +0000 (01:02 +0000)]
Make the ti_sysc device quiet.  It's an internal utility pseudo-device
that makes the upstream FDT data work right, so we don't need to see a
couple dozen instances of it spam the dmesg at boot time unless it's a
verbose boot.

4 years agoFix arm and aarch64 builds of libedit after r352275
dim [Sat, 14 Sep 2019 21:49:42 +0000 (21:49 +0000)]
Fix arm and aarch64 builds of libedit after r352275

On arm and arm64, where chars are unsigned by default, buildworld dies
with:

--- terminal.o ---
/usr/src/contrib/libedit/terminal.c:569:41: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     el->el_cursor.v][where & 0370] !=
                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/src/contrib/libedit/terminal.c:659:28: error: comparison of
integers of different signs: 'wint_t' (aka 'int') and 'wchar_t' (aka
'unsigned int') [-Werror,-Wsign-compare]
                                     [el->el_cursor.h] == MB_FILL_CHAR)
                                     ~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~

Fix this by making MB_FILL_CHAR a wint_t, so no casting is needed.

Note that in https://reviews.freebsd.org/D21584 this was also proposed
by Yuichiro Naito <naito.yuichiro_gmail.com>.

Reviewed by: bapt
Subscribers: naito.yuichiro_gmail.com, ml_vishwin.info
MFC after: 3 weeks
X-MFC-With: r352275
Differential Revision: https://reviews.freebsd.org/D21657

4 years agoFix aux_info corruption in rtld direct execution mode.
bdragon [Sat, 14 Sep 2019 21:18:10 +0000 (21:18 +0000)]
Fix aux_info corruption in rtld direct execution mode.

After the aux vector is moved, it is necessary to re-digest aux_info so the
pointers are updated to the new locations.

This was causing thread creation to fail on powerpc64 when using direct
execution due to a nonsense value being read for aux_info[AT_STACKPROT].

Approved by: jhibbits (mentor)
Differential Revision: https://reviews.freebsd.org/D21656

4 years agoCreate a mechanism for encoding a system errno into the IIC_Exxxxx space.
ian [Sat, 14 Sep 2019 19:33:36 +0000 (19:33 +0000)]
Create a mechanism for encoding a system errno into the IIC_Exxxxx space.

Errors are communicated between the i2c controller layer and upper layers
(iicbus and slave device drivers) using a set of IIC_Exxxxxx constants which
effectively define a private number space separate from (and having values
that conflict with) the system errno number space. Sometimes it is necessary
to report a plain old system error (especially EINTR) from the controller or
bus layer and have that value make it back across the syscall interface
intact.

I initially considered replicating a few "crucial" errno values with similar
names and new numbers, e.g., IIC_EINTR, IIC_ERESTART, etc. It seemed like
that had the potential to grow over time until many of the errno names were
duplicated into the IIC_Exxxxx space.

So instead, this defines a mechanism to "encode" an errno into the IIC_Exxxx
space by setting the high bit and putting the errno into the lower-order
bits; a new errno2iic() function does this. The existing iic2errno()
recognizes the encoded values and extracts the original errno out of the
encoded value. An interesting wrinkle occurs with the pseudo-error values
such as ERESTART -- they aleady have the high bit set, and turning it off
would be the wrong thing to do. Instead, iic2errno() recognizes that lots of
high bits are on (i.e., it's a negative number near to zero) and just
returns that value as-is.

Thus, existing drivers continue to work without needing any changes, and
there is now a way to return errno values from the lower layers. The first
use of that is in iicbus_poll() which does mtx_sleep() with the PCATCH flag,
and needs to return the errno from that up the call chain.

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

4 years agoIntroduce arb(3), the Array-based Red-Black Tree macros: similar
trasz [Sat, 14 Sep 2019 19:23:46 +0000 (19:23 +0000)]
Introduce arb(3), the Array-based Red-Black Tree macros: similar
to the traditional tree(3) RB trees, but using an array (preallocated,
linear chunk of memory) to store the tree.

This avoids allocation overhead, improves memory locality,
and makes it trivially easy to share/transfer/copy the entire tree
without the need for marshalling.  The downside is that the size
is fixed at initialization time; there is no mechanism to resize
it.

This is one of the dependencies for the new stats(3) framework
(https://reviews.freebsd.org/D20477).

Reviewed by: bcr (man pages), markj
Discussed with: cem
MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix
Obtained from: Netflix
Differential Revision: https://reviews.freebsd.org/D20324

4 years agoMake pseudofs(9) create directory entries in order, instead
trasz [Sat, 14 Sep 2019 19:16:07 +0000 (19:16 +0000)]
Make pseudofs(9) create directory entries in order, instead
of the reverse.

This fixes Linux sysctl(8) binary - it assumes the first two
directory entries are always "." and "..". There might be other
Linux apps affected by this.

NB it might be a good idea to rewrite it using queue(3).

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

4 years agoInclude <lock.h>, required to use spinlocks in this code.
ian [Sat, 14 Sep 2019 18:20:14 +0000 (18:20 +0000)]
Include <lock.h>, required to use spinlocks in this code.

4 years agoamend r:352320 Fix date for sg@
sg [Sat, 14 Sep 2019 14:26:30 +0000 (14:26 +0000)]
amend r:352320 Fix date for sg@

Approved by:    bcr (mentor)

4 years agoSet bcr@ mentor for sg@
sg [Sat, 14 Sep 2019 12:40:46 +0000 (12:40 +0000)]
Set bcr@ mentor for sg@

Approved by:    bcr (mentor)

4 years agoImprove the description of big5(5)
lwhsu [Sat, 14 Sep 2019 08:15:16 +0000 (08:15 +0000)]
Improve the description of big5(5)

- Fix the statement that big5 is a de facto standard of Traditional Chinese
  text [1]
- Add a BUGS section describes the problem of big5 and suggests use utf8

PR: 189095
Submitted by: Brennan Vincent <brennan@umanwizard.com> [1]
Reviewed by: Ting-Wei Lan <lantw44@gmail.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21622

4 years agolualoader: Add reload-conf loader command
kevans [Sat, 14 Sep 2019 03:38:18 +0000 (03:38 +0000)]
lualoader: Add reload-conf loader command

This command will trigger a reload of the configuration from disk. This is
useful if you've changed currdev from recovery media to local disk as much
as I have over the past ~2 hours and are tired of the extra keystrokes.

This is really just a glorified shortcut, but reload-conf is likely easier
to remember for other people and does save some keystrokes when reloading
the configuration. It is also resilient to the underlying config method
changing interface, but this is unlikely to happen.

MFC after: 1 week

4 years agopowerpc64/powernv: Add opal NVRAM driver for PowerNV systems
jhibbits [Sat, 14 Sep 2019 03:30:34 +0000 (03:30 +0000)]
powerpc64/powernv: Add opal NVRAM driver for PowerNV systems

Add a very basic NVRAM driver for OPAL which can be used by the IBM
powerpc-utils nvram utility, not to be confused with the base nvram utility,
which only operates on powermac_nvram.

The IBM utility handles all partitions itself, treating the nvram device as
a plain store.

An alternative would be to manage partitions in the kernel, and augment the
base nvram utility to deal with different backing stores, but that
complicates the driver significantly.  Instead, present the same interface
IBM's utlity expects, and we get the usage for free.

Tested by: bdragon

4 years agoAdd a "count_until_fail" option to gnop, which says to start failing
chs [Fri, 13 Sep 2019 23:03:56 +0000 (23:03 +0000)]
Add a "count_until_fail" option to gnop, which says to start failing
I/O requests after the given number have been allowed though.

Approved by:    imp (mentor)
Reviewed by:    rpokala kib 0mp mckusick
Sponsored by:   Netflix
Differential Revision:  https://reviews.freebsd.org/D21593

4 years agoDrivers may pass runt packets to filter. This is okay.
glebius [Fri, 13 Sep 2019 22:36:04 +0000 (22:36 +0000)]
Drivers may pass runt packets to filter. This is okay.

Reviewed by: gallatin

4 years agoInclude <stdint.h> in unwind-arm.h, since it uses uint32_t and uint64_t
dim [Fri, 13 Sep 2019 21:00:19 +0000 (21:00 +0000)]
Include <stdint.h> in unwind-arm.h, since it uses uint32_t and uint64_t
in various declarations.

Otherwise, depending on how unwind-arm.h is included from other source
files, the compiler may complain that uint32_t and uint64_t are unknown
types.

MFC after: 3 days

4 years agoAdd RELNOTES comment for r352304 discussing removing default mlock()
cy [Fri, 13 Sep 2019 20:21:59 +0000 (20:21 +0000)]
Add RELNOTES comment for r352304 discussing removing default mlock()
for ntpd.

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

4 years agoNo longer mlock() ntpd pages by default in memory thus allowing its
cy [Fri, 13 Sep 2019 20:20:05 +0000 (20:20 +0000)]
No longer mlock() ntpd pages by default in memory thus allowing its
pages to page as necessary.

To restore historic BSD behaviour add the following to ntp.conf:
rlimit memlock 32

Discussed on: freebsd-current@ between Sept 6-9, 2019
Reported by: Users using ASLR with stack gap != 0
Reviewed by: ian, kib, rgrimes (all previous versions)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21581

4 years agoriscv trap_pfault: remove unneeded hold of the process around vm_fault() call.
kib [Fri, 13 Sep 2019 20:17:14 +0000 (20:17 +0000)]
riscv trap_pfault: remove unneeded hold of the process around vm_fault() call.

This is re-appearance of the nop code removed from other arches in r287625.

Reviewed by: alc (as part of the larger patch), markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
DIfferential revision: https://reviews.freebsd.org/D21645

4 years agoAdd support for Intel Stratix 10 platform.
br [Fri, 13 Sep 2019 16:50:57 +0000 (16:50 +0000)]
Add support for Intel Stratix 10 platform.

Intel Stratix 10 SoC includes a quad-core arm64 cluster and FPGA fabric.

This adds support for reconfiguring FPGA.

Accessing FPGA core of this SoC require the level of privilege EL3,
while kernel runs in EL1 (lower) level of privilege.

This provides an Intel service layer interface that uses SMCCC to pass
queries to the secure-monitor (EL3).

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21454

4 years agoAdd generic arm/arm64 secure-monitor SMCCC interface and switch
br [Fri, 13 Sep 2019 15:56:33 +0000 (15:56 +0000)]
Add generic arm/arm64 secure-monitor SMCCC interface and switch
PSCI code to use it.

This interface will also be used by Intel Stratix 10 platform.

This was not tested on arm due to lack of PSCI-enabled arm hardware
lying around.

Reviewed by: andrew
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21439

4 years agovfs: release usecount using fetchadd
mjg [Fri, 13 Sep 2019 15:49:04 +0000 (15:49 +0000)]
vfs: release usecount using fetchadd

1. If we release the last usecount we take ownership of the hold count, which
means the vnode will remain allocated until we vdrop it.
2. If someone else vrefs they will find no usecount and will proceed to add
their own hold count.
3. No code has a problem with v_usecount transitioning to 0 without the
interlock

These facts combined mean we can fetchadd instead of having a cmpset loop.

Reviewed by: kib (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21528

4 years agoRemove remnant from the pre LIBADD era
bapt [Fri, 13 Sep 2019 14:51:00 +0000 (14:51 +0000)]
Remove remnant from the pre LIBADD era

4 years agoUpdate libedit to a snapshot from 2019-09-10
bapt [Fri, 13 Sep 2019 06:50:02 +0000 (06:50 +0000)]
Update libedit to a snapshot from 2019-09-10

This version bring many fixes regarding unicode support
It also adds proper support for filename completion (we do not need our custom
patches anymore)
Improves the libreadline compatibility

Note that the same work was done by Yuichiro Naito in
https://reviews.freebsd.org/D21196 the main difference is in this case we have
reimported libedit in contrib to fix a long standing mess in the previous merges
which prevented a proper update workflow. (discussed long ago with pfg@)

The only difference with upstream libedit is we have added a compatibility shim
for the _elf_fn_sh_complete function which we previously added to support quoting
in filename completion and is not needed anymore.
This was added to continue supported old /bin/sh binaries and not break backward
compatibility (as discussed with jilles@)

Reviewed by: Yuichiro Naito <naito.yuichiro_gmail.com>
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D21584

4 years agoInsert proper copyright/license headers
bapt [Fri, 13 Sep 2019 06:36:24 +0000 (06:36 +0000)]
Insert proper copyright/license headers

Those scripts are without copyright and license assignement since their creation
After grabbing information from The various authors and contributors assign
proper license header and copyrights.

This has been reported by yuripv in his work on integrating those in Illumos!

Reported by: yuripv
Discussed with: marino, edwin
MFC after: 3 days

4 years agomtree -O: Fix not descending on hash collisions
bdrewery [Thu, 12 Sep 2019 20:46:46 +0000 (20:46 +0000)]
mtree -O: Fix not descending on hash collisions

MFC after: 2 weeks
Obtained from: NetBSD (nakayama)

4 years ago[jail] removal by jid doesn't trigger pre/post stop scripts
mizhka [Thu, 12 Sep 2019 18:53:29 +0000 (18:53 +0000)]
[jail] removal by jid doesn't trigger pre/post stop scripts

This commit fixes bug: command "jail -r" didn't trigger pre/post stop
commands (and others) defined in config file if jid is specified insted of
name. Also it adds basic tests for usr.sbin/jail to avoid regression.

Reviewed by: jamie, kevans, ray
MFC after:      5 days
Differential Revision: https://reviews.freebsd.org/D21328

4 years agomtree -c: Fix username logic when getlogin(3) fails.
bdrewery [Thu, 12 Sep 2019 18:51:59 +0000 (18:51 +0000)]
mtree -c: Fix username logic when getlogin(3) fails.

Obtained from: NetBSD (Credit to Sascha Wildner with DragonFlyBSD)
MFC after: 2 weeks

4 years agomtree: Fix -f -f not considering type changes.
bdrewery [Thu, 12 Sep 2019 18:44:48 +0000 (18:44 +0000)]
mtree: Fix -f -f not considering type changes.

This only lists the changed type and not other attributes so that it
matches the behavior of -C as done in r66747 for fmtree. The NetBSD
-ff implementation was copied from fmtree.

Reviewed by: imp
MFC after: 2 weeks
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D21623

4 years ago[Bug 240473] add support of Ralink RT5390R Wireless Card
mizhka [Thu, 12 Sep 2019 18:37:26 +0000 (18:37 +0000)]
[Bug 240473] add support of Ralink RT5390R Wireless Card

This commit adds PCI ID of Ralink RT5390R into ids table of driver ral.
Tests show stability of card during day. Network speed is reasonable (
around several megabytes per second).

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240473
Reported by: zetrotrack000@gmail.com
Reviewed by: ray
Approved by: ray
MFC after: 5 days
Differential Revision:  https://reviews.freebsd.org/D21604

4 years agoarm64: connect Linuxulator to the build
emaste [Thu, 12 Sep 2019 18:14:44 +0000 (18:14 +0000)]
arm64: connect Linuxulator to the build

More work needs to be done, but it is capable of running basic
statically or dynamically linked Linux/arm64 binaries.

Relnotes: Yes
Sponsored by: The FreeBSD Foundation

4 years agoRemove Tagged Command Queuing feature reporting.
mav [Thu, 12 Sep 2019 17:42:37 +0000 (17:42 +0000)]
Remove Tagged Command Queuing feature reporting.

I never saw those devices myself, FreeBSD never supported them, and it is
officially obsolete since ACS-2 specification.

MFC after: 3 days

4 years agoReport Trusted Computing feature set support.
mav [Thu, 12 Sep 2019 17:20:51 +0000 (17:20 +0000)]
Report Trusted Computing feature set support.

It practically means the device is SED.

MFC after: 3 days

4 years agoRemove a redundant NULL pointer check in cpuset_modify_domain().
markj [Thu, 12 Sep 2019 16:47:38 +0000 (16:47 +0000)]
Remove a redundant NULL pointer check in cpuset_modify_domain().

cpuset_getroot() is guaranteed to return a non-NULL pointer.

Reported by: Mark Millard <marklmi@yahoo.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years ago[PPC64] Add ifunc support in libcsu
luporl [Thu, 12 Sep 2019 16:45:07 +0000 (16:45 +0000)]
[PPC64] Add ifunc support in libcsu

When ifuncs are used in statically linked binaries, the C runtime
must perform the needed dynamic relocations, to make calls to ifuncs
work correctly.

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

4 years agoUse REFCOUNT_COUNT() to obtain refcount where appropriate.
hselasky [Thu, 12 Sep 2019 16:26:59 +0000 (16:26 +0000)]
Use REFCOUNT_COUNT() to obtain refcount where appropriate.
Refcount waiting will set some flag bits in the refcount value.
Make sure these bits get cleared by using the REFCOUNT_COUNT()
macro to obtain the actual refcount.

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

4 years agoUse %u instead of %d to print unsigned integer.
hselasky [Thu, 12 Sep 2019 16:20:03 +0000 (16:20 +0000)]
Use %u instead of %d to print unsigned integer.
While at it remove an empty line.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix for undefined behaviour.
hselasky [Thu, 12 Sep 2019 15:57:49 +0000 (15:57 +0000)]
Fix for undefined behaviour.
Left shift of 1 by 31 places cannot be represented in type 'int'.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoGet the readline header from the installed header instead of the from the source
bapt [Thu, 12 Sep 2019 15:50:14 +0000 (15:50 +0000)]
Get the readline header from the installed header instead of the from the source
location.

4 years agoGet the readline header from the installed header instead of the from the source
bapt [Thu, 12 Sep 2019 15:46:58 +0000 (15:46 +0000)]
Get the readline header from the installed header instead of the from the source
location.

With newer import of libedit, the path to be able to access readline/readline.h
will also include header which name will conflict with some expected by ntp in
another path and end up breaking the build.

4 years agoRemove useless extra definition of libedit flags
bapt [Thu, 12 Sep 2019 15:44:53 +0000 (15:44 +0000)]
Remove useless extra definition of libedit flags

Note that all the line editor part is done in the libntp

4 years agoSIOCSIFNAME: Do nothing if we're not actually changing
kevans [Thu, 12 Sep 2019 15:36:48 +0000 (15:36 +0000)]
SIOCSIFNAME: Do nothing if we're not actually changing

Instead of throwing EEXIST, just succeed if the name isn't actually
changing. We don't need to trigger departure or any of that because there's
no change from consumers' perspective.

PR: 240539
Reviewed by: brooks
MFC after: 5 days
Differential Revision: https://reviews.freebsd.org/D21618

4 years agoFollow up r352244: kenv: tighten up assertions
kevans [Thu, 12 Sep 2019 14:34:46 +0000 (14:34 +0000)]
Follow up r352244: kenv: tighten up assertions

As I like to forget: static kenv var formatting is actually such that an
empty environment would be double null bytes. We should make sure that a
non-zero buffer has at least enough for this, though most of the current
usage is with a 4k buffer.

4 years agokenv: assert that an empty static buffer passed in is "empty"
kevans [Thu, 12 Sep 2019 13:51:43 +0000 (13:51 +0000)]
kenv: assert that an empty static buffer passed in is "empty"

Garbage in the passed-in buffer can cause problems if any attempts to read
the kenv are inadvertently made between init_static_kenv and the first
kern_setenv -- assuming there is one.

This is cheap and easy, so do it. This also helps rule out some class of
bugs as one tries to debug; tunables fetch from the static environment up
until SI_SUB_KMEM + 1, and many of these buffers are global ~4k buffers that
rely on BSS clearing while others just grab a page of free memory and use it
(e.g. xen).

4 years agoig4(4): Fix SDA HOLD time set too low on Skylake controllers
wulf [Thu, 12 Sep 2019 12:33:09 +0000 (12:33 +0000)]
ig4(4): Fix SDA HOLD time set too low on Skylake controllers

Execution of "Soft reset" command (IG4_REG_RESETS_SKL) at controller init
stage sets SDA_HOLD register value to 0x0001 which is often too low for
normal operation.

Set SDA_HOLD back to 28 after reset to restore controller functionality.

PR: 240339
Reported by: imp, GregV, et al.
MFC after: 3 days

4 years agoRemove usesless readline compat includes which will reinclude readline.h
bapt [Thu, 12 Sep 2019 08:54:48 +0000 (08:54 +0000)]
Remove usesless readline compat includes which will reinclude readline.h
itself.

This simplifies the upcoming update to newer libedit.

4 years agoImport tzdata 2019c
philip [Thu, 12 Sep 2019 00:19:16 +0000 (00:19 +0000)]
Import tzdata 2019c

Changes: https://github.com/eggert/tz/blob/2019c/NEWS

MFC after: 3 days

4 years agobuf: Add B_INVALONERR flag to discard data
cem [Wed, 11 Sep 2019 21:24:14 +0000 (21:24 +0000)]
buf: Add B_INVALONERR flag to discard data

Setting the B_INVALONERR flag before a synchronous write causes the buf
cache to forcibly invalidate contents if the write fails (BIO_ERROR).

This is intended to be used to allow layers above the buffer cache to make
more informed decisions about when discarding dirty buffers without
successful write is acceptable.

As a proof of concept, use in msdosfs to handle failures to mark the on-disk
'dirty' bit during rw mount or ro->rw update.

Extending this to other filesystems is left as future work.

PR: 210316
Reviewed by: kib (with objections)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21539

4 years agogetsockopt.2: clarify that SO_TIMESTAMP is not 100% reliable
asomers [Wed, 11 Sep 2019 19:48:32 +0000 (19:48 +0000)]
getsockopt.2: clarify that SO_TIMESTAMP is not 100% reliable

When SO_TIMESTAMP is set, the kernel will attempt to attach a timestamp as
ancillary data to each IP datagram that is received on the socket. However,
it may fail, for example due to insufficient memory. In that case the
packet will still be received but not timestamp will be attached.

Reviewed by: kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21607

4 years agofusefs: Fix iosize for FUSE_WRITE in 7.8 compat mode
asomers [Wed, 11 Sep 2019 19:29:40 +0000 (19:29 +0000)]
fusefs: Fix iosize for FUSE_WRITE in 7.8 compat mode

When communicating with a FUSE server that implements version 7.8 (or older)
of the FUSE protocol, the FUSE_WRITE request structure is 16 bytes shorter
than normal. The protocol version check wasn't applied universally, leading
to an extra 16 bytes being sent to such servers. The extra bytes were
allocated and bzero()d, so there was no information disclosure.

Reviewed by: emaste
MFC after: 3 days
MFC-With: r350665
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21557

4 years agoping: Verify whether a datagram timestamp was actually received.
asomers [Wed, 11 Sep 2019 18:54:45 +0000 (18:54 +0000)]
ping: Verify whether a datagram timestamp was actually received.

ping(8) uses SO_TIMESTAMP, which attaches a timestamp to each IP datagram at
the time it's received by the kernel.  Except that occasionally it doesn't.
Add a check to see whether such a timestamp was actually set before trying
to read it.  This fixes segfaults that can happen when the kernel doesn't
attach a timestamp.

The bug has always existed, but prior to r351461 it manifested as an
implausible round-trip-time, not a segfault.

Reported by: pho
MFC after: 3 days
MFC-With: 351461

4 years agoAvoid unneeded call to arc4random() in syncache_add()
gallatin [Wed, 11 Sep 2019 18:48:26 +0000 (18:48 +0000)]
Avoid unneeded call to arc4random() in syncache_add()

Don't call arc4random() unconditionally to initialize sc_iss, and
then when syncookies are enabled, just overwrite it with the
return value from from syncookie_generate(). Instead, only call
arc4random() to initialize sc_iss when syncookies are not
enabled.

Note that on a system under a syn flood attack, arc4random()
becomes quite expensive, and the chacha_poly crypto that it calls
is one of the more expensive things happening on the
system. Removing this unneeded arc4random() call reduces CPU from
about 40% to about 35% in my test scenario (Broadwell Xeon, 6Mpps
syn flood attack).

Reviewed by: rrs, tuxen, bz
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21591

4 years agoOnly skip problematic test in CI env.
lwhsu [Wed, 11 Sep 2019 18:40:05 +0000 (18:40 +0000)]
Only skip problematic test in CI env.

PR: 237450
Sponsored by: The FreeBSD Foundation

4 years agoping: fix a string in an error message
asomers [Wed, 11 Sep 2019 18:08:40 +0000 (18:08 +0000)]
ping: fix a string in an error message

MFC after: 3 days

4 years agoriscv: Add missing header
kp [Wed, 11 Sep 2019 18:07:15 +0000 (18:07 +0000)]
riscv: Add missing header

r352218 missing an include statement, causing the build to fail.

Submitted by: Nicholas O'Brien (nickisobrien_gmail.com)
Sponsored by: Axiado

4 years agoUpdate comments and ordering in linux*_dummy.c
emaste [Wed, 11 Sep 2019 17:56:48 +0000 (17:56 +0000)]
Update comments and ordering in linux*_dummy.c

- sort alphabetically
- getcpu arrived in Linux 2.6.19
- fanotify_* arrived in 2.6.36

4 years agolinuxulator: add stub arm64 linux_genassym.c
emaste [Wed, 11 Sep 2019 17:29:44 +0000 (17:29 +0000)]
linuxulator: add stub arm64 linux_genassym.c

This will be fleshed out in the future but allows us to build the arm64
linuxulator using the same infrastructure as x86.

4 years agolinuxulator: memfd_create first appeared in Linux 3.17
emaste [Wed, 11 Sep 2019 17:05:49 +0000 (17:05 +0000)]
linuxulator: memfd_create first appeared in Linux 3.17

Reference: http://man7.org/linux/man-pages/man2/memfd_create.2.html

4 years agolinuxulator: seccomp syscall first appeared in Linux 3.17
emaste [Wed, 11 Sep 2019 17:04:13 +0000 (17:04 +0000)]
linuxulator: seccomp syscall first appeared in Linux 3.17

Reference: http://man7.org/linux/man-pages/man2/seccomp.2.html

4 years agoAvoid the use of the non-portable -D argument to ls.
brooks [Wed, 11 Sep 2019 17:01:31 +0000 (17:01 +0000)]
Avoid the use of the non-portable -D argument to ls.

This was used to store the mtime of the source file in a commment in a
generated header file.  This is of little-to-no diagnostic value and
the result doesn't even end up in the source tree.

Reported by: arichardson
Reviewed by: arichardson
MFC after: 1 days
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21605

4 years agoTemporarily skip flakey test case sys.kern.ptrace_test.ptrace__getppid
lwhsu [Wed, 11 Sep 2019 16:24:03 +0000 (16:24 +0000)]
Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__getppid

PR: 240510
Sponsored by: The FreeBSD Foundation

4 years agoriscv: Small fix to CPU compatibility identification
kp [Wed, 11 Sep 2019 16:16:53 +0000 (16:16 +0000)]
riscv: Small fix to CPU compatibility identification

fdt_is_compatible_strict() inspects the first compatible property.
We need to inspect the following properties for 'riscv'.
ofw_bus_node_is_compatible() does a recursive search.

This patch fixes "Can't find CPU" error message when bootverbose = true.

Submitted by: Nicholas O'Brien (nickisobrien_gmail.com)
Reviewed by: philip, kp
Sponsored by: Axiado
Differential Revision: https://reviews.freebsd.org/D21576

4 years agolocale: initialize variables to make gcc happy
yuripv [Wed, 11 Sep 2019 16:00:03 +0000 (16:00 +0000)]
locale: initialize variables to make gcc happy

Reported by: jenkins

4 years agoWith the recent commit of ktls, we no longer have a
rrs [Wed, 11 Sep 2019 15:41:36 +0000 (15:41 +0000)]
With the recent commit of ktls, we no longer have a
sb_tls_flags, its just the sb_flags. Also the ratelimit
code, now that the defintion is in sockbuf.h, does not
need the ktls.h file (or its predecessor).

Sponsored by: Netflix Inc

4 years agolocale: more output fixes
yuripv [Wed, 11 Sep 2019 15:39:28 +0000 (15:39 +0000)]
locale: more output fixes

- make abday, day, abmon, mon, am_pm output quoting match linux
- workaround localeconv() issue for mon_grouping and grouping (PR172215)
- for other values not available in default locale, output -1 instead of
  127 (CHAR_MAX) as returned by localeconv()

With these changes, output of `locale` and `locale -k` for all keywords
specified by POSIX exactly matches the linux one.

PR: 237752
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D21599

4 years agofw_stub.awk: use @generated tag in generated files
emaste [Wed, 11 Sep 2019 13:35:22 +0000 (13:35 +0000)]
fw_stub.awk: use @generated tag in generated files

Multiple tools use @generated to identify generated files (for example,
in a review Phabricator will by default hide diffs in enerated files).
Use the @generated tag in makesyscalls.sh as we've done for other
generated files.

4 years agoAssume all the short args have optional args so allocate space for the
imp [Wed, 11 Sep 2019 13:34:19 +0000 (13:34 +0000)]
Assume all the short args have optional args so allocate space for the
':'. It's slightly wasteful, but much easier (and the savings in bytes
at runtime would be tiny, but the code to do it larger).

Submitted by: Sebastian Huber

4 years agobectl(8): Add a "check" command
kevans [Wed, 11 Sep 2019 13:27:10 +0000 (13:27 +0000)]
bectl(8): Add a "check" command

This command simply returns 0 at the moment and explicitly takes no
arguments. This should be used by utilities wanting to see if bectl can
operate on the system they're running, or with a specific root (`bectl -r`).
It may grow more checks than "will libbe successfully init" in the future,
but for now this is enough as that checks for the dataset mounted at "/" and
that it looks capable of being a BE root (e.g. it's not a top-level dataset)

bectl commands can now specify if they want to be silent, and this will turn
off libbe_print_on_error so they can control the output as needed. This is
already used in `bectl check`, and may be turned on in the future for some
other commands where libbe errors are better suppressed as the failure mode
may be obvious.

Requested by: David Fullard
MFC after: 3 days

4 years agolinux: add trivial renameat2 implementation
emaste [Wed, 11 Sep 2019 13:01:59 +0000 (13:01 +0000)]
linux: add trivial renameat2 implementation

Just return EINVAL if flags != 0.  The Linux man page documents one
case of EINVAL as "The filesystem does not support one of the flags in
flags."

After r351723 userland binaries will try using new system calls.

Reported by: mjg
Reviewed by: mjg, trasz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21590

4 years agoregen linuxulator sysent after r352208
emaste [Wed, 11 Sep 2019 12:58:53 +0000 (12:58 +0000)]
regen linuxulator sysent after r352208