Skip to content

Encode AMD family 16 and later correctly in the ProcessorID - #3792

Merged
dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-processorid-amd
Oct 12, 2026
Merged

dbwiddis merged 1 commit into
oshi:masterfrom
dbwiddis:fix-processorid-amd

Conversation

@dbwiddis

@dbwiddis dbwiddis commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

AbstractCentralProcessor.createProcessorID rebuilds the x86 processor signature (CPUID leaf 1 EAX) from the displayed family, model and stepping when no platform source supplies one.

Bug

A family above 15 is defined as a base family of 15 (bits 11:8) plus an extended family (bits 27:20). The encoder instead split the family's own bits between the two fields, so family 23 (AMD Zen) became base 7 / extended 1: 00100712 instead of 00800F12. Every AMD processor from family 16 (K10) on got a wrong ProcessorID. Intel families 6 and 15 were already correct.

This is the inverse of the decoding bug fixed in #3789.

Where the encoded value is used

  • Linux, when neither dmidecode (root) nor cpuid is available, which is common for unprivileged users
  • Solaris
  • Windows, when WMI returns no ProcessorId

Tests

  • Zen (23/1/2 → 00800F12) and Zen 4 (25/97/2 → 00A60F12) against known signatures.
  • Six real Intel and AMD signatures round-trip through cpuidToFamilyModelStepping and back unchanged.
  • Both new tests fail on the old encoder.

Not verified on AMD hardware: I have no AMD machine to hand, and CI's Linux runners usually take the ID from dmidecode.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed processor ID generation for AMD processors from family 16 onward, including cases where system tools or Windows WMI do not provide an ID.

createProcessorID builds the x86 processor signature (CPUID leaf 1 EAX) from
the displayed family, model and stepping when no platform source supplies
one. A family above 15 is defined as a base family of 15 plus an extended
family, but the encoder split the family's own bits between the two fields:
family 23 (AMD Zen) became base 7 / extended 1, giving 00100712 instead of
00800F12. Every AMD processor from family 16 (K10) on was affected; Intel's
families 6 and 15 were already correct.

This is the inverse of the decoding bug fixed in oshi#3789.

The encoded value is used on Linux when neither dmidecode nor cpuid is
available, on Solaris, and on Windows when WMI returns no ProcessorId.

Tests encode Zen and Zen 4 against known signatures, and round-trip six
real Intel and AMD signatures through cpuidToFamilyModelStepping and back.
@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1181411a-fa1c-434b-a8ec-6b6570be6688

📥 Commits

Reviewing files that changed from the base of the PR and between c8fe762 and 66c8c35.


📒 Files selected for processing (3)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java
  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📜 Recent review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest
  • GitHub Check: Test JDK 25, macos-latest
  • GitHub Check: changes
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Lint (ForbiddenAPIs, Javadoc, SLF4J)
  • GitHub Check: Lint (Spotless, Checkstyle)
  • GitHub Check: Error Prone
  • GitHub Check: Analyze (java)

🧰 Additional context used
📚 Code guidelines (2)
AGENTS.md — auto-discovered
CONTRIBUTING.md — auto-discovered

📓 Path-based instructions (2)
Source excerpt: **Banned APIs** (`config/forbidden-apis.txt` and friends, enforced by `forbiddenapis:check`): `oshi-common` may not reference `com.sun.jna.**`, `java.lang.foreign.**`, or any `System.load`/`loadLibrary`.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java
  • oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java

Source excerpt: The Changelog lets users know what's changed.

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Files:

  • CHANGELOG.md

🔇 Additional comments (3)
oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java (1)

377-383: LGTM!


oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java (1)

22-22: LGTM!

Also applies to: 418-436


CHANGELOG.md (1)

8-8: LGTM!



📝 Walkthrough

Walkthrough

createProcessorID now encodes family values above 15 using base family 15 and an extended family value. Tests cover AMD Zen and Zen 4 IDs and CPUID round trips for Intel and AMD examples.

Changes

Processor ID Encoding

Layer / File(s) Summary
Correct family encoding and test round trips
oshi-common/src/main/java/oshi/hardware/common/AbstractCentralProcessor.java, oshi-common/src/test/java/oshi/hardware/common/AbstractCentralProcessorTest.java, CHANGELOG.md
createProcessorID encodes family values above 15 using base family 15 and the low 8 bits of family - 15. Tests check AMD Zen and Zen 4 IDs and CPUID round trips across six Intel and AMD examples. The changelog documents the correction and listed fallback cases.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to 66c8c

No identified issue needs resolution before merging. The processor ID correction is ready for normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: correcting ProcessorID encoding for AMD family 16 and later.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.

Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks the family bits,
Then bounds through Zen with tidy fits.
Six CPUIDs return as planned,
Locale-rooted, neat and grand.
The changelog joins the hop parade.

Comment @coderabbitai help to get the list of available commands.

@dbwiddis
dbwiddis merged commit 509fdea into oshi:master Oct 12, 2026
17 of 18 checks passed
@dbwiddis
dbwiddis deleted the fix-processorid-amd branch October 12, 2026 02:45
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.

1 participant