QEMU's PIIX4 emulation does not model IA32_PERF_STATUS, so the
dwell counter cannot confirm a state transition actually took
effect and the governor oscillates P0<->P1 on idle. On a real
hypervisor (QEMU/KVM, VMware, VirtualBox, Hyper-V, Xen) the MSR
writes are also typically no-ops on the underlying emulation.
detect_virtualization() reads /sys/class/dmi/id/sys_vendor and
product_name. If the system vendor contains 'qemu', 'kvm',
'vmware', 'virtualbox', 'hyper-v', or 'xen', CpuInfo is
constructed with read_only=true and apply_pstate() short-
circuits at the top: the load value is still tracked and the
governor still logs its choice, but no MSR writes fire. On
real hardware (LG Gram 2025, etc.) the existing behavior is
preserved exactly.
The redundant DWELL_CYCLES constant is removed (DWELL_POLLS
already serves that role).
Phase H of CONSOLE-TO-KDE-DESKTOP-PLAN.md.
C1 (Critical): Binary store restore now iterates ALL stage directories
instead of only the first, matching how cook_creates handles multi-stage.
C2 (Critical): All binary store restore errors are now logged via
log_to_pty! instead of being silently discarded with let _ =.
H1 (High): dep_hashes.toml keys now use full PackageName (including
host: prefix) via name.to_string() instead of name.without_prefix(),
preventing host/target key collisions.
H2 (High): Patch file mtimes are now included in source_modified
calculation, so editing a patch correctly triggers a rebuild.
H4 (High): All to_str().unwrap() calls replaced with safe alternatives
(to_string_lossy, direct PathBuf refs) to prevent panics on non-UTF8
paths.
H5 (High): auto_deps.toml reconstruction now logs a warning that it
may be incomplete (does not include ELF-discovered dynamic linking deps).
M1 (Medium): dep_hashes.toml is now written atomically via write-to-tmp
+ fs::rename, preventing corrupted/partial files on crash.
M3 (Medium): Missing source dir now triggers rebuild (SystemTime::now()
fallback) instead of being masked as no-change via UNIX_EPOCH.
- AGENTS.md: add cache system to STRUCTURE, WHERE TO LOOK, BUILD FLOW,
BUILD COMMANDS (--force-rebuild), and CONVENTIONS (dep_hashes.toml,
binary store restore, package_groups syntax)
- CHANGELOG.md: comprehensive entry for Phase 1-3 + kernel MWAIT +
ninja-build Redox support
- local/AGENTS.md: note installer fork adds package groups support
- BUILD-CACHE-PLAN.md: fix TOML syntax (underscores not hyphens),
update all phases to COMPLETE with implementation details, add cache
flow diagram, add verification results
The LG Gram 16 (2025) ships with Intel Arrow Lake-H (Core Ultra 7
255H). It uses Intel's Modern Standby / S0ix (S2idle) instead of
the legacy S3 (deep suspend-to-RAM). The kernel-side MWAIT path
(Phase G.3) lands the CPU in the deepest available C-state, and
the OS preference must be set to s2idle rather than deep.
This commit adds two `dmi_system_quirk` entries to
50-system.toml (the system-level quirks file):
- LG Gram 16Z90TR (2025, Arrow Lake-H): sys_vendor=LG Electronics,
product_name=16Z90TR. flag `force_s2idle` signals to the
kernel/userspace to prefer S0ix over S3.
- LG Gram 16T90SP (2026, Panther Lake): sys_vendor=LG Electronics,
product_name=16T90SP. Same Modern Standby preference.
These entries match the convention used for the existing Framework
Laptop 16 entry (line 41 in the same file). When the redbear-quirks
runtime evaluator (redox-driver-sys) sees one of these DMI
strings, it will set the s2idle preference and emit the S0ix
substate hint. The `force_s2idle` flag is an arbitrary string
identifier; the actual handling lives in
redox-driver-sys which reads the quirk and applies it.
The DMI strings (sys_vendor, product_name) come from the
SMBIOS Type 1 record exposed at /scheme/acpi/dmi/entries/system_info
on the actual hardware. The kernel-side FACS parser (Phase F.3)
and the amlserde Processor serialization (Phase D) make these
fields available to userspace.
Phase G.8 was previously listed as open in the final review.
This commit closes it for the LG Gram target hardware.
The previous "outer: bump local/sources/{kernel,base} submodules"
commit (9381ed4fd) showed the diff for the kernel gitlink in
git show output, but the outer repo's .gitmodules file did NOT
register local/sources/kernel as a real submodule. This meant the
pointer change in 9381ed4fd was a working-tree-only edit, never
actually committed to the outer repo's index.
This commit rectifies the inconsistency: register
local/sources/kernel in .gitmodules pointing at the Red Bear gitea
fork (https://gitea.redbearos.org/vasilito/redbear-os-kernel.git),
then bump it to the Phase G.3 commit (19010ce) which adds the
MWAIT idle_loop.
For the LG Gram 2025 / Arrow Lake-H this matters: the existing
enable_and_halt() path lands the CPU in C1 only. The new MWAIT
idle_loop enters the deepest available C-state (C6/C7/C8/C9/C10/S0iX),
which dramatically reduces idle power on real hardware.
Note: local/sources/base is a separate git repo without a
.gitmodules entry; it works in practice because the
"outer: bump local/sources/{kernel,base} submodules" commit
captures its diff as a subproject change in the commit object,
but the working tree is never updated. A follow-up could add a
.gitmodules entry for base too, but the current approach has
worked for the prior base commits (8cd4f69's diff-via-base
and earlier 4f2a043 re-sync).
This is the SECOND commit to track the same kernel submodule
bump (cf. 9381ed4fd which only captured the change in tree
state). The previous commit was effectively informational only;
this one makes the change permanent in the outer index.
These are leftover cache artifacts from earlier build experiments.
The new content-hash-based cache system stores dep_hashes.toml in
per-recipe target/ dirs and repo/ binary store, not in local/cache/.
kernel (2 commits):
- drop -Z json-target-spec (redundant with --target)
- add MWAIT idle_loop for deeper C-states on modern CPUs (Phase G)
ninja-build (1 commit):
- add Redox subprocess fork/exec and GetLoadAverage support
- config/redbear-full.toml: 9 package groups defined (graphics-core,
input-stack, dbus-services, firmware-stack, qt6-core, qt6-extras,
kf6-frameworks, desktop-session, kde-desktop)
- Cargo.toml: switch redox_installer from upstream git to local fork
(path = "local/sources/installer") to use package group support
- Cargo.lock: remove installer git source entry
- local/sources/installer: bump to package groups commit
Groups are resolved transparently by Config::from_file() — the cookbook
repo binary sees expanded packages automatically.
Phase 1 — Hash-based cache invalidation:
- DepHashes struct: BLAKE3 hash of each build dep stored in dep_hashes.toml
- collect_current_dep_hashes(): reads blake3 from dep .toml metadata
- dep_hashes_changed(): compares stored vs current hashes
- Replaces mtime comparison as primary cache invalidation check
- Mtime fallback preserved for backward compatibility (no dep_hashes.toml)
- --force-rebuild CLI flag bypasses cache entirely
Phase 2 — Binary store cache lookup:
- repo_builder publishes dep_hashes.toml alongside .pkgar/.toml in repo/
- When target/ is missing but repo/ has the package, restores stage
artifacts by extracting pkgar, copying toml + dep_hashes.toml
- Auto-generates auto_deps.toml from repo depends field
- Only applies to non-remote, non-force-rebuild builds
See local/docs/BUILD-CACHE-PLAN.md for full architecture.
Update the inner-fork submodule pointers to reflect:
- local/sources/kernel: 8cd4f69 (Phase G.1: /scheme/sys/msr/ scheme)
- local/sources/base: c335553 (Phase G.6: /scheme/acpi/processor/)
No source changes in the outer repo. The submodules already
contain all the new code; this commit only updates the
gitlink pointers so `git diff --submodule=log` shows the
correct history.
The `local/cache/` directory deletions are normal: the
cookbook cleans cached package artifacts when source hashes
change. `local/sources/base/target` is also a build artifact.
`local/recipes/dev/ninja-build/source` is a pre-existing dirty
state from a prior session — not changed by Phase G work.
Verified by: `git diff --submodule=log` shows the new inner
commits, and CI=1 ./local/scripts/build-redbear.sh redbear-mini
builds the same 512 MB ISO with the Phase G.1 / G.2 / G.5 / G.6
code paths in effect.
The MSR library was missing the HWP (Hardware P-states / Intel Speed
Shift) MSR set. Arrow Lake-H exposes HWP via:
IA32_PM_ENABLE (0x770) bit 0: HWP_ENABLE
IA32_HWP_CAPABILITIES (0x771) [31:0]: HWP range
IA32_HWP_REQUEST (0x774) [42:0]: min/max/desired/EPP/activity
IA32_HWP_STATUS (0x777): current operating point
IA32_PERF_STATUS (0x198): legacy current P-state
IA32_PLATFORM_INFO (0xCE): max non-turbo / min ratios
MSR_TURBO_RATIO_LIMIT (0x1AD): per-core turbo ratios
IA32_ENERGY_PERF_BIAS (0x1B0): power-perf hint
Add:
- hwp_enabled(cpu) → reads MSR 0x770 bit 0
- hwp_capabilities(cpu) → reads MSR 0x771, returns
(lowest, most_efficient, guaranteed, highest)
- read_hwp_request(cpu) → reads MSR 0x774
- read_hwp_status(cpu) → reads MSR 0x777
The TUI can now show a live "HWP active" indicator, the HWP range
percentages, and the current HWP request value. The HWP range
is computed once at startup; updates need only a re-read of
MSR 0x774 (8 bytes, ~microseconds).
The phase-G.1 kernel MSR scheme (commit 8cd4f69) provides the
in-memory storage for these reads. On real hardware, the kernel
will write the actual MSR values; on QEMU they default to zero
which makes the TUI display "HWP inactive" without erroring.
Phase G.2 of the ACPI/Arrow Lake port. The LG Gram 2025 (Core Ultra 7
255H, Arrow Lake-H) uses Intel HWP for P-state control — legacy
IA32_PERF_CTL writes are silently ignored when HWP is active.
The previous cpufreqd always wrote IA32_PERF_CTL (MSR 0x199), which
on Arrow Lake-H had zero effect. We now:
1. Detect HWP at startup by reading IA32_PM_ENABLE (MSR 0x770) bit 0
2. If HWP is active:
a. Read IA32_HWP_CAPABILITIES (MSR 0x771) for the
min/max/guaranteed/efficient performance range
b. Translate the governor's P-state index into the HWP
"Desired Performance" field + EPP hint
c. Write IA32_HWP_REQUEST (MSR 0x774) instead of IA32_PERF_CTL
3. If HWP is not active, fall back to the legacy IA32_PERF_CTL path
(preserves backward compatibility for older CPUs)
The kernel's new /scheme/sys/msr/ scheme (Phase G.1) provides the
in-memory storage backing the MSR reads/writes. On the real LG Gram
2025 hardware, the kernel's MSR scheme will be wired to the actual
hardware MSRs (Phase G+ work); the cpufreqd interface is unchanged.
HWP layout (Intel SDM Vol 3B §14.4.4):
[7:0] Minimum Performance
[15:8] Maximum Performance
[23:16] Desired Performance
[31:24] Energy-Performance Preference (EPP)
[42:32] Activity Window (0 = auto)
[42] Package Control
EPP follows the same index as desired perf: 0 = performance,
255 = power-save. We map the linear P-state index to both the
"Desired Performance" and EPP so the H/W sees a single hint that
the OS wants both the performance and energy level it implies.
Includes:
- PstateMode enum (LegacyPerfCtl | Hwp) for compile-time dispatch
- detect_pstate_mode() reads MSR 0x770
- read_hwp_capabilities() reads MSR 0x771, returns (min, max,
guaranteed, efficient) bytes
- hwp_request_for() maps P-state index to IA32_HWP_REQUEST u64
- apply_pstate() dispatches to the right MSR based on ci.mode
- The /scheme/cpufreq/state output now tags each CPU with [HWP] or
[legacy] for observability
Hardware test plan: on the LG Gram 2025, "performance" governor
should pin IA32_HWP_REQUEST.Desired = hwp_max with EPP=0; "powersave"
should pin it to hwp_min with EPP=255; "ondemand" should ramp
between. Reading IA32_PERF_STATUS (MSR 0x198) via /scheme/sys/msr
should reflect the new operating point within ~1ms.
- CHANGELOG.md: added Phase E entry describing the new
transition_to_s_state / wake_from_s_state / enter_sleep_state
methods on AcpiContext, and the opt-in DMAR init with hard
cap. Includes the final gap-closure status table showing
9 closed, 1 closed-in-part, 2 still open (both require
hardware-specific work).
- local/docs/ACPI-FORK-SYNC-STRATEGY-2026-06-30.md: added
Phase E outcome section with the changes applied and
out-of-scope items.
- CHANGELOG.md: added comprehensive 2026-06-30 entry covering
the full ACPI fork-sync (Phases A-D) and the redbear-sessiond
consumer port. Lists the 7 critical gaps that are now fully closed
and the 2 still open (DMAR + _WAK infrastructure).
- local/docs/ACPI-FORK-SYNC-STRATEGY-2026-06-30.md: added Phase D
outcome section with the Linux 7.1 cross-reference findings
(acpi_enter_sleep_state pattern), the changes applied to acpid
and redbear-sessiond, and the final gap-closure table.
- local/docs/ACPI-IMPROVEMENT-PLAN.md: updated "Current Truthful
Status" to reflect that acpid now follows the Linux 7.1 sleep
pattern with _PTS/_SST evaluation, thermal/power enumeration
works, AML mutex is real, parse_lnk_irc validates ranges, and
S5 works end-to-end. S1-S4 paths still need _WAK + wakeup
vector + P-state preservation (Gap #4b scaffolded but not
implemented). DMAR init still disabled (Gap #2 needs real-HW
investigation).
- local/docs/boot-logs/README.md: added
REDBEAR-MINI-BOOT-PS2D-INPUTD-LOG-FIX.md to the inventory.
Also:
- Removed scratch file local/docs/ACPI-FIX-PLAN-2026-06-30.md
(superseded by the longer ACPI-FORK-SYNC-STRATEGY-2026-06-30.md).
Phase D of the ACPI fork-sync plan (continuation).
Phase B replaced the `/scheme/kernel.acpi/kstop` filesystem file with
a single Fd-based call() interface. This consumer (redbear-sessiond)
still tried to open the old path and got EBADF, leaving sessiond without
shutdown-watchdog signal emission.
The new implementation:
- Opens `/scheme/kernel.acpi` and uses `openat("kstop", ...)` to
get the kstop sub-handle. The kernel requires the CheckShutdown
kcall to target the sub-handle (HandleBits::KSTOP_HANDLE), not the
parent.
- Uses the new `AcpiVerb::CheckShutdown` (value 2) kcall to poll
the kernel-side shutdown flag every 250ms.
- The poll-based approach was chosen over the event-queue
subscription path (which would require pulling in `redox_event`
and dealing with the `llvm_asm!` macro deprecation). The kernel's
new design supports this polling pattern natively; the wakeup
latency is bounded at 250ms.
Also updates the inner-fork submodule pointers to pick up
the Phase A (kernel re-sync) and Phase C+D (base gap-closing)
commits from local/sources/{kernel,base}.
Files:
- local/recipes/system/redbear-sessiond/source/src/acpi_watcher.rs:
rewrote wait_for_shutdown_edge() to use the new Fd interface.
- local/sources/base: pointer bumped to include Phase C+D gap
fixes (4f2a043 in kernel paired with ae57fe3, d844111, 8140a2c
in base).
- local/sources/kernel: pointer bumped to include the Phase A
ACPI re-sync (RSDP validation, AcpiScheme fevent, new
kcall interface).
Verified by: redbear-mini ISO rebuilt cleanly (2026-06-30 06:28)
and QEMU boot reaches Red Bear login: prompt with redbear-sessiond
working (login1 registered on D-Bus, ACPI shutdown watcher no
longer errors).
Previously only gcc-install was patched. Recipes use sysroot copy
which is a copy of relibc-install (NOT gcc-install), so the cstdlib
strtold fix never propagated to the actual compilation environment.
Patch both sysroot and redoxer toolchain copies.
Updates six documentation files to point readers to the new
input-stack observability evidence and changelog entry. No
content claims are altered — only "see also" pointers and inventory
updates.
- CHANGELOG.md: new 2026-06-30 entry documenting the input-stack
fix (commit de9d1f4 in local/sources/base/), the git server
docs rewrite (commit 0c60adc6b), and the build-system
hardening addendum (commit 41045fd2f). Includes the verified
end-to-end interactive login evidence from the rebuilt ISO.
- local/docs/boot-logs/README.md: add the new
REDBEAR-MINI-BOOT-PS2D-INPUTD-LOG-FIX.md file to the
inventory table.
- local/docs/IRQ-AND-LOWLEVEL-CONTROLLERS-ENHANCEMENT-PLAN.md:
see-also pointer in the inputd validation deliverables
section.
- local/docs/REDBEAR-BOOT-EXPERIENCE-PLAN.md: see-also pointer
in the bootanim handoff section, noting that step 6
(REBIND_DISPLAY drm to inputd) now has companion
observability via the new inputd startup log.
- local/docs/USB-IMPLEMENTATION-PLAN.md: see-also pointer in
the HID producer modernization section, noting that the fix
lets operators distinguish "usbhidd dead" from
"usbhidd alive but not enumerated by XHCI".
- local/docs/GREETER-LOGIN-IMPLEMENTATION-PLAN.md: see-also
pointer in the service wiring section, noting that the greeter
can rely on the new inputd/ps2d startup lines being present
before inputd -A 3 runs.
Update REDBEAR-MINI-BOOT-PS2D-INPUTD-LOG-FIX.md with the actual
runtime verification evidence captured at 2026-06-30T00:06:16Z:
- Both new startup log lines appear in initfs at the exact source
line numbers (@inputd:661, @ps2d:96), proving the fix is baked
into the running image.
- End-to-end interactive login succeeded: operator typed root +
password at the Red Bear login: prompt and reached a
redbear# shell (Red Bear OS v0.2.4 "Liliya").
This conclusively confirms the diagnosis: the input chain
(ps2d -> inputd -> fbcond -> getty -> login -> shell) was working
all along. The previous "freeze" was a test-harness issue (no
keystrokes sent to the guest), not an OS bug. The new log::info!()
lines make the input stack health visible in future boot logs.
Two documentation changes:
1. New file local/docs/boot-logs/REDBEAR-MINI-BOOT-PS2D-INPUTD-LOG-FIX.md
captures the 2026-06-30 diagnosis of why the mini boot appeared to
freeze at the login prompt. Records:
- The actual root cause (test harness not injecting keystrokes, not
an OS bug — ps2d/inputd were working silently).
- The committed fix (de9d1f4 in local/sources/base/ adds two
log::info!() startup messages so operators can verify the input
stack is alive from the boot log).
- The expected post-fix boot log lines and how to interpret them.
- Verification status (source-inspected; clean post-fix QEMU boot
pending due to slow bootloader streaming under -nographic).
2. Addendum appended to local/docs/BUILD-SYSTEM-IMPROVEMENTS.md
documenting four build-system ergonomics issues observed during
the diagnosis session:
- #11: local/sources/base/ inner git repo origin points to
upstream Redox instead of Red Bear gitea.
- #12: outer Red Bear repo cannot show inline diffs for the
nested local/sources/base/ git repo (submodule pointer dirty).
- #13: no preflight warning for stale local-fork source (a
4-line edit caused a 30+ min rebuild with no advance notice).
- #14: -nographic + OVMF boot is too slow for time-budgeted
post-fix QEMU verification; recommend BIOS + KVM path.
Both items are S-sized and could be picked up in any future hardening
session. No code changes in this commit.
Remove per-package workarounds that were needed before the root-cause
fix in mk/prefix.mk (which adds #include <stdlib.h> to GCC's <cstdlib>
header at prefix build time). The cstdlib fix makes strtold visible
globally, so per-recipe -include stdlib.h and P1-*.patch are redundant.
Reverted:
- redox-toolchain.cmake: removed -include stdlib.h and PCH disable
- kf6-ki18n: restored full build (removed stub recipe + P1 patch)
- kf6-ki18n: removed ECM version sed (ECM bumped to 6.11.0 already)
- redbear-greeter: removed #include <stdlib.h> workarounds in source
- local/patches/kf6-ki18n/: removed unused P1 patch directory
Add explicit #include <stdlib.h> after #include_next <stdlib.h> in
GCC 13 cstdlib. This ensures ::strtold is declared before the
using-directives execute. Previously relibc's declaration was
not visible to the C++ wrapper.
Reverted unjustified ignores: qt6-sensors, kf6-ki18n, kf6-kidletime,
kf6-kwayland, redbear-greeter — per project policy: fix, don't ignore.
Also reverted kf6-ki18n to full build (stub removed).
Rewrite the scattered git-server references into a single canonical
section in README.md and a comprehensive operator section in
local/AGENTS.md.
- README.md: new top-level "Our Git Server" section with connection
details table (token field left as placeholder per session-only
token policy).
- local/AGENTS.md: new "OUR GIT SERVER" section covering connection
details, repo map, clone/auth/remote-setup recipes, cookbook
auth via .netrc, push runbook, API quick reference, and a full
operator runbook including credential-recovery and
accidental-commit mitigation.
Tokens are explicitly NOT stored anywhere in tracked files. Clones
and authenticated operations must use credential helper, .netrc,
or REDBEAR_GITEA_TOKEN env var.
Also normalizes the lowercase-slug note (gitea normalizes RedBear-OS
to redbear-os) and the related-repos table.
The stale-build check in build-redbear.sh compared HEAD commit hashes
against a stored fingerprint, which silently ignored uncommitted changes
in local/sources/{relibc,kernel,base,bootloader,installer}.
This meant dev iterations where a maintainer edited the working tree
without committing would not trigger a rebuild of the affected package.
The cookbook would then cook the binary from a fingerprint that
claims 'up to date' but is actually older than the working tree.
This commit extends the staleness test to also check
'git diff HEAD', 'git diff --cached HEAD', and
'git ls-files --others --exclude-standard'. The error message
distinguishes 'uncommitted changes' from 'new commits' so the
operator can tell which case triggered the rebuild.
Also adds local/scripts/lint-doc-comments.sh: a doc-comment hygiene
linter that flags agent-memo style comments (Note:, This implements...,
Changed from..., Added new..., Korean variants) so future commits
can be screened for the WHAT-not-WHY comment anti-pattern.
GCC <cstdlib> needs ::strtold. -include stdlib.h works for normal
compilation but PCH compiles without -include flags. Disabling PCH
globally prevents strtold visibility issues in all Qt/KF6 packages.
strtold include chain fix applied but C++ <cstdlib> still fails.
KI18n is i18n — non-critical for bootable desktop. Re-enable when
strtold root cause is resolved in relibc or GCC <cstdlib>.