]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoThe net.inet.tcp.nolocaltimewait=1 optimization prevents local TCP connections
Gleb Smirnoff [Wed, 21 Mar 2018 20:59:30 +0000 (20:59 +0000)]
The net.inet.tcp.nolocaltimewait=1 optimization prevents local TCP connections
from entering the TIME_WAIT state. However, it omits sending the ACK for the
FIN, which results in RST. This becomes a bigger deal if the sysctl
net.inet.tcp.blackhole is 2. In this case RST isn't send, so the other side of
the connection (also local) keeps retransmitting FINs.

To fix that in tcp_twstart() we will not call tcp_close() immediately. Instead
we will allocate a tcptw on stack and proceed to the end of the function all
the way to tcp_twrespond(), to generate the correct ACK, then we will drop the
last PCB reference.

While here, make a few tiny improvements:
- use bools for boolean variable
- staticize nolocaltimewait
- remove pointless acquisiton of socket lock

Reported by: jtl
Reviewed by: jtl
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D14697

6 years agoUEFI: Ditch console mode setting, choose optimal GOP mode later in boot
Kyle Evans [Wed, 21 Mar 2018 20:36:57 +0000 (20:36 +0000)]
UEFI: Ditch console mode setting, choose optimal GOP mode later in boot

boot1 is too early to be deciding a good resolution. Console modes don't map
cleanly/predictably to actual screen resolutions, and GOP does not reflect
the actual screen resolution after a console mode change. Rip it out.

Add an efi-autoresizecons command to loader to choose an optimal screen
resolution based on the current environment. We'll explicitly execute this
later, preferably before we draw anything of value but after we load config
and pick up any tunables we may need to decide where we're going.

This method also allows us to actually pass the correct framebuffer
information on to the kernel.

UGA autoresizing is not implemented because it doesn't have the kind of mode
enumeration that GOP does. If an interested person with relevant hardware
could get in contact, we can take a look at implementing UGA autoresize.

This effectively "fixes" the breakage caused by r327058, but doesn't
actually set the resolution correctly until the interpreter calls
efi-autoresizcons. The lualoader version of this has been included for
reference; the forth equivalent will follow.

Reviewed by: imp (with some hestitation), manu
Differential Revision: https://reviews.freebsd.org/D14788

6 years agolualoader: Use printc when we expect ANSI escape sequences
Kyle Evans [Wed, 21 Mar 2018 18:02:56 +0000 (18:02 +0000)]
lualoader: Use printc when we expect ANSI escape sequences

6 years agoDocument the limitations associated with using the audit syscalls
Christian S.J. Peron [Wed, 21 Mar 2018 17:22:42 +0000 (17:22 +0000)]
Document the limitations associated with using the audit syscalls
from jailed process.  These might get implemented in jails in the
future, but for now they are not supported.

Discussed on:   freebsd-security@
Reviewed by:    brueffer@
MFC after:      2 weeks

6 years agoImport Blake2 algorithms (blake2b, blake2s) from libb2
Conrad Meyer [Wed, 21 Mar 2018 16:18:14 +0000 (16:18 +0000)]
Import Blake2 algorithms (blake2b, blake2s) from libb2

The upstream repository is on github BLAKE2/libb2.  Files landed in
sys/contrib/libb2 are the unmodified upstream files, except for one
difference:  secure_zero_memory's contents have been replaced with
explicit_bzero() only because the previous implementation broke powerpc
link.  Preferential use of explicit_bzero() is in progress upstream, so
it is anticipated we will be able to drop this diff in the future.

sys/crypto/blake2 contains the source files needed to port libb2 to our
build system, a wrapped (limited) variant of the algorithm to match the API
of our auth_transform softcrypto abstraction, incorporation into the Open
Crypto Framework (OCF) cryptosoft(4) driver, as well as an x86 SSE/AVX
accelerated OCF driver, blake2(4).

Optimized variants of blake2 are compiled for a number of x86 machines
(anything from SSE2 to AVX + XOP).  On those machines, FPU context will need
to be explicitly saved before using blake2(4)-provided algorithms directly.
Use via cryptodev / OCF saves FPU state automatically, and use via the
auth_transform softcrypto abstraction does not use FPU.

The intent of the OCF driver is mostly to enable testing in userspace via
/dev/crypto.  ATF tests are added with published KAT test vectors to
validate correctness.

Reviewed by: jhb, markj
Obtained from: github BLAKE2/libb2
Differential Revision: https://reviews.freebsd.org/D14662

6 years agocryptosoft(4): Zero plain hash contexts, too
Conrad Meyer [Wed, 21 Mar 2018 16:12:07 +0000 (16:12 +0000)]
cryptosoft(4): Zero plain hash contexts, too

An OCF-naive user program could use these primitives to implement HMAC, for
example.  This would make the freed context sensitive data.

Probably other bzeros in this file should be explicit_bzeros as well.
Future work.

Reviewed by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D14662 (minor part of a larger work)

6 years agoUpdate copyright per Matthew Macy
Stephen Hurd [Wed, 21 Mar 2018 15:57:36 +0000 (15:57 +0000)]
Update copyright per Matthew Macy

"Under my tutelage Nicole did 85% of the work. At the time it seemed
simplest for a number of reasons to put my copyright on it. I now consider
that to have been a mistake."

Submitted by: Matthew Macy <mmacy@mattmacy.io>
Reviewed by: shurd
Approved by: shurd
Differential Revision: https://reviews.freebsd.org/D14766

