]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r326769:
bapt [Sun, 7 Jan 2018 10:29:15 +0000 (10:29 +0000)]
MFC r326769:

Remove hard coded number of lun definition

The number of lun exposed is now exposed via sysctl by the kernel.
Use that number in ctlstat instead of the hardcoded version
Add a backward compatibility in case the sysctl(2) request fails.

This also allows ctlstat -l 1118 to actually work when having more than
1024 luns.

Reviewed by: avg, manu (both before the backward compatibility addition)
Approved by: avg, manu (both before the backward compatibility addition)
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D13446

6 years agoMFC r327220-r327221
ian [Sun, 7 Jan 2018 02:59:27 +0000 (02:59 +0000)]
MFC r327220-r327221

r327220:
Update the FDT example for the lm75 sensor to match current devicetree
standards and what the existing driver expects.

Also change 'like' to 'such as' where the text is providing an example
rather than a simile.

r327221:
Complete the changing of the old "i2c-address" property to the modern "reg"
property by updating the description text to match the updated example.

This should have been part of r327220

6 years agoMFC r327222:
ian [Sun, 7 Jan 2018 02:57:35 +0000 (02:57 +0000)]
MFC r327222:

Add a new ARM kernel option, LOCORE_MAP_MB, to control the size of the
kernel VA mapping in the temporary page tables set up by locore-v6.S.

The number used to be hard-coded to 64MB, which is still the default if
the kernel option is not specified.  However, 64MB is insufficient for
using a large mdroot filesystem.  The hard-coded number can't be safely
increased because too large a number may run into memory-mapped IO space
on some SoCs that must not be mapped as ordinary memory.

6 years agoMFC r327226, r327356
ian [Sun, 7 Jan 2018 01:08:10 +0000 (01:08 +0000)]
MFC r327226, r327356

r327226:
Add a section describing how to tune ARM kernel options to use an MD_ROOT
filesystem larger than about 50-55 MiB.

The description of VM_KMEM_SIZE_SCALE is roughly as hand-wavy as my
understanding of the option, but at least mentioning that it's a factor
and giving an empirical datapoint that works will give folks some idea
of what to tweak if they have problems.

r327356:
Correct a mistake and reword a couple sentences to clarify that "the value"
refers to the scale value, not the kmem_arena size that results from scaling.

Suggested by: alc@

6 years agoMFC r327439:
ian [Sun, 7 Jan 2018 01:06:04 +0000 (01:06 +0000)]
MFC r327439:

Allow use of .WAIT in the LOCAL_DIRS and LOCAL_LIB_DIRS lists.

A comment in Makefile.inc1 has long stated that LOCAL_DIRS are built last,
after the base system.  Incremental improvements in parallel building over
the years have led to LOCAL_DIRS being built in parallel with base system
directories.  This change allows the .WAIT directive to appear in LOCAL_DIRS
and LOCAL_LIB_DIRS lists to give the user some control over parallel
building of local additions.

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

6 years agoMFC r327398:
eadler [Sun, 7 Jan 2018 00:38:34 +0000 (00:38 +0000)]
MFC r327398:

isgreater(3): correct description of isunordered macro

PR: 211376
Submitted by: Duane <parakleta@darkreality.org>

6 years agoMFC r327396:
eadler [Sun, 7 Jan 2018 00:35:52 +0000 (00:35 +0000)]
MFC r327396:

man(1): document exit code

man(1) uses standard exit codes, document that.

PR: 223517
Reported by: wosch

6 years agoMFC r327420:
eadler [Sun, 7 Jan 2018 00:31:45 +0000 (00:31 +0000)]
MFC r327420:

skel: Quote PAGER in dot.shrc

PR: 181853
Submitted by: pl@catslair.org

6 years agoMFC r327367:
ian [Sun, 7 Jan 2018 00:04:13 +0000 (00:04 +0000)]
MFC r327367:

Make kernel option KERNVIRTADDR optional, remove it from std.<platform>
files that can use the default value.

It used to be required that the low-order bits of KERNVIRTADDR matched
the low-order bits of the physical load address for all arm platforms.
That hasn't been a requirement for armv6 platforms since FreeBSD 10.
There is no longer any relationship between load addr and KERNVIRTADDR
except that both must be aligned to a 2 MiB boundary.

This change makes the default KERNVIRTADDR value 0xc0000000, and removes the
options from all the platforms that can use the default value.  The default
is now defined in vmparam.h, and that file is now included in a few new
places that reference KERNVIRTADDR, since it may not come in via the
forced-include of opt_global.h on the compile command line.

6 years agoMFC r327048-r327050
ian [Sat, 6 Jan 2018 23:24:52 +0000 (23:24 +0000)]
MFC r327048-r327050

r327048:
Restore the ability to use EARLY_PRINTF support during most of initarm().

The real kernel page tables are set up much earlier in initarm() now than
they were when early printf support was first added, and they end up undoing
the mapping made in locore.S for early printf support.  This re-adds the
mapping after switching to the new/real kernel page tables, making early
printf work again right after switching to them.

r327049:
Allow pmap_kremove() to remove 1MB section mappings as well as 4K pages.
This will allow it to undo temporary device mappings such as those made
with pmap_preboot_map_attr().

Reviewed by: cognet

r327050:
If a temporary mapping is made to support EARLY_PRINTF, undo that mapping
after cninit() runs, otherwise we leave a bogus device-memory mapping in
userspace VA in the kernel pmap forever.

Pointed out by: cognet

6 years agoMFC r327032:
ian [Sat, 6 Jan 2018 23:20:35 +0000 (23:20 +0000)]
MFC r327032:

Add a new kernel config option, MD_ROOT_READONLY, which forces on the
MD_READONLY flag for the md device automatically instantiated during
kernel init for an mdroot filesystem.

Note that there is specifically and by design no tunable or sysctl
control over this feature.  Without this option, you already have control
over whether the mdroot fs is writeable using vfs.root.mountfrom.options
from loader(8), the root_rw_mount rcvar, and by using "mount -u[rw] /"
or equivelent on the fly.  This option is being added to provide a way
to make the mdroot fs truly immutable before userland code begins running.

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

6 years agoMFC r326924-r326925
ian [Sat, 6 Jan 2018 23:12:32 +0000 (23:12 +0000)]
MFC r326924-r326925

r326924:
Fix debugging output, fallout from something like s/read/readctl/g
while renaming variables in a previous change.

r326925:
Do not attempt to refill the TX fifo if there is no data left to transfer.

A comment in bcm_bsc_fill_tx_fifo() even lists sc_totlen > 0 as a
precondition for calling the routine.   I apparently forgot to make the
code do what my comment said.

6 years agoMFC r326750:
ian [Sat, 6 Jan 2018 23:04:14 +0000 (23:04 +0000)]
MFC r326750:

Do not give up if writing to the chip's control and status registers fails
during startup.  When a brand new chip leaves the factory, it is in a
special power-saving mode that disables most functions on the chip to
save battery power.  The chip is stuck in this mode until the first write
to the time registers, which automatically clears the special power-saving
mode and starts the oscillator.

Also, the day-of-week register in this chip counts 1-7, not 0-6, so write
the values accordingly.

