]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoRegularize my copyright notice
imp [Wed, 4 Dec 2019 16:56:11 +0000 (16:56 +0000)]
Regularize my copyright notice

o Remove All Rights Reserved from my notices
o imp@FreeBSD.org everywhere
o regularize punctiation, eliminate date ranges
o Make sure that it's clear that I don't claim All Rights reserved by listing
  All Rights Reserved on same line as other copyright holders (but not
  me). Other such holders are also listed last where it's clear.

4 years agoFix accidentally changed copyright year.
imp [Wed, 4 Dec 2019 16:55:55 +0000 (16:55 +0000)]
Fix accidentally changed copyright year.

Noticed by: bapt@

4 years agoloader: clean up efipart filter expressions
tsoome [Wed, 4 Dec 2019 16:41:00 +0000 (16:41 +0000)]
loader: clean up efipart filter expressions

Small cleanup based on illumos review.

4 years agoChase r352304. The default rlimit memlock is no memory locking.
cy [Wed, 4 Dec 2019 15:04:06 +0000 (15:04 +0000)]
Chase r352304. The default rlimit memlock is no memory locking.

Reported by: egypcio@
MFC after: 3 days

4 years agoFix arm64 build after r355373
lwhsu [Wed, 4 Dec 2019 08:21:54 +0000 (08:21 +0000)]
Fix arm64 build after r355373

Sponsored by: The FreeBSD Foundation

4 years agoRemove "All rights reserved" phrase from copyright notes.
se [Wed, 4 Dec 2019 08:03:33 +0000 (08:03 +0000)]
Remove "All rights reserved" phrase from copyright notes.

With the ratification of the Berne Convention in 2000, it became obsolete.

I have removed that phrase and the "(c)" only from files without copyright
claims by other parties. There are 2 files (pci.c, pci_private.h) that are
also claimed by Michael Smith <msmith@freebsd.org> and by BSDi, which have
therefore not been included in this commit.

When all member nations of the Buenos Aires Convention adopted the Berne
Convention, the phrase "All rights reserved" became unnecessary to assert
copyright. Remove it from files under my copyright.

There are 2 files (pci.c, pci_private.h) that) that do also bear msmith's
and BSDi's copyright. I have left them unchanged for now, since I do not
know whether they (or the legal successor in case of BSDi) would agree.

4 years agoUse full path to sysctl(8) since /sbin is not in PATH.
bdrewery [Wed, 4 Dec 2019 04:01:53 +0000 (04:01 +0000)]
Use full path to sysctl(8) since /sbin is not in PATH.

X-MFC-With: r355379
MFC after: 2 weeks

4 years agopowerpc/booke: Fix some formatting errors in debug printfs
jhibbits [Wed, 4 Dec 2019 03:51:30 +0000 (03:51 +0000)]
powerpc/booke: Fix some formatting errors in debug printfs

Use the right formats for the types given (vm_offset_t and vm_size_t are
both uint32_t on 32-bit platforms, and uint64_t on 64-bit platforms, and
match size_t in size, so we can use the size_t format as we do in other
similar code).

These were found by clang.

4 years agoRun make in parallel.
bdrewery [Wed, 4 Dec 2019 03:44:50 +0000 (03:44 +0000)]
Run make in parallel.

This is mostly targetting the 'installconfig' phase of 'distribution'
which does a full tree walk.

MFC after:  2 weeks

4 years agopowerpc/booke: Fix 32-bit Book-E SMP AP bringup
jhibbits [Wed, 4 Dec 2019 03:41:55 +0000 (03:41 +0000)]
powerpc/booke: Fix 32-bit Book-E SMP AP bringup

r354266 changed the type of bp_kernload to vm_paddr_t in platform_mpc85xx.c,
but not the variable itself in locore.S.  This caused the AP to not come up,
due to overwriting the following variable (bp_virtaddr).  Also, properly
load bp_kernload into MAS3 and MAS7.  Prior to r354266, we required loading
into the low 4GB, but now we can load from anywhere in memory that ubldr can
access.

4 years agoChange the implementation of bit_ffc_area_at so that, in the worst
dougm [Wed, 4 Dec 2019 03:36:54 +0000 (03:36 +0000)]
Change the implementation of bit_ffc_area_at so that, in the worst
case, the number of operations spent on each b-bit word is
proportional to lg b rather than b.

For one word, shrink all regions of 0-bits by size-1 bit positions in
no more than O(lg(min(b,size))) operations. In what remains, the first
0-bit is either the start of an area of sufficient size contained
within the original word, or the start of an area that could spill
over into the next word, and prove to be of sufficient size once the
start of that word is examined.

Change bit_ffs_area_at similarly.

Reviewed by: erj, jacob.e.keller_intel.com
MFC with: r354977
Differential Revision: https://reviews.freebsd.org/D22523

4 years agocaroot update to latest tip: one (1) addition, none (0) removed
kevans [Wed, 4 Dec 2019 02:59:50 +0000 (02:59 +0000)]
caroot update to latest tip: one (1) addition, none (0) removed

