Commit Graph

294984 Commits

Author SHA1 Message Date
hannken f9f51a4a90 Remove now unused genfs_nolock(), genfs_nounlock() and genfs_noislocked(). 2022-03-19 13:52:45 +00:00
hannken f0222b464b Switch spec_vnodeop vector to real vnode locking, VV_LOCKSWORK now. 2022-03-19 13:52:11 +00:00
hannken afc8fd54cd Fix locking after opendisk(), VOP_IOCTL() needs an unlocked vnode,
vn_rdwr() needs flag IO_NODELOCKED.
2022-03-19 13:51:35 +00:00
hannken ce218897d7 Lock vnode across VOP_OPEN. 2022-03-19 13:50:02 +00:00
hannken 0c2cd91233 Lock vnode across VOP_OPEN/VOP_IOCTL/VOP_CLOSE. 2022-03-19 13:49:21 +00:00
hannken f38668ff6c Switch MFS device node to real vnode locking, VV_LOCKSWORK now. 2022-03-19 13:48:42 +00:00
hannken 54ba77bc44 As FSTRANS is part of VOP_*LOCK() since June 4, 2017 the vdead_check()
from union_lock() is no longer needed.

Adapt union_lock() to the recent addition of upgrade or downgrade.

VV_LOCKSWORK now.
2022-03-19 13:48:04 +00:00
riastradh 8c13a1c7ef rnd(9): Omit needless locks in various HWRNG drivers.
Now that the rnd(9) API guarantees serial callbacks, we can simplify
everything a bit more.

(Some drivers like hifn(4) and sun8icrypto(4) still use locks to
coordinate with other parts of the driver to submit requests to and
process responses from the device.)
2022-03-19 11:55:03 +00:00
riastradh 54916e3adb rnd(9): Document the serial use of rndsource callbacks.
This simplifies the rndsource API -- no need to lock, unless you're
also coordinating with other driver logic like concurrent
opencrypto(4) requests that share device requests.
2022-03-19 11:54:53 +00:00
riastradh 574989065b tegra124_car(4): Attach rndsource synchronously.
It looks like the original motivation for deferring to
config_interrupts was to wait until softint_establish worked.  But
this no longer needs to use softints to deliver the entropy, so
that's moot.

Doing this synchronously gives us a better chance for more entropy
earlier.
2022-03-19 11:37:17 +00:00
riastradh 698c20237e rnd(9): Adjust IPL of locks used by rndsource callbacks.
These no longer ever run from hard interrupt context or with a spin
lock held, so there is no longer any need to have them at IPL_VM to
block hard interrupts.  Instead, lower them to IPL_SOFTSERIAL.
2022-03-19 11:37:05 +00:00
riastradh 09845d8340 tegra124_car(4): No need for rnd lock -- delete it.
This only ever reads from a single device register, so no need to
serialize access.

XXX This should really have a hardware-specific health test, but I
can't find any documentation on the underlying physical entropy
source.
2022-03-19 11:36:53 +00:00
riastradh 084d57f7d6 meson_rng(4): No need for lock -- delete it.
We only ever read a single register at a time; no exclusive access or
serialization needed.

XXX This driver should have some kind of hardware-specific health
test -- is there documentation anywhere for what this RNG actually
is?
2022-03-19 11:36:43 +00:00
riastradh 828f07b88f usbdi(9): Fix usbd_get_no_alts.
This incorrectly rejected the configuration as invalid if any
descriptor is not large enough to be interface descriptors.

Instead, it should reject the configuration only if any descriptor is
not large enough to be a _descriptor_, or if any interface-type
descriptor is not large enough to be an interface descriptor, but
skip over descriptors of other types even if they're smaller than
interface descriptors.

