Commit Graph

246930 Commits

Author SHA1 Message Date
Conrad Meyer
2c1962aba6 epoch.9: Add missing functions, clean up documentation
Various rototilling.
2019-12-28 01:35:32 +00:00
Mark Johnston
5541eb27d6 Remove some stale comments from the page allocator.
Since r352110 the page lock is not required to wire pages in any
context.
2019-12-27 23:19:21 +00:00
Alexander Motin
2178f45b86 Fix GEOM_UZIP orphanization.
Previous code destroyed softc even with provider still open, that resulted
in panic under load.  This change postpones the free till the final close,
when we know for sure there will be no more I/O requests.

MFC after:	2 weeks
Sponsored by:	iXsystems, Inc.
2019-12-27 21:44:13 +00:00
Hans Petter Selasky
fa6d8b65d3 Implement dump_stats command for usbconfig(8).
This command is useful when debugging USB device issues.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-12-27 20:37:14 +00:00
Hans Petter Selasky
34b0ca243f Implement new libusb v2.0 API function, libusb20_dev_get_stats().
This function is useful when debugging USB device issues.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-12-27 20:35:12 +00:00
Hans Petter Selasky
7082625d97 Make USB statistics per device instead of per bus.
Bump the FreeBSD version due to structure change to
force recompilation of external USB modules.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
2019-12-27 20:29:13 +00:00
Brandon Bergren
12fe21a3d8 [PowerPC] Ignore fortify-source warning in trap vector copy
Due to a bug in clang 9.0.0 source tracking, the trap vector copying will
always trigger a fortify-source warning.

The destination buffers are 0x2f00 bytes, and the bcopy region is 0x2e00
bytes, so there is not an overflow here.

(I have been running with this patch since September.)
2019-12-27 19:58:14 +00:00
Justin Hibbits
741dfd86b3 Fix the powerpc copyout fixup from r356113
Summary:
r356113 used an older patch, which predated the
freebsd_copyout_auxargs() addition.  Fix this by using a private
powerpc_copyout_auxargs() instead, and keep it private to powerpc, not in MI
files.

Reviewed by:	kib, bdragon
Differential Revision:	https://reviews.freebsd.org/D22935
2019-12-27 17:38:25 +00:00
Ed Maste
742654c958 src.conf.5: regen after r356127, disable GPL_DTC by default 2019-12-27 17:12:06 +00:00
Ed Maste
cb9da00eb7 Switch GPL_DTC to default off
We use the BSDL devicetree compiler as long as we have a C++11 compiler.
dtc is not needed as a build tool on the platforms that are still using
GCC 4.2.1 (and it is being disabled very soon, anyhow).

Discussed with:	imp, kevans
2019-12-27 16:59:26 +00:00
Konstantin Belousov
4085590d39 ufs: do not leave non-reclaimed vnodes with zero i_mode around.
After a recent change, vput() relocks even the exclusively locked
vnode before inactivating it.  Before that, UFS could safely
instantiate a vnode for cleared inode, then the last vput() after
ffs_vgetf() noted that ip->i_mode == 0 and recycled.  Now, it is
possible for other threads to note the half-constructed vnode, e.g. to
insert it into hash, which makes other threads to use it despite mode
is zero, before inactivation and reclaim.

Handle the found cases in SU code, by explicitly doing reclaim.
Assert that other places get fully constructed inode from ffs_vgetf(),
which cannot be cleared before dependencies are resolved.

Reported and tested by:	pho
Reviewed by:	mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2019-12-27 16:43:34 +00:00
Ed Maste
d3a549991a src.opts.mk: switch LLVM_LIBUNWIND to opt-out
PowerPC switched to LLVM_LIBUNWIND along with the switch to Clang/LLVM
in r356111.  This leaves only 32-bit Arm and sparc64 not using LLVM's
unwinder, so switch the sense to opt-out.