Added:
- Entrust Root Certification Authority - G4

4 years agox86: Add missed break to TAA status sysctl
cem [Wed, 4 Dec 2019 02:42:22 +0000 (02:42 +0000)]
x86: Add missed break to TAA status sysctl

Just a typo that Coverity identified.

Coverity also identified an unused store in the same functional area (x86 TAA
stuff), but this commit does not address that issue (CID 1408334).

Reported by: Coverity
CID: 14083281408332

4 years agoPass 0 to __builtin_frame_address() to appease modern GCC.
jhb [Tue, 3 Dec 2019 23:20:19 +0000 (23:20 +0000)]
Pass 0 to __builtin_frame_address() to appease modern GCC.

Modern versions of GCC warn about passing non-zero values to
__builtin_frame_address().  Passing 1 is a cosmetic change to remove
the db_trace_self() frame from the printed stack trace.

Reported by: marius, imp
Differential Revision: https://reviews.freebsd.org/D22600

4 years agoUse uintptr_t instead of register_t * for the stack base.
jhb [Tue, 3 Dec 2019 23:17:54 +0000 (23:17 +0000)]
Use uintptr_t instead of register_t * for the stack base.

- Use ustringp for the location of the argv and environment strings
  and allow destp to travel further down the stack for the stackgap
  and auxv regions.
- Update the Linux copyout_strings variants to move destp down the
  stack as was done for the native ABIs in r263349.
- Stop allocating a space for a stack gap in the Linux ABIs.  This
  used to hold translated system call arguments, but hasn't been used
  since r159992.

Reviewed by: kib
Tested on: md64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22501

4 years agoCurrently the breadn_flags() and getblkx() interfaces are passed
mckusick [Tue, 3 Dec 2019 23:07:09 +0000 (23:07 +0000)]
Currently the breadn_flags() and getblkx() interfaces are passed
the vnode, logical block number, and size of data block that is
being requested. They then use the VOP_BMAP function to calculate
the mapping from logical block number to physical block number from
which to access the data. This change expands the interface to also
pass the physical block number in cases where the VOP_MAP function
may no longer work, for example when a file is being truncated.

No functional change.

Reviewed by:  kib
Tested by:    Peter Holm
Sponsored by: Netflix

4 years agocpufreq_dt: Do not fetch again hw.ncpu
manu [Tue, 3 Dec 2019 22:26:55 +0000 (22:26 +0000)]
cpufreq_dt: Do not fetch again hw.ncpu

MD code already set the global variable mp_ncpus according to
the tunable hw.ncpu so use the global variable directly.

Reported by: ian

4 years agocpufreq_dt: Do not attach the device if the cpu isn't present
manu [Tue, 3 Dec 2019 22:08:54 +0000 (22:08 +0000)]
cpufreq_dt: Do not attach the device if the cpu isn't present

If we boot with hw.ncpu=X (available on arm and arm64 at least) we
shouldn't attach the cpufreq driver as cf_set_method will try to get
the cpuid and it doesn't exists.
This solves cpufreq panicing on RockChip RK3399 when booting with
hw.ncpu=4

MFC after: 1 week

4 years agoRemove "all rights reserved" from copyright for the file that Jared McNeill
manu [Tue, 3 Dec 2019 21:05:33 +0000 (21:05 +0000)]
Remove "all rights reserved" from copyright for the file that Jared McNeill
own. He gave me permission to do this.

4 years agoRemove "all rights reserved" from copyright for the file I own.
manu [Tue, 3 Dec 2019 21:00:45 +0000 (21:00 +0000)]
Remove "all rights reserved" from copyright for the file I own.
Some of the files have both me and Jared McNeill and he gave me
permission to remove it from his files too.

4 years agoarm64: rockchip: rl3399: Remove the ability to put the PLL in normal mode at boot
manu [Tue, 3 Dec 2019 19:18:32 +0000 (19:18 +0000)]
arm64: rockchip: rl3399: Remove the ability to put the PLL in normal mode at boot

RK3399 PLLs have three modes :
 - Normal, where they behave normally and their freq is calculated based on
   the registers values.
 - Slow, where the PLL freq is 24Mhz (well, the external oscillator).
 - Deep Slow, used for suspend where the freq is 32Khz.

We used to put every CPU related PLL in normal mode but it can cause problem
if the firmware didn't setup the clocks register correctly.
And even if it did but left the pll in slow or deep slow mode that might be
because the PMIC suppling voltage for the CPU haven't been configured yet
and we cannot do that at this point.
So remove the ability to set PLLs to normal mode at boot to avoid any problems.

4 years agolualoader: correct a typo from r354247
kevans [Tue, 3 Dec 2019 18:44:19 +0000 (18:44 +0000)]
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.

X-MFC-With: r354247
MFC after: 3 days

