]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years ago[2/3] Add certctl(8)
kevans [Wed, 2 Oct 2019 01:05:53 +0000 (01:05 +0000)]
[2/3] Add certctl(8)

This is a simple utility to hash all trusted on the system into
/etc/ssl/certs. It also allows the user to blacklist certificates they do
not trust.

This work was done primarily by allanjude@, with minor contributions by
myself.

No objection from: secteam
Differential Revision: https://reviews.freebsd.org/D16857

4 years ago[1/3] Initial infrastructure for SSL root bundle in base
kevans [Wed, 2 Oct 2019 01:05:29 +0000 (01:05 +0000)]
[1/3] Initial infrastructure for SSL root bundle in base

This setup will add the trusted certificates from the Mozilla NSS bundle
to base.

This commit includes:
- CAROOT option to opt out of installation of certs
- mtree amendments for final destinations
- infrastructure to fetch/update certs, along with instructions

A follow-up commit will add a certctl(8) utility to give the user control
over trust specifics. Another follow-up commit will actually commit the
initial result of updatecerts.

This work was done primarily by allanjude@, with minor contributions by
myself.

No objection from: secteam
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D16856

4 years agogeneric_ehci: Enable all phys and resets
manu [Tue, 1 Oct 2019 22:20:03 +0000 (22:20 +0000)]
generic_ehci: Enable all phys and resets

The number of phys and resets is not defined and it controller dependent
so enable/disable every one of them.

4 years agoarm: allwinner: a10_ehci: Enable all phys
manu [Tue, 1 Oct 2019 22:19:12 +0000 (22:19 +0000)]
arm: allwinner: a10_ehci: Enable all phys

Even if there should be only one phy enable all the ones declared in
the dts just to be sure.

4 years agoNeed to use ${${_${group}DIR_${file}}} for STAGE_DIR
sjg [Tue, 1 Oct 2019 20:32:03 +0000 (20:32 +0000)]
Need to use ${${_${group}DIR_${file}}} for STAGE_DIR