These changes are based on the patch submitted by Brian Scott, but I
elimated warnings since this condition is expected, and added some comments,
and so in general blame me for any mistakes.

PR: 223642

6 years agoMFC r327211: nandtool: Add missing mode for open() with O_CREAT
jilles [Sat, 6 Jan 2018 22:59:10 +0000 (22:59 +0000)]
MFC r327211: nandtool: Add missing mode for open() with O_CREAT

If O_CREAT is given, open() needs a mode argument. Follow the umask by
passing 0666.

6 years agoMFC r325108:
ian [Sat, 6 Jan 2018 22:56:48 +0000 (22:56 +0000)]
MFC r325108:

Improve the performance of the hpet timer in bhyve guests by making the
timer frequency a power of two.  This changes the frequency from 10 to
16.7 MHz (2 ^ 24 HZ).  Using a power of two avoids roundoff errors when
doing arithmetic in sbintime_t units.

Testing shows this can fix erratic ntpd behavior in guests using the
hpet timer (which is the default for multicore guests).

6 years agoMFC r325045, r325054-r325056, r325061, r325063, r325065
ian [Sat, 6 Jan 2018 21:19:52 +0000 (21:19 +0000)]
MFC r325045, r325054-r325056, r325061, r325063, r325065

r325045:
Actually release resources in detach() rather than just returning EBUSY.
This will enable use of 'devctl disable', allow creation of a module, etc.

r325054:
Increase the alignment of the rx/tx descriptor ring buffers to 64 bytes.

16 was the correct alignment for older hardware, but the imx7 requires
64-byte alignment, which is a fine value to use on all systems.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

r325055:
Add FECFLAG_AVB variant flag to support new features on imx7.

This flag is analogous to the Linux driver FEC_QUIRK_HAS_AVB.  It
indicates an FEC with support for Audio Video Bridging (AVB).  This
indicator is used for various other parts in the Linux driver
(drivers/net/ethernet/freescale/fec_main.c).

Use it to customize the receive/transmit buffer alignment.  The receive
buffer alignment increased to 64-bytes on the i.MX 6SoloX and i.MX
7Dual.  There are no hard alignment restrictions for transmit buffers on
these chips.

Fix the ffec_softc::fectype type to provide enough storage for the
feature flags.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

r325056:
Avoid AXI bus issues due to a MAC reset on imx6sx and imx7.

When the FEC is connected to the AXI bus (indicated by AVB flag), a
MAC reset while a bus transaction is pending can hang the bus.
Instead of resetting, turn off the ENABLE bit, which allows the
hardware to complete any in-progress transfers (appending a bad CRC
to any partial packet) and release the AXI bus.  This could probably
be done unconditionally for all hardware variants, but that hasn't
been tested.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

r325061:
Support up to 3 IRQs in the ffec driver.

Newer hardware splits the interrupts onto 3 different irq lines, but the
docs barely mention that there are multiple interrupts, and do not detail
how they're split up.  The code now supports 1-3 irqs, and uses the same
interrupt service routine to handle all of them.