4 years agoloader: ReadKeyStrokeEx may return partial keystrokes
tsoome [Tue, 3 Dec 2019 18:36:39 +0000 (18:36 +0000)]
loader: ReadKeyStrokeEx may return partial keystrokes

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

PR: 240760
Reported by: Ariel Millennium Thornton
MFC after: 1 week

4 years agobitset: avoid pessimized code when bitset size is not constant
rlibby [Tue, 3 Dec 2019 17:43:57 +0000 (17:43 +0000)]
bitset: avoid pessimized code when bitset size is not constant

We have a couple optimizations for when the bitset is known to be just
one word.  But with dynamically sized bitsets, it was actually more work
to determine the size than just to do the necessary computation.  Now,
only use the optimization when the size is known to be constant.

Reviewed by: markj
Discussed with: jeff
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22639

4 years agomips busdma: bzero map on alloc
rlibby [Tue, 3 Dec 2019 17:43:52 +0000 (17:43 +0000)]
mips busdma: bzero map on alloc

Maps from the mips busdma dmamap_zone were not completely initialized.
In particular, pagesneeded and pagesreserved were not initialized.  This
could cause a crash.

Remove some dead fields from mips struct bus_dmamap while here.

Reported by: brooks
Reviewed by: ian
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22638

4 years agoctau.c: convert from KOI8-R to UTF-8 encoding
emaste [Tue, 3 Dec 2019 16:52:03 +0000 (16:52 +0000)]
ctau.c: convert from KOI8-R to UTF-8 encoding

AFAICT this is the last source file (excluding contrib) that was not
ASCII or UTF-8.

4 years agoscterm-sc.c: convert source file to UTF-8 encoding
emaste [Tue, 3 Dec 2019 16:45:53 +0000 (16:45 +0000)]
scterm-sc.c: convert source file to UTF-8 encoding

Most source files are already ASCII or UTF-8 but this one was not previously
converted.

4 years agoRegularize copyright notices for me.
imp [Tue, 3 Dec 2019 15:48:28 +0000 (15:48 +0000)]
Regularize copyright notices for me.

Remove stray All Rights Reserved and other non-license stuff. Make sure all
copyrights have year.

4 years agoMake icmp6_reflect() static.
bz [Tue, 3 Dec 2019 14:46:38 +0000 (14:46 +0000)]
Make icmp6_reflect() static.

icmp6_reflect() is not used anywhere outside icmp6.c, no reason to
export it.

Sponsored by: Netflix

4 years agodevstat_selectdevs: resize dev_select only after copying data out of it
avg [Tue, 3 Dec 2019 09:48:43 +0000 (09:48 +0000)]
devstat_selectdevs: resize dev_select only after copying data out of it

The resizing could be a downsizing so some data would be lost and we
could attempt to read past the end of the new memory allocation.

MFC after: 2 weeks
Sponsored by: Panzura

4 years agoImport DTS files for riscv from Linux 5.4
manu [Tue, 3 Dec 2019 09:12:53 +0000 (09:12 +0000)]
Import DTS files for riscv from Linux 5.4

Requested by:  mhorne

4 years agoRevert r355188 as it shouldn't have created the risc-v directory at
manu [Tue, 3 Dec 2019 09:06:37 +0000 (09:06 +0000)]
Revert r355188 as it shouldn't have created the risc-v directory at
the top level.

Reported by: rpokala

4 years agoUse refcount from "in_joingroup_locked()" when joining multicast
hselasky [Tue, 3 Dec 2019 08:46:59 +0000 (08:46 +0000)]
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)
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoExplicitly exit() instead of return in main().
delphij [Tue, 3 Dec 2019 07:03:25 +0000 (07:03 +0000)]
Explicitly exit() instead of return in main().

MFC after: 2 weeks

4 years agonewfs_msdos: -A is incompatible with -r, not -o.
delphij [Tue, 3 Dec 2019 07:01:28 +0000 (07:01 +0000)]
newfs_msdos: -A is incompatible with -r, not -o.

PR: 242314
Submitted by: Guy Yur <guyyur gmail com>
MFC after: 2 weeks

4 years agosyscons.c: clang-format pass to reduce style inconsistencies
kevans [Tue, 3 Dec 2019 02:30:52 +0000 (02:30 +0000)]
syscons.c: clang-format pass to reduce style inconsistencies

This was purely automatically massaged... some parts are still imperfect,
but this is close enough to make it more readable/easy to work on.
Unfortunately the vt/syscons/kdb situation slightly complicates changes to
tty locking, so some work will need to be done to remediate that.

4 years agoUse a precise bit count for the slab free items in UMA. This significantly
jeff [Mon, 2 Dec 2019 22:44:34 +0000 (22:44 +0000)]
Use a precise bit count for the slab free items in UMA.  This significantly
shrinks embedded slab structures.

Reviewed by: markj, rlibby (prior version)
Differential Revision: https://reviews.freebsd.org/D22584

4 years agoFix a few places that free a page from an object without busy held. This is
jeff [Mon, 2 Dec 2019 22:42:05 +0000 (22:42 +0000)]
Fix a few places that free a page from an object without busy held.  This is
tightening constraints on busy as a precursor to lockless page lookup and
should largely be a NOP for these cases.

Reviewed by: alc, kib, markj
Differential Revision: https://reviews.freebsd.org/D22611

4 years agoFix the last few cases that grab without busy or valid. The grab functions must
jeff [Mon, 2 Dec 2019 22:38:25 +0000 (22:38 +0000)]
Fix the last few cases that grab without busy or valid.  The grab functions must
return the page in some held state for consistency elsewhere.

Reviewed by: alc, kib, markj
Differential Revision: https://reviews.freebsd.org/D22610

4 years agoInitialize the idle thread's lock sooner so it's not evaluated on every fork
jeff [Mon, 2 Dec 2019 22:35:45 +0000 (22:35 +0000)]
Initialize the idle thread's lock sooner so it's not evaluated on every fork
exit and we can rely on it elsewhere.

Reviewed by: mav, kib, jhb, markj
Differential Revision: https://reviews.freebsd.org/D22624

4 years agoDon't run sched_preempt() inside of an extra critical section. This disables
jeff [Mon, 2 Dec 2019 22:34:19 +0000 (22:34 +0000)]
Don't run sched_preempt() inside of an extra critical section.  This disables
the sched_preempt() switch optimization and causes the sched lock to be dropped
and immediately reacquired.

Reviewed by: jhb, kib, mav, markj (with changes)
Differential Revision: https://reviews.freebsd.org/D22623

4 years agoBump __FreeBSD_version after r355304.
trasz [Mon, 2 Dec 2019 21:09:57 +0000 (21:09 +0000)]
Bump __FreeBSD_version after r355304.

The net/tcprtt port depends on this.

Sponsored by: Klara, Inc, Netflix

4 years agoloader.efi: fix cd boot for cisco C220M3
tsoome [Mon, 2 Dec 2019 21:08:59 +0000 (21:08 +0000)]
loader.efi: fix cd boot for cisco C220M3

Reported by: Chris Ross
MFC after: 1w

4 years agoExpand stats(3) man page to add a caveat regarding HZ.
trasz [Mon, 2 Dec 2019 21:03:09 +0000 (21:03 +0000)]
Expand stats(3) man page to add a caveat regarding HZ.

Suggested by: thj
Sponsored by: Klara Inc, Netflix

4 years agoMake use of the stats(3) framework in the TCP stack.
trasz [Mon, 2 Dec 2019 20:58:04 +0000 (20:58 +0000)]
Make use of the stats(3) framework in the TCP stack.

This makes it possible to retrieve per-connection statistical
information such as the receive window size, RTT, or goodput,
using a newly added TCP_STATS getsockopt(3) option, and extract
them using the stats_voistat_fetch(3) API.

See the net/tcprtt port for an example consumer of this API.

Compared to the existing TCP_INFO system, the main differences
are that this mechanism is easy to extend without breaking ABI,
and provides statistical information instead of raw "snapshots"
of values at a given point in time.  stats(3) is more generic
and can be used in both userland and the kernel.

Reviewed by: thj
Tested by: thj
Obtained from: Netflix
Relnotes: yes
Sponsored by: Klara Inc, Netflix
Differential Revision: https://reviews.freebsd.org/D20655

4 years agobhyve: uniform printf format string newlines
vmaffione [Mon, 2 Dec 2019 20:51:46 +0000 (20:51 +0000)]
bhyve: uniform printf format string newlines

Some of the printf statements only use LF to get a newline. However, a CR character is also required for the serial console to print debug logs in a nice way.
Fix those code locations that only use LF, by adding a CR character.

Reviewed by: markj, aleksandr.fedorov@itglobal.com
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22552

4 years agoFix a typo (upto --> up to) and reword to improve word flow.
cy [Mon, 2 Dec 2019 20:39:40 +0000 (20:39 +0000)]
Fix a typo (upto --> up to) and reword to improve word flow.

MFC after: 3 days

4 years agoFix a hang introduced in r351599.
ken [Mon, 2 Dec 2019 19:57:39 +0000 (19:57 +0000)]
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>
MFC after: 1 week

4 years agoDo not initialize the flags field in struct gpiobus_pin from the flags in
ian [Mon, 2 Dec 2019 19:57:20 +0000 (19:57 +0000)]
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 agoRemove "all rights reserved" from copyright after getting a response from
ian [Mon, 2 Dec 2019 16:15:18 +0000 (16:15 +0000)]
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.

4 years agolibzpool: use CFLAGS.lz4.c to build lz4.o and lz4.pico
tsoome [Mon, 2 Dec 2019 15:37:06 +0000 (15:37 +0000)]
libzpool: use CFLAGS.lz4.c to build lz4.o and lz4.pico

Clean up this Makefile a bit.

4 years agorevert r354714 "Boot arm64 kernel using booti command from U-boot."
jhibbits [Mon, 2 Dec 2019 15:07:06 +0000 (15:07 +0000)]
revert r354714 "Boot arm64 kernel using booti command from U-boot."

After discussing with mmel@, it was clear this is insufficient to address
all the needs.  mmel@ will commit his original patch, from
https://reviews.freebsd.org/D13861, and the additions needed from r354714
will be made afterward.

Requested by: mmel
Sponsored by: Juniper Networks, Inc.

4 years agomlx5: Do not try to enable fwdumps if scan space did not responded.
kib [Mon, 2 Dec 2019 14:22:55 +0000 (14:22 +0000)]
mlx5: Do not try to enable fwdumps if scan space did not responded.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agomlx5: Downgrade assert about misbehaving hardware to error message.
kib [Mon, 2 Dec 2019 14:21:40 +0000 (14:21 +0000)]
mlx5: Downgrade assert about misbehaving hardware to error message.

Sponsored by: Mellanox Technologies
MFC after: 1 week

4 years agoFix spurious error from sysrc
dteske [Mon, 2 Dec 2019 05:24:16 +0000 (05:24 +0000)]
Fix spurious error from sysrc

When using sysrc to modify a file, the file should be created silently.
However, with the introduction of SVN r335280, an error of "No such file
or directory" would appear despite everything else working as-expected.

The nature of this spurious error is that SVN r335280 did not check if
the file exists first, before trying to fixup the line-endings in the
file just prior to modification.

PR: bin/240875
Reported by: Jose Luis Duran
MFC after: 3 days

4 years agoFix leading whitespace (spaces->tabs) in comments; no functional change.
ian [Mon, 2 Dec 2019 00:00:26 +0000 (00:00 +0000)]
Fix leading whitespace (spaces->tabs) in comments; no functional change.

4 years agoRewrite gpioiic(4) to use the gpio_pin_* API, and to conform to the modern
ian [Sun, 1 Dec 2019 23:05:20 +0000 (23:05 +0000)]
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.

4 years agopowerpc: Add 'show frame <addr>' to show an arbitrary trap frame
jhibbits [Sun, 1 Dec 2019 21:29:34 +0000 (21:29 +0000)]
powerpc: Add 'show frame <addr>' to show an arbitrary trap frame

This lets us print, for example, the user's trap frame when a panic occurs.
The frame address is given in the backtrace at the trap point, which can
then be passed to 'show frame'.  This is useful for debugging as it can show
inputs that lead to a panic or fault.  It can also be used to print trap
frames from other CPUs that get stuck.

i386 already has a similar command, but no others do.

4 years agoMove most of the gpio_pin_* functions from ofw_gpiobus.c to gpiobus.c so
ian [Sun, 1 Dec 2019 21:27:09 +0000 (21:27 +0000)]
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.

4 years agoMove all ECN related flags from the flags to the flags2 field.
tuexen [Sun, 1 Dec 2019 21:01:33 +0000 (21:01 +0000)]
Move all ECN related flags from the flags to the flags2 field.
This allows adding more ECN related flags in the future.
No functional change intended.

Submitted by: Richard Scheffenegger
Reviewed by: rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22497

4 years agoMake the TF_* flags easier readable by humans by adding leading zeroes
tuexen [Sun, 1 Dec 2019 20:45:48 +0000 (20:45 +0000)]
Make the TF_* flags easier readable by humans by adding leading zeroes
to make them aligned.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22428

4 years agoRemove more needless <sys/tty.h> includes
kevans [Sun, 1 Dec 2019 20:43:37 +0000 (20:43 +0000)]
Remove more needless <sys/tty.h> includes

As part of my journey to make it easy to determine what's relying on tty
bits, remove a couple more. Some of these just outright didn't need it,
while others did rely on <sys/tty.h> pollution for mutex headers.

4 years agoStore the bottom of the shadow chain in OBJ_ANON object->handle member.
kib [Sun, 1 Dec 2019 20:43:04 +0000 (20:43 +0000)]
Store the bottom of the shadow chain in OBJ_ANON object->handle member.

The handle value is stable for all shadow objects in the inheritance
chain.  This allows to avoid descending the shadow chain to get to the
bottom of it in vm_map_entry_set_vnode_text(), and eliminate
corresponding object relocking which appeared to be contending.

Change vm_object_allocate_anon() and vm_object_shadow() to handle more
of the cred/charge initialization for the new shadow object, in
addition to set up the handle.