STAGE_DIR.${${_${group}DIR_${file}}:C,[/*],_,g} was getting
${STAGE_OBJTOP}BINDIR rather than
${STAGE_OBJTOP}${BINDIR} when FILESDIR=BINDIR

Reviewed by: stevek
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21858

4 years agoarm: allwinner: a10_ehci: Look for the phy based on the id
manu [Tue, 1 Oct 2019 20:22:54 +0000 (20:22 +0000)]
arm: allwinner: a10_ehci:  Look for the phy based on the id

phy-names was never in the bindings schema even if it was present
in some DTS. Get the optional phy based on its ID.

PR: 240978

4 years agogeneric_ohci: Look for the phy based on the id
manu [Tue, 1 Oct 2019 20:21:49 +0000 (20:21 +0000)]
generic_ohci: Look for the phy based on the id

phy-names was never in the bindings schema even if it was present
in some DTS. Get the optional phy based on its ID.

4 years agoImprove latency of synchronous 128KB writes.
mav [Tue, 1 Oct 2019 20:09:25 +0000 (20:09 +0000)]
Improve latency of synchronous 128KB writes.

Before my ZIL space optimization few years ago 128KB writes were logged
as two 64KB+ records in two 128KB log blocks.  After that change it became
~124KB+/4KB+ in two 128KB log blocks to free space in the second block
for another record.  Unfortunately in case of 128KB only writes, when space
in the second block remained unused, that change increased write latency by
imbalancing checksum computation time between parallel threads.

This change introduces new 68KB log block size, used for both writes below
67KB and 128KB-sharp writes.  Writes of 68-127KB are still using one 128KB
block to not increase processing overhead.  Writes above 131KB are still
using full 128KB blocks, since possible saving there is small.  Mixed loads
will likely also fall back to previous 128KB, since code uses maximum of
the last 10 requested block sizes.

On a simple 128KB write test with queue depth of 1 this change demonstrates
~15-20% performance improvement.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoAdd 8 and 16 bit versions of atomic_cmpset and atomic_fcmpset for arm.
ian [Tue, 1 Oct 2019 19:39:00 +0000 (19:39 +0000)]
Add 8 and 16 bit versions of atomic_cmpset and atomic_fcmpset for arm.

This adds 8 and 16 bit versions of the cmpset and fcmpset functions. Macros
are used to generate all the flavors from the same set of instructions; the
macro expansion handles the couple minor differences between each size
variation (generating ldrexb/ldrexh/ldrex for 8/16/32, etc).

In addition to handling new sizes, the instruction sequences used for cmpset
and fcmpset are rewritten to be a bit shorter/faster, and the new sequence
will not return false when *dst==*old but the store-exclusive fails because
of concurrent writers. Instead, it just loops like ldrex/strex sequences
normally do until it gets a non-conflicted store. The manpage allows LL/SC
architectures to bogusly return false, but there's no reason to actually do
so, at least on arm.

Reviewed by: cognet

4 years agosyr827: Switch to iicdev_{readfrom,writeto}
manu [Tue, 1 Oct 2019 18:32:27 +0000 (18:32 +0000)]
syr827: Switch to iicdev_{readfrom,writeto}

Also use IIC_INTRWAIT as we need this to work with the rockchip i2c driver.

4 years agoarm64: rockchip: rk805: Switch to iicdev_{readfrom,writeto}
manu [Tue, 1 Oct 2019 18:30:06 +0000 (18:30 +0000)]
arm64: rockchip: rk805: Switch to iicdev_{readfrom,writeto}

This simpify the code a bit.

4 years agoMove httpd to simple_httpd...
kevans [Tue, 1 Oct 2019 18:14:37 +0000 (18:14 +0000)]
Move httpd to simple_httpd...

This avoids PATH conflicts with a real httpd, as a user will likely almost
always prefer the more fully-featured httpd. This also lines up with the
historical name of the program.

4 years agosysalls.master: remove superfluous ellipsis in comment
emaste [Tue, 1 Oct 2019 17:05:21 +0000 (17:05 +0000)]
sysalls.master: remove superfluous ellipsis in comment

A single period is sufficient in this comment, and making this change
lets us find references to varargs syscalls by searching for ...

4 years agoIn short, pmap_enter_quick_locked("user space", ..., VM_PROT_READ) doesn't
alc [Tue, 1 Oct 2019 15:33:47 +0000 (15:33 +0000)]
In short, pmap_enter_quick_locked("user space", ..., VM_PROT_READ) doesn't
work.  More precisely, it doesn't set ATTR_AP(ATTR_AP_USER) in the page
table entry, so any attempt to read from the mapped page by user space
generates a page fault.  This problem has gone unnoticed because the page
fault handler, vm_fault(), will ultimately call pmap_enter(), which
replaces the non-working page table entry with one that has
ATTR_AP(ATTR_AP_USER) set.

This change reduces the number of page faults during a "buildworld" by
about 19.4%.

Reviewed by: andrew, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21841

4 years agoAdd a top-level makeman target
kevans [Tue, 1 Oct 2019 15:10:35 +0000 (15:10 +0000)]
Add a top-level makeman target

Abstracting away the details of how src.conf(5) is generated is arguably a
good thing; do so with a top-level makeman target.

4 years agoRegen src.conf(5) after r352927 (HTTPD option added)
kevans [Tue, 1 Oct 2019 14:56:31 +0000 (14:56 +0000)]
Regen src.conf(5) after r352927 (HTTPD option added)

4 years agoMove simple_httpd out of picobsd, add HTTPD option (default OFF)
kevans [Tue, 1 Oct 2019 14:55:16 +0000 (14:55 +0000)]
Move simple_httpd out of picobsd, add HTTPD option (default OFF)

picobsd/tinyware has had this compact HTTPD server for a long time, and some
people do use it. Move it out into usr.sbin well in advance of any action
being taken on picobsd.

This has been gated behind an HTTPD option defaulted to *off*, primarily for
two reasons:
1.) This code likely needs a good audit, as it's been living off in picobsd
    land for a long time, and
2.) We don't currently ship an httpd and this may not be a welcome surprise.

Reviewed by: eugen
Differential Revision: https://reviews.freebsd.org/D21724

4 years agoClean up duplicate entries in sys/conf/files
rstone [Tue, 1 Oct 2019 13:36:01 +0000 (13:36 +0000)]
Clean up duplicate entries in sys/conf/files

Reviewed by: imp

4 years agoxen/ctrl: acknowledge all control requests
royger [Tue, 1 Oct 2019 08:21:41 +0000 (08:21 +0000)]
xen/ctrl: acknowledge all control requests

Currently only suspend requests are acknowledged by writing an empty
string back to the xenstore control node, but poweroff or reboot
requests are not acknowledged and FreeBSD simply proceeds to perform
the desired action.

Fix this by acknowledging all requests, and remove the suspend specific
ack done in the handler.

Sponsored by: Citrix Systems R&D
MFC after: 3 days

4 years agoAdd iflag=fullblock to dd
mmacy [Mon, 30 Sep 2019 22:00:48 +0000 (22:00 +0000)]
Add iflag=fullblock to dd

Normally, count=n means read(2) will be called n times on the input to dd. If
the read() returns short, as may happen when reading from a pipe, fewer bytes
will be copied from the input. With conv=sync the buffer is padded with zeros
to fill the rest of the block.

iflag=fullblock causes dd to continue reading until the block is full, so that
count=n means n full blocks are copied. This flag is compatible with illumos
and GNU dd and is used in the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by:  iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D21441

4 years agoAdd oflag=fsync and oflag=sync capability to dd
mmacy [Mon, 30 Sep 2019 21:56:42 +0000 (21:56 +0000)]
Add oflag=fsync and oflag=sync capability to dd

Sets the O_FSYNC flag on the output file. oflag=fsync and oflag=sync are
synonyms just as O_FSYNC and O_SYNC are synonyms. This functionality is
intended to improve portability of dd commands in the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by:  iXsytems, Inc.
Differential Revision: https://reviews.freebsd.org/D21422

4 years agodd: Check result of close(2) for errors
mmacy [Mon, 30 Sep 2019 21:53:26 +0000 (21:53 +0000)]
dd: Check result of close(2) for errors

close(2) can return errors from previous operations which should not be ignored.

PR: 229616
Submitted by: Thomas Hurst
Reported by: Thomas Hurst
Reviewed by: mmacy@
Obtained from: Ryan Moeller
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21376

4 years agoAdd conv=fdatasync flag to dd
mmacy [Mon, 30 Sep 2019 21:48:12 +0000 (21:48 +0000)]
Add conv=fdatasync flag to dd

The fdatasync flag performs an fdatasync(2) on the output file before closing it.
This will be useful for the ZFS test suite.

Submitted by: Ryan Moeller
Reviewed by: manpages, mmacy@
MFC after: 1 week
Sponsored by: iXSystems, Inc.
Differential Revision: https://reviews.freebsd.org/D21373

4 years agoUpdate cloudabi(32|64) sysents with "make sysent".
brooks [Mon, 30 Sep 2019 21:14:33 +0000 (21:14 +0000)]
Update cloudabi(32|64) sysents with "make sysent".

MFC after: 1 week

4 years agoRegen after r347228 and r352693.
brooks [Mon, 30 Sep 2019 21:00:19 +0000 (21:00 +0000)]
Regen after r347228 and r352693.

No functional change.

4 years agoRestore the ability to set capenabled directly in syscalls.conf.
brooks [Mon, 30 Sep 2019 20:58:29 +0000 (20:58 +0000)]
Restore the ability to set capenabled directly in syscalls.conf.

This fixes generation of cloudabi syscall tables broken in r340424.

Reviewed by: kevans, emaste
MFC after: 3 days
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D21821

4 years agoRemove more identifiers orphaned by r351742.
markj [Mon, 30 Sep 2019 20:39:25 +0000 (20:39 +0000)]
Remove more identifiers orphaned by r351742.

Reviewed by: alc, kib
Differential Revision: https://reviews.freebsd.org/D21642

4 years agoPull in r357528 from upstream llvm trunk (by Craig Topper):
dim [Mon, 30 Sep 2019 19:24:21 +0000 (19:24 +0000)]
Pull in r357528 from upstream llvm trunk (by Craig Topper):

  [X86] Check MI.isConvertibleTo3Addr() before calling
  convertToThreeAddress in X86FixupLEAs.

  X86FixupLEAs just assumes convertToThreeAddress will return nullptr
  for any instruction that isn't convertible.

  But the code in convertToThreeAddress for X86 assumes that any
  instruction coming in has at least 2 operands and that the second one
  is a register. But those properties aren't guaranteed of all
  instructions. We should check the instruction property first.

Pull in r365720 from upstream llvm trunk (by Craig Topper):

  [X86] Don't convert 8 or 16 bit ADDs to LEAs on Atom in FixupLEAPass.

  We use the functions that convert to three address to do the
  conversion, but changing an 8 or 16 bit will cause it to create a
  virtual register. This can't be done after register allocation where
  this pass runs.

  I've switched the pass completely to a white list of instructions
  that can be converted to LEA instead of a blacklist that was
  incorrect. This will avoid surprises if we enhance the three address
  conversion function to include additional instructions in the future.

  Fixes PR42565.

This should fix assertions/segfaults when compiling certain ports with
CPUTYPE=atom.

PR: 240928
MFC after: 3 days

4 years agolinux_renameat2: don't add extra \n on error.
kaktus [Mon, 30 Sep 2019 19:05:14 +0000 (19:05 +0000)]
linux_renameat2: don't add extra \n on error.

linux_msg() already adds \n at the end of all messages.

Reported by: emaste, kib (mentor), mjg (mentor)
Reviewed by: kib (mentor), mjg (mentor)
Differential Revision: https://reviews.freebsd.org/D21852

4 years agolibsysdecode: decode PROT_MAX flags
kaktus [Mon, 30 Sep 2019 19:03:43 +0000 (19:03 +0000)]
libsysdecode: decode PROT_MAX flags

Extend libsysdecode to pretty-print PROT_MAX flags and fix decoding of regular protection flags broken since r349240.

before:
truss:
mmap(0x0,40960,0x30000,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 34366234624 (0x800632000)
kdump:
11439 protmax  CALL  mmap(0,0xa000,0x30000<><invalid>196608,0x21002<MAP_PRIVATE|MAP_ANON|MAP_NOCORE>,0xffffffff,0)

after:
truss:
mmap(0x0,40960,PROT_MAX(PROT_READ|PROT_WRITE)|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 34366234624 (0x800632000)
kdump:
11439 protmax  CALL  mmap(0,0xa000,0x30000<PROT_MAX(PROT_READ|PROT_WRITE)|PROT_READ|PROT_WRITE>,0x21002<MAP_PRIVATE|MAP_ANON|MAP_NOCORE>,0xffffffff,0)

Reviewed by: kib (mentor)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D21706

4 years agoCapsicumize nm(1).
markj [Mon, 30 Sep 2019 17:27:59 +0000 (17:27 +0000)]
Capsicumize nm(1).

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21107

4 years agonm: Adjust argc and argv in get_opt().
markj [Mon, 30 Sep 2019 17:26:42 +0000 (17:26 +0000)]
nm: Adjust argc and argv in get_opt().

This refactoring makes it slightly easier to capsicumize nm(1).

Discussed with: emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoCapsicumize c++filt(1).
markj [Mon, 30 Sep 2019 16:10:42 +0000 (16:10 +0000)]
Capsicumize c++filt(1).

Reviewed by: emaste
Discussed with: oshogbo
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21106

4 years agoAdd IFLIB_SINGLE_IRQ_RX_ONLY.
markj [Mon, 30 Sep 2019 15:59:07 +0000 (15:59 +0000)]
Add IFLIB_SINGLE_IRQ_RX_ONLY.

As of r347221 the iflib legacy interrupt mode setup assumes that drivers
perform both receive and transmit processing from the interrupt handler.
This assumption is invalid in the vmxnet3 driver, so introduce the
IFLIB_SINGLE_IRQ_RX_ONLY flag to make iflib avoid tx processing in the
interrupt handler.

PR: 239118
Reported and tested by: Juraj Lutter <otis@sk.freebsd.org>
Obtained from: marius
Reviewed by: gallatin
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D21831

4 years agoarm64: rockchip: rk_clk_pll: Check mode on recalc
manu [Mon, 30 Sep 2019 15:01:09 +0000 (15:01 +0000)]
arm64: rockchip: rk_clk_pll: Check mode on recalc

If the pll is in slow or deep slow mode return the correct frequency.

4 years agoarm64: rockchip: correct reset value
manu [Mon, 30 Sep 2019 15:00:22 +0000 (15:00 +0000)]
arm64: rockchip: correct reset value

If bit is 0 the reset is not asserted.
Also register our self as a reset provider, this was commented
in r352850

Reported by: mmel

4 years agoFix coredump_phnum_test when kern.compress_user_cores != 0
vangyzen [Mon, 30 Sep 2019 14:05:44 +0000 (14:05 +0000)]
Fix coredump_phnum_test when kern.compress_user_cores != 0

If `kern.compress_user_cores` is non-zero, decompress the core file.

Use `sysctl -f` to restore previous values.

Don't bother restoring `ulimit -c`, since that's a per-process value.

Check more commands with `atf_check`.

Reviewed by: olivier ngie
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21820

4 years agosyscalls.master: consistency, move ); to newline (no functional change)
kevans [Mon, 30 Sep 2019 13:26:16 +0000 (13:26 +0000)]
syscalls.master: consistency, move ); to newline (no functional change)

4 years agoDon't use stack memory which is not initialized.
tuexen [Mon, 30 Sep 2019 12:06:57 +0000 (12:06 +0000)]
Don't use stack memory which is not initialized.
Thanks to Mark Wodrich for reporting this issue for the userland stack in
https://github.com/sctplab/usrsctp/issues/380
This issue was also found for usrsctp by OSS-fuzz in
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17778

MFC after: 3 days

4 years agoInitialize baseaddr to suppres warning.
ray [Sun, 29 Sep 2019 23:47:23 +0000 (23:47 +0000)]
Initialize baseaddr to suppres warning.

Pointy hat to: ray

4 years agoections into expected offset in binary format.
ray [Sun, 29 Sep 2019 22:34:01 +0000 (22:34 +0000)]
ections into expected offset in binary format.
Calculate binary file offset using address field, bacause software know only offset to known data, not where to load segment.
With that patch, kernel .data section can have any alignment/offset - kernel boor fine.

PR: 235391
Reviewed by: markj
MFC after: 1 month
Differential Revision: D21827

4 years agoamd64 pmap: batch chunk removal in pmap_remove_pages
mjg [Sun, 29 Sep 2019 20:44:13 +0000 (20:44 +0000)]
amd64 pmap: batch chunk removal in pmap_remove_pages

pv list lock is the main bottleneck during poudriere -j 104 and
pmap_remove_pages is the most impactful consumer. It frees chunks with the lock
held even though it plays no role in correctness. Moreover chunks are often
freed in groups, sample counts during buildkernel (0-sized frees removed):

    value  ------------- Distribution ------------- count
          0 |                                         0
          1 |                                         8
          2 |@@@@@@@                                  19329
          4 |@@@@@@@@@@@@@@@@@@@@@@                   58517
          8 |                                         1085
         16 |                                         71
         32 |@@@@@@@@@@                               24919
         64 |                                         899
        128 |                                         7
        256 |                                         2
        512 |                                         0

Thus:
1. batch freeing
2. move it past unlocking pv list

Reviewed by: alc (previous version), markj (previous version), kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21832

4 years agomemfd_create(3): Don't actually force hugetlb size with MFD_HUGETLB
kevans [Sun, 29 Sep 2019 17:30:10 +0000 (17:30 +0000)]
memfd_create(3): Don't actually force hugetlb size with MFD_HUGETLB

The size flags are only required to select a size on systems that support
multiple sizes. MFD_HUGETLB by itself is valid.

4 years agoAdjust tests after page fault changes in r352807
jilles [Sun, 29 Sep 2019 15:17:58 +0000 (15:17 +0000)]
Adjust tests after page fault changes in r352807

Commit r352807 fixed various signal numbers and codes from page faults;
adjust the tests so they expect the fixes to be present.

PR: 211924

4 years agoRFC 7112 requires a host to put the complete IP header chain
tuexen [Sun, 29 Sep 2019 10:45:13 +0000 (10:45 +0000)]
RFC 7112 requires a host to put the complete IP header chain
including the TCP header in the first IP packet.
Enforce this in tcp_output(). In addition make sure that at least
one byte payload fits in the TCP segement to allow making progress.
Without this check, a kernel with INVARIANTS will panic.
This issue was found by running an instance of syzkaller.

Reviewed by: jtl@
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D21665

4 years agoMFD_*: swap ordering
kevans [Sun, 29 Sep 2019 03:26:29 +0000 (03:26 +0000)]
MFD_*: swap ordering

This API is still young enough that I would expect no one to be dependant on
this yet... Swap the ordering while it's young to match Linux values to
potentially ease implementation of linuxolator syscall, being able to reuse
existing constants.

4 years agofdt_slicer: bump to SI_ORDER_THIRD following r347183
kevans [Sun, 29 Sep 2019 03:12:35 +0000 (03:12 +0000)]
fdt_slicer: bump to SI_ORDER_THIRD following r347183

r347183 bumped GEOM classes to SI_ORDER_SECOND to resolve a race between
them and the initialization of devsoftc.mtx in devinit, but missed this
dependency on g_flashmap that may now lose the race against GEOM
classes/g_init.

There's a great comment that describes the situation that has also been
updated with the new ordering of GEOM classes.

Reported by: bdragon
MFC after: 4 days

4 years agoImport DTS files from Linux 5.3
manu [Sat, 28 Sep 2019 23:08:19 +0000 (23:08 +0000)]
Import DTS files from Linux 5.3

4 years agoarm: allwinner: Add pll_mipi to the files
manu [Sat, 28 Sep 2019 23:01:23 +0000 (23:01 +0000)]
arm: allwinner: Add pll_mipi to the files

4 years agoImport DTS files from Linux 5.2
manu [Sat, 28 Sep 2019 22:54:56 +0000 (22:54 +0000)]
Import DTS files from Linux 5.2

4 years agoImport DTS files from Linux 5.3
manu [Sat, 28 Sep 2019 22:38:14 +0000 (22:38 +0000)]
Import DTS files from Linux 5.3

4 years agoImport DTS from Linux 5.2
manu [Sat, 28 Sep 2019 22:35:29 +0000 (22:35 +0000)]
Import DTS from Linux 5.2

4 years agoarm64: rockchip: Add usb2phy driver
manu [Sat, 28 Sep 2019 22:25:21 +0000 (22:25 +0000)]
arm64: rockchip: Add usb2phy driver

This driver is for the usb phy present on rockchip SoC.
It only support RK3399 and host mode for now.
The driver expose the usb clock needed by the usb controller.

4 years agodwc: Add more delay for chip reset
manu [Sat, 28 Sep 2019 22:23:21 +0000 (22:23 +0000)]
dwc: Add more delay for chip reset

On rockchip board it seems that the value in the DTS
are not enough for reseting the chip, I don't know if
the value are really incorrect or if DELAY is not precise
enough or if the rockchip gpio driver have some "lag" of some
kind or not.
For now just add more delay.

4 years agoarm64: rockchip: Fix map_gpio
manu [Sat, 28 Sep 2019 22:21:16 +0000 (22:21 +0000)]
arm64: rockchip: Fix map_gpio

The map_gpio function wasn't correct, the first element is the pin
and not the phandle.

4 years agoarm64: rockchip: Implement resets
manu [Sat, 28 Sep 2019 22:19:52 +0000 (22:19 +0000)]
arm64: rockchip: Implement resets

Module resets where not implemented when rockchip clocks were commited.
Implement them.
Since all resets registers are contiguous a driver only need to give
the start offset and the number of resets. This avoid to have to declare
every resets.

4 years agoarm64: rockchip: rk3399: Add usb2 clocks
manu [Sat, 28 Sep 2019 22:17:26 +0000 (22:17 +0000)]
arm64: rockchip: rk3399: Add usb2 clocks

4 years agoarm64: allwinner: a64: Add PLL_MIPI
manu [Sat, 28 Sep 2019 22:14:33 +0000 (22:14 +0000)]
arm64: allwinner: a64: Add PLL_MIPI

PLL_MIPI is the last important PLL that we missed.
Add support for it.
Since it's one of the possible parent for TCON0 also add this clock
now that we can.
While here add some info about what video related clocks should be
enabled at boot and with what frequency.

4 years agoEliminate redundant calls to critical_enter() and critical_exit() from
alc [Sat, 28 Sep 2019 17:16:03 +0000 (17:16 +0000)]
Eliminate redundant calls to critical_enter() and critical_exit() from
pmap_update_entry().  It suffices that interrupts are blocked.

Reviewed by: andrew, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21753

4 years agoRevert the mode_t -> int changes and add a warning in the BUGS section instead.
imp [Sat, 28 Sep 2019 17:15:48 +0000 (17:15 +0000)]
Revert the mode_t -> int changes and add a warning in the BUGS section instead.

While FreeBSD's implementation of these expect an int inside of libc, that's an
implementation detail that we can hide from the user as it's the natural
promotion of the current mode_t type and before it is used in the kernel, it's
converted back to the narrower type that's the current definition of mode_t. As
such, documenting int is at best confusing and at worst misleading. Instead add
a note that these args are variadic and as such calling conventions may differ
from non-variadic arguments.

4 years agoDisable build of LOCAL_MODULES for cross-builds by default.
jhb [Sat, 28 Sep 2019 14:20:28 +0000 (14:20 +0000)]
Disable build of LOCAL_MODULES for cross-builds by default.

WITHOUT_LOCAL_MODULES can be set to disable LOCAL_MODULES for native
builds.  WITH_LOCAL_MODULES can be set to leave it enabled for cross
builds.

This does not use a knob in kern.opts.mk because the options framework
does not currently support options whose default varies on the build
type.  I discussed a few options there with Warner (e.g. maybe having
a tri-state where the default value is "auto" and having Makefile.inc1
apply logic when MK_LOCAL_MODULES is set to "auto"), but Warner ok'd
this approach for now until a better solution is implemented.

Requested by: many
Reviewed by: imp (in person at EuroBSDCon)
Differential Revision: https://reviews.freebsd.org/D21608

4 years agoDisable REPRODUCIBLE_BUILD for kernel builds.
jhb [Sat, 28 Sep 2019 14:14:42 +0000 (14:14 +0000)]
Disable REPRODUCIBLE_BUILD for kernel builds.

The REPRODUCIBLE_BUILD option is actually managed in two separate
files.  src.opts.mk governs the setting for world builds and
kern.opts.mk governs it for kernel builds.  r350550 only changed the
default for world builds.

Reported by: emaste
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D21444

4 years agoReplacing MD5 by SipHash improves the performance of the TCP time stamp
tuexen [Sat, 28 Sep 2019 13:13:23 +0000 (13:13 +0000)]
Replacing MD5 by SipHash improves the performance of the TCP time stamp
initialisation, which is important when the host is dealing with a
SYN flood.
This affects the computation of the initial TCP sequence number for
the client side.
This has been discussed with secteam@.

Reviewed by: gallatin@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D21616

4 years agoEnsure that the INP lock is released before leaving [gs]etsockopt()
tuexen [Sat, 28 Sep 2019 13:05:37 +0000 (13:05 +0000)]
Ensure that the INP lock is released before leaving [gs]etsockopt()
for RACK specific socket options.
These issues were found by a syzkaller instance.
Reviewed by: rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D21825

4 years agobhyve: support for enabling/disabling the net backend
vmaffione [Sat, 28 Sep 2019 12:02:43 +0000 (12:02 +0000)]
bhyve: support for enabling/disabling the net backend

Extend the net backend interface with two functions, namely netbe_rx_disable()
and netbe_rx_enable(), which can be used by the net device emulators to stop
the backend from invoking the receive callback. This is useful for device
emulators, i.e., on hardware resets or to implement receive backpressure.
The mevent module has been extendede to support the addition of a disabled
event. To prevent race conditions, the net backends will start with receive
operation disabled. A follow-up patch will use the new functionalities in
the virtio-net device.

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

4 years agoFix Q_TOSTR(3) with GCC when it's called with first parameter being const.
trasz [Sat, 28 Sep 2019 09:54:03 +0000 (09:54 +0000)]
Fix Q_TOSTR(3) with GCC when it's called with first parameter being const.

Discussed with: cem
MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix
Differential Revision: https://reviews.freebsd.org/D21766

4 years agoRename ARB_REBALANCE(3) to ARB_REINSERT(3) to match tree(3),
trasz [Sat, 28 Sep 2019 09:50:01 +0000 (09:50 +0000)]
Rename ARB_REBALANCE(3) to ARB_REINSERT(3) to match tree(3),
and document it.

MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix

4 years agoSort MLINKS for arb(3), and actually make them work by fixing a '=' vs '+='
trasz [Sat, 28 Sep 2019 09:37:05 +0000 (09:37 +0000)]
Sort MLINKS for arb(3), and actually make them work by fixing a '=' vs '+='
mixup.

MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix

4 years agoAdd RB_REINSERT(3), a low overhead alternative to removing a node
trasz [Sat, 28 Sep 2019 09:22:52 +0000 (09:22 +0000)]
Add RB_REINSERT(3), a low overhead alternative to removing a node
and reinserting it back with an updated key.

This is one of dependencies for the upcoming stats(3) code.

Reviewed by: cem
Obtained from: Netflix
MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix
Differential Revision: https://reviews.freebsd.org/D21786

4 years agoMove the SysV IPC stuff out of the 'abi' rc script, into a new one:
trasz [Sat, 28 Sep 2019 09:12:41 +0000 (09:12 +0000)]
Move the SysV IPC stuff out of the 'abi' rc script, into a new one:
'sysvipc' - it has nothing to do with ABIs, and I'd like to later
rename 'abi' to 'linux', which better describes its purpose and also
matches the rcvar name.

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

4 years agopowerpc/booke64: Align initial stack setting to match that of aim64's
jhibbits [Sat, 28 Sep 2019 03:33:07 +0000 (03:33 +0000)]
powerpc/booke64: Align initial stack setting to match that of aim64's

Clang9/LLD9 appears to get quite confused with the instruction stream used
to obtain the tmpstack pointer, almost as though it thinks this is a C
function, so tries to optimize it.  Since the AIM64 method doesn't use the
TOC to obtain the tmpstack, just follow that model, and lld won't get
confused.

Reported by: bdragon
MFC after: 2 weeks

4 years agodpaa(4): Fix memcpy size for threshold copy in NCSW contrib
jhibbits [Sat, 28 Sep 2019 02:49:46 +0000 (02:49 +0000)]
dpaa(4): Fix memcpy size for threshold copy in NCSW contrib

On 64-bit platforms uintptr_t makes the copy twice as large as it should be.
This code isn't actually used in FreeBSD, since it's for guest mode only,
not hypervisor mode, but fixing it for completeness sake.

Reported by: bdragon (clang9 build)

4 years agoFix some problems with the SPARSE_MAPPING option in the kernel linker.
markj [Sat, 28 Sep 2019 01:42:59 +0000 (01:42 +0000)]
Fix some problems with the SPARSE_MAPPING option in the kernel linker.

- Ensure that the end of the mapping passed to vm_page_wire() is
  page-aligned.  vm_page_wire() expects this.
- Wire pages before reading data into them.
- Apply protections specified in the segment descriptor using
  vm_map_protect() once relocation processing is done.
- On amd64, ensure that we load KLDs above KERNBASE, since they
  are compiled with the "kernel" memory model by default.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21756

4 years agoImplement pmap_page_is_mapped() correctly on arm64 and riscv.
markj [Fri, 27 Sep 2019 23:37:01 +0000 (23:37 +0000)]
Implement pmap_page_is_mapped() correctly on arm64 and riscv.

We must also check for large mappings.  pmap_page_is_mapped() is
mostly used in assertions, so the problem was not very noticeable.

Reviewed by: alc
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D21824

4 years agoCorrect the scope of several global variables.
markj [Fri, 27 Sep 2019 21:04:33 +0000 (21:04 +0000)]
Correct the scope of several global variables.

They are accessed from multiple compilation units.  No functional change
intended.

MFC after: 1 week
Sponsored by: Netflix

4 years agoUse set -o xtrace in preference to set -x for consistency with
imp [Fri, 27 Sep 2019 20:56:49 +0000 (20:56 +0000)]
Use set -o xtrace in preference to set -x for consistency with
the rest of nanobsd.sh.

4 years agoPush and pop xtrace correctly for run_early_customize
imp [Fri, 27 Sep 2019 20:56:44 +0000 (20:56 +0000)]
Push and pop xtrace correctly for run_early_customize

run_early_customize is run as a shell list, not as a subshell, so that the side
effects of setting variables can affect later stages of the build (for better or
worse, it's been like this since it was introduced). It therefore has the side
effect of turning off xtrace always, which limits the usefulness of sh -x
nanobsd.sh. Remember the old setting and only turn off tracing after the command
if tracing was off before. All the other places where we do similar things we use
a subshell, so we don't need to do this.

4 years agoRemove workaround for building on FreeBSD hosts prior to FreeBSD 10.
imp [Fri, 27 Sep 2019 20:56:31 +0000 (20:56 +0000)]
Remove workaround for building on FreeBSD hosts prior to FreeBSD 10.

rm -x was introduced in the FreeBSD 10 time frame. 4 years ago I added a
function to cope with building nanobsd images on hosts as old FreeBSD 7 that
lacked rm -x. The workaround is no longer needed as FreeBSD 9 hasn't been
supported for almost 3 years. Eliminate the wrapper and use rm -x directly
again.

4 years agoAllow entering fractional delays in top(1) interactive mode.
dim [Fri, 27 Sep 2019 20:53:31 +0000 (20:53 +0000)]
Allow entering fractional delays in top(1) interactive mode.

This uses the same logic as with the -s option, first validating the
entered value, then storing the result in a struct timeval.

MFC after: 3 days
X-MFC-With: r352818

4 years agoMake fractional delays for top(1) work for interactive mode.
dim [Fri, 27 Sep 2019 20:20:21 +0000 (20:20 +0000)]
Make fractional delays for top(1) work for interactive mode.

In r334906, the -s option was changed to allow fractional times, but
this only functioned correctly for batch mode.  In interactive mode, any
delay below 1.0 would get floored to zero.  This would put top(1) into a
tight loop, which could be difficult to interrupt.

Fix this by storing the -s option value (after validation) into a struct
timeval, and using that struct consistently for delaying with select(2).

Next up is to allow interactive entry of a fractional delay value.

MFC after: 3 days

4 years agokTLS: Fix a bug where we would not encrypt anon data inplace.
gallatin [Fri, 27 Sep 2019 20:08:19 +0000 (20:08 +0000)]
kTLS: Fix a bug where we would not encrypt anon data inplace.

Software Kernel TLS needs to allocate a new destination crypto
buffer when encrypting data from the page cache, so as to avoid
overwriting shared clear-text file data with encrypted data
specific to a single socket. When the data is anonymous, eg, not
tied to a file, then we can encrypt in place and avoid allocating
a new page. This fixes a bug where the existing code always
assumes the data is private, and never encrypts in place. This
results in unneeded page allocations and potentially more memory
bandwidth consumption when doing socket writes.

When the code was written at Netflix, ktls_encrypt() looked at
private sendfile flags to determine if the pages being encrypted
where part of the page cache (coming from sendfile) or
anonymous (coming from sosend). This was broken internally at
Netflix when the sendfile flags were made private, and the
M_WRITABLE() check was added. Unfortunately, M_WRITABLE() will
always be false for M_NOMAP mbufs, since one cannot just mtod()
them.

This change introduces a new flags field to the mbuf_ext_pgs
struct by stealing a byte from the tls hdr. Note that the current
header is still 2 bytes larger than the largest header we
support: AES-CBC with explicit IV. We set MBUF_PEXT_FLAG_ANON
when creating an unmapped mbuf in m_uiotombuf_nomap() (which is
the path that socket writes take), and we check for that flag in
ktls_encrypt() when looking for anon pages.

Reviewed by: jhb
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D21796

4 years agocontrolelf: update man page
emaste [Fri, 27 Sep 2019 19:26:52 +0000 (19:26 +0000)]
controlelf: update man page

Some minor corrections, clarifications or rewording.

4 years agokTLS support for TLS 1.3
gallatin [Fri, 27 Sep 2019 19:17:40 +0000 (19:17 +0000)]
kTLS support for TLS 1.3

TLS 1.3 requires a few changes because 1.3 pretends to be 1.2
with a record type of application data. The "real" record type is
then included at the end of the user-supplied plaintext
data. This required adding a field to the mbuf_ext_pgs struct to
save the record type, and passing the real record type to the
sw_encrypt() ktls backend functions.

Reviewed by: jhb, hselasky
Sponsored by: Netflix
Differential Revision: D21801

4 years agocache: decrease ncnegfactor to 5
mjg [Fri, 27 Sep 2019 19:14:03 +0000 (19:14 +0000)]
cache: decrease ncnegfactor to 5

The current mechanism is bogus in several ways:
- the limit is a percentage of total entries added, which means negative
entries get evicted all the time even if there are plenty of resources
- evicting code is almost not concurrent, which makes it unable to
remove entries fast enough when doing something as simple as -j 104
buildworld
- there is no support for performing mass removal if necessary

Vast majority of negative entries never get any hits. Only evicting
them when the filesystem demands it results in a significant growth of
the namecache with almost no improvement in the hit ratio.

Sample result about afer 90 minutes of poudriere -j 104:

           current    no evict   % of the original
numneg     219737     2013157    916
numneghits 266711906  263544562  98 [1]

[1] this may look funny but there is a certain dose of variation to the
build

The number was chosen as something which mostly eliminates spurious
evictions during lighter workloads but still keeps the total at bay.

Sponsored by: The FreeBSD Foundation

4 years agocache: stop requeuing negative entries on the hot list
mjg [Fri, 27 Sep 2019 19:13:22 +0000 (19:13 +0000)]
cache: stop requeuing negative entries on the hot list

Turns out it does not improve hit ratio, but it does come with a cost
induces stemming from dirtying hit entries.

Sample result: hit counts of evicted entries after 2 buildworlds

before:

           value  ------------- Distribution ------------- count
              -1 |                                         0
               0 |@@@@@@@@@@@@@@@@@@@@@@@@@                180865
               1 |@@@@@@@                                  49150
               2 |@@@                                      19067
               4 |@                                        9825
               8 |@                                        7340
              16 |@                                        5952
              32 |@                                        5243
              64 |@                                        4446
             128 |                                         3556
             256 |                                         3035
             512 |                                         1705
            1024 |                                         1078
            2048 |                                         365
            4096 |                                         95
            8192 |                                         34
           16384 |                                         26
           32768 |                                         23
           65536 |                                         8
          131072 |                                         6
          262144 |                                         0

after:
           value  ------------- Distribution ------------- count
              -1 |                                         0
               0 |@@@@@@@@@@@@@@@@@@@@@@@@@                184004
               1 |@@@@@@                                   47577
               2 |@@@                                      19446
               4 |@                                        10093
               8 |@                                        7470
              16 |@                                        5544
              32 |@                                        5475
              64 |@                                        5011
             128 |                                         3451
             256 |                                         3002
             512 |                                         1729
            1024 |                                         1086
            2048 |                                         363
            4096 |                                         86
            8192 |                                         26
           16384 |                                         25
           32768 |                                         24
           65536 |                                         7
          131072 |                                         5
          262144 |                                         0

Sponsored by: The FreeBSD Foundation

4 years agocache: make negative list shrinking a little bit concurrent
mjg [Fri, 27 Sep 2019 19:12:43 +0000 (19:12 +0000)]
cache: make negative list shrinking a little bit concurrent

Continue protecting demotion from the hotlist and selection of the
target list with the ncneg_shrink_lock lock, but drop it before
relocking to zap the node.

While here count how many times we skipped shrinking due to the lock
being already taken.

Sponsored by: The FreeBSD Foundation

4 years agocache: stop recalculating upper limit each time a new entry is added
mjg [Fri, 27 Sep 2019 19:12:20 +0000 (19:12 +0000)]
cache: stop recalculating upper limit each time a new entry is added

Sponsored by: The FreeBSD Foundation

4 years agocontrolelf: exit with error if file endianness does not match host
emaste [Fri, 27 Sep 2019 19:07:11 +0000 (19:07 +0000)]
controlelf: exit with error if file endianness does not match host

We need to add support for cross-endian operation, but until that's done
just exit with an error rather than misbehaving.

4 years agocontrolelf: simplify feature string parsing
emaste [Fri, 27 Sep 2019 18:49:13 +0000 (18:49 +0000)]
controlelf: simplify feature string parsing

Also add error handling on failure to seek/write updated value.

4 years agoImprove MD page fault handlers.
kib [Fri, 27 Sep 2019 18:43:36 +0000 (18:43 +0000)]
Improve MD page fault handlers.

Centralize calculation of signal and ucode delivered on unhandled page
fault in new function vm_fault_trap().  MD trap_pfault() now almost
always uses the signal numbers and error codes calculated in
consistent MI way.

This introduces the protection fault compatibility sysctls to all
non-x86 architectures which did not have that bug, but apparently they
were already much more wrong in selecting delivered signals on
protection violations.

Change the delivered signal for accesses to mapped area after the
backing object was truncated.  According to POSIX description for
mmap(2):
   The system shall always zero-fill any partial page at the end of an
   object. Further, the system shall never write out any modified
   portions of the last page of an object which are beyond its
   end. References within the address range starting at pa and
   continuing for len bytes to whole pages following the end of an
   object shall result in delivery of a SIGBUS signal.

   An implementation may generate SIGBUS signals when a reference
   would cause an error in the mapped object, such as out-of-space
   condition.
Adjust according to the description, keeping the existing
compatibility code for SIGSEGV/SIGBUS on protection failures.

For situations where kernel cannot handle page fault due to resource
limit enforcement, SIGBUS with a new error code BUS_OBJERR is
delivered.  Also, provide a new error code SEGV_PKUERR for SIGSEGV on
amd64 due to protection key access violation.

vm_fault_hold() is renamed to vm_fault().  Fixed some nits in
trap_pfault()s like mis-interpreting Mach errors as errnos.  Removed
unneeded truncations of the fault addresses reported by hardware.

PR: 211924
Reviewed by: alc
Discussed with: jilles, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D21566

4 years agocontrolelf: tidy up option parsing
emaste [Fri, 27 Sep 2019 18:39:05 +0000 (18:39 +0000)]
controlelf: tidy up option parsing

Sponsored by: The FreeBSD Foundation

4 years agocontrolelf: add protmax control
emaste [Fri, 27 Sep 2019 17:28:25 +0000 (17:28 +0000)]
controlelf: add protmax control

Sponsored by: The FreeBSD Foundation

4 years agoCorrect the final argument name in the top(1) manpage.
dim [Fri, 27 Sep 2019 17:11:21 +0000 (17:11 +0000)]
Correct the final argument name in the top(1) manpage.

The description talks about 'number', while the final argument was
'count'.  Since 'count' is already used for the count of displays,
change the final argument name to 'number'.

MFC after: 3 days

4 years agocontrolelf: some style(9) cleanup
emaste [Fri, 27 Sep 2019 16:57:32 +0000 (16:57 +0000)]
controlelf: some style(9) cleanup

Submitted by: clang-format

4 years agoFix a race in vm_page_swapqueue().
markj [Fri, 27 Sep 2019 16:46:08 +0000 (16:46 +0000)]
Fix a race in vm_page_swapqueue().

vm_page_swapqueue() atomically transitions a page between queues.  To do
so, it must hold the page queue lock for the old queue.  However, once
the queue index has been updated, the queue lock no longer protects the
page's queue state.  Thus, we must speculatively remove the page from
the old queue before committing the queue state update, and roll back if
the update fails.

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

4 years agocontrolelf: install standard BSD 2 clause license
emaste [Fri, 27 Sep 2019 16:44:29 +0000 (16:44 +0000)]
controlelf: install standard BSD 2 clause license

Reported by: kaktus
Sponsored by: The FreeBSD Foundation

4 years agoFix object locking in vm_object_unwire() after r352174.
markj [Fri, 27 Sep 2019 16:41:34 +0000 (16:41 +0000)]
Fix object locking in vm_object_unwire() after r352174.

Now, vm_page_busy_sleep() expects the page's object to be locked.
vm_object_unwire() does some unusual lazy locking of the object chain
and keeps objects locked until a busy page is encountered or the loop
terminates.  When a busy page is encountered, rather than unlocking all
but the "bottom-level" object, we must instead skip the object to which
"tm" belongs.

Reported and tested by: pho
Reviewed by: kib
Discussed with: jeff
Sponsored by: Intel, Netflix
Differential Revision: https://reviews.freebsd.org/D21790

4 years agocontrolelf: clean up warnings
emaste [Fri, 27 Sep 2019 16:35:08 +0000 (16:35 +0000)]
controlelf: clean up warnings

- use explicit ELF note name when not found
- no trailing . on warnings
- no \n

Sponsored by: The FreeBSD Foundation

4 years agonvdimm(4): Extract ACPI root bus driver
cem [Fri, 27 Sep 2019 16:32:44 +0000 (16:32 +0000)]
nvdimm(4): Extract ACPI root bus driver

No functional change intended.

The intent is to add a "legacy" e820 pmem newbus bus for nvdimm device in a
subsequent revision, and it's a little more clear if the parent buses get
independent source files.

Quite a lot of ACPI-specific logic is left in nvdimm.c; disentangling that
is a much larger change (and probably not especially useful).

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D21813

4 years agoAdd tool to modify ELF binary feature control bits
emaste [Fri, 27 Sep 2019 16:27:52 +0000 (16:27 +0000)]
Add tool to modify ELF binary feature control bits

This will allow feature control bits (e.g. for ASLR, PROT_MAX) to be
inspected or modified.

Some clean-up and additional work is likely still required, but we can
iterate on this in the tree.

Submitted by: Bora Ã–zarslan <borako.ozarslan@gmail.com>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19290