Commit Graph

731 Commits

Author SHA1 Message Date
vasilito ac2f1ccbc2 iommu: Add Intel VT-d daemon foundation (Phase 3.2)
- Add intel_vtd.rs module with DMAR parsing, DRHD discovery,
  register definitions, and basic unit initialization
- Update iommu daemon discovery to detect both AMD-Vi (IVRS)
  and Intel VT-d (DMAR) units
- Update IommuScheme to track both amd_units and intel_units
- Intel VT-d init: version check, capability read, disable
  translation, report supported features (QI, IR, EIM)

Full DMA remapping enablement (root table, context entries,
page tables, command buffer) remains as TODO for follow-up.
2026-05-20 21:13:03 +03:00
vasilito b2eaa8d96f base: Add ACPI C-state discovery and thermal-based C-state policy (P52)
- drivers/acpid/src/cstate.rs: Evaluate _CST per processor, parse
  Package-of-Packages into CStateInfo structs
- AcpiContext: add cstate_state field with refresh, add processor_names()
  to scan _PR namespace
- acpid scheme: expose /scheme/acpi/cstates/<proc> read handles
- thermald: read /scheme/sys/cstate, set /scheme/sys/cstate_policy
  to restrict to C1 when temp exceeds WARNING_TEMP

Works with kernel P25 cpuidle deep C-states.
2026-05-20 20:47:37 +03:00
vasilito 4fe34d543f baseline 2026-05-20 19:58:33 +03:00
vasilito 5f0c54ebfe baseline 2026-05-20 19:58:12 +03:00
vasilito 80c9bccc09 docs: Add hardware validation matrix template
Define 4 hardware target classes (AMD/Intel desktop/laptop),
per-target checklist, negative-result capture format, and
quick/full test procedures. Ready for bare-metal evidence.
2026-05-20 18:56:32 +03:00
vasilito 676a4342ce udev-shim: Only log hotplug events when device count changes
Track the last PCI device count and only emit log messages when
devices are added or removed, eliminating redundant 2-second poll
noise.
2026-05-20 18:52:43 +03:00
vasilito e5b82a644a coretempd: Add AMD Zen temperature sensor support
Detect CPU vendor by probing MSRs (Intel IA32_THERM_STATUS vs AMD
TCTL MSR C0010293). Support both Intel Tjmax-based and AMD direct
temperature reading. Log detected vendor per CPU at startup.
2026-05-20 18:52:01 +03:00
vasilito 2c7de8dea6 base: Add per-service log files and size-based rotation to logd (P51)
Extend logd output thread to write logs to per-service files in
/var/log/<service>.log, with automatic size-based rotation (10 MB
threshold, 5 backup files). All logs also go to /var/log/system.log.
Backwards compatible with existing sink file descriptors.
2026-05-20 18:39:49 +03:00
vasilito fb2de33c6d base: Add structured logging rate limiter and thermald integration (P50)
Add RateLimitedLog to common::logger for per-message rate limiting with
"last message repeated N times" warnings. Add structured_log! macro for
key=value formatted logs. Update thermald to rate-limit the max-temp
summary line (30s interval) to reduce log volume.
2026-05-20 18:14:47 +03:00
vasilito 3890840001 base: Add IRQ affinity logging and CPU tracking to pcid (P49)
Track the target CPU ID in InterruptVector, and log the interrupt type
(MSI-X/MSI/Legacy) and CPU affinity at allocation time in
pci_allocate_interrupt_vector. Add log_affinity() helper for drivers
to call after setup.
2026-05-20 17:55:36 +03:00
vasilito b360748b82 base: Add ACPI fan device discovery and status exposure (P48)
Add fan.rs module to acpid that discovers FAN* devices under \_TZ,
evaluates _FST for current speed level and RPM, and exposes them via
/scheme/acpi/fan/<name>/status. Update thermald to read and log fan
status alongside temperature sensors.
2026-05-20 17:47:39 +03:00
vasilito ad2e85079d base: Update thermald to use P44 thermal zones and coretempd (P47)
Replace the old hardcoded /scheme/acpi/thermal_zone/{n} paths with
proper discovery of /scheme/acpi/thermal/ zones and /scheme/coretemp/
CPU temperatures. Logs per-zone and per-CPU temps with max tracking.
2026-05-20 17:23:19 +03:00
vasilito 1a0a684765 base: Migrate ahcid and ac97d to MSI-X interrupts (P46)
Switch storage and audio drivers from legacy INTx to
pci_allocate_interrupt_vector which auto-prefers MSI-X > MSI > Legacy.
2026-05-20 17:12:51 +03:00
vasilito e178e0fd86 base: Migrate e1000d and ixgbed to MSI-X interrupts (P45)
Switch network drivers from legacy INTx to pci_allocate_interrupt_vector
which auto-prefers MSI-X > MSI > Legacy. rtl8139d and rtl8168d already
used this helper; e1000d and ixgbed were the remaining legacy-only NIC
drivers.
2026-05-20 17:03:05 +03:00
vasilito bb4f757ba0 kernel: Add MONITOR/MWAIT C1 idle support (P24)
Implement CPU power-saving idle loop using x86 MONITOR/MWAIT:
- Add monitor(), mwait(), enable_and_mwait() to interrupt module
- Detect MWAIT availability via CPUID at boot
- Use MONITOR+MWAIT instead of STI+HLT when supported
- Expose /scheme/sys/cstate_policy for userspace control
- Add RdWr Kind variant to sys scheme for read+write files
2026-05-20 16:49:48 +03:00
vasilito 4fe734d1c2 fix: Regenerate P44 patch with clean upstream baseline
Previous P44 was generated against an already-patched tree causing
validation failures. Regenerated using git diff -U0 -w against
P0-P43 baseline.
2026-05-20 14:11:00 +03:00
vasilito 0834c21607 udev-shim: Harden rules file write with retry loop
Handle BrokenPipe and AlreadyExists races when writing default udev
rules during early boot. Retry up to 3 times with 50ms backoff.
2026-05-20 14:00:49 +03:00
vasilito 40ba2caaf6 base: Add missing P35-P43 boot-hardening patches
Graceful init patches for fbcond, graphics scheme, smolnetd, vesad,
PCI interrupt allocation, BAR probing, common init, inputd fallback,
and dhcpd hard dependency ordering.
2026-05-20 13:57:47 +03:00
vasilito 8f8c69a04e docs: Remove named AI references from commit policy
Make the anti-pattern description generic instead of naming a
specific tool or service.
2026-05-20 13:55:53 +03:00
vasilito ae46dabeb0 docs: Add comprehensive system assessment and improvement plan
Replace 5 stale planning docs with unified assessment:
- New: COMPREHENSIVE-SYSTEM-ASSESSMENT-AND-IMPROVEMENT-PLAN.md
  (12-subsystem audit vs Linux 7.1, 6 phases of work)
