]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agocxgbe(4): sysctl to reset the temperature/voltage sensor.
Navdeep Parhar [Sun, 24 Nov 2019 16:40:54 +0000 (16:40 +0000)]
cxgbe(4): sysctl to reset the temperature/voltage sensor.

# sysctl dev.<nexus>.<inst>.reset_sensor=1
# sysctl dev.t6nex.0.reset_sensor=1

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoDon't need giant for these drivers dev nodes.
Warner Losh [Sun, 24 Nov 2019 15:37:19 +0000 (15:37 +0000)]
Don't need giant for these drivers dev nodes.

Also, Giant isn't required to busy / unbusy a device, so drop that too while I'm
here. It's not done elsewhere in the tree and in the future will likely be
handled by a node lock to ensure consistency. Leave Giant in place for attach
and removing childing, as that's actually still needed, even if imperfect.

Remove stale comment about contigmalloc taking Giant and calling w/o the lock
held. Neither of these is still true.

4 years agoHoist locking giant back up into the ioctl handler
Warner Losh [Sun, 24 Nov 2019 15:37:14 +0000 (15:37 +0000)]
Hoist locking giant back up into the ioctl handler

Move the locking back into the ioctl handler. This "fixes" the race where we hve
a hot plug event just after the dropping of Giant in pci_find_dbsf, assuming the
driver doesn't then call anything that drops and picks up Giant again... It's a
little safer since don't think it doesn't, but we lack the tools to know for
sure.

4 years agoFix leak in state machine for commands.
Warner Losh [Sun, 24 Nov 2019 15:24:05 +0000 (15:24 +0000)]
Fix leak in state machine for commands.

When we get a device departed message from the firmware, we send a TARGET_REST
to the device to let the firmware know we're done and as part of the recovery
process. This will abort all the commands. While the documentation says the IOC
is responsible for writing the completion message for all the commands pending
with an aborted status, we sometimes have queued commands for the target that
haven't been completed so are in the INQUEUE state. So, when we later complete
the pending CCB as aborted, these commands are freed and we hit the "state not
busy" panic.

Elsewhere where we dequeue commands, we move the state to BUSY from INQUEUE. Do
that here as well. In talking to Ken, Scott and Justin, they recommended a
series of tests to see if this is 100% safe. Those tests are ongoing, but
preliminary tests suggest this is safe as we see no duplicate completions when
we hit this case at work. We have a machine that has a dodgy powersupply which
usually doesn't apply power to a few drives, but sometimes does when the machine
is under heavy load so we get a rash of the connect / disconnect messages over
half an hour. Without this change, we'd see state not busy panic. With this
change, the drives just annoyingly come and go without affecting the rest of the
machine, but without a complete error injection test suite, it's hard to know if
all edge cases are now covered or not.

Discussed with: scottl, ken, gibbs

4 years agoFix gcc build
Li-Wen Hsu [Sun, 24 Nov 2019 15:03:35 +0000 (15:03 +0000)]
Fix gcc build

We have -Werror=strict-overflow so gcc complains:

In file included from /tmp/obj/workspace/src/amd64.amd64/tmp/usr/include/bitstring.h:36:0,
                 from /workspace/src/tests/sys/sys/bitstring_test.c:34:
