SchOS/kernel/dev
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz e72205cdc0 panic: the crash screen reaches every display, not just the console's
"it also doesn't show crash screen on virtio gpu or just other gpu than default
vga" -- true, and on the virtio-gpu it was worse than nothing. The head kept
showing the console from a second before the panic: one screen saying the
kernel is dead, the other showing a shell prompt.

panic() painted into the console framebuffer and stopped there. Two cases were
missing, and they are not the same problem.

**The kernel still drives it.** display_acquire() hands back a buffer; the
report is copied in and presented. Ordinary, and a no-op when the display
class's buffer *is* the console's, so a one-screen machine does not do the work
twice.

**A process drives it.** The hard one, and the one hybrid.md owed an answer
for. The kernel let go of the device deliberately, and the process holding it
will never run again -- there is no scheduling after a panic -- so there is
nobody left to ask. It is not a race that can be won by being careful.

So the userspace driver says where it is scanning out *in advance*:
PCIIOC_PANICFB, registered by vgpud after bring-up and after every modeset. On
a panic the kernel paints the report into that memory and asks the kernel
driver the device was taken from to put it on screen one last time --
`panic_present` in struct pci_driver, which virtio-gpu implements by resetting
the device out from under a driver that is still nominally running. That is
safe here and nowhere else, because nothing is going to run again.

The panic path allocates nothing. It cannot: a corrupted heap is one of the
ways a machine gets here, and an allocator that deadlocks takes the crash
screen *and* the serial log's last chance to be read. So the driver keeps its
BAR mappings across the handover, rebuilds one queue from 20 KB of static
memory, and bounds every spin -- including the reset acknowledge, which is an
unbounded `while` in probe() and correct there.

**The registration is checked like the promise it is.** The range must lie
inside a block that process got from PCIIOC_DMA on that device. Without that,
a claimed device would be a way to nominate any physical address in the machine
-- page tables, kernel text -- to be overwritten with four megabytes of crash
report at the one moment nothing is left to notice. That is a worse bug than
the one this fixes. It goes away with the claim and with the process.

What it buys is worth stating plainly: a device can be evicted to userspace
without the kernel losing its ability to tell you the machine died. The
alternative was a driver boundary that is also a blind spot.

Verified both ways under QEMU with two heads, `echo c > /proc/sysrq`, and a
screendump of each over QMP:

  vgpud holding the device   both heads byte-identical, serial says
                             "The report is on the virtio-gpu display too."
  kernel holding it          same, via display_acquire/display_present
                             (/proc/pci shows 1af4:1050 [virtio-gpu])

Both supported configurations: one boot each, no traps, no panics, socktest and
memfdtest green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-22 16:53:16 +02:00
..
bio.c fs: timestamps come from the clock, and /proc/fsstat says how full the tables are 2026-09-12 17:14:14 +02:00
cdev.c errno: -1 is EPERM, and four places were saying it by accident 2026-09-14 22:12:28 +02:00
dbg.c debugger: D5, the network transport -- and the plan closes 2026-09-14 15:33:53 +02:00
device.c panic: the crash screen reaches every display, not just the console's 2026-09-22 16:53:16 +02:00
disk.c dev: raw disks are 64-bit, so a real drive stops wrapping at 4 GB 2026-08-11 12:15:38 +02:00
fb.c gfx: the console and the crash screen stop drawing on a driver by name 2026-08-15 17:04:10 +02:00
gfx.c branding: one mark, and PSOGM draws it 2026-09-21 21:35:58 +02:00
ide.c ide: idewait spun for a minute on any machine with no legacy drive 2026-09-13 14:43:35 +02:00
input.c kernel: the clock ran 7x slow because the GPU never acknowledged its interrupt 2026-09-12 21:34:36 +02:00
irq.c hybrid: interrupts to userspace, and a crashed driver that stays crashed 2026-09-13 18:11:00 +02:00
kbd.c kbd: three layouts, and the arrow keys were sitting on top of UTF-8 2026-09-20 01:09:32 +02:00
keymap.c kbd: three layouts, and the arrow keys were sitting on top of UTF-8 2026-09-20 01:09:32 +02:00
mouse.c gfx: the console and the crash screen stop drawing on a driver by name 2026-08-15 17:04:10 +02:00
netuser.c ldls: a network, in a process 2026-09-14 08:31:06 +02:00
pci.c boot: one line when it works, all of it when it does not 2026-09-14 21:19:50 +02:00
pciuser.c panic: the crash screen reaches every display, not just the console's 2026-09-22 16:53:16 +02:00
procfs.c kmem: a slab allocator, and what the fixed tables actually cost 2026-09-22 09:32:06 +02:00
ramdisk.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
text.c Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00
ttf.c font: the console draws outlines now, and a byte could not have held Ą 2026-09-20 00:35:34 +02:00
uart.c boot: one line when it works, all of it when it does not 2026-09-14 21:19:50 +02:00
vt.c font: the console draws outlines now, and a byte could not have held Ą 2026-09-20 00:35:34 +02:00