]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r346263:
Mariusz Zaborski [Wed, 1 May 2019 07:00:56 +0000 (07:00 +0000)]
MFC r346263:
  tcpdump: disable Capsicum if -E option is provided.

  The -E is used to provide a secret for decrypting IPsec.
  The secret may be provided through command line or as the file.
  The problem is that tcpdump doesn't support yet opening files in capability mode
  and the file may contain a list of the files to open.

  As a workaround, for now, let's just disable capsicum if the -E
  the option is provided.

  PR:           236819

5 years agoMFC r346459:
Cy Schubert [Wed, 1 May 2019 01:53:19 +0000 (01:53 +0000)]
MFC r346459:

  MFV r346450:

  Update sqlite3-3.27.1 (3270100) --> sqlite3-3.27.2 (3270200)

5 years agoMFC r346804:
Cy Schubert [Wed, 1 May 2019 01:49:33 +0000 (01:49 +0000)]
MFC r346804:

Left justify a function header brace as it should be.
No functional change.

5 years agoMFC r341759, r341796, r341839, r341989, r346591:
Cy Schubert [Wed, 1 May 2019 01:42:38 +0000 (01:42 +0000)]
MFC r341759, r341796, r341839, r341989, r346591:
The following five MFCs update wpa 2.6 --> 2.8.

r341759:
MFV r341618: Update wpa 2.6 --> 2.7.

r341796:
Clean stale wpa dependencies and objects after r341759

The wpa update added some source files with the same name as a file in
another directory (found via .PATH in the previous version).  Having a
stale entry in a .depend file means the new file won't be built, so test
for this case and if found remove all of wpa's dependency files.

Sponsored by:   The FreeBSD Foundation

r341839:
Set default ciphers.

Submitted by:   jkim@

r341989:
Makefile.inc1: update stale wpa dependency removal statement

Only stale .depend files are removed; do not mention object files.

r346591:
Update wpa_supplicant/hostapd 2.7 --> 2.8

Upstream documents the following advisories:

- https://w1.fi/security/2019-1/sae-side-channel-attacks.txt
- https://w1.fi/security/2019-2/eap-pwd-side-channel-attack.txt
- https://w1.fi/security/2019-3/sae-confirm-missing-state-validation.txt
- https://w1.fi/security/2019-4/eap-pwd-missing-commit-validation.txt
- https://w1.fi/security/2019-5/eap-pwd-message-reassembly-issue-\
  with-unexpected-fragment.txt

Security: CVE-2019-9494, VU#871675, CVE-2019-9495, CVE-2019-9496,
CVE-2019-9497, CVE-2019-9498, CVE-2019-9499

Relnotes: yes

5 years agoMFC 344711: Fix missed posted interrupts in VT-x in bhyve.
John Baldwin [Tue, 30 Apr 2019 23:53:54 +0000 (23:53 +0000)]
MFC 344711: Fix missed posted interrupts in VT-x in bhyve.

When a vCPU is HLTed, interrupts with a priority below the processor
priority (PPR) should not resume the vCPU while interrupts at or above
the PPR should.  With posted interrupts, bhyve maintains a bitmap of
pending interrupts in PIR descriptor along with a single 'pending'
bit.  This bit is checked by a CPU running in guest mode at various
places to determine if it should be checked.  In addition, another CPU
can force a CPU in guest mode to check for pending interrupts by
sending an IPI to a special IDT vector reserved for this purpose.

bhyve had a bug in that it would only notify a guest vCPU of an
interrupt (e.g. by sending the special IPI or by resuming it if it was
idle due to HLT) if an interrupt arrived that was higher priority than
PPR and no interrupts were currently pending.  This assumed that if
the 'pending' bit was set, any needed notification was already in
progress.  However, if the first interrupt sent to a HLTed vCPU was
lower priority than PPR and the second was higher than PPR, the first
interrupt would set 'pending' but not notify the vCPU, and the second
interrupt would not notify the vCPU because 'pending' was already set.
To fix this, track the priority of pending interrupts in a separate
per-vCPU bitmask and notify a vCPU anytime an interrupt arrives that
is above PPR and higher than any previously-received interrupt.

