Skip to content

loongarch: fix CPUCFG /proc/cpuinfo flag string (cfg -> cpucfg) - #477

Open
0z5a wants to merge 1 commit into
google:mainfrom
0z5a:fix/loongarch-cpucfg-flag
Open

0z5a wants to merge 1 commit into
google:mainfrom
0z5a:fix/loongarch-cpucfg-flag

Conversation

@0z5a

@0z5a 0z5a commented Nov 14, 2026

Copy link
Copy Markdown

The Linux kernel lists the CPUCFG feature as cpucfg in the Features line of /proc/cpuinfo (arch/loongarch/kernel/proc.c; the token has been cpucfg since v5.19). The LoongArch introspection table looked for cfg. HasWord() only matches whole words, so the flag was never found. GetLoongArchInfo() reads only /proc/cpuinfo, so CPUCFG was always reported as false.

This PR changes the flag string to cpucfg. It is the same kind of fix as #464 (smelutv1 -> smelutv2 on aarch64).

The two existing LoongArch tests use real /proc/cpuinfo dumps whose Features lines contain cpucfg, but they asserted EXPECT_FALSE(info.features.CPUCFG). This PR changes those assertions to EXPECT_TRUE. With the old string, both tests now fail with Value of: info.features.CPUCFG Actual: false Expected: true; with the fix, both pass.

Testing: there is no LoongArch CI job, so I built test/cpuinfo_loongarch_test.cc against the fake filesystem on a non-LoongArch host. I defined __loongarch64 / __linux__ for the LoongArch implementation file, since the parser is plain C and does not depend on the ISA. Results: 2/2 tests fail before the change and 2/2 pass after it. The regular test suite still passes, and clang-format --style=file --dry-run --Werror is clean on both files.

This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.

The kernel lists the CPUCFG feature as "cpucfg" in /proc/cpuinfo
(arch/loongarch/kernel/proc.c since v5.19). The table looked for "cfg",
which HasWord() never matches, so CPUCFG was always false. The two
LoongArch tests use real cpuinfo dumps that contain "cpucfg" but
asserted false; expect true.
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