I modified the submitted changes to use bus_alloc_resources() instead of
using loops to allocate each irq separately.  Thus, blame any bugs on me (I
can't actually test on imx7 hardware).

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

r325063:
Use the 16-bit receive shift feature in ffec hardware that supports it.

When available, enabling this feature causes the hardware to write data
to the receive buffer starting at a 16-bit offset from the start address.
This eliminates the need to copy the data after receiving to re-align
the protocol headers to a 32-bit boundary.

PR: 222634
Submitted by: sebastian.huber@embedded-brains.de

r325065:
Split the hardware type enum and the hw feature flags bits into separate
fields in the softc; they're ORed together in the ofw_compat_data.

I already caught myself doing 'sc->fectype == <enum val>' without masking
out the feature bits in one place, and that's sure to happen again.
Glomming them together is convenient for storing them in the ofw_compat_data
array, but there's no reason to keep them together in the softc.

6 years agoMFC r325060:
ian [Sat, 6 Jan 2018 20:52:30 +0000 (20:52 +0000)]
MFC r325060:

Add a #define RESOURCE_SPEC_END.  Similar to DEVMETHOD_END and
KOBJMETHOD_END, this is to serve as the end marker in an array of
resource_spec structures.

6 years agoMFC r326654:
bryanv [Sat, 6 Jan 2018 20:22:32 +0000 (20:22 +0000)]
MFC r326654:

Use consistent name for the vxlan VNI parameter name and provide shorthand

6 years agoFix imx6 hdmi init after r323553.
ian [Sat, 6 Jan 2018 19:24:49 +0000 (19:24 +0000)]
Fix imx6 hdmi init after r323553.

This is a direct commit to 11-stable because major architectural changes in
12 prevent a direct MFC of the affected code.  Conceptually, this is...

MFC r324416:

Fix imx6 hdmi init after r323553, which used a config_intrhook to defer the
attachment of i2c devices needed by hdmi.

The hdmi init also uses an intrhook callback to defer initialization, and if
the hdmi callback runs first, the i2c devices will not yet have registered
their device_t in association with their FDT phandle, which allows cross-
device references on FDT systems.

Now the hdmi deferred init checks for the i2c device registration, and if
it's not complete yet, it registers as an eventhandler watching for newbus
attach events.  When the i2c device eventually attaches, the hdmi driver
unregisters from watching further events, and continues with the hdmi init.
Because the function signatures for an intrhook callback and an event
handler callback are the same, a single function is used for both callbacks.

Reported by: Russell Haley <russ.haley@gmail.com>

6 years agoMFC r324413, r324415
ian [Sat, 6 Jan 2018 17:20:58 +0000 (17:20 +0000)]
MFC r324413, r324415

r324413:
Restore the ability to deregister an eventhandler from within the callback.

When the EVENTHANDLER(9) subsystem was created, it was a documented feature
that an eventhandler callback function could safely deregister itself. In
r200652 that feature was inadvertantly broken by adding drain-wait logic to
eventhandler_deregister(), so that it would be safe to unload a module upon
return from deregistering its event handlers.

There are now 145 callers of EVENTHANDLER_DEREGISTER(), and it's likely many
of them are depending on the drain-wait logic that has been in place for 8
years. So instead of creating a separate eventhandler_drain() and adding it
to some or all of those 145 call sites, this creates a separate
eventhandler_drain_nowait() function for the specific purpose of
deregistering a callback from within the running callback.

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

r324415:
Add eventhandler notifications for newbus device attach/detach.

The detach case is slightly complicated by the fact that some in-kernel
consumers may want to know before a device detaches (so they can release
related resources, stop using the device, etc), but the detach can fail. So
there are pre- and post-detach notifications for those consumers who need to
handle all cases.

A couple salient comments from the review, they amount to some helpful
documentation about these events, but there's currently no good place for
such documentation...

Note that in the current newbus locking model, DETACH_BEGIN and
DETACH_COMPLETE/FAILED sequence of event handler invocation might interweave
with other attach/detach events arbitrarily. The handlers should be prepared
for such situations.

Also should note that detach may be called after the parent bus knows the
hardware has left the building. In-kernel consumers have to be prepared to
cope with this race.

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

6 years agoMFC r302480:
eadler [Sat, 6 Jan 2018 06:34:49 +0000 (06:34 +0000)]
MFC r302480:

Add -P to pathchk usage

6 years agoMFC r327183:
eadler [Sat, 6 Jan 2018 05:00:36 +0000 (05:00 +0000)]
MFC r327183:

.git*: add gitattributes and gitignore

For users of the git mirrors, lets provide useful git configuration
files.

6 years agoMFC r324185:
ian [Fri, 5 Jan 2018 19:28:13 +0000 (19:28 +0000)]
MFC r324185:

Enhance the interrupt capabilities of ti_pruss driver.

The existing ti_pruss driver for the PRUSS Hardware provided by the AM335x
ARM CPU has basic interrupt capabilities.  This updated driver provides some
more options:

 - Sysctl based configuration for the interrupts (for some examples, see the
   test plan in the phabricator review cited below).

 - A device file (/dev/pruss0.irqN) for each enabled interrupt. This file
   can be read and the device blocks if no irq has happened or returns an
   uint64_t timestamp based on nanouptime().

 - Each interrupt device file provides kqueue-based event notification,
   blocking read(), or select().

Submitted by: Manuel Stuhn <freebsdnewbie@freenet.de>
Differential Revision: https://reviews.freebsd.org/D11959

6 years agoMFC r324169:
ian [Fri, 5 Jan 2018 19:21:45 +0000 (19:21 +0000)]
MFC r324169:

Work around bcm283x silicon bugs to make i2c repeat-start work for the most
common case where it's needed -- a write followed by a read to the same slave.

The i2c controller in this chip only performs complete transfers, it does
not provide control over start/repeat-start/stop operations on the bus.
Thus, we have gotten a full stop/start sequence rather than a repeat-start
when doing a typical i2c slave access of "write address, read data".  Some
i2c slave devices require a repeat-start to work correctly.

These changes cause the controller to do a repeat-start by pre-staging the
read parameters in the controller registers immediate after the controller
has latched the values for the initial write operation, but before any
bytes are actually written.  With the values pre-staged, when the write
portion of the transfer completes, the state machine in the silicon sees
a new start operation already staged and that causes it to perform a
repeat-start.  The key to tricking the buggy hardware into doing this is
to avoid prefilling any output data in the transmit FIFO so that it is
possible to catch the silicon in the state where transmit values are
latched but the transmit isn't completed yet.

6 years agoMFC r319987, r324107-r324108
ian [Fri, 5 Jan 2018 19:12:36 +0000 (19:12 +0000)]
MFC r319987, r324107-r324108

r319987 (MFC'd just to make following changes apply cleanly):
Replace md(4) usage in diskless(8) script rc.initdiskless with tmpfs(5).
Need to multiply the size of the disk passed to mount_md by 512 as mdmfs
expects number of 512-byte blocks while tmpfs size option wants number of
bytes.

r324107:
Enhance mdmfs(8) to work with tmpfs(5).

Existing scripts and associated config such as rc.initdiskless, rc.d/var,
and others, use mdmfs to create memory filesystems. That program accepts a
size argument which allows SI suffixes and treats an unsuffixed number as a
count of 512 byte sectors. That makes it difficult to convert existing
scripts to use tmpfs instead of mdmfs, because tmpfs treats unsuffixed
numbers as a count of bytes. The script logic to deal with existing user
config that might include suffixed and unsuffixed numbers is... unpleasant.

Also, there is no g'tee that tmpfs will be available. It is sometimes
configured out of small-resource embedded systems to save memory and flash
storage space.

These changes enhance mdmfs(8) so that it accepts two new values for the
'md-device' arg: 'tmpfs' and 'auto'. With tmpfs, the program always uses
tmpfs(5) (and fails if it's not available). With 'auto' the program prefers
tmpfs, but falls back to using md(4) if tmpfs isn't available. It also
handles the -s <size> argument so that the mdconfig interpetation of
unsuffixed numbers applies when tmpfs is used as well, so that existing user
config keeps working after a switch to tmpfs.

A new rc setting, mfs_type, is added to etc/defaults/rc.conf to let users
force the use of tmpfs or md; the default value is "auto".

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

r324108:
Remove spurious $flags; it's a paste-o from copying the line from rc.subr.
Also, add a comment documenting the args passed to mount_md().

6 years agoMFC r327329:
pfg [Fri, 5 Jan 2018 17:21:51 +0000 (17:21 +0000)]
MFC r327329:
dev/txp: Update if_txpreg.h to match OpenBSD's version.

Resolve a minor mismatch: TXP_CMD_READ_VERSION instead of
TXP_CMD_VERSIONS_READ.
Curiously the later is defined but not used in OpenBSD.

Obtained from: OpenBSD (CVS 1.31-1.34)

6 years agoMFC r327497, r327498: fix memory disclosure in hpt* ioctls
emaste [Fri, 5 Jan 2018 16:04:56 +0000 (16:04 +0000)]
MFC r327497, r327498: fix memory disclosure in hpt* ioctls

r327497: hpt27xx: plug info leak in hpt_ioctl

The hpt27xx ioctl handler allocates a buffer without M_ZERO and calls
hpt_do_ioctl(), which might not overwrite the entire buffer.

Also zero bytesReturned in case it is not written by hpt_do_ioctl().

The hpt27xx device has permissions only for root so this is not urgent,
and the fix can be MFCd and considered for a future EN.

Reported by:  Ilja van Sprundel <ivansprundel@ioactive.com>
Submitted by: Domagoj Stolfa <domagoj.stolfa@gmail.com> (M_ZERO)

r327498: hpt{nr,rr}: plug info leak in hpt_ioctl

The hpt{nr,rr} ioctl handler allocates a buffer without M_ZERO and calls
hpt_do_ioctl(), which might not overwrite the entire buffer.

Also zero bytesReturned in case it is not written by hpt_do_ioctl().

The hpt27{nr,rr} device has permissions only for root so this is not urgent,
and the fix can be MFCd and considered for a future EN.

The same issue was reported in the hpt27xx driver by Ilja Van Sprundel.

Security: memory disclosure in root-only ioctls
Sponsored by: The FreeBSD Foundation

6 years agoMFC r327359:
kib [Fri, 5 Jan 2018 11:46:45 +0000 (11:46 +0000)]
MFC r327359:
Do not lock vm map in swapout_procs().

6 years agoMFC r327354:
kib [Fri, 5 Jan 2018 11:45:40 +0000 (11:45 +0000)]
MFC r327354:
Style.

6 years agoMFC r326807:
fsu [Fri, 5 Jan 2018 10:04:13 +0000 (10:04 +0000)]
MFC r326807:
Fix extattr getters in case of neither uio nor buffer was not passed to VOP_*.

Approved by:    pfg (mentor)

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

6 years agoMFC r327094: Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system.
mav [Fri, 5 Jan 2018 02:15:05 +0000 (02:15 +0000)]
MFC r327094:  Add AHCI/XHCI device IDs found on AMD Ryzen+B350 system.

6 years agoMFC: r323076, r324502, r325670, r326866
jkim [Thu, 4 Jan 2018 19:43:42 +0000 (19:43 +0000)]
MFC: r323076, r324502, r325670, r326866

Merge ACPICA 20171214.

6 years agoMFC: r324501
jkim [Thu, 4 Jan 2018 19:35:55 +0000 (19:35 +0000)]
MFC: r324501

Do not check whether AcpiOsGetTimer() is called during boot.

6 years agoMFC r326861-r326863:
markj [Thu, 4 Jan 2018 16:19:56 +0000 (16:19 +0000)]
MFC r326861-r326863:
Add some gmirror tests and fix indentation in existing tests.

6 years agoMFC r326912:
markj [Thu, 4 Jan 2018 16:18:30 +0000 (16:18 +0000)]
MFC r326912:
Fix a logic bug in makefs lazy inode initialization.

6 years agoMFC r326774, r326811:
markj [Thu, 4 Jan 2018 16:17:31 +0000 (16:17 +0000)]
MFC r326774, r326811:
Pass the trap frame to fasttrap hooks.

6 years agoMFC r327295:
pfg [Thu, 4 Jan 2018 15:55:27 +0000 (15:55 +0000)]
MFC r327295:
Start syncing changes from OpenBSD's ip6_id.c instead of ip_id.c.

correct non-repetitive ID code, based on comments from niels provos.
- seed2 is necessary, but use it as "seed2 + x" not "seed2 ^ x".
- skipping number is not needed, so disable it for 16bit generator (makes
  the repetition period to 30000)

Obtained from: OpenBSD (CVS rev. 1.2)

6 years agoMFC r327286:
kib [Thu, 4 Jan 2018 11:51:02 +0000 (11:51 +0000)]
MFC r327286:
Reuse kern_proc_vmmap_resident() for procfs_map resident count.

6 years agoMFC r327285:
kib [Thu, 4 Jan 2018 11:49:32 +0000 (11:49 +0000)]
MFC r327285:
Make kern_proc_vmmap_resident() externally accesible, and move the
vmmap_skip_res_cnt control check inside it.

6 years agoMFC r327316:
kib [Thu, 4 Jan 2018 11:44:58 +0000 (11:44 +0000)]
MFC r327316:
In vm_swapout_map_deactivate_pages(), it is enough to lock the map for read.

6 years agoMFC r327319:
kib [Thu, 4 Jan 2018 11:43:42 +0000 (11:43 +0000)]
MFC r327319:
Clean up the comment.

6 years agoMFC r327469:
kib [Thu, 4 Jan 2018 11:40:22 +0000 (11:40 +0000)]
MFC r327469:
Add CR4.SMAP control bit.

6 years agoMFC r327284:
kib [Thu, 4 Jan 2018 11:38:42 +0000 (11:38 +0000)]
MFC r327284:
Style.  Remove useless return.

6 years agoMFC r327264i (by imp), r327283:
kib [Thu, 4 Jan 2018 11:36:13 +0000 (11:36 +0000)]
MFC r327264i (by imp), r327283:
Fix returns without cleanups.

6 years agoMFC r322812:
smh [Wed, 3 Jan 2018 15:01:31 +0000 (15:01 +0000)]
MFC r322812:

Avoid TCP log messages which are false positives.

Sponsored by: Multiplay

6 years agoMFC r327140:
ae [Wed, 3 Jan 2018 12:18:55 +0000 (12:18 +0000)]
MFC r327140:
  Fix rule number truncation, use uint16_t type to specify rulenum.
  Also sort variable declartions by size.

  PR: 224555

6 years agoMFC r327437:
kib [Wed, 3 Jan 2018 11:03:44 +0000 (11:03 +0000)]
MFC r327437:
Remove MP SAFE marks and stray register name in comments.

6 years agoMFC r324328:
mjg [Tue, 2 Jan 2018 20:22:31 +0000 (20:22 +0000)]
MFC r324328:

     amd64: remove unused variable from pmap_delayed_invl_genp

This is take #2.

6 years agoMFC r326983:
markj [Tue, 2 Jan 2018 16:19:41 +0000 (16:19 +0000)]
MFC r326983:
Avoid using bioq_* in gmirror.

6 years agoMFC r326935:
markj [Tue, 2 Jan 2018 16:15:24 +0000 (16:15 +0000)]
MFC r326935:
Avoid CPU migration in dtrace_gethrtime() on x86.

6 years agoMFC r326919:
markj [Tue, 2 Jan 2018 16:14:36 +0000 (16:14 +0000)]
MFC r326919:
Unregister the ARC lowmem event handler earlier in arc_fini().

6 years agoMFC r325924:
mjg [Tue, 2 Jan 2018 00:14:46 +0000 (00:14 +0000)]
MFC r325924:

    sched: move panic handling code out of choosethread

    This avoids jumps in the common case of the kernel not being panicked.

6 years agoMFC r324867,r324869:
mjg [Tue, 2 Jan 2018 00:11:56 +0000 (00:11 +0000)]
MFC r324867,r324869:

    sdt: whack unused SDT_PROBE_ENABLED

=============

    sdt: make all sdt probe sites test one variable

    This saves on cache misses at the expense of a slight grow of .text.

    Note this is a bandaid for lack of hotpatching.

6 years agoMFC r324335,r327393,r327397,r327401,r327402:
mjg [Tue, 2 Jan 2018 00:02:36 +0000 (00:02 +0000)]
MFC r324335,r327393,r327397,r327401,r327402:

    locks: take the number of readers into account when waiting

    Previous code would always spin once before checking the lock. But a lock
    with e.g. 6 readers is not going to become free in the duration of once spin
    even if they start draining immediately.

    Conservatively perform one for each reader.

    Note that the total number of allowed spins is still extremely small and is
    subject to change later.

=============

    rwlock: tidy up __rw_runlock_hard similarly to r325921

=============

    sx: read the SX_NOADAPTIVE flag and Giant ownership only once

    These used to be read multiple times when waiting for the lock the become
    free, which had the potential to issue completely avoidable traffic.

=============

    locks: re-check the reason to go to sleep after locking sleepq/turnstile

    In both rw and sx locks we always go to sleep if the lock owner is not
    running.

    We do spin for some time if the lock is read-locked.

    However, if we decide to go to sleep due to the lock owner being off cpu
    and after sleepq/turnstile gets acquired the lock is read-locked, we should
    fallback to the aforementioned wait.

=============

    sx: fix up non-smp compilation after r327397

=============

    locks: adjust loop limit check when waiting for readers

    The check was for the exact value, but since the counter started being
    incremented by the number of readers it could have jumped over.

=============

    Return a non-NULL owner only if the lock is exclusively held in owner_sx().

    Fix some whitespace bugs while here.

6 years agoMFC r327394,r327395:
mjg [Mon, 1 Jan 2018 23:45:09 +0000 (23:45 +0000)]
MFC r327394,r327395:

    mtx: pre-read the lock value in thread_lock_flags_

    Since this function is effectively slow path, if we get here the lock is most
    likely already taken in which case it is cheaper to not blindly attempt the
    atomic op.

    While here move hwpmc probe out of the loop to match other primitives.

=============

    mtx: deduplicate indefinite wait check in spinlocks and thread lock

6 years agoMFC r327164:
dim [Mon, 1 Jan 2018 20:39:12 +0000 (20:39 +0000)]
MFC r327164:

Fix clang 6.0.0 compiler warnings in binutils

Latest clang git has a warning -Wnull-pointer-arithmetic which will
trigger a -Werror failure. Addition and subtraction from a null pointer
is undefined behaviour and could be optimized into anything.

Furthermore, using the difference between two pointers and casting the
result back to a pointer is not portable since the size of ptrdiff_t
does not necessary have to be the same as size of void* (this happens
e.g. on CHERI). Using intptr_t instead fixes this portability issue and
the compiler warning.

Submitted by; Alexander Richardson
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D12928

6 years agoMFC r327167:
dim [Mon, 1 Jan 2018 20:24:16 +0000 (20:24 +0000)]
MFC r327167:

Remove obsolete register keyword from opensolaris's sysmacros.h.  When
compiling zfsd with recent clang, it leads to a warning about the
register storage class being incompatible with C++17.

6 years agoMFC r327435:
bz [Sun, 31 Dec 2017 16:52:29 +0000 (16:52 +0000)]
MFC r327435:

  Happy New Year 2018 my friends!

6 years agoMFC r324045:
mjg [Sun, 31 Dec 2017 05:16:23 +0000 (05:16 +0000)]
MFC r324045:

    sysctl: remove target buffer read/write checks prior to calling the handler

    Said checks were inherently racy anyway as jokers could unmap target areas
    before the handler got around to accessing them.

    This saves time by avoiding locking the address space.

6 years agoMFC r320561,r323236,r324041,r324314,r324609,r324613,r324778,r324780,r324787,
mjg [Sun, 31 Dec 2017 05:06:35 +0000 (05:06 +0000)]
MFC r320561,r323236,r324041,r324314,r324609,r324613,r324778,r324780,r324787,
    r324803,r324836,r325469,r325706,r325917,r325918,r325919,r325920,r325921,
    r325922,r325925,r325963,r326106,r326107,r326110,r326111,r326112,r326194,
    r326195,r326196,r326197,r326198,r326199,r326200,r326237:

    rwlock: perform the typically false td_rw_rlocks check later

    Check if the lock is available first instead.

=============

    Sprinkle __read_frequently on few obvious places.

    Note that some of annotated variables should probably change their types
    to something smaller, preferably bit-sized.

=============

    mtx: drop the tid argument from _mtx_lock_sleep

    tid must be equal to curthread and the target routine was already reading
    it anyway, which is not a problem. Not passing it as a parameter allows for
    a little bit shorter code in callers.

=============

    locks: partially tidy up waiting on readers

    spin first instant of instantly re-readoing and don't re-read after
    spinning is finished - the state is already known.

    Note the code is subject to significant changes later.

=============

    locks: take the number of readers into account when waiting

    Previous code would always spin once before checking the lock. But a lock
    with e.g. 6 readers is not going to become free in the duration of once spin
    even if they start draining immediately.

    Conservatively perform one for each reader.

    Note that the total number of allowed spins is still extremely small and is
    subject to change later.

=============

    mtx: change MTX_UNOWNED from 4 to 0

    The value is spread all over the kernel and zeroing a register is
    cheaper/shorter than setting it up to an arbitrary value.

    Reduces amd64 GENERIC-NODEBUG .text size by 0.4%.

=============

    mtx: fix up owner_mtx after r324609

    Now that MTX_UNOWNED is 0 the test was alwayas false.

=============

    mtx: clean up locking spin mutexes

    1) shorten the fast path by pushing the lockstat probe to the slow path
    2) test for kernel panic only after it turns out we will have to spin,
    in particular test only after we know we are not recursing

=============

    mtx: stop testing SCHEDULER_STOPPED in kabi funcs for spin mutexes

    There is nothing panic-breaking to do in the unlock case and the lock
    case will fallback to the slow path doing the check already.

=============

    rwlock: reduce lockstat branches in the slowpath

=============

    mtx: fix up UP build after r324778

=============

    mtx: implement thread lock fastpath

=============

    rwlock: fix up compilation without KDTRACE_HOOKS after r324787

=============

    rwlock: use fcmpset for setting RW_LOCK_WRITE_SPINNER

=============

    sx: avoid branches if in the slow path if lockstat is disabled

=============

    rwlock: avoid branches in the slow path if lockstat is disabled

=============

    locks: pull up PMC_SOFT_CALLs out of slow path loops

=============

    mtx: unlock before traversing threads to wake up

    This shortens the lock hold time while not affecting corretness.
    All the woken up threads end up competing can lose the race against
    a completely unrelated thread getting the lock anyway.

=============

    rwlock: unlock before traversing threads to wake up

    While here perform a minor cleanup of the unlock path.

=============

    sx: perform a minor cleanup of the unlock slowpath

    No functional changes.

=============

    mtx: add missing parts of the diff in r325920

    Fixes build breakage.

=============

    locks: fix compilation issues without SMP or KDTRACE_HOOKS

=============

    locks: remove the file + line argument from internal primitives when not used

    The pair is of use only in debug or LOCKPROF kernels, but was passed (zeroed)
    for many locks even in production kernels.

    While here whack the tid argument from wlock hard and xlock hard.

    There is no kbi change of any sort - "external" primitives still accept the
    pair.

=============

    locks: pass the found lock value to unlock slow path

    This avoids an explicit read later.

    While here whack the cheaply obtainable 'tid' argument.

=============

    rwlock: don't check for curthread's read lock count in the fast path

=============

    rwlock: unbreak WITNESS builds after r326110

=============

    sx: unbreak debug after r326107

    An assertion was modified to use the found value, but it was not updated to
    handle a race where blocked threads appear after the entrance to the func.

    Move the assertion down to the area protected with sleepq lock where the
    lock is read anyway. This does not affect coverage of the assertion and
    is consistent with what rw locks are doing.

=============

    rwlock: stop re-reading the owner when going to sleep

=============

    locks: retry turnstile/sleepq loops on failed cmpset

    In order to go to sleep threads set waiter flags, but that can spuriously
    fail e.g. when a new reader arrives. Instead of unlocking everything and
    looping back, re-evaluate the new state while still holding the lock necessary
    to go to sleep.

=============

    sx: change sunlock to wake waiters up if it locked sleepq

    sleepq is only locked if the curhtread is the last reader. By the time
    the lock gets acquired new ones could have arrived. The previous code
    would unlock and loop back. This results spurious relocking of sleepq.

    This is a step towards xadd-based unlock routine.

=============

    rwlock: add __rw_try_{r,w}lock_int

=============

    rwlock: fix up compilation of the previous change

    commmitted wrong version of the patch

=============

    Convert in-kernel thread_lock_flags calls to thread_lock when debug is disabled

    The flags argument is not used in this case.

=============

    Add the missing lockstat check for thread lock.

=============

    rw: fix runlock_hard when new readers show up

    When waiters/writer spinner flags are set no new readers can show up unless
    they already have a different rw rock read locked. The change in r326195 failed
    to take that into account - in presence of new readers it would spin until
    they all drain, which would be lead to trouble if e.g. they go off cpu and
    can get scheduled because of this thread.

6 years agoMFC r325725:
mjg [Sun, 31 Dec 2017 04:09:40 +0000 (04:09 +0000)]
MFC r325725:

    sysctl: try to avoid malloc in name2oid

    name2oid is called all the time and passed names are almost always very short
    (< 16 characters).

6 years agoMFC r323307,r323308,r323385,r324378,r325266,r325268,r325433,r325451,r325456,
mjg [Sun, 31 Dec 2017 04:06:11 +0000 (04:06 +0000)]
MFC r323307,r323308,r323385,r324378,r325266,r325268,r325433,r325451,r325456,
    r325458:

    namecache: factor out dot lookup into a dedicated function

    The intent is to move uncommon cases out of the way.

=============

    namecache: fold the unlock label into the only consumer

    No functional changes.

=============

    namecache: clean up struct namecache_ts handling

    namecache_ts differs from mere namecache by few fields placed mid struct.
    The access to the last element (the name) is thus special-cased.

    The standard solution is to put new fields at the very beginning anad
    embedd the original struct. The pointer shuffled around points to the
    embedded part. If needed, access to new fields can be gained through
    __containerof.

=============

    namecache: factor out ~MAKEENTRY lookups from the common path

    Lookups of the sort are rare compared to regular ones and succesfull ones
    result in removing entries from the cache.

    In the current code buckets are rlocked and a trylock dance is performed,
    which can fail and cause a restart. Fixing it will require a little bit
    of surgery and in order to keep the code maintaineable the 2 cases have
    to split.

=============

    namecache: ncnegfactor 16 -> 12

    It is used on each new entry addition to decide whether to whack an existing
    negative entry in order to prevent a blow out in size, but the parameter was
    set years ago and never revisited.

    Building with poudriere results in about 400 evictions per second which
    unnecessarily grab entries from the hot list.

    With the new parameter there are next to no evictions of the sort.

=============

    namecache: fix .. check broken after r324378

=============

    namecache: skip locking in cache_purge_negative if there are no entries

=============

    namecache: skip locking in cache_lookup_nomakeentry if there is no entry

=============

    namecache: wlock buckets in cache_lookup_nomakeentry

    Since the case of an empty chain was already covered, it si very likely
    that the existing entry is matching. Skipping readlocking saves on lock
    upgrade.

=============

    namecache: bump numcache after dropping all locks

    This makes no difference correctness-wise, but shortens total hold time.

6 years agoMFC r323235,r323236,r324789,r324863:
mjg [Sun, 31 Dec 2017 03:35:34 +0000 (03:35 +0000)]
MFC r323235,r323236,r324789,r324863:

    Introduce __read_frequently

    While __read_mostly groups variables together, their placement is not
    specified. In particular 2 frequently used variables can end up in
    different lines.

    This annotation is only expected to be used for variables read all the time,
    e.g. on each syscall entry.

=============

    Sprinkle __read_frequently on few obvious places.

    Note that some of annotated variables should probably change their types
    to something smaller, preferably bit-sized.

=============

    Mark kdb_active as __read_frequently and switch to bool to eat less space.

=============

    Change kdb_active type to u_char.

    Fixes warnings from gcc and keeps the small size. Perhaps nesting should be moved
    to another variablle.

6 years agoMFC r324547:
mjg [Sun, 31 Dec 2017 03:17:28 +0000 (03:17 +0000)]
MFC r324547:

    xinstall: plug an infinite loop in directory creation

    If stat continues to fail with ENOENT and mkdir with EEXIST the code wont
    finish. In particular this can show up when the target path follows through
    a symlink to a non-existent directory.

6 years agoMFC r324127:
mjg [Sun, 31 Dec 2017 03:15:45 +0000 (03:15 +0000)]
MFC r324127:

    tmpfs: skip zero-sized page count updates

    Such updates consisted of vast majority of modificiations, especially
    in tmpfs_reg_resize.

    For the case where page count did no change and the size grew we only
    need to update tn_size. Use this fact to avoid vm object lock/relock.

6 years agoMFC r323234,r323305,r323306,r324044:
mjg [Sun, 31 Dec 2017 03:06:29 +0000 (03:06 +0000)]
MFC r323234,r323305,r323306,r324044:

    Start annotating global _padalign locks with __exclusive_cache_line

    While these locks are guarnteed to not share their respective cache lines,
    their current placement leaves unnecessary holes in lines which preceeded them.

    For instance the annotation of vm_page_queue_free_mtx allows 2 neighbour
    cachelines (previously separate by the lock) to be collapsed into 1.

    The annotation is only effective on architectures which have it implemented in
    their linker script (currently only amd64). Thus locks are not converted to
    their not-padaligned variants as to not affect the rest.

=============

    Annotate global process locks with __exclusive_cache_line

=============

    Annotate Giant with __exclusive_cache_line

=============

    Annotate sysctlmemlock with __exclusive_cache_line.

6 years agoMFC r321922:
mjg [Sun, 31 Dec 2017 02:48:16 +0000 (02:48 +0000)]
MFC r321922:
    amd64: annotate the syscall return address check with __predict_false

    before:
       0xffffffff80b03ebb <+2059>:      mov    0x460(%r14),%rax
       0xffffffff80b03ec2 <+2066>:      mov    0x98(%rax),%rax
       0xffffffff80b03ec9 <+2073>:      shr    $0x2f,%rax
       0xffffffff80b03ecd <+2077>:      je     0xffffffff80b03edd <amd64_syscall+2093>
       0xffffffff80b03ecf <+2079>:      mov    0x3f8(%r14),%rax
       0xffffffff80b03ed6 <+2086>:      orl    $0x1,0xc8(%rax)
       0xffffffff80b03edd <+2093>:      add    $0xf8,%rsp

    after:
       0xffffffff80b03ebb <+2059>:      mov    0x460(%r14),%rax
       0xffffffff80b03ec2 <+2066>:      mov    0x98(%rax),%rax
       0xffffffff80b03ec9 <+2073>:      shr    $0x2f,%rax
       0xffffffff80b03ecd <+2077>:      jne    0xffffffff80b03eef <amd64_syscall+2111>
       0xffffffff80b03ecf <+2079>:      add    $0xf8,%rsp

6 years agoIn stable/11, support for including config. files is broken and only the
roberto [Fri, 29 Dec 2017 16:48:14 +0000 (16:48 +0000)]
In stable/11, support for including config. files is broken and only the
last one is taken into account.

Code in 12-CURRENT s different and works so commit is in stable/11.

Patch by Alexander Zagrebin <alex@zagrebin.ru> in the PR.

PR: 220884
Relnotes: yes
Submitted by: Dan McGregor <dan.mcgregor@usask.ca>

6 years agoMFC r326876:
ae [Fri, 29 Dec 2017 10:47:24 +0000 (10:47 +0000)]
MFC r326876:
  Follow the RFC6980 and silently ignore following IPv6 NDP messages
  that had the IPv6 fragmentation header:
   o  Neighbor Solicitation
   o  Neighbor Advertisement
   o  Router Solicitation
   o  Router Advertisement
   o  Redirect

  Introduce M_FRAGMENTED mbuf flag, and set it after IPv6 fragment reassembly
  is completed. Then check the presence of this flag in correspondig ND6
  handling routines.

  PR: 224247

6 years agoMFC r327029:
ume [Wed, 27 Dec 2017 14:50:07 +0000 (14:50 +0000)]
MFC r327029:
Don't ignore trailing spaces after numerical IP addresses.

PR: 224403

6 years agoMFC r326613: Update tcpdump to 4.9.2
emaste [Wed, 27 Dec 2017 03:24:24 +0000 (03:24 +0000)]
MFC r326613: Update tcpdump to 4.9.2

It contains many fixes, including bounds checking, buffer overflows (in
SLIP and bittok2str_internal), buffer over-reads, and infinite loops.

One other notable change:
  Do not use getprotobynumber() for protocol name resolution.
  Do not do any protocol name resolution if -n is specified.

Relnotes: Yes
Security: CVE-2017-11108, CVE-2017-11541, CVE-2017-11542
Security: CVE-2017-11543, CVE-2017-12893, CVE-2017-12894
Security: CVE-2017-12895, CVE-2017-12896, CVE-2017-12897
Security: CVE-2017-12898, CVE-2017-12899, CVE-2017-12900
Security: CVE-2017-12901, CVE-2017-12902, CVE-2017-12985
Security: CVE-2017-12986, CVE-2017-12987, CVE-2017-12988
Security: CVE-2017-12989, CVE-2017-12990, CVE-2017-12991
Security: CVE-2017-12992, CVE-2017-12993, CVE-2017-12994
Security: CVE-2017-12995, CVE-2017-12996, CVE-2017-12997
Security: CVE-2017-12998, CVE-2017-12999, CVE-2017-13000
Security: CVE-2017-13001, CVE-2017-13002, CVE-2017-13003
Security: CVE-2017-13004, CVE-2017-13005, CVE-2017-13006
Security: CVE-2017-13007, CVE-2017-13008, CVE-2017-13009
Security: CVE-2017-13010, CVE-2017-13011, CVE-2017-13012
Security: CVE-2017-13013, CVE-2017-13014, CVE-2017-13015
Security: CVE-2017-13016, CVE-2017-13017, CVE-2017-13018
Security: CVE-2017-13019, CVE-2017-13020, CVE-2017-13021
Security: CVE-2017-13022, CVE-2017-13023, CVE-2017-13024
Security: CVE-2017-13025, CVE-2017-13026, CVE-2017-13027
Security: CVE-2017-13028, CVE-2017-13029, CVE-2017-13030
Security: CVE-2017-13031, CVE-2017-13032, CVE-2017-13033
Security: CVE-2017-13034, CVE-2017-13035, CVE-2017-13036
Security: CVE-2017-13037, CVE-2017-13038, CVE-2017-13039
Security: CVE-2017-13040, CVE-2017-13041, CVE-2017-13042
Security: CVE-2017-13043, CVE-2017-13044, CVE-2017-13045
Security: CVE-2017-13046, CVE-2017-13047, CVE-2017-13048
Security: CVE-2017-13049, CVE-2017-13050, CVE-2017-13051
Security: CVE-2017-13052, CVE-2017-13053, CVE-2017-13054
Security: CVE-2017-13055, CVE-2017-13687, CVE-2017-13688
Security: CVE-2017-13689, CVE-2017-13690, CVE-2017-13725

6 years agoMFC r317409 by glebius:
emaste [Wed, 27 Dec 2017 03:18:13 +0000 (03:18 +0000)]
MFC r317409 by glebius:

Cherry-pick 5d3c5151c2b885aab36627bafb8539238da27b2d, it fixes use after free
if tcpdump(1) is run on non-existent interface.

6 years agoMFC r326835: Reduce size of several on-stack string buffers.
mav [Wed, 27 Dec 2017 00:34:13 +0000 (00:34 +0000)]
MFC r326835: Reduce size of several on-stack string buffers.

Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>

6 years agoMFC r327088:
kib [Tue, 26 Dec 2017 20:56:55 +0000 (20:56 +0000)]
MFC r327088:
Update HISTORY section for the atomic(9) page.

6 years agoMFC r326982
alc [Tue, 26 Dec 2017 20:33:45 +0000 (20:33 +0000)]
MFC r326982
  Document the semantics of atomic_thread_fence operations.

  Add atomic_load_<type> and atomic_store_<type>, and explain why they
  exist.

  Define the synchronizes-with relationship and its effects.

  Reorder and revise some of the existing text.  For example, more
  precisely describe when ordinary accesses are atomic.

6 years agoMFC r326480:
bryanv [Tue, 26 Dec 2017 17:12:16 +0000 (17:12 +0000)]
MFC r326480:

Add if media and link status events to vxlan

6 years agoMFC r326496:
dim [Tue, 26 Dec 2017 14:44:02 +0000 (14:44 +0000)]
MFC r326496:

Upgrade our copies of clang, llvm, lldb and libc++ to r319231 from the
upstream release_50 branch.  This corresponds to 5.0.1 rc2.

MFC r326831:

Pull in r315334 from upstream lld trunk (by Rafael Espindola):

  Don't create a dummy __tls_get_addr.

  We just don't need one with the current setup.

  We only error on undefined references that are used by some
  relocation.

  If we managed to relax all uses of __tls_get_addr, no relocation uses
  it and we don't produce an error.

  This is less code and fixes the case were we fail to relax. Before we
  would produce a broken output, but now we produce an error.

Pull in r320390 from upstream lld trunk (by Rafael Espindola):

  Create reserved symbols early so they can be versioned.

  This fixes pr35570.

  We were creating these symbols after parsing version scripts, so they
  could not be versioned.

  We cannot move the version script parsing later because we need it for
  lto.

  One option is to move both addReservedSymbols and
  createSyntheticSections earlier. The disadvantage is that some
  sections created by createSyntheticSections replace other input
  sections. For example, gdb index replaces .debug_gnu_pubnames, so it
  wants to run after gc sections so that it can set S->Live to false.

  What this patch does instead is to move just the ElfHeader creation
  early.

Pull in r320412 from upstream lld trunk (by Rafael Espindola):

  Handle symbols pointing to output sections.

  Now that gc sections runs after linker defined symbols are added it
  can see symbols that point to an OutputSection.

  Should fix a bot failure.

Pull in r320431 from upstream lld trunk (by Peter Collingbourne):

  ELF: Do not follow relocation edges to output sections during GC.

  This fixes an assertion error introduced by r320390.

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

Together these fix handling of reserved symbols, in particular _end,
which is needed to make brk(2) and sbrk(2) work correctly.  This
unbreaks the emacs ports on amd64, and also appears to unbreak most of
world on i386.

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

MFC r326879 (by emaste):

lld: Simplify a boolean expression by De Morgan's laws.

Cherry-pick lld r315653 by Rui Ueyama:
    I don't really understand what exactly this expression means,
    but at least I can mechanically transform it.

Obtained from: LLVM r315653

MFC r326897 (by emaste):

lld: Slightly simplify code and add comment.

Cherry-pick lld r315658 by Rui Ueyama:
    This is not a mechanical transformation. Even though I believe this
    patch is correct, I'm not 100% sure if lld with this patch behaves
    exactly the same way as before on all edge cases. At least all tests
    still pass.

    I'm submitting this patch because it took almost a day to understand
    this function, and I don't want to lose it.

This fixes jemalloc assertion failures observed at startup with i386
binaries and an lld-linked libc.so.

Reviewed by: dim
Obtained from: LLVM r315658
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13503

MFC r326909:

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
5.0.1 release (upstream r320880).

Relnotes: yes

MFC r326957 (by emaste):

lld: Don't write preemptible symbol values to the .got.

It is not necessary and matches what bfd and gold do.

This was a regression from [LLVM] r315658.

Obtained from: LLVM r321023 by Rafael EspĂ­ndola

6 years agoMFC r324536 (by emaste):
dim [Tue, 26 Dec 2017 14:26:15 +0000 (14:26 +0000)]
MFC r324536 (by emaste):

libunwind: use upstream patch to disable executable stacks

arm uses '@' as a comment character, and cannot use @progbits in the
.section directive. Apply the upstream noexec stach change which avoids
this issue.

Obtained from: LLVM r277868

6 years agoMFC r326973:
kib [Tue, 26 Dec 2017 10:09:18 +0000 (10:09 +0000)]
MFC r326973:
Use atomic_load(9) to read ppsinfo sequence numbers.

6 years agoMFC r326971, r327047 (by ian), r327053 (by marius), r327074, r327097:
kib [Tue, 26 Dec 2017 10:07:17 +0000 (10:07 +0000)]
MFC r326971, r327047 (by ian), r327053 (by marius), r327074, r327097:
Add atomic_load(9) and atomic_store(9) operations.

6 years agoMFC r327118:
kib [Tue, 26 Dec 2017 09:57:15 +0000 (09:57 +0000)]
MFC r327118:
Add missed AVX512VL (128 and 256 bit vector length) extension
identification bit.

6 years agoMFC r326977:
kib [Tue, 26 Dec 2017 09:55:36 +0000 (09:55 +0000)]
MFC r326977:
mlx5en: Avoid SFENCe on x86.

6 years agoMFC r326791: Close the correct file descriptor.
delphij [Tue, 26 Dec 2017 08:32:02 +0000 (08:32 +0000)]
MFC r326791: Close the correct file descriptor.

6 years agoMFC r326401:
asomers [Tue, 26 Dec 2017 04:02:35 +0000 (04:02 +0000)]
MFC r326401:

Fix assertion when ZFS fails to open certain devices

"panic: vdev_geom_close_locked: cp->private is NULL"
This panic will result if ZFS fails to open a device due to either of the
following reasons:

1) The device's sector size is greater than 8KB.
2) ZFS wants to open the device RW, but it can't be opened for writing.

