]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r345139, r345151, r346324, r346328: ether_gen_addr KPI
Kyle Evans [Sat, 27 Apr 2019 04:39:41 +0000 (04:39 +0000)]
MFC r345139, r345151, r346324, r346328: ether_gen_addr KPI

if_bridge and if_vxlan conversion to this deterministic MAC address KPI has
been MFC as well.  This is potentially error prone as the generated address
range for these has decreased, but I've deemed this acceptable for stable
branches due to collisions for thees interfaces being easily remedied.

I have no intention of switching anything else to this KPI in any stable
branches.

r345139:
ether: centralize fake hwaddr generation

We currently have two places with identical fake hwaddr generation --
if_vxlan and if_bridge. Lift it into if_ethersubr for reuse in other
interfaces that may also need a fake addr.

r345151:
ether_fakeaddr: Use 'b' 's' 'd' for the prefix

This has the advantage of being obvious to sniff out the designated prefix
by eye and it has all the right bits set. Comment stolen from ffec.

I've removed bryanv@'s pending question of using the FreeBSD OUI range --
no one has followed up on this with a definitive action, and there's no
particular reason to shoot for it and the administrative overhead that comes
with deciding exactly how to use it.

r346324:
net: adjust randomized address bits

Give devices that need a MAC a 16-bit allocation out of the FreeBSD
Foundation OUI range. Change the name ether_fakeaddr to ether_gen_addr now
that we're dealing real MAC addresses with a real OUI rather than random
locally-administered addresses.

r346328:
Compile sha1.c when ether support is included

sha1 is used by ether_gen_addr after r346324. Perhaps in an ideal world we
could detect that the kernel's been compiled without sha1_* bits included
and silently fallback to arc4random instead because these platforms/kernel
configs are far and few between. It's fairly lightweight, though, so just
include it for now.

5 years agoMFC r346469: dtc(1): Pull in fix for segfault-upon-error condition
Kyle Evans [Sat, 27 Apr 2019 04:16:15 +0000 (04:16 +0000)]
MFC r346469: dtc(1): Pull in fix for segfault-upon-error condition

Specifically, parse errors within a node would lead to a segfault due to
an unconditional dereference after emitting the error.

5 years agoMFC r346307, r346618: Further DTB building consolidation/documentation
Kyle Evans [Sat, 27 Apr 2019 04:12:32 +0000 (04:12 +0000)]
MFC r346307, r346618: Further DTB building consolidation/documentation

r346307:
fdt: further consolidate DTB building and revise manpage

FDT_DTS_FILE was built separately with a rule in sys/conf/files and
recreated the rules we used in dtb.mk. Now that we have other infrastructure
to build a DTB along with the kernel, fold FDT_DTS_FILE into that since it
doesn't have any special requirements.

fdt(4) never got revised to mention the DTS/DTSO make options, so do that
now.

r346618:
fdt: stop installing FDT_DTS_FILE

r346307 inadvertently started installing FDT_DTS_FILE along with the kernel.
While this isn't necessarily bad, it was not intended or discussed and it
actively breaks some current setups that don't anticipate any .dtb being
installed when it's using static fdt. This change could be reconsidered down
the line, but it needs to be done with prior discussion.

Fix it by pushing FDT_DTS_FILE build down into the raw dtb.build.mk bits.
This technically allows modules building DTS to accidentally specify an
FDT_DTS_FILE that gets built but isn't otherwise useful (since it's not
installed), but I suspect this isn't a big deal and would get caught with
any kind of testing -- and perhaps this might end up useful in some other
way, for example by some module wanting to embed fdt in some other way than
our current/normal mechanism.

5 years agoMFC r346628: Split the pkg configuration file FreeBSD.conf into versions
Colin Percival [Sat, 27 Apr 2019 04:00:50 +0000 (04:00 +0000)]
MFC r346628: Split the pkg configuration file FreeBSD.conf into versions
for {latest, quarterly} and use Makefile logic to decide which one to
install (right now, unconditionally "latest").

