Skip to content

🐛 Decode the whole SMBIOS memory-type table, not three values of it - #31

Merged
ManupaKDU merged 2 commits into
masterfrom
feat/memory-type-decoding
Aug 27, 2026
Merged

🐛 Decode the whole SMBIOS memory-type table, not three values of it#31
ManupaKDU merged 2 commits into
masterfrom
feat/memory-type-decoding

Conversation

@manupawickramasinghe

@manupawickramasinghe manupawickramasinghe commented Aug 26, 2026

Copy link
Copy Markdown
Member

Merge order: #32 (unbreaks currently-red CI) → #28#29#30#31. Each is independently reviewable; the order just keeps the checks readable.

The bug

The System Summary reported the literal string "DRAM SDRAM" as the memory type on most current laptops.

Two bugs compounding. Win32_PhysicalMemory.SMBIOSMemoryType was decoded for exactly three values:

let mem_type = match u(r.get("SMBIOSMemoryType")) {
    Some(26) => "DDR4",
    Some(34) => "DDR5",
    Some(24) => "DDR3",
    _ => "DRAM",
};

Every soldered-memory machine reports an LPDDR code (0x1B0x1E, 0x23), so that fallback covered most portable hardware sold today. summary_window.rs then appended " SDRAM" to whatever it was handed, turning the fallback into nonsense.

The fix

smbios_memory_type decodes the full DMTF table, codes 0x010x24, cross-checked against dmidecode's dmi_memory_device_type. That adds:

  • LPDDR, LPDDR2, LPDDR3, LPDDR4, LPDDR5 — the laptop gap
  • HBM, HBM2, HBM3
  • the older SDRAM / RDRAM / DDR / DDR2 / FB-DIMM codes

0x150x17 are Reserved rather than memory types, so they deliberately fall through along with everything unassigned. A test walks every code from 0x01 to 0x24 and asserts that only those three reach the unknown path, so the coverage claim is checked rather than asserted.

An unassigned code reports as Unknown (type 0x25) rather than being flattened into a wrong name. DMTF assigns new codes as memory generations ship, and the raw number is what lets someone look one up.

The " SDRAM" suffix now goes through memory_type_label, which applies it only to the DDR and LPDDR families — HBM3 and Unknown are left alone.

Verification

  • 7 new tests, all passing. They take the raw code rather than reading WMI, so they run on every CI leg — including the aarch64 one from ✨ Build and publish arm64 Linux artifacts #29.
  • Full suite: 89 passed, 0 failed.
  • cargo clippy --all-targets -- -D warnings clean across "", web, gui, tui, gui,web.
  • Verified on real hardware — a DDR5 desktop still reports DDR5:
Memory
  P0 CHANNEL A/DIMMA1  16 GB DDR5
  P0 CHANNEL B/DIMMB1  16 GB DDR5

One note for reviewers: memory_type_label needs #[allow(dead_code)] because only the GUI renders it. Without that the headless legs fail on -D warnings — caught locally by running the same feature matrix CI does, not by the default build.

Adjacent, deliberately not fixed here

The same Memory panel infers channel count from the module count (summary_window.rs), so four DIMMs on a mainstream dual-channel board report "Quad-Channel", and 3/6/8/12-module HEDT and server configurations report nothing at all. Different bug, different fix — worth its own PR.

🤖 Generated with Claude Code

The Summary reported the literal string "DRAM SDRAM" for most current laptops.

Two bugs compounding. `Win32_PhysicalMemory.SMBIOSMemoryType` was decoded for
DDR3, DDR4 and DDR5 only, with everything else flattened to "DRAM" — and every
soldered-memory machine reports an LPDDR code, so that fallback covered most
portable hardware sold today. The Summary then appended " SDRAM" to whatever it
was given, turning the fallback into nonsense.

`smbios_memory_type` now decodes the full DMTF table, codes 0x01 through 0x24,
cross-checked against dmidecode's `dmi_memory_device_type`. That adds LPDDR
through LPDDR5, HBM/HBM2/HBM3, and the older SDRAM/RDRAM/DDR/DDR2 codes.

A code the table does not know reports as `Unknown (type 0x25)` rather than
being flattened into a wrong name. DMTF assigns new codes as memory
generations ship, and the raw number is what lets someone look one up.

The suffix is now applied by `memory_type_label`, which adds " SDRAM" only to
the DDR and LPDDR families — "HBM3" and "Unknown" are left alone.

Six tests cover the mapping; they take the raw code rather than reading WMI, so
they run on every CI leg. Verified on a DDR5 desktop, which still reports
DDR5 through `sensorview info`.

`memory_type_label` is marked `#[allow(dead_code)]` because only the GUI
renders it — without that the headless legs fail CI's `-D warnings`.

Not fixed here, but adjacent and worth a separate look: the same Memory panel
infers channel count from the module count, so four DIMMs on a dual-channel
board report "Quad-Channel".

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 22:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The table skipped 0x08-0x0C (ROM, Flash, EEPROM, FEPROM, EPROM), so the claim
that it decodes the DMTF range was not quite true — those fell to the unknown
path. Added, and the doc comment now says explicitly that 0x15-0x17 are
Reserved rather than memory types and are meant to fall through.

A new test walks every code from 0x01 to 0x24 and asserts that only the
Reserved three reach the unknown path, so the claim is checked rather than
asserted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@manupawickramasinghe

Copy link
Copy Markdown
Member Author

The Windows and macOS checks here are red for a reason that has nothing to do with this PR: both fail at the Clippy step on error: using chunks_exact with a constant chunk size, inherited from master. That is Rust 1.98's new clippy::chunks_exact_to_as_chunks lint meeting CI's -D warnings — see #32, which fixes it.

Confirmed by reading the failing logs: the lint fires in src/source/firmware.rs (Windows) and src/source/macos/dvfs.rs (macOS), neither of which this PR touches. The Linux leg, where neither file compiles, is green.

Merge #32 first and these go green on a rebase.

@ManupaKDU
ManupaKDU merged commit 6b59f28 into master Aug 27, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants