]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r355703:
Toomas Soome [Fri, 20 Dec 2019 08:12:44 +0000 (08:12 +0000)]
MFC r355703:
loader: clean up devopen and devclose a bit

devopen should undo setup of f->f_dev in case of error.
devclose can just call free().

4 years agoMFC r355713:
Toomas Soome [Fri, 20 Dec 2019 07:40:28 +0000 (07:40 +0000)]
MFC r355713:
loader: cd9660_open() warn: is 'buf' large enough for 'struct iso_primary_descriptor'?

We do allocate amount of memory (void * or char *), and then assign this
buffer to struct iso_primary_descriptor *vd. Make sure we do
allocate enough bytes.

In fact we do allocate enough, but it is good idea to make sure this really
is so.

4 years agoMFC r355676:
Konstantin Belousov [Fri, 20 Dec 2019 01:00:18 +0000 (01:00 +0000)]
MFC r355676:
rtld: make checks for mmap(2) failures compliant with documentation.

4 years agoMFC r355457: Make devstat_end_transaction_bio() count BIO_ORDERED.
Alexander Motin [Fri, 20 Dec 2019 00:25:56 +0000 (00:25 +0000)]
MFC r355457: Make devstat_end_transaction_bio() count BIO_ORDERED.

4 years agoAdd Makefile.depend.options
Simon J. Gerraty [Thu, 19 Dec 2019 04:58:11 +0000 (04:58 +0000)]
Add Makefile.depend.options

Leaf directories that have dependencies impacted
by options need a Makefile.depend.options file
to avoid churn in Makefile.depend

DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc
can be set in local.dirdeps-options.mk
which can add to those set in Makefile.depend.options

See share/mk/dirdeps-options.mk

Also update affected Makefile.depend files.

MFC of r355616 and r355617

Reviewed by:  bdrewery
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22469

4 years agoUpdate dirdeps.mk and gendirdeps.mk
Simon J. Gerraty [Thu, 19 Dec 2019 04:49:34 +0000 (04:49 +0000)]
Update dirdeps.mk and gendirdeps.mk

The env space consumed by exporting all libc's .meta files
left little room for command line,
so unexport when done.

Update dirdeps.mk to latest and add
dirdeps-targets.mk to simplify/update targets/Makefile

Makefile changes to go with Makefile.depend changes in D22494

MFC of r355618

Reviewed by:  bdrewery
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22495

4 years agoMFC r339955, r355590: sed test fix + \r, \n, \t
Kyle Evans [Thu, 19 Dec 2019 02:29:15 +0000 (02:29 +0000)]
MFC r339955, r355590: sed test fix + \r, \n, \t

r339955:
usr.bin/sed/tests: fix one of the regression test cases by adding its
results file to the build.

r355590:
sed: process \r, \n, and \t

This is both reasonable and a common GNUism that a lot of ported software
expects.

Universally process \r, \n, and \t into carriage return, newline, and tab
respectively. Newline still doesn't function in contexts where it can't
(e.g. BRE), but we process it anyways rather than passing
UB \n (escaped ordinary) through to the underlying regex engine.

Adding a --posix flag to disable these was considered, but sed.1 already
declares this version of sed a super-set of POSIX specification and this
behavior is the most likely expected when one attempts to use one of these
escape sequences in pattern space.

This differs from pre-r197362 behavior in that we now honor the three
arguably most common escape sequences used with sed(1) and we do so outside
of character classes, too.

Other escape sequences, like \s and \S, will come later when GNU extensions
are added to libregex; sed will likely link against libregex by default,
since the GNU extensions tend to be fairly un-intrusive.

4 years agoMFC r355761: <unistd.h>: remove redundant __BSD_VISIBLE
Kyle Evans [Thu, 19 Dec 2019 02:19:04 +0000 (02:19 +0000)]
MFC r355761: <unistd.h>: remove redundant __BSD_VISIBLE

This bit is already inside of a larger __BSD_VISIBLE block.

4 years agoMFC r355643: __FreeBSD__version bumps for sigsetops
Kyle Evans [Thu, 19 Dec 2019 02:14:49 +0000 (02:14 +0000)]
MFC r355643: __FreeBSD__version bumps for sigsetops

4 years agoAdd sigsetop extensions commonly found in musl libc and glibc
Kyle Evans [Thu, 19 Dec 2019 02:09:16 +0000 (02:09 +0000)]
Add sigsetop extensions commonly found in musl libc and glibc

These functions (sigandset, sigisemptyset, sigorset) are commonly available
in at least musl libc and glibc; sigorset, at least, has proven quite useful
in qemu-bsd-user work for tracking the current process signal mask in a more
self-documenting/aesthetically pleasing manner.

4 years agostand: liblua: drop default buffer size to 128
Kyle Evans [Thu, 19 Dec 2019 02:05:48 +0000 (02:05 +0000)]
stand: liblua: drop default buffer size to 128

Lua allocates LUAL_BUFFERSIZE buffers on the stack for various string
functions (string.format, string.gsub) -- this works out to be somewhat
significant and not necessary, based on how we use string operations.
Dropping it risks having to allocate per call to format/gsub, but this is
not the case for our usage. This simply stops allocating 8K buffers on the
stack when luaL_Buffer is used.

4 years agousr.sbin/ntp: don't emit versions w/ make -s
Kyle Evans [Thu, 19 Dec 2019 02:04:40 +0000 (02:04 +0000)]
usr.sbin/ntp: don't emit versions w/ make -s

<sys.mk> defines ECHO=echo when not using make -s, and ECHO=true when using
make -s.

export ECHO for ntp products and use it in the mkver script to echo the
version. This suppresses the output as appropriate. ECHO is given a default
value to make sure things still work as expected for anyone that isn't
redefining ECHO.

4 years agoMFC r355451: Remove some branching from GEOM_DISK hot path.
Alexander Motin [Thu, 19 Dec 2019 01:34:34 +0000 (01:34 +0000)]
MFC r355451: Remove some branching from GEOM_DISK hot path.

pp->private just can not be NULL in those places.

In g_disk_start() and g_disk_ioctl() both dp != NULL and !dp->d_destroyed
should always be true if disk_gone() and disk_destroy() are used properly,
since GEOM does not send requests to errored providers.  If the protocol is
not followed, then no amount of additional checks here give real safety.

In g_disk_access() though the checks are useful, since GEOM blocks only
new opens for errored providers, but allows closes.  It should not happen
if disk_gone() and disk_destroy() are used properly, but may otherwise.

To improve cases when disk_gone() is not used, call it from disk_destroy().
It does not give full guaranties, but it errors the provider and makes
GEOM block unwanted requests at least after some race.

4 years agoMFC r355438: Block ioctls for dying GEOM_DEV instances.
Alexander Motin [Thu, 19 Dec 2019 01:32:15 +0000 (01:32 +0000)]
MFC r355438: Block ioctls for dying GEOM_DEV instances.

For normal I/Os consumer and provider statuses are checked by g_io_check().
But ioctl calls often do not go through it, being dispatched directly. This
change makes their semantics more alike, protecting lower levels.

4 years agoMFC r355437: Make GEOM_DEV code slightly more compact.
Alexander Motin [Thu, 19 Dec 2019 01:30:29 +0000 (01:30 +0000)]
MFC r355437: Make GEOM_DEV code slightly more compact.

Should be no functional change.

4 years agoMFC r355412, r355420: Wrap g_trace() into a macro to avoid unneeded calls.
Alexander Motin [Thu, 19 Dec 2019 01:28:05 +0000 (01:28 +0000)]
MFC r355412, r355420: Wrap g_trace() into a macro to avoid unneeded calls.

In most cases with debug disabled this function does nothing, but argument
passing and the call still cost measurable time due to cache misses, etc.

While there, define G_F_FOOTSHOOTING instead of numeric constants.

4 years agoMFC r355410: Switch GEOM_DEV from make_dev_p() to make_dev_s().
Alexander Motin [Thu, 19 Dec 2019 01:25:44 +0000 (01:25 +0000)]
MFC r355410: Switch GEOM_DEV from make_dev_p() to make_dev_s().

It closes the race condition and so allows to remove few NULL checks.

Also while there, use dev->si_drv1 in addition to cp->private to store
softc pointer.  For calls coming from the dev side it gives reliable cache
hit instead of often miss before.

4 years agoMFC r350532-350536,350559,350584-350585,350746-350747:
Bjoern A. Zeeb [Wed, 18 Dec 2019 11:48:50 +0000 (11:48 +0000)]
MFC r350532-350536,350559,350584-350585,350746-350747:

Merge the first part of frag6.c changes from HEAD.  Apart from moving the
sysctls into the local file these are mostly non-functional changes.

  frag6.c: sort includes
  frag6.c: move variables and sysctls into local file
  frag6.c: remove dead code
  frag6.c: rename malloc type
  frag6.c: make compile with gcc
  frag6.c: fix includes
  frag6.c: re-order functions within file
  frag6.c: rename ip6q[] to ipq6b[] and consistently use "bucket"
  frag6.c: initial comment and whitespace cleanup.
  frag6.c: cleanup varaibles and return statements.

  Sponsored by: Netflix

4 years agoMFC r355317:
Xin LI [Wed, 18 Dec 2019 08:08:51 +0000 (08:08 +0000)]
MFC r355317:

newfs_msdos: -A is incompatible with -r, not -o.

PR: 242314
Submitted by: Guy Yur <guyyur gmail com>

