Files
RedBear-OS/config/redbear-full.toml
T
vasilito b681a2fb66 virtio-inputd: review-driven fixes for BLOCKERs and MAJORs (Phase 5.1 hardening)
Two parallel review agents cross-checked the virtio-inputd driver against
the Linux 7.1 reference (drivers/virtio/virtio_input.c, virtio_input.h)
and the proven redox-drm virtio transport. 12 issues were found across
BLOCKER, MAJOR, MINOR, and NIT severity, all fixed in this commit before
runtime testing.

BLOCKERs (would have prevented the driver from working in QEMU):

  1. fill_avail() never wrote avail_idx after pushing the 64 ring
     entries. The device reads avail_ring[avail_idx % size] to discover
     new buffers, so without publishing avail_idx = size, the device
     saw avail_idx = 0 and ignored all initial buffers. Fix: explicit
     'fence(Release); write_avail_idx(self.size)' with a spec citation.

  2. drain() recycled IDs derived from 'last_used_idx - drained_count',
     which is wrong when the used ring wraps and a single drain cycle
     spans more than one full ring revolution. Fix: collect the actual
     drained 'id' values in a stack '[u16; 64]' array during the drain
     loop, then push those exact ids back to the avail ring. The
     doc-comment explains why the derivation is unsafe.

  3. config_read_string() and config_read_bitmap() used
     'self.device_cfg.size()' (the MMIO region size = 40) instead of
     the device-reported config size from offset 2. Fix: use
     'config_read_size()' to read the actual size field.

  4. config/redbear-full.toml: device_id_range was a TOML string
     ('0x1042..=0x107F') but serde's Range<u16> deserializes from a
     sequence, not a string. pcid-spawner would have silently failed
     to load the fragment. Fix: use serde array form
     'device_id_range = [0x1042, 0x107F]'.

MAJORs (silent failure modes or runtime bugs):

  5. activate_queue() had no fence between address writes and
     'queue_enable = 1'. A CPU write buffer may reorder writes to
     distinct MMIO addresses. Fix: explicit 'fence(SeqCst)' with
     a comment citing virtio spec 2.8 and Linux's virtio_wmb.

  6. No 'reset_device()' on error path after partial init. The device
     would be left in ACKNOWLEDGE|DRIVER with no driver active,
     requiring a guest reboot to recover. Fix: wrap init in a closure;
     any error calls 'transport.reset_device()' before propagating.

  7. Drain loop never checked DEVICE_NEEDS_RESET or DEVICE_STATUS_FAILED.
     If the device entered an unrecoverable state, the driver would
     poll forever with stale state. Fix: 'device_in_error_state()' on
     the transport; loop checks it each iteration and exits cleanly.

  8. The abs_count probe used 'config_read_size() == 24', which was
     always false (virtio_input_absinfo is 20 bytes, not 24). The
     count was always logged as 0. Fix: '>= 20' per spec.

MINORs / NITs (hardening, no functional impact):

  9. config_read_absinfo() returned AbsInfo without validating
     device-reported size. Now returns Option<AbsInfo> and validates
     size >= 20.

 10. map_cap_region() missing bounds check: capability range may
     extend past BAR end (QEMU is permissive; bare-metal is not).
     Added 'cap_end > bar_size' check with spec reference.

 11. Legacy device 0x1052 entry in pcid fragment caused spurious
     spawn + log noise. Removed.

 12. notify_queue() error silently dropped with .ok(). Now logs warn
     and continues.

Plan update:

The CONSOLE-TO-KDE-DESKTOP-PLAN.md v5.1 changelog now has a new
'9.1.1 Phase 5.1 review-driven fixes' section documenting all 12
findings with file:line, severity, and fix. Future maintainers can
trace the BLOCKERs back to specific commits to understand the
critical-path safety net this review provided.

Verification: cargo check zero errors, 64 warnings (all unused
keycode constants reserved for Phase 5.2 expansion). The driver
is now ready for runtime testing in QEMU.
2026-06-08 22:43:38 +03:00

679 lines
14 KiB
TOML