6 years agoIf the INP lock is uncontested, avoid taking a reference and jumping
Jonathan T. Looney [Wed, 21 Mar 2018 15:54:46 +0000 (15:54 +0000)]
If the INP lock is uncontested, avoid taking a reference and jumping
through the lock-switching hoops.

A few of the INP lookup operations that lock INPs after the lookup do
so using this mechanism (to maintain lock ordering):

1. Lock lookup structure.
2. Find INP.
3. Acquire reference on INP.
4. Drop lock on lookup structure.
5. Acquire INP lock.
6. Drop reference on INP.

This change provides a slightly shorter path for cases where the INP
lock is uncontested:

1. Lock lookup structure.
2. Find INP.
3. Try to acquire the INP lock.
4. If successful, drop lock on lookup structure.

Of course, if the INP lock is contested, the functions will need to
revert to the previous way of switching locks safely.

This saves a few atomic operations when the INP lock is uncontested.

Discussed with: gallatin, rrs, rwatson
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D12911

6 years agoUse a table to find the endpoint configuration
Andrew Turner [Wed, 21 Mar 2018 15:17:54 +0000 (15:17 +0000)]
Use a table to find the endpoint configuration

On the Allwinner SoCs we need to set a custom endpoint configuration. To
allow for this use a table to store the configuration so the attachment
can override it.

Reviewed by: hselasky
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14783

6 years agolualoader: Clear up some possible naming confusion
Kyle Evans [Wed, 21 Mar 2018 15:09:47 +0000 (15:09 +0000)]
lualoader: Clear up some possible naming confusion

In the original lualoader project, 'escapef' and 'escapeb' were chosen for
'escape fg' and 'escape bg'. We've carried on this naming convention, and as
our use of attributes grow the likeliness of 'escapeb'/'resetb' being
confused upon glance for 'escape bold'/'reset bold' increases.

Fix this by renaming these four functions to {escape,reset}{fg,bg} rather
than {escape,reset}{f,b} for clarity.

Reported by: dteske

6 years agoMark psycho interrupts as MPSAFE. It's safe to do so now that we don't
Warner Losh [Wed, 21 Mar 2018 14:47:17 +0000 (14:47 +0000)]
Mark psycho interrupts as MPSAFE. It's safe to do so now that we don't
need Giant to call shutdown_nice().

6 years agoUnlock giant when calling shutdown_nice()
Warner Losh [Wed, 21 Mar 2018 14:47:12 +0000 (14:47 +0000)]
Unlock giant when calling shutdown_nice()

6 years agoThis is MPSAFE on this platform, so don't take Giant out while running
Warner Losh [Wed, 21 Mar 2018 14:47:08 +0000 (14:47 +0000)]
This is MPSAFE on this platform, so don't take Giant out while running
the callback.

6 years agoThese interrupts call shutdown_nice() which should be called Giant
Warner Losh [Wed, 21 Mar 2018 14:47:03 +0000 (14:47 +0000)]
These interrupts call shutdown_nice() which should be called Giant
unlocked. Rather than dropping it in the interrupt handler, mark these
handlers as MPSAFE.

6 years agobufshutdown is no longer called with Giant held, so there's no need to
Warner Losh [Wed, 21 Mar 2018 14:46:59 +0000 (14:46 +0000)]
bufshutdown is no longer called with Giant held, so there's no need to
drop or pickup Giant anymore. Remove that code and adjust comments.

6 years agoRemove Giant from init creation and vfs_mountroot.
Warner Losh [Wed, 21 Mar 2018 14:46:54 +0000 (14:46 +0000)]
Remove Giant from init creation and vfs_mountroot.

Sponsored by: Netflix
Discussed with: kib@, mckusick@
Differential Review: https://reviews.freebsd.org/D14712

6 years agoAdd new shared library -- libipt.
Ruslan Bukin [Wed, 21 Mar 2018 14:37:04 +0000 (14:37 +0000)]
Add new shared library -- libipt.

libipt is the Intel Processor Trace (Intel PT) packets decoder.

- Include libipt to amd64 build.
- Install libipt headers to /usr/include/libipt/

Sponsored by: DARPA, AFRL

6 years agoFollowing ports commit r465175, avoid fetch(1) to obtain
Glen Barber [Wed, 21 Mar 2018 14:36:16 +0000 (14:36 +0000)]
Following ports commit r465175, avoid fetch(1) to obtain
overlays and DTB files for the RPI3.

Submitted by: manu
Sponsored by: The FreeBSD Foundation

6 years agoRevert r331273: "Release the "TUR" reference when clearing the TUR work flag. We...
Warner Losh [Wed, 21 Mar 2018 12:55:59 +0000 (12:55 +0000)]
Revert r331273: "Release the "TUR" reference when clearing the TUR work flag. We mostly"

It exposes other issues, so revert to the pervious state of known issues.

6 years agoMove sysinit and sysuninit linker sets in the data (writeable) section.
Konstantin Belousov [Wed, 21 Mar 2018 10:26:39 +0000 (10:26 +0000)]
Move sysinit and sysuninit linker sets in the data (writeable) section.

Both sets are sorted in place, and with the introduction of read-only
permissions on the amd64 kernel text, the sorting override depended on
CR0.WP turned off.  Make it correct by moving the sets into writeable
part of the KVA, also fixing boot on machines where hand-off from BIOS
to OS occurs with CR0.WP set.

Based on submission by: Peter Lei <peter.lei@ieee.org>
MFC after: 1 week

6 years ago[bsd-family-tree] Announce NetBSD 7.1.2
Eitan Adler [Wed, 21 Mar 2018 09:07:01 +0000 (09:07 +0000)]
[bsd-family-tree] Announce NetBSD 7.1.2