/workspace/src/tests/sys/sys/bitstring_test.c: In function 'bit_ffc_at_test':
/workspace/src/sys/sys/bitstring.h:239:5: error: assuming signed overflow does not occur when assuming that (X + c) >= X is always true [-Werror=strict-overflow]
  if (_start >= _nbits) {
     ^

Disable assuming overflow of signed integer will never happen by specifying
-fno-strict-overflow

Sponsored by: The FreeBSD Foundation

4 years agopf: Add endline to all DPFPRINTF()
Kristof Provost [Sun, 24 Nov 2019 13:53:36 +0000 (13:53 +0000)]
pf: Add endline to all DPFPRINTF()

DPFPRINTF() doesn't automatically add an endline, so be consistent and
always add it.

4 years agobsd-family-tree: add several new entries
Eitan Adler [Sun, 24 Nov 2019 07:52:35 +0000 (07:52 +0000)]
bsd-family-tree: add several new entries

Reviewed by: imp, scottl
Differential Revision: https://reviews.freebsd.org/D22529

4 years ago[PowerPC] Fix stack padding issue on ppc32.
Brandon Bergren [Sun, 24 Nov 2019 06:43:03 +0000 (06:43 +0000)]
[PowerPC] Fix stack padding issue on ppc32.

Four bytes of padding are needed in the regular powerpc case to bring the
stack frame size up to a multiple of 16 bytes to meet ABI requirements.

Fixes odd hangs I was encountering during testing.

4 years agocxgbe(4): Update the firmware interface header.
Navdeep Parhar [Sun, 24 Nov 2019 05:37:28 +0000 (05:37 +0000)]
cxgbe(4): Update the firmware interface header.

This allows the driver to be updated for the next firmware without
waiting for it to be released.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

4 years agortld/powerpc: Fix _rtld_bind_start for powerpcspe
Justin Hibbits [Sun, 24 Nov 2019 04:35:29 +0000 (04:35 +0000)]
rtld/powerpc: Fix _rtld_bind_start for powerpcspe

Summary:
We need to save off the full 64-bit register, not just the low 32 bits,
of all registers getting saved off in _rtld_bind_start.  Additionally,
we need to save off the other SPE registers (SPEFSCR and accumulator),
so that their program state is not affected by the PLT resolver.

Reviewed by: bdragon
Differential Revision: https://reviews.freebsd.org/D22520

4 years agoAdd a warning about Giant Locked devices
Warner Losh [Sat, 23 Nov 2019 23:57:26 +0000 (23:57 +0000)]
Add a warning about Giant Locked devices

Add a warning when a device registers with devfs and requests
D_NEEDGIANT. The warning says the device will go away before
13.0. This is needed to flush out the devices in the tree that are
still Giant locked. This warning, or some variant of it, should have
gone into the tree a long time ago...

The intention is to require all devices be converted to not use
automatic giant in this way, or remove any such devices that remain
that we don't have the hardware to test a conversion of.

kbd so far is the only device that can't leave the tree, yet needs
something sensible done to avoid the auto giant lock (even if it is
just doing the wrapping itself). There may be others added to this
list... Any discussions of this topic will take place on arch@.

4 years agoWe don't even need Giant here. It isn't protecting anything internal
Warner Losh [Sat, 23 Nov 2019 23:44:00 +0000 (23:44 +0000)]
We don't even need Giant here. It isn't protecting anything internal
to geom, and nothing we call requires it to be held. It's left over
from a time when the latter wasn't the case. Retire it.

Reviewed in concept: scottl@

4 years agoPush Giant down one layer
Warner Losh [Sat, 23 Nov 2019 23:43:52 +0000 (23:43 +0000)]
Push Giant down one layer

The /dev/pci device doesn't need GIANT, per se. However, one routine
that it calls, pci_find_dbsf implicitly does. It walks a list that can
change when PCI scans a new bus. With hotplug, this means we could
have a race with that scanning. To prevent that, take out Giant around
scanning the list.

However, given that we have places in the tree that drop giant, if
held when we call into them, the whole use of Giant to protect newbus
may be less effective that we desire, so add a comment about why we're
talking it out, and we'll address the issue when we lock newbus with
something other than Giant.

4 years ago[PowerPC] Fix typo in _ctx_start on ppc32
Brandon Bergren [Sat, 23 Nov 2019 23:41:21 +0000 (23:41 +0000)]
[PowerPC] Fix typo in _ctx_start on ppc32

Theoretically, this was breaking the size calculation for the symbol.

Noticed when doing a readthrough.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D22525

4 years ago[PowerPC] Use QEMU-compatible version of SPE accumulator save
Brandon Bergren [Sat, 23 Nov 2019 21:18:55 +0000 (21:18 +0000)]
[PowerPC] Use QEMU-compatible version of SPE accumulator save

Switch from "evaddumiaaw 0,0" to "evmwumiaa 0,0,0" when persisting the
accumulator. This has the benefit of actually being implemented in QEMU
as it is the form Linux uses for the same task.

Both instructions are functionally equivilent, as we are using them for
their side effect of copying the accumulator to GPRs rather than for the
actual math operation that they are performing.

Reviewed by: jhibbits

4 years agolibclang_rt: enable on powerpc*
Dimitry Andric [Sat, 23 Nov 2019 19:35:09 +0000 (19:35 +0000)]
libclang_rt: enable on powerpc*

Summary:
Enable on powerpc64 and in lib/libclang_rt/Makefile change
MACHINE_CPUARCH to MACHINE_ARCH because on powerpc64
MACHINE_ARCH==MACHINE_CPUARCH so the 32-bit library overwrites 64-bit
library during installworld.

This patch doesn't enable any other libclang_rt libraries because they
need to be separately ported.

I have verified that games/julius (which fails on powerpc64 elfv2
without this change because of no libclang_rt profiling library) builds.

Test Plan: Ship it, test on powerpc and powerpcspe

Submitted by: pkubaj
Reviewed by: dim, jhibbits
Differential Revision: https://reviews.freebsd.org/D22425
MFC after: 1 month
X-MFC-With: r353358

4 years agoThe error messages that indicate bugs in 'area' bitstring functions
Doug Moore [Sat, 23 Nov 2019 17:22:36 +0000 (17:22 +0000)]
The error messages that indicate bugs in 'area' bitstring functions
should identify accurately which function exhibited the bug.

Reviewed by: asomers
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22519

4 years agobcm2835_sdhci: fix non-INVARIANTS build
Kyle Evans [Sat, 23 Nov 2019 13:39:47 +0000 (13:39 +0000)]
bcm2835_sdhci: fix non-INVARIANTS build

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

Reported by: Mark Millard

4 years agoarm64/NOTES: add SOC_BRCM_BCM2838
Kyle Evans [Sat, 23 Nov 2019 03:38:26 +0000 (03:38 +0000)]
arm64/NOTES: add SOC_BRCM_BCM2838

This should have been done back when it was added, but it was not. It only
really adds an extra entry for memory mapping bits in bcm2835_vcbus.c, so
nothing too extensive yet.

4 years agobcm2835_dma: rip out the "use_dma" flag, make it non-optional
Kyle Evans [Sat, 23 Nov 2019 01:47:17 +0000 (01:47 +0000)]
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.

4 years agobcm2835_sdhci: "fix" DMA on the RPi 4
Kyle Evans [Sat, 23 Nov 2019 01:46:02 +0000 (01:46 +0000)]
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.

4 years agoAdd explicit SI_SUB_EPOCH
Conrad Meyer [Fri, 22 Nov 2019 23:23:40 +0000 (23:23 +0000)]
Add explicit SI_SUB_EPOCH

Add explicit SI_SUB_EPOCH, after SI_SUB_TASKQ and before SI_SUB_SMP
(EARLY_AP_STARTUP).  Rename existing "SI_SUB_TASKQ + 1" to SI_SUB_EPOCH.

epoch(9) consumers cannot epoch_alloc() before SI_SUB_EPOCH:SI_ORDER_SECOND,
but likely should allocate before SI_SUB_SMP.  Prior to this change,
consumers (well, epoch itself, and net/if.c) just open-coded the
SI_SUB_TASKQ + 1 order to match epoch.c, but this was fragile.

Reviewed by: mmacy
Differential Revision: https://reviews.freebsd.org/D22503

4 years agoDo not retry long ready waits if previous gave nothing.
Alexander Motin [Fri, 22 Nov 2019 21:31:59 +0000 (21:31 +0000)]
Do not retry long ready waits if previous gave nothing.

I have some disks reporting "Logical unit is in process of becoming ready"
for about half an hour before finally reporting failure.  During that time
CAM waits for the readiness during ~2 minutes for each request, that makes
system boot take very long time.

This change reduces wait times for the following requests to ~1 second if
previously long wait for that device has timed out.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agorandom(4): De-export random_sources list
Conrad Meyer [Fri, 22 Nov 2019 20:24:15 +0000 (20:24 +0000)]
random(4): De-export random_sources list

The internal datastructures do not need to be visible outside of
random_harvestq, and this helps ensure they are not misused.

No functional change.

Approved by: csprng(delphij, markm)
Differential Revision: https://reviews.freebsd.org/D22485

4 years agoMark hpt27xx for removal in 13.0; all CAM drivers will be Giant-free by then.
Scott Long [Fri, 22 Nov 2019 20:23:22 +0000 (20:23 +0000)]
Mark hpt27xx for removal in 13.0; all CAM drivers will be Giant-free by then.

Relnotes: yes

4 years agorandom(4): Use ordinary sysctl definitions
Conrad Meyer [Fri, 22 Nov 2019 20:22:29 +0000 (20:22 +0000)]
random(4): Use ordinary sysctl definitions

There's no need to dynamically populate them; the SYSCTL_ macros take care
of load/unload appropriately already (and random_harvestq is 'standard' and
cannot be unloaded anyway).

Approved by: csprng(delphij, markm)
Differential Revision: https://reviews.freebsd.org/D22484

4 years agodhclient: support option 114, default-url ascii
Dave Cottlehuber [Fri, 22 Nov 2019 20:22:16 +0000 (20:22 +0000)]
dhclient: support option 114, default-url ascii

This will enable further automation of HTTP UEFI boot loader support by
providing a specific option for providing the boot URL to FreeBSD.

Documented in:

https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcp-options
https://tools.ietf.org/html/rfc3679

Approved by: emaste
MFC after: 2 weeks
Sponsored by: SkunkWerks, GmbH
Differential Revision: https://reviews.freebsd.org/D22475

4 years agorandom(4): Abstract loader entropy injection
Conrad Meyer [Fri, 22 Nov 2019 20:20:37 +0000 (20:20 +0000)]
random(4): Abstract loader entropy injection

Break random_harvestq_prime up into some logical subroutines.  The goal
is that it becomes easier to add other early entropy sources.

While here, drop pre-12.0 compatibility logic.  loader default configuration
should preload the file as expeced since 12.0.

Approved by: csprng(delphij, markm)
Differential Revision: https://reviews.freebsd.org/D22482

4 years agorandom(4): Remove unused definitions
Conrad Meyer [Fri, 22 Nov 2019 20:18:07 +0000 (20:18 +0000)]
random(4): Remove unused definitions

Approved by: csprng(gordon, markm)
Differential Revision: https://reviews.freebsd.org/D22481

4 years agobcm2835_vcbus: add the *other* rpi4 compat string
Kyle Evans [Fri, 22 Nov 2019 19:56:52 +0000 (19:56 +0000)]
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.

4 years agoMMCCAM: defer release of ccb until we're done with it
Kyle Evans [Fri, 22 Nov 2019 19:54:14 +0000 (19:54 +0000)]
MMCCAM: defer release of ccb until we're done with it

If we've found a device, we attempt to call xpt_action() on a ccb that's
already been released. Simply defer release until after we're done with it.

Reviewed by: imp, scottl
MFC after: 1 week

4 years agorandom/ivy: Provide mechanism to read independent seed values from rdrand
Conrad Meyer [Fri, 22 Nov 2019 19:30:31 +0000 (19:30 +0000)]
random/ivy: Provide mechanism to read independent seed values from rdrand

On x86 platforms with the intrinsic, rdrand is a deterministic bit generator
(AES-CTR) seeded from an entropic source.  On x86 platforms with rdseed, it
is something closer to the upstream entropic source.  (There is more nuance;
a block diagram is provided in [1].)

On devices with rdrand and without rdseed, there is no good intrinsic for
acecssing the good entropic soure directly.  However, the DRBG is guaranteed
to reseed every 8 kB on these platforms.  As a conservative option, on such
hardware we can read an extra 7.99kB samples every time we want a sample
from an independent seed.

As one can imagine, this drastically slows the effective read rate of
RDRAND (a factor of 1024 on amd64 and 2048 on ia32).  Microbenchmarks on AMD
Zen (has RDSEED) show an RDRAND rate of 25 MB/s and Intel Haswell (no
RDSEED) show RDRAND of 170 MB/s.  This would reduce the read rate on Haswell
to ~170 kB/s (at 100% CPU).  random(4)'s harvestq thread periodically
"feeds" from pure sources in amounts of 128-1024 bytes.  On Haswell,
enabling this feature increases the CPU time of RDRAND in each "feed" from
approximately 0.7-6 µs to 0.7-6 ms.

Because there is some performance penalty to this more conservative option,
a knob is provided to enable the change.  The change does not affect
platforms with RDSEED.

[1]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide#inpage-nav-4-2

Approved by: csprng(delphij, markm)
Differential Revision: https://reviews.freebsd.org/D22455

4 years agoRemove xpt_lock mutex.
Alexander Motin [Fri, 22 Nov 2019 18:55:27 +0000 (18:55 +0000)]
Remove xpt_lock mutex.

CAM does not require SIM locks for years, and obviously does not require
it for completely virtual XPT SIM.

MFC after: 2 weeks

4 years agoSchedule the trm(4) driver for removal. It relies on Giant and thus has
Scott Long [Fri, 22 Nov 2019 18:50:53 +0000 (18:50 +0000)]
Schedule the trm(4) driver for removal.  It relies on Giant and thus has
required compat shims in CAM for 12 years.

Relnotes: yes

4 years agoRevert r354909: Make the warning for deprecated NO_ variables an error.
Brooks Davis [Fri, 22 Nov 2019 18:41:09 +0000 (18:41 +0000)]
Revert r354909: Make the warning for deprecated NO_ variables an error.

An unexpectidly large number of ports define NO_MAN (and sometimes the
long-dead NOMAN).  I'll fix ports and then re-commit.

4 years agoMake CAM use root_mount_hold_token() to delay boot.
Alexander Motin [Fri, 22 Nov 2019 18:39:51 +0000 (18:39 +0000)]
Make CAM use root_mount_hold_token() to delay boot.

Before this change CAM used config_intrhook_establish() for this purpose,
but that approach does not allow to delay it again after releasing once.

USB stack uses root_mount_hold() to delay boot until bus scan is complete.
But once it is, CAM had no time to scan SCSI bus, registered by umass(4),
if it already done other scans and called config_intrhook_disestablish().
The new approach makes it work smooth, assuming the USB device is found
during the initial bus scan.  Devices appearing on USB bus later may still
require setting kern.cam.boot_delay, but hopefully those are minority.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoRemove NEEDGIANT from the scsi_sg /dev node. It likely has not been
Scott Long [Fri, 22 Nov 2019 18:18:36 +0000 (18:18 +0000)]
Remove NEEDGIANT from the scsi_sg /dev node.  It likely has not been
needed for many years.

Reported by: imp

4 years agoAdd and document options to allow rpc.lockd and rpc.statd to run in the
Ravi Pokala [Fri, 22 Nov 2019 16:53:30 +0000 (16:53 +0000)]
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.

Submitted by: Alex Burlyga
Reviewed by: bcr, imp
MFC after: 1 week
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D22474

4 years agoSimplify vm_pageout_init_domain() and add a "big picture" comment.
Mark Johnston [Fri, 22 Nov 2019 16:31:43 +0000 (16:31 +0000)]
Simplify vm_pageout_init_domain() and add a "big picture" comment.

Stop subtracting 1024/200 from vmd_page_count/200.  I cannot see how
such precise accounting can make a difference on modern systems.

Add some explanation of what the page daemon does and how it handles
memory shortages.

Reviewed by: dougm
Discussed with: jeff, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22396

4 years agoReclaim memory from UMA if the page daemon is struggling.
Mark Johnston [Fri, 22 Nov 2019 16:31:30 +0000 (16:31 +0000)]
Reclaim memory from UMA if the page daemon is struggling.

Use the UMA reclaim thread to asynchronously drain all caches if
there is a severe shortage in a domain.  Otherwise we only trigger UMA
reclamation every 10s even when the system has completely run out of
memory.

Stop entirely draining the caches when one domain falls below its min
threshold.  In some workloads it is normal for one NUMA domain to end
up being nearly depleted by kernel memory allocations, for example for
the ZFS ARC.  The domainset iterators skip domains below the
vmd_min_free theshold on the first iteration, so we should allow that
mechanism to limit further depletion of the domain's free pages before
taking the extreme step of calling uma_reclaim(UMA_RECLAIM_DRAIN_CPU).

Discussed with: jeff
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22395

4 years agoUpdate the checks in vm_page_zone_import().
Mark Johnston [Fri, 22 Nov 2019 16:31:10 +0000 (16:31 +0000)]
Update the checks in vm_page_zone_import().

- Remove the cnt == 1 check.  UMA passes cnt == 1 when it has disabled
  per-CPU caching.  In this case we might as well just allocate a single
  page and return it to the caller, since the caller is going to do
  exactly that anyway if the UMA cache allocation attempt fails.
- Don't replenish caches if the domain is severely short on free pages.
  With large buckets we may otherwise quickly exacerbate a situation
  where the page daemon is failing to keep up.
- Don't replenish caches if the calling thread belongs to the page
  daemon, which should avoid creating extra memory pressure when it is
  trying to free memory.  Virtually all such allocations while occur in
  the context of laundering, where the laundry thread must allocate
  slabs for various swap and I/O-related UMA zones.

Reviewed by: kib
Discussed with: alc, jeff
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22394

4 years agoRevise the page cache size policy.
Mark Johnston [Fri, 22 Nov 2019 16:30:47 +0000 (16:30 +0000)]
Revise the page cache size policy.

In r353734 the use of the page caches was limited to systems with a
relatively large amount of RAM per CPU.  This was to mitigate some
issues reported with the system not able to keep up with memory pressure
in cases where it had been able to do so prior to the addition of the
direct free pool cache.  This change re-enables those caches.

The change modifies uma_zone_set_maxcache(), which was introduced
specifically for the page cache zones.  Rather than using it to limit
only the full bucket cache, have it also set uz_count_max to provide an
upper bound on the per-CPU cache size that is consistent with the number
of items requested.  Remove its return value since it has no use.

Enable the page cache zones unconditionally, and limit them to 0.1% of
the domain's pages.  The limit can be overridden by the
vm.pgcache_zone_max tunable as before.

Change the item size parameter passed to uma_zcache_create() to the
correct size, and stop setting UMA_ZONE_MAXBUCKET.  This allows the page
cache buckets to be adaptively sized, like the rest of UMA's caches.
This also causes the initial bucket size to be small, so only systems
which benefit from large caches will get them.

Reviewed by: gallatin, jeff
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22393

4 years agoFix locking in vm_reserv_reclaim_contig().
Mark Johnston [Fri, 22 Nov 2019 16:28:52 +0000 (16:28 +0000)]
Fix locking in vm_reserv_reclaim_contig().

We were not properly handling the case where the trylock of the
reservaton fails, in which case we could leak reservation lock.

Introduce a marker reservation to implement precise scanning in
vm_reserv_reclaim_contig().  Before, a race could result in early
termination of the scan in rare situations.  Use the marker's lock to
serialize scans of the partpop queue so that a global marker structure
can be used.  Modify vm_reserv_reclaim_inactive() to handle the presence
of a marker while minimizing the hold time of domain-global locks.

Reviewed by: alc, jeff, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22392

4 years agoFix typos in the cpuset_{get,set}domain() man page.
Mark Johnston [Fri, 22 Nov 2019 16:25:00 +0000 (16:25 +0000)]
Fix typos in the cpuset_{get,set}domain() man page.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoFix off-by-one error in HPA/AMA maximum reporting.
Alexander Motin [Fri, 22 Nov 2019 15:41:47 +0000 (15:41 +0000)]
Fix off-by-one error in HPA/AMA maximum reporting.

Before my refactoring the code reported value as maximum number of sectors,
adding one to the maximum sector number returned by respective command.
While this difference is somewhat confusing, restore previous behavior.

MFC after: 3 days

4 years agoamd: add deprecation warning on program startup
Ed Maste [Fri, 22 Nov 2019 15:06:07 +0000 (15:06 +0000)]
amd: add deprecation warning on program startup

Reviewed by: rgrimes, trasz, kevans, brooks
Discussed with: cy
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22466

4 years agoadd deprecation notice to amd man page
Ed Maste [Fri, 22 Nov 2019 15:04:03 +0000 (15:04 +0000)]
add deprecation notice to amd man page

Clarify the deprecation notice in amd.8.  amd will be removed from the
FreeBSD base system before FreeBSD 13.0.

Reviewed by: rgrimes, trasz, kevans, brooks (all earlier, in D22466)
Discussed with: cy
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

4 years agoInitialize variable bitstr
Li-Wen Hsu [Fri, 22 Nov 2019 10:15:15 +0000 (10:15 +0000)]
Initialize variable bitstr

r354991 removed variable-sized object initializing on defining.  For the safe
reason, manually initialize the members to 0.

Sponsored by: The FreeBSD Foundation

4 years agoFix GCC build.
Li-Wen Hsu [Fri, 22 Nov 2019 10:03:16 +0000 (10:03 +0000)]
Fix GCC build.

Sponsored by: The FreeBSD Foundation

4 years agopowerpc/ptrace: Give ptrace(2) access to SPE registers when available
Justin Hibbits [Fri, 22 Nov 2019 04:34:46 +0000 (04:34 +0000)]
powerpc/ptrace: Give ptrace(2) access to SPE registers when available

SPE registers are already exported in core dumps with the VMX note, so use
the same interface for live access.

Instead of simply guarding out in #ifndef __SPE__ the cpu_feature check, I
chose to keep the check and check against PPC_FEATURE_SPE, on the off-chance
someone decides to run a SPE kernel on a non-SPE device (which is possible,
though highly unlikely, and would be no different from running a MPC85XX
kernel in that instance).

4 years agoFix the pNFS server's reporting of SpaceUsed (va_bytes).
Rick Macklem [Fri, 22 Nov 2019 00:22:55 +0000 (00:22 +0000)]
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.)