I elected to list the individual arm MACHINE_ARCHs so future changes
are more clear if LLVM_LIBUNWIND is enabled for one or two but not all
32-bit Arm targets (see PR 233664).
2019-12-27 16:28:43 +00:00
Ed Maste
897dc64400 src.opts.mk: switch LLVM toolchain to opt-out
After PowerPC switched in r356111, the list of targets using LLVM as the
default toolchain is much longer than those not using it.  Switch the
sense of the test to exclude those not using LLVM.

Targets not using LLVM is currently mips, riscv5, and sparc64; work is
in progress to migrate the first two to LLVM.
2019-12-27 15:47:32 +00:00
Ed Maste
da39b3adfb src.conf.5: regenerate after recent changes
r355588 Fix WITHOUT_CLANG build
r355646 Revert r354348
r355943 add LDNS build knob dependency on OPENSSL
r356111 Use LLVM as default toolchain for all PowerPC targets
2019-12-27 15:33:43 +00:00
Mateusz Guzik
3983dc32d7 Plug a warning in read-mostly spinlocks reported by gcc. 2019-12-27 13:37:19 +00:00
Mateusz Guzik
eb9764615d vfs: remove production kernel checks and mp == NULL support from vdrop
1. The only place in the tree which calls getnewvnode with mp == NULL does it
for vp_crossmp which will never execute this codepath. Any vnode which legally
has ->v_mount == NULL is also doomed, which once more wont execute this code.
2. Remove an assertion for v_holdcnt from production kernels. It gets taken care
of by refcount macros in debug kernels.

Any code which would want to pass NULL mp can construct a fake one instead.

Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D22722
2019-12-27 11:26:12 +00:00
Mateusz Guzik
deb2e577a2 mac: use a sleepable rmlock instead of an sx lock
If any non-static modules are loaded (and mac_ntpd tends to be), the lock is
taken all the time al over the kernel. On platforms like arm64 this results in
an avoidable significant performance degradation. Since write-locking is almost
never needed, use a primitive optimized towards read-locking.

Sample result of building the kernel on tmpfs 11 times:
stock           11142.80s user 6704.44s system 4924% cpu 6:02.42 total
patched         11118.95s user 2374.94s system 4547% cpu 4:56.71 total
2019-12-27 11:23:32 +00:00
Mateusz Guzik
1f162fef76 Add read-mostly sleepable locks
To be used when like rmlocks, except when sleeping for readers needs to be
allowed. See the manpage for more information.

Reviewed by:	kib (previous version)
Differential Revision:	https://reviews.freebsd.org/D22823
2019-12-27 11:19:57 +00:00
Brandon Bergren
e99c4e4d64 [PowerPC] Clang powerpcspe build fixes
* Fix a couple of format errors.
* Add some extra compiler flags needed to force clang to build SPE code.
  (These are temporary until the target triple is fixed)
2019-12-27 05:01:13 +00:00
Justin Hibbits
6b45727338 Fix the build from r356113.
Types had changed from when the patch was first created, and a final build
was not done pre-commit.
2019-12-27 04:52:17 +00:00
Justin Hibbits
bcd3c41334 Add a note to UPDATING on the move to clang for powerpc* 2019-12-27 04:42:03 +00:00
Brad Davis
aa06306162 [gpioths] Fix GPIOTHS_DEBUG
Chase the removal of dev from gpioths_dht_readbytes() in r355540.

Reviewed by:	ian
Approved by:	will (mentor)
Differential Revision:	https://reviews.freebsd.org/D22926
2019-12-27 04:11:14 +00:00
Brandon Bergren
b1f8da3843 [PowerPC] Switch to PIC kernel modules on powerpc*
To improve reliability of kernel modules after the clang switch, switch to
-fPIC when building for now.

This bypasses some limitations to the way clang and LLD handle relocations,
and is a more robustly tested compilation regime than the
"static shared object" mode that we were previously attempting to convince
the compiler stack to use.

The kernel linker was recently augmented to be able to handle this mode.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D22798
2019-12-27 04:07:51 +00:00
Justin Hibbits
adea0d6368 Eliminate the last MI difference in AT_* definitions (for powerpc).
Summary:
As a transition aide, implement an alternative elfN_freebsd_fixup which
is called for old powerpc binaries.  Similarly, add a translation to rtld to
convert old values to new ones (as expected by a new rtld).

