swapoff: don't leak vnode pointer to device
After looking up the device path, we compare the vnode to the vnode of
each swap device. Prior to this change we leaked a vnode reference to
the device we're trying to remove from the swap pool.
Effort: CHERI upstreaming
Reviewed by: kib, markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D61464
(cherry picked from commit 9506d8e0b1788068cbd4c2cbc984cb6ee0dcb0ab)
swapoff: release vnode held since swapon
kern_swapon looks up the proposed swap path and aquires a vnode which is
held (unlocked) throughout the life of the swap device. In the device
case (swapgeom) it was never released in the swapoff path.
Remove an incorrect comment about swapgeom_close being called from
biodone. It is only called directly via swapoff(2) or at the end of the
shutdown path.
Reviewed by: kib, markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D61465
(cherry picked from commit 933f5f616a8a44b7af6cdccecf959ef1e8bab66e)
routing: Sort the nexthops of a group by metric
Sort the nexthops of a group by metric first and by index second,
and keep the metric of each nexthop in the unused storage field.
The nexthops with the lowest metric are the first ones in the array.
The group is sized and compiled from them without visiting every
nexthop for its metric, and the metric argument of these functions
goes away.
decompose_change_notification() walks two groups in their sort
order, so make it use the same comparison.
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D61637
routing: Fix the size of nexthop groups with mixed metrics
calc_min_mpath_slots_fast() selects the nexthops with the lowest
metric through wn[i].nh, but reads their weights from wn[i].storage,
a copy of the weights that is sorted independently of the nexthops.
In a group with more than one metric the weights of the wrong
nexthops are summed, and the weights of all nexthops take part in
the divisibility check, so the group gets a wrong number of slots
and a wrong traffic split.
Calculate the number of slots as the sum of the weights divided by
their greatest common divisor instead. It needs no sorted copy of
the weights and is exact where the old code gave up and used
RIB_MAX_MPATH_WIDTH slots.
The storage field is part of the bytes that identify a group. It is
no longer written by the calculation, so set it to zero.
Reviewed by: glebius
[2 lines not shown]
kobj: convert KOBJOPLOOKUP() to returning pointer to function
This makes KOBJOPLOOKUP() rather more suitable for purposes outside the
macros generated by makeobjops.awk. Of note other callers can lookup
the function on their parent class and call that explicitly.
Reviewed by: zlei
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D48408
snd_dummy: Do not use dummy_chan_io() as mpu401's interrupt handler
dummy_chan_io() runs with sc->lock held, but mpu401 calls its handler
from a callout with no mutex associated with it, so writing to the MIDI
device node caused a panic.
Give mpu401 its own handler, and leave MIDI to mpu401's timer instead of
the PCM callout.
Fixes: e963472ef853 ("snd_dummy: Initial MIDI support")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c8d1c94741231d95964b91910880769019478854)
snd_uaudio: Fix the MIDI TX round-robin
Nothing advances curr_cable, so umidi_bulk_write_callback() only
services cable 0, which is a problem on MIDI devices with more than one
jack.
Fixes: 039477d3e7e7 ("snd_uaudio: Simplify chan->curr_cable calculation in uaudio_bulk_write_callback()")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
(cherry picked from commit f58613868b50dfd6c2adc7128ea60d7b276fdbf1)
snd_uaudio: Do not touch mixer_lock when there is no mixer
Using the mixer lock unconditionally panics because the lock is
uninitialized on devices with no audio interfaces, for instance
MIDI-only keyboards.
Fixes: 9a00e0b8ca56 ("snd_uaudio: Do not use snd_mixer->lock as mixer_lock")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61506
(cherry picked from commit dabd959b17597ad790327020a667ced9a05d7499)
sound: Remove stale midi module dependencies
midi(4) stopped being a module in 45bb10e0ed5a ("sound: Stop building
midi as a module"), so snd_cmi(4) and snd_emu10k1(4) fail to load
because they still depend on it.
Fixes: 45bb10e0ed5a ("sound: Stop building midi as a module")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
(cherry picked from commit 563c2f27e0ffec96a0ddd77b68c7ca6614d704af)
fbt/powerpc: don't instrument the trap entry path
On powerpc an fbt probe is a program interrupt that goes through the
normal trap path, powerpc_interrupt() -> trap() -> dtrace_trap(). A
probe on trap() or powerpc_interrupt() fires again on the way to its
own handler, so it recurses until the kernel stack runs out, and
enabling fbt::trap:entry panics the machine right away.
Skip both functions, like aarch64 and riscv skip their exception
handlers.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61660