MFC after: 2 weeks

4 years agocc_ktr_event_name is used only with KTR
Gleb Smirnoff [Thu, 21 Nov 2019 23:55:43 +0000 (23:55 +0000)]
cc_ktr_event_name is used only with KTR

4 years agoDelete ih_thread. Should have gone in r334170.
Gleb Smirnoff [Thu, 21 Nov 2019 23:55:19 +0000 (23:55 +0000)]
Delete ih_thread.  Should have gone in r334170.

4 years agoAdd variant of root_mount_hold() without allocation.
Alexander Motin [Thu, 21 Nov 2019 21:59:35 +0000 (21:59 +0000)]
Add variant of root_mount_hold() without allocation.

It allows to use this KPI in non-sleepable contexts.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agoMerge commit a751f557d from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:36:46 +0000 (20:36 +0000)]
Merge commit a751f557d from llvm git (by Simon Atanasyan):

  [mips] Set macros for Octeon+ CPU

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit 0d14656b9 from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:35:53 +0000 (20:35 +0000)]
Merge commit 0d14656b9 from llvm git (by Simon Atanasyan):

  [mips] Set __OCTEON__ macros

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit e578d0fd2 from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:32:34 +0000 (20:32 +0000)]
Merge commit e578d0fd2 from llvm git (by Simon Atanasyan):

  [mips] Fix `__mips_isa_rev` macros value for Octeon CPU

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit 3552d3e0f from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:26:34 +0000 (20:26 +0000)]
Merge commit 3552d3e0f from llvm git (by Simon Atanasyan):

  [mips] Add `octeon+` to the list of CPUs accepted by the driver

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit bf996f761 from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:25:12 +0000 (20:25 +0000)]
Merge commit bf996f761 from llvm git (by Simon Atanasyan):

  [mips] Write `AFL_EXT_OCTEONP` flag to the `.MIPS.abiflags` section

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit 3718102d4 from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:23:35 +0000 (20:23 +0000)]
Merge commit 3718102d4 from llvm git (by Simon Atanasyan):

  [mips] Support `octeon+` CPU in the `.set arch=` directive

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoMerge commit 7bed381ea from llvm git (by Simon Atanasyan):
Dimitry Andric [Thu, 21 Nov 2019 20:22:07 +0000 (20:22 +0000)]
Merge commit 7bed381ea from llvm git (by Simon Atanasyan):

  [mips] Implement Octeon+ `saa` and `saad` instructions

  `saa` and `saad` are 32-bit and 64-bit store atomic add instructions.

     memory[base] = memory[base] + rt

  These instructions are available for "Octeon+" CPU. The patch adds
  support for both instructions to MIPS assembler and diassembler and
  introduces new CPU type - "octeon+".

  Next patches will implement `.set arch=octeon+` directive and
  `AFL_EXT_OCTEONP` ISA extension flag support.

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans
MFC after: 1 month
X-MFC-With: r353358

