base: bump gitlink for ps2d bounded-read fix + acpid power-resource engine (tasks 8,11); evidence: task-11 new, task-3 capture re-run (AMDIF031 confirmed, Raphael iGPU BIOS-disabled)

This commit is contained in:
2026-08-05 14:45:26 +03:00
parent 98bb16cc99
commit ec09b7d990
3 changed files with 247 additions and 128 deletions
@@ -0,0 +1,197 @@
================================================================================
RED BEAR OS — TASK 11 EVIDENCE ARTIFACT
acpid power-resource dependency engine (_PR0/_PR3/_STA/_ON/_OFF, GPP7-class trees)
2026-08-05
================================================================================
STATUS: COMPLETE — 16/16 host tests GREEN
check-sweep: PENDING (blocked by concurrent build holding /tmp/redbear-build.lock)
commit: f203f9e6 on submodule/base
================================================================================
DESIGN
================================================================================
1. POWER-RESOURCE ENGINE (drivers/acpid/src/power.rs, 260 lines)
PowerEngine discovers the ACPI namespace topology at init time by walking
the Namespace tree via `Namespace::traverse`. It finds:
- PowerResource objects (identified by child level kind + parent level values)
- Devices/ThermalZones carrying _PR0 or _PR3 methods
The engine maintains shared state behind parking_lot::Mutex:
- resources: HashMap<String, ResourceEntry> — per-resource state
(system_level, resource_order, on/off state, reference count)
- devices: HashMap<String, DevicePowerEntry> — per-device dependency info
(_PR0 resource list, _PR3 resource list, resolved flags)
Key capabilities:
- Reference counting: mark_resource_on/off with underflow guard
- Cycle detection: DFS-based with Gray/White/Black coloring, returns typed
PowerError::CycleDetected with the cycle path
- Resource ordering: resolve_pr0_from_package matches (system_level, resource_order)
from serialized AmlSerdeValue against the pre-built index; sorts by resource_order
- _STA parsing: ResourceState::from_sta(sta) extracts bit 0 for on/off
- Sequence computation: on_sequence (ascending resource_order), off_sequence (reverse)
2. AML EVALUATION ROUTING
ALL AML method evaluations (_STA, _ON, _OFF, _PR0, _PR3) MUST route through
the serialized AML worker (todo 10's GpeWorker). The scheme-serving thread
never evaluates AML.
For the initial enumeration (expose-only phase), no AML evaluation is needed —
the namespace walk is a pure data-structure traversal. In production, _PR0
resolution and _STA evaluation will go through GpeWorker::enqueue_eval_complex
(to be wired when the power-control write path is activated).
3. SCHEME EXPOSURE (drivers/acpid/src/scheme.rs)
/scheme/acpi/power/ — directory listing: batteries, adapters,
and discovered PowerResource devices
/scheme/acpi/power/<dev>/ — device directory (if has _PR0/_PR3)
/scheme/acpi/power/<dev>/state — "on"/"off"/"unknown"/"not_manageable"
PowerEngine is lazy-initialized on first access to /scheme/acpi/power.
If AML hasn't loaded yet, the directory is empty (safe fallback).
Default policy: ENUMERATE + EXPOSE ONLY. Never power-gates devices
Red Bear drivers are using. Power state changes only on explicit consumer
request (future write path).
================================================================================
FILES CHANGED
================================================================================
NEW:
drivers/acpid/src/power.rs (260 lines)
- PowerEngine struct with namespace walk, ref counting, cycle detection
- ResourceEntry, DevicePowerEntry, ResourceState, DevicePowerState
- PowerError error type (typed, no panics)
- resolve_pr0_from_package, resolve_pr3_from_package
- on_sequence, off_sequence (ordered by resource_order)
- mark_resource_on, mark_resource_off, update_resource_sta
- short_name helper
drivers/acpid/tests/power_resource_standalone.rs (484 lines)
- 16 host-runnable tests over synthetic GPP7-shaped namespace
- Compiled as separate crate (avoids linking libredox on host)
- Fixture: 3 PowerResources (PWRS/PWR2/PWR3), 3 Devices (S0F0/S1F0/S2F0)
MODIFIED:
drivers/acpid/src/acpi.rs
+ enumerate_power_resources() on AmlSymbols — locks namespace,
calls PowerEngine::enumerate
drivers/acpid/src/main.rs
+ mod power;
drivers/acpid/src/scheme.rs
+ power_engine: Option<PowerEngine> field on AcpiScheme
+ ensure_power_engine() lazy init
+ HandleKind::PowerDevice, HandleKind::PowerDevState variants
+ Match arms in open/read/list for power resource devices
================================================================================
TEST RESULTS
================================================================================
Standalone (16/16 GREEN):
$ cd /tmp/power-test && cargo test
running 16 tests
test cycle_detection_no_cycles ... ok
test cycle_detection_detects_injected ... ok
test device_state_transitions ... ok
test empty_package_returns_empty ... ok
test enumerate_discovers_all_devices ... ok
test enumerate_finds_power_resources ... ok
test missing_device_returns_none ... ok
test not_manageable_without_pr0 ... ok
test off_sequence_reverse_of_on ... ok
test on_sequence_ordered ... ok
test ref_count_increments_and_decrements ... ok
test resolve_pr0_deduplicates ... ok
test resolve_pr0_matches_resources ... ok
test resource_not_found_error ... ok
test short_name_extracts_last ... ok
test update_sta_parses_correctly ... ok
test result: ok. 16 passed; 0 failed
In-crate check: cargo check --manifest-path drivers/acpid/Cargo.toml → PASS
Acceptance criteria met:
[x] Synthetic GPP7 tree → correct _ON ordering with ref-counts
[x] Cycle injection → detected + typed error
[x] Missing method → typed error, no panic
[x] Device state transitions: Unknown → On → Off
[x] Empty package → returns empty list
[x] _STA parsing: bit 0 extraction for on/off
[x] resource_order-based sorting (ascending for _ON, descending for _OFF)
================================================================================
DESIGN NOTES
================================================================================
1. PowerResource objects live in the PARENT scope's values, not in the
PowerResource child level's values. This is a property of how
acpi-rs Namespace stores objects: `insert(path, obj)` adds the object
to the last level's values, while `add_level(path, kind)` creates a
child NamespaceLevel. The PowerResource OBJECT is in the parent's
values (keyed by the child's name), while the child level only
indicates the KIND.
2. The _PR0/_PR3 resolution matches by (system_level, resource_order)
against the pre-built resource index. This avoids needing a reverse
lookup from WrappedObject → AmlName. Ambiguous matches log a warning
and take the first entry.
3. Reference counting mirrors Linux power.c: ref_count increments on
mark_resource_on, decrements on mark_resource_off, _ON only on
0→1 transition, _OFF only on 1→0 transition.
4. Cycle detection uses standard DFS with three-color marking.
Cycles could theoretically exist when a PowerResource's _PR0
references another device's resources (though this is theoretical).
5. The scheme thread NEVER evaluates AML. PowerEngine enumeration uses
only namespace data-structure traversal (no AML). Future _STA/_ON/_OFF
calls will go through the GpeWorker's serialized channel.
================================================================================
COMMIT
================================================================================
Branch: submodule/base
SHA: f203f9e6
Message: feat(acpid): power-resource dependency engine (_PR0/_PR3/_STA/_ON/_OFF)
Parent gitlink NOT bumped (orchestrator does that)
================================================================================
RISKS
================================================================================
- CHECK-SWEEP: The canonical build via build-redbear.sh --check-sweep
is blocked by a concurrent build holding /tmp/redbear-build.lock.
This must be re-run when the lock is released.
- AML EVALUATION: The GpeWorker's enqueue_eval currently only handles
Vec<u64> return types. For _PR0/_PR3 evaluation (which returns
Package of References), a new AmlWork::EvalComplex variant returning
AmlSerdeValue will be needed. This is deferred until the power-control
write path is activated — the initial enumeration phase does not need
it (namespace walk is pure data traversal).
- NAME NORMALIZATION: AmlName::as_string() produces normalized paths
(e.g., \_SB_.PCI0.GPP7.S0F0) while human input uses AmlName::from_str
format (\\_SB.PCI0.GPP7.S0F0). The power engine uses as_string()
format internally. Scheme path components use the human format.
The short_name() helper bridges this for scheme directory listings.
================================================================================
EVIDENCE PATH
================================================================================
.omo/evidence/task-11-ryzen-7000-x670e-compat.txt
+49 -127
View File
@@ -1,149 +1,71 @@
# Task 3 — Ryzen 7000 / X670E Host Evidence Capture
**Plan:** `.omo/plans/ryzen-7000-x670e-compat.md`
**Date:** 2026-08-05T14:30:00+0300
**Tool:** `local/scripts/capture-host-evidence/` (Rust, 26 unit tests)
---
## Command Log
```bash
# Non-root captures (runs as kellito)
cargo test --manifest-path local/scripts/capture-host-evidence/Cargo.toml # 26/26 PASSED
cargo build --manifest-path local/scripts/capture-host-evidence/Cargo.toml # OK (warnings: unused madt types — used only from tests)
./local/scripts/capture-host-evidence/target/debug/capture-host-evidence # 9 collected, 1 partial, 5 missing
# Root captures (requires operator sudo — script ready)
sudo ./local/scripts/capture-host-evidence/capture-root.sh
# Then re-run: cargo run --manifest-path local/scripts/capture-host-evidence/Cargo.toml
```
**Date:** 2026-08-05T14:34:12+0300
## Summary
- **Collected:** 9 non-root artifacts
- **Partial:** 1 (/proc/iomem — addresses zeroed)
- **Missing:** 5 (acpidump, dmidecode, dmesg, nvme id-ctrl, /sys/kernel/debug/usb/devices — all need root)
- **Secret scan:** 0 hits across 8 committed files (lspci, cpuinfo-tsc, lsusb-t, firmware, bridge-bar-topology, baselines-verification, madt-analysis, README)
Collected: 9 non-root artifacts
Partial: 1 artifacts (need root for full data)
Empty: 0 artifacts
Missing: 5 artifacts (root/tool required)
## Evidence Artifacts
## What was captured
| File | Source | Lines | Status |
|------|--------|-------|--------|
| `lspci.txt` | `lspci -nnvvv -xxx` | 952 | ✅ Collected |
| `iomem.txt` | `/proc/iomem` | 125 | ⚠️ Partial (zeroed — needs root) |
| `cpuinfo-tsc.txt` | `/proc/cpuinfo` | 124 | ✅ Collected |
| `lsusb-t.txt` | `lsusb -t` | 35 | ✅ Collected |
| `firmware.txt` | `/lib/firmware/{amdgpu,mediatek,rtl_nic}` | 794 | ✅ Collected |
| `bridge-bar-topology.txt` | `lspci -vvv` BAR lines | 101 | ✅ Collected |
| `baselines.toml` | F2 immutable diff baselines | 44 | ✅ Written (task-specified SHAs) |
| `baselines-verification.txt` | Verification report | — | ✅ Generated |
| `IGPU-BIOS-ENABLE-INSTRUCTIONS.md` | iGPU enable instructions | 43 | ✅ Written |
| `madt-analysis.txt` | Synthetic MADT expected types | — | ✅ Generated (real parse pending root) |
- - lspci -nnvvv -xxx: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/lspci.txt (952 lines)
- - /proc/cpuinfo (TSC flags): /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/cpuinfo-tsc.txt (124 lines)
- - lsusb -t: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/lsusb-t.txt (36 lines)
- - firmware inventory: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/firmware.txt (794 lines)
- - bridge-window/BAR topology: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/bridge-bar-topology.txt (101 lines)
- - baselines.toml verification: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/baselines-verification.txt
- - wrote /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/IGPU-BIOS-ENABLE-INSTRUCTIONS.md (1358 bytes)
- - MADT analysis: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/madt-analysis.txt
- - Secret scan: 0 hits across 8 files
## Root-Capture Artifacts (After `capture-root.sh`)
## Partial captures (root needed)
| File | Source | Notes |
|------|--------|-------|
| `raw-apic.dat` | `acpidump -b``apic.dat` | Parsed by Rust MADT parser → `madt-analysis.txt` |
| `dmidecode.txt` | `sudo dmidecode` (redacted) | DMI info with serials/UUIDs redacted |
| `dmesg-display.txt` | `sudo dmesg \| grep -iE 'amdgpu\|drm\|fb'` | Filtered display lines |
| `nvme-id-ctrl.txt` | `sudo nvme id-ctrl` HMB fields | HMPRE/HMMIN/HMMINDS/HMMAXD |
| `usb-debug-devices.txt` | `sudo cat /sys/kernel/debug/usb/devices` | USB topology |
| `lspci-xxxx.txt` | `sudo lspci -nnvvv -xxxx` | Full extended config space |
- - PARTIAL /proc/iomem: /mnt/data/kellito/Builds/RedBear-OS/local/docs/evidence/ryzen-x670e/iomem.txt
Status: captured (125 lines) but MOST addresses are zeroed (non-root limitation)
Runbook: sudo cat /proc/iomem (or run capture-root.sh first)
Raw ACPI table binaries go to `~/redbear-evidence-raw/` (OUTSIDE the repo). SHA-256 manifest at `~/redbear-evidence-raw/RAW-MANIFEST.md`.
## MISSING artifacts and why
## MADT Record-Type Inventory
- - 💀 MISSING /sys/kernel/debug/usb/devices
Reason: cannot read: Permission denied (os error 13)
Runbook: sudo cat /sys/kernel/debug/usb/devices (or run capture-root.sh first)
- - 💀 MISSING dmesg
Reason: dmesg failed: dmesg: чтение буфера ядра завершилось неудачно: Операция не позволена
**Status:** Synthetic (real parse requires root — `capture-root.sh` collects `apic.dat`, Rust MADT parser is ready).
Runbook: sudo dmesg | grep -iE 'amdgpu|drm|fb|efifb' (or run capture-root.sh first)
- - 💀 MISSING dmidecode
Reason: permission denied (needs root)
Runbook: sudo dmidecode (or run capture-root.sh first: sudo ./local/scripts/capture-host-evidence/capture-root.sh)
- - 💀 MISSING acpidump -b
Reason: acpidump failed (likely needs root): Could not open table file: /sys/firmware/acpi/tables/SSDT4
Could not get ACPI tables, AE_ACCESS
**Expected record types on this firmware:**
- Type 0 (Processor Local APIC) — 24 entries (12C/24T)
- Type 1 (I/O APIC) — multiple I/O APICs (dual-Promontory chipset)
- Type 2 (Interrupt Source Override) — ISA IRQ remaps
- Type 4 (Local APIC NMI) — LINT1 NMI per CPU
- Type 5 (Local APIC Address Override) — if 64-bit LAPIC base
- Type 9 (Processor Local x2APIC) — x2APIC entries (modern Zen4)
- Type 0xA (Local x2APIC NMI) — per-CPU NMI via x2APIC
Runbook: sudo acpidump -b # then copy *.dat to ~/redbear-evidence-raw/ per hygiene rules
- - 💀 MISSING nvme id-ctrl
Reason: nvme id-ctrl failed (needs root + nvme-cli installed)
Runbook: Install nvme-cli: pacman -S nvme-cli / apt install nvme-cli
Then: sudo nvme id-ctrl /dev/nvme0 and sudo nvme id-ctrl /dev/nvme1
CRITICAL: This is Gate A's HMB assertion input.
(Or run capture-root.sh first: sudo ./local/scripts/capture-host-evidence/capture-root.sh)
**Parser validation:** 14 unit tests in `src/madt.rs` over synthetic MADT bytes (empty, type-0-only, mixed type-0+9+4+0xA, >255 APIC IDs, malformed sub-2-byte records, truncated records, bad signature, declared-length clamping, zero-length records). All 26 total tests pass.
See `local/docs/evidence/ryzen-x670e/README.md` for the full operator runbook.
**To complete:** Run `sudo ./local/scripts/capture-host-evidence/capture-root.sh`, then re-run the tool. The Rust MADT parser will parse `raw-apic.dat` and output a real record-type inventory.
## MADT analysis
## iomem AMDIF031 Line
The MADT could not be extracted (acpidump requires root). See `madt-analysis.txt` for expected record types and unit test coverage.
Unit tests: `cargo test --manifest-path local/scripts/capture-host-evidence/Cargo.toml`
```
00000000-00000000 : AMDIF031:00
00000000-00000000 : AMDIF031:00 AMDIF031:00
00000000-00000000 : amd_iommu
00000000-00000000 : AMDIF031:01
00000000-00000000 : AMDIF031:01 AMDIF031:01
```
## baselines.toml
**AMDIF031 CONFIRMED on this platform.** Addresses are zeroed (non-root limitation). The device IS present — the expected 0xfb300000 region will be confirmed when `capture-root.sh` is run with sudo. Confirmed match: `AMDIF031:00` and `AMDIF031:01` both present, matching the dual-Promontory X670E chipset topology.
Preserved (not overwritten). Verification report in `baselines-verification.txt`.
## iGPU (Raphael 1002:164e) Enumeration Status
## Gate A — Critical blockers
**STATUS: IGPU_NOT_ENUMERATED** — the Raphael iGPU (1002:164e) is ABSENT from `lspci -nnvvv` output.
**Actual GPU found:**
```
01:00.0 VGA compatible controller: NVIDIA Corporation AD103 [GeForce RTX 4080] (rev a1)
```
**Framebuffer:** `/sys/class/graphics/fb0` reports `nvidia-drmdrmfb` (NVIDIA simplefb — NOT Raphael amdgpu).
**GOP/Display Evidence:**
- No Raphael iGPU (1002:164e) in lspci → BIOS-disabled, as expected for MS-7D70 with dGPU present
- No amdgpu lines in dmesg (kernel.dmesg_restrict=1 blocks non-root access; `capture-root.sh` resolves)
- fb0 is NVIDIA, not AMD
- `/lib/firmware/amdgpu/` contains 675 files including `gc_11_0_1_*` (Raphael-compatible) and `psp_13_0_5_*`
**BIOS change required (operator action):** See `local/docs/evidence/ryzen-x670e/IGPU-BIOS-ENABLE-INSTRUCTIONS.md`. The iGPU must be set to "Force" in BIOS → Integrated Graphics Configuration before any Raphael display work can proceed.
## DCN315 Closure Evidence
The DCN315 closure file is at `local/docs/evidence/ryzen-x670e/dcn315-closure.md`. This was generated independently (Round 21 task) and is NOT owned by this task. It is **immutable**: this capture task reads it, does NOT modify it.
## baselines.toml Verification
| Component | Expected SHA (task) | Actual HEAD (2026-08-05) | Match |
|-----------|---------------------|--------------------------|-------|
| parent | 47a22479bc... | cab22e5a4a... | ❌ Differs (commits landed) |
| base | 219b2e5f9f... | aeb2df8e06... | ❌ Differs (commits landed) |
| bootloader | 44d3f3b11d... | 44d3f3b11d... | ✅ |
| installer | b3a500ec52... | b3a500ec52... | ✅ |
| kernel | 088ab2dd67... | 088ab2dd67... | ✅ |
| libredox | afc0d4d4af... | afc0d4d4af... | ✅ |
| redoxfs | 5a07d59f2a... | 5a07d59f2a... | ✅ |
| relibc | ae06748508... | ae06748508... | ✅ |
| syscall | ca430f0601... | ca430f0601... | ✅ |
| userutils | 89e53284f7... | 89e53284f7... | ✅ |
baselines.toml uses the task-specified SHAs (immutable F2 diff baseline). parent and base have since advanced. The 8 submodule SHAs match current HEADs.
## Evidence Hygiene
- ✅ Raw ACPI binaries: designed to go to `~/redbear-evidence-raw/` (OUTSIDE repo) via `capture-root.sh`
- ✅ Committed files: decompiled/redacted excerpts only
- ✅ Secret scan: 0 hits across 8 committed files (serials, MACs, UUIDs all caught by redact.rs)
- ✅ No raw dumps committed into the repo tree
- ⚠️ Root capture script (`capture-root.sh`) is committed and ready — operator must run with sudo
## Gate A — Critical Information
- **nvme id-ctrl HMB fields:** PENDING — `capture-root.sh` collects `nvme-id-ctrl.txt` with sudo
- **Raphael iGPU (1002:164e):** ABSENT — IGPU_NOT_ENUMERATED; operator must enable in BIOS
- **acpidump (MADT/MCFG/IVRS/FADT):** PENDING — `capture-root.sh` collects `.dat` files to `~/redbear-evidence-raw/`
- **AMDIF031 at 0xfb300000:** CONFIRMED PRESENT (address zeroed non-root; sudo confirms actual address)
- **AMD-Vi IOMMU:** CONFIRMED PRESENT in `/proc/iomem` (IVRS table needs root acpidump)
## Tool Quality
- **Language:** Rust (project policy)
- **Tests:** 26/26 passing (14 MADT parser + 12 redact/secret-scan)
- **Build:** Clean (6 warnings: unused MADT types — used only by tests, expected)
- **Root fallback:** All collectors check for pre-captured files from `capture-root.sh` before running live commands
- **Redaction:** Auto-redacts serial numbers, MACs, UUIDs in dmidecode/lspci/dmesg outputs
- **Secret scan:** Zero-tolerance scan over all committed `.txt` files; 0 hits across 8 files
- **nvme id-ctrl HMB fields**: MISSING (needs root + nvme-cli). Gate A's HMB assertion depends on this.
- **Raphael iGPU (1002:164e)**: ABSENT from lspci. BIOS-disabled. See IGPU-BIOS-ENABLE-INSTRUCTIONS.md.
- **acpidump (MADT/MCFG/IVRS/FADT)**: MISSING. Needed for todo 5 (MADT normalization), todo 14 (AMD-Vi), todo 15 (PCI auditor).