virtio_random: defer first enqueue until after DRIVER_OK
According to the virtio spec:
> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.
DRIVER_OK isn't set until after attach completes, so defer the first
enqueue. We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.
Tested with q35 virtio-random, which still works.
Reported by: llm-postcr
Reviewed by: kfv, markj
Fixes: f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
[2 lines not shown]
virtio_random: stop on detach, don't poll
If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead. This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
virtio_pci_modern: enable virtqueues before completing attach
Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll. This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached. The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.
This can be reproduced with a qemu invocation like so:
qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
-drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
-device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
-object rng-random,id=rng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=rng0,bus=rp1 \
-display curses
[5 lines not shown]
virtio_random: avoid using vtrnd_detach in the failure path
On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().
We don't have that many resources to free, so just inline those. This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
[libc] Return the written character from putc, fputc and putchar (#239980)
All three returned zero on success. C requires the character written,
taken as an unsigned char and converted to int. A caller comparing the
result against the character it passed reads zero as a failed write.
m4's configure probes ftello by writing a byte after a read reaches end
of file and checking that putc returns it. It concluded LLVM-libc had a
Solaris bug it does not have, then failed to compile the workaround it
selected.
Assisted-by: Claude
virtio_random: defer first enqueue until after DRIVER_OK
According to the virtio spec:
> The driver MUST NOT send any buffer available notifications to the
> device before setting DRIVER_OK.
DRIVER_OK isn't set until after attach completes, so defer the first
enqueue. We haven't found any problems as a result of this to the best
of my knowledge: q35 and other devices that we *have* been used with
will apparently check when we go DRIVER_OK.
Tested with q35 virtio-random, which still works.
Reported by: llm-postcr
Reviewed by: kfv, markj
Fixes: f1c5a2e3a62505 ("virtio_random: Pipeline fetching the data")
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
[2 lines not shown]
virtio_pci_modern: enable virtqueues before completing attach
Most of our drivers setup interrupt(s) and virtqueues are enabled at
that time, but nothing will currently enable them for devices that we're
only going to poll. This most notably affects virtio-random, and the
problem can be observed with qemu's q35 emulation and a random device
attached. The q35 implementation ignores the ring unless it's enabled,
so vtrnd_harvest() will consistently EAGAIN rather than contribute
anything of value, but with this patch it becomes functional.
This can be reproduced with a qemu invocation like so:
qemu-system-x86_64 -machine q35,accel=tcg -cpu max -smp 2 -m 2G \
-drive file=FreeBSD-16.0-CURRENT-amd64-ufs.qcow2,if=virtio \
-device pcie-root-port,id=rp1,bus=pcie.0,chassis=1 \
-object rng-random,id=rng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=rng0,bus=rp1 \
-display curses
[5 lines not shown]
virtio_random: stop on detach, don't poll
If the device is hung, then polling will block the detach and hang us.
Stop it and drain the queue instead. This fixes a hang on detach in
some circumstances without the upcoming virtio_pci_modern fix.
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
(cherry picked from commit cce522853aae3da45b131c2522dd2510edf083e7)
virtio_random: avoid using vtrnd_detach in the failure path
On the off chance that we discover more than one virtio-random device,
the second one will deregister the global instance or trip an invariant
when it fails to attach and calls vtrnd_detach().
We don't have that many resources to free, so just inline those. This
is purely a hygiene thing, we haven't seen an instance of this in the
wild (to my knowledge).
Reviewed by: bnovkov, kfv
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
(cherry picked from commit 26ba71f73e8914ecd9e5b1e7bb864fee41158d04)
linux: Bound native getdents and getdents64 batches
linux_getdents() and linux_getdents64() round their native read size up
to DEV_BSIZE before converting entries. For an unaligned caller buffer,
the native batch can contain more entries than fit in the Linux buffer.
Conversion then returns EINVAL even after copying complete entries,
and the native read has already advanced the directory position.
For counts of at least DEV_BSIZE, use min(args->count, MAXBSIZE) instead.
A 768-byte request, such as rustix's initial directory read, now uses a
768-byte native buffer rather than 1024. The converted Linux dirent and
dirent64 records are no larger than their native counterparts, so the
whole translated batch fits. Returning a short batch is allowed, and
consuming the whole native batch avoids needing to rewind the directory
position.
Keep the existing sizing for counts below DEV_BSIZE. This fixes the
oversized-batch case in both getdents interfaces, including legacy
getdents for 32-bit and 64-bit callers. The remaining small-buffer,
[8 lines not shown]
drm/amd/pm: derive stable PPT limits from PPTable
From Yang Wang
db1e5bd4ee8efe8d8f294576d20e13b9d435a6f7 in linux-6.18.y/6.18.61
25f4a46b0c8acd77c9065b50a1fe48af27d91fdf in mainline linux
drm/amd/display: Fix rounding errors in CalculatePrefetchSchedule
From Matthew Stewart
a5c18f62c897e0cffc469db8af52143a6e1b57f3 in linux-6.18.y/6.18.61
fa0300333db07ca4ad56c9879f155faafd3f7079 in mainline linux
drm/amdkfd: Fix signal reset event
From Amber Lin
a5bc8c907c9fa3540f750a4c3ea2b25bd54cacb4 in linux-6.18.y/6.18.61
b38f9b6ffdfc86d5aff36881d9e8028c79bc98c9 in mainline linux
drm/amdgpu/gfx11: WARN() rather than BUG() for invalid SDMA engine
From Alex Deucher
61ebae16cef33e8601d030e3d200e36025a2c49b in linux-6.18.y/6.18.61
c24edbd5ae0e4f24e0179e8c9f22a867016177bb in mainline linux
drm/amdgpu/atomfirmware: WARN() rather than BUG()
From Alex Deucher
a1a4ef16abcaa0bf09952b4413a2cc2991f20b89 in linux-6.18.y/6.18.61
d7c595044965c826e6f3ce30590d3ec4399cd633 in mainline linux
drm/amdkfd: add sanity check in svm_range_is_valid
From Eric Huang
f1be0815acc30ec458aef72fafb393b28476c27e in linux-6.18.y/6.18.61
aa7e29cf9a37092cf5057a612ee09f28df20258f in mainline linux
drm/amd/pm: Validate legacy hwmgr PP table offsets
From Yang Wang
35606292782dd35d152cc997a95742fd9bc2bcbd in linux-6.18.y/6.18.61
0ceb6bc43e62f0e73b282c9de8f4bc4d5498f281 in mainline linux
drm/amd/pm: Validate Vega10 PPTable subtable bounds
From Yang Wang
d930abfdca53f3db4c60eb4b30069f51c8528c83 in linux-6.18.y/6.18.61
9914149f99fd2ddcfd2a8c1053a57d96ec43448e in mainline linux
drm/amd/pm: Validate Tonga PPTable subtable bounds
From Yang Wang
269e57807b70ba29832a866de83a3cbe00b0cc66 in linux-6.18.y/6.18.61
53ef33c084c5778cc2dcd1efff25e31b6e231141 in mainline linux
drm/amd/pm: Guard VBIOS AC timing table walk
From Xiang Liu
f20fe19df5d99abc6fac744b279486cb1c2ab07f in linux-6.18.y/6.18.61
2bf6867e5953a140fc91c3159987656e44ed29fb in mainline linux
drm/amd/pm: Validate Tonga PowerPlay state array bounds
From Yang Wang
2fe60f66d6ab08a5a0df484d2c2983328142dc0d in linux-6.18.y/6.18.61
1ac24df78c566d767a5ef05a1fe0ecc55bac248d in mainline linux