The entropy queue stores entropy gathered from environmental sources.
Periodically (every 100ms currently), the random kthread will drain this
queue and mix it into the CSPRNG's entropy pool(s).
The old scheme uses a ring buffer with a mutex to serialize producers,
while the sole consumer, the random kthread, avoids using a mutex on the
basis that no serialization is needed since nothing else is updating the
consumer index. On platforms without total store ordering, however,
this isn't sufficient: when a producer inserts a queue entry and updates
`ring.in`, there is no guarantee that the consumer will see the updated
queue entry upon observing the updated producer index. That is, the
update to `ring.in` may be visible before the updated queue entry is
visible. As a result, we could end up mixing in zero'ed queue entries,
though this race is fairly unlikely in practice given how infrequently
the kthread runs.
The easiest way to fix this is to make the kthread acquire the mutex as
well, and hold it while processing queue entries. However, this might
result in a long hold time if there are many queue entries, and we
really want the hold times to be short, e.g., to avoid delaying
interrupt processing.
We could introduce a proper MPSC queue, but this is probably
overcomplicated for a consumer which runs at 10Hz.
Instead, define two buffers, always with one designated as the "active"
buffer. Producers queue entries in the active buffer, and the kthread
uses the mutex to atomically flip the two buffers, so it can process
entries from the inactive buffer without holding the mutex. This
requires more memory, but keeps mutex hold times short and lets us keep
the queue implementation very simple.
Reviewed by: cem
MFC after: 1 month
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51112
Specifying unit numbers is not needed anymore, and half of those weren't
used anymore in the first place.
Sponsored by: The FreeBSD Foundation
Reviewed by: adrian, markj, emaste
Differential Revision: https://reviews.freebsd.org/D50690
This doesn't register all MIDI devices, for example USB ones, and is not
widely used in the first place. In the future all MIDI devices will
register to sndstat, where we already have defined a MIDI device type,
but we haven't made use of it yet.
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50610
The in-kernel MIDI sequencer is not used anymore, since this is done by
userland applications nowadays. It also contains bugs, and we are not
exactly sure how it works, or if it worked properly in the first place.
Sponsored by: The FreeBSD Foundation
Reviewed by: vishwin, markj
Differential Revision: https://reviews.freebsd.org/D50605
Move functions and variables internal to gpiobus to their own header to
avoid namespace pollution and misuse.
Reviewed by: wulf, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50872
gpiobus_release_pin is only meant to be used internally by gpiobus. Use
gpio_pin_release instead.
This also fixes a memory leak since gpio_pin_get_by_ofw_idx returns a
malloc'd pointer, which gpio_pin_release now frees.
Reviewed by: wulf, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50871
gpiobus_acquire_pin is only meant to be used internally by gpiobus. Use
gpio_pin_acquire instead.
Reviewed by: manu, mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50870
In some cases, drivers may need to acquire an existing gpio_pin_t. With
the functions gpiobus currently exposes, this isn't possible as they
allocate a new pin then acquire that. Add a new gpio_pin_acquire
function which accepts an existing gpiobus_pin structure.
Reviewed by: mmel, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50869
It is a programming error to call this function with an invalid pin.
Also return proper error value on failure.
Suggested by: mmel
Reviewed by: imp, mmel
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50940
Only attach gpiobus when the controller is fully initialized. Children
of gpiobus expect this to be the case.
Reviewed by: mmel, imp, andrew
Approved by: imp (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51088
Some drivers need to postpone the attachment of gpiobus until hardware
init is done. Add a new gpiobus_add_bus function to accommodate this
case.
Suggested by: mmel, andrew
Reviewed by: mmel, imp, andrew
Approved by: imp (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51133
In order to be able to use MODULE_DEVICE_TABLE() with multiple bus
attachments, factor out the bus-specfic MODULE_PNP_INFO() and place
it next to the structure defining the table.
As it turns out bnxt(4) has been using the MODULE_DEVICE_TABLE() with
PCI attachments for the "auxillary" bus so far. That makes little sense.
Define the MODULE_PNP_INFO() to nothing for that. We may consider
pulling these LinucKPI bits in semi-native drivers into LinuxKPI
one day as that route is not really sustainabke.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: imp, dumbbell
Differential Revision: https://reviews.freebsd.org/D51049
Such annotations are obsolete, the compiler tells us when parameters are
unused. No functional change intended.
Reviewed by: cem
MFC after: 1 week
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51114
Entropy queue entries always include the low 32 bits of a CPU cycle
count reading. Introduce a macro for this instead of hard-coding
get_cyclecount() calls everywhere; this is handy for testing purposes
since this way, random(4)'s use of the cycle counter (e.g., the number
of bits we use) can be changed in one place.
No functional change intended.
Reviewed by: cem, delphij
MFC after: 1 week
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51113
They can't be used externally, so it makes no sense to have them in a
header. No functional change intended.
Reviewed by: cem
MFC after: 1 week
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51111
The HWT framework provides infrastructure for hardware-assisted tracing. It
collects detailed information about software execution and records it as
"events" in highly compressed format into DRAM. The events cover information
about control flow changes of a program, whether branches taken or not,
exceptions taken, timing information, cycles elapsed and more. This allows
to reconstruct entire program flow of a given application.
This comes with separate machine-dependent tracing backends for trace
collection, trace decoder libraries and an instrumentation tool.
Reviewed by: kib (sys/kern bits)
Sponsored by: UKRI
Differential Revision: https://reviews.freebsd.org/D40466
This way it is clear which type uses which members.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D51127
When encountering a failed NIC, the mlx5 driver will wait up to 120
secs for the firmware to respond. This timeout is absurdly huge, and
leads to boot times of 40 minutes to over an hour on our servers when a
NIC fails. This is because the driver will attempt to attach to the
failed NIC multiple times (once for each driver loaded after mlx5),
and wait 2 minutes on each attempt. This happens because the mlx5
driver is still the best match for the device. This delay then
triggers watchdog timeouts in our environment, rendering servers
with a failed NIC entirely unbootable without manual intervention.
Note that FW_INIT_WARN_MESSAGE_INTERVAL must also be decreased, as
it must be less than the init timeout.
Reviewed by: kib (initial version, before reducing warn interval)
Sponsored by: Netflix
This was recently added to Linux to improve incremental update support,
as you could previously add Allowed-IPs but not remove without replacing
the whole set (and thus, potentially disrupting existing traffic).
Removal is incredibly straightforward; we'll find it in p_aips first
to ensure that it's actually valid for this peer, then we'll delete it
from the radix tree before we remove the corresponding p_aips entry.
Reviewed by: Jason A. Donenfeld, jhb
Differential Revision: https://reviews.freebsd.org/D50448
We'll re-use these in a future wg_aip_del() to perfectly reconstruct
what we expect to find in a_addr/a_mask.
Reviewed by: ivy, markj (both earlier version), Aaron LI, jhb
Differential Revision: https://reviews.freebsd.org/D50447
The only difference in the wg_aip_add() call after IP validation is the
address family. Just pull that out into a variable and avoid the two
different callsites for wg_aip_add(). A future change will add a new
call for each case to remove an address from the peer, so it's nice to
avoid needing to repeat the logic for two different branches.
Reviewed by: Aaron LI, Jason A. Donenfeld, ivy, jhb, markj
Differential Revision: https://reviews.freebsd.org/D50446
With the old size, the string could easily be truncated, resulting in
non-unique identifiers.
PR: 287679
Reported by: Phil Krylov <phil@krylov.eu>
Reviewed by: kib
MFC after: 2 weeks
The TRNG service will return random data in x3. Use the correct field
when filling the buffer in trng_read.
This driver has not been in any release, so no security advisory is
needed.
Reviewed by: bz
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50979
In the SMCCC TRNG and Errata ABI drivers check if the version
functions are implemented before calling them. Without this the firmware
may complain about an unimplemented function being called.
Reported by: bz
Reviewed by: bz
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50978
Switch to the SMCCC not supported macro in smccc_arch_features. This
shouldn't be a functional change as the value is identical to the PSCI
value it replaces.
Reviewed by: bz, emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50977
The CH343 devices support any baud rate up to 6 Mbps.
PR: 272803
Reviewed by: imp
Tested by: joerg, Tomasz "CeDeROM" CEDRO <tomek_AT_cedro_DOT_info>
Differential Revision: https://reviews.freebsd.org/D46290
Provide flexibility to use format strings for gone_in(). As a side
effect, this removes hardcoded string "Obsolete code will be removed
soon:" from the message, so now it is obligation of the deprecated code to
provide a meaningful message. This required a small adoption of the
existing users: midi, drm2 and le(4). Note that gone_in() is not a public
KPI as it has no sense to use it outside of the FreeBSD tree.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D50783
Pass 0 as the number of indirect descriptors when they are not
supported.
This fixes an issue on the Arm FVP model where we don't negotiate
them, however pass a number of segments greater than
VIRTIO_MAX_INDIRECT. This leads to virtqueue_alloc failing and
virtio_blk failing to attach.
Reviewed by: Harry Moulton <harry.moulton@arm.com>
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D50909
Account for endianness when writing to 24bpp framebuffers. Also create a
vt_fb_mem_wr3 function to avoid code duplication.
Reviewed by: manu, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50843
Make sure there is enough room to write more than one byte.
Reviewed by: manu, imp
Approved by: imp (mentor)
Differential Revision: https://reviews.freebsd.org/D50842