4 years agoChase r344883. ntp is 4.2.8p13.
Cy Schubert [Thu, 21 Nov 2019 20:15:22 +0000 (20:15 +0000)]
Chase r344883. ntp is 4.2.8p13.

MFC after: 3 days

4 years agobitstring: add functions to find contiguous set/unset bit sequences
Eric Joyner [Thu, 21 Nov 2019 19:57:56 +0000 (19:57 +0000)]
bitstring: add functions to find contiguous set/unset bit sequences

Add bit_ffs_area_at and bit_ffc_area_at functions for searching a bit
string for a sequence of contiguous set or unset bits of at least the
specified size.

The bit_ffc_area function will be used by the Intel ice driver for
implementing resource assignment logic using a bitstring to represent
whether or not a given index has been assigned or is currently free.

The bit_ffs_area, bit_ffc_area_at and bit_ffs_area_at functions are
implemented for completeness.

I'd like to add further test cases for the new functions, but I'm not
really sure how to add them easily. The new functions depend on specific
sequences of bits being set, while the bitstring tests appear to run for
varying bit sizes.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: asomers@, erj@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22400

4 years agoInstall bsd.sysdir.mk.
Warner Losh [Thu, 21 Nov 2019 19:54:10 +0000 (19:54 +0000)]
Install bsd.sysdir.mk.

