Commit Graph

38 Commits

Author SHA1 Message Date
Red Bear OS 92bf05c20a pcid: EOF config reads at the config-space boundary (256 fallback / 4096 ECAM)
The Handle::Config read handler never returned 0, so fs::read /
read_to_end on /scheme/pci/<addr>/config streamed dwords forever —
any unbounded read of a config file hung. Found by the initfs
driver-manager hang: propose_msix_vectors' unbounded config read never
terminated, stalling the oneshot initfs service and the whole boot.

- cfg_access: Pcie::has_ecam() reports ECAM availability.
- scheme: config_space_size() = 4096 with ECAM, 256 in PCI 3.0
  fallback; the read handler returns Ok(0) at the boundary and fstat
  advertises the correct size.
2026-07-23 22:19:19 +09:00
Red Bear OS b0e760659c pcid: no panic on PCI 3.0 fallback config access; warning sweep
- fallback.rs: config reads at offset >= 256 (PCIe extended space) now
  return the PCI-standard 0xFFFFFFFF 'absent' value and writes are
  dropped, instead of panicking the PCI daemon. This is the exact
  behavior of real hardware and Linux's CF8 path on MCFG-less machines,
  and it lets MSI-X feature discovery degrade to INTx cleanly. Found by
  the first driver-manager QEMU gate (i440fx): pcid panicked at
  fallback.rs:65 and the boot hung.
- driver_handler.rs: drop vestigial func param from read_full_device_id.
- driver_interface/mod.rs: use Option::insert's return value directly
  (must_use) instead of discarding and re-reading as_ref.
2026-07-23 20:13:17 +09:00
Red Bear OS 9c571e2942 pcid: guard config access against out-of-range offsets (fixes boot panic)
An extended-capability walk (pci_types capabilities()) that follows a
chain running to/past the end of config space read at offset 4096,
which tripped the dword-offset assert in bus_addr_offset_in_dwords
("pcie offset larger than 4095") and aborted pcid with an Invalid
opcode fault / UNHANDLED EXCEPTION on boot — after switchroot to /usr,
so it blocked reaching login.

PCIe config space is exactly 4096 bytes (offsets 0..=4095). Fix at two
levels:

- ConfigRegionAccess::read/write (cfg_access/mod.rs): guard the single
  access choke point — an out-of-range read returns the PCI "no
  response" pattern (0xFFFFFFFF, which also terminates a capability
  walk cleanly) and an out-of-range write is a no-op. This catches any
  caller (capability walk, scheme reads, driver access).

- scheme.rs config read/write loop: clamp the loop bound with
  saturating_add(...).min(4096) so a consumer requesting offset+len
  past the boundary reads only the valid part instead of looping to
  offset 4096.

Verified: boot no longer panics in pcid (progresses past the previous
crash point through switchroot and the /usr driver set).
2026-07-22 14:20:57 +09:00
Red Bear OS ddcd08709f pcid: read REDBEAR_DRIVER_PCI_IRQ_MODE / DISABLE_ACCEL env vars
The pcid_interface crate now reads the two env vars emitted by
driver-manager's SpawnDecision committee:
- REDBEAR_DRIVER_PCI_IRQ_MODE: lets the spawned child know
  whether to fall back to MSI / INTx instead of MSI-X
- REDBEAR_DRIVER_DISABLE_ACCEL: lets the spawned child suppress
  hardware acceleration (matches PciQuirkFlags::DISABLE_ACCEL)

Both values are stored on PciFunctionHandle and exposed via
accessors (irq_mode_hint / disable_accel_hint) so the driver
daemons can read them at startup. 6 new unit tests cover the
env-var parsing.

Refs: local/docs/DRIVER-MANAGER-MIGRATION-PLAN.md § 5.2 D2.7.
2026-07-21 12:07:49 +09:00
Red Bear OS 2b48b9e966 pcid: log PCIe->I/O-port fallback at info; fbcond: transient no-display at debug 2026-07-16 06:39:43 +09:00
Red Bear OS 3fe7b12434 fix: add try_map_bar, try_pci_allocate_interrupt_vector, fix try_mem return type
- try_mem now returns Result (matching caller expectations)
- try_map_bar: non-panicking BAR mapping on PciFunctionHandle
- try_pci_allocate_interrupt_vector: non-panicking IRQ allocation
- virtio-core: reverted .ok_or() back to .map_err() for Result type
2026-07-12 02:48:16 +03:00
Red Bear OS 4932cb4d62 fix: add try_port() to PciBar and try_irq_handle() to LegacyInterruptLine
Non-panicking variants needed by ac97d, vboxd, and other drivers that
prefer error handling over panics.
2026-07-12 02:39:59 +03:00
Red Bear OS bf9989b7c0 fix: add try_mem() to PciBar, fix virtio-core caller
Added try_mem() returning Option<(usize, usize)> for non-panicking
memory BAR access. Fixed virtio-core/probe.rs to use .ok_or() instead
of .map_err() to match the Option return type.
2026-07-12 02:34:09 +03:00
Red Bear OS 00b799d512 absorb: 41 orphaned base patches re-applied (Phase 1.0A)
Per local/docs/PATCH-PRESERVATION-AUDIT-2026-07-12.md the base
fork was carrying only 38 of 100 patches in local/patches/base/.
The other 62 patches' content was silently missing from the fork
working tree, even though their .patch files were preserved.

This commit re-applies 41 patches that genuinely still apply
cleanly + 17 hunks that partially applied. Recovery covers:

- D-Bus initfs service wiring (P4-initfs-dbus-services)
- USB service wiring (P4-initfs-usb-drm-services)
- netcfg/dhcp/dhcpv6 driver fixes
- acpid shutdown/PM/quirk fixes
- inputd/ps2d hard-fail logging
- pcid driver interface refinements (server cmd channel)
- virtio-core for VirtualBox support
- ixgbed/rtl8139/rtl8168 net drivers
- ahcid NCQ + per-function interrupt coalescing
- logd persistent logging
- bootstrap procmgr race-condition fixes
- cargo version pin to +rb0.3.0 (synchronized release branch)

58 files changed, +1444/-318 lines.

Untracked mnt/ tree and *.orig / *.rej files cleaned up after
patch application (leftover from absolute-path patch headers).
2026-07-12 01:29:08 +03:00
Red Bear OS bd595851e2 base: apply Red Bear patches on latest upstream/main
251 files: init, acpid, ipcd, netcfg, ihdgd, virtio-gpud, scheme-utils,
inputd, block driver, ptyd, ramfs, randd, initfs bootstrap, path deps,
version +rb0.3.1, author attribution
2026-07-11 11:39:24 +03:00
bjorn3 24fb66e144 Fix warnings for updated rustc
And move away from an internal feature now that there is a proper
(unstable) function for it.
2026-05-27 21:11:53 +02:00
bjorn3 e9fd66c78e drivers/pcid: Map BAR through pcid
This way PCI drivers don't need to use the privileged physmap interface,
but only need access to a pcid handle. This is not yet enough for
running drivers as unprivileged processes. Interrupts also need
privileges and we need IOMMU support in the kernel.
2026-05-09 20:53:21 +02:00
bjorn3 d528fb73b4 drivers: Use map_bar instead of physmap where possible
Physmap requires root, while map_bar in the future could be run as
unprivileged process given a pcid handle for the target device.
2026-05-09 20:12:41 +02:00
bjorn3 28900f7c49 scheme-utils: Introduce Blocking as counterpart to ReadinessBased for blocking schemes 2026-04-19 11:05:04 +02:00
bjorn3 6686c73d26 Implement on_close method of SchemeSync instead of using a separate method 2026-04-19 10:42:19 +02:00
bjorn3 317a0178b6 Introduce scheme-utils crate and HandleMap type
HandleMap deduplicates the id assignment for handles and unlike most
existing implementations handles overflow just fine.
2026-04-13 22:19:07 +02:00
auronandace 557a3d1954 consolidate several dependencies into the workspace 2026-03-22 15:11:33 +00:00
Ribbon 90ea974ce0 Add missing Cargo package description and update drivers README 2026-03-16 10:39:15 -06:00
Ibuki Omatsu 2738f69224 feat: Implement std_fs_call handling to initfs, ramfs, acpi and xhci 2026-02-28 08:15:16 -07:00
auronandace 7849aa23b3 make serde and toml workspace dependencies 2026-02-27 08:39:29 +00:00
auronandace 4e77bb0f96 add precedence lint to drivers 2026-02-20 15:00:43 +00:00
bjorn3 7f0e870b76 Update to pci_types 0.10.1
And avoid hiding channel open errors in pcid-spawner. This would have
made the location of the problem more obvious.
2026-02-07 18:02:32 +01:00
Ibuki.O 22ab1e7878 chore: Pin pci_types version to 0.10.0. 2026-02-07 22:56:50 +09:00
bjorn3 fc1c391340 Move common::init call into pcid_interface::pci_daemon 2026-01-25 20:08:49 +01:00
Ibuki Omatsu 334928f151 feat: Introduce userspace namespace manager and adapt all schemes. 2026-01-20 20:56:58 -07:00
Jeremy Soller f740b61774 Use workspace dependencies for many common crates 2026-01-20 10:12:08 -07:00
Wildan M d08c6cbe6f Split driver log level env 2026-01-10 06:35:06 +07:00
Jeremy Soller b1c95d31e7 ihdgd: start parsing BIOS tables 2025-12-19 08:15:06 -07:00
Jeremy Soller 0fee261866 Allow reading PCI ROM address and size 2025-12-18 12:15:23 -07:00
Ibuki Omatsu 3681e1b74a refactor: Replace unlink and rmdir with unlinkat in ramfs. Update redox-scheme and redox-rt for bootstrap. 2025-12-17 18:46:05 -07:00
bjorn3 256f4fe6b8 drivers/pcid: Update to redox-scheme 0.8 2025-12-13 13:08:31 +01:00
bjorn3 1ac570fe06 Couple of minor feature gate changes 2025-12-13 12:38:22 +01:00
bjorn3 3abe41d258 drivers/pcid: Add pci_daemon function
This handles daemonization and getting the PciFunctionHandle.
2025-12-04 11:44:29 +01:00
bjorn3 f06923b201 Standardize main function of all daemons 2025-12-04 11:44:29 +01:00
bjorn3 7aa0776abd Rustfmt 2025-12-03 22:02:20 +01:00
bjorn3 f1057b6750 daemon: Abort on errors
All users did this anyway. And handling it inside the daemon crate
allows avoiding a panic of the parent process when the child process
panicked.
2025-12-03 21:55:47 +01:00
bjorn3 54d81e7423 Merge redox-daemon into this repo 2025-12-03 21:07:13 +01:00
bjorn3 07a2b97f08 Add 'drivers/' from commit '20ffe4d7f4a85b7cc1f59495d7e6e355fed4cb06'
git-subtree-dir: drivers
git-subtree-mainline: e76ecea4ce
git-subtree-split: 20ffe4d7f4
2025-11-29 19:04:04 +01:00