Candidate fix for PR kern/56762.
2022-03-19 10:05:52 +00:00
skrll 0f687ae99b Improve a VPRINTF 2022-03-19 09:55:30 +00:00
skrll fbc3b9a854 Alight code re-organisation so it better matches the VPRINTF headings
it is under. NFCI.
2022-03-19 09:54:25 +00:00
skrll 8003e477b5 Slight code re-organisation. NFCI. 2022-03-19 09:53:18 +00:00
riastradh 18cd690f6a clockrnd(9): Use atomic_load_relaxed for struct clockrnd::needed.
This may be set concurrently by clockrnd_get, so let's match the
atomic_store_relaxed and avoid the appearance of data races.
2022-03-18 23:37:14 +00:00
riastradh a0fb64e97e entropy(9): Establish the softint a little earlier.
Just need to wait until softint_establish and high-priority xcalls
will work, no later than that.  Doing this earlier gives us slightly
more of a chance to ensure cprng_fast and ssp get entropy from
hardware RNG devices that rely on interrupts.
2022-03-18 23:37:06 +00:00
riastradh f646e78fb1 sun8icrypto(4): Do self-test and first RNG draw synchronously.
If the self-test fails, disable everything else at boot -- don't just
leave it to the operator to notice and do something.

This way we get entropy earlier at boot, before threads start and
before the first things in the kernel that draw from it (cprng fast
init, ssp init).
2022-03-18 23:36:57 +00:00
riastradh ee48cc646f sun8icrypto(4): Attach rndsource as RND_TYPE_RNG.
Previously this was attached as RND_TYPE_UNKNOWN, at a time when the
kernel assumed _any_ RNG-type rndsource produced independent uniform
random bits and subjected it to automatic tests that would fail with
high probability for many other distributions.  But sun8icrypto(4) is
very nonuniform (probably yields consecutive samples of a ring
oscillator, which are very much not independent).

Now the kernel no longer makes this assumption, so it is valid to
label this as what it is -- a hardware RNG.  We should ideally still
have better information from the vendor about what's going on under
the hood before enabling nonzero entropy for it.  But at least we can
label its type accurately.
2022-03-18 23:36:42 +00:00
riastradh ddaf907b4f sun8icrypto(4): Split out interrupt and thread locks.
No need to block interrupts while we're going through all the data
structures -- only need to block interrupts for the handoff from
interrupt handler to lower-priority logic.
2022-03-18 23:35:48 +00:00
riastradh 5901ceaa11 getrandom(2): Fix return value checks in automatic tests.
The syscall only guarantees up to 256 bytes in a single go -- if
interrupted, it might return short, but if the caller requested at
least 256 bytes it will definitely return 256 bytes.
2022-03-18 23:35:37 +00:00
riastradh e2caead148 entropy(9): Count dropped or truncated interrupt samples. 2022-03-18 23:35:28 +00:00
riastradh 4b3ca98c58 entropy(9): Reduce global entropy lock from IPL_VM to IPL_SOFTSERIAL.
This is no longer ever taken in hard interrupt context, so there's no
longer any need to block interrupts while doing crypto operations on
the global entropy pool.
2022-03-18 23:35:19 +00:00
riastradh e4ceb72edc entropy(9): Request entropy after the softint is enabled.
Otherwise, there is a window during which interrupts are running, but
the softint is not, so if many interrupts queue (low-entropy) samples
early at boot, they might get dropped on the floor.  This could
happen, for instance, with a PCI RNG like ubsec(4) or hifn(4) which
requests entropy and processes it in its own hard interrupt handler.
2022-03-18 23:35:07 +00:00
riastradh ceeae26ca4 entropy(9): Use the early-entropy path only while cold.
This way, we never take the global entropy lock from interrupt
handlers (no interrupts while cold), so the global entropy lock need
not block interrupts.

There's an annoying ordering issue here: softint_establish doesn't
work until after CPUs have been detected, which happens inside
configure(), which is also what enables interrupts.  So we have no
opportunity to softint_establish the entropy softint _before_
interrupts are enabled.

To work around this, we have to put a conditional into the interrupt
path, and go out of our way to process any queued samples after
establishing the softint.  If we just made softint_establish work
early, like percpu_create does now, this problem would go away and we
could delete a bit of logic here.