Translation of old<->new values  is incomplete, but sufficient to allow an
installworld of a new userspace from an old one when a new kernel is running.

Test Plan:
Someone needs to see how a new kernel/rtld/libc works with an old
binary.  If if works we can probalby ship this.  If not we probalby need
some more compat bits.

Submitted by:	brooks
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D20799
2019-12-27 04:07:03 +00:00
Justin Hibbits
e4399d169a [PowerPC64] Starting from FreeBSD 13.0, default to ELFv2 ABI
This changes the LLVM default powerpc64 ABI to ELFv2, if target OS is
FreeBSD >= 13.0

This will also be sent upstream.

Submitted by:	alfredo.junior_eldorado.org.br
Reviewed by:	dim, luporl
Relnotes:	YES
Differential Revision:	https://reviews.freebsd.org/D20383
2019-12-27 04:00:04 +00:00
Justin Hibbits
678da4a274 Use LLVM as default toolchain for all PowerPC targets
This enables LLVM as the default compiler for powerpc, powerpc64, and
powerpcspe, as well as LLD as the default linker for powerpc64.

LLD is not yet ready for prime time for powerpc and powerpcspe, but work is
continuing on it.

Submitted by:	alfredo.junior_eldorado.org.br
Relnotes:	YES
Differential Revision:	https://reviews.freebsd.org/D20378
2019-12-27 03:54:27 +00:00
Jeff Roberson
ff5ce8a7a5 Fix a pair of bugs introduced in r356002. When we reclaim physical pages we
allocate them with VM_ALLOC_NOOBJ which means they are not busy.  For now
move the busy assert for the new page in vm_page_replace into the public
api and out of the private api used by contig reclaim.  Fix another issue
where we would leak busy if the page could not be removed from pmap.

Reported by:	pho
Discussed with:	markj
2019-12-27 01:50:16 +00:00
Alexander Motin
a29df733fa Reimplement gvinum orphanization.
gvinum was the only GEOM class, using consumer nstart/nend fields. Making
it do its own accounting for orphanization purposes allows in perspective
to remove burden of that expensive for SMP accounting from GEOM.

Also the previous implementation spinned in a tight event loop, waiting
for all active BIOs to complete, while the new one knows exactly when it
is possible to close the consumer.

MFC after:	1 month
Sponsored by:	iXsystems, Inc.
2019-12-27 01:36:53 +00:00
Mark Johnston
6b5d8e30f1 Plug some ifaddr refcount leaks.
- Only take an ifaddr ref in in rt_exportinfo() if the caller explicitly
  requests it.  Take care to release it in this case.
- Don't unconditionally take a ref in rtrequest1_fib().  rt_getifa_fib()
  will acquire a reference, in which case we would previously acquire
  two references.
- Stop taking a reference in rtinit1() before calling rtrequest1_fib().
  rtrequest1_fib() will acquire a reference for the RTM_ADD case.

PR:		242746
Reviewed by:	melifaro (previous version)
Tested by:	ghuckriede@blackberry.com
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D22912
2019-12-27 01:12:54 +00:00
Pedro F. Giffuni
afced35c1d msun: drop clause 3 from the Berkeley license.
Per the University California Regents letter, drop the so-called
"advertisement" clause.

Discussed with:	bde, kargl (2017)
Differential Revision:	https://reviews.freebsd.org/D22928
2019-12-27 01:11:26 +00:00
Justin Hibbits
7b6b882fe4 [PowerPC] enable atomic.c in compiler_rt and do not check and forces
lock/lock_free decisions in compiled time

Summary:
Enables atomic.c in compiler_rt and forces clang to not emit a call for runtime
decision about lock/lock_free.  At compiling time, if clang can't decide if
atomic operation can be lock free, it emits calls to external functions  like
`__atomic_is_lock_free`, `__c11_atomic_is_lock_free` and
`__atomic_always_lock_free`, postponing decision to a runtime check.  According
to LLVM code documentation, the mechanism exists due to differences between
x86_64 processors that can't be decided at runtime.