MFC After: 3 days

6 years agoAppease GCC 4.2
Conrad Meyer [Wed, 21 Mar 2018 04:44:19 +0000 (04:44 +0000)]
Appease GCC 4.2

It mistakenly believes the 'static' keyword must come first.  Fix PPC,
Sparc64, and maybe MIPS world.  Fallout from r331279.

Reported by: tinderbox (results come slowly)

6 years agoAdd missed sys/limits.h include
Conrad Meyer [Wed, 21 Mar 2018 03:43:40 +0000 (03:43 +0000)]
Add missed sys/limits.h include

Apparently header pollution on x86 hid its absense.  Sorry, other arch
users.

Fix the missed header introduced in r331279.

Reported by: tinderbox

6 years agocore.lua(8): Update to reflect recently added function clearCachedKernels
Kyle Evans [Wed, 21 Mar 2018 03:16:14 +0000 (03:16 +0000)]
core.lua(8): Update to reflect recently added function clearCachedKernels

6 years agolualoader: Add primitive hook module, use it to untangle bogus reference
Kyle Evans [Wed, 21 Mar 2018 03:07:16 +0000 (03:07 +0000)]
lualoader: Add primitive hook module, use it to untangle bogus reference

See: comments in the hook module about intended usage, as well as the
introduced use for config.reloaded.

Use the newly introduced hook module to define a "config.reloaded" hook.
This is currently used to register core's clearKernelCache as a reload hook
to avoid a circular dependency and fix this functionality- it didn't
actually work out, and it isn't immediately obvious how it slipped into src.

Other hook types will be introduced into the core lualoader as useful hook
points are identified.

6 years agoRegenerate sysent files after r331279.
Conrad Meyer [Wed, 21 Mar 2018 01:17:01 +0000 (01:17 +0000)]
Regenerate sysent files after r331279.

6 years agoImplement getrandom(2) and getentropy(3)
Conrad Meyer [Wed, 21 Mar 2018 01:15:45 +0000 (01:15 +0000)]
Implement getrandom(2) and getentropy(3)

The general idea here is to provide userspace programs with well-defined
sources of entropy, in a fashion that doesn't require opening a new file
descriptor (ulimits) or accessing paths (/dev/urandom may be restricted
by chroot or capsicum).

getrandom(2) is the more general API, and comes from the Linux world.
Since our urandom and random devices are identical, the GRND_RANDOM flag
is ignored.

getentropy(3) is added as a compatibility shim for the OpenBSD API.

truss(1) support is included.

Tests for both system calls are provided.  Coverage is believed to be at
least as comprehensive as LTP getrandom(2) test coverage.  Additionally,
instructions for running the LTP tests directly against FreeBSD are provided
in the "Test Plan" section of the Differential revision linked below.  (They
pass, of course.)

PR: 194204
Reported by: David CARLIER <david.carlier AT hardenedbsd.org>
Discussed with: cperciva, delphij, jhb, markj
Relnotes: maybe
Differential Revision: https://reviews.freebsd.org/D14500

6 years agoRepresent boolean jail options as an array of structures containing the
Jamie Gritton [Tue, 20 Mar 2018 23:08:42 +0000 (23:08 +0000)]
Represent boolean jail options as an array of structures containing the
flag and both the regular and "no" names, instead of two different string
arrays whose indices need to match the flag's bit position.  This makes
them similar to the say "jailsys" options are represented.

Loop through either kind of option array with a structure pointer rather
then an integer index.

6 years agoCorrect comment date in r331255
Ed Maste [Tue, 20 Mar 2018 23:08:04 +0000 (23:08 +0000)]
Correct comment date in r331255

Reported by: jhb

6 years agoUse count(9) api for the bpf(4) statistics.
Alexander V. Chernikov [Tue, 20 Mar 2018 22:57:06 +0000 (22:57 +0000)]
Use count(9) api for the bpf(4) statistics.

Currently each bfp descriptor uses u64 variables to maintain its counters.
On interfaces with high packet rate this leads to unnecessary contention
and inaccurate reporting.

PR: kern/205320
Reported by: elofu17 at hotmail.com
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D14726

6 years agoExtend the description of ALTQ to call it a system which is a framework in
Sevan Janiyan [Tue, 20 Mar 2018 22:41:26 +0000 (22:41 +0000)]
Extend the description of ALTQ to call it a system which is a framework in
altq(4) to match altq(9). This makes preserving the history section as the
author of ALTQ easier in the history section, rather than calling it a framework
in the description & a system in the history.
Add a history section to altq(4) and extend the history section in altq(9)

Approved by: bcr (mentor)
MFC after: 5 days
Differential Revision:  https://reviews.freebsd.org/D14774

6 years agoRelease the "TUR" reference when clearing the TUR work flag. We mostly
Warner Losh [Tue, 20 Mar 2018 22:07:45 +0000 (22:07 +0000)]
Release the "TUR" reference when clearing the TUR work flag. We mostly
do this right, except when there's no BP and we do a TUR by request.
In that case, we clear the flag, but don't release the reference,
leaking the reference on rare occasion.

PR: 226510
Sponsored by: Netflix

6 years agoAt this point iwmesg isn't initialized yet, so print pointer to lock
Gleb Smirnoff [Tue, 20 Mar 2018 22:05:21 +0000 (22:05 +0000)]
At this point iwmesg isn't initialized yet, so print pointer to lock
rather than panic before panicing.