- Removed: IMPLEMENTATION-MASTER-PLAN, SUBSYSTEM-ASSESSMENT-2026-05,
  SMP-BOOT-HARDENING-PLAN, CPU-DMA-IRQ-MSI-SCHEDULER-FIX-PLAN,
  COMPREHENSIVE-BOOT-IMPROVEMENT-PLAN
2026-05-20 13:47:25 +03:00
vasilito b1af8a356f acpid: Add ACPI thermal zone discovery and evaluation (P44)
Implement full thermal zone backend in acpid:
- thermal.rs: Discover \_TZ_.TZ* zones, evaluate \_TMP, \_CRT, \_PSV,
  \_AC0, \_TC1, \_TC2, \_TSP, \_TZP methods
- scheme.rs: Expose /scheme/acpi/thermal/ with per-zone temperature files
- acpi.rs: Add thermal_state and thermal_zone_names() to AcpiContext

Wired as P44 patch in base recipe.toml.
2026-05-20 13:47:04 +03:00
vasilito 6ca3e47383 Add coretempd CPU temperature sensor daemon
New local recipe coretempd reads IA32_THERM_STATUS MSR via the
new sys:msr scheme and exposes per-CPU temperatures via scheme:coretemp.

- Reads IA32_THERM_STATUS (0x19C) and IA32_TEMPERATURE_TARGET (0x1A2)
- Calculates Celsius from digital readout relative to TjMax
- Exposes /scheme/coretemp/ directory with per-CPU temperature files
- Added to redbear-mini.toml (inherited by redbear-full)
- Added 15_coretempd.service init file
2026-05-20 13:46:43 +03:00
vasilito 7999a896d0 cpufreqd: Use new sys:msr scheme for P-state control
Replace non-existent /dev/cpu/{n}/msr path with /scheme/sys/msr/{cpu}/{msr}
now that the kernel exposes MSR access via the sys scheme.
2026-05-20 13:40:45 +03:00
vasilito 56be23ce6e kernel: Add sys:msr scheme for userspace MSR read/write
Expose MSR access via /scheme/sys/msr/<cpu>/<msr> for root only.
Required for cpufreqd P-state control and thermal sensor drivers.
2026-05-20 13:38:53 +03:00
vasilito 9233726f58 P0..P71 baseline before fbcond/fbbootlogd init fix 2026-05-20 00:30:18 +03:00
vasilito 861e6f88d2 driver-manager: fix scheme collision and scheme availability check; redox-driver-sys: CPU affinity logging; redbear-hwutils: timer characterization 2026-05-19 23:50:32 +03:00
vasilito a9051ebb91 base: P25-P32 patch chain — fbcond VESA fallback, driver-manager initfs, init conditions, acpid graceful boot, xhcid interrupts 2026-05-19 23:50:01 +03:00
vasilito 2a5eff93ec P24: ACPI S5 derivation with shutdown semantics and error propagation
Add deterministic S5 (soft-off) state derivation and structured error
handling to acpid. Derive S5 parameters once at startup (or retry at
shutdown if AML was not ready) instead of re-parsing the _S5 package
on every shutdown attempt. Replace unit-return set_global_s_state()
with ShutdownResult enum for proper error propagation and fallback
handling.

