]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r343455: Fix tpm2 acpidump compilation on 32-bit
mw [Fri, 26 Apr 2019 02:19:25 +0000 (02:19 +0000)]
MFC r343455: Fix tpm2 acpidump compilation on 32-bit

5 years agoMFC r345438,r345842,r346259,r346261: TPM as possible entropy source
mw [Fri, 26 Apr 2019 01:58:36 +0000 (01:58 +0000)]
MFC r345438,r345842,r346259,r346261: TPM as possible entropy source

r345438:
Allow using TPM as entropy source

TPM has a built-in RNG, with its own entropy source.
The driver was extended to harvest 16 random bytes from TPM every 10 seconds.
A new build option "TPM_HARVEST" was introduced - for now, however, it
is not enabled by default in the GENERIC config.

Reviewed by: markm, delphij
Approved by: secteam

r345842:
Add a cv_wait to the TPM2.0 harvesting function

r346259:
tpm: Prevent session hijack

r346261:
Improve tpm20 style

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield

5 years agoMFC r343438: Use ACPI TPM2 table to probe tpmtis and tpmcrb device
mw [Fri, 26 Apr 2019 01:20:39 +0000 (01:20 +0000)]
MFC r343438: Use ACPI TPM2 table to probe tpmtis and tpmcrb device

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield

5 years agoMFC r342084,r342251,r342271,r342285: Introduce TPM2.0 driver
mw [Fri, 26 Apr 2019 01:02:24 +0000 (01:02 +0000)]
MFC r342084,r342251,r342271,r342285: Introduce TPM2.0 driver

r342084
Introduce driver for TPM 2.0 in CRB and FIFO (TIS) modes

r342251
Include the new TPM 2.0 driver in the TPM module.

r342271
Fix obtaining RSP address in TPM CRB for non-amd64 platforms

r342285
tpm(4): Fix GCC build after r342084 (TPM 2.0 driver commit)

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Stormshield

5 years agoFix build with r346707.
mav [Thu, 25 Apr 2019 22:53:25 +0000 (22:53 +0000)]
Fix build with r346707.

5 years agoMFC r339826 (by yuripv):
mav [Thu, 25 Apr 2019 21:09:07 +0000 (21:09 +0000)]
MFC r339826 (by yuripv):
Provide basic descriptions for VMX exit reason (from "Intel 64 and IA-32
Architectures Software Developer’s Manual Volume 3").  Add the document
to SEE ALSO in bhyve.8 (and pet manlint here a bit).

5 years agoMFC r340731 (by markj): Use taskqueue_quiesce(9) to implement taskq_wait().
mav [Thu, 25 Apr 2019 18:49:29 +0000 (18:49 +0000)]
MFC r340731 (by markj): Use taskqueue_quiesce(9) to implement taskq_wait().

5 years agoMFC r344569, r344618, r344621 (by bapt):
mav [Thu, 25 Apr 2019 18:30:47 +0000 (18:30 +0000)]
MFC r344569, r344618, r344621 (by bapt):

r344569:
Implement parallel mounting for ZFS filesystem

It was first implemented on Illumos and then ported to ZoL.
This patch is a port to FreeBSD of the ZoL version.
This patch also includes a fix for a race condition that was amended

With such patch Delphix has seen a huge decrease in latency of the mount phase
(https://github.com/openzfs/openzfs/commit/a3f0e2b569 for details).
With that current change Gandi has measured improvments that are on par with
those reported by Delphix.

Zol commits incorporated:
https://github.com/zfsonlinux/zfs/commit/a10d50f999511d304f910852c7825c70c9c9e303
https://github.com/zfsonlinux/zfs/commit/e63ac16d25fbe991a356489c86d4077567dfea21

Reviewed by: avg, sef
Approved by: avg, sef
Obtained from: ZoL
Relnotes: yes
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D19098

r344618:
Fix regression introduced in r344569

Reported by: cy
Tested by: cy
Submitted by: Fatih Acar <fatih@gandi.net>

r344621:
Fix a regression introduced in r344569

Import a fix from illumos (thanks Toomas Soomas for pointing at it)

See https://www.illumos.org/issues/10205 for more details
Illumos commit: https://github.com/illumos/illumos-gate/commit/247b7da039fd88350c50e3d7fef15bdab6bef215

Submitted by: jack@gandi.net
Reported by: cy
Reviewed by: tsoome, cy, bapt
Obtained from: Illumos

5 years agoMFC r345200: MFV r336930: 9284 arc_reclaim_thread has 2 jobs
mav [Thu, 25 Apr 2019 17:28:36 +0000 (17:28 +0000)]
MFC r345200: MFV r336930: 9284 arc_reclaim_thread has 2 jobs

`arc_reclaim_thread()` calls `arc_adjust()` after calling
`arc_kmem_reap_now()`; `arc_adjust()` signals `arc_get_data_buf()` to
indicate that we may no longer be `arc_is_overflowing()`.

The problem is, `arc_kmem_reap_now()` can take several seconds to
complete, has no impact on `arc_is_overflowing()`, but due to how the
code is structured, can impact how long the ARC will remain in the
`arc_is_overflowing()` state.

The fix is to use seperate threads to:

1. keep `arc_size` under `arc_c`, by calling `arc_adjust()`, which
    improves `arc_is_overflowing()`

2. keep enough free memory in the system, by calling
 `arc_kmem_reap_now()` plus `arc_shrink()`, which improves
 `arc_available_memory()`.

illumos/illumos-gate@de753e34f9c399037936e8bc547d823bba9d4b0d

Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com>
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Tim Kordas <tim.kordas@joyent.com>
Approved by: Garrett D'Amore <garrett@damore.org>
Author: Brad Lewis <brad.lewis@delphix.com>

5 years agoMFC r344601 (by sef): Set process title during zfs send.
mav [Thu, 25 Apr 2019 17:25:13 +0000 (17:25 +0000)]
MFC r344601 (by sef): Set process title during zfs send.

This adds a '-V' option to 'zfs send', which sets the process title once a
second to the progress information.

This code has been in FreeNAS for a long time now; this is just upstreaming
it here.  It was originially written by delphij.

5 years agoMFC r340311: Do not ignore arc_adjust() return value.
mav [Thu, 25 Apr 2019 17:22:41 +0000 (17:22 +0000)]
MFC r340311: Do not ignore arc_adjust() return value.

This covers scenario when ARC may not shrink as fast as it could:
1. arc_size < arc_c and arc_adjust() does not evict anything, returning
   zero to arc_reclaim_thread();
2. arc_available_memory() reports memory pressure, which can not be
   satisfied by arc_kmem_reap_now();
3. arc_shrink() reduces arc_c and calls arc_adjust(), return of which is
   ignored;
4. even if the last arc_adjust() could not satisfy arc_size < arc_c,
   arc_reclaim_thread() will still go to sleep, since the first one
   returned zero.

5 years agoMFC r339298 (by allanjude):
mav [Thu, 25 Apr 2019 15:56:32 +0000 (15:56 +0000)]
MFC r339298 (by allanjude):
Add missing sysctls for tuning vdev queue depths for new I/O types

This connects new tunables that were added but not exposed in:
r329502 (zpool remove)
r337007 (zpool initialize)

5 years agoMFC r339009 (by allanjude):
mav [Thu, 25 Apr 2019 15:51:00 +0000 (15:51 +0000)]
MFC r339009 (by allanjude):
Avoid panic when adjusting priority of a read in the face of an IO error

PR:             231516
Reported by:    sbruno
Approved by:    re (rgrimes)
Obtained from:  ZFS-on-Linux
X-MFC-with:     334844
Sponsored by:   Klara Systems

MFV/ZoL:        Fix zio->io_priority failed (7 < 6) assert

commit c26cf0966d131b722c32f8ccecfe5791a789d975
Author: Tony Hutter <hutter2@llnl.gov>
Date:   Tue May 29 18:13:48 2018 -0700

  Fix zio->io_priority failed (7 < 6) assert

  This fixes an assert in vdev_queue_change_io_priority():

    VERIFY3(zio->io_priority < ZIO_PRIORITY_NUM_QUEUEABLE) failed (7 < 6)
    PANIC at vdev_queue.c:832:vdev_queue_change_io_priority()

Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
5 years agoMFC r337594 (by mmacy):
mav [Thu, 25 Apr 2019 15:31:35 +0000 (15:31 +0000)]
MFC r337594 (by mmacy):
ZFS/MFV:    Use cached feature info in spa_add_feature_stats()

commit 417104bdd3c7ce07ec58674dd078f9891c3bc780
Author: Ned Bass <bass6@llnl.gov>
Date:   Thu Feb 26 12:24:11 2015 -0800

    Use cached feature info in spa_add_feature_stats()

    Avoid issuing I/O to the pool when retrieving feature flags information.
    Trying to read the ZAPs from disk means that zpool clear would hang if
    the pool is suspended and recovery would require a reboot. To keep the
    feature stats resident in memory, we hang a cached nvlist off of the
    spa.  It is built up from disk the first time spa_add_feature_stats() is
    called, and refreshed thereafter using the cached feature reference
    counts. spa_add_feature_stats() gets called at pool import time so we
    can be sure the cached nvlist will be available if the pool is later
    suspended.

Signed-off-by: Ned Bass <bass6@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
    Closes #3082

5 years agoMFC r346229 and r346248:
hselasky [Thu, 25 Apr 2019 12:01:11 +0000 (12:01 +0000)]
MFC r346229 and r346248:
Fix spelling and remove superfluous USB keyword.

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

5 years agoMFC r346356:
hselasky [Thu, 25 Apr 2019 11:57:34 +0000 (11:57 +0000)]
MFC r346356:
Implement flag for telling cuse(3) clients if the peer is running in 32-bit
compat mode or not. This is useful when implementing compatibility ioctl(2)
handlers in userspace.

Sponsored by: Mellanox Technologies

5 years agoMFC r346118:
markj [Thu, 25 Apr 2019 03:47:32 +0000 (03:47 +0000)]
MFC r346118:
Reinitialize multicast source filter structures after invalidation.

5 years agoMFC r343298:
gonzo [Thu, 25 Apr 2019 00:58:11 +0000 (00:58 +0000)]
MFC r343298:

[ndis] Fix unregistered use of FPU by NDIS in kernel on amd64

amd64 miniport drivers are allowed to use FPU which triggers "Unregistered use
of FPU in kernel" panic.

Wrap all variants of MSCALL with fpu_kern_enter/fpu_kern_leave.  To reduce
amount of allocations/deallocations done via
fpu_kern_alloc_ctx/fpu_kern_free_ctx maintain cache of fpu_kern_ctx elements.

Based on the patch by Paul B Mahol

PR: 165622
Submitted by: Vlad Movchan <vladislav.movchan@gmail.com>

5 years agoMFC r343224, r343533
gonzo [Thu, 25 Apr 2019 00:56:11 +0000 (00:56 +0000)]
MFC r343224, r343533

r343224:
Add KBD_BOOTPROTO quirk for Logitech G510s USB keyboard

PR: 232136
Submitted by: dgilbert@eicat.ca

r343533:
[usb] Add UQ_KBD_BOOTPROTO quirk for Corsair K68 keyboard

PR: 222114
Submitted by: Zane C. Bowers-Hadley <vvelox@vvelox.net>

5 years agoMFC r346319:
kp [Wed, 24 Apr 2019 14:08:16 +0000 (14:08 +0000)]
MFC r346319:

pf: Fix panic on invalid DIOCRSETTFLAGS

If during DIOCRSETTFLAGS pfrio_buffer is NULL copyin() will fault, which we're
not allowed to do with a lock held.
We must count the number of entries in the table and release the lock during
copyin(). Only then can we re-acquire the lock. Note that this is safe, because
pfr_set_tflags() will check if the table and entries exist.

This was discovered by a local syzcaller instance.

5 years agoFixup mismerge of r345079. CONFS in HEAD and stable/12 is FILES in
cy [Tue, 23 Apr 2019 04:06:26 +0000 (04:06 +0000)]
Fixup mismerge of r345079. CONFS in HEAD and stable/12 is FILES in
stable/11.

This is a direct commit to the stable/11 branch.

Reported by: Allendorf, Scott C <scott-allendorf@uiowa.edu>

5 years agoMFC r346254: config(8): replace opteq with a call to strcasecmp
kevans [Tue, 23 Apr 2019 02:37:12 +0000 (02:37 +0000)]
MFC r346254: config(8): replace opteq with a call to strcasecmp

This obscures the comparison slightly less; when option name appear in
files, they are case-insensitive.

5 years agoMFC r346427: cron(8): schedule interval jobs that loaded during execution
kevans [Tue, 23 Apr 2019 02:29:08 +0000 (02:29 +0000)]
MFC r346427: cron(8): schedule interval jobs that loaded during execution

Jobs using the @<second> syntax currently only get executed if they exist
when cron is started. The simplest reproducer of this is:

echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob

myjob will get loaded at the next second==0, but this echo job will not
run until cron restarts. These jobs are normally handled in
run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup
time so they run 'n' seconds later.

Fix this by special-casing TargetTime > 0 in the database load. Preexisting
jobs will be handled at startup during run_reboot_jobs as normal, but if
we've reloaded a database during runtime we'll hit this case and set
e->lastexit to the current time when we process it. They will then run every
'n' seconds from that point, and a full restart of cron is no longer
required to make these jobs work.

5 years agoMFC r337364:
ian [Mon, 22 Apr 2019 15:26:21 +0000 (15:26 +0000)]
MFC r337364:

Document 64-bit arm in terms of arch name (aarch64) not machine (arm64).
Other architectures are documented in terms of the name that is displayed by
'uname -p', aka MACHINE_ARCH and TARGET_ARCH in the build system, now
aarch64 matches the rest of them.

PR: 220297

5 years agoMFC r346312:
ian [Mon, 22 Apr 2019 15:23:06 +0000 (15:23 +0000)]
MFC r346312:

Only set up the interrupts that will actually be used in arm generic_timer.

The code previously set up interrupt handlers for all the interrupt
resources available, including for timers that are not in use.  That could
lead to interrupt storms.  For example, if boot firmware enabled the virtual
timer but the kernel is using the physical timer, it could get flooded with
interrupts on the virtual timer which it cannot shut off.  By only setting
up an interrupt handler for the hardware that will actually be used, any
interrupts from other timer units will remain masked in the interrupt
controller.

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

5 years agoMFC r345475-r345476
ian [Mon, 22 Apr 2019 15:20:46 +0000 (15:20 +0000)]
MFC r345475-r345476

r345475:
Truncate a too-long interrupt handler name when there is only one handler.

There are only 19 bytes available for the name of an interrupt plus the
name(s) of handlers/drivers using it. There is a mechanism from the days of
shared interrupts that replaces some of the handler names with '+' when they
don't all fit into 19 bytes.

In modern times there is typically only one device on an interrupt, but long
device names are the norm, especially with embedded systems. Also, in systems
with multiple interrupt controllers, the names of the interrupts themselves
can be long. For example, 'gic0,s54: imx6_anatop0' doesn't fit, and
replacing the device driver name with a '+' provides no useful info at all.

When there is only one handler but its name was too long to fit, this
change truncates enough leading chars of the handler name (replacing them
with a '-' char to indicate that some chars are missing) to use all 19
bytes, preserving the unit number typically on the end of the name. Using
the prior example, this results in: 'gic0,s54:-6_anatop0' which provides
plenty of info to figure out which device is involved.

PR: 211946
Reviewed by: gonzo@ (prior version without the '-' char)
Differential Revision: https://reviews.freebsd.org/D19675

r345476:
Revert accidental change that should not have been included in r345475.
I had changed this value as part of a local experiment, and neglected to
change it back before committing the other changes.

5 years agoMFC r345480, r346013
ian [Mon, 22 Apr 2019 15:09:47 +0000 (15:09 +0000)]
MFC r345480, r346013

r345480:
Support device-independent labels for geom_flashmap slices.

While geom_flashmap has always supported label names for its slices, it does
so by appending "s.labelname" to the provider device name, meaning you still
have to know the name and unit of the hardware device to use the labels.

These changes add support for device-independent geom_flashmap labels, using
the standard geom_label infrastructure. geom_flashmap now creates a softc
struct attached to its geom, and as it creates slices it stores the label
into an array in the softc. The new geom_label_flashmap uses those labels
when tasting a geom_flashmap provider.

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

r346013:
Add g_label_flashmap.c to the module, should have been part of r345480.

5 years agoMFC r345000:
ian [Mon, 22 Apr 2019 15:06:56 +0000 (15:06 +0000)]
MFC r345000:

Mark the imx_spi device busy while transfers are in progress, so that the
module can't be unloaded while interrupts are pending.

5 years agoMFC r335159, r344505-r344507, r344523, r344525-r344526, r344529, r344556,
ian [Mon, 22 Apr 2019 15:04:11 +0000 (15:04 +0000)]
MFC r335159, r344505-r344507, r344523, r344525-r344526, r344529, r344556,
r344606-r344612, r344614-r344616, r344681, r344684-r344686, r344728,
r344733-r344734, r344981

A large set of changes that collectively modernize the at45d and mx25l
(DataFlash and SpiFlash) drivers, add FDT support, and add geom_flashmap
support to them.

r335159 by manu:
mx25l: Add pnp info

r344505:
Add a functional detach() implementation to make module unloading possible.

r344506:
Add support for probing/attaching on FDT-based systems.

r344507:
Switch to using config_intrhook_oneshot().  That allows the error handling
in the delayed attach to use early returns, which allows reducing the level
of indentation.  So all in all, what looks like a lot of changes is really
no change in behavior, mostly just moving whitespace around.

r344523:
Include the jedec "extended device information string" in the criteria used
to match a chip to our table of metadata describing the chips. At least one
new DataFlash chip has a 3-byte jedec ID identical to its predecessors and
differs only in the extended info, and it has different metadata requiring a
unique entry in the table.  This paves the way for supporting such chips.

The metadata table now includes two new fields, extmask and extid.  The two
bytes of extended info obtained from the chip are ANDed with extmask then
compared to extid, so it's possible to use only a subset of the extended
info in the matching.

We now always read 6 bytes of jedec ID info. Most chips don't return any
extended info, and the values read back for those two bytes may be
indeterminate, but such chips have extmask and extid values of 0x0000 in the
table, so the extid effectively doesn't participate in the matching on those
chips and it doesn't matter what they return in the extended info bytes.

r344525:
Add a metadata entry for the AT45DB641E chip.  This chip has the same 3-byte
jedec ID as its older cousin the AT45DB642D, but uses a different page size.
The only way to distinguish between the two chips is that the 2D chip has
0 bytes of extended ID info and the new 1E has 1 byte of extended ID.  The
actual value of the extended ID byte is all zeroes.  In other words, it's
the presence of the extended info that identifies this chip. (Presumably
a future upgrade might define non-zero values for the extended ID byte.)

r344526:
Resolve a name conflict when both SpiFlash and DataFlash devices are present.

Both SpiFlash (mx25l) and DataFlash (at45d) drivers create a disk device
with a name of /dev/flash/spiN where N is the driver's unit number.  If
both types of devices are present in the same system, this creates a fatal
conflict that prevents attachment of whichever device attaches second
(because mx25l0 and at45d0 both try to create a spi0).

This gives each type of device a unique name (mx25lN or at45dN respectively)
and also adds an alias of spiN for compatibility.  When both device types
appear in the same system, only the first to attach gets the spiN alias.
When the second device attaches there is a non-fatal warning that the alias
can't be created, but both devices are still accessible via their primary
names (and there is no need for the spiN name to work for backwards
compatibility on such a system, because it has never been possible to use
the spiN names when both devices exist).

r344529:
Fix a paste-o that broke the build on all arches.

r344556:
Set maximum bus clock speed from hints when attaching hinted spibus(4) children.

Some devices (such as spigen(4)) document that this works, but it appears that the
code to implement it never got added.

r344606:
Add support for geom_flashmap by providing a getattr() for "SPI:device".

r344607:
Compile fdt_slicer and geom_flashmap when the at45d device is included.

r344608:
Update a comment to reflect reality; no functional changes.

r344609:
Make it possible to load fdt_slicer as a module (unloading works too fwiw).

r344610:
Add manpages for at45d(4) and mx25l(4).

r344611:
Add a module dependency on fdt_slicer.

r344612:
Add a module dependency on fdt_slicer.  Also, move the PNP_INFO to its more
usual location, down near the DRIVER_MODULE() stuff.

r344614:
Rename some functions and variables to have shorter names, which allows
unwrapping multiple lines of code.  Also, convert some short multiline
comments into single-line comments.  Change old-school FALSE to false.

All in all, no functional changes, it's just more compact and readable.

r344615:
Child nodes with a compatible property are not slices, according to the
devicetree/bindings/mtd/partitions.txt document, so just ignore them.

r344616:
Add support to fdt_slicer for the new style partition data documented in
devicetree/bindings/mtd/partition.txt.

In the old style, all the children of the device node which did not have a
compatible property were the partitions.  In the new style, there is a child
node of the device which has a compatible string of "fixed-partitions", and
its children are the individual partitions.

Also, support the read-only property by setting the corresponding slice flag.

r344681:
Build fdt support modules on systems that use fdt data.

kern.opts.mk sets make var OPT_FDT to a non-empty value if platform.h
contains OPT_FDT.

r344684:
Undo accidental part of r344681.

I think I must have accidentally mouse-click pasted while scrolling and
didn't notice it.

r344685:
Add required header file to SRCS.

r344686:
Add another required header file.

For some reason this seems to be required on aarch64, but I can build armv7
from clean without needing this in the list.  (The file does get included,
so the mystery is why armv7 works.)

r344728:
Bugfix: use a dummy buffer for the inactive side of a transfer.

This is especially important for writes.  SPI is inherently a bidirectional
bus; you receive data (even if it's garbage) while writing.  We should not
receive that data into the same buffer we're writing to the device.

When reading it doesn't matter what we send to the device, but using the
dummy buffer for that as well is pleasingly symmetrical.

r344733:
Add some comments.  Give #define'd names to some scattered numbers.  Change
some #define'd names to be more descriptive.  When reporting a post-write
compare failure, report the page number, not the byte address of the page.
The latter is the only functional change, it makes the number match the
words of the error message.

r344734:
Allow the sector size of the disk device to be configured using hints or
FDT data.  The sector size must be a multiple of the device's page size.
If not configured, use the historical default of the device page size.

Setting the disk sector size to 512 or 4096 allows a variety of standard
filesystems to be used on the device.  Of course you wouldn't want to be
writing frequently to a SPI flash chip like it was a disk drive, but for
data that gets written once (or rarely) and read often, using a standard
filesystem is a nice convenient thing.

r344981:
Give the mx25l device sole ownership of the name /dev/flash/spi* instead of
trying to use disk_add_alias() to make spi* an alias for mx25l*.  It turns
out disk_add_alias() works for partitions, but not slices, and that's hard
to fix.

This change is, in effect, a partial revert of r344526.

The mips world relies on the existence of flashmap names formatted as
/dev/flash/spi0s.name, whereas pretty much nothing relies on at45d devices
using the /dev/spi* names (because until recently the at45d driver didn't
even work reliably). So this change makes mx25l devices the sole owner of
the /dev/flash/spi* namespace, which actually makes some sense because it is
a SpiFlash(tm) device, so flash/spi isn't a horrible name.

5 years agoMFC r342652:
ian [Mon, 22 Apr 2019 14:10:40 +0000 (14:10 +0000)]
MFC r342652:

Support the SPI mode and bus clock frequency parameters set by the devices
requesting SPI transfers.

Reported by: SAITOU Toshihide <toshi@ruby.ocn.ne.jp>

5 years agoMFC r344267:
ian [Mon, 22 Apr 2019 13:59:21 +0000 (13:59 +0000)]
MFC r344267:

Add a compatible string to match recent changes in the upstream dts.

5 years agoMFC r342850:
ian [Mon, 22 Apr 2019 13:58:28 +0000 (13:58 +0000)]
MFC r342850:

Add a missing \n to a bootverbose printf.

5 years agoMFC r342639:
ian [Mon, 22 Apr 2019 13:55:06 +0000 (13:55 +0000)]
MFC r342639:

When allocating a new keyboard at vt_upgrade() time, unwind any cngrabs
done on the old keyboard and then do the corresponding number of grabs
on the new keyboard.

This fixes a race that can leave the system with a non-functioning
keyboard.  It goes like this...

 - The bios claims there is an AT keyboard, atkbd attaches.
 - SI_SUB_INT_CONFIG_HOOKS runs.
 - USB probes devices. Devices begin attaching, including disks.
 - GELI prompts for a password for a just-attached disk, which results
   in a cngrab() while atkbd is the keyboard.
 - A USB keyboard attaches.
 - vt_upgrade() runs and switches the keyboard to the new USB keyboard,
   but because cngrab was never called for it, it's not activated and
   keystrokes are ignored.
 - Now there is no functional keyboard and no way to get one; even
   plugging in a different USB keyboard doesn't help, because the console
   is still grabbed, still waiting for a GELI pw.

5 years agoMFC r337731:
ian [Mon, 22 Apr 2019 13:51:25 +0000 (13:51 +0000)]
MFC r337731:

Export the eeprom device size via readonly sysctl.  Also export the write
page size and address size, although they are likely to be inherently
less-interesting values outside of the driver.

5 years agoMFC r336137-r336138, r336202, r336214, r336216
ian [Mon, 22 Apr 2019 13:45:08 +0000 (13:45 +0000)]
MFC r336137-r336138, r336202, r336214, r336216

r336137:
Add a manpage for the imx_spi driver.

r336138:
Add pnp info to the imx_spi driver.

r336202:
Enhancements and fixes for the spigen(4) driver...

- Resources used by spigen_mmap_single() are now tracked using
  devfs_set_cdevpriv() rather than in the softc.

- Since resources are now tracked per-open-fd, there is no need to try to
  impose any exclusive-open logic, so flags related to that are removed.

- Flags used to track open status to prevent detach() when the device is
  open are replaced with calls to device_busy()/device_unbusy().  That
  extends the protection up the hierarchy so that the spibus and hardware
  controller drivers also can't be detached while the device is open/in use.

- Arbitrary limits on the maximum size of a transfer are removed, along with
  the sysctl variables that allowed the limits to be changed.  There is just
  no reason to limit the size of a spi transfer to the machine's page size.
  Or to any other arbitrary value, really.

- Most of the locking is removed.  It was mostly protecting access to flags
  and fields in the softc that no longer exist.  The locking that remains is
  just to prevent concurrent calls to device_[un]busy().

- The code was calling malloc() with M_WAITOK while holding a mutex in
  several places.  Since most of the locking is gone, that's fixed.

r336214:
Add various spi devices to NOTES.

r336216:
Actually build and install the spigen.4 manpage.

5 years agoMFC r346009:
markj [Mon, 22 Apr 2019 11:17:37 +0000 (11:17 +0000)]
MFC r346009:
Set the p_oppid field of orphans when exiting.

5 years agoMFC r346225:
kib [Mon, 22 Apr 2019 10:02:34 +0000 (10:02 +0000)]
MFC r346225:
Fix order of destructors between main binary and libraries.

5 years agoMFC r336094, r336096
ian [Mon, 22 Apr 2019 05:00:29 +0000 (05:00 +0000)]
MFC r336094, r336096

r336094:
Catch up with improvements in RTC handling... It's no longer necessary to
ignore the timestamp passed in to settime() due to inaccuracy, the core
routines now pass in a nanosecond-accurate time freshly-obtained before
calling each driver's settime() method.  Also, add calls to the new
debugging output helpers.

r336096:
Make the imx6_snvs driver usable as a module, add pnp info.  Add a manpage.

5 years agoMFC r336079:
ian [Mon, 22 Apr 2019 04:58:01 +0000 (04:58 +0000)]
MFC r336079:

Add pnp info to imx6_ahci, and add a module makefile, and a manpage for it.

5 years agoMFC r333073-r333074
ian [Mon, 22 Apr 2019 04:56:41 +0000 (04:56 +0000)]
MFC r333073-r333074

r333073 by manu:
arm: Fix duplicate ahci DRIVER_MODULE

Name each ahci driver uniquely.
This remove the warning printed at each arm boot :
module_register: cannot register simplebus/ahci from kernel; already loaded from kernel

r333074 by manu:
arm: Fix duplicate ehci DRIVER_MODULE

Name each ehci driver uniquely.
This remove the warning printed at each arm boot :
module_register: cannot register simplebus/ehci from kernel; already loaded from kernel

5 years agoMFC r335766:
ian [Mon, 22 Apr 2019 04:23:49 +0000 (04:23 +0000)]
MFC r335766:

Add missing MODULE_VERSION() and MODULE_DEPEND().

5 years agoMFC r336070, r336072-r336073, r336076
ian [Mon, 22 Apr 2019 04:15:22 +0000 (04:15 +0000)]
MFC r336070, r336072-r336073, r336076

r336070:
Add pnp info and a module makefile for the imx_wdog watchdog driver.

r336072:
Correctly calculate the value to put in the imx wdog countdown register.

The correct value is seconds*2-1.  The code was using just seconds*2, which
led to being off by a half-second -- usually not a big deal, except when the
value was the max (128) it overflowed so zero would get written to the
countdown register, which equates to a timeout of a half second.

r336073:
Add support to the imx watchdog for the FDT "timeout-sec" property, by
automatically initializing the watchdog using the given value.  Also,
attach at BUS_PASS_TIMER to extend watchdog protection to more of the
kernel init process.

r336076:
Add a manpage for the imx5/6 watchdog driver.

5 years agoMFC r336052:
ian [Mon, 22 Apr 2019 04:11:37 +0000 (04:11 +0000)]
MFC r336052:

Set .PATH to dev/usb/serial so that these modules compile again.

5 years agoMFC r335982, r335985, r335988-r335989
ian [Mon, 22 Apr 2019 04:07:51 +0000 (04:07 +0000)]
MFC r335982, r335985, r335988-r335989

r335982:
Fix an out-of-bounds array access... the irq data for teardown is in two
arrays, as elements 0 and 1 of one array and elements 1 and 2 of the other.
Run the loop 0..1 instead of 1..2 and use named constants to offset into
one of the arrays.

PR: 229508

r335985:
Remove a test and early-out which just can't possibly be right.  It causes
detach() to do nothing if attach() succeeded, which is the opposite of
what's needed.  Also, move device_delete_children() from the end to the
beginning of detach(), so that children won't be trying to make use of the
hardware we're in the process of shutting down.

PR: 229510

r335988:
Add a missing call to usb_bus_mem_free_all() when detaching.

r335989:
Detach all children before beginning to tear down the hardware, instead of
doing it last.  Also, remove the local tracking of whether usb's busdma
memory allocation got done, because it's safe to call the free_all
function even if it wasn't.

5 years agoMFC r335594:
ian [Mon, 22 Apr 2019 04:02:16 +0000 (04:02 +0000)]
MFC r335594:

Retrieve the bus clock speed and mode (polarity/phase) from the child device
and set up the hardware accordingly on each transfer.  This replaces the old
configuration done via sysctl, and allows both fdt configuration data and
userland control via the spigen device to work.

Submitted by: Bob Frazier
Differential Revision: https://reviews.freebsd.org/D15031

5 years agoMFC r335527, r335529, r335593
ian [Mon, 22 Apr 2019 03:55:02 +0000 (03:55 +0000)]
MFC r335527, r335529, r335593

r335527:
Add spi(8), a utility for communicating with a device on a SPI bus from
userland, conceptually similar to what i2c(8) provides for i2c devices.

Submitted by: Bob Frazier
Differential Revision: https://reviews.freebsd.org/D15029

r335529:
Eliminate gcc "shadowed declaration" warnings by using idx rather than
index as a variable name.

r335593:
Add an example for displaying the manufacturer and size info from a
standard spiflash chip.

5 years agoMFC r335506
ian [Mon, 22 Apr 2019 03:52:11 +0000 (03:52 +0000)]
MFC r335506

r335506:
Incorporate bus and chip select numbers into spigen(4) cdev names.  Rather
than assigning spigen device names in order of creation, this uses a device
name that corresponds to the owning spibus and chip-select index.

Example: /dev/spigen0.1 would be a child of spibus0, and use cs = 1

The intent is for systems like Raspberry Pi to have a consistent way of
using an SPI interface with a specific cs value from a user application.
Otherwise, there is no consistent way of knowing which cs pin will be
assigned to a particular spigen device. The alternative is to specify
everything in "the right order" in an overlay file, which is less than
ideal. Additionally, this duplicates (to some extent) the way Linux handles
a similar situation with their 'spidev' device, so it would be somewhat
familiar to those who also use Linux.

A new kernel config option, SPIGEN_LEGACY_CDEVNAME, causes the driver to
also create /dev/spigenN device name aliases, with N incrementing in the
order of device instantiation.  This is provided to ease the transition
for existing systems using the original naming convention (particularly
when these changes are MFC'd to stable branches).

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

5 years agoComment out checks that are causing failures on ^/stable/11, post-r337133
ngie [Mon, 22 Apr 2019 03:19:40 +0000 (03:19 +0000)]
Comment out checks that are causing failures on ^/stable/11, post-r337133

Some usr.bin/procstat code has not been MFCed to ^/stable/11 for command line
handling, and unfortunately, r337133 (which was MFCed as r337542) relies on
that support.

Comment out the checks and add a pointer to the PR for code archaeology and
to cause future potential parties to verify changes when backporting them.

This is a direct commit to ^/stable/11

PR: 237445
Reviewed by: markj
Approved by: emaste (mentor; implicit)
Differential Revision: https://reviews.freebsd.org/D19998

5 years agoMFC r346252: cron(8): Add MAILFROM ability for crontabs
kevans [Mon, 22 Apr 2019 03:06:12 +0000 (03:06 +0000)]
MFC r346252: cron(8): Add MAILFROM ability for crontabs

This changes the sender mail address in a similar fashion to how MAILTO may
change the recipient. The default from address remains unchanged.

PR: 140304

5 years agoMFC r334817, r334910
kevans [Mon, 22 Apr 2019 03:04:39 +0000 (03:04 +0000)]
MFC r334817, r334910

r334817:
Add new functionality and syntax to cron(1) to allow to run jobs at a
given interval, which is counted in seconds since exit of the previous
invocation of the job. Example user crontab entry:

@25 sleep 10

The example will launch 'sleep 10' every 35 seconds. This is a rather
useless example above, but clearly explains the functionality.

The practical goal here is to avoid overlap of previous job invocation
to a new one, or to avoid too short interval(s) for jobs that last long
and doesn't have any point of immediate launch soon after previous run.

Another useful effect of interval jobs can be noticed when a cluster of
machines periodically communicates with a single node. Running the task
time based creates too much load on the node. Running interval based
spreads invocations across machines in cluster. Note that -j/-J won't
help in this case.

r334910:
Remove old, dead compat code.

We no longer need to od these things conditionally, and the fallbacks
are to 4.2BSD era defaults, which nobody uses anymore. Vixie cron has
diverged from upstream anyway in our tree, and it's not clear there's
actually a viable upstream anymore. Plus, we don't follow the
vendor-supplied code pattern here.

I'm doing this to reduce false positives from grep.

5 years agoMFC r330358, r330360
ian [Mon, 22 Apr 2019 02:37:46 +0000 (02:37 +0000)]
MFC r330358, r330360

r330358: Minor changes to wording.
r330360: Minor (mostly) wording changes.

5 years agoMFC r346216:
kib [Sun, 21 Apr 2019 09:13:56 +0000 (09:13 +0000)]
MFC r346216:
ld-elf.so: make LD_DEBUG always functional.

5 years agoMFC r343911, r344238-r344241, r344247, r344254-r344255, r344260, r344268,
kevans [Sun, 21 Apr 2019 04:35:49 +0000 (04:35 +0000)]
MFC r343911, r344238-r344241, r344247, r344254-r344255, r344260, r344268,
r344335, r344839, r345066, r345330

r343911:
Allow reading the UEFI variable size

When loading bigger variables form UEFI it is necessary to know their
size beforehand, so that an appropriate amount of memory can be
allocated. The easiest way to do this is to try to read the variable
with buffer size equal 0, expecting EFI_BUFFER_TOO_SMALL error to be
returned. Allow such possible approach in efi_getenv routine.

Extracted from a bigger patch as suggested by imp.

r344238:
Restore loader(8)'s ability for lsdev to show partitions within a bsd slice.

I'm pretty sure this used to work at one time, perhaps long ago.  It has
been failing recently because if you call disk_open() with dev->d_partition
set to -1 when d_slice refers to a bsd slice, it assumes you want it to
open the first partition within that slice.  When you then pass that open
dev instance to ptable_open(), it tries to read the start of the 'a'
partition and decides there is no recognizable partition type there.

This restores the old functionality by resetting d_offset to the start
of the raw slice after disk_open() returns.  For good measure, d_partition
is also set back to -1, although that doesn't currently affect anything.

I would have preferred to make disk_open() avoid such rude assumptions and
if you ask for partition -1 you get the raw slice.  But the commit history
shows that someone already did that once (r239058), and had to revert it
(r239232), so I didn't even try to go down that road.

r344239:
Use a couple local variables to avoid repetitive long expressions that
cause line-wrapping.

r344240:
Make lsdev -v output line up in neat columns by using a fixed width for
the size field and a tab between the partition type and the size.

Changes this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows            49MB
        disk0s2: FreeBSD                14GB
        disk0s2a: FreeBSD UFS         14GB
        disk0s2b: Unknown             2048KB
        disk0s2d: FreeBSD UFS         2040KB

to this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows      49MB
        disk0s2: FreeBSD          14GB
        disk0s2a: FreeBSD UFS     14GB
        disk0s2b: Unknown       2048KB
        disk0s2d: FreeBSD UFS   2040KB

r344241:
Garbage collection no-longer-used constant.

r344247:
Make uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
loaderdev variable works correctly.

The uboot_devdesc struct is variously cast back and forth between
uboot_devdesc and disk_devdesc as pointers are handed off through various
opaque interfaces.  uboot_devdesc attempted to mimic the layout of
disk_devdesc by having a devdesc struct, followed by a union of some
device-specific stuff that included a struct that contains the same fields
as a disk_devdesc.  However, one of those fields inside the struct is 64-bit
which causes the entire union to be 64-bit aligned -- 32 bits of padding
is added between the struct devdesc and the union, so the whole mess ends
up NOT properly mimicking a disk_devdesc after all.  (In disk_devdesc there
is also 32 bits of padding, but it shows up immediately before the d_offset
field, rather than before the whole collection of d_* fields.)

This fixes the problem by using an anonymous union to overlay the devdesc
field uboot network devices need with the disk_devdesc that uboot storage
devices need.  This is a different solution than the one contributed with
the PR (so if anything goes wrong, the blame goes to me), but 95% of the
credit for this fix goes to Pawel Worach and Manuel Stuhn who analyzed the
problem and proposed a fix.

r344254:
Use DEV_TYP_NONE instead of -1 to indicate no device was specified.

DEV_TYP_NONE has a value of zero, which makes more sense since the device
type is a bunch of bits describing the device, crammed into an int.

r344255:
Fix more places to use DEV_TYP_NONE instead of -1 to indicate 'no device'.

r344260:
Allow the u-boot loaderdev env var to be formatted in the "usual" loader(8)
way: device<unit>[s|p]<slice><partition>.  E.g., disk0s2a or disk3p12.
The code first tries to parse the variable in this format using the
standard disk_parsedev().  If that fails, it falls back to parsing the
legacy format that has been supported by ubldr for years.

In addition to 'disk', all the valid uboot device names can also be used:
mmc, sata, usb, ide, scsi. The 'disk' device serves as an alias for all
those types and will match the Nth storage-type device found (where N is
the unit number).

r344268:
loader: ptable_close() should check its argument

If the passed in table is NULL, just return.

r344335:
Fix the handling of legacy-format devices in the u-boot loaderdev variable.
When I added support for the standard loader(8) disk0s2a: type formats,
the parsing of legacy format was broken because it also contains a colon,
but it comes before the slice and partition. That would cause disk_parsedev()
to return success with the slice and partition set to wildcard values.

This change examines the string first, and if it contains spaces, dots, or
a colon at any position other than the end, it must be a legacy-format
string and we don't even try to use disk_parsedev() on it.

r344839:
Add retry loop around GetMemoryMap call to fix fragmentation bug

The call to BS->AllocatePages can cause the memory map to become framented,
causing BS->GetMemoryMap to return EFI_BUFFER_TOO_SMALL more than once. For
example this can happen on the MinnowBoard Turbot, causing the boot to stop
with an error. Avoid this by calling GetMemoryMap in a loop.

r345066:
stand: Improve some debugging experience

Some of these files using <FOO>_DEBUG defined a DEBUG() macro to serve as a
debug-printf. -DDEBUG is useful to enable some debugging output across
multiple ELF/common parts, so switch the DEBUG-as-printf macros over to
something more like DPRINTF that is more commonly used for this kind of
thing and less likely to conflict.

userboot/elf64_freebsd debugging also assumed %llx for uint64; use PRIx64
instead.

r345330:
loader: fix loading of kernels with . in path

The loader indended to search the kernel file name (only) for . but
instead searched the entire path, so paths like
"boot/test.elfv2/kernel" would not work.

PR: 233097

5 years agoMFC r341101, r341231, r341276, r341329, r341433, r341780, r342054-r342055,
kevans [Sun, 21 Apr 2019 04:26:02 +0000 (04:26 +0000)]
MFC r341101, r341231, r341276, r341329, r341433, r341780, r342054-r342055,
r342721, r342742, r342840, r343008, r343225

r341101:
powerpcspe: Don't crash the loader on ubldr with SPE instructions.

-msoft-float seems to be insufficient for disabling the SPE on powerpcspe.
Force it off with -mno-spe as well.  This prevents a crash in ubldr on
powerpcspe.

r341231:
loader: command_bcache() should print unsigned values

All bcache counters are unsigned.

r341276:
When handling CMD_CRIT error set command_errmsg to NULL after we dump it out,
so that it does not result in error message printed twice.

OK load doodoo
can't find 'doodoo'
can't find 'doodoo'
OK

r341329:
loader.efi: fix EFI getchar() for multiple consoles

This fix is ported from illumos (issue #9970), the analysis and initial
implementation was done by John Levon.

See also: https://www.illumos.org/issues/9970

Currently, efi_cons_getchar() will wait for a key. While this seems to make
sense, the implementation of getchar() in common/console.c will loop across
getchar() for all consoles without doing ischar() first.

This means that if we've configured multiple consoles, we can't input into
the serial, as getchar() will be sat waiting for input only from efi_console.c

This patch does implement a bit more generic key buffer to support
translation of input keys, and we use generic efi_readkey() to reduce
duplication from calls from getchar() and poll().

r341433:
Move inclusion of src.opts.mk later.

src.opts.mk includes bsd.own.mk. This in turn defines CTFCONVERT_CMD
depending on the MK_CTF value. We then set MK_CTF to no, which has no
real effect. The solution is to set all the MK_foo values before
including src.opts.mk.

This should stop the cdboot binary from exploding in size for releases
built WITH_CTF=yes in src.conf.

r341780:
powerpc/ubldr: Teach powerpc's ubldr to boot 64-bit kernels

This is just a copy of powerpc/ofw's ppc64_elf_freebsd.c modified to fit
ubldr's boot format.

r342054:
Print an error message in efi_main.c if we can't allocate memory for the heap

With the default Qemu parameters, only 128MB RAM gets given to a VM. This causes
the loader to be unable to allocate the 64MB it needs for the heap. This change
makes the cause of the error more obvious.

r342055:
Cast error message in efi_main.c to CHAR16* to avoid build error

r342721:
loader.efi: update memmap command to recognize new attributes

Also move memory type to string translation to libefi for later use.

r342742:
loader.efi: efi variable rework and lsefi command added

This update does add diag and debug capabilities to interpret the efi
variables, configuration and protocols (lsefi).

The side effect is that we add/update bunch of related headers.

r342840:
Create MK_LOADER_VERBOSE and connect it to ELF_VERBOSE in the loader
code.

r343008:
Add Dell Chromebook to the list of devices with E820 extmem quirk enabled

Just like for Acer C270 chromebook the E820 extmem workaround is required for
FreeBSD to boot on Dell chromebook.

r343225:
Unbreak mip64 build after r328437

Add exit and getchar functions to beri/boot2 code. They are required by
panic_action functin introduced in r328437

PR: 18498, 204916

5 years agoMFC r337534-r337535
kevans [Sun, 21 Apr 2019 04:18:57 +0000 (04:18 +0000)]
MFC r337534-r337535

r337534:
Refactor common code into execute_script().

r337535:
Use NULLs instead of casted zeroes, for consistency.

5 years agoMFC r338262, r339334, r339796, r340240, r340857, r340917, r341007
kevans [Sun, 21 Apr 2019 04:15:57 +0000 (04:15 +0000)]
MFC r338262, r339334, r339796, r340240, r340857, r340917, r341007

r338262:
stand: fdt: Drop some write-only assignments/variables and leaked bits

Generally straightforward enough; a copy of argv[1] was being made in
command_fdt_internal, solely used for a comparison within the
handler-search, then promptly leaked.

r339334:
loader.efi: add poweroff command

Add poweroff command to make life a bit easier.

r339796:
Simplify the EFI delay() function by calling BS->Stall()

r340240:
loader: ptable_open() check for ptable_cd9660read result is wrong

The ptable_*read() functions return NULL on read errors (and partition table
closed as an side effect). The ptable_open must check the return value and
act properly.

r340857:
Nuke out buffer overflow safety marker code, it duplicates similar code in
the malloc()/free() as well as having potential of softening the handling
in case error is detected down to a mere warning as compared to hard panic
in free().

r340917:
Update pxeboot(8) manual page to reflect the next-server change in the ISC DHCP v3 server.

r341007:
Bump the date of pxeboot(8) manual page for r340917.

PR: 123484, 232483

5 years agoMFC r337321, r337435, r337707, r337740, r337834, r337836, r337968
kevans [Sun, 21 Apr 2019 04:00:19 +0000 (04:00 +0000)]
MFC r337321, r337435, r337707, r337740, r337834, r337836, r337968

r337321:
Make it possible for init to execute any executable, not just sh(1)
scripts. This means one should be able to eg rewrite their /etc/rc
in Python.

r337435:
Move description of init_shell, init_script, and init_chroot kenv
tunables from loader(8) to init(8), since it's init that actually
uses them.  Add .Xrs at their old place.

r337707:
Move around text in loader(8), in particular stuff related to ZFS,
to restore the usual section order.

r337740:
Add init_exec kenv(1) variable, to make init(8) execute a file
after opening the console, replacing init as PID 1.

From the user point of view, it makes it possible to run eg the
shell as PID 1, using 'set init_exec=/bin/sh' at the loader(8)
prompt.

r337834:
Add SECURITY section to loader(8).

r337836:
Improve formatting.

r337968:
Consistently use NULL to terminate the argv; no functional changes.

Relnotes: yes (init_exec kenv(1) variable)

5 years agoMFC r339292: Fix a minor typo in loader.conf(5).
kevans [Sun, 21 Apr 2019 03:54:49 +0000 (03:54 +0000)]
MFC r339292: Fix a minor typo in loader.conf(5).

5 years agoMFC r337871, r339970, r342151, r342161, r343123-r343124, r344226, r344234,
kevans [Sun, 21 Apr 2019 03:43:27 +0000 (03:43 +0000)]
MFC r337871, r339970, r342151, r342161, r343123-r343124, r344226, r344234,
r344248, r344387

r337871:
pkgfs_init: Initialize pkg

new_package may not set *pp if it errors out, leaving pkg uninitialized.

r339970:
Remove unnecessary include from libstand.

r342151:
loader: zfs reader should not probe partitionless disks

First of all, normal setups can not boot such pools as the tools
do not support installing boot programs.

Secondly, for proper pool configuration detection, we need to checks all
four label copies on disk, 2 from front and 2 from the end of the disk,
but zfs label does not contain the size of the disk - so we depend on
firmware to report the correct disk size or use information from the
partition table.

Without partition table, we only can rely on firmware to report and support
disk IO properly.

There is a specific case: 8TB disks are reported by BIOS to have 4294967295
sectors (0x00000000ffffffff), the sectors reported by OS is 15628053168
(0x00000003a3812ab0), so the reported size is less than actual but is hitting
32-bit max. Unfortuantely the real limit must be even lower because probing
this disk in this system will wnd up with hung system.

UEFI boot of this system seems not to be affected.

r342161:
loader: zfs reader should not probe partitionless disks (UEFI case)

With r342151 I did fix the BIOS version of zfs_probe_dev() from accessing
the whole disk, but the fix was not complete - we actually did not check
if the device name was really for whole disk. Since UEFI version
is only calling the zfs_probe_dev() with partitions and not with whole
disk, the UEFI loader was not able to find the zfs pools.

This update does correct the issue by calling archsw.arch_getdev() to
translate the device name back to dev_desc, and we have whole disk when both
partition and slice values are -1.

r343123:
loader should ignore active multi_vdev_crash_dump feature on zpool

Since the loader zfs reader does not need to read the dump zvol, we can
just enable the feature.

illumos issue #9051 https://www.illumos.org/issues/9051

r343124:
libsa: add asprintf()

asprintf() is a nice tool for string processing.

r344226:
Fix memory corruption bug introduced in r325310

The bug occurred when a bounce buffer was used and the requested read
size was greater than the size of the bounce buffer.  This commit also
rewrites the read logic so that it is easier to systematically verify
all alignment and size cases.

r344234:
It turns out r344226 narrowed the overrun bug but did not eliminate it entirely

This commit fixes a remaining output buffer overrun in the
single-sector case when there is a non-zero tail.

r344248:
cd9660: dirmatch fails to unmatch when name is prefix for directory record

Loader does fail to properly match the file name in directory record and
does open file based on prefix match.

For fix, we check the name lengths first.

r344387:
loader: really fix cd9660 dirmatch

The cd9660_open() does pass whole path to dirmatch() and we need to
compare only the current path component, not full path.

Additinally, skip over duplicate / (if any) and check if the last component
in the path was meant to be directory (having trailing /). If it is in fact
a file, error out.

5 years agoMFC r341253, r341328, r342619, r342626, r342707, r342785, r342865
kevans [Sun, 21 Apr 2019 03:36:05 +0000 (03:36 +0000)]
MFC r341253, r341328, r342619, r342626, r342707, r342785, r342865

r341253:
The libstand's panic() appends its own '\n' to the message, so that users of the API
don't need to supply one.

r341328:
loader: create separate lists for fd, cd and hd, merge bioscd with biosdisk

Create unified block IO implementation in BIOS version, like it is done in UEFI
side. Implement fd, disk and cd device lists, this will split floppy devices
from disks and will allow us to have consistent, predictable device naming
(modulo BIOS issues).

r342619:
loader: create bio_alloc and bio_free for bios bounce buffer

We do have 16KB buffer space defined in pxe.c, move it to bio.c and implement
bio_alloc()/bio_free() interface to make it possible to use this space for
other BIOS calls (notably, from biosdisk.c).

r342626:
Add Copyright.

r342707:
i386_parsedev() needs to support fd devices

r342785:
With buggy int13 ah=15, we can mis-identify the floppy devices.

We have no option than trust INT13 ah=08 return code during the init phase.

r342865:
biospci_write_config args were backwards

biospci_write_config args swapped length and value to write. Some
hardware coped just fine, while other hardware had issues.

PR: 155441, 234460

5 years agoMFC r339658, r339959, r340047, r340049, r340215
kevans [Sun, 21 Apr 2019 03:30:47 +0000 (03:30 +0000)]
MFC r339658, r339959, r340047, r340049, r340215

r339658:
loader: biosdisk interface should be able to cope with 4k sectors

The 4kn support in current bios specific biosdisk.c is broken, as the code
is only implementing the support for the 512B sector size.

This work is building the support for custom size sectors, we still do assume
the requested data to be multiple of 512B blocks and we only do address the
biosdisk.c interface here.

For reference, see also:
https://www.illumos.org/issues/8303
https://www.illumos.org/rb/r/547

As the GELI is moved above biosdisk "layer", the GELI should just work

r339959:
loader: issue edd probe before legacy ah=08 and detect no media

while probing for drives, use int13 extended info before standard one and
provide workaround for case we are not getting needed information in case
of floppy drive.

In case of INT13 errors, there are (at least) 3 error codes appearing in case
of missin media - 20h, 31h and 80h. Flag the no media and do not print an
error.

r340047:
loader: do not probe floppy devices for zfs

The subject is telling it all.

r340049:
loader: biosdisk should check if the media is present

The bd_print/bd_open/bd_strategy need to make sure the device does have
media, before getting into performing IO operations. Some systems can
hung if the device without a media is accessed.

r340215:
loader: always set media size from partition.

The disk access is validated by using partition table definitions, therefore
we have no need for if statements, just set the disk size.

Of course the partition table itself may be incorrect/inconsistent, but if
so, we are in trouble anyhow.

5 years agoMFC i386 stand cleanup: r337353-r337354, r337356, r337872, r337878, r337881,
kevans [Sun, 21 Apr 2019 03:27:12 +0000 (03:27 +0000)]
MFC i386 stand cleanup: r337353-r337354, r337356, r337872, r337878, r337881,
r337890-r337891, r338188

r337353:
loader: cstyle cleanup for biosdisk.c

Also switch u_int to uint32_t. Also replace "write" by "dowrite".
No functional changes intended.

r337354:
loader: 337353 did miss to rename 2 write instances

2 write instances got somehow missed.

r337356:
loader: bd_open() should cleanup from disk_open() error

Since bd_open() does early increment for reference counter and bcache
allocation, it also should undo those in case of the error.

Also remove unused variables rdev, g_err.

r337872:
libi386: remove BD_SUPPORT_FRAGS

BD_SUPPORT_FRAGS is preprocessor knob to allow partial reads in bioscd/biosdisk
level. However, we already have support for partial reads in bcache, and there
is no need to have duplication via preprocessor controls.

Note that bioscd/biosdisk interface is assumed to perform IO in 512B blocks,
so the only translation we have to do is 512 <-> native block size.

r337878:
libi386: remove bd_read() and bd_write() wrappers

Those wroappers are nice, but do not really add much value.

r337881:
libi386: use BD_RD and BR_WR constants

Use BD_RD and BD_WR instead of 0 and 1.

r337890:
libi386: small style updates in biosdisk

Use break instead of return in for loop, as done earlier. Insert and remove
some blank lines. No functional changes intended.

r337891:
libi386: bd_io_workaround() is to be called for reads only

bd_io() can perform either reads or writes, we only need bd_io_workaround()
for reads.

r338188:
loader: bios loader should allow to chain load a file

The current chain command does accept only device, allow also a file to be used,
such as /boot/pmbr or /boot/mbr (or stored third party MBR/VBR block).

Also fix file descriptor leak.

5 years agoMFC r337271, r337317: stand: i386: sector calculation fixes
kevans [Sun, 21 Apr 2019 03:22:57 +0000 (03:22 +0000)]
MFC r337271, r337317: stand: i386: sector calculation fixes

r337271:
Some drives report a geometry that is inconsisetent with the total
number of sectors reported through the BIOS. Cylinders * heads *
sectors may not necessarily be equal to the total number of sectors
reported through int13h function 48h.

An example of this is when a Mediasonic HD3-U2B PATA to USB enclosure
with a 80 GB disk is attached. Loader hangs at line 506 of
stand/i386/libi386/biosdisk.c while attempting to read sectors beyond
the end of the disk, sector 156906855. I discovered that the Mediasonic
enclosure was reporting the disk with 9767 cylinders, 255 heads, 63
sectors/track. That's 156906855 sectors. However camcontrol and
Windows 10 both report report the disk having 156301488 sectors, not
the calculated value. At line 280 biosdisk.c sets the sectors to the
higher of either bd->bd_sectors or the total calculated at line 276
(156906855) instead of the lower and correct value of 156301488 reported
by int 13h 48h.

This was tested on all three of my Mediasonic HD3-U2B PATA to USB
enclosures.

Instead of using the higher of bd_sectors (returned by int13h) or the
calculated value, this patch uses the lower and safer of the values.

r337317:
In r337271, we limited the sector number to the lower of calculated
number and CHS based number.  However, on some systems, BIOS would
report 0 in CHS fields, making the system to think there is 0 sectors.

Add a check before comparing the calculated total with bd_sectors.

5 years agoMFC r336424-r336425: loader command typos
kevans [Sun, 21 Apr 2019 03:16:09 +0000 (03:16 +0000)]
MFC r336424-r336425: loader command typos

r336424:
Fix typo in the command summary.

Of course, I can't get the command to work, but it's a start...

r336425:
More typos

5 years agoMFC r333662: Clarify that boot_mute / boot -m mutes kernel console only
kevans [Sun, 21 Apr 2019 03:15:11 +0000 (03:15 +0000)]
MFC r333662: Clarify that boot_mute / boot -m mutes kernel console only

Perhaps RB_MUTE could mute user startup (rc) output as well, but right
now it mutes only kernel console output, so make the documentation match
reality.

PR: 228193

5 years agoMFC: r345995
rmacklem [Sun, 21 Apr 2019 00:59:21 +0000 (00:59 +0000)]
MFC: r345995
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.

5 years agoMFC: r345994
rmacklem [Sun, 21 Apr 2019 00:51:43 +0000 (00:51 +0000)]
MFC: r345994
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.

5 years agoMFC: r345992, r346087
rmacklem [Sun, 21 Apr 2019 00:41:06 +0000 (00:41 +0000)]
MFC: r345992, r346087
Add INET6 support for the upcalls to the nfsuserd daemon.

The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get
updates to the username<->uid and groupname<->gid mappings.
A change to AF_LOCAL last year had to be reverted, since it could result
in vnode locking issues on the AF_LOCAL socket.
This patch adds INET6 support and the required #ifdef INET and INET6
to the code.

5 years agoMFC r345996:
cy [Sat, 20 Apr 2019 15:06:58 +0000 (15:06 +0000)]
MFC r345996:

Update sqlite3-3.26.0 (3260000) --> sqlite3-3.27.1 (3270100)

5 years agoMFC r346010:
markj [Sat, 20 Apr 2019 11:03:46 +0000 (11:03 +0000)]
MFC r346010:
Fix indentation.

5 years agoMFC r346011:
markj [Sat, 20 Apr 2019 11:03:16 +0000 (11:03 +0000)]
MFC r346011:
Stop compiling bhyve(8) with -O0.

5 years agoMFC bectl(8)/libbe(3): r337663-337664,337667,337697-337699,337800,337805,
kevans [Sat, 20 Apr 2019 04:16:51 +0000 (04:16 +0000)]
MFC bectl(8)/libbe(3): r337663-337664,337667,337697-337699,337800,337805,
337915-337918,337921,337924,337947,337993-337995,338221-338222,338303,
338417,339047,339972,339994,340334,340507-340508,340592-340594,
340635-340636,340722-340723,340974,342466,342849,342903,342911,343335,
343543,343977,343993-343994,344034,344067,344084,345302,345769,
345845-345846,345848,346082

There are simply too many small changes to enumerate; in summary:

bectl(8)/libbe(3) has been introduced from current state in -CURRENT and
added to the stable/11 rescue build. bectl(8) is a tool for managing ZFS
boot environments, largely inspired by beadm. It includes features such as
being able to jail a boot environment or easily mount it for modification.

Relnotes: probably

5 years agoMFC: 342657, 345025
imp [Fri, 19 Apr 2019 20:23:39 +0000 (20:23 +0000)]
MFC: 342657, 345025

Quirks for Chipfancier chips. Their READ CAPACITY 10 and READ CAPACITY
16 values differ, and the default of using RC16 gets the improper one.

PR: 234503

5 years agoFix minor mismerge in r346296, where one file for the LLVM BPF target
dim [Fri, 19 Apr 2019 20:09:13 +0000 (20:09 +0000)]
Fix minor mismerge in r346296, where one file for the LLVM BPF target
was missing.  This would lead to link errors when attempting to build
clang and llvm executables.

Direct commit to stable/11, since head and stable/12 have correct
libllvm Makefiles.

5 years agoMFC 344740:
bz [Fri, 19 Apr 2019 17:29:20 +0000 (17:29 +0000)]
MFC 344740:

  Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.

  Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were set.
  Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make world
  compile again.

5 years agoMFC r345757:
bz [Fri, 19 Apr 2019 15:54:32 +0000 (15:54 +0000)]
MFC r345757:

  Improve debugging options in bcm2835_sdhci.c

  Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively
  turn on debugging printfs if debugging is turned on at compile time.

5 years agoMFC r344700:
bz [Fri, 19 Apr 2019 15:46:08 +0000 (15:46 +0000)]
MFC r344700:

  Add ushort and ulong to linux/types.h.

  When porting code once written for Linux we find not only uints but also ushort and ulong.
  Provide central typedefs as part of the linuxkpi for those as well.

5 years agoMFC r340494:
bz [Fri, 19 Apr 2019 15:34:21 +0000 (15:34 +0000)]
MFC r340494:

  Improve the comment for arpresolve_full() in if_ether.c.
  No functional changes.

5 years agoMFC r346275:
gjb [Fri, 19 Apr 2019 13:23:41 +0000 (13:23 +0000)]
MFC r346275:
 Remove INDEX-10 reference, as 10.x is now EoL.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r345966, r345968:
kib [Fri, 19 Apr 2019 13:18:54 +0000 (13:18 +0000)]
MFC r345966, r345968:
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

5 years agoMFC r345965:
kib [Fri, 19 Apr 2019 13:09:16 +0000 (13:09 +0000)]
MFC r345965:
Add DEV_RESET /dev/devctl2 ioctl.

5 years agoMFC r345963, r345997:
kib [Fri, 19 Apr 2019 13:04:48 +0000 (13:04 +0000)]
MFC r345963, r345997:
Implement resets for PCI buses and PCIe bridges.

5 years agoMFC r345960:
kib [Fri, 19 Apr 2019 12:57:37 +0000 (12:57 +0000)]
MFC r345960:
Provide newbus infrastructure for initiating device reset.

5 years agoMFC r345964:
kib [Fri, 19 Apr 2019 12:40:21 +0000 (12:40 +0000)]
MFC r345964:
Remove single-use DEV_RESET() macro.

5 years agoMFC r345959:
kib [Fri, 19 Apr 2019 12:33:58 +0000 (12:33 +0000)]
MFC r345959:
Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

5 years agoMFC r346158:
kib [Fri, 19 Apr 2019 12:31:16 +0000 (12:31 +0000)]
MFC r346158:
Do not access mutex memory after unlock.

PR: 237195

5 years agoMFC r346161: Fix SCSI sense data pass through.
mav [Fri, 19 Apr 2019 03:47:59 +0000 (03:47 +0000)]
MFC r346161: Fix SCSI sense data pass through.

5 years agoMFC: r345866
rmacklem [Thu, 18 Apr 2019 02:47:59 +0000 (02:47 +0000)]
MFC: r345866
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

5 years agoFix cross-building VMs with a non-/usr/src source directory.
cperciva [Thu, 18 Apr 2019 00:38:54 +0000 (00:38 +0000)]
Fix cross-building VMs with a non-/usr/src source directory.

The path /usr/src was hard-coded here, resulting in mkimg not being able
to find the bootfiles.

Direct commit to stable/11 because the code in HEAD and stable/12 is
completely different due to changes in OBJDIR layout.

5 years agoAfter r346168, also merge build infrastructure for LLVM libomp.
dim [Wed, 17 Apr 2019 20:16:48 +0000 (20:16 +0000)]
After r346168, also merge build infrastructure for LLVM libomp.

MFC r345235:

Add lib/libomp, with a Makefile, and generated configuration headers.
Not connected to the main build yet, as there is still the issue of the
GNU omp.h header conflicting with the LLVM one.  (That is, if MK_GCC is
enabled.)

PR: 236062

MFC r345236:

Connect lib/libomp to the build.

* Set MK_OPENMP to yes by default only on amd64, for now.
* Bump __FreeBSD_version to signal this addition.
* Ensure gcc's conflicting omp.h is not installed if MK_OPENMP is yes.
* Update OptionalObsoleteFiles.inc to cope with the conflicting omp.h.
* Regenerate src.conf(5) with new WITH/WITHOUT fragments.

Relnotes: yes
PR: 236062

MFC r345242:

Explicitly link libomp.so against -lpthread, as it depends on pthread
functionality.  This should make example OpenMP programs work out of the
box.

Reported by: jbeich
PR: 236062, 236581

MFC r345278:

Also explicitly link libomp.so against -lm, as it transitively depends
on scalbn and a few other math functions, via libcompiler-rt.  This
should allow OpenMP programs to link with BFD linkers too.

Reported by: jbeich
PR: 236062, 236581

MFC r345282:

Remove --as-needed from the linker flags for libomp.so, as these
actually prevent the transitive dependency on libm.

Reported by: jbeich
PR: 236062, 236581

MFC r345291:

Turn on MK_OPENMP for i386 by default, now that it can build.

Noticed by: jbeich
PR: 236062, 236582

5 years agoMFC r345316, r345317, r345858:
cperciva [Wed, 17 Apr 2019 12:34:37 +0000 (12:34 +0000)]
MFC r345316, r345317, r345858:

r345316: Register ARM64 EC2 AMIs as being for the ARM64 architecture.

r345317: Don't install amazon-ssm-agent package into ARM64 AMIs.

r345858: Add support for cross-building cloudware images.

With these changes it is possible to build ARM64 EC2 AMIs on stable/12 --
said images do not *work* yet, however.

5 years agoFix a typo.
gjb [Tue, 16 Apr 2019 23:08:54 +0000 (23:08 +0000)]
Fix a typo.

Submitted by: adamw
Sponsored by: The FreeBSD Foundation

5 years agoMFC r345192-r345194: if_bridge(4): Drop pointless rtflush
kevans [Tue, 16 Apr 2019 21:02:41 +0000 (21:02 +0000)]
MFC r345192-r345194: if_bridge(4): Drop pointless rtflush

r345192:
if_bridge(4): Drop pointless rtflush

At this point, all routes should've already been dropped by removing all
members from the bridge. This condition is in-fact KASSERT'd in the line
immediately above where this nop flush was added.

r345193:
Revert r345192: Too many trees in play for bridge(4) bits

An accidental appendage was committed that has not undergone review yet.

r345194:
if_bridge(4): Drop pointless rtflush

At this point, all routes should've already been dropped by removing all
members from the bridge. This condition is in-fact KASSERT'd in the line
immediately above where this nop flush was added.

5 years agoMFC r346132: stand: refactor overlay loading a little bit
kevans [Tue, 16 Apr 2019 21:01:07 +0000 (21:01 +0000)]
MFC r346132: stand: refactor overlay loading a little bit

It was pointed out that manually loading a .dtb to be used rather than
relying on platform-specific method for loading .dtb will result in overlays
not being applied. This was true because overlay loading was hacked into
fdt_platform_load_dtb, rather than done in a way more independent from how
the .dtb is loaded.

Instead, push overlay loading (for now) out into an
fdt_platform_load_overlays. This method easily allows ubldr to pull in any
fdt_overlays specified in the ub env, and omits overlay-checking on
platforms where they're not tested and/or not desired (e.g. powerpc). If we
eventually stop caring about fdt_overlays from ubenv (if we ever cared),
this method should get chopped out in favor of just calling
fdt_load_dtb_overlays() directly.

5 years agoMFC r345180, r345187: if_bridge(4): Fix module teardown
kevans [Tue, 16 Apr 2019 20:56:51 +0000 (20:56 +0000)]
MFC r345180, r345187: if_bridge(4): Fix module teardown

r345180: if_bridge(4): Fix module teardown

bridge_rtnode_zone still has outstanding allocations at the time of
destruction in the current model because all of the interface teardown
happens in a VNET_SYSUNINIT, -after- the MOD_UNLOAD has already been
processed.  The SYSUNINIT triggers destruction of the interfaces, which then
attempts to free the memory from the zone that's already been destroyed, and
we hit a panic.

Solve this by virtualizing the uma_zone we allocate the rtnodes from to fix
the ordering. bridge_rtable_fini should also take care to flush any
remaining routes that weren't taken care of when dynamic routes were flushed
in bridge_stop.

r345187: bridge: Fix STP-related panic

After r345180 we need to have the appropriate vnet context set to delete an
rtnode in bridge_rtnode_destroy().
That's usually the case, but not when it's called by the STP code (through
bstp_notify_rtage()).

We have to set the vnet context in bridge_rtable_expire() just as we do in the
other STP callback bridge_state_change().

5 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
dim [Tue, 16 Apr 2019 20:05:24 +0000 (20:05 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365.

MFC r306265 (by emaste):

Force LLVM_LIBUNWIND off if we don't have a C++11 compiler

Tested by: bde
Differential Revision: https://reviews.freebsd.org/D7746

MFC r308100 (by emaste):

compile libunwind c source with -fexceptions

When an exception is thrown the unwinder must unwind its own C source
(starting with _Unwind_RaiseException in UnwindLevel1.c), so it needs to
be built with unwinding data.

MFC r324998 (by bdrewery):

Prefix {TARGET,BUILD}_TRIPLE with LLVM_ to avoid Makefile.inc1 collision.

The Makefile.inc1 TARGET_TRIPLE is for specifying which -target is used
during the build of world.

Reviewed by: dim, imp
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D12792

MFC r329093 (by emaste):

Promote llvm-cov to a standalone option

Introduce WITH_/WITHOUT_LLVM_COV to match GCC's WITH_/WITHOUT_GCOV.
It is intended to provide a superset of the interface and functionality
of gcov.

It is enabled by default when building Clang, similarly to gcov and GCC.

This change moves one file in libllvm to be compiled unconditionally.
Previously it was included only when WITH_CLANG_EXTRAS was set, but the
complexity of a new special case for (CLANG_EXTRAS | LLVM_COV) is not
worth avoiding a tiny increase in build time.

Reviewed by: dim, imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D142645

MFC r331244 (by jhb):

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

MFC r336691 (by emaste):

llvm: remove __FreeBSD_version conditionals

All supported FreeBSD build host versions have backtrace.h, so we can
just eliminate that test.  For futimes() we can test the compiler's
built-in __FreeBSD__ major version rather than relying on including
osreldate.h.  This should reduce the frequency with which Clang gets
rebuilt when building world.

Reviewed by: dim
Sponsored by: The FreeBSD Foundation

MFC r337379 (by andrew):

Default to armv5te in LINT on arm. This should fix building LINT there.

MFC r337552:

Add optional LLVM BPF target support

BPF (eBPF) is an independent instruction set architecture which is
introduced in Linux a few years ago. Originally, eBPF execute
environment was only inside Linux kernel. However, recent years there
are some user space implementation (https://github.com/iovisor/ubpf,
https://doc.dpdk.org/guides/prog_guide/bpf_lib.html) and kernel space
implementation for FreeBSD is going on
(https://github.com/YutaroHayakawa/generic-ebpf).

The BPF target support can be enabled using WITH_LLVM_TARGET_BPF, as it
is not built by default.

Submitted by: Yutaro Hayakawa <yhayakawa3720@gmail.com>
Reviewed by: dim, bdrewery
Differential Revision: https://reviews.freebsd.org/D16033

MFC r337585:

In r308100, an explicit -fexceptions flag was added for the C sources
from LLVM's libunwind, which end up in libgcc_eh.a and libgcc_s.so.
This is because the unwinder needs the unwinder data for its own
functions.

However, for the C++ sources in libunwind, -fexceptions is already the
default, and this can have the side effect of generating a reference to
__gxx_personality_v0, the so-called personality function, which is
normally provided by the C++ ABI library (libcxxrt or libsupc++).

If the reference ends up in the eventual libgcc_s.so, linking any
non-C++ programs against it will fail with "undefined reference to
`__gxx_personality_v0'".

Note that at high optimization levels, the reference is usually
optimized away, which is why we have never noticed this problem before.

With clang 7.0.0 though, higher optimization levels don't help anymore,
since the addition of address-significance tables [1] in
<https://reviews.llvm.org/rL337339>.  Effectively, this always causes a
reference to __gxx_personality_v0.

After discussion with the upstream author of that change, it turns out
that we should compile libunwind sources with the -fno-exceptions
-funwind-tables flags instead.  This ensures unwind tables are
generated, but no references to any personality functions are emitted.

[1] https://lists.llvm.org/pipermail/llvm-dev/2018-May/123514.html

Reported by: jbeich
PR: 230399

MFC r340287 (by emaste):

Consolidate gcov entries in OptionalObsoleteFiles

Sponsored by: The FreeBSD Foundation

MFC r340289 (by emaste):

llvm-cov: also install as gcov (if GNU gcov is disabled)

llvm-cov provides a gcov-compatible interface when invoked as gcov.

Reviewed by: dim, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17923

MFC r340296 (by emaste):

Move llvm-profdata build into MK_LLVM_COV block

llvm-profdata is used with llvm-cov for code coverage (although llvm-cov
can also operate independently in a gcov-compatible mode).
Although llvm-profdata can be used independently of llvm-cov it makes
sense to group these under one option.

Also handle these in OptionalObsoleteFiles.inc while here.

Sponsored by: The FreeBSD Foundation

MFC r340300 (by emaste):

libllvm: Move SampleProfWriter to SRCS_MIN

It is required by llvm-profdata, now built by default under the
LLVM_COV knob.  The additional complexity that would come from avoiding
building it if CLANG_EXTRAS and LLVM_COV are both disabled is not worth
the small savings in build time.

Sponsored by: The FreeBSD Foundation

MFC r340972 (by emaste):

llvm-objdump: initial man page

Based on llvm-objdump's online documentation and usage information.
This serves as a starting point; additional detail and cleanup still
required.

Also being submitted upstream in LLVM review D54864.  I expect to use
this bespoke copy while we have LLVM 6.0 or 7.0 in FreeBSD; when we
update to LLVM 8.0 it should be upstream and we will switch to it.

PR: 233437
Reviewed by: bcr (man formatting)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18309

MFC r340973 (by emaste):

llvm-objdump.1: remove invalid options

Some options appear in llvm-objdump's usage information as a side effect
of its option parsing implementation and are not actually llvm-objdump
options.  Reported in LLVM review https://reviews.llvm.org/D54864.

Reported by: Fangrui Song
Sponsored by: The FreeBSD Foundation

MFC r340975 (by emaste):

llvm-objdump.1: fix igor / mandoc -Tlint warnings

Accidentally omitted from r340972.

MFC r341055 (by emaste):

llvm-objdump.1: remove more unintentional options

Some options come from static constructors in LLVM libraries and are
automatically added to llvm's usage output.  They're not really supposed
to be llvm-objdump options.

Reported by: Fangrui Song in LLVM review D54864
Sponsored by: The FreeBSD Foundation

MFC r344779:

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
the upstream release_80 branch r355313 (effectively, 8.0.0 rc3).  The
release will follow very soon, but no more functional changes are
expected.

Release notes for llvm, clang and lld 8.0.0 will soon be available here:
<https://releases.llvm.org/8.0.0/docs/ReleaseNotes.html>
<https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html>
<https://releases.llvm.org/8.0.0/tools/lld/docs/ReleaseNotes.html>

PR: 236062
Relnotes: yes

MFC r344798 (by emaste):

libllvm: promote WithColor and xxhash to SRCS_MIN

The armv6 build failed in CI due to missing symbols (from these two
source files) in the bootstrap Clang.

This affected only armv6 because other Clang-using archs are using LLD
as the bootstrap linker, and thus include SRCS_MIW via LLD_BOOTSTRAP.

Reported by: CI, via lwhsu
Sponsored by: The FreeBSD Foundation

MFC r344825:

Add a few missed files to the MK_LLVM_TARGET_BPF=yes case, otherwise
clang and various other executables will fail to link with undefined
symbols.

Reported by: O. Hartmann <ohartmann@walstatt.org>

MFC r344852:

Put in a temporary workaround for what is likely a gcc 6 bug (it does
not occur with gcc 7 or later).  This should prevent the following error
from breaking the head-amd64-gcc CI builds:

In file included from /workspace/src/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp:14:0:
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: 'template<class _InputIterator> lldb_private::MemoryRegionInfos::MemoryRegionInfos(_InputIterator, _InputIterator, const allocator_type&)' inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'
   using std::vector<lldb_private::MemoryRegionInfo>::vector;
                                                      ^~~~~~
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: conflicts with version inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'

Reported by: CI

MFC r344896:

Pull in r354937 from upstream clang trunk (by Jörg Sonnenberger):

  Fix inline assembler constraint validation

  The current constraint logic is both too lax and too strict. It fails
  for input outside the [INT_MIN..INT_MAX] range, but it also
  implicitly accepts 0 as value when it should not. Adjust logic to
  handle both correctly.

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

Pull in r355491 from upstream clang trunk (by Hans Wennborg):

  Inline asm constraints: allow ICE-like pointers for the "n"
  constraint (PR40890)

  Apparently GCC allows this, and there's code relying on it (see bug).

  The idea is to allow expression that would have been allowed if they
  were cast to int. So I based the code on how such a cast would be
  done (the CK_PointerToIntegral case in
  IntExprEvaluator::VisitCastExpr()).

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

These should fix assertions and errors when using the inline assembly
"n" constraint in certain ways.

In case of devel/valgrind, a pointer was used as the input for the
constraint, which lead to "Assertion failed: (isInt() && "Invalid
accessor"), function getInt".

In case of math/secp256k1, a very large integer value was used as input
for the constraint, which lead to "error: value '4624529908474429119'
out of range for constraint 'n'".

PR:             236216, 236194

MFC r344951:

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062

MFC r345018:

Merge LLVM libunwind trunk r351319, from just before upstream's
release_80 branch point.  Afterwards, we will merge the rest of the
changes in the actual release_80 branch.

PR: 236062

MFC r345019:

Merge LLVM libunwind release_80 branch r355677 (effectively, 8.0.0 rc4).

PR: 236062

MFC r345021:

Pull in r355854 from upstream llvm trunk (by Jonas Paulsson):

  [RegAlloc]  Avoid compile time regression with multiple copy hints.

  As a fix for https://bugs.llvm.org/show_bug.cgi?id=40986 ("excessive
  compile time building opencollada"), this patch makes sure that no
  phys reg is hinted more than once from getRegAllocationHints().

  This handles the case were many virtual registers are assigned to the
  same physreg. The previous compile time fix (r343686) in
  weightCalcHelper() only made sure that physical/virtual registers are
  passed no more than once to addRegAllocationHint().

  Review: Dimitry Andric, Quentin Colombet
  https://reviews.llvm.org/D59201

This should fix a hang when compiling certain generated .cpp files in
the graphics/opencollada port.

PR: 236313

MFC r345068 (by jhb):

Move libunwind out of contrib/llvm/projects.

Move LLVM's libunwind to its own contrib/ directory similar to other
runtime libraries like libc++ and libcxxrt.

Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D19534

MFC r345073:

Revert r308867 (which was originally committed in the clang390-import
project branch):

  Work around LLVM PR30879, which is about a bad interaction between
  X86 Call Frame Optimization on i386 and libunwind, by disallowing the
  optimization for i386-freebsd12.

  This should fix some instances of broken exception handling when
  frame pointers are omitted, in particular some unittests run during
  the build of editors/libreoffice.

  This hack will be removed as soon as upstream has implemented a more
  permanent fix for this problem.

And indeed, after r345018 and r345019, which updated LLVM libunwind to
the most recent version, the above workaround is no longer needed.  The
upstream commit which fixed this is:

  https://llvm.org/viewvc/llvm-project?view=revision&revision=292723

Specifically, 32 bit (i386-freebsd) executables optimized with omitted
frame pointers and Call Frame Optimization should now behave correctly
when a C++ exception is thrown, and the stack is unwound.

Upstream PR: https://llvm.org/bugs/show_bug.cgi?id=30879
PR: 236062

MFC r345152:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062

MFC r345231:

Add LLVM openmp trunk r351319 (just before the release_80 branch point)
to contrib/llvm.  This is not yet connected to the build, the glue for
that will come in a follow-up commit.

PR: 236062

MFC r345232:

Bootstrap svn:mergeinfo on contrib/openmp.

PR: 236062

MFC r345233:

Merge openmp release_80 branch r356034 (effectively, 8.0.0 rc5).

PR: 236062

MFC r345234:

Add openmp __kmp_gettid() wrapper, using pthread_getthreadid_np(3).
This has also been submitted upstream.

PR:           236062

MFC r345283:

Enable building libomp.so for 32-bit x86.  This is done by selectively
enabling the functions that save and restore MXCSR, since access to this
register requires SSE support.

Note that you may run into other issues with OpenMP on i386, since this
*not* yet supported upstream, and certainly not extensively tested.

PR: 236062, 236582

MFC r345345:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365.  There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

https://llvm.org/releases/8.0.0/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/clang/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/tools/lld/docs/ReleaseNotes.html
https://llvm.org/releases/8.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 236062

MFC r345349:

Pull in r352826 from upstream lld trunk (by Fangrui Song):

  [ELF] Support --{,no-}allow-shlib-undefined

  Summary:
  In ld.bfd/gold, --no-allow-shlib-undefined is the default when
  linking an executable. This patch implements a check to error on
  undefined symbols in a shared object, if all of its DT_NEEDED entries
  are seen.

  Our approach resembles the one used in gold, achieves a good balance
  to be useful but not too smart (ld.bfd traces all DSOs and emulates
  the behavior of a dynamic linker to catch more cases).

  The error is issued based on the symbol table, different from
  undefined reference errors issued for relocations. It is most
  effective when there are DSOs that were not linked with -z defs (e.g.
  when static sanitizers runtime is used).

  gold has a comment that some system libraries on GNU/Linux may have
  spurious undefined references and thus system libraries should be
  excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
  story may have changed now but we make --allow-shlib-undefined the
  default for now. Its interaction with -shared can be discussed in the
  future.

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: joerg, emaste, arichardson, llvm-commits

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

Pull in r352943 from upstream lld trunk (by Fangrui Song):

  [ELF] Default to --no-allow-shlib-undefined for executables

  Summary:
  This follows the ld.bfd/gold behavior.

  The error check is useful as it captures a common type of ld.so
  undefined symbol errors as link-time errors:

      // a.cc => a.so (not linked with -z defs)
      void f(); // f is undefined
      void g() { f(); }

      // b.cc => executable with a DT_NEEDED entry on a.so
      void g();
      int main() { g(); }

      // ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
      // symbol lookup error: ... undefined symbol: f

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: llvm-commits, emaste, arichardson

  Tags: #llvm

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

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141

MFC r345449:

Pull in r356809 from upstream llvm trunk (by Eli Friedman):

  [ARM] Don't form "ands" when it isn't scheduled correctly.

  In r322972/r323136, the iteration here was changed to catch cases at
  the beginning of a basic block... but we accidentally deleted an
  important safety check.  Restore that check to the way it was.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=41116

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

This should fix "Assertion failed: (LiveCPSR && "CPSR liveness tracking
is wrong!"), function UpdateCPSRUse" errors when building the devel/xwpe
port for armv7.

PR: 236062, 236568

5 years agoMFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.
mav [Tue, 16 Apr 2019 18:32:07 +0000 (18:32 +0000)]
MFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.

 - Do not retry if periph was invalidated.
 - Do not decrement retry_count if already zero.
 - Report action_string when applicable.

5 years agoMFC r346064:
kib [Tue, 16 Apr 2019 17:56:53 +0000 (17:56 +0000)]
MFC r346064:
Fix dirty buf exhaustion easily triggered with msdosfs.

5 years agoMFC r345425, r345514, r345799, r345800, r345803, r346157:
kib [Tue, 16 Apr 2019 17:43:14 +0000 (17:43 +0000)]
MFC r345425, r345514, r345799, r345800, r345803, r346157:
Enable tmpfs rw->ro remounts.

5 years agoRelease notes documentation:
gjb [Tue, 16 Apr 2019 17:12:27 +0000 (17:12 +0000)]
Release notes documentation:
- r336449, setproctitle_fast(3) addition.
- r337418, kqueue(2) allow EVFILT_TIMER updates.
- r338405, pthread_get_name_np(3) addition.
- r339857, ddb(4) option to print process arguments added.
- r340182, ichwd(4) support for Lewisburg PCH TCO watchdog timer.
- r341828, ZFS vnode reclaimation deadlock fixed.
- r342206, lagg(4) allow changing MTU without destroying interface.
- r342656, x86 MSI IRQs are now tunable.
- r343084, jail(8) IDs printed when logging a process exit.
- r344399, zfsloader functionality now part of loader(8).
- r344399, loader(8) GELI support extended to all architectures.
- r344403, efi guess console device/type if not defined.
- r345040, ccr(4) driver addition.
- r345981, random(4) reseeding performance improvements.

Add Klara Systems, Modirum MDPay, and Panzura to the sponsors
file, sort, and remove random blank lines.

Sponsored by: The FreeBSD Foundation