4 years agoMFC r350531:
Bjoern A. Zeeb [Wed, 18 Dec 2019 00:12:30 +0000 (00:12 +0000)]
MFC r350531:
  IPv6 cleanup: kernel

  Finish what was started a few years ago and harmonize IPv6 and IPv4
  kernel names.  We are down to very few places now that it is feasible
  to do the change for everything remaining with causing too much disturbance.

  Remove "aliases" for IPv6 names which confusingly could indicate
  that we are talking about a different data structure or field or
  have two fields, one for each address family.
  Try to follow common conventions used in FreeBSD.

  * Rename sin6p to sin6 as that is how it is spelt in most places.
  * Remove "aliases" (#defines) for:
    - in6pcb which really is an inpcb and nothing separate
    - sotoin6pcb which is sotoinpcb (as per above)
    - in6p_sp which is inp_sp
    - in6p_flowinfo which is inp_flow
  * Try to use ia6 for in6_addr rather than in6p.
  * With all these gone  also rename the in6p variables to inp as
    that is what we call it in most of the network stack including
    parts of netinet6.

  The reasons behind this cleanup are that we try to further
  unify netinet and netinet6 code where possible and that people
  will less ignore one or the other protocol family when doing
  code changes as they may not have spotted places due to different
  names for the same thing.

  No functional changes inteded.

  Sponsored by: Netflix

  Do not MFC the in_pcb.h changes for the stable branch.
  This MFC is mostly only done in order to be able to MFC other changes
  with less conflicts.

4 years agoMFC r350522:
Bjoern A. Zeeb [Tue, 17 Dec 2019 23:45:34 +0000 (23:45 +0000)]
MFC r350522:

  IPv6 cleanup: netstat

  Rename the variable for the in6_addr from in6p to ia6 to follow the
  convention generally used in FreeBSD.

  No functional changes.

  Sponsored by: Netflix

4 years agoMFC r355299:
Kenneth D. Merry [Tue, 17 Dec 2019 20:29:47 +0000 (20:29 +0000)]
MFC r355299:

  ------------------------------------------------------------------------
  r355299 | ken | 2019-12-02 14:57:39 -0500 (Mon, 02 Dec 2019) | 52 lines

  Fix a hang introduced in r351599.

  My changes in 351599 (kindly committed by avg) made the cd(4) media check
  asynchronous to avoid a sleep while holding a mutex.

  There was a difficult to reproduce bug with those changes that caused a
  hang on boot on some single processor machines/VMs.  Leandro Lupori
  managed to reproduce the bug, diagnose it, and supplied a patch!  Here is
  his analysis, from the PR:

  ======
  I was able to reproduce the problem described in comment#14.

  Actually, I wasn't trying to reproduce it, I just started seeing it a few
  weeks ago, in CURRENT.

  I can reproduce it consistently, by using QEMU to run a PowerPC64 VM with a
  single core/thread (-smp 1).

  It happens only when there is no media in the emulated CD-ROM, a device
  that QEMU adds by default, unless -nodefaults is specified in command line.

  I've debugged it and this is what I've found:

  1- After the CD probe is successful, GEOM will try to open the device,
  which will end up calling cdcheckmedia(), that sets CD state to
  CD_STATE_MEDIA_PREVENT.
  2- Next, scsi_prevent() is executed and succeeds, the CD_FLAG_DISC_LOCKED
  flag is set and CD state moves to CD_STATE_MEDIA_SIZE.
  3- Next, scsi_read_capacity() is executed and fails, state is set to
  CD_STATE_MEDIA_ALLOW, cdmediaprobedone() is called and wakes up
  cdcheckmedia().
  4- Then, when cdstart() is invoked to process CD_STATE_MEDIA_ALLOW, it
  first checks if CD_FLAG_DISC_LOCKED is set, and if so skips directly to
  CD_STATE_MEDIA_SIZE state. This will repeat the steps of bullet 3, entering
  an infinite MEDIA_SIZE command loop.

  When there is a least another core/thread, the GEOM thread that performed
  the initial cdopen() will get scheduled again, closing the CD device, that
  will call cdprevent(PR_ALLOW) that clears the CD_FLAG_DISC_LOCKED flag and
  breaks the loop.

  So, apparently, the problem is CD_STATE_MEDIA_ALLOW being skipped when
  CD_FLAG_DISC_LOCKED is set. If I understand correctly, in this case, the
  state should be advanced to CD_STATE_MEDIA size only when the current state
  is CD_STATE_MEDIA_PREVENT.
  =====
  ------------------------------------------------------------------------

PR: kern/219857
Submitted by: Leandro Lupori <leandro.lupori@gmail.com>

4 years agoMFC r355575: Add missing language specifier for Hebrew il.kbd description
Ed Maste [Tue, 17 Dec 2019 15:02:29 +0000 (15:02 +0000)]
MFC r355575: Add missing language specifier for Hebrew il.kbd description

PR: 235094 (related)
Sponsored by: The FreeBSD Foundation

4 years agoMFC r355581:
Andrey V. Elsukov [Tue, 17 Dec 2019 10:00:19 +0000 (10:00 +0000)]
MFC r355581:
  Avoid access to stale ip pointer and call UPDATE_POINTERS() after
  PULLUP_LEN_LOCKED().

  PULLUP_LEN_LOCKED() could update mbuf and thus we need to update related
  pointers that can be used in next opcodes.

  Reported by: Maxime Villard <max at m00nbsd net>

NOTE: this commit also adds UPDATE_POINTERS() stub macro, that originally
is part of r345166 commit that was not merged.

4 years agoMFC r350413:
Andrey V. Elsukov [Tue, 17 Dec 2019 09:46:00 +0000 (09:46 +0000)]
MFC r350413:
  Avoid possible lock leaking.

  After r343619 ipfw uses own locking for packets flow. PULLUP_LEN() macro
  is used in ipfw_chk() to make m_pullup(). When m_pullup() fails, it just
  returns via `goto pullup_failed`. There are two places where PULLUP_LEN()
  is called with IPFW_PF_RLOCK() held.

  Add PULLUP_LEN_LOCKED() macro to use in these places to be able release
  the lock, when m_pullup() fails.

  Sponsored by: Yandex LLC

  NOTE: since r343619 was not merged, this commit is mostly NOP, but
  it is needed to reduce code difference between stable and head/.

4 years agoMFC r355648-r355649
Emmanuel Vadot [Mon, 16 Dec 2019 18:05:28 +0000 (18:05 +0000)]
MFC r355648-r355649

r355648:
arm64: rockchip: rk_pinctrl: Add bias parsing based on the SoC type

Not all rockchip have the same value for pullup/pulldown so add a function
per SoC and call the right one to have the proper value.

r355649:
arm64: rockchip: rk_pinctrl: Fix parse_bias for RK3399

Only bank 0 and bank 2 are different than other rockchip SoC, fix this.
While here remove some debug printfs that where added in r355648

X-MFC-With: r355648

4 years agoMFC r354407:
Emmanuel Vadot [Mon, 16 Dec 2019 18:02:48 +0000 (18:02 +0000)]
MFC r354407:

arm64: allwinner: a64: Do not init the video related clocks

This should be handled by the video drivers and this break EFIFB
as this changes clock setup by the bootloader.

4 years agoMFC r354115:
Emmanuel Vadot [Mon, 16 Dec 2019 18:00:05 +0000 (18:00 +0000)]
MFC r354115:

dtc: Allow multiple dts-v1 tag

Some dts are including dtsi that also contain a /dts-v1/ tag at the
top. GNU DTC doesn't seems to have a problem with that so fix our
dtc to behave the same.

Reviewed by: kevans

4 years agoMFC r354086:
Emmanuel Vadot [Mon, 16 Dec 2019 17:59:02 +0000 (17:59 +0000)]
MFC r354086:

flash: Add GigaDevice gd25q128 flash

Add this flash chip which is a 128Mb spi flash.

4 years agoMFC r355570:
Mark Johnston [Mon, 16 Dec 2019 15:41:32 +0000 (15:41 +0000)]
MFC r355570:
Configure headphone redirection for the Dell L780 and X1 Carbon 7th gen.

4 years agoMFC r353682 (by emaste):
Mark Johnston [Mon, 16 Dec 2019 15:41:13 +0000 (15:41 +0000)]
MFC r353682 (by emaste):
snd_hda: style(9) whitespace fixup

PR: 241299

4 years agoMFC r355670:
Cy Schubert [Mon, 16 Dec 2019 02:38:47 +0000 (02:38 +0000)]
MFC r355670:

Rather than pass the address of the packet information control block to
ipf_pcksum6(), directly pass the adddress of the mbuf to it. This reduces
one pointer dereference. ipf_pcksum6() doesn't use the packet information
control block except to obtain the mbuf address.

4 years agoMFC r355669:
Cy Schubert [Sun, 15 Dec 2019 21:28:08 +0000 (21:28 +0000)]
MFC r355669:

in6_cksum() returns zero when checksums are good.

4 years agoMFC r355222, r355260:
Xin LI [Sun, 15 Dec 2019 08:23:38 +0000 (08:23 +0000)]
MFC r355222, r355260:

r355222: Use strlcat().
r355260: Simplify code with strlcpy/strlcat.

4 years agoMFC r355638: ObsoleteFiles.inc: chase libpcap update in r334277
Ed Maste [Sun, 15 Dec 2019 04:18:19 +0000 (04:18 +0000)]
MFC r355638: ObsoleteFiles.inc: chase libpcap update in r334277

libpcap 1.9.0 (pre-release) update removed the export-defs.h header.

PR: 242559
Submitted by: John Hein

4 years agoMFC r355506:
Mark Johnston [Sat, 14 Dec 2019 18:32:00 +0000 (18:32 +0000)]
MFC r355506:
gcore: Avoid using vm_map_entry_t.

4 years agoMFC r345744, r348122, r355247
Xin LI [Sat, 14 Dec 2019 09:49:36 +0000 (09:49 +0000)]
MFC r345744, r348122, r355247

r345744: random(4): Attempt to persist entropy promptly
r348122: save-entropy(8), rc.d/random: Set nodump flag
r355247: Reduce disk write load in /usr/libexec/save-entropy.

4 years agoMFC 354924:
Pedro F. Giffuni [Sat, 14 Dec 2019 03:14:46 +0000 (03:14 +0000)]
MFC 354924:
MFV 354917, 354918, 354919
openresolv: update to version 3.9.2

4 years agoMFC r355343:
Ryan Libby [Fri, 13 Dec 2019 09:19:24 +0000 (09:19 +0000)]
MFC r355343:

  mips busdma: bzero map on alloc

4 years agoMerge r355134,355375,355589
Scott Long [Fri, 13 Dec 2019 05:29:26 +0000 (05:29 +0000)]
Merge r355134,355375,355589

Clean up and clarify meta commentary on TAA.  Add a state to denote
that TSX doesn't exist on the CPU.

x86: Add missed break to TAA status sysctl

Fix the TAA state machine to do the right thing when the TAA
migitation is available in microcode and the operator has set
the sysctl to automatic mode.

Sponsored by: Intel

4 years agoMFC r352350: rangelock: add rangelock_cookie_assert
Kyle Evans [Fri, 13 Dec 2019 04:03:03 +0000 (04:03 +0000)]
MFC r352350: rangelock: add rangelock_cookie_assert

A future change to posixshm to add file sealing will move locking out of
shm_dotruncate as kern_shm_open() will require the lock to be held across
the dotruncate until the seal is actually applied. For this, the cookie is
passed into shm_dotruncate_locked which asserts RCA_WLOCKED.

4 years agoMFC r343777, r352244-r352245: kenv fix + assertions
Kyle Evans [Fri, 13 Dec 2019 03:29:54 +0000 (03:29 +0000)]
MFC r343777, r352244-r352245: kenv fix + assertions

r343777:
Fix zapping of static hints and env in init_static_kenv().  Environments
are terminated by 2 NULs, but only 1 NUL was zapped.  Zapping only 1
NUL just splits the first string into an empty string and a corrupted
string.  All other strings in static hints and env remained live early
in the boot when they were supposed to be disabled.

Support calling init_static_kenv() very early in the boot, so as to
use the env very early in the boot.  Then the pointer to the loader
env may change after the first call due to enabling paging or otherwise
remapping the pointer.  Another call is needed to register the change.
Don't use the previous pointer in this (or any) later call.

r352244:
kenv: assert that an empty static buffer passed in is "empty"

Garbage in the passed-in buffer can cause problems if any attempts to read
the kenv are inadvertently made between init_static_kenv and the first
kern_setenv -- assuming there is one.

This is cheap and easy, so do it. This also helps rule out some class of
bugs as one tries to debug; tunables fetch from the static environment up
until SI_SUB_KMEM + 1, and many of these buffers are global ~4k buffers that
rely on BSS clearing while others just grab a page of free memory and use it
(e.g. xen).

r352245:
Follow up r352244: kenv: tighten up assertions

As I like to forget: static kenv var formatting is actually such that an
empty environment would be double null bytes. We should make sure that a
non-zero buffer has at least enough for this, though most of the current
usage is with a 4k buffer.

4 years agoMFC: r354989
Rick Macklem [Thu, 12 Dec 2019 22:00:10 +0000 (22:00 +0000)]
MFC: r354989
Fix the pNFS server's reporting of SpaceUsed (va_bytes).

The pNFS server currently reports SpaceUsed (va_bytes) for the metadata
file. This in not correct, since the metadata file is always empty and,
as such, va_bytes is just the allocation for the empty file.
This patch adds va_bytes to the list of attributes acquired from the
DS for a file, so that it includes the allocated data size and is updated
when the file is written.
For files created on a pNFS server before this patch is applied, the
va_bytes value is estimated by rounding va_size up to a multiple of
BLKDEV_IOSIZE. Once the file is written after this patch has been
applied to the metadata server, the va_bytes returned for the file
will be correct.

This patch only affects a pNFS metadata server.

Found during testing of the NFSv4.2 pNFS server for the Allocate operation.
(Not yet in head/current.)

4 years agoMFC Collection of Raspberry Pi fixes: r348803-r348804, r354488, r354524,
Kyle Evans [Thu, 12 Dec 2019 19:21:16 +0000 (19:21 +0000)]
MFC Collection of Raspberry Pi fixes: r348803-r348804, r354488, r354524,
r354560-r354561, r354563, r354577, r354579, r354823, r354825,
r354844-r354846, r354868, r354875-r354876, r354930-r354933, r354956,
r355016, r355025-r355026, r355031, r355563

r348803 by bz:
bcm2835_sdhci.c: save block registers to avoid controller bug

Extending what the initial revision, r273264, r276985, r277346 have
started for the transfer mode and command registers, another pair of
16bit registers written in sequence are block size and block count,
which fall together onto the same 32bit line and hence the same
register(s) would be written twice in sequence for those as well.

Use a similar approach to transfer mode and command and save the writes
to either of the block regiters and then only execute a write once.
We can do this as with transfer mode their values are meaningless until
a command is issued so we can use that write to command as a trigger
to also write out the block registers.
Compared to transfer mode and command the value of block count can
change, so we need to keep state and actually read the block registers
back the first time after a write.

r348804 by bz:
bcm2835_sdhci.c: exit DMA if not enough data left to avoid timeout errors

In the DMA case, given we disable the data interrupts, we never seem
to get DATA_END.  Given we are relying on DMA interrupts we are not
using the SDHCI state machine and hence only call into
sdhci_platform_will_handle() for the first check of data.
We do not call "will handle" for any following round trips of the same
transaction if block size * count > BCM_DMA_BLOCK_SIZE.
Manually check "left" in the DMA interrupt handler to see if we have at
least another full BCM_DMA_BLOCK_SIZE to handle.
Without this change we would DMA that and then even start a DMA with
left == 0 which would lead to a timeout and error.
Now we re-enable data interrupts and return and let the SDHCI generic
interrupt handler and state machine pick the SPACE_AVAIL up and then
find that it should punt to the pio_handler for the remaining bytes
or finish the data transaction.

With this change block mode seems to work beyond 7 * 64byte blocks,
which worked as it was below BCM_DMA_BLOCK_SIZE.

r354488:
bcm_lintc: don't attach if "interrupt-controller" is missing

This is a standard required property for interrupt controllers, and present
on the bcm_lintc nodes for currently supported RPi models. For the RPi4, we
have both bcm_lintc as well as GIC-400, but only one may be active at a
time.

Don't probe bcm_lintc if it's missing the "interrupt-controller" property --
in RPi 4 DTS, the bcm_lintc node is actually missing this along with other
required interrupt properties. Presumably, if the earlier boot stages will
support switching to the legacy interrupt controller (as is suggested
possible by the documentation), the DTS will need to be updated to indicate
the proper interrupt-parent and hopefully also mark this node as an
interrupt-controller instead.

r354524:
bcm2835_dma: Mark IRQs shareable

On the RPi4, some of these IRQs are shared. Start moving toward a mode where
we accept that shared IRQs happen and simply ignore interrupts that are
seemingly for no reason.

I would like to be more verbose here, but my 30-minute assessment of the
current world order is that mapping a resource/rid to an actual IRQ number
(as found in FDT) data is not a simple matter. Determining if more than one
handler is attached to an IRQ is closer to feasible, but it's unclear which
way is the cleaner path. Beyond that, we're only really using it to be
slightly more verbose when something's going wrong, so for now just suppress
and drop a complaint-comment.

This was originally submitted (via freebsd-arm@) by Robert Crowston; the
additional verbosity was dropped by kevans@.

r354560:
bcm2835_sdhci: add some very basic support for rpi4

DMA is currently disabled while I work out why it's broken, but this is
enough for upstream U-Boot + rpi-firmware + our rpi3-psci-monitor to boot
with the right config.

The RPi 4 is still not in a good "supported" state, as we have no
USB/PCI-E/Ethernet drivers, but if air-gapped pies only able to operate over
cereal is your thing, here's your guy.

r354561:
bcm2835_sdhci: remove unused power_id field

This was once set, but I removed it by the time I committed it because both
configurations use the same POWER_ID. This can be separated back out if the
situation changes.

r354563:
bcm2835: commit missing constant from r354560

Surgically pulling the patch from my debugging work lead to this slopiness-
my apologies.

r354577:
arm64: add SOC_BRCM_BCM2838, build it in GENERIC

BCM2838/BCM2711 is the Raspberry Pi 4, which we will soon be able to boot
on once some ports bits are worked out.

r354579:
bcm2835_sdhci: don't panic in DMA interrupt if curcmd went away

This is an exceptional case; generally found during controller errors.
A panic when we attempt to acess slot->curcmd->data is less ideal than
warning, and other verbiage will be emitted to indicate the exact error.

r354823:
bcm2835_sdhci: push DATA_END handling out of DMA interrupt path

This simplifies the DMA interrupt handler quite a bit. The sdhci framework
will call platform_finish_transfer() if it's received SDHCI_INT_DATA_END, so
we can take care of any final cleanup there and simply not worry about the
possibility of it ending in the DMA interrupt path.

r354825:
bcm2835_sdhci: use a macro for interrupts we handle

This is just further simplification, very little functional change. In the
DMA interrupt handler, we *do* now acknowledge both DATA_AVAIL | SPACE_AVAIL
every time -- these operations are mutually exclusive, so while this is a
functional change, it's effectively a nop. Removing the 'mask' local allows
us to further simplify in a future change.

r354844:
bcm2835_sdhci: drop an assert in start_dma_seg

Trivial change to clarify locking expectations... no functional change.

r354845:
bcm2835_sdhci: some style cleanup, no functional change

r354846:
bcm2835_sdhci: formalize DMA tag/segment scaling requirements

This allows easy and care-free scaling of NUM_DMA_SEGS with proper-ish
calculations to make sure we can actually handle the number of segments we'd
like to handle on average so that performance comparisons can be easily made
at different values if/once we can actually handle it. It also makes it
helps the untrained reader understand more quickly the reasoning behind the
choice of maxsize/maxsegs/maxsegsize.

r354868:
bcm2835_sdhci: various refactoring of DMA path

This round of refactoring is mostly about streamlining the interrupt handler
to make it easier to verify and reason about operations taking place while
trying to bring FreeBSD up on the RPi4.

r354875:
bcm2835: push address mapping conversion for DMA/mailbox to runtime

We could maintain the static conversions for the !AArch64 Raspberry Pis, but
I'm not sure it's worth it -- we'll traverse the platform list exactly once
(of which there are only two for armv7), then every conversion there-after
traverses the memory map listing of which there are at-most two entries for
these boards: sdram and peripheral space.

Detecting this at runtime is necessary for the AArch64 SOC, though, because
of the distinct IO windows being otherwise not discernible just from support
compiled into the kernel. We currently select the correct window based on
/compatible in the FDT.

We also use a similar mechanism to describe the DMA restrictions- the RPi 4
can have up to 4GB of RAM while the DMA controller and mailbox mechanism can
technically, kind of, only access the lowest 1GB. See the comment in
bcm2835_vcbus.h for a fun description/clarification of this.

r354876:
bcm2835_vcbus: add compatibility name for ^/sys/contrib/vchiq

It's unclear how this didn't get caught in my last iteration, but the fix is
easy- the interface is still compatible, it was just gratuituously renamed
to match my arbitrary definition of consistency... VCBUS, the BCM2835 name,
represents an address on the VideoCore CPU Bus.

In a similar fashion, while it is a physical address, the ARMC portion
represents that these are addresses as seen by the ARM CPU.

To make things even more fun, the BCM2711 peripheral documentation describes
not virtual address space vs. physical address space, but instead the 32-bit
address map vs. the address map in "Low Peripheral" mode. The latter of
these is what the *ARMC* macros translate to/from.

r354930:
bcm2835_sdhci: clean up DMA segments in error handling path

Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.

r354931:
Revert r354930: wrong diff, right message.

r354932:
bcm2835_sdhci: roll back r354823

r354823 kicked DATA_END handling out of the DMA interrupt path "to make
things easy", but this was likely a mistake -- if we know we're done after
we've finished pending DMA operations, we should go ahead and acknowledge
it rather than waiting for the controller to finalize it. If it's not ready,
we'll simply re-enable interrupts and wait for it anyways, to be re-entered
in sdhci_data_intr.

r354933:
bcm2835_sdhci: clean up DMA segments in error handling path

Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.

r354956:
bcm2835_sdhci: only inspect interrupts we handle

We'll write the value we read back to ack pending interrupts, but we should
at least make it clear to ourselves that we only want to ack pending
transfer interrupts.

r355016:
bcm2835_vcbus: add the *other* rpi4 compat string

The DTS I used initially had brcm,bcm2838; the new one uses brcm,bcm2711.
Add that one as well.

r355025:
bcm2835_sdhci: "fix" DMA on the RPi 4

According to the documentation I have, DREQ pacing should be required here.
The DREQ# hasn't changed since the BCM2835. As soon as we attempt to setup
DREQ, DMA stalls and there's no clear reason why as of yet. Setting this
back to NONE seems to work just as well, though it's yet to be determined if
this is a sustainable model in high-throughput scenarios.

r355026:
bcm2835_dma: rip out the "use_dma" flag, make it non-optional

Now that it works for the Raspberry Pi 4, we can discontinue our workarounds
that were put in place to at least get a bootable kernel for other testing.

r355031:
bcm2835_sdhci: fix non-INVARIANTS build

sc is now only used to make sure we're not re-entering the data handling
path erroneously.

r355563:
RPI: Fix DMA/SDHCI on the BCM2836 (Raspberry Pi 2)

r354875 pushed VCBUS <-> ARMC translations to runtime determination, but
incorrectly mapped addresses for the BCM2836 -- SOC_BCM2835 and SOC_BCM2836
are actually mutually exclusive, so the BCM2836 config (GENERIC) would have
taken the latter path in the header and used 0x3f000000 as peripheral start.

Easily fixed -- split out the BCM2836 into its own memmap config and use
that instead if SOC_BCM2836 is included. With this, we get back to userland
again.

4 years agoMFC: r355554
Baptiste Daroussin [Thu, 12 Dec 2019 19:17:26 +0000 (19:17 +0000)]
MFC: r355554

Fix: netstat -rs

Routing statistics requires somes symbols that are only loaded when not running
live. Load them only in that specific case

PR: 242423
Submitted by: olivier

4 years agoMFC r355460: libbe: fix build against sysutils/openzfs, part 1
Kyle Evans [Thu, 12 Dec 2019 18:53:45 +0000 (18:53 +0000)]
MFC r355460: libbe: fix build against sysutils/openzfs, part 1

This is the half of the changes required that work as-is with both in-tree
ZFS and the new hotness, sysutils/openzfs.  Highlights are less dependency
on header pollution (from somewhere) and using 'mnttab' instead of
'extmnttab'.   In the in-tree ZFS, the latter is a #define for the former,
but in the port extmnttab is actually a distinct struct that's a super-set
of mnttab.  We really want mnttab here anyways, so just use it.

4 years agoMFC r354247, r355349: lualoader try_include improvement
Kyle Evans [Thu, 12 Dec 2019 18:51:32 +0000 (18:51 +0000)]
MFC r354247, r355349: lualoader try_include improvement

r354247: lualoader: rewrite try_include using lfs + dofile

Actual modules get require()'d in, rather than try_include(). All instances
of try_include should be provided with proper hooks/API in the rest of
loader to do the work they need to do, since we can't rely on them to exist.
Convert this now to lfs + dofile since we won't really be treating them as
modules.

lfs is required because dofile will properly throw an error if the file
doesn't exist, which is not in the spirit of 'optionally included'.

Getting out of the pcall game allows us to provide a loader.exit() style
call that backs out to the common bits of loader (autoboot sequence unless
disabled with a loader.setenv("autoboot_delay", "NO")). The most ideal way
identified so far to implement loader.exit() is to throw a special
abort-style error that indicates to the caller in interp_lua that we've not
actually errored out, just continue execution. Otherwise, we have to hack in
logic to bubble up and return from loader.lua without continuing further,
which gets kind of ugly depending on the context in which we're aborting.

A compat shim is provided temporarily in case the executing loader doesn't
yet have loader.lua_path, which was just added in r354246.

r355349: lualoader: correct a typo from r354247

r354247 converted try_include to lfs + dofile with the loader.lua_path added
just before. Fortunately, there was a hardcoded /boot/lua fallback in case
loader.lua_path wasn't being set yet- I typo'd it as loader.lua_paths.

Fix the typo.

4 years agoMFC r355568:
Dimitry Andric [Thu, 12 Dec 2019 18:16:32 +0000 (18:16 +0000)]
MFC r355568:

Correctly check for C++17 and higher when declaring timespec_get()

Summary:
In rS338751, the check to declare `timespec_get()` for C++17 and higher
was incorrectly done against a `cplusplus` define, while it should have
been `__cplusplus`.

Fix this by using `__cplusplus`, and also bump `__FreeBSD_version` so it
becomes possible to correctly check for `timespec_get()` in upstream
libc++ headers.

Reviewed by: brooks, emaste
Differential Revision: https://reviews.freebsd.org/D22735

4 years agoMFC r355422:
Konstantin Belousov [Thu, 12 Dec 2019 13:47:02 +0000 (13:47 +0000)]
MFC r355422:
mlx5: Do not poke hardware for statistic after teardown is started.

4 years agoMFC r355407:
Konstantin Belousov [Thu, 12 Dec 2019 13:46:02 +0000 (13:46 +0000)]
MFC r355407:
Stop using per-mount tmpfs zones.

4 years agoMFC r355182: Fix use-after-free in case of L2ARC prefetch failure.
Alexander Motin [Thu, 12 Dec 2019 00:29:48 +0000 (00:29 +0000)]
MFC r355182: Fix use-after-free in case of L2ARC prefetch failure.

In case L2ARC read failed, l2arc_read_done() creates _different_ ZIO
to read data from the original storage device.  Unfortunately pointer
to the failed ZIO remains in hdr->b_l1hdr.b_acb->acb_zio_head, and if
some other read try to bump the ZIO priority, it will crash.

The problem is reproducible by corrupting L2ARC content and reading
some data with prefetch if l2arc_noprefetch tunable is changed to 0.
With the default setting the issue is probably not reproducible now.

4 years agoMFC r355404: Mark some more hot global variables with __read_mostly.
Alexander Motin [Wed, 11 Dec 2019 15:15:21 +0000 (15:15 +0000)]
MFC r355404: Mark some more hot global variables with __read_mostly.

4 years agoMFC r355144:
Mark Johnston [Wed, 11 Dec 2019 14:28:13 +0000 (14:28 +0000)]
MFC r355144:
iwm(4): Remove _mvm from the namespace.

4 years agoMFC r355143:
Mark Johnston [Wed, 11 Dec 2019 14:27:33 +0000 (14:27 +0000)]
MFC r355143:
iwm(4): Fix version string formatting.

4 years agoMFC r355399:
Mark Johnston [Wed, 11 Dec 2019 14:27:00 +0000 (14:27 +0000)]
MFC r355399:
Fix an off-by-one error in vm_map_pmap_enter().

4 years agoMFC r340127,340133,355085: libbsdxml (expat) 2.2.9.
Xin LI [Wed, 11 Dec 2019 06:30:26 +0000 (06:30 +0000)]
MFC r340127,340133,355085: libbsdxml (expat) 2.2.9.

4 years agoMFC r354969:
Hans Petter Selasky [Tue, 10 Dec 2019 07:06:32 +0000 (07:06 +0000)]
MFC r354969:
Add USB ID for Diamond Multimedia BVU195 Display Link device.

Submitted by: darius@dons.net.au
PR: 242128
Sponsored by: Mellanox Technologies

4 years agoMFC r355322:
Hans Petter Selasky [Tue, 10 Dec 2019 07:04:20 +0000 (07:04 +0000)]
MFC r355322:
Use refcount from "in_joingroup_locked()" when joining multicast
groups. Do not acquire additional references. This makes the IPv4 IGMP
code in line with the IPv6 MLD code.

Background:
The IPv4 multicast code puts an extra reference on the in_multi struct
when joining groups.  This becomes visible when using daemons like
igmpproxy from ports, that multicast entries do not disappear from the
output of ifmcstat(8) when multicast streams are disconnected.

This fixes a regression issue after r349762.

While at it factor the ip_mfilter_insert() and ip6_mfilter_insert() calls
to avoid repeated "is_new" check.

Differential Revision: https://reviews.freebsd.org/D22595
Tested by: Guido van Rooij <guido@gvr.org>
Reviewed by: rgrimes (network)
Sponsored by: Mellanox Technologies

4 years agoMFC r355347:
Toomas Soome [Mon, 9 Dec 2019 21:10:18 +0000 (21:10 +0000)]
MFC r355347:
loader: ReadKeyStrokeEx may return partial keystrokes

In some systems we can receive no scancode nor unicodechar values.

PR: 240760
Reported by: Ariel Millennium Thornton

4 years agoMFC r350624 (by cem):
Alexander Motin [Mon, 9 Dec 2019 17:13:17 +0000 (17:13 +0000)]
MFC r350624 (by cem):
amdtemp(4), amdsmn(4): Attach to Ryzen 3 (Zen 2) hostbridges

PR: 239607

4 years agoMFC r355224, r355308, r355392:
Toomas Soome [Mon, 9 Dec 2019 16:21:26 +0000 (16:21 +0000)]
MFC r355224, r355308, r355392:
loader.efi: efipart needs better support detecting nested partitions

Just as disks can have nested partitions, the same happens with cd devices,
so we need to detect device paths and make sure we will not mix the handles.

To address this:

we fetch handle array and create linked list of block devices.
we walk the list and detect parent devices and set children pd_parent.
for {fd, cd, hd}, we walk device list and pick up our devices and store to
corresponding list. We make sure we store parent device first.

For sorting we use 3 steps: We check for floppy, we check for cd and then
everything else must be hd.

In general, it seems the floppy devices have no parent.
CD can have both parents and children (multiple boot entries, partitions
from the hybrid disk image).

Tested by: cross+freebsd@distal.com on Cisco UCS systems, C200 series (C220M5, C240M4, C220M3).
Also on MBP with UEFI 1.10

4 years agoMFC r355424: release: chase ports r519089 (rpi-firmware update)
Kyle Evans [Mon, 9 Dec 2019 15:30:12 +0000 (15:30 +0000)]
MFC r355424: release: chase ports r519089 (rpi-firmware update)

4 years agoMFC r355288:
Konstantin Belousov [Mon, 9 Dec 2019 00:43:11 +0000 (00:43 +0000)]
MFC r355288:
mlx5: Do not try to enable fwdumps if scan space did not responded.

4 years agoMFC r355287:
Konstantin Belousov [Mon, 9 Dec 2019 00:42:12 +0000 (00:42 +0000)]
MFC r355287:
mlx5: Downgrade assert about misbehaving hardware to error message.

4 years agoMFC r355469:
Mark Johnston [Mon, 9 Dec 2019 00:34:34 +0000 (00:34 +0000)]
MFC r355469:
Fix fault_type handling in vm_map_lookup().

4 years agoMFC r355129:
Andrey V. Elsukov [Sun, 8 Dec 2019 15:22:20 +0000 (15:22 +0000)]
MFC r355129:
  Add support for dummy ESP packets with next header field equal to
  IPPROTO_NONE.

  According to RFC4303 2.6 they should be silently dropped.

  Submitted by: aurelien.cazuc.external_stormshield.eu
  Sponsored by: Stormshield
  Differential Revision: https://reviews.freebsd.org/D22557

4 years agoMFC r351770,r352920-r352923
Matt Macy [Sun, 8 Dec 2019 04:19:05 +0000 (04:19 +0000)]
MFC r351770,r352920-r352923

MFCs to dd appear to have been haphazard so selectively
MFCing individually didn't work easily.

Add conv=fsync flag to dd

The fsync flag performs an fsync(2) on the output file before closing it.
This will be useful for the ZFS test suite.

Add conv=fdatasync flag to dd

The fdatasync flag performs an fdatasync(2) on the output file before closing it.
This will be useful for the ZFS test suite.

dd: Check result of close(2) for errors

close(2) can return errors from previous operations which should not be ignored.

Add oflag=fsync and oflag=sync capability to dd

Sets the O_FSYNC flag on the output file. oflag=fsync and oflag=sync are
synonyms just as O_FSYNC and O_SYNC are synonyms. This functionality is
intended to improve portability of dd commands in the ZFS test suite.

Add iflag=fullblock to dd

Normally, count=n means read(2) will be called n times on the input to dd. If
the read() returns short, as may happen when reading from a pipe, fewer bytes
will be copied from the input. With conv=sync the buffer is padded with zeros
to fill the rest of the block.

iflag=fullblock causes dd to continue reading until the block is full, so that
count=n means n full blocks are copied. This flag is compatible with illumos
and GNU dd and is used in the ZFS test suite.

Submitted by: Ryan Moeller, Thomas Hurst
Reviewed by: manpages, mmacy@
Sponsored by: iXsystems, Inc.

4 years agoMFC r349549: MFV r349535: less v551.
Xin LI [Sat, 7 Dec 2019 19:02:09 +0000 (19:02 +0000)]
MFC r349549: MFV r349535: less v551.

Relnotes: yes

4 years agoMFC r355193:
Ian Lepore [Sat, 7 Dec 2019 17:46:32 +0000 (17:46 +0000)]
MFC r355193:

Implement the ofw_bus_get_node method in the imx_gpio driver so that
ofw_gpiobus can find its fdt metadata and instantiate child devices.

4 years agoMFC r354973:
Ian Lepore [Sat, 7 Dec 2019 17:44:21 +0000 (17:44 +0000)]
MFC r354973:

Rewrite iicdev_writeto() to use a single buffer and a single iic_msg, rather
than effectively doing scatter/gather IO with a pair of iic_msgs that direct
the controller to do a single transfer with no bus STOP/START between the
two buffers.  It turns out we have multiple i2c hardware drivers that don't
honor the NOSTOP and NOSTART flags; sometimes they just try to do the
transfers anyway, creating confusing failures or leading to corrupted data.

4 years agoMFC r352938:
Ian Lepore [Sat, 7 Dec 2019 17:34:04 +0000 (17:34 +0000)]
MFC r352938:

Add 8 and 16 bit versions of atomic_cmpset and atomic_fcmpset for arm.

This adds 8 and 16 bit versions of the cmpset and fcmpset functions. Macros
are used to generate all the flavors from the same set of instructions; the
macro expansion handles the couple minor differences between each size
variation (generating ldrexb/ldrexh/ldrex for 8/16/32, etc).

In addition to handling new sizes, the instruction sequences used for cmpset
and fcmpset are rewritten to be a bit shorter/faster, and the new sequence
will not return false when *dst==*old but the store-exclusive fails because
of concurrent writers. Instead, it just loops like ldrex/strex sequences
normally do until it gets a non-conflicted store. The manpage allows LL/SC
architectures to bogusly return false, but there's no reason to actually do
so, at least on arm.

Reviewed by: cognet

4 years agoMFC r352338:
Ian Lepore [Sat, 7 Dec 2019 17:24:07 +0000 (17:24 +0000)]
MFC r352338:

Create a mechanism for encoding a system errno into the IIC_Exxxxx space.

Errors are communicated between the i2c controller layer and upper layers
(iicbus and slave device drivers) using a set of IIC_Exxxxxx constants which
effectively define a private number space separate from (and having values
that conflict with) the system errno number space. Sometimes it is necessary
to report a plain old system error (especially EINTR) from the controller or
bus layer and have that value make it back across the syscall interface
intact.

I initially considered replicating a few "crucial" errno values with similar
names and new numbers, e.g., IIC_EINTR, IIC_ERESTART, etc. It seemed like
that had the potential to grow over time until many of the errno names were
duplicated into the IIC_Exxxxx space.

So instead, this defines a mechanism to "encode" an errno into the IIC_Exxxx
space by setting the high bit and putting the errno into the lower-order
bits; a new errno2iic() function does this. The existing iic2errno()
recognizes the encoded values and extracts the original errno out of the
encoded value. An interesting wrinkle occurs with the pseudo-error values
such as ERESTART -- they aleady have the high bit set, and turning it off
would be the wrong thing to do. Instead, iic2errno() recognizes that lots of
high bits are on (i.e., it's a negative number near to zero) and just
returns that value as-is.

Thus, existing drivers continue to work without needing any changes, and
there is now a way to return errno values from the lower layers. The first
use of that is in iicbus_poll() which does mtx_sleep() with the PCATCH flag,
and needs to return the errno from that up the call chain.

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

4 years agoMFC r353024-r353025
Ian Lepore [Sat, 7 Dec 2019 17:19:36 +0000 (17:19 +0000)]
MFC r353024-r353025

r353024:
Clarify how the -f option for daemon(8) interacts with other options
related to redirecting stdout and stderr.

r353025:
Bump .Dd for earlier update (should have been part of r353024).

4 years agoMFC r352196, r352333, r352342, r353653
Ian Lepore [Sat, 7 Dec 2019 17:17:34 +0000 (17:17 +0000)]
MFC r352196, r352333, r352342, r353653

r352196:
In am335x_dmtpps, use a spin mutex to interlock between PPS capture and PPS
ioctl(2) handling.  This allows doing the pps_event() work in the polling
routine, instead of using a taskqueue task to do that work.

Also, add PNPINFO, and switch to using make_dev_s() to create the cdev.

Using a spin mutex and calling pps_event() from the polling function works
around the situation which requires more than 2 sets of timecounter
timehands in a single-core system to get reliable PPS capture.  That problem
would happen when a single-core system is idle in cpu_idle() then gets woken
up with an event timer event which was scheduled to handle a hardclock tick.
That processing path would end up calling tc_windup 3 or 4 times between
when the tc polling function was called and when the taskqueue task would
eventually run, and with only two sets of timehands, the th_generation count
would always be too old to allow the captured PPS data to be used.

r352333:
Include <lock.h>, required to use spinlocks in this code.

r352342:
Make the ti_sysc device quiet.  It's an internal utility pseudo-device
that makes the upstream FDT data work right, so we don't need to see a
couple dozen instances of it spam the dmesg at boot time unless it's a
verbose boot.

r353653:
Update some comments; no functional changes.  Some historical old comments
in this driver indicate that the SD_CAPA register is write-once and after
being set one time the values in it cannot be changed.  That turns out not
to be the case -- the values written to it survive a reset, but they can
be rewritten/changed at any time.

4 years agoMFC r355214, r355239, r355274, r355276-r355277, r355295, r355298
Ian Lepore [Sat, 7 Dec 2019 17:10:03 +0000 (17:10 +0000)]
MFC r355214, r355239, r355274, r355276-r355277, r355295, r355298

r355214:
Ignore "gpio-hog" nodes when instantiating ofw_gpiobus children.  Also,
in ofw_gpiobus_probe() return BUS_PROBE_DEFAULT rather than 0; we are not
the only possible driver to handle this device, we're just slightly better
than the base gpiobus (which probes at BUS_PROBE_GENERIC).

In the time since this code was first written, the gpio controller bindings
aquired the concept of a "hog" node which could be used to preset one or
more gpio pins as input or output at a specified level.  This change doesn't
fully implement the hogging concept, it just filters out hog nodes when
instantiating child devices by scanning for child nodes in the fdt data.

The whole concept of having child nodes under the controller node is not
supported by the standard bindings, and appears to be a freebsd extension,
probably left over from the days when we had no support for cross-tree
phandle references in the fdt data.

r355239:
Add an OFWBUS_PNP_INFO() macro for devices that hang directly off the root
ofwbus.  Also, apply some style(9) whitespace fixing to the
SIMPLEBUS_PNP_INFO() macro (no functional change).

r355274:
Move most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so
that they can be used by drivers on non-FDT-configured systems.  Only the
functions related to acquiring pins by parsing FDT data remain in
ofw_gpiobus.  Also, add two new functions for acquiring gpio pins based on
child device_t and index, or on the bus device_t and pin number.  And
finally, defer reserving pins for gpiobus children until they acquire the
pin, rather than reserving them as soon as the child is added (before it's
even known whether the child will attach).

This will allow drivers configured with hints (or any other mechanism) to
use the same code as drivers configured via FDT data.  Until now, a hinted
driver and an FDT driver had to be two completely different sets of code,
because hinted drivers could only use gpiobus calls to manipulate pins,
while fdt-configured drivers could not use that API (due to not always being
children of the bus that owns the pins) and had to use the newer
gpio_pin_xxxx() functions.  Now drivers can be written in the more
traditional form, where most of the code is shared and only the resource
acquisition code at attachment time changes.

r355276:
Rewrite gpioiic(4) to use the gpio_pin_* API, and to conform to the modern
FDT bindings document for gpio-i2c devices.

Using the gpio_pin_* functions to acquire/release/manipulate gpio pins
removes the constraint that both gpio pins must belong to the same gpio
controller/bank, and that the gpioiic instance must be a child of gpiobus.
Removing those constraints allows the driver to be fully compatible with
the modern dts bindings for a gpio bitbanged i2c bus.

For hinted attachment, the two gpio pins still must be on the same gpiobus,
and the device instance must be a child of that bus.  This preserves
compatibility for existing installations that have use gpioiic(4) with hints.

r355277:
Fix leading whitespace (spaces->tabs) in comments; no functional change.

r355295:
Remove "all rights reserved" from copyright after getting a response from
Luiz that he also was not intentionally asserting that right, it was already
there when he added his name.

r355298:
Do not initialize the flags field in struct gpiobus_pin from the flags in
struct gpio_pin.  It turns out these two sets of flags are completely
unrelated to each other.

Also, update the comment for GPIO_ACTIVE_LOW to reflect the fact that it
does get set, somewhat unobviously, by code that parses FDT data.  The bits
from the FDT cell containing flags are just copied to gpiobus_pin.flags, so
there's never any obvious reference to the symbol GPIO_ACTIVE_LOW being
stored into the flags field.

4 years agoMFC r355225:
Benedict Reuschling [Sat, 7 Dec 2019 14:17:56 +0000 (14:17 +0000)]
MFC r355225:
Capitalize some user-visible output messages in
the bectl utility.

No functional changes.

Approved by: imp@
Differential Revision: https://reviews.freebsd.org/D22330

4 years agoMFC r238022 (cem): dhclient: fix braino in previous bugfix r300174
Ed Maste [Sat, 7 Dec 2019 03:56:36 +0000 (03:56 +0000)]
MFC r238022 (cem): dhclient: fix braino in previous bugfix r300174

The previous revision missed the exact same error in a copy paste block
of the same code in another function.  Fix the identical case, too.

A DHCP client identifier is simply the hardware type (one byte)
concatenated with the hardware address (some variable number of bytes,
but at most 16).  Limit the size of the temporary buffer to match and
the rest of the calculations shake out correctly.

PR: 238022
Reported by: Young <yangx92 AT hotmail.com>
Submitted by: Young <yangx92 AT hotmail.com>

4 years agoMFC r354446: rc.shutdown: print a newline before watchdog timeout message
Ed Maste [Sat, 7 Dec 2019 03:29:58 +0000 (03:29 +0000)]
MFC r354446: rc.shutdown: print a newline before watchdog timeout message

Previously the watchdog timeout message was appended to the last entry
in the "Waiting for PIDS" list, resulting in a message like

    Waiting for PIDS: 31299 31296 90201 9020090 second watchdog timeout
    expired. Shutdown terminated.

Print a newline to separate the watchdog timeout message.

Also MFC 355476: rc.shutdown: kill shutdown process after logging message

Move the kill -KILL $$ back to the pre-r354446 location at the end of
the shutdown timeout handler.

PR: 241072
Sponsored by: The FreeBSD Foundation

4 years agoMFC r355388:
Cy Schubert [Sat, 7 Dec 2019 00:53:22 +0000 (00:53 +0000)]
MFC r355388:

Chase r352304. The default rlimit memlock is no memory locking.

Reported by: egypcio@

4 years agoMFC r355300:
Cy Schubert [Sat, 7 Dec 2019 00:51:37 +0000 (00:51 +0000)]
MFC r355300:

Fix a typo (upto --> up to) and reword to improve word flow.

4 years agoMFC r355003:
Mark Johnston [Fri, 6 Dec 2019 18:51:16 +0000 (18:51 +0000)]
MFC r355003:
Update the checks in vm_page_zone_import().

4 years agoMFC r344551:
Mark Johnston [Fri, 6 Dec 2019 18:27:50 +0000 (18:27 +0000)]
MFC r344551:
Fix handling of rights on stdio streams, take two.

PR: 234885

4 years agoMFC r340138 (by oshogbo):
Mark Johnston [Fri, 6 Dec 2019 18:26:34 +0000 (18:26 +0000)]
MFC r340138 (by oshogbo):
capsicum: use a new capsicum helpers in tools

4 years agoMFC r355139:
Brooks Davis [Fri, 6 Dec 2019 17:58:27 +0000 (17:58 +0000)]
MFC r355139:

Fix a logic bug when "mask" contains a ?: operator.

Newer versions of clang warn that '&' evaluates before '?:'.

Reviewed by: markj
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22573

4 years agoMFC r355001:
Mark Johnston [Fri, 6 Dec 2019 15:01:36 +0000 (15:01 +0000)]
MFC r355001:
Fix locking in vm_reserv_reclaim_contig().

4 years agoMFC r355211:
Konstantin Belousov [Fri, 6 Dec 2019 11:46:15 +0000 (11:46 +0000)]
MFC r355211:
Add a VN_OPEN_INVFS flag.

4 years agoMFC r349184. This fixing PCI passthrough via VT-d on modern chipsets with
Scott Long [Fri, 6 Dec 2019 09:50:01 +0000 (09:50 +0000)]
MFC r349184.  This fixing PCI passthrough via VT-d on modern chipsets with
multiple translation units.

PR: 229852
Submitted by: callum@mitchison.org

4 years agoMFC r354779:
Alan Somers [Fri, 6 Dec 2019 00:29:16 +0000 (00:29 +0000)]
MFC r354779:

Actually hook CAM_IO_STATS up to the build

It's still disabled by default, but now it can be enabled with config(5) and
it will be build in LINT.

Reviewed by: imp
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22383

4 years agoMFC r354812:
Alan Somers [Fri, 6 Dec 2019 00:27:16 +0000 (00:27 +0000)]
MFC r354812:

Update the ses(4) man page

This driver was largely rewritten in 2015 (svn r235911) but the man page was
never updated to match.

Reviewed by: trasz
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D22339

4 years agoMFC r354664-r354666
Alan Somers [Fri, 6 Dec 2019 00:24:31 +0000 (00:24 +0000)]
MFC r354664-r354666

r354664:
sesutil: fix an out-of-bounds array access

sesutil would allow the user to toggle an LED that was one past the maximum
element.  If he tried, ENCIOC_GETELMSTAT would return EINVAL.

Reported by: Coverity
Coverity CID: 1398940
Sponsored by: Axcient

r354665:
sesutil: fix some memory leaks

Reported by: Coverity
Coverity CID: 1331665
Sponsored by: Axcient

r354666:
sesutil: fix another memory leak

Instead of calloc()ing (and forgetting to free) in a tight loop, just put
this small array on the stack.

Reported by: Coverity
Coverity CID: 1331665
Sponsored by: Axcient

4 years agoMFC r355108 and r355170:
Hans Petter Selasky [Thu, 5 Dec 2019 14:50:46 +0000 (14:50 +0000)]
MFC r355108 and r355170:
Fix panic when loading kernel modules before root file system is mounted.
Make sure the rootvnode is always NULL checked.

Differential Revision: https://reviews.freebsd.org/D22545
PR: 241639
Sponsored by: Mellanox Technologies

4 years agor355120 | dim | 2019-11-26 23:01:09 +0100 (Tue, 26 Nov 2019) | 32 lines
Dimitry Andric [Wed, 4 Dec 2019 17:45:34 +0000 (17:45 +0000)]
r355120 | dim | 2019-11-26 23:01:09 +0100 (Tue, 26 Nov 2019) | 32 lines

The fdlibm hypot() implementations shouldn't potentially left-shift
negative numbers (invoking undefined behavior)

Summary:
Various paths through hypot(x, y) will multiply x and y by a power of
two, perform the calculation in a range where IEEE-754 provides greater
precision, then undo the multiplication to determine the true result.
Undoing that multiplication is implemented as t1*w, where t1=2**k.

2**k is often computed by taking the high word of 1.0, then adding k<<20
(for doubles or long doubles) or k<<23 (for floats) to it, then
overwriting that high word. But when k is negative this left-shifts a
negative value -- and that's undefined behavior in many editions of C
and C++.

This patch should fix all hypot implementations to compute 2**k without
triggering this particular bit of undefined behavior.

Test Plan: I've only very lightly tested out the hypot(double, double)
change, in SpiderMonkey's JavaScript engine, for consistency with prior
behavior.  The other functions' changes have more or less only been
eyeballed.  Careful examination appreciated!  Do note, however, that an
error in any of these changes would most likely produce a value that is
incorrect by a factor of two, so any mistake would most likely be
glaring if invoked.

Submitted by: Jeff Walden <jwalden@mit.edu>
Obtained from: https://github.com/freebsd/freebsd/pull/414
Reviewed by: dim, lwhsu
Differential Revision: https://reviews.freebsd.org/D22354

4 years agoMFC r355165: Make DMAR allow Intel NTB device to access its own BAR0.
Alexander Motin [Wed, 4 Dec 2019 15:14:14 +0000 (15:14 +0000)]
MFC r355165: Make DMAR allow Intel NTB device to access its own BAR0.

I have no good explanation why it happens, but I found that in B2B mode
at least Xeon v4 NTB leaks accesses to its configuration memory at BAR0
originated from the link side to its host side.  DMAR predictably blocks
those, making access to remote scratchpad registers in B2B mode impossible.

This change creates identity mapping in DMAR covering the BAR0 addresses,
making the NTB work fine with DMAR enabled.  It seems like allowing single
4KB range at 32KB offset may be enough, but I don't see a reason to be so
specific.

4 years agoMFC r355163: Make the code slightly more compact.
Alexander Motin [Wed, 4 Dec 2019 15:12:09 +0000 (15:12 +0000)]
MFC r355163: Make the code slightly more compact.

There should be no functional change.

4 years agoMFC r355074: Report XLAT0 register for completeness.
Alexander Motin [Wed, 4 Dec 2019 15:11:42 +0000 (15:11 +0000)]
MFC r355074: Report XLAT0 register for completeness.

4 years agoMFC r355146:
Konstantin Belousov [Wed, 4 Dec 2019 09:21:00 +0000 (09:21 +0000)]
MFC r355146:
Ease the life of PT_TO_SCE/PT_TO_SCX users when debuggee sleeps in
sigsuspend(2)/sig{timed,}wait(2).

4 years agoMFC r355138:
Konstantin Belousov [Wed, 4 Dec 2019 09:18:32 +0000 (09:18 +0000)]
MFC r355138:
bus_dma_dmar_load_ident(9): load identity mapping into the map.

4 years agoMFC r355065 - r355068: Linux epoll improvements.
Vladimir Kondratyev [Tue, 3 Dec 2019 23:11:40 +0000 (23:11 +0000)]
MFC r355065 - r355068: Linux epoll improvements.

r355065:
Linux epoll: Don't deregister file descriptor after EPOLLONESHOT is fired

Linux epoll does not remove descriptor after one-shot event has been triggered.
Set EV_DISPATCH kqueue flag rather then EV_ONESHOT to get the same behavior.

Required by Linux Steam client.

PR: 240590
Reported by: Alex S <iwtcex@gmail.com>
Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D22513

r355066:
Linux epoll: Check both read and write kqueue events existence in EPOLL_CTL_ADD

Linux epoll EPOLL_CTL_ADD op handler should always check registration
of both EVFILT_READ and EVFILT_WRITE kevents to deceide if supplied
file descriptor fd is already registered with epoll instance.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D22515

r355067:
Linux epoll: Register events with zero event mask

Such an events are legal and should be interpreted as EPOLLERR | EPOLLHUP.
Register a disabled kqueue event in that case as we do not support EPOLLHUP yet.

Required by Linux Steam client.

PR: 240590
Reported by: Alex S <iwtcex@gmail.com>
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D22516

r355068:
Linux epoll: Allow passing of any negative timeout value to epoll_wait

Linux epoll allow passing of any negative timeout value to epoll_wait()
to cause unbound blocking

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D22517

4 years agoMFC r354624
Eric van Gyzen [Tue, 3 Dec 2019 22:57:10 +0000 (22:57 +0000)]
MFC r354624

tip/cu: check for EOF on input on the local side

If cu reads an EOF on the input side, it goes into a tight loop
sending a garbage byte to the remote.  With this change, it exits
gracefully, along with its child.

Sponsored by: Dell EMC Isilon

4 years agoMFC r355006:
Ravi Pokala [Tue, 3 Dec 2019 22:53:22 +0000 (22:53 +0000)]
MFC r355006:

Add and document options to allow rpc.lockd and rpc.statd to run in the
foreground.

This allows a separate process to monitor when and how those programs exit.
That process can then restart them if needed.