This was found and debugged in the bhyve port to SmartOS maintained by
Joyent.  Relevant SmartOS bugs with more background:

https://smartos.org/bugview/OS-6829
https://smartos.org/bugview/OS-6930
https://smartos.org/bugview/OS-7354

5 years agoAllow no_hash to appear in manifest.
Simon J. Gerraty [Tue, 30 Apr 2019 23:01:13 +0000 (23:01 +0000)]
Allow no_hash to appear in manifest.

sbin/veriexec will ignore entries that have no hash anyway,
but loader needs to be explicitly told that such files are
ok to ignore (not verify).

We will report as Unverified depending on verbose level,
but with no reason - because we are not rejecting the file.

MFC r346604

5 years agoMFC r346567:
Navdeep Parhar [Tue, 30 Apr 2019 21:27:32 +0000 (21:27 +0000)]
MFC r346567:

cxgbe(4): Make sure bundled_fw is always initialized before use.

This fixes a bug that prevented the driver from auto-flashing the
firmware when it didn't see one on the card.  This feature was
introduced in r321390 and this bug was introduced in r343269.

Reported by: gallatin@
Sponsored by: Chelsio Communications

5 years agoMFC r340375 (by jch@):
Navdeep Parhar [Tue, 30 Apr 2019 21:24:44 +0000 (21:24 +0000)]
MFC r340375 (by jch@):

cxgbe/netmap: Fix cxgbe netmap when interface is DOWN

A kernel panic can occur if the cxgbe interface is DOWN
when activating netmap. This patch prevents the driver
from freeing up cxgbe netmap resources when they have not
been allocated.

Submitted by: Nicolas Witkowski <nwitkowski@verisign.com>
Reviewed by: np
Sponsored by: Verisign, Inc.
Differential Revision: https://reviews.freebsd.org/D17802

5 years agoMFC r346596:
Konstantin Belousov [Tue, 30 Apr 2019 18:36:56 +0000 (18:36 +0000)]
MFC r346596:
ipoib: assign link-local address according to RFC.

5 years agoMFC r346267, 346269:
Fedor Uporov [Tue, 30 Apr 2019 09:10:45 +0000 (09:10 +0000)]
MFC r346267, 346269:
ext2fs: Initial version of DTrace support.

Reviewed by:    pfg, gnn

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

5 years agoMFC r345056, r345058, r345059
Kashyap D Desai [Tue, 30 Apr 2019 07:10:11 +0000 (07:10 +0000)]
MFC r345056, r345058, r345059

r345056

fw_outstanding"(outstanding IOs at firmware level) counter gets screwed up when R1 fastpath
writes are running. Some of the cases which are not handled properly in driver are:

1. With R1 fastpath supported, single write from CAM layer can consume 2 MPT frames
at driver/firmware level for fastpath qualification(if fw_outstanding < controller Queue Depth).
Due to this driver has to throttle IOs coming from CAM layer as well as second fastpath
write(of R1 write) against Adapter Queue Depth.
If "fw_outstanding" reaches to adapter queue depth, driver should return IOs from CAM layer with
device busy status.While allocating second MPT frame(corresponding to R1 FP write) also, driver
should ensure fw_outstanding should not exceed adapter QD.

2. For R1 fastpath writes completion, driver decrements "fw_oustanding" counter without
really returning MPT frame to free pool. It may cause IOs(with heavy IOs running, consuming whole
adapter Queue Depth) consuming MPT frames reserved for DCMDs(management commands) and
DCMDs(internal and sent by application) not getting MPT frame will start failing.