6 years agoPush down Giant one layer. In the days of yore, back when Penitums
Warner Losh [Tue, 20 Mar 2018 22:01:18 +0000 (22:01 +0000)]
Push down Giant one layer. In the days of yore, back when Penitums
were the new kids on the block and F00F hacks were all the rage, one
needed to take out Giant to do anything moderately complicated with
the VM, mappings and such. So the pccard / cardbus code held Giant for
the entire insertion or removal process.

Today, the VM is MP safe. The lock is only needed for dealing with
newbus things. Move locking and unlocking Giant to be only around
adding and probing devices in pccard and cardbus.

6 years agoFix whitespace issues in r330034. No functional changes.
Gleb Smirnoff [Tue, 20 Mar 2018 22:00:58 +0000 (22:00 +0000)]
Fix whitespace issues in r330034. No functional changes.

6 years agoRemove reference to lint. We no longer support it, so exceptions for
Warner Losh [Tue, 20 Mar 2018 21:37:33 +0000 (21:37 +0000)]
Remove reference to lint. We no longer support it, so exceptions for
it are no longer relevant.

6 years agoRevert part of r331264: disable interrupts before disabling WP.
Mark Johnston [Tue, 20 Mar 2018 21:36:35 +0000 (21:36 +0000)]
Revert part of r331264: disable interrupts before disabling WP.

We might otherwise be preempted, leaving WP disabled while another
thread runs on the CPU.

Reported by: kib
X-MFC with: r331264

6 years agoUpdate to include information about using SPDX-License-Identifier
Warner Losh [Tue, 20 Mar 2018 21:31:18 +0000 (21:31 +0000)]
Update to include information about using SPDX-License-Identifier
lines.

6 years agoDrop support for lint for cdefs.h.
Warner Losh [Tue, 20 Mar 2018 21:18:40 +0000 (21:18 +0000)]
Drop support for lint for cdefs.h.

6 years agoRemove obsolete lint support.
Warner Losh [Tue, 20 Mar 2018 21:17:48 +0000 (21:17 +0000)]
Remove obsolete lint support.

6 years agoMake use of the KPI added in r331252.
Mark Johnston [Tue, 20 Mar 2018 21:16:26 +0000 (21:16 +0000)]
Make use of the KPI added in r331252.

MFC after: 2 weeks

6 years agoRestore close quote lost in r331254
Ed Maste [Tue, 20 Mar 2018 21:04:47 +0000 (21:04 +0000)]
Restore close quote lost in r331254

6 years agoUse <stdarg.h> instead of <machine/stdarg.h> in userland.
John Baldwin [Tue, 20 Mar 2018 21:00:45 +0000 (21:00 +0000)]
Use <stdarg.h> instead of <machine/stdarg.h> in userland.

<machine/stdarg.h> is a kernel-only header.  The standard header for
userland is <stdarg.h>.  Using the standard header in userland avoids
weird build errors when building with external compilers that include
their own stdarg.h header.

Reviewed by: arichardson, brooks, imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14776

6 years agoRemove a lingering inaccuracy from mlock.2.
Mark Johnston [Tue, 20 Mar 2018 20:45:47 +0000 (20:45 +0000)]
Remove a lingering inaccuracy from mlock.2.

User wirings of the same address range don't stack.

Noted by: Dan Nelson
MFC after: 3 days

6 years agolualoader: Use less atomic options for resetting colors/attributes
Kyle Evans [Tue, 20 Mar 2018 20:26:24 +0000 (20:26 +0000)]
lualoader: Use less atomic options for resetting colors/attributes

Noted by dteske:

CSI 1m ... CSI 22m
CSI 2m ... CSI 22m
CSI 4m ... CSI 24m
CSI 5m ... CSI 25m
CSI 7m ... CSI 27m
CSI 8m ... CSI 28m
CSI (30-37)m ... CSI 39m
CSI (40-47)m ... CSI 49m

- Provide resetf/resetb to match escapef/escapeb
- Use CSI 22m to undo a bold

This is a more reasonable approach than what was previously taken.

Reported by: dteske

6 years agoMove the CR0.WP manipulation KPI to x86.
Konstantin Belousov [Tue, 20 Mar 2018 20:20:49 +0000 (20:20 +0000)]
Move the CR0.WP manipulation KPI to x86.

This should allow to avoid some #ifdefs in the common x86/ code.

Requested by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agolualoader: Reset attributes and color scheme with color.highlight()
Kyle Evans [Tue, 20 Mar 2018 20:05:11 +0000 (20:05 +0000)]
lualoader: Reset attributes and color scheme with color.highlight()

Previously, we sent a CSI 0m sequence to reset attributes, which also reset
the color scheme if the terminal defaults didn't match what we're expecting.
Go all-in and reset the color scheme, too, just in case.

Reported by: emaste

6 years agoMake linuxulator fn declaration match definition
Ed Maste [Tue, 20 Mar 2018 19:28:52 +0000 (19:28 +0000)]
Make linuxulator fn declaration match definition

I accidentally swapped 'linux_fixup_elf' to 'linux_elf_fixup' in amd64's
declaration (only),  while bringing this change over from git and
encountering a conflict.

6 years agoRemove stale generated assym.s files after r331254
Ed Maste [Tue, 20 Mar 2018 18:02:21 +0000 (18:02 +0000)]
Remove stale generated assym.s files after r331254

So that -DNO_CLEAN builds work.

This should be reverted after a sufficient transition period (perhaps 3
or 6 months).

Sponsored by: The FreeBSD Foundation

6 years agoRename assym.s to assym.inc
Ed Maste [Tue, 20 Mar 2018 17:58:51 +0000 (17:58 +0000)]
Rename assym.s to assym.inc

assym is only to be included by other .s files, and should never
actually be assembled by itself.