On PowerPC and PowerPCSPE (32 bits), we already know in advance it can't be lock
free, so we force the decision at compile time and avoid having to implement it
in an external library.

This patch was made after 32 bit users testing the PowePC32 bit ISO reported
llvm could not be compiled with in-base llvm due to `__atomic_load8` not
implemented.

Submitted by:	alfredo.junior_eldorado.org.br
Reviewed by:	jhibbits, dim

Differential Revision:	https://reviews.freebsd.org/D22549
2019-12-26 23:06:28 +00:00
Kyle Evans
6795e26b8a cron(8): use proper variable to determine mailer process status
While the mailer is normally opened/set if the mailto is set, this is not
the case if the grandchild actually didn't produce any output. This change
corrects the situation to only attempt to kill/close the mail process if it
was actually opened in the first place.

The reporter initially stumbled on the -n (suppress mail on success) flag
leading to a SIGKILL of the process group, but simultaneously
discovered/reported the behavior with !-n jobs if MAILTO was set and no
output happened.

All of these places that are checking mailto should actually be checking
whether mail is set, so do that for consistency+correctness.

This set of bugs were introduced by r352668.

Submitted by:	sigsys@gmail.com
Reported by:	sigsys@gmail.com
2019-12-26 22:49:19 +00:00
Justin Hibbits
e211e5fec6 powerpc: Move ppc32_runtime_resolve() declaration to the right place
The function is only used in 32-bit kernels, so move the declaration to
!powerpc64.
2019-12-26 22:47:24 +00:00
Rick Macklem
56c049a003 Fix mount_nfs to recognize the NFSv4 specific errors returned by nmount(2).
When mount_nfs calls nmount(2), certain NFSv4 specific errors such as
NFSERR_MINORVERMISMATCH can be returned.
Without this patch, 10021 is reported as an unknown error.
This is not particulcarily serious, but make it difficult for sysadmins
to figure out why the mount attempt is failing.
This patch uses nfsv4_errstr.h to convert 10021 and similar to error strings
that can be printed out.
A positive side effect of this patch is the removal of a reference to
sys/nfsclient/nfs.h, which should no longer be used, since it is
part of the old NFS client.

This patch should only affect reporting of failed mount attempts and not the
semantics of NFS mount attempts.
2019-12-26 22:33:20 +00:00
Dimitry Andric
4f58713dcc Merge commit d3aeac8e2 from llvm git (by Justin Hibbits)
[PowerPC] Only use PLT annotations if using PIC relocation model

  Summary:
  The default static (non-PIC, non-PIE) model for 32-bit powerpc does
  not use @PLT annotations and relocations in GCC.  LLVM shouldn't use
  @PLT annotations either, because it breaks secure-PLT linking with
  (some versions of?) GNU LD.

  Update the available-externally.ll test to reflect that default mode
  should be the same as the static relocation, by using the same check
  prefix.

  Reviewed by:    sfertile
  Differential Revision: https://reviews.llvm.org/D70570

Reviewed by:	jhibbits
Differential Revision: https://reviews.freebsd.org/D22913
2019-12-26 21:20:45 +00:00
Rick Macklem
57fd4aa7e4 Change NFSv4.1 and NFSv4.2 error strings to start with lower case letter.
r356084 added error strings for NFSv4.1 and NFSv4.2, with the first
character capitalized. Since the other error strings were not capitalized
and these strings would usually be imbedded in an error, I decided to
make the first characters lower cased.
No real effect but more consistent.
2019-12-26 21:06:34 +00:00
Scott Long
13d700adec Abstract the locking for PCIe hotplug. It still uses Giant so there's
no functional change yet.
2019-12-26 21:00:06 +00:00
Conrad Meyer
f3bae413e9 random(9): Deprecate random(9), remove meaningless srandom(9)
srandom(9) is meaningless on SMP systems or any system with, say,
interrupts.  One could never rely on random(9) to produce a reproducible
sequence of outputs on the basis of a specific srandom() seed because the
global state was shared by all kernel contexts.  As such, removing it is
literally indistinguishable to random(9) consumers (as compared with
retaining it).