Submitted by: Jung-uk Kim

4 years agobitstring: exit early if _start is past size of the bitstring
Eric Joyner [Thu, 21 Nov 2019 19:36:11 +0000 (19:36 +0000)]
bitstring: exit early if _start is past size of the bitstring

bit_ffs_at and bit_ffc_at both take _start parameters which indicate to
start searching from _start onwards.

If the given _start index is past the size of the bit string, these
functions will calculate an address of the current bitstring which is
after the expected size. The function will also dereference the memory,
resulting in a read buffer overflow.

The output of the function remains correct, because the tests ensure to
stop the loop if the current bitstring chunk passes the stop bitstring
chunk, and because of a check to ensure the reported _value is never
past _nbits.

However, if <sys/bitstring.h> is ever used in code which is checked by
-fsanitize=undefined, or similar static analysis, it can produce
warnings about reading past the buffer size.

Because of the above mentioned checks, these buffer overflows do not
occur as long as _start is less than _nbits. Additionally, by definition
bit_ffs_at and bif_ffc_at should set _result to -1 in any case where the
_start is after the _nbits.

Check for this case at the start of the function and exit early if so,
preventing the buffer read overflow, and reducing the amount of
computation that occurs.

Note that it may seem odd to ever have code that could call bit_ffc_at
or bit_ffs_at with a _start value greater than _nbits. However, consider
a for-loop that used bit_ffs and bit_ffs_at to loop over a bit string
and perform some operation on each bit that was set. If the last bit of
the bit string was set, the simplest loop implementation would call
bit_ffs_at with a start of _nbits, and expect that to return -1. While
it does infact perform correctly, this is what ultimately triggers the
unexpected buffer read overflow.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed by: asomers@, erj@
MFC after: 1 week
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22398