Reviewed by: imp, bdrewery (earlier)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D14180

6 years agoDisable write protection around patching of XSAVE instruction in the
Konstantin Belousov [Tue, 20 Mar 2018 17:47:29 +0000 (17:47 +0000)]
Disable write protection around patching of XSAVE instruction in the
context switch code.

Some BIOSes give control to the OS with CR0.WP already set, making the
kernel text read-only before cpu_startup().

Reported by: Peter Lei <peter.lei@ieee.org>
Reviewed by: jtl
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14768

6 years agoProvide KPI for handling of rw/ro kernel text.
Konstantin Belousov [Tue, 20 Mar 2018 17:43:50 +0000 (17:43 +0000)]
Provide KPI for handling of rw/ro kernel text.

This is a pure syntax patch to create an interface to enable and later
restore write access to the kernel text and other read-only mapped
regions.  It is in line with e.g. vm_fault_disable_pagefaults() by
allowing the nesting.

Discussed with: Peter Lei <peter.lei@ieee.org>
Reviewed by: jtl
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14768

6 years agoSet the proper vnet in IPsec callback functions.
John Baldwin [Tue, 20 Mar 2018 17:05:23 +0000 (17:05 +0000)]
Set the proper vnet in IPsec callback functions.

When using hardware crypto engines, the callback functions used to handle
an IPsec packet after it has been encrypted or decrypted can be invoked
asynchronously from a worker thread that is not associated with a vnet.
Extend 'struct xform_data' to include a vnet pointer and save the current
vnet in this new member when queueing crypto requests in IPsec.  In the
IPsec callback routines, use the new member to set the current vnet while
processing the modified packet.

This fixes a panic when using hardware offload such as ccr(4) with IPsec
after VIMAGE was enabled in GENERIC.

Reported by: Sony Arpita Das and Harsh Jain @ Chelsio
Reviewed by: bz
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D14763

6 years agoCheck for wrap-around in vm_phys_alloc_seg_contig().
Konstantin Belousov [Tue, 20 Mar 2018 16:17:55 +0000 (16:17 +0000)]
Check for wrap-around in vm_phys_alloc_seg_contig().

It is possible to provide insane values for size in contigmalloc(9)
request, which usually not reaches the phys allocator due to failing
KVA allocation.  But with the forthcoming 4/4 i386, where 32bit
architecture has almost 4G KVA, contigmalloc(1G) is not unreasonable
outright and KVA might be available sometimes.

Then, the calculation of pa_end could wrap around, depending on the
physical address, and the checks in vm_phys_alloc_seg_contig() would
pass while the iteration in the loop after the 'done' label goes out
of the vm_page_array bounds.

Fix it by detecting the wrap.

Reported and tested by: pho
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14767

6 years agoDrop KTR_CONTENTION.
Mark Johnston [Tue, 20 Mar 2018 15:51:05 +0000 (15:51 +0000)]
Drop KTR_CONTENTION.

It is incomplete, has not been adopted in the other locking primitives,
and we have other means of measuring lock contention (lock_profiling,
lockstat, KTR_LOCK). Drop it to slightly de-clutter the mutex code and
free up a precious KTR class index.

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

6 years agoAdd support for MIPS to LLVM's libunwind.
John Baldwin [Tue, 20 Mar 2018 15:44:17 +0000 (15:44 +0000)]
Add support for MIPS to LLVM's libunwind.

This is originally based on a patch from David Chisnall for soft-float
N64 but has since been updated to support O32, N32, and hard-float ABIs.
The soft-float O32, N32, and N64 support has been committed upstream.
The hard-float changes are still in review upstream.

Enable LLVM_LIBUNWIND on mips when building with a suitable (C+11-capable)
toolchain.  This has been tested with external GCC for all ABIs and
O32 and N64 with clang.

Reviewed by: emaste
Obtained from: CheriBSD (original N64 patch)
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D14701

6 years agoRemove the entry about loader.efi needing to be updated before the kernel.
Andrew Turner [Tue, 20 Mar 2018 13:39:41 +0000 (13:39 +0000)]
Remove the entry about loader.efi needing to be updated before the kernel.
The kernel now handles the situation it's warning against as of r331241.

Sponsored by: DARPA, AFRL

6 years agoCheck if the gettime runtime service is valid.
Andrew Turner [Tue, 20 Mar 2018 13:35:20 +0000 (13:35 +0000)]
Check if the gettime runtime service is valid.

The U-Boot efi runtime service expects us to set the address map before
calling any runtime services. It will then remap a few functions to their
runtime version. One of these is the gettime function. If we call into
this without having set a runtime map we get a page fault.

Add a check to see if this is valid in efi_init() so we don't try to use
the possibly invalid pointer.

Reviewed by: imp, kevans (both previous version)
X-MFC-With: r330868
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D14759

6 years agoKill assert I shouldn't have committed
Warner Losh [Tue, 20 Mar 2018 13:14:10 +0000 (13:14 +0000)]
Kill assert I shouldn't have committed

6 years agoStarting LBA is a 64bit number, so use htole64 instead of htole32. The
Warner Losh [Tue, 20 Mar 2018 03:37:14 +0000 (03:37 +0000)]
Starting LBA is a 64bit number, so use htole64 instead of htole32. The
latter casts the LBA to a 32-bit number before assigning it to the 64
bit structure entity. This works fine on the first 2TB of TRIMs, but
terrible beyond that due to trucation.

Also, add an assert to make sure we don't end too many DSM TRIM
entries in one request.

Sponsored by: Netflix