Changes:
- S5State struct caches SLP_TYPa/b, PM1a/b ports, derivation timestamp
- ShutdownError enum: MissingFadt, Pm1aZero, AmlNotReady, S5NotFound,
  S5NotPackage, SlpTypNotInteger, S5WriteFailed
- ShutdownResult enum: Ok, FallbackReset, Err(ShutdownError)
- derive_s5_state() method with early init attempt and lazy fallback
- set_global_s_state() returns ShutdownResult instead of ()
- Early S5 derivation in AcpiContext::init() logs AML readiness status
- main.rs logs shutdown result for debugging

This is W2.1/W2.2 from ACPI-IMPROVEMENT-PLAN.md.
2026-05-19 02:43:58 +03:00
vasilito ba5e010bb7 P21-P23: boot daemon panic fixes, x2APIC MADT fallback, rootfs hard dep on drivers
P21: Replace 67 panic-grade calls across 9 boot daemon files with
graceful error handling. Affected: ps2d, inputd, fbcond, fbbootlogd.

P22: Add x2APIC MADT fallback for processors with LocalApic entries
instead of LocalX2Apic entries. QEMU KVM boots now correctly detect
all vCPUs via zero-extended APIC ID fallback.

P23: Change 50_rootfs.service from requires_weak to requires on
40_drivers.target, ensuring redoxfs waits for disk drivers before
attempting filesystem mount. This fixes the boot race where rootfs
mount failed before drivers were ready, causing init to have no
userland services after switchroot.
2026-05-19 02:18:17 +03:00
vasilito b1022dfa39 fix: ramfs depends hard on randd before startup (P20)
ramfs@.service required randd as requires_weak, which doesn't enforce
readiness ordering. When ramfs called std::random before randd registered
/scheme/rand, it panicked with 'failed to generate random data'.

Changed requires_weak to requires so init waits for randd to register
its scheme before starting ramfs.

Also patched Rust stdlib sys/random/redox.rs to fall back to xorshift64
seeded from ASLR rather than panicking when /scheme/rand is unavailable.
This is a belt-and-suspenders fix: even with proper ordering, the stdlib
should not panic on missing entropy during early boot.
2026-05-18 17:43:33 +03:00
vasilito f3bef6b403 fix: remove P18-5 duplicate RSDP hunk, fix P19-init log crate dependency
P18-5 had a duplicate acpi.rs RSDP probing hunk that reversed P5's
BIOS probing code, causing P19-acpid hunk #8 to fail. Removed the
duplicate, keeping only aml_physmem.rs hunks.

P19-init used log::warn!() but init in initfs has no log crate
dependency. Replaced with init_warn(&format!(...)) from the existing
color module.

All 58/58 patches validate. redbear-mini builds successfully.
2026-05-18 17:00:01 +03:00
vasilito 419ff3c536 fix: regenerate P18-9, P19-init, P19-acpid patches as -U0 -w resilient format
All 58 base patches now pass repo validate-patches base.

- P18-9-msi-allocation-resilience: regenerated against P0-P18-8 baseline
  with correct upstream content (deamon typo preserved for virtio-netd)
- P19-init-startup-hardening: regenerated against P0-P18-9 baseline
- P19-acpid-startup-hardening: regenerated against P0-P18-9 + P19-init
  baseline with all 39 hunks in -U0 -w format (zero context lines)
2026-05-18 16:05:52 +03:00
vasilito ecc120b013 chore: kernel source patches, local recipe updates, and build artifacts
Kernel source (ephemeral — changes durable in local/patches/kernel/):
- P20 x2apic ICR mode fix, P21 x2apic SMP fix applied
- ACPI MADT, RSDP, SDT improvements
- Context switch, percpu, event, IRQ scheme updates
- MSI/vector allocation, NUMA/SLIT/SRAT support