4 years agoNIC KTLS for Chelsio T6 adapters.
John Baldwin [Thu, 21 Nov 2019 19:30:31 +0000 (19:30 +0000)]
NIC KTLS for Chelsio T6 adapters.

This adds support for ifnet (NIC) KTLS using Chelsio T6 adapters.
Unlike the TOE-based KTLS in r353328, NIC TLS works with non-TOE
connections.

NIC KTLS on T6 is not able to use the normal TSO (LSO) path to segment
the encrypted TLS frames output by the crypto engine.  Instead, the
TOE is placed into a special setup to permit "dummy" connections to be
associated with regular sockets using KTLS.  This permits using the
TOE to segment the encrypted TLS records.  However, this approach does
have some limitations:

1) Regular TOE sockets cannot be used when the TOE is in this special
   mode.  One can use either TOE and TOE-based KTLS or NIC KTLS, but
   not both at the same time.

2) In NIC KTLS mode, the TOE is only able to accept a per-connection
   timestamp offset that varies in the upper 4 bits.  Put another way,
   only connections whose timestamp offset has the 28 lower bits
   cleared can use NIC KTLS and generate correct timestamps.  The
   driver will refuse to enable NIC KTLS on connections with a
   timestamp offset with any of the lower 28 bits set.  To use NIC
   KTLS, users can either disable TCP timestamps by setting the
   net.inet.tcp.rfc1323 sysctl to 0, or apply a local patch to the
   tcp_new_ts_offset() function to clear the lower 28 bits of the
   generated offset.

3) Because the TCP segmentation relies on fields mirrored in a TCB in
   the TOE, not all fields in a TCP packet can be sent in the TCP
   segments generated from a TLS record.  Specifically, for packets
   containing TCP options other than timestamps, the driver will
   inject an "empty" TCP packet holding the requested options (e.g. a
   SACK scoreboard) along with the segments from the TLS record.
   These empty TCP packets are counted by the
   dev.cc.N.txq.M.kern_tls_options sysctls.

Unlike TOE TLS which is able to buffer encrypted TLS records in
on-card memory to handle retransmits, NIC KTLS must re-encrypt TLS
records for retransmit requests as well as non-retransmit requests
that do not include the start of a TLS record but do include the
trailer.  The T6 NIC KTLS code tries to optimize some of the cases for
requests to transmit partial TLS records.  In particular it attempts
to minimize sending "waste" bytes that have to be given as input to
the crypto engine but are not needed on the wire to satisfy mbufs sent
from the TCP stack down to the driver.

TCP packets for TLS requests are broken down into the following
classes (with associated counters):

- Mbufs that send an entire TLS record in full do not have any waste
  bytes (dev.cc.N.txq.M.kern_tls_full).

- Mbufs that send a short TLS record that ends before the end of the
  trailer (dev.cc.N.txq.M.kern_tls_short).  For sockets using AES-CBC,
  the encryption must always start at the beginning, so if the mbuf
  starts at an offset into the TLS record, the offset bytes will be
  "waste" bytes.  For sockets using AES-GCM, the encryption can start
  at the 16 byte block before the starting offset capping the waste at
  15 bytes.

- Mbufs that send a partial TLS record that has a non-zero starting
  offset but ends at the end of the trailer
  (dev.cc.N.txq.M.kern_tls_partial).  In order to compute the
  authentication hash stored in the trailer, the entire TLS record
  must be sent as input to the crypto engine, so the bytes before the
  offset are always "waste" bytes.

In addition, other per-txq sysctls are provided:

- dev.cc.N.txq.M.kern_tls_cbc: Count of sockets sent via this txq
  using AES-CBC.

- dev.cc.N.txq.M.kern_tls_gcm: Count of sockets sent via this txq
  using AES-GCM.

- dev.cc.N.txq.M.kern_tls_fin: Count of empty FIN-only packets sent to
  compensate for the TOE engine not being able to set FIN on the last
  segment of a TLS record if the TLS record mbuf had FIN set.

- dev.cc.N.txq.M.kern_tls_records: Count of TLS records sent via this
  txq including full, short, and partial records.

- dev.cc.N.txq.M.kern_tls_octets: Count of non-waste bytes (TLS header
  and payload) sent for TLS record requests.

- dev.cc.N.txq.M.kern_tls_waste: Count of waste bytes sent for TLS
  record requests.

To enable NIC KTLS with T6, set the following tunables prior to
loading the cxgbe(4) driver:

hw.cxgbe.config_file=kern_tls
hw.cxgbe.kern_tls=1

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D21962

4 years agoRewrite iicdev_writeto() to use a single buffer and a single iic_msg, rather
Ian Lepore [Thu, 21 Nov 2019 19:13:05 +0000 (19:13 +0000)]
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 agoRemove two obsolete comments that reference splhigh/splx.
Warner Losh [Thu, 21 Nov 2019 18:49:54 +0000 (18:49 +0000)]
Remove two obsolete comments that reference splhigh/splx.

4 years agoUse kmod.opts.mk to fix standalone build.
John Baldwin [Thu, 21 Nov 2019 18:21:30 +0000 (18:21 +0000)]
Use kmod.opts.mk to fix standalone build.

4 years agoAdd a kmod.opts.mk.
John Baldwin [Thu, 21 Nov 2019 18:14:26 +0000 (18:14 +0000)]
Add a kmod.opts.mk.

This Makefile sets KERN_OPTS.  This permits kernel module Makefiles to
use KERN_OPTS to control the value of variables such as SRCS that are
used by bsd.kmod.mk for KERN_OPTS values that honor WITH/WITHOUT
options for standalone builds.

4 years agoAdd USB ID for Diamond Multimedia BVU195 Display Link device.
Hans Petter Selasky [Thu, 21 Nov 2019 16:42:25 +0000 (16:42 +0000)]
Add USB ID for Diamond Multimedia BVU195 Display Link device.