6 years agoMake kern.cam.nda.num_trim tunable to limit the number of BIO_DELETE
Warner Losh [Tue, 20 Mar 2018 03:37:09 +0000 (03:37 +0000)]
Make kern.cam.nda.num_trim tunable to limit the number of BIO_DELETE
requests that we'll collapse into one DSM_TRIM. By default it is a
256, which is the max that will fit into a 4k page.

Sponsored by: Netflix

6 years agoRemove some redundant MPSAFE flags.
Warner Losh [Tue, 20 Mar 2018 03:37:04 +0000 (03:37 +0000)]
Remove some redundant MPSAFE flags.

This was pointed out in a code review I'm having trouble finding right
now, but go ahead and eliminate these.

Sponsored by: Netfix

6 years agoNote: this isn't a general thing. It only affects u-boot-based arm64
Warner Losh [Tue, 20 Mar 2018 03:36:51 +0000 (03:36 +0000)]
Note: this isn't a general thing. It only affects u-boot-based arm64
systems. Make sure the note says that specific case only. Also,
provide a recipe to do it.

Sponsored by: Netflix

6 years agoRationalize license text on Linuxolator files
Ed Maste [Tue, 20 Mar 2018 02:50:11 +0000 (02:50 +0000)]
Rationalize license text on Linuxolator files

i386 linux.h missed in r330239.

Approved by: sos
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

6 years agoCast through uintptr_t to narrow the buf domain pointer on 32-bit archs
Justin Hibbits [Tue, 20 Mar 2018 02:01:30 +0000 (02:01 +0000)]
Cast through uintptr_t to narrow the buf domain pointer on 32-bit archs

arg2 is an intmax_t, which on 32-bit architectures is 64 bits, wider than a
pointer.  When &bdomain[i] is added to arg2 it widens from uintptr_t to
intmax_t, then gcc whines when it gets cast to a pointer.  Casting through
uintptr_t silences this warning.

6 years agoAdd /boot/overlays to ObsoleteFiles
Kyle Evans [Tue, 20 Mar 2018 01:33:04 +0000 (01:33 +0000)]
Add /boot/overlays to ObsoleteFiles

It has been replaced by /boot/dtb/overlays. We haven't yet populated it with
any of our own overlays, so no further damage from here.

Reported by: Oliver Pinter <oliver.pinter@hardenedbsd.org>

6 years agoFix powerpc Book-E build post-331018/331048.
Justin Hibbits [Tue, 20 Mar 2018 01:07:22 +0000 (01:07 +0000)]
Fix powerpc Book-E build post-331018/331048.

pagedaemon_wakeup() was moved from vm_pageout.h to vm_pagequeue.h.

6 years agoblacklist: Fix minor memory leak in configuration parsing error case
Conrad Meyer [Tue, 20 Mar 2018 00:16:24 +0000 (00:16 +0000)]
blacklist: Fix minor memory leak in configuration parsing error case

Ordinarily, the continue clause of the for-loop would free 'line.'  In this
case we instead return early, missing the free.  Add an explicit free to
avoid the leak.

Reported by: Coverity
Sponsored by: Dell EMC Isilon

6 years ago[ofw] fix errneous checks for OF_finddevice(9) return value
Oleksandr Tymoshenko [Tue, 20 Mar 2018 00:03:49 +0000 (00:03 +0000)]
[ofw] fix errneous checks for OF_finddevice(9) return value

OF_finddevices returns ((phandle_t)-1) in case of failure. Some code
in existing drivers checked return value to be equal to 0 or
less/equal to 0 which is also wrong because phandle_t is unsigned
type. Most of these checks were for negative cases that were never
triggered so trhere was no impact on functionality.

Reviewed by: nwhitehorn
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D14645

6 years agoUpdate mpr(4) driver from v15 to v18 from Broadcom site.
Alexander Motin [Mon, 19 Mar 2018 23:21:45 +0000 (23:21 +0000)]
Update mpr(4) driver from v15 to v18 from Broadcom site.

Version 16 is just a number bump, since we already had those changes.

Version 17 introduces new AdapterType value, that allows new user-space
tools from Broadcom to differentiate adapter generations 3 and 3.5.

Version 18 updates headers and adds SAS_DEVICE_DISCOVERY_ERROR reporting.

MFC after: 2 weeks

6 years agoFix initialization of eventhandler mutex.
Matt Joras [Mon, 19 Mar 2018 22:43:27 +0000 (22:43 +0000)]
Fix initialization of eventhandler mutex.

mtx_init does not do a copy of the name string it is passed. The
eventhandler code incorrectly passed the parameter string directly to
mtx_init instead of using the copy it makes. This was an existing
problem with the code that I dutifully copied over in my changes in r325621.

Reported by: Anton Rang <rang AT acm.org>
Reviewed by: rstone, markj
Approved by: rstone (mentor)
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D14764

6 years agoRename linuxulator functions with linux_ prefix
Ed Maste [Mon, 19 Mar 2018 21:26:32 +0000 (21:26 +0000)]
Rename linuxulator functions with linux_ prefix

It's preferable to have a consistent prefix.  This also reduces
differences between the three linux*_sysvec.c files.

Sponsored by: Turing Robotic Industries Inc.

6 years agopf: Fix memory leak in DIOCRADDTABLES
Kristof Provost [Mon, 19 Mar 2018 21:13:25 +0000 (21:13 +0000)]
pf: Fix memory leak in DIOCRADDTABLES

If a user attempts to add two tables with the same name the duplicate table
will not be added, but we forgot to free the duplicate table, leaking memory.
Ensure we free the duplicate table in the error path.

Reported by: Coverity
CID: 1382111
MFC after: 3 weeks