Discussed with: gjb

5 years agoMFC: r346192
Rick Macklem [Sat, 27 Apr 2019 02:05:04 +0000 (02:05 +0000)]
MFC: r346192
Fix printing of the line that starts with "LocalOpen...".

When "nfsstat -E -c" was done, the title line starting with "LocalOpen..."
was not being displayed. This was introduced by r328588.

5 years agoMFC: r346191
Rick Macklem [Sat, 27 Apr 2019 01:58:51 +0000 (01:58 +0000)]
MFC: r346191
Add support for INET6 addresses to the kernel code that dumps open/lock state.

PR#223036 reported that INET6 callback addresses were not printed by
nfsdumpstate(8). This kernel patch adds INET6 addresses to the dump structure,
so that nfsdumpstate(8) can print them out, post-r346190.

5 years agoMFC: r346190
Rick Macklem [Sat, 27 Apr 2019 01:50:09 +0000 (01:50 +0000)]
MFC: r346190
Fix nfsdumpstate(8) so that it can print out INET6 callback addresses.

The patch adds support for printing of INET6 callback addresses.
It also adds the #ifdef INET, INET6 as requested by bz@.

5 years agoMFC r345656: Do not map small IOCTL buffers to KVA, but copy.
Alexander Motin [Fri, 26 Apr 2019 17:21:12 +0000 (17:21 +0000)]
MFC r345656: Do not map small IOCTL buffers to KVA, but copy.

CAM IOCTL interfaces traditionally mapped user-space data buffers to KVA.
It was nice originally, but now it takes too much to handle respective
TLB shootdowns, while small kernel memory allocations up to 64KB backed
by UMA and accompanied by copyin()/copyout() can be much cheaper.

For large buffers mapping still may have sense, and unmapped I/O would
be even better, but the last unfortunately is more tricky, since unmapped
I/O API is too specific to struct bio now.

Sponsored by: iXsystems, Inc.

5 years agoMFC r346370:
Kristof Provost [Fri, 26 Apr 2019 14:15:58 +0000 (14:15 +0000)]
MFC r346370:

pfctl: Fix ifgroup check

We cannot just assume that any name which ends with a letter is a group
That's not been true since we allowed renaming of network interfaces. It's also
not true for things like epair0a.

Try to retrieve the group members for the name to check, since we'll get ENOENT
if the group doesn't exist.

5 years agoMFC r346349:
Kristof Provost [Fri, 26 Apr 2019 13:00:22 +0000 (13:00 +0000)]
MFC r346349:

pf: No need to M_NOWAIT in DIOCRSETTFLAGS

Now that we don't hold a lock during DIOCRSETTFLAGS memory allocation we can
use M_WAITOK.

Pointed out by: glebius@

5 years agoMFC r346347:
Kristof Provost [Fri, 26 Apr 2019 12:59:23 +0000 (12:59 +0000)]
MFC r346347:

pf tests: Fail the test if we can't set the rules

The test should fail if pf rules can't be set. This is helpful both
while writing tests and to verify that pfctl works as expected.

5 years agoMFC r345830: Create kernel module to parse Veriexec manifest based on envs
Marcin Wojtas [Fri, 26 Apr 2019 11:12:51 +0000 (11:12 +0000)]
MFC r345830: Create kernel module to parse Veriexec manifest based on envs

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

5 years agoMFC r343455: Fix tpm2 acpidump compilation on 32-bit
Marcin Wojtas [Fri, 26 Apr 2019 02:16:57 +0000 (02:16 +0000)]
MFC r343455: Fix tpm2 acpidump compilation on 32-bit