Local recipe source updates:
- redox-driver-acpi: bus/prt hardening
- redox-drm: Intel display, KMS connector improvements
- driver-manager: config/scheme hardening
- thermald: main.rs fix
- uutils-tar, ninja-build: source updates

Other:
- bootloader, installer, redoxfs, relibc, userutils source updates
- recipe.toml.backup, libxcvt source directory
2026-05-18 14:20:54 +03:00
vasilito f6c2eb2a8e feat: ACPI Wave 1 boot-critical hardening (P19) + robust patch generation
- P19-init-startup-hardening: Replace panic-grade expect/unwrap in init
  startup paths (getns, register_scheme_to_ns, setrens, filename parsing)
  with graceful error handling and logging
- P19-acpid-startup-hardening: Replace panic-grade calls in acpid with
  graceful degradation (rxsdt read failure → warn + exit 0, SDT parse →
  error + exit 1, I/O privilege → fatal, scheme registration → fatal,
  setrens → warn + continue, event loop errors → log + continue)
- P18-9-msi-allocation-resilience: Regenerate with git diff -U0 -w format
  for maximum context resilience
- fetch.rs: Change --fuzz=0 to --fuzz=3 for resilient patch application
- AGENTS.md: Document robust patch generation technique as mandatory
- Add P4/P5/P6/P7 patches (estale, dmi, i2c, ps2d hardening)
- Add P21 kernel x2apic SMP fix patch
- Multiple local recipe source improvements (redox-drm, driver-manager,
  driver-acpi, thermald)
- Config updates for redbear-mini and redbear-device-services
- Subsystem assessment document
2026-05-18 14:07:42 +03:00
vasilito 7798ed86eb fix: remove P20 forward patch — cascading context issues with P16-1
x2APIC ICR mode fix cannot be a forward patch because P16-1-sipi-timing
references the ICR line as context. Modifying P1 (which introduces the line)
would require updating P16-1's offsets. Will address by consolidating into
an existing early patch in a future revision.
2026-05-17 15:25:36 +03:00
vasilito b40daef15c chore: remove kernel patch artifacts 2026-05-17 14:57:18 +03:00
vasilito 2bfe4b427b feat: raw framebuffer fallback for fbbootlogd when DRM unavailable
- Add RawFb struct: direct framebuffer rendering via physmap
- Add RawTextScreen: simple text renderer using orbclient font
- Fallback in FbbootlogScheme::new() when V2GraphicsHandle fails
- Reads FRAMEBUFFER_ADDR/WIDTH/HEIGHT/STRIDE from bootloader env
- Scroll via ptr::copy on pixel rows, clear bottom line
- No DRM, no shadow buffer, no GPU required — like MS-DOS text mode
- Add common dependency to fbbootlogd Cargo.toml
2026-05-17 14:56:50 +03:00
vasilito 20853c41f5 fix: correct P20 patch line numbers from actual diff
- Derived line offsets from real pre-P20 vs post-P20 diff
- x86.rs: 3 hunks at @@ -446/-456/-468 converting hardcoded <<32 to
  local_apic.x2-gated format with xAPIC <<56 fallback
- local_apic.rs: 1 hunk promoting debug! to info! for bootlog visibility
2026-05-17 14:51:58 +03:00
vasilito ef999ebc8f chore: remove patch leftovers (.orig/.rej) 2026-05-17 13:57:56 +03:00
vasilito 081ed10a8b fix: x2APIC ICR format + build system durability docs
- Fix LocalX2Apic handler: use local_apic.x2 to select correct ICR
  format (<<32 for x2APIC, <<56 for xAPIC) instead of hardcoded <<32
- Promote x2APIC/xAPIC detection from debug! to info! for bootlog
- Document build system durability in AGENTS.md: cardinal rule,
  two-layer architecture, correct workflow, anti-patterns
2026-05-17 13:57:37 +03:00
vasilito cee25393d8 fix: boot process improvements — dependency cycle, INIT_NOTIFY, probing loop, and log spam fixes
- Fix P15-8-init-cycle-detection.patch: replace visiting+error with seen+silent-skip
  to eliminate 11 false-positive 'dependency cycle detected' errors on shared deps
- Fix P0-daemon-fix-init-notify-unwrap.patch: remove eprintln! for missing
  INIT_NOTIFY (expected for oneshot_async services, ~7 daemons affected)
- Fix driver-manager hotplug loop: add PERMANENTLY_SKIPPED static set shared
  between hotplug handler and DriverConfig::probe() to stop infinite re-probing
  of Fatal/NotSupported/deferred-exhausted device+driver pairs (e.g. ided)