Reported by: jeff
Reviewed by: alc (previous version), jeff (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
Differrential revision: https://reviews.freebsd.org/D22541

4 years agoThis is an initial step in implementing the new congestion window
tuexen [Sun, 1 Dec 2019 20:35:41 +0000 (20:35 +0000)]
This is an initial step in implementing the new congestion window
validation as specified in RFC 7661.

Submitted by: Richard Scheffenegger
Reviewed by: rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D21798

4 years agoAdd a description for the TCP sysctl variable rfc6675_pipe.
tuexen [Sun, 1 Dec 2019 19:20:28 +0000 (19:20 +0000)]
Add a description for the TCP sysctl variable rfc6675_pipe.
It was introduced by r290122, but no documentation was provided.
This is taken from https://reviews.freebsd.org/D21798, since it
is not related to the feature added there.

Submitted by: Richard Scheffenegger
MFC after: 1 week

4 years agoMake the IPTOS value available to all substate handlers. This will allow
tuexen [Sun, 1 Dec 2019 18:47:53 +0000 (18:47 +0000)]
Make the IPTOS value available to all substate handlers. This will allow
to add support for L4S or SCE, which require processing of the IP TOS
field.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22426

4 years agoIn order for the TCP Handshake to support ECN++, and further ECN-related
tuexen [Sun, 1 Dec 2019 18:05:02 +0000 (18:05 +0000)]
In order for the TCP Handshake to support ECN++, and further ECN-related
improvements, the ECN bits need to be exposed to the TCP SYNcache.
This change is a minimal modification to the function headers, without any
functional change intended.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, rrs@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22436

4 years agoWhen changing the MTU of an SCTP path, not only cancel all ongoing
tuexen [Sun, 1 Dec 2019 17:35:36 +0000 (17:35 +0000)]
When changing the MTU of an SCTP path, not only cancel all ongoing
RTT measurements, but also scheldule new ones for the future.

Submitted by: Julius Flohr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22547

4 years agoUpdate the hostcache also for PTB messages received for SCTP/IPv6.
tuexen [Sun, 1 Dec 2019 16:14:44 +0000 (16:14 +0000)]
Update the hostcache also for PTB messages received for SCTP/IPv6.
The corresponding code for SCTP/IPv4 was introduced in
https://svnweb.freebsd.org/base?view=revision&revision=317597

Submitted by: Julius Flohr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22605

4 years agoSimplify code with strlcpy/strlcat.
delphij [Sun, 1 Dec 2019 08:04:22 +0000 (08:04 +0000)]
Simplify code with strlcpy/strlcat.

MFC after: 2 weeks

4 years agobhyve amd: amdvi_dump_cmds() log the command for which the command completion failed...
anish [Sun, 1 Dec 2019 04:00:08 +0000 (04:00 +0000)]
bhyve amd: amdvi_dump_cmds() log the command for which the command completion failed.  Completion is checked in poll mode although it can be done using interrupts.
No need to log all the commands in command ring but only the last one for which completion failed.

Reported by: np@freebsd.org
Reviewed by: np, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22566

4 years agousb: remove some extraneous tty.h includes
kevans [Sun, 1 Dec 2019 03:56:18 +0000 (03:56 +0000)]
usb: remove some extraneous tty.h includes

4 years agolockmgr: remove more remnants of adaptive spinning
mjg [Sun, 1 Dec 2019 00:35:08 +0000 (00:35 +0000)]
lockmgr: remove more remnants of adaptive spinning

Sponsored by: The FreeBSD Foundation

4 years agotmpfs: use proper macros for permission values in tmpfs_access
mjg [Sun, 1 Dec 2019 00:34:49 +0000 (00:34 +0000)]
tmpfs: use proper macros for permission values in tmpfs_access

While here group them in one var to prevent overy long lines. Perhaps a
general macro of the same sort should be introduced.

Requested by: kib

4 years agoFix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros.
bz [Sun, 1 Dec 2019 00:22:04 +0000 (00:22 +0000)]
Fix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros.

r354748-354750 replaced the KAME macros with m_pulldown() calls.
Contrary to the rest of the network stack m_len checks before m_pulldown()
were not put in placed (see r354748).
Put these m_len checks in place for now (to go along with the style of the
network stack since the initial commits).  These are not put in for
performance but to avoid an error scenario (even though it also will help
performance at the moment as it avoid allocating an extra mbuf; not because
of the unconditional function call).

The observed error case went like this:
(1) an mbuf with M_EXT arrives and we call m_pullup() unconditionally on it.
(2) m_pullup() will call m_get() unless the requested length is larger than
MHLEN (in which case it'll m_freem() the perfectly fine mbuf) and migrate the
requested length of data and pkthdr into the new mbuf.
(3) If m_get() succeeds, a further m_pullup() call going over MHLEN will fail.
This was observed with failing auto-configuration as an RA packet of
200 bytes exceeded MHLEN and the m_pullup() called from nd6_ra_input()
dropped the mbuf.
(Re-)adding the m_len checks before m_pullup() calls avoids this problems
with mbufs using external storage for now.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agotty: implement TIOCNOTTY
kevans [Sat, 30 Nov 2019 20:10:50 +0000 (20:10 +0000)]
tty: implement TIOCNOTTY

Generally, it's preferred that an application fork/setsid if it doesn't want
to keep its controlling TTY, but it could be that a debugger is trying to
steal it instead -- so it would hook in, drop the controlling TTY, then do
some magic to set things up again. In this case, TIOCNOTTY is quite handy
and still respected by at least OpenBSD, NetBSD, and Linux as far as I can
tell.

I've dropped the note about obsoletion, as I intend to support TIOCNOTTY as
long as it doesn't impose a major burden.

Reviewed by: bcr (manpages), kib
Differential Revision: https://reviews.freebsd.org/D22572

4 years agoReduce disk write load in /usr/libexec/save-entropy.
delphij [Sat, 30 Nov 2019 20:06:53 +0000 (20:06 +0000)]
Reduce disk write load in /usr/libexec/save-entropy.

Before this commit, the save-entropy script rotates entropy files
like logs. This involves creating a new file that holds the entropy
and renaming of all existing entropy files. However, the entropy
data do not really need to be kept in a particular order, and
replacing the oldest file is sufficient.

This commit replaces the rotation with a scan in the
[1..entropy_save_num] space that finds the first empty slot, or
the slot of the oldest file, and writes entropy into that slot.

This also fixes an issue that prevents save-entropy from saving
any entropy when there is one non-regular file in any slot as a
side effect.

Based on an earlier patch from peterj@.

PR: 134225
Reported by: peterj
Reviewed by: csprng (cem, markm)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22612

4 years agosmp: cast the read in quiesce_all_critical through void *
mjg [Sat, 30 Nov 2019 19:33:02 +0000 (19:33 +0000)]
smp: cast the read in quiesce_all_critical through void *

Fixes compilation on some 32-bit arm platforms.

Sponsored by: The FreeBSD Foundation

4 years agoAdd an OFWBUS_PNP_INFO() macro for devices that hang directly off the root
ian [Sat, 30 Nov 2019 19:16:44 +0000 (19:16 +0000)]
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).

4 years agoldconfig: fetch hw.machine_arch only once
mjg [Sat, 30 Nov 2019 17:30:01 +0000 (17:30 +0000)]
ldconfig: fetch hw.machine_arch only once

This happens to be of significance with poudriere which runs the script a lot
when installing packages.

4 years agolockprof: use IPI-injecetd fences to fix hangs on stat dump and reset
mjg [Sat, 30 Nov 2019 17:24:42 +0000 (17:24 +0000)]
lockprof: use IPI-injecetd fences to fix hangs on stat dump and reset

The previously used quiesce_all_cpus walks all CPUs and waits until curthread
can run on them. Even on contemporary machines this becomes a significant
problem under load when it can literally take minutes for the operation to
complete. With the patch the stall is normally less than 1 second.

Reviewed by: kib, jeff (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21740

4 years agoAdd a way to inject fences using IPIs
mjg [Sat, 30 Nov 2019 17:22:10 +0000 (17:22 +0000)]
Add a way to inject fences using IPIs

A variant of this facility was already used by rmlocks where IPIs would
enforce ordering.

This allows to elide fences where they are rarely needed and the cost of
IPI (should it be necessary) is cheaper.

Reviewed by: kib, jeff (previous version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21740

4 years agodevfs: introduce a per-dev lock to protect ->si_devsw
mjg [Sat, 30 Nov 2019 16:46:19 +0000 (16:46 +0000)]
devfs: introduce a per-dev lock to protect ->si_devsw

This allows bumping threadcount without taking the global devmtx lock.

In particular this eliminates contention on said lock while using bhyve
with multiple vms.

Reviewed by: kib
Tested by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22548

4 years agotmpfs: add fast path to tmpfs_access for common case lookup
mjg [Sat, 30 Nov 2019 16:41:47 +0000 (16:41 +0000)]
tmpfs: add fast path to tmpfs_access for common case lookup

VEXEC consists of vast majority of all calls and almost all targets have
at least 0111.

4 years agovfs: swap placement between v_type and v_tag
mjg [Sat, 30 Nov 2019 16:40:16 +0000 (16:40 +0000)]
vfs: swap placement between v_type and v_tag

The former is frequently accessed (e.g., in vfs_cache_lookup) and shares the
cacheline with v_usecount, avoidably adding to cache misses during concurrent
lookup. The latter is almost unused and probably can get garbage-collected.

The struct does not change in size despite enum vs char * discrepancy.
On 64-bit archs there used to be 4 bytes padding after v_type giving 480 bytes
in total.

4 years agoCapitalize some user-visible output messages in
bcr [Sat, 30 Nov 2019 14:17:45 +0000 (14:17 +0000)]
Capitalize some user-visible output messages in
the bectl utility.

No functional changes.

Approved by:     imp@
MFC after:     7 days
Differential Revision: https://reviews.freebsd.org/D22330

4 years agoloader.efi: efipart needs better support detecting nested partitions
tsoome [Sat, 30 Nov 2019 09:11:28 +0000 (09:11 +0000)]
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).
Also on MBP with UEFI 1.10

Reported by: Chriss Ross
MFC after: 1w
Differential Revision: https://reviews.freebsd.org/D22553

4 years agoUse strlcat().
delphij [Sat, 30 Nov 2019 05:57:54 +0000 (05:57 +0000)]
Use strlcat().

MFC after: 2 weeks

4 years agoCorrect date and time of George Harrison's death.
grog [Fri, 29 Nov 2019 23:04:45 +0000 (23:04 +0000)]
Correct date and time of George Harrison's death.
  Source: https://www.beatlesbible.com/2001/11/29/george-harrison-dies/

4 years agoRestore swap space accounting for non-anonymous swap objects. This was
jeff [Fri, 29 Nov 2019 19:57:49 +0000 (19:57 +0000)]
Restore swap space accounting for non-anonymous swap objects.  This was
broken in r355082.  Reduce some locking in nearby related object type
checks.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22565

4 years agoAvoid acquiring the object lock if color is already set. It can not be
jeff [Fri, 29 Nov 2019 19:49:20 +0000 (19:49 +0000)]
Avoid acquiring the object lock if color is already set.  It can not be
unset until the object is recycled so this check is stable.  Now that we
can acquire the ref without a lock it is not necessary to group these
operations and we can avoid it entirely in many cases.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22565

4 years agoFix a perf regression from r355122. We can use a shared lock to drop the
jeff [Fri, 29 Nov 2019 19:47:40 +0000 (19:47 +0000)]
Fix a perf regression from r355122.  We can use a shared lock to drop the
last ref on vnodes.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22565

4 years agoIgnore "gpio-hog" nodes when instantiating ofw_gpiobus children. Also,
ian [Fri, 29 Nov 2019 18:05:54 +0000 (18:05 +0000)]
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.

4 years agoUse the VM_MEMATTR macros to describe the MAIR offsets.
andrew [Fri, 29 Nov 2019 16:14:32 +0000 (16:14 +0000)]
Use the VM_MEMATTR macros to describe the MAIR offsets.

Remove the duplicate macros that defined a subset of the VM_MEMATTR values.
While here use VM_MEMATTR macros when filling in the MAIR register.

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

4 years agotty_rel_gone: add locking assertion
kevans [Fri, 29 Nov 2019 14:46:13 +0000 (14:46 +0000)]
tty_rel_gone: add locking assertion

We already assert the lock is held later during tty_rel_free(), but it is
arguably good form to clarify locking expectations here as well at the
top-level that other drivers use.

4 years agoAdd a VN_OPEN_INVFS flag.
kib [Fri, 29 Nov 2019 14:02:32 +0000 (14:02 +0000)]
Add a VN_OPEN_INVFS flag.

vn_open_cred() assumes that it is called from the top-level of a VFS
syscall.  Writers must call bwillwrite() before locking any VFS
resource to wait for cleanup of dirty buffers.

ZFS getextattr() and setextattr() VOPs do call vn_open_cred(), which
results in wait for unrelated buffers while owning ZFS vnode lock (and
ZFS does not use buffer cache).  VN_OPEN_INVFS allows caller to skip
bwillwrite.

Note that ZFS is still incorrect there, because it starts write on an
mp and locks a vnode while holding another vnode lock.

Reported by: Willem Jan Withagen <wjw@digiware.nl>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoIn nfs_lock(), recheck vp->v_data after lock before accessing it.
kib [Fri, 29 Nov 2019 13:55:56 +0000 (13:55 +0000)]
In nfs_lock(), recheck vp->v_data after lock before accessing it.

We might race with reclaim, and then this is no longer a nfs vnode, in
which case we do not need to handle deferred vnode_pager_setsize()
either.

Reported by: rk@ronald.org
PR:  242184
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years ago[PPC] Remove extra \0 char inserted on vty by QEMU
luporl [Fri, 29 Nov 2019 11:34:11 +0000 (11:34 +0000)]
[PPC] Remove extra \0 char inserted on vty by QEMU

Since version 2.11.0, QEMU became bug-compatible with
PowerVM's vty implementation, by inserting a \0 after
every \r going to the guest. Guests are expected to
workaround this issue by removing every \0 immediately
following a \r.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D22171

4 years agokern.mk: -Wno-error=stringop-overflow for gcc due to false positives
rlibby [Fri, 29 Nov 2019 06:25:07 +0000 (06:25 +0000)]
kern.mk: -Wno-error=stringop-overflow for gcc due to false positives

Demote gcc's Wstringop-overflow to Wno-error due to false positives.
E.g. the riscv64 build with gcc 8.3.0 has been failing with this warning
since r355062 [1].  A bug has been filed with gcc [2].  The warning was
first introduced in gcc 7.1 [3]. Hopefully we can avoiding suppressing
the warning in future gcc versions.

[1] https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/16691/
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718
[3] https://gcc.gnu.org/wiki/WarningHistory

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22603

4 years agoktls_session zone: don't need to specify uma trash
rlibby [Fri, 29 Nov 2019 06:25:03 +0000 (06:25 +0000)]
ktls_session zone: don't need to specify uma trash

The use of the uma trash procedures is automatic, there's no need to
pass them explicitly here.

Reviewed by: markj
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22582