Below is one test case to hit the issue described above-
1. Run heavy IOs (outstanding IOs should hit adapter Queue Depth).
2. Run management tool (Broadcom's storcli tool) querying adapter in loop (run command- "storcli64 /c0 show" in loop).
3. Management tool's requests would start failing due to non-availability of free MPT frames as all frames would be consumed by IOs.

Fix: Increment/decrement of "fw_outstanding" counter should be in sync with MPT frame get/return.

r345058

Allocated MFI frames should be same as MPT frames reserved for DCMDs

r345059

Update driver version to 07.709.04.00-fbsd

5 years agoMFC r346751:
Ian Lepore [Tue, 30 Apr 2019 00:59:59 +0000 (00:59 +0000)]
MFC r346751:

Add a manpage for elf_aux_info(3)

5 years agoMFC r346713:
Ian Lepore [Tue, 30 Apr 2019 00:58:43 +0000 (00:58 +0000)]
MFC r346713:

Fix typo: the 4th argument to GPIO_PIN_ACCESS_32 is the set of pins to
change, not the variable used to return the original pin state.

PR: 237378
Reported by: Mori Hiroki <yamori813@yahoo.co.jp>

5 years agoMFC r346489:
Ian Lepore [Tue, 30 Apr 2019 00:54:31 +0000 (00:54 +0000)]
MFC r346489:

Move the reporting of spurious interrupts under bootverbose control, because
occasional spurious interrupts are a normal thing on this hardware.  Also,
change the name of the cpu-local interrupt controller driver from local_intc
to lintc, because the name gets built into interrupt names, which have to
fit into a 19-byte field for stats reporting (so this allows 5 more bytes
of the actual interrupt name to be displayed).

5 years agoMFC r345351:
Enji Cooper [Mon, 29 Apr 2019 23:07:19 +0000 (23:07 +0000)]
MFC r345351:
r345351 (by bdrewery):

Build common kernel dependencies before modules.

This ensures files like genassym.o and awk/mfiles are generated before
descending into the modules build.  It may also allow some module builds
to not recreate files that are already present in the KERNBUILDDIR.

This fixes a rare build race where genassym.o is missing and assym.inc
is empty.

More work is planned around this to reduce some redundant dependency
generation in modules.

PR: 233339

5 years agoMFC 345041:
John Baldwin [Mon, 29 Apr 2019 21:39:09 +0000 (21:39 +0000)]
MFC 345041:
Update ccr(4) to note recent support for SHA2-224 and plain SHA hashes.

5 years agoMFC r346571,r346572:
Enji Cooper [Mon, 29 Apr 2019 19:34:09 +0000 (19:34 +0000)]
MFC r346571,r346572:

Update the spelling of my name

Previous spellings of my name (NGie, Ngie) weren't my legal spelling. Use Enji
instead for clarity.

While here, remove "All Rights Reserved" from copyrights I "own".

5 years agoMFC r345723:
Enji Cooper [Mon, 29 Apr 2019 19:32:11 +0000 (19:32 +0000)]
MFC r345723:

PROG_OVERRIDE_VARS should override default values if specified

The behavior prior to this change would not override default values if set in
`bsd.own.mk`, or (in the more general case) globally before `bsd.progs.mk` was
included. This affected `bsd.test.mk` as well, since it consumes
`bsd.progs.mk`.

Some examples of this failing behavior are as follows:

* `BINMODE` defaults to 0555 per `bsd.own.mk`. If someone wanted to set the
  `BINMODE` to `NOBINMODE` (0444) for `prog`, for example, like
  `BINMODE.prog= ${NOBINMODE}`, `bsd.progs.mk` would not honor the per-PROG
  setting.
* An application, `prog`, does not build at `WARNS?= 6`. Before this change,
  setting to a lower `WARNS` value, e.g., `WARNS.prog= 3`, would have been
  impossible, requiring that `prog` be built from another directory,
  the global `WARNS` be lowered, or a per-PROG value needing to be set
  across the board. None of the above workarounds is desirable.

This change unbreaks variables defined in `PROG_OVERRIDE_VARS` which have
defaults set before `bsd.progs.mk` is included, by setting them to their
defined values if set on a per-PROG basis.

5 years agoMFC r346539:
Enji Cooper [Mon, 29 Apr 2019 19:12:47 +0000 (19:12 +0000)]
MFC r346539:

Fix `get_int_via_sysctlbyname(..)` on Jenkins

Initialize `oldlen` to the size of the value, instead of leaving the value
unitialized. Leaving it unitialized seems to work by accident on amd64 when
running 64-bit programs, but not on i386.

This matches patterns in use in other programs.

PR: 237458
Tested on: ^/head (amd64), ^/stable/11 (i386)

5 years agoMFC r344192 (by sef): Add support for a virtual hostname to nfsd
Alexander Motin [Mon, 29 Apr 2019 19:10:24 +0000 (19:10 +0000)]
MFC r344192 (by sef): Add support for a virtual hostname to nfsd

Specifically, this allows (via "-V vhostname") telling nfsd what principal
to use, instead of the hostname.  This is used at iXsystems for fail-over in
HA systems.

Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D19191

5 years agoMFC r346542:
Enji Cooper [Mon, 29 Apr 2019 19:09:44 +0000 (19:09 +0000)]
MFC r346542:

Fix sys.kern.coredump_phnum_test.coredump_phnum on i386

The zero-padding when printing out the Size field is on 32-bit architectures is
5, not 15. Adjust the regular expression to work with both the 32-bit and
64-bit case.

5 years agoMFC r346113:
Mariusz Zaborski [Mon, 29 Apr 2019 18:56:39 +0000 (18:56 +0000)]
MFC r346113:
 libnv: fix compilation warnings

 When building libnv without a debug those arguments are no longer used
 because assertions will be changed to NOP.

 Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>

5 years agoMFC r346112:
Mariusz Zaborski [Mon, 29 Apr 2019 18:54:39 +0000 (18:54 +0000)]
MFC r346112:
  libnv: fix compilation warnings

  When building libnv without a debug those arguments are no longer used
  because assertions will be changed to NOP.

  Submitted by: Mindaugas Rasiukevicius <rmind@netbsd.org>

MFC r346115:
  The nvlist_report_missing is also used by the cnvlist.
  It can't be a static one.

  Reported by:  jenkins

5 years agoMFC ar: implement support for /SYM64/ 64-bit archives
Ed Maste [Mon, 29 Apr 2019 18:34:11 +0000 (18:34 +0000)]
MFC ar: implement support for /SYM64/ 64-bit archives

r346079: ar: implement support for /SYM64/ 64-bit archives

Submitted by: Gerald Aryeetey <aryeeteygerald_rogers.com>
Reviewed by: imp (earlier)

r346568: ar: test for writing 64-bit format only if symbol count is nonzero

This is a minor simplification; if we do not have any symbols the empty
symbol table can be in 32-bit format.

r346569: ar: use array notation to access s_so

This is somewhat more readable than pointer arithmetic.  Also remove an
unnecessary cast while here.

r346582: ar: shuffle symbol offsets during conversion for 32-bit ar archives

During processing we maintain symbol offsets in the 64-bit s_so array,
and when writing the archive convert to 32-bit if no offsets are greater
than 4GB.  However, this was somewhat inefficient as we looped over the
array twice: first, converting to big endian and second, writing each
32-bit value one at a time (and incorrectly so on big-endian platforms).

Instead, when writing a 32-bit archive shuffle convert symbol data to
big endian (as required by the ar format) and shuffle to the beginning
of the allocation at the same time.

Also correct emission of the symbol count on big endian platforms.

Further changes are planned, but this should fix powerpc64.

Reported by: jhibbits, mlinimon
Reviewed by: jhibbits, Gerald Aryeetey (earlier)
Tested by: jhibbits

PR: 234454
Sponsored by: The FreeBSD Foundation

5 years agoMFC r339648: ar: report errno on warning/error
Ed Maste [Mon, 29 Apr 2019 18:25:39 +0000 (18:25 +0000)]
MFC r339648: ar: report errno on warning/error

Previously ar would report an error like "ar: fatal: Write error"
without including additional errno information.  Change warnings and
errors to include archive_errno() so that the user may have some idea
of the reason for the failure.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r346016:
Mitchell Horne [Mon, 29 Apr 2019 16:16:00 +0000 (16:16 +0000)]
MFC r346016:
Add option to build LLVM RISC-V target

Approved by:  markj (mentor)

5 years agoMFC r346544:
Mark Johnston [Mon, 29 Apr 2019 13:20:24 +0000 (13:20 +0000)]
MFC r346544:
Clarify the relationship between INVARIANTS and DIAGNOSTIC a bit.

5 years agoMFC r345473:
Dmitry Chagin [Sun, 28 Apr 2019 14:38:21 +0000 (14:38 +0000)]
MFC r345473:

Whitespace cleanup (annoying).

5 years agoMFC r345471, r345472, r346603:
Dmitry Chagin [Sun, 28 Apr 2019 14:37:20 +0000 (14:37 +0000)]
MFC r345471, r345472, r346603:

Update syscall.master to 5.0.

For 32-bit Linuxulator, ipc() syscall was historically
the entry point for the IPC API. Starting in Linux 4.18, direct
syscalls are provided for the IPC. Enable it.

5 years agoMFC r345469, r345470:
Dmitry Chagin [Sun, 28 Apr 2019 14:34:31 +0000 (14:34 +0000)]
MFC r345469, r345470:

Linux between 4.18 and 5.0 split IPC system calls.
In preparation for doing this in the Linuxulator modify our linux_shmat()
to match actual Linux shmat() system call.

5 years agoMFC r345468:
Dmitry Chagin [Sun, 28 Apr 2019 14:30:25 +0000 (14:30 +0000)]
MFC r345468:

Revert r313993.
AMD64_SET_**BASE expects a pointer to a pointer, we just passing in the pointer value itself.

Set PCB_FULL_IRET for doreti to restore %fs, %gs and its correspondig base.

PR: 225105

5 years agoMFC r346688-r346689: tap(4) MODULE_VERSION
Kyle Evans [Sun, 28 Apr 2019 03:51:08 +0000 (03:51 +0000)]
MFC r346688-r346689: tap(4) MODULE_VERSION

r346688:
tap(4): Add a MODULE_VERSION

Otherwise tap(4) can be loaded by loader despite being compiled into the
kernel, causing a panic as things try to double-initialize.

r346689:
tap(4): Correct driver name...

PR: 220867

5 years agoMFC r346545-r346546, r346680, r346700, r346705
Kyle Evans [Sun, 28 Apr 2019 03:49:40 +0000 (03:49 +0000)]
MFC r346545-r346546, r346680, r346700, r346705

r346545:
libbe(3): allow creation of arbitrary depth boot environments

libbe currently only provides an API to create a recursive boot environment,
without any formal support for intentionally limiting the depth. This
changeset adds an API, be_create_depth, that may be used to arbitrarily
restrict the depth of the new BE.

r346546:
libbe(3): Add a test for be creation

r346680:
libbe(3): Copy received properties as well

This was inherently broken on send|recv datasets.

r346700:
libbe(3): Fix mis-application of patch (SHLIBDIR)

Rob's patch in D18564 cemented the SHLIBDIR because bsd.own.mk (included by
src.opts.mk) sets it to /usr/lib. r346546 did somehow not apply this part of
the patch, leaving it to get installed to the wrong place and subsequently
removed via ObsoleteFiles.