# Red Bear OS Full Configuration
# Desktop/graphics ISO for bare metal and QEMU.
#
# Build: make live CONFIG_NAME=redbear-full
# QEMU: make all CONFIG_NAME=redbear-full && make qemu
#
# Extends redbear-mini with the full desktop/graphics stack:
# Wayland, Qt6, KF6, KWin, Mesa, DRM drivers, firmware, greeter.
#
# GPU/display policy: DRM/KMS ONLY. No VESA. Real GPU drivers:
# QEMU → virtio-gpu via redox-drm (virgl 3D)
# Intel → i915-like via redox-drm (Mesa i965/iris)
# AMD → amdgpu via redox-drm + linux-kpi (Mesa radeonsi)
# Display path: bootloader FB → redox-drm → DRM/KMS → KWin compositor
# Consult local/reference/linux-7.0/ for driver behavior reference.
include = ["redbear-mini.toml"]
[general]
filesystem_size = 2048
[users.messagebus]
uid = 100
gid = 100
name = "messagebus"
home = "/nonexistent"
shell = "/usr/bin/false"
[users.root]
password = "password"
uid = 0
gid = 0
shell = "/usr/bin/zsh"
[users.user]
password = ""
uid = 1000
gid = 1000
name = "user"
home = "/home/user"
shell = "/usr/bin/zsh"
[packages]
# Runtime driver parameter control surface.
driver-params = {}
# D-Bus IPC (required by greeter/session services)
expat = {}
dbus = {}
# Firmware loading
redbear-firmware = {}
firmware-loader = {}
# Intel Wi-Fi bounded driver path
redbear-iwlwifi = {}
# NUMA topology discovery (userspace daemon)
numad = {}
# GPU/graphics stack
redox-drm = {}
mesa = {}
libdrm = {}
libepoxy = {}
libdisplay-info = "ignore"
libxcvt = "ignore"
lcms2 = "ignore"
freetype2 = {}
fontconfig = {}
libwayland = {}
wayland-protocols = {}
plasma-wayland-protocols = {}
redbear-compositor = {}
# Keyboard/input
libxkbcommon = {}
xkeyboard-config = {}
libevdev = {}
libinput = {}
redbear-keymapd = {}
redbear-ime = {}
redbear-accessibility = {}
# Qt6 stack
qtbase = {}
qtdeclarative = {}
qtsvg = {}
qtwayland = {}
qt6-wayland-smoke = {}
qt6-sensors = {}
# KF6 Frameworks — explicit real-build surface in alphabetical order
# kirigami: blocked (QML gate — QQuickWindow/QQmlEngine headers don't exist on Redox)
kf6-kio = {}
# kde-cli-tools = {} # blocked: direct repo cook fails
kdecoration = {}
kf6-attica = {}
kf6-karchive = {}
kf6-kauth = {}
kf6-kbookmarks = {}
kf6-kcmutils = {}
kf6-kcodecs = {}
kf6-kcolorscheme = {}
kf6-kcompletion = {}
kf6-kconfig = {}
kf6-kconfigwidgets = {}
kf6-kcoreaddons = {}
kf6-kcrash = {}
kf6-kdbusaddons = {}
kf6-kdeclarative = {}
kf6-kded6 = {}
kf6-kguiaddons = {}
kf6-ki18n = {}
kf6-kiconthemes = {}
kf6-kidletime = {}
kf6-kitemmodels = {}
kf6-kitemviews = {}
kf6-kjobwidgets = {}
kf6-knotifications = {}
kf6-kpackage = {}
kf6-kservice = {}
kf6-ktextwidgets = {}
kf6-kwayland = {}
kf6-kwidgetsaddons = {}
kf6-kwindowsystem = {}
kf6-kxmlgui = {}
kf6-prison = {}
kf6-solid = {}
kf6-sonnet = {}
kf6-ksvg = {}
kf6-knewstuff = {}
kf6-kwallet = {}
kf6-kglobalaccel = {}
kf6-pty = {}
kf6-notifyconfig = {}
kf6-parts = {}
icu = {}
konsole = {}
kglobalacceld = {}
# kwin (real KWin compositor, QML-free build via KWIN_BUILD_QML_UI=OFF)
kwin = {}
# Plasma + app packages — blocked on kirigami (QML gate)
# plasma-framework = {}
# plasma-workspace = {}
# plasma-desktop = {}
redbear-authd = {}
redbear-session-launch = {}
seatd = {}
redbear-greeter = {}
sddm = {}
amdgpu = "ignore"
#amdgpu = {} # TODO: fix conflicting idr_* defs with linux-kpi headers
# Core Red Bear umbrella package
redbear-meta = {}
# Phase 1 runtime validation tests (POSIX: signalfd, timerfd, eventfd, shm_open, sem_open, waitid)
relibc-phase1-tests = {}
# Native build toolchain — excluded from desktop ISO to reduce size.
# For on-OS development, build redbear-dev config or install separately.
# gcc-native = {}
# binutils-native = {}
# Desktop fonts and icons
dejavu = {}
freefont = {}
hicolor-icon-theme = {}
pop-icon-theme = {}
# Suppress legacy desktop packages
orbdata = "ignore"
orbital = "ignore"
orbterm = "ignore"
orbutils = "ignore"
cosmic-edit = "ignore"
cosmic-files = "ignore"
cosmic-icons = "ignore"
cosmic-term = "ignore"
curl = "ignore"
git = "ignore"
mc = {}
#curl = "ignore" # suppressed: cascade rebuild
#git = "ignore" # suppressed: cascade rebuild
#konsole = {} # WIP: recipe exists, not yet built — blocked by libiconv fetch
#kf6-pty = {} # WIP: recipe exists, not yet built
[[files]]
path = "/lib/firmware/amdgpu"
data = ""
directory = true
mode = 0o755
[[files]]
path = "/usr/lib/fonts"
data = "/usr/share/fonts"
symlink = true
[[files]]
path = "/lib/drivers.d/30-graphics.toml"
data = """
[[driver]]
name = "redox-drm"
description = "DRM/KMS display driver (AMD + Intel + VirtIO)"
priority = 60
command = ["/usr/bin/redox-drm"]
depends_on = ["pci"]
[[driver.match]]
class = 0x03
vendor = 0x1002
[[driver.match]]
class = 0x03
vendor = 0x8086
[[driver.match]]
class = 0x03
vendor = 0x1af4
"""
[[files]]
path = "/lib/drivers.d/60-wifi.toml"
data = """
[[driver]]
name = "redbear-iwlwifi"
description = "Intel Wi-Fi driver"
priority = 45
command = ["/usr/lib/drivers/redbear-iwlwifi", "--full-init"]
depends_on = ["pci", "firmware"]
[[driver.match]]
vendor = 0x8086
class = 0x02
subclass = 0x80
"""
[[files]]
path = "/etc/init.d/00_firmware-loader.service"
data = """
[unit]
description = "Firmware loading scheme"
requires_weak = [
"05_boot-essential.target",
]
[service]
cmd = "/usr/bin/firmware-loader"
type = { scheme = "firmware" }
"""
[[files]]
path = "/etc/init.d/05_boot-essential.target"
data = """
[unit]
description = "Boot essential services target"
requires_weak = [
"04_drivers.target",
]
"""
[[files]]
path = "/etc/init.d/13_iommu.service"
data = """
[unit]
description = "IOMMU DMA remapping daemon"
requires_weak = [
"05_boot-essential.target",
"00_acpid.service",
]
[service]
cmd = "/usr/bin/iommu"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/10_redox-drm.service"
data = """
[unit]
description = "DRM/KMS display driver (AMD + Intel + VirtIO)"
requires_weak = [
"05_boot-essential.target",
"00_driver-manager.service",
]
[service]
cmd = "/usr/bin/sh"
args = ["-c", "if ! head -c 1 /scheme/drm/card0 >/dev/null 2>&1; then exec /usr/bin/redox-drm; fi; echo 'scheme:drm already registered, skipping'"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/12_dbus.service"
data = """
[unit]
description = "D-Bus system bus"
requires_weak = [
"12_boot-late.target",
"00_ipcd.service",
]
[service]
cmd = "/usr/bin/dbus-daemon"
args = ["--system", "--nopidfile"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/13_redbear-sessiond.service"
data = """
[unit]
description = "Red Bear session broker (org.freedesktop.login1)"
requires_weak = [
"12_dbus.service",
]
[service]
cmd = "/usr/bin/redbear-sessiond"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/13_seatd.service"
data = """
[unit]
description = "seatd seat management daemon"
requires_weak = [
"12_dbus.service",
"13_redbear-sessiond.service",
]
[service]
cmd = "/usr/bin/seatd"
args = ["-l", "info"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/keymaps/.gitkeep"
data = ""
[[files]]
path = "/etc/init.d/13_redbear-keymapd.service"
data = """
[unit]
description = "Runtime keymap daemon"
requires_weak = [
"10_evdevd.service",
]
[service]
cmd = "/usr/bin/redbear-keymapd"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/13_redbear-ime.service"
data = """
[unit]
description = "Input method engine daemon"
requires_weak = [
"10_evdevd.service",
]
[service]
cmd = "redbear-ime"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/13_redbear-accessibility.service"
data = """
[unit]
description = "Accessibility input filter daemon (sticky/slow/bounce keys)"
requires_weak = [
"10_evdevd.service",
]
[service]
cmd = "redbear-accessibility"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/14_redbear-upower.service"
data = """
[unit]
description = "UPower D-Bus service (org.freedesktop.UPower)"
requires_weak = [
"12_dbus.service",
]
[service]
cmd = "redbear-upower"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/14_redbear-udisks.service"
data = """
[unit]
description = "UDisks2 D-Bus service (org.freedesktop.UDisks2)"
requires_weak = [
"12_dbus.service",
]
[service]
cmd = "redbear-udisks"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/14_redbear-polkit.service"
data = """
[unit]
description = "PolicyKit1 D-Bus service (org.freedesktop.PolicyKit1)"
requires_weak = [
"12_dbus.service",
]
[service]
cmd = "redbear-polkit"
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/11_redbear-authd.service"
data = """
[unit]
description = "Red Bear authentication daemon"
requires_weak = [
"12_dbus.service",
]
[service]
cmd = "/usr/bin/redbear-authd"
envs = { QT_PLUGIN_PATH = "/usr/plugins", QT_QPA_PLATFORM_PLUGIN_PATH = "/usr/plugins/platforms", QML2_IMPORT_PATH = "/usr/qml", XCURSOR_THEME = "Pop", XKB_CONFIG_ROOT = "/usr/share/X11/xkb", KWIN_DRM_DEVICES = "/scheme/drm/card0" }
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/12_sddm.service"
data = """
[unit]
description = "SDDM display manager"
requires_weak = [
"00_driver-manager.service",
"10_redox-drm.service",
"10_evdevd.service",
"12_dbus.service",
"13_redbear-sessiond.service",
"13_seatd.service",
"11_redbear-authd.service",
]
[service]
cmd = "/usr/bin/sddm"
envs = { QT_PLUGIN_PATH = "/usr/plugins", QT_QPA_PLATFORM_PLUGIN_PATH = "/usr/plugins/platforms", QML2_IMPORT_PATH = "/usr/qml", XCURSOR_THEME = "Pop", XKB_CONFIG_ROOT = "/usr/share/X11/xkb" }
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/29_activate_console.service"
data = """
[unit]
description = "Activate fallback console VT"
requires_weak = [
"05_boot-essential.target",
]
[service]
cmd = "inputd"
args = ["-A", "2"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/30_console.service"
data = """
[unit]
description = "Console terminals"
requires_weak = [
"29_activate_console.service",
]
[service]
cmd = "sh"
args = ["-c", "sleep 0.2; exec getty 2"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/31_debug_console.service"
data = """
[unit]
description = "Debug console on serial port"
requires_weak = [
"29_activate_console.service",
]
[service]
cmd = "getty"
args = ["/scheme/debug/no-preserve", "-J"]
type = "oneshot_async"
"""
[[files]]
path = "/etc/init.d/99_diag_serial.service"
data = """
[unit]
description = "Serial diagnostic marker"
requires_weak = [
"31_debug_console.service",
"30_console.service",
"12_dbus.service",
]
[service]
cmd = "zsh"
args = ["-c", "echo BOOT_COMPLETE_SERIAL_MARKER"]
type = "oneshot"
"""
[[files]]
path = "/etc/init.d/99_kwin_test.service"
data = """
[unit]
description = "FS diagnostic and direct kwin test"
requires_weak = [
"12_sddm.service",
]
[service]
cmd = "zsh"
args = ["-c", "sleep 30; echo '=== FS DIAG ==='; ls -lad /tmp /var/log /var/run /run; echo '--- root write ---'; echo ok > /writetest; ls -la /writetest; cat /writetest; rm /writetest; echo '--- /tmp write ---'; echo ok > /tmp/writetest; ls -la /tmp/writetest; cat /tmp/writetest; rm /tmp/writetest; echo '--- mkdir /tmp/testdir ---'; mkdir /tmp/testdir; ls -lad /tmp/testdir; rmdir /tmp/testdir; echo '--- /var/log write ---'; echo ok > /var/log/writetest; ls -la /var/log/writetest; rm /var/log/writetest; echo '--- /var/run write ---'; echo ok > /var/run/writetest; ls -la /var/run/writetest; rm /var/run/writetest; echo '=== KWIN TEST ==='; mkdir -p /tmp/run/kwin; HOME=/tmp XDG_RUNTIME_DIR=/tmp/run/kwin QT_DEBUG_PLUGINS=1 QT_QPA_PLATFORM=wayland KWIN_DRM_DEVICES=/scheme/drm/card0 LIBSEAT_BACKEND=seatd SEATD_SOCK=/var/run/seatd.sock /usr/bin/kwin_wayland --drm /scheme/drm/card0; echo 'kwin exited'"]
type = "oneshot_async"
"""
[users.greeter]
password = ""
uid = 101
gid = 101
name = "greeter"
home = "/var/lib/sddm"
shell = "/usr/bin/zsh"
[users.sddm]
password = ""
uid = 102
gid = 102
name = "sddm"
home = "/var/lib/sddm"
shell = "/usr/bin/nologin"
[groups.greeter]
gid = 101
members = ["greeter", "sddm"]
[groups.sddm]
gid = 102
members = ["sddm"]
[groups.sudo]
gid = 1
members = ["user"]
[groups.user]
gid = 1000
members = ["user"]
[groups.messagebus]
gid = 100
members = ["messagebus"]
[[files]]
path = "/etc/sddm.conf"
data = """
[General]
DisplayServer=wayland
GreeterEnvironment=QT_PLUGIN_PATH=/usr/plugins,QML2_IMPORT_PATH=/usr/qml,QT_QPA_PLATFORM_PLUGIN_PATH=/usr/plugins/platforms
[Theme]
Current=mayagrid
ThemeDir=/usr/share/sddm/themes
[Wayland]
CompositorCommand=/usr/libexec/sddm-helper-start-wayland kwin_wayland --drm /scheme/drm/card0
[Users]
DefaultPath=/usr/bin
MinimumUid=1000
MaximumUid=60000
RememberLastUser=true
[Autologin]
User=
Session=plasmawayland
"""
[[files]]
path = "/usr/share/wayland-sessions/plasmawayland.desktop"
data = """
[Desktop Entry]
Name=Plasma Wayland
Comment=KDE Plasma on Wayland
Exec=/usr/bin/kwin_wayland --drm /scheme/drm/card0
Type=Application
DesktopNames=KDE
"""
[[files]]
path = "/etc/pcid.d/ihdgd.toml"
data = """
[[drivers]]
name = "Intel GPU (VGA compatible)"
class = 0x03
vendor = 0x8086
subclass = 0x00
command = ["redox-drm"]
[[drivers]]
name = "Intel GPU (3D controller)"
class = 0x03
vendor = 0x8086
subclass = 0x02
command = ["redox-drm"]
"""
[[files]]
path = "/etc/pcid.d/virtio-gpud.toml"
data = """
[[drivers]]
name = "VirtIO GPU"
class = 0x03
vendor = 0x1af4
device = 0x1050
command = ["/usr/bin/redox-drm"]
"""
[[files]]
path = "/etc/pcid.d/virtio-inputd.toml"
data = """
# virtio-input — class 0x09 (input), vendor 0x1af4 (Red Hat virtio),
# device id range 0x1042..=0x107F (modern virtio 1.0+ input devices).
# The driver itself only attaches to type=18 (input) via PCI cap walk.
# device_id_range uses serde array form for Range<u16>.
[[drivers]]
name = "VirtIO Input (modern)"
class = 0x09
vendor = 0x1af4
device_id_range = [0x1042, 0x107F]
command = ["/usr/lib/drivers/virtio-inputd"]
"""
[[files]]
path = "/etc/environment.d/90-dbus.conf"
data = """
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
"""
[[files]]
path = "/home/user"
data = ""
directory = true
mode = 0o755
[[files]]
path = "/root"
data = ""
directory = true
mode = 0o700