Candidate fix for PR kern/56730.
2022-03-18 23:34:56 +00:00
riastradh 0107837f03 entropy(9): Create per-CPU state earlier.
This will make it possible to use it from interrupts as soon as they
start, which means the global entropy pool lock won't have to block
interrupts.
2022-03-18 23:34:44 +00:00
riastradh a9f92eb79d drm: In ww_mutex_unlock, do lockdebug check first.
This way we get a full lockdebug dump when LOCKDEBUG is enabled,
instead of just the panic message (which includes the lock address
you could pass to `show lock' in ddb, but let's get the dump by
default even if you don't enter ddb).

Also in the KASSERT print the mutex.
2022-03-18 23:33:41 +00:00
riastradh c08c8e5f45 dwc2: Use getticks(), not hardclock_ticks. 2022-03-18 23:32:59 +00:00
riastradh a7f1d9045b drm: Use getticks(), not hardclock_ticks. 2022-03-18 23:32:49 +00:00
riastradh d0b4496362 old drm: Use getticks(), not hardclock_ticks.
Should delete this code, no idea if it even still compiles.
2022-03-18 23:32:41 +00:00
riastradh acef9115d3 net80211: Use getticks(), not hardclock_ticks.
Less extern in .c this way too.
2022-03-18 23:32:24 +00:00
riastradh 4e7bd1dfb2 osnet: Delete dead #if 0 code using hardclock_ticks. 2022-03-18 23:32:14 +00:00
reinoud b660056cbc Replace the variable field data[0] to data[1] to avoid undefined behaviour. 2022-03-18 16:06:18 +00:00
uwe b696d1634c virtio_pci_bus_space_write_8: don't use bus_space_write_8.
The standard says:

  4.1.3.1 Driver Requirements: PCI Device Layout

  For device configuration access, the driver MUST use ... 32-bit
  wide and aligned accesses for ... 64-bit wide fields.  For 64-bit
  fields, the driver MAY access each of the high and low 32-bit parts
  of the field independently.

NB: "MAY" in this text refers to "independently" (i.e. the order of
accesses) not "32-bit" (which is restricted by the earlier "MUST").

Note also that virtio_{read,write}_device_config_8 in virtio.c already
uses two 32-bit accesses.
2022-03-17 23:05:01 +00:00
uwe 5c30743af4 virtio_pci.c: use PCI_BAR macro instead of open-coding it. 2022-03-17 22:53:13 +00:00
riastradh fa903bde0e x86: Revert previous syscall biglock slippage attribution.
The attribution in userret is good enough as is, because the stack
trace on panic shows the syscall number in the trap frame, so no need
to put extra cost in the syscall entry logic even under DIAGNOSTIC.
2022-03-17 22:22:49 +00:00
andvar ef3e3cb582 revert broken to borken, it is used spelling in BSD and "tastes better that way". 2022-03-17 08:08:03 +00:00
mrg 8e5ae65545 apply some more consistency in platform checks, collapse some
checks, and enable pigz on arm64eb.
2022-03-17 06:24:30 +00:00
mrg baae5e2cfb enable ZFS on arm64eb. works witih basic testing.
(dtrace does not.)
2022-03-17 06:20:47 +00:00
mrg 9dbd2329f9 add some register bits for interrupt control/error status.
(not yet used.)
2022-03-17 05:45:23 +00:00
riastradh a820d532b6 entropy(9): Forbid entropy_extract in hard interrupt context.
With a little additional work, this will let us reduce the global
entropy pool lock so it never blocks interrupts.
2022-03-16 23:56:55 +00:00
riastradh 8ad5456761 cprng(9): Forbid use in hard interrupt context.
May need access to the global entropy pool (infrequently).  This way
the global entropy pool lock can be lowered to IPL_SOFTSERIAL too,
with a little additional work.
2022-03-16 23:56:33 +00:00
riastradh 7e68a8b30e i915: Avoid freeing anything under a spin lock. 2022-03-16 23:32:52 +00:00
andvar db54414c68 s/paniced/panicked/ and s/borken/broken/ in comments. 2022-03-16 20:31:01 +00:00
andvar 65f618399e s/watchog/watchdog in comment and log message, one wording fix in comment. 2022-03-16 10:08:02 +00:00
andvar ab0c0eb001 s/frmae/frame/ 2022-03-16 09:48:23 +00:00
yamaguchi a4f5ddd75f ixl: Added support for Intel ethernet X710-T*L 2022-03-16 05:26:37 +00:00
yamaguchi fd26d06206 Regen. 2022-03-16 05:23:51 +00:00