Mark random(9) as deprecated and slated for quick removal.  This is not to
say we intend to remove all fast, non-cryptographic PRNG(s) in the kernel.
It/they just won't be random(9), as it exists today, in either name or
implementation.

Before random(9) is removed, a replacement will be provided and in-tree
consumers will be converted.

Note that despite the name, the random(9) interface does not bear any
resemblance to random(3).  Instead, it is the same crummy 1988 Park-Miller
LCG used in libc rand(3).
2019-12-26 19:41:09 +00:00
Conrad Meyer
3ee1d5bb9d random(4): Simplify RANDOM_LOADABLE
Simplify RANDOM_LOADABLE by removing the ability to unload a LOADABLE
random(4) implementation.  This allows one-time random module selection
at boot, by loader(8).  Swapping modules on the fly doesn't seem
especially useful.

This removes the need to hold a lock over the sleepable module calls
read_random and read_random_uio.

init/deinit have been pulled out of random_algorithm entirely.  Algorithms
can run their own sysinits to initialize; deinit is removed entirely, as
algorithms can not be unloaded.  Algorithms should initialize at
SI_SUB_RANDOM:SI_ORDER_SECOND.  In LOADABLE systems, algorithms install
a pointer to their local random_algorithm context in p_random_alg_context at
that time.

Go ahead and const'ify random_algorithm objects; there is no need to mutate
them at runtime.

LOADABLE kernel NULL checks are removed from random_harvestq by ordering
random_harvestq initialization at SI_SUB_RANDOM:SI_ORDER_THIRD, after
algorithm init.  Prior to random_harvestq init, hc_harvest_mask is zero and
no events are forwarded to algorithms; after random_harvestq init, the
relevant pointers will already have been installed.

Remove the bulk of random_infra shim wrappers and instead expose the bare
function pointers in sys/random.h.  In LOADABLE systems, read_random(9) et
al are just thin shim macros around invoking the associated function
pointer.  We do not provide a registration system but instead expect
LOADABLE modules to register themselves at SI_SUB_RANDOM:SI_ORDER_SECOND.
An example is provided in randomdev.c, as used in the random_fortuna.ko
module.

Approved by:	csprng(markm)
Discussed with:	gordon
Differential Revision:	https://reviews.freebsd.org/D22512
2019-12-26 19:32:11 +00:00
Conrad Meyer
af00898b5d gone_in(9): Trivial string grammar and style cleanups 2019-12-26 18:25:07 +00:00
Kyle Evans
94551ceb0a kbdmux: simplify modevent handler
In the event of a MOD_LOAD failure, MOD_UNLOAD will be invoked to unwind
module load. Most of the reversion in MOD_LOAD can just be deferred to
normal MOD_UNLOAD cleanup, rather than duplicating the effort.

A NULL return of kbd_get_switch in the MOD_UNLOAD handler has been
downgraded from a panic to a successful return, as that certainly just means
that kbd_add_driver failed (not possible at the moment) and we have no work
to do.
2019-12-26 17:25:51 +00:00
Kyle Evans
2899979df9 Revert r355806: kbd drivers: don't double register keyboard drivers
r356087 made it rather innocuous to double-register built-in keyboard
drivers; we now set a flag to indicate that it's been registered and only
act once on a registration anyways. There is no misleading here, as the
follow-up kbd_delete_driver will actually remove the driver as needed now
that the linker set isn't also consulted after kbdinit.
2019-12-26 17:09:36 +00:00
Kyle Evans
f46412c021 kern_cons: add a stub kbdinit for configs with no keyboard/console drivers
A weak symbol here is decidedly cleaner than any #ifdef soup or relocating
kbdinit, the former leading to maintenance required on addition of any
console/keyboard drivers and the latter pushing kbd init bits away from
where they're used.
2019-12-26 15:47:19 +00:00
Kyle Evans
3ed7166aca kbd: merge linker set drivers into standard kbd driver list
This leads to the revert of r355806; this reduces duplication in keyboard
registration and driver switch lookup and leaves us with one authoritative
source for currently registered drivers. The reduced duplication later is
nice as we have more procedure involved in keyboard setup.