Submitted by: darius@dons.net.au
PR: 242128
MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoIntroduce bsd.sysdir.mk to consolidate looking for the kernel.
Warner Losh [Thu, 21 Nov 2019 15:59:33 +0000 (15:59 +0000)]
Introduce bsd.sysdir.mk to consolidate looking for the kernel.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D22144

4 years agobsdinstall.8: Fix description of DISTRIBUTIONS environment variable
Mateusz Piotrowski [Thu, 21 Nov 2019 15:54:56 +0000 (15:54 +0000)]
bsdinstall.8: Fix description of DISTRIBUTIONS environment variable

Reviewed by: bcr
Approved by: bcr (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22478

4 years agoObsoleteFiles.inc: add sio(4) leftovers
Niclas Zeising [Thu, 21 Nov 2019 15:38:27 +0000 (15:38 +0000)]
ObsoleteFiles.inc: add sio(4) leftovers

Add the manual page for sio(4) to ObsoleteFiles.inc, so that make delete-all
will remove it.  The manual page was removed together with sio(4) in
r354929.

Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D22477

4 years agoarch.7: document only FreeBSD 11.0 and later
Ed Maste [Thu, 21 Nov 2019 14:23:16 +0000 (14:23 +0000)]
arch.7: document only FreeBSD 11.0 and later

FreeBSD 11 is the earliest supported version and there is no longer a
need to include information about differences present in earlier
releases.

4 years agobcm2835_sdhci: only inspect interrupts we handle
Kyle Evans [Thu, 21 Nov 2019 14:01:44 +0000 (14:01 +0000)]
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.

4 years agoDisable KCSAN within a panic.
Andrew Turner [Thu, 21 Nov 2019 13:59:01 +0000 (13:59 +0000)]
Disable KCSAN within a panic.

The kernel is single threaded at this point and the panic is more
important.

Sponsored by: DARPA, AFRL

4 years agorevert contrib/amd changes accidentally committed with r354950
Ed Maste [Thu, 21 Nov 2019 13:57:30 +0000 (13:57 +0000)]
revert contrib/amd changes accidentally committed with r354950

4 years agorevert r354935 and apply fix for cleandir failure
Ed Maste [Thu, 21 Nov 2019 13:56:16 +0000 (13:56 +0000)]
revert r354935 and apply fix for cleandir failure

This reapplies the RISC-V GNU ld workaround from r354896, r354899, and
354900, along with a fix for the build failure during cleandir.

LINKER_TYPE was not being set during cleandir, resulting in
Malformed conditional (${LINKER_TYPE} == "bfd" && ${MACHINE} == "riscv")
from Cirrus-CI.

PR: 242109
Sponsored by: The FreeBSD Foundation

4 years agoMFV r354383: 10592 misc. metaslab and vdev related ZoL bug fixes
Andriy Gapon [Thu, 21 Nov 2019 13:35:43 +0000 (13:35 +0000)]
MFV r354383: 10592 misc. metaslab and vdev related ZoL bug fixes

illumos/illumos-gate@555d674d5d4b8191dc83723188349d28278b2431
https://github.com/illumos/illumos-gate/commit/555d674d5d4b8191dc83723188349d28278b2431

https://www.illumos.org/issues/10592
  This is a collection of recent fixes from ZoL:
  8eef997679b Error path in metaslab_load_impl() forgets to drop ms_sync_lock
  928e8ad47d3 Introduce auxiliary metaslab histograms
  425d3237ee8 Get rid of space_map_update() for ms_synced_length
  6c926f426a2 Simplify log vdev removal code
  21e7cf5da89 zdb -L should skip leak detection altogether
  df72b8bebe0 Rename range_tree_verify to range_tree_verify_not_present
  75058f33034 Remove unused vdev_t fields

Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>
MFC after: 4 weeks

4 years agoAdd kcsan_md_unsupported from NetBSD.
Andrew Turner [Thu, 21 Nov 2019 13:22:23 +0000 (13:22 +0000)]
Add kcsan_md_unsupported from NetBSD.

It's used to ignore virtual addresses that may have a different physical
address depending on the CPU.

Sponsored by: DARPA, AFRL

4 years agoFix the bus_space functions with KCSAN on arm64.
Andrew Turner [Thu, 21 Nov 2019 13:12:58 +0000 (13:12 +0000)]
Fix the bus_space functions with KCSAN on arm64.

Arm64 doesn't define the bus_space_set_multi_stream and
bus_space_set_region_stream functions. Don't try to define them there.

Sponsored by: DARPA, AFRL

4 years agoFix for style(9): use parentheses around return statements.
Andrew Turner [Thu, 21 Nov 2019 12:29:20 +0000 (12:29 +0000)]
Fix for style(9): use parentheses around return statements.

Reported by: kib
Sponsored by: DARPA, AFRL

4 years agoPort the NetBSD KCSAN runtime to FreeBSD.
Andrew Turner [Thu, 21 Nov 2019 11:22:08 +0000 (11:22 +0000)]
Port the NetBSD KCSAN runtime to FreeBSD.

Update the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime to work in
the FreeBSD kernel. It is a useful tool for finding data races between
threads executing on different CPUs.

This can be enabled by enabling KCSAN in the kernel config, or by using the
GENERIC-KCSAN amd64 kernel. It works on amd64 and arm64, however the later
needs a compiler change to allow -fsanitize=thread that KCSAN uses.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22315

4 years agoMFV r354382,r354385: 10601 10757 Pool allocation classes
Andriy Gapon [Thu, 21 Nov 2019 08:20:05 +0000 (08:20 +0000)]
MFV r354382,r354385: 10601 10757 Pool allocation classes

illumos/illumos-gate@663207adb1669640c01c5ec6949ce78fd806efae
https://github.com/illumos/illumos-gate/commit/663207adb1669640c01c5ec6949ce78fd806efae

10601 Pool allocation classes
https://www.illumos.org/issues/10601
  illumos port of ZoL Pool allocation classes. Includes at least these two
  commits:
  441709695 Pool allocation classes misplacing small file blocks
  cc99f275a Pool allocation classes

10757 Add -gLp to zpool subcommands for alt vdev names
https://www.illumos.org/issues/10757
  Port from ZoL of
  d2f3e292d Add -gLp to zpool subcommands for alt vdev names
  Note that a subsequent ZoL commit changed -p to -P
  a77f29f93 Change full path subcommand flag from -p to -P

Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Portions contributed by: Håkan Johansson <f96hajo@chalmers.se>
Portions contributed by: Richard Yao <ryao@gentoo.org>
Portions contributed by: Chunwei Chen <david.chen@nutanix.com>
Portions contributed by: loli10K <ezomori.nozomu@gmail.com>
Author: Don Brady <don.brady@delphix.com>

11541 allocation_classes feature must be enabled to add log device

illumos/illumos-gate@c1064fd7ce62fe763a4475e9988ffea3b22137de
https://github.com/illumos/illumos-gate/commit/c1064fd7ce62fe763a4475e9988ffea3b22137de

https://www.illumos.org/issues/11541
  After the allocation_classes feature was integrated, one can no longer add a
  log device to a pool unless that feature is enabled. There is an explicit check
  for this, but it is unnecessary in the case of log devices, so we should handle
  this better instead of forcing the feature to be enabled.

Author: Jerry Jelinek <jerry.jelinek@joyent.com>

FreeBSD notes.
I faithfully added the new -g, -L, -P flags, but only -g does something:
vdev GUIDs are displayed instead of device names.  -L, resolve symlinks,
and -P, display full disk paths, do nothing at the moment.
The use of special vdevs is backward compatible for read-only access, so
root pools should be bootable, but exercise caution.

MFC after: 4 weeks

4 years agoInclude MACHINE in the which variable selection to use section.
Warner Losh [Thu, 21 Nov 2019 06:48:30 +0000 (06:48 +0000)]
Include MACHINE in the which variable selection to use section.

4 years agoAdd table for MACHINE_CPUARCH
Warner Losh [Thu, 21 Nov 2019 06:44:19 +0000 (06:44 +0000)]
Add table for MACHINE_CPUARCH

Add table and also some additional verbage of which one to use.

4 years agoRevert r354896, r354899, r354900:
Glen Barber [Thu, 21 Nov 2019 04:12:08 +0000 (04:12 +0000)]
Revert r354896, r354899, r354900:
 Fix build.

Sponsored by: Rubicon Communications, LLC (netgate.com)

4 years agomark arm.arm (v4/v5) kernels as NO_UNIVERSE for now
Ed Maste [Thu, 21 Nov 2019 03:10:02 +0000 (03:10 +0000)]
mark arm.arm (v4/v5) kernels as NO_UNIVERSE for now

r354290 removed arm.arm from universe, but arm.arm kernels were still
found and built during the kernel stage.  I'm not aware of a better way
to address this at the moment, but since there aren't many arm.arm
kernels anyhow just add an explicit NO_UNIVERSE to them.

Reported by: rpokala

4 years agobcm2835_sdhci: clean up DMA segments in error handling path
Kyle Evans [Thu, 21 Nov 2019 02:49:41 +0000 (02:49 +0000)]
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.

4 years agobcm2835_sdhci: roll back r354823
Kyle Evans [Thu, 21 Nov 2019 02:47:55 +0000 (02:47 +0000)]
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.

4 years agoRevert r354930: wrong diff, right message.
Kyle Evans [Thu, 21 Nov 2019 02:44:05 +0000 (02:44 +0000)]
Revert r354930: wrong diff, right message.

4 years agobcm2835_sdhci: clean up DMA segments in error handling path
Kyle Evans [Thu, 21 Nov 2019 02:41:22 +0000 (02:41 +0000)]
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.

4 years agoRemove sio(4).
Gleb Smirnoff [Thu, 21 Nov 2019 01:24:49 +0000 (01:24 +0000)]
Remove sio(4).
It had been disconnected from build in r181233 in 2008.

Reviewed by: imp

4 years agoAvoid relying on pollution from libcasper.h.
Mark Johnston [Thu, 21 Nov 2019 00:17:14 +0000 (00:17 +0000)]
Avoid relying on pollution from libcasper.h.

Reported by: sjg
Sponsored by: The FreeBSD Foundation

4 years agoAdd --esp/-E argument to print the currently booted ESP
Warner Losh [Wed, 20 Nov 2019 23:58:36 +0000 (23:58 +0000)]
Add --esp/-E argument to print the currently booted ESP

Add code to decode the BootCurrent and BootXXXX variable it points at
to deduce the ESP used to boot the system. By default, it prints the
path to that device. With --unix-path (-p) it will instead print the
current mount point for the ESP, if any (or an error). With
--device-path (-d) it wil print the UEFI device path for the ESP.

Note: This is the best guess based on the UEFI variables. If the ESP
is part of a gmirror, etc, that won't be reported. If by some weird
chance there was a complicated series of chain boots, this may not be
what you want. For setups that don't add layers on top of the raw
devices, it is accurate.

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

4 years agoMFV 354917, 354918, 354919
Pedro F. Giffuni [Wed, 20 Nov 2019 23:56:20 +0000 (23:56 +0000)]
MFV 354917, 354918, 354919
openresolv: update to version 3.9.2

MFC after: 3 weeks

4 years agoCreate /etc/os-release file.
Warner Losh [Wed, 20 Nov 2019 23:45:31 +0000 (23:45 +0000)]
Create /etc/os-release file.

Each boot, regenerate /var/run/os-release based on the currently running
system. Create a /etc/os-release symlink pointing to this file (so that this
doesn't create a new reason /etc can not be mounted read-only).

This is compatible with what other systems do and is what the sysutil/os-release
port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
implement this natively as well. The complete standard can be found at
https://www.freedesktop.org/software/systemd/man/os-release.html

Moving this to the base solves both the non-standard location problem with the
port, as well as the lack of update of this file on system update.

Bump __FreeBSD_version to 1300060

PR: 238953
Differential Revision:  https://reviews.freebsd.org/D22271

4 years agoImport openresolv 3.9.0
Pedro F. Giffuni [Wed, 20 Nov 2019 22:13:14 +0000 (22:13 +0000)]
Import openresolv 3.9.0

More information at: https://roy.marples.name/projects/openresolv

4 years agoStandardize EFI's ESP mount point.
Warner Losh [Wed, 20 Nov 2019 21:06:29 +0000 (21:06 +0000)]
Standardize EFI's ESP mount point.

Mount the UEFI ESP on /boot/efi. No current system uses this by default, but
there are many ad-hoc schemes that do this in /efi or /esp or /uefi and adding a
new directory at the top-level would have a much higher likelihood of
collision. Document this in /etc/mtree/BSD.root.mtree and create EFIDIR and
related variables in bsd.own.mk.

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