The solution is to change the initialization order to ensure that the
assertion will be satisfied.

PR: 221066
Reported by: David NewHamlet <wheelcomplex@gmail.com>
Reviewed by: avg
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D13278

6 years agoMFC r326290:
asomers [Tue, 26 Dec 2017 04:00:30 +0000 (04:00 +0000)]
MFC r326290:

diskinfo(8): Delete dead code in slog test

Reported by: Coverity
CID: 1377556
Reviewed by: mav
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D13275

6 years agoMFC r326289:
asomers [Tue, 26 Dec 2017 03:59:49 +0000 (03:59 +0000)]
MFC r326289:

Add basic tests for ctfconvert(1), fold(1) and rs(1)

Add basic command line parsing test coverage for these utilities.  The tests
were automatically generated based on their man pages.  These tests can be
expanded by hand for more thorough coverage.  The aim is to generate very
basic amount of test coverage for all the utilities in the base system.

Tests generated via: https://github.com/shivansh/smoketestsuite/

Submitted by: shivansh
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D12424

6 years agoMFC r326185: Set errno to EFTYPE instead of EINVAL to be more consistent
delphij [Mon, 25 Dec 2017 04:32:15 +0000 (04:32 +0000)]
MFC r326185: Set errno to EFTYPE instead of EINVAL to be more consistent
with the rest of code.