keyboard_driver->flags is used to more quickly detect bogus adds/removes.
From KPI consumers' perspective, nothing changes- kbd_add_driver of an
already-registered driver will succeed, and a single kbd_delete_driver will
later remove it as expected. In contrast to historical behavior,
kbd_delete_driver on a driver registered via linker set will now actually
de-register the driver so that it may not be used -- e.g. if kbdmux's
MOD_LOAD handler fails somewhere.

Detection for already-registered drivers in kbd_add_driver has improved, as
the previous SLIST_NEXT(driver) != NULL check would not have caught a driver
that's at the tail end.

kbdinit is now called from cninit() rather than via SYSINIT so that keyboard
drivers are available as early as console drivers. This is particularly
important as cnprobe will, in both syscons and vt, attempt to do any early
configuration of keyboard drivers built-in (see: kbd_configure).

Reviewed by:	imp (earlier version, pre-cninit change)
Differential Revision:	https://reviews.freebsd.org/D22835
2019-12-26 15:21:34 +00:00
Ian Lepore
6f3bd9a660 Add comments to a couple i2c device lines. 2019-12-26 02:22:38 +00:00
Ian Lepore
20cc099585 In kern.pre.mk, split SYSTEM_LD into two variables to avoid duplication in
other files.

Arm and mips systems need to replace the SYSTEM_LD variable because they
need to create intermediate files which are post-processed with objcopy to
create the final .TARGET file. Previously they did so by pasting the full
expansion of SYSTEM_LD with the output filename replaced. This means
changing SYSTEM_LD in kern.pre.mk means you need to chase down anything that
replaces it and figure out how it differs so you can paste your changes in
there too.

Now there is a SYSTEM_LD_BASECMD variable that holds the entire basic kernel
linker command without the input and output files. This will allow arm and
mips makefiles to create their custom versions by refering to
SYSTEM_LD_BASECMD, which then becomes the one place where you have to make
changes to the basic linker command args.

Differential Revision:	https://reviews.freebsd.org/D22921
2019-12-25 22:33:47 +00:00
Rick Macklem
8f2940cec7 Add NFSv4.1 and NFSv4.2 errors to nfsv4_errstr.h.
nfsv4_errstr.h only had strings for NFSv4.0 errors. This patch adds the
errors for NFSv4.1 and NFSv4.2. At this time, this file is not used by
any sources in the tree, so the change is not significant.
I do plan on using nfsv4_errstr.h in a future patch to mount_nfs.c.
Since I am doing this patch so that "minor version mismatch" will be
recognized, I made that string less abbreviated.
2019-12-25 22:25:30 +00:00
Jeff Roberson
cc7ce83ae0 Further reduce the cacheline footprint of fast allocations by duplicating
the zone size and flags fields in the per-cpu caches.  This allows fast
alloctions to proceed only touching the single per-cpu cacheline and
simplifies the common case when no ctor/dtor is specified.

Reviewed by:	markj, rlibby
Differential Revision:	https://reviews.freebsd.org/D22826
2019-12-25 20:57:24 +00:00
Jeff Roberson
376b1ba394 Optimize fast path allocations by storing bucket headers in the per-cpu
cache area.  This allows us to check on bucket space for all per-cpu
buckets with a single cacheline access and fewer branches.

Reviewed by:	markj, rlibby
Differential Revision:	https://reviews.freebsd.org/D22825
2019-12-25 20:50:53 +00:00
Jeff Roberson
3639ac42e5 Fix a bug with _NUMA domains introduced in r339686. When M_NOWAIT is
specified there was no loop termination condition in keg_fetch_slab().

Reported by:	pho
Reviewed by:	markj
2019-12-25 19:26:35 +00:00