5 years agoMFC r345438,r345842,r346259,r346261: TPM as possible entropy source
Marcin Wojtas [Fri, 26 Apr 2019 01:41:55 +0000 (01:41 +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.

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
Marcin Wojtas [Fri, 26 Apr 2019 01:29:00 +0000 (01:29 +0000)]
MFC r343438: Use ACPI TPM2 table to probe tpmtis and tpmcrb device

Sponsored by: Stormshield

5 years agoMFC r342084,r342251,r342271,r342285: Introduce TPM2.0 driver
Marcin Wojtas [Fri, 26 Apr 2019 01:02:14 +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 agoMFC r344840: Extend libsecureboot(old libve) to obtain trusted certificates from...
Marcin Wojtas [Fri, 26 Apr 2019 00:48:52 +0000 (00:48 +0000)]
MFC r344840: Extend libsecureboot(old libve) to obtain trusted certificates from UEFI and implement revocation

UEFI related headers were copied from edk2.

A new build option "MK_LOADER_EFI_SECUREBOOT" was added to allow
loading of trusted anchors from UEFI.

Certificate revocation support is also introduced.
The forbidden certificates are loaded from dbx variable.
Verification fails in two cases:

There is a direct match between cert in dbx and the one in the chain.
The CA used to sign the chain is found in dbx.
One can also insert a hash of TBS section of a certificate into dbx.
In this case verifications fails only if a direct match with a
certificate in chain is found.

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

5 years agoMFC r343911: Allow reading the UEFI variable size
Marcin Wojtas [Fri, 26 Apr 2019 00:39:30 +0000 (00:39 +0000)]
MFC 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.

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

5 years agoMFC r346056:
Enji Cooper [Thu, 25 Apr 2019 21:42:02 +0000 (21:42 +0000)]
MFC r346056:

Fix a typo when sanity checking in the bootstrap-tools target

The path is incorrect for the linker in the error message. It should have been
/usr/bin/ld, not /usr/bin/cc .

5 years agoMFC: r345888: Use IN_foo() macros from sys/netinet/in.h inplace of
Rodney W. Grimes [Thu, 25 Apr 2019 21:28:28 +0000 (21:28 +0000)]
MFC: r345888: Use IN_foo() macros from sys/netinet/in.h inplace of
handcrafted code

There are a few places that use hand crafted versions of the macros
from sys/netinet/in.h making it difficult to actually alter the
values in use by these macros.  Correct that by replacing handcrafted
code with proper macro usage.

Reviewed by: karels, kristof
Approved by: bde (mentor, implicit)
Sponsored by: John Gilmore
Differential Revision: https://reviews.freebsd.org/D19317

5 years agoMFC r339826 (by yuripv):
Alexander Motin [Thu, 25 Apr 2019 21:04:38 +0000 (21:04 +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 r345200: MFV r336930: 9284 arc_reclaim_thread has 2 jobs
Alexander Motin [Thu, 25 Apr 2019 14:41:29 +0000 (14:41 +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>

5 years agoMFC r344601 (by sef): Set process title during zfs send.
Alexander Motin [Thu, 25 Apr 2019 14:39:52 +0000 (14:39 +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.
Alexander Motin [Thu, 25 Apr 2019 14:33:38 +0000 (14:33 +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 r346229 and r346248:
Hans Petter Selasky [Thu, 25 Apr 2019 12:00:06 +0000 (12:00 +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:
Hans Petter Selasky [Thu, 25 Apr 2019 11:56:07 +0000 (11:56 +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 r346352, r346355:
Konstantin Belousov [Thu, 25 Apr 2019 08:28:54 +0000 (08:28 +0000)]
MFC r346352, r346355:
Correct handling of RMRR during early enumeration stages.

5 years agoMFC r346351:
Konstantin Belousov [Thu, 25 Apr 2019 08:27:00 +0000 (08:27 +0000)]
MFC r346351:
Remove witness warning. dmar_bus_dmamap_create() does not sleep.

5 years agoMFC r346350:
Konstantin Belousov [Thu, 25 Apr 2019 08:25:48 +0000 (08:25 +0000)]
MFC r346350:
Reduce verbosity, do not announce details of irte programming by default.

5 years agoMFC r346543:
Mark Johnston [Thu, 25 Apr 2019 03:48:37 +0000 (03:48 +0000)]
MFC r346543:
Disable vm map consistency checking by default on INVARIANTS kernels.

5 years agoMFC r346118:
Mark Johnston [Thu, 25 Apr 2019 03:46:54 +0000 (03:46 +0000)]
MFC r346118:
Reinitialize multicast source filter structures after invalidation.

5 years agoMFC r346320:
Kristof Provost [Wed, 24 Apr 2019 15:02:59 +0000 (15:02 +0000)]
MFC r346320:

pf tests: Try to provoke the panic with invalid DIOCRSETTFLAGS

There was an issue with copyin() on DIOCRSETTFLAGS, which would panic if
pfrio_buffer was NULL.
Test for the issue fixed in r346319.

5 years agoMFC r346319:
Kristof Provost [Wed, 24 Apr 2019 14:08:14 +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 agoMFC r346490:
Benedict Reuschling [Wed, 24 Apr 2019 06:41:52 +0000 (06:41 +0000)]
MFC r346490:

Typo fix in ipfw.8: amd -> and

There is an (obvious) typo in the following sentence:

"Please note, that keep-state amd limit imply implicit check-state for ..."

Replace the "amd" with "and", bump .Dd.

PR:     237438
Submitted by:     michael@galassi.us

5 years agoMFC r345562 (by cem), r346294:
Konstantin Belousov [Tue, 23 Apr 2019 12:29:19 +0000 (12:29 +0000)]
MFC r345562 (by cem), r346294:
x86: Use XSAVEOPT for fpusave(), when available.

5 years agoMFC r346254: config(8): replace opteq with a call to strcasecmp
Kyle Evans [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
Kyle Evans [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 r346009:
Mark Johnston [Mon, 22 Apr 2019 11:13:53 +0000 (11:13 +0000)]
MFC r346009:
Set the p_oppid field of orphans when exiting.

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

5 years agoMFC r339473,r340075,r342918,r343592,r343593,r343614,r343665,r343669:
Enji Cooper [Mon, 22 Apr 2019 08:58:33 +0000 (08:58 +0000)]
MFC r339473,r340075,r342918,r343592,r343593,r343614,r343665,r343669:

MFC a number of changes to elftoolchain/readelf(1). This brings the copy of
elftoolchain more in line with the version in ^/head and partially fixes
the issue with `sys.kern.coredump_phnum_test.coredump_phnum` on ^/stable/12.

Tested with: make tinderbox

r339473 (by emaste):

libelf: also test for 64-bit ELF in _libelf_is_mips64el

Although _libelf_is_mips64el is only called in contexts where we've
already checked that e_class is ELFCLASS64 but this may change in the
future.  Add a safety belt so that we don't access an invalid e_ehdr64
union member if it does.

r340075 (by emaste):

readelf: decode R_MIPS_HIGHER and R_MIPS_HIGHEST relocation types

r342918 (by emaste):

Update to ELF Tool Chain r3668

Highlights:
- Make sure that only TLS sections are sorted into TLS segment.
- Fixed multiple errors in "Section to Segment mapping".
- Man page updates
- ar improvements
- elfcopy: avoid filter_reloc uninitialized variable for rela
- elfcopy: avoid stripping relocations from static binaries
- readelf: avoid printing directory in front of absolute path
- readelf: add NT_FREEBSD_FEATURE_CTL FreeBSD note type
- test improvements

NOTES:

Some of these changes originated in FreeBSD and simply reduce diffs
between contrib and vendor.

ELF Tool Chain ar is not (currently) used in FreeBSD, and there are
improvements in both FreeBSD and ELF Tool Chain ar that are not in
the other.

r343592 (by emaste):

readelf: decode flag bits in DT_FLAGS/DT_FLAGS_1

Decode d_val when the tag is DT_FLAGS or DT_FLAGS_1 based on the
information at:

https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-42444.html

PR: 232983

r343593 (by emaste):

readelf: fix i386 build

Use %jx and (uintmax_t) cast.

PR: 232983
MFC with: r343592

r343614 (by emaste):

readelf: dump elf note data

Output format is compatible with GNU readelf's handling of unknown note
types (modulo a GNU char signedness bug); future changes will add type-
specific decoding.

Relnotes: Yes

r343665 (by emaste):

readelf: use table-based DT_FLAGS and DT_FLAGS_1 decoding

Fewer lines of code and more maintainable.

r343669 (by emaste):

readelf: decode FreeBSD note types

Decode NT_FREEBSD_ABI_TAG, NT_FREEBSD_ARCH_TAG, and NT_FREEBSD_FEATURE_CTL.

Relnotes: Yes

5 years agoMFC r346252: cron(8): Add MAILFROM ability for crontabs
Kyle Evans [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 r344556:
Ian Lepore [Mon, 22 Apr 2019 00:49:13 +0000 (00:49 +0000)]
MFC 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.

5 years agoMFC r345480, r346013
Ian Lepore [Mon, 22 Apr 2019 00:45:09 +0000 (00:45 +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 r344505-r344507, r344523, r344525-r344526, r344529, r344606-r344612,
Ian Lepore [Mon, 22 Apr 2019 00:38:25 +0000 (00:38 +0000)]
MFC r344505-r344507, r344523, r344525-r344526, r344529, 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 and
geom_label support to them.

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.

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.

Reported by: jhibbits@

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 r344267:
Ian Lepore [Sun, 21 Apr 2019 22:31:52 +0000 (22:31 +0000)]
MFC r344267:

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

5 years agoMFC r344254-r344255
Ian Lepore [Sun, 21 Apr 2019 22:28:50 +0000 (22:28 +0000)]
MFC r344254-r344255

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'.

5 years agoMFC r344238-r344241
Ian Lepore [Sun, 21 Apr 2019 22:26:27 +0000 (22:26 +0000)]
MFC r344238-r344241

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 collect no-longer-used constant.

5 years agoMFC r342639:
Ian Lepore [Sun, 21 Apr 2019 22:21:36 +0000 (22:21 +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 r341420, r341473, r341651
Ian Lepore [Sun, 21 Apr 2019 22:13:07 +0000 (22:13 +0000)]
MFC r341420, r341473, r341651

r341420:
Eliminate duplicated code and struct member definitions in the handoff
of args data between gptboot/zfsboot and loader(8).

Despite what seems like a lot of changes here, there are no actual
changes in behavior, or in the data layout in the structures involved.
This is just eliminating identical code pasted into multiple locations.

In detail, the changes are...

- Move struct zfs_boot_args definition from libsa/zfs/libzfs.h to
  i386/common/bootargs.h because it is specific to x86 booting and the
  handoff between zfsboot and loader, and has no relation to the zfs
  library code in general.

- The geli_boot_args and zfs_boot_args structs both contain an identical
  set of member variables containing geli information.  Extract this out
  to a new geli_boot_data struct, and embed it in the arg-passing structs.

- Provide new routines geli_import_boot_data() and geli_export_boot_data()
  that can be shared between gptboot, zfsboot, and loader instead of
  pasting identical code into several different .c files.

- Remove some checks for a NULL pointer that can never be true because the
  pointer being tested was set using pointer math (kargs + 1) and that can
  never result in NULL in this code.

r341473:
Fix args cross-threading between gptboot(8) and loader(8) with zfs support.

When loader(8) is built with zfs support enabled, it assumes that any extarg
data present is a zfs_boot_args struct, but if the first-stage loader was
gptboot(8) the extarg data is actually a geli_boot_args struct.  Luckily,
zfsboot(8) and gptzfsboot(8) have always passed KARGS_FLAGS_ZFS along with
KARGS_FLAGS_EXTARG, so we can use KARGS_FLAGS_ZFS to decide whether the
extarg data is a zfs_boot_args struct.

To avoid similar problems in the future, gptboot(8) now passes a new
KARGS_FLAGS_GELI to indicate that extarg data is geli_boot_args.  In
loader(8), if the neither KARGS_FLAGS_ZFS nor KARGS_FLAGS_GELI is set but
extarg data is present (which will be the case for gptboot compiled before
this change), we now check for the known size of the geli_boot_args struct
passed by the older versions of gptboot as a way of confirming what type of
extarg data is present.

In a semi-related tidying up, since loader's main() has already decided
what type of extarg data is present and set the global 'zargs' var
accordingly, don't repeat the check in extract_currdev, just check whether
zargs is NULL or not.

r341651:
Don't reference zfs-specific variables if LOADER_ZFS_SUPPORT is undefined
because the variables will be undefined too.

5 years agoMFC r346312:
Ian Lepore [Sun, 21 Apr 2019 20:55:33 +0000 (20:55 +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 Lepore [Sun, 21 Apr 2019 20:53:15 +0000 (20:53 +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 r345000:
Ian Lepore [Sun, 21 Apr 2019 20:50:55 +0000 (20:50 +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 r344260, r344335
Ian Lepore [Sun, 21 Apr 2019 20:46:49 +0000 (20:46 +0000)]
MFC r344260, r344335

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).

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.

5 years agoMFC r344247:
Ian Lepore [Sun, 21 Apr 2019 20:40:49 +0000 (20:40 +0000)]
MFC 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.

PR: 233097

5 years agoMFC r342850: Add a missing \n to a bootverbose printf.
Ian Lepore [Sun, 21 Apr 2019 19:50:30 +0000 (19:50 +0000)]
MFC r342850: Add a missing \n to a bootverbose printf.

5 years agoMFC r342652:
Ian Lepore [Sun, 21 Apr 2019 19:49:15 +0000 (19:49 +0000)]
MFC r342652:

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

5 years agoMFC r346216:
Konstantin Belousov [Sun, 21 Apr 2019 09:11:22 +0000 (09:11 +0000)]
MFC r346216:
ld-elf.so: make LD_DEBUG always functional.

5 years agoMFC: r345995
Rick Macklem [Sun, 21 Apr 2019 00:11:58 +0000 (00:11 +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.

This is a content change.

5 years agoMFC: r345994
Rick Macklem [Sun, 21 Apr 2019 00:05:12 +0000 (00:05 +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
Rick Macklem [Sat, 20 Apr 2019 23:46:06 +0000 (23:46 +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.
This patch also reverts the unused AF_LOCAL socket code.

5 years agoMFC r345996:
Cy Schubert [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 r345348, r345594:
Mark Johnston [Sat, 20 Apr 2019 11:05:56 +0000 (11:05 +0000)]
MFC r345348, r345594:
Use -fdebug-prefix-map to map auto-generated kernel build paths.

5 years agoMFC r346010:
Mark Johnston [Sat, 20 Apr 2019 11:04:13 +0000 (11:04 +0000)]
MFC r346010:
Fix indentation.

5 years agoMFC r346011:
Mark Johnston [Sat, 20 Apr 2019 11:02:40 +0000 (11:02 +0000)]
MFC r346011:
Stop compiling bhyve(8) with -O0.

5 years agoMFC r345739:
Mark Johnston [Sat, 20 Apr 2019 11:01:47 +0000 (11:01 +0000)]
MFC r345739:
Do not perform DAD on stf(4) interfaces.

5 years agoMFC r345593:
Mark Johnston [Sat, 20 Apr 2019 10:58:33 +0000 (10:58 +0000)]
MFC r345593:
Prepend DW_AT_comp_dir to relative line number directory table entries.

5 years agoMFC r345513:
Mark Johnston [Sat, 20 Apr 2019 10:56:56 +0000 (10:56 +0000)]
MFC r345513:
Reject F_SETLK_REMOTE commands when sysid == 0.

5 years agoMFC: 342657, 345025
Warner Losh [Fri, 19 Apr 2019 20:22:21 +0000 (20:22 +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.

5 years agoMFC r344740:
Bjoern A. Zeeb [Fri, 19 Apr 2019 17:28:38 +0000 (17:28 +0000)]
MFC r344740:

  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:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:53:30 +0000 (15:53 +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 r345372:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:52:09 +0000 (15:52 +0000)]
MFC r345372:

  Whitespace cleanup in sdhci.c

  No functional changes.  Replace whitespace by tabs, indent with 4 spaces,
  coalesce multi-line shorter than 80 characters,

5 years agoMFC r345370:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:50:51 +0000 (15:50 +0000)]
MFC r345370:

  Align struct sdhci_slot MMCCAM members.

  Whitespace only, no functional change.

5 years agoMFC r344959:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:48:57 +0000 (15:48 +0000)]
MFC r344959:

  Add two more products found inside a T480 to usbdevs.

  Add an Intel Bluetooth module.
  Add Synaptics as a vendor with a fingerprint reader product.

5 years agoMFC r344700:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:45:36 +0000 (15:45 +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:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:33:54 +0000 (15:33 +0000)]
MFC r340494:

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

5 years agoMFC r346275:
Glen Barber [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:
Konstantin Belousov [Fri, 19 Apr 2019 12:54:05 +0000 (12:54 +0000)]
MFC r345966, r345968:
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

5 years agoMFC r345965:
Konstantin Belousov [Fri, 19 Apr 2019 12:50:25 +0000 (12:50 +0000)]
MFC r345965:
Add DEV_RESET /dev/devctl2 ioctl.

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

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

5 years agoMFC r345964:
Konstantin Belousov [Fri, 19 Apr 2019 12:38:48 +0000 (12:38 +0000)]
MFC r345964:
Remove single-use DEV_RESET() macro.

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

5 years agoMFC r346158:
Konstantin Belousov [Fri, 19 Apr 2019 12:30:15 +0000 (12:30 +0000)]
MFC r346158:
Do not access mutex memory after unlock.

PR: 237195

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

5 years agoMFC r346159: Fix thread name buffer overflow.
Alexander Motin [Fri, 19 Apr 2019 03:46:35 +0000 (03:46 +0000)]
MFC r346159: Fix thread name buffer overflow.

5 years agoMFC: r345866
Rick Macklem [Thu, 18 Apr 2019 02:32:04 +0000 (02:32 +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 agoMFC r345312
Eric Joyner [Wed, 17 Apr 2019 23:09:06 +0000 (23:09 +0000)]
MFC r345312

iflib: mark isc_driver_version as constant

From Jake:
The iflib core never modifies the isc_driver_version string. Allow
drivers to safely assign pointers to constant buffers by marking this
parameter const.

(Additional comment by erj: This also adds a new sysctl_add_oid macro,
SYSCTL_ADD_CONST_STRING, for displaying const strings).

Submitted by:   Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:    erj@, gallatin@, jhb@
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D19577

5 years agoMFC r345303, r345305, r345657, r345658
Eric Joyner [Wed, 17 Apr 2019 23:02:37 +0000 (23:02 +0000)]
MFC r345303, r345305, r345657, r345658

Includes:
- iflib: prevent possible infinite loop in iflib_encap
- iflib: expose the Rx mbuf buffer size to drivers
- iflib: hold the CTX lock in iflib_pseudo_register
- iflib: return ENETDOWN when the network device is down

5 years agoMFC r344817
Eric Joyner [Wed, 17 Apr 2019 22:45:19 +0000 (22:45 +0000)]
MFC r344817

Remove references to CONTIGMALLOC_WORKS in iflib and em

From Jake:
"The iflib_fl_setup() function tries to pick various buffer sizes based
on the max_frame_size value defined by the parent driver. However, this
code was wrapped under CONTIGMALLOC_WORKS, which was never actually
defined anywhere.

This same code pattern was used in if_em.c, likely trying to match
what iflib uses.

Since CONTIGMALLOC_WORKS is not defined, remove this dead code from
iflib_fl_setup and if_em.c

Given that various iflib drivers appear to be using a similar
calculation, it might be worth making this buffer size a value that the
driver can peek at in the future."

Submitted by:   Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:    shurd@
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D19199

5 years agoMFC r344643 and r345306
Eric Joyner [Wed, 17 Apr 2019 22:41:27 +0000 (22:41 +0000)]
MFC r344643 and r345306

Includes two ixgbe/ixv fixes:
ixgbe(4): Fix panic triggered by assertion from interrupt
ixv(4): Add missing IFLIB_IS_VF flag in iflib shared ctx

Sponsored by: Intel Corporation

5 years agoAfter r346168, also merge build infrastructure for LLVM libomp.
Dimitry Andric [Wed, 17 Apr 2019 20:08:01 +0000 (20:08 +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 r345855: cpsw: use `phy-handle` in FDT to find PHY address
Ed Maste [Wed, 17 Apr 2019 17:19:19 +0000 (17:19 +0000)]
MFC r345855: cpsw: use `phy-handle` in FDT to find PHY address

In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR: 236624
Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by: Gerald Aryeetey
Reviewed by: manu
Sponsored by: The FreeBSD Foundation

5 years agoMFC r345316, r345317, r345858:
Colin Percival [Wed, 17 Apr 2019 07:47:03 +0000 (07:47 +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 agoMFC r345519: DTS/DTSO makeoptions
Kyle Evans [Tue, 16 Apr 2019 21:09:57 +0000 (21:09 +0000)]
MFC r345519: DTS/DTSO makeoptions

Allow kernel config to specify DTS/DTSO to build, and out-of-tree support

This allows for directives such as

makeoptions DTS+=/out/of/tree/myboard.dts
# in tree! Same rules applied as if this were in a dtb/ module
makeoptions DTS+=otherboard.dts

to be specified in config(5) and have these built/installed alongside th
kernel. The assumption that overlays live in an overlays/ directory is only
made for in-tree DTSO, but we still make the assumption that out-of-tree
arm64 DTS will be in vendored directories (for now).

This lowers the cost to hacking on an overlay or dts by being able to
quickly throw it in a custom config, especially if it doesn't fit one of the
current dtb/modules quite appropriately or it's not intended for commit
there.

The build/install targets were split out of dtb.mk to centralize the build
logic and leave out the all/realinstall/CLEANFILES additions... it was
believed that we didn't want to pollute the kernel build with these.

The build rules were converted to suffix rules at the suggestion of Ian to
clean things up a little bit in a world where we can have mixed
in-tree/out-of-tree DTS/DTSO specified.

5 years agoMFC r345192-r345194: if_bridge(4): Drop pointless rtflush
Kyle Evans [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
Kyle Evans [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 r346082: libbe(3): use libzfs name validation for datasets/snapshot names
Kyle Evans [Tue, 16 Apr 2019 20:59:57 +0000 (20:59 +0000)]
MFC r346082: libbe(3): use libzfs name validation for datasets/snapshot names

Our home-rolled solution didn't quite capture all of the details, and we
didn't actually validate snapshot names at all. zfs_name_valid captures the
important details, but it doesn't necessarily expose the errors that we're
wanting to see in the be_validate_* functions. Validating lengths
independently, then the names, should make this a non-issue.

5 years agoMFC r345180, r345187: if_bridge(4): Fix module teardown
Kyle Evans [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 agoMFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.
Alexander Motin [Tue, 16 Apr 2019 18:31:40 +0000 (18:31 +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 r346065:
Konstantin Belousov [Tue, 16 Apr 2019 17:55:54 +0000 (17:55 +0000)]
MFC r346065:
Add vn_fsync_buf().