- Fix driver-manager log_timeline: suppress repeated EPIPE/ENOENT errors with
  AtomicI32 dedup and AtomicBool one-shot guards for boot timeline JSON
- Add driver-manager SIGTERM handler, ACPI bus registration, --status mode,
  driver reap loop, graceful shutdown, and reduced deferred retries (30→3)
2026-05-17 12:34:02 +03:00
vasilito 7914626765 fix: update KWin and Qt6 cross-compile patches for Redox
KWin: add Redox compat for libinput device, wl-socket Unix domain socket\nwrapper, RamFile mmap, tablet mode manager, and CMake fixes for helpers\nand systembell plugins.

Qt6: add Redox compat for qplatformdefs (posix), corelib CMake,\nqtypes.h sizing, native socket engine, and Wayland client buffer\nintegration header.
2026-05-15 07:25:45 +01:00
vasilito a5df2280bc fix: update KF6 cross-compile patches for Redox
CMakeLists.txt patches for kf6-attica, kf6-kcmutils, kf6-kcolorscheme,\nkf6-kcompletion, kf6-kconfigwidgets, kf6-kdeclarative, kf6-kiconthemes,\nkf6-kitemmodels, kf6-kitemviews, kf6-kjobwidgets, kf6-ktextwidgets,\nkf6-kwayland, kf6-kxmlgui, kf6-pty, kf6-solid — disable missing dependencies,\nadd Redox compatibility definitions, and fix build errors.
2026-05-15 07:24:51 +01:00
vasilito 13c5d239ca feat: add Mesa EGL hardware GPU probe with virgl support
P5: Enable PRIME export for GBM dumb buffers so virgl can import scanout\nbuffers via fd-to-handle.

P6: Add redox_probe_device_hw() that opens /scheme/drm/card0, resolves the\nDRI driver via PCI ID lookup (loader_get_driver_for_fd), and initializes the\nhardware path through dri2_load_driver_dri3 with __DRIimageLoaderExtension.\nIncludes fprintf(stderr) debug logging tagged [REDOX-EGL] for tracing the\nHW init sequence. Falls back to software rendering if HW probe fails.
2026-05-15 07:24:31 +01:00
vasilito 104edae141 feat: rewrite libdrm ioctl bridge with VirtGPU support
Wire P1/P2 patches into recipe.toml. Source reflects the full ioctl bridge\nrewrite: VirtGPU NR mappings, EXECBUFFER/GET_CAPS special handlers,\nPCI info bridge for drmGetDevice2, and removal of the old per-ioctl C\nhandler functions in favor of unified redox_drm_simple_ioctl() dispatch.
2026-05-15 07:24:15 +01:00
vasilito dd0cc3725a feat: add VirtGPU ioctl bridge and PCI info patches for libdrm
P1: Replaces the old per-ioctl C handlers with a unified dispatch through\nredox_drm_simple_ioctl(), adds VirtGPU NR mappings (MAP, EXECBUFFER,\nGETPARAM, RESOURCE_CREATE, GET_CAPS, etc.), and special handlers for\nEXECBUFFER (inline command buffer) and GET_CAPS (variable response).

P2: Adds __redox__ blocks to drmParsePciBusInfo, drmParsePciDeviceInfo,\nand drmGetDevice2 using the DRM scheme GET_PCI_INFO ioctl to populate\nPCI device identification without /sys access.
2026-05-15 07:23:57 +01:00
vasilito 3129fdccd2 fix: correct VirtIO GPU command opcodes and enable virgl feature
Align 2D command opcodes, response opcodes, and 3D command opcodes with\nthe Linux UAPI definitions in include/uapi/linux/virtio_gpu.h. Enable\nVIRTIO_GPU_F_VIRGL feature negotiation during device initialization to\nactivate the virgl 3D rendering path.
2026-05-15 07:23:40 +01:00
vasilito a23484237c fix: align MMIO mappings to page boundaries for VirtIO capabilities
VirtIO capability structures can start at non-page-aligned offsets within\nBARs. The kernel physmap requires page-aligned addresses. Align the physical\naddress down, adjust the size, and apply the page offset to the returned\npointer. Track the original map pointer/size separately for correct unmapping.
2026-05-15 07:23:25 +01:00
vasilito 8e5792303a fix: correct BAR size probing for non-zero base addresses
The previous BAR size calculation used !(inverted & mask) & mask which\nproduces incorrect results when the BAR has a non-zero base address.\nUse lowest-set-bit extraction (masked & (!masked + 1)) to correctly\ncompute the BAR size from the writable bit pattern read back from hardware.
2026-05-15 07:23:11 +01:00
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00