r346705:
libbe(3): Fix libcompat build

SHLIBDIR should still be optionally set, just before src.opts.mk is included
so that libcompat can properly override it. This fixes lib32 failures
reported by both Jenkins and Michael Butler.

5 years agoMFC r345407,r345408: Add nvme to arm64 GENERIC, and build if_ena on arm64.
Colin Percival [Sat, 27 Apr 2019 19:48:15 +0000 (19:48 +0000)]
MFC r345407,r345408: Add nvme to arm64 GENERIC, and build if_ena on arm64.

These allow stable/12 to boot on Amazon EC2 "A1" family (arm64) instances.

Sponsored by: https://www.patreon.com/cperciva

5 years agoOn non-x86 systems, use "quarterly" packages.
Colin Percival [Sat, 27 Apr 2019 19:45:33 +0000 (19:45 +0000)]
On non-x86 systems, use "quarterly" packages.

x86 architectures have "latest" package builds on stable/*, so keep using
those (they'll get switched over to "quarterly" during releases).

Direct commit to stable/12 because using "latest" packages is appropriate
for all architectures on HEAD.

Discussed with: gjb

5 years agoMFC r346440:
Mark Johnston [Sat, 27 Apr 2019 05:35:20 +0000 (05:35 +0000)]
MFC r346440:
Export cpu_core from opensolaris.ko.

PR: 191462

5 years agoBump __FreeBSD_version for ether_gen_addr availability
Kyle Evans [Sat, 27 Apr 2019 04:51:57 +0000 (04:51 +0000)]
Bump __FreeBSD_version for ether_gen_addr availability

This is a direct commit to stable branches as the bump wasn't present in
head.

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.