6 years agoMFC r326186: Slightly fix bidirectional stream number allocation.
mav [Mon, 25 Dec 2017 00:25:15 +0000 (00:25 +0000)]
MFC r326186: Slightly fix bidirectional stream number allocation.

This logic is still imperfect, since it allows at most 15 bidirectional
streams out of 30 allowed by specification, but at least now those should
work better.  On the other side I don't remember I ever saw controller
supporting the bidirectional streams, so this is likely a nop change.

6 years agoMFC r326898:
ae [Sun, 24 Dec 2017 02:05:19 +0000 (02:05 +0000)]
MFC r326898:
  Fix possible memory leak.

  vxlan_ftable entries are sorted in descending order, due to wrong arguments
  order it is possible to stop search before existing element will be found.
  Then new element will be allocated in vxlan_ftable_update_locked() and can
  be inserted in the list second time or trigger MPASS() assertion with
  enabled INVARIANTS.

  PR: 224371

6 years agoMFC r326872: fix expiration arithmetic after r326738 and MFC.
eugen [Fri, 22 Dec 2017 18:14:55 +0000 (18:14 +0000)]
MFC r326872: fix expiration arithmetic after r326738 and MFC.

Approved by: mav (mentor)

6 years agoMFC r326808, r326824:
fsu [Fri, 22 Dec 2017 17:19:08 +0000 (17:19 +0000)]
MFC r326808, r326824:
Move buffer size checks outside of the vnode locks.

Reviewed by:    kib, cem, pfg (mentor)
Approved by:    pfg (mentor)

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

6 years agoMFC r326878:
markj [Fri, 22 Dec 2017 16:15:44 +0000 (16:15 +0000)]
MFC r326878:
Mark uctf/err.user64mode.ksh as EXFAIL for now.

6 years agoMFC r326877:
markj [Fri, 22 Dec 2017 16:15:00 +0000 (16:15 +0000)]
MFC r326877:
Skip gnop tests if the corresponding kernel module isn't available.

6 years agoMFC r326881, r326882:
markj [Fri, 22 Dec 2017 16:14:20 +0000 (16:14 +0000)]
MFC r326881, r326882:
Minor cleanup.

6 years agoMFC r326410:
markj [Thu, 21 Dec 2017 22:48:02 +0000 (22:48 +0000)]
MFC r326410:
Document gmirror sysctls.

6 years agoMFC r326409:
markj [Thu, 21 Dec 2017 22:47:04 +0000 (22:47 +0000)]
MFC r326409:
Update gmirror metadata less frequently when synchronizing.

6 years agoMFC r326847:
ae [Thu, 21 Dec 2017 14:09:06 +0000 (14:09 +0000)]
MFC r326847:
  Fix mbuf leak when TCPMD5_OUTPUT() method returns error.

  PR: 223817

6 years agoMFC r326851:
kib [Thu, 21 Dec 2017 13:30:56 +0000 (13:30 +0000)]
MFC r326851:
In devfs_lookupx() dotdot lookup case, avoid dereferencing
dvp->v_mount after dvp is unlocked.

6 years agoMFC r326561: Use strlcpy().
delphij [Wed, 20 Dec 2017 07:55:47 +0000 (07:55 +0000)]
MFC r326561: Use strlcpy().

6 years agoMFC r326560: Create links for xzdiff.
delphij [Wed, 20 Dec 2017 07:43:32 +0000 (07:43 +0000)]
MFC r326560: Create links for xzdiff.