6 years agoixgbe(4): Update shared code, add support for X552 1G, fix bug
Eric Joyner [Mon, 19 Mar 2018 20:55:05 +0000 (20:55 +0000)]
ixgbe(4): Update shared code, add support for X552 1G, fix bug

This patch will:

- Update ixgbe shared code
- Add support for Intel(R) Ethernet Connection X552 1000BASE-T
- Add error handling for link state check preventing VF from stopping traffic
  after changing PF's MTU value

Submitted by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Reviewed by: Intel Networking
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D13885

6 years agocam_periph_acquire() now returns an errno.
Kenneth D. Merry [Mon, 19 Mar 2018 20:19:00 +0000 (20:19 +0000)]
cam_periph_acquire() now returns an errno.

The ch(4) driver was missed in change 328918, which changed
cam_periph_acquire() to return an errno instead of cam_status.

As a result, ch(4) failed to attach.

Sponsored by: Spectra Logic

6 years agoGiven hidden visibility to symbols referenced by the DOF section.
Mark Johnston [Mon, 19 Mar 2018 19:32:05 +0000 (19:32 +0000)]
Given hidden visibility to symbols referenced by the DOF section.

MFC after: 1 week

6 years agoRevert r318180 and re-enable AIO tests on md(4) by default.
John Baldwin [Mon, 19 Mar 2018 19:09:15 +0000 (19:09 +0000)]
Revert r318180 and re-enable AIO tests on md(4) by default.

The 'physio' fast-path used by AIO requests on md(4) devices, is not
gated on the unsafe_aio knob.  Prior to r327755, some AIO requests could
fail the fast-path and fall back to the slow-path (requests for devices
not supporting unmapped I/O and requests which failed with EFAULT during
the fast-path).  However, those cases now return a suitable error rather
than using the slow-path.

PR: 217261
Reviewed by: asomers
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D14742

6 years agoImport Intel Processor Trace decoder library from
Ruslan Bukin [Mon, 19 Mar 2018 18:59:15 +0000 (18:59 +0000)]
Import Intel Processor Trace decoder library from
vendor/processor-trace/24982c1a6fce48f1e416461d42899805f74fbb26

Sponsored by: DARPA, AFRL

6 years agoImport Intel Processor Trace library.
Ruslan Bukin [Mon, 19 Mar 2018 18:34:08 +0000 (18:34 +0000)]
Import Intel Processor Trace library.

Git ID 24982c1a6fce48f1e416461d42899805f74fbb26

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

6 years agoFix a typo.
John Baldwin [Mon, 19 Mar 2018 17:14:56 +0000 (17:14 +0000)]
Fix a typo.

Reviewed by: kib

6 years agoAdd support for the experimental Internet-Draft "TCP Alternative Backoff with
Lawrence Stewart [Mon, 19 Mar 2018 16:37:47 +0000 (16:37 +0000)]
Add support for the experimental Internet-Draft "TCP Alternative Backoff with
ECN (ABE)" proposal to the New Reno congestion control algorithm module.
ABE reduces the amount of congestion window reduction in response to
ECN-signalled congestion relative to the loss-inferred congestion response.

More details about ABE can be found in the Internet-Draft:
https://tools.ietf.org/html/draft-ietf-tcpm-alternativebackoff-ecn

The implementation introduces four new sysctls:

- net.inet.tcp.cc.abe defaults to 0 (disabled) and can be set to non-zero to
  enable ABE for ECN-enabled TCP connections.

- net.inet.tcp.cc.newreno.beta and net.inet.tcp.cc.newreno.beta_ecn set the
  multiplicative window decrease factor, specified as a percentage, applied to
  the congestion window in response to a loss-based or ECN-based congestion
  signal respectively. They default to the values specified in the draft i.e.
  beta=50 and beta_ecn=80.

- net.inet.tcp.cc.abe_frlossreduce defaults to 0 (disabled) and can be set to
  non-zero to enable the use of standard beta (50% by default) when repairing
  loss during an ECN-signalled congestion recovery episode. It enables a more
  conservative congestion response and is provided for the purposes of
  experimentation as a result of some discussion at IETF 100 in Singapore.

The values of beta and beta_ecn can also be set per-connection by way of the
TCP_CCALGOOPT TCP-level socket option and the new CC_NEWRENO_BETA or
CC_NEWRENO_BETA_ECN CC algo sub-options.

Submitted by: Tom Jones <tj@enoti.me>
Tested by: Tom Jones <tj@enoti.me>, Grenville Armitage <garmitage@swin.edu.au>
Relnotes: Yes
Differential Revision: https://reviews.freebsd.org/D11616

6 years agoAmend missed reference to /boot/overlays, moved to /boot/dtb/overlays
Kyle Evans [Mon, 19 Mar 2018 16:17:10 +0000 (16:17 +0000)]
Amend missed reference to /boot/overlays, moved to /boot/dtb/overlays

6 years agoMove /boot/overlays to /boot/dtb/overlays
Kyle Evans [Mon, 19 Mar 2018 16:16:12 +0000 (16:16 +0000)]
Move /boot/overlays to /boot/dtb/overlays

The former is fairly vague; these are FDT overlays to be applied to the
running system, so /boot/dtb is a sensible location to put it without
cluttering up /boot/dtb even further if desired.

6 years agolualoader: Setup default color scheme if we're using colors
Kyle Evans [Mon, 19 Mar 2018 15:48:31 +0000 (15:48 +0000)]
lualoader: Setup default color scheme if we're using colors

The console may have been set for different colors before lualoader kicks
in; notably, a black-on-white color scheme is not necessarily what we're
expecting.

While here, make color.default() a composition of color.escape() instead of
rewriting the escape sequence to make it more obvious what it's achieving: a
white-on-black color scheme with no attributes set.

Reported by: emaste, whose eyes may rest easily

6 years agosys/dts: Remove arm64 from subdir as it no longer exists.
Emmanuel Vadot [Mon, 19 Mar 2018 15:35:26 +0000 (15:35 +0000)]
sys/dts: Remove arm64 from subdir as it no longer exists.

r325987 removed the arm64 directory, remove it from SUBDIR too.

6 years agoAdd note to UPDATING about UEFI changes requiring loader(8) update
Kyle Evans [Mon, 19 Mar 2018 15:27:53 +0000 (15:27 +0000)]
Add note to UPDATING about UEFI changes requiring loader(8) update

These problems have only been observed with boards using U-Boot (e.g. ARM)
where virtual addresses are already set in the memory map by the firmware
and the firmware is expecting a call to SetVirtualAddressMap to be made.
I refrain from mentioning this in the note because this could also be the
case on some not-yet-tested firmware on amd64 and it's not a bad
recommendation for the general case.

6 years agolinux*_sysvec.c: rationalize whitespace and comments
Ed Maste [Mon, 19 Mar 2018 15:11:10 +0000 (15:11 +0000)]
linux*_sysvec.c: rationalize whitespace and comments

There's a fair amount of duplication between MD linuxulator files.
Make indentation and comments consistent between the three versions of
linux_sysvec.c to reduce diffs when comparing them.

Sponsored by: Turing Robotic Industries Inc.

6 years agoloader.conf: remove obsolete non-x86 beastie menu statement
Ed Maste [Mon, 19 Mar 2018 15:07:15 +0000 (15:07 +0000)]
loader.conf: remove obsolete non-x86 beastie menu statement

As of r330005 the same loader.conf defaults are used on all platforms.

Sponsored by: The FreeBSD Foundation

6 years agoRemove redundant integer cast in ibcore. The "ref_count" field already
Hans Petter Selasky [Mon, 19 Mar 2018 13:51:33 +0000 (13:51 +0000)]
Remove redundant integer cast in ibcore. The "ref_count" field already
has integer type.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoRemove note that `fwd tablearg` is supported only by IPv4. IPv6 is
Andrey V. Elsukov [Mon, 19 Mar 2018 10:50:27 +0000 (10:50 +0000)]
Remove note that `fwd tablearg` is supported only by IPv4. IPv6 is
supported too.

MFC after: 1 week

6 years agoPlug a possible memory leak.
Xin LI [Mon, 19 Mar 2018 05:49:26 +0000 (05:49 +0000)]
Plug a possible memory leak.

MFC after: 2 weeks

6 years agoUpdate my calendar entry to be more specific now that UTF8 turns out to be fine
Mateusz Guzik [Mon, 19 Mar 2018 00:25:10 +0000 (00:25 +0000)]
Update my calendar entry to be more specific now that UTF8 turns out to be fine

6 years agoThe gids argument can be declared as const.
Mariusz Zaborski [Sun, 18 Mar 2018 19:50:32 +0000 (19:50 +0000)]
The gids argument can be declared as const.
We don't modified it in this function.

6 years agoAdd the device/chip type to the disk d_descr field, and print more info
Ian Lepore [Sun, 18 Mar 2018 18:58:47 +0000 (18:58 +0000)]
Add the device/chip type to the disk d_descr field, and print more info
about the chip including the erase block size at attach time.

Also add myself to the copyrights since at this point svn blame would point
to me as the culprit for much of this.

6 years agoDon't add links or cleanfiles for NO_OBJ case, in addition to not
Warner Losh [Sun, 18 Mar 2018 18:50:48 +0000 (18:50 +0000)]
Don't add links or cleanfiles for NO_OBJ case, in addition to not
creating them. Move them under the if after the all: target.  They are
just defines, so it doesn't really matter where we have them.

MFC After: 3 days

6 years agoAdd support for 4K and 32K erase block sizes. Many of the supported chips
Ian Lepore [Sun, 18 Mar 2018 18:37:47 +0000 (18:37 +0000)]
Add support for 4K and 32K erase block sizes.  Many of the supported chips
have these flags set in the ident table, but there was no code to support
using the smaller erase sizes.

6 years agoMake all internal routines return an int error status, and check the
Ian Lepore [Sun, 18 Mar 2018 17:47:57 +0000 (17:47 +0000)]
Make all internal routines return an int error status, and check the
status at all call points.  Combine the get_status and wait_for_ready
routines, since waiting for ready is the only reason to ever get status.

6 years agoFix reference to man page in Makefile.
Mariusz Zaborski [Sun, 18 Mar 2018 17:27:37 +0000 (17:27 +0000)]
Fix reference to man page in Makefile.
I broke it in r331120.

6 years agoAdd sc_parent to the softc and use it in place of device_get_parent() calls
Ian Lepore [Sun, 18 Mar 2018 17:25:23 +0000 (17:25 +0000)]
Add sc_parent to the softc and use it in place of device_get_parent() calls
all over the place.  Also pass the softc as the arg to all the internal
functions instead of passing a device_t and calling device_get_softc() in
each function.

6 years agoUse __syscall(2) rather than syscall(2) in syscall/tst.args.c.
Mark Johnston [Sun, 18 Mar 2018 17:03:26 +0000 (17:03 +0000)]
Use __syscall(2) rather than syscall(2) in syscall/tst.args.c.

Some of mmap(2)'s arguments are 64 bits wide.

MFC after: 3 days