Skip to content

lscpu: show RISC-V MMU mode#4417

Merged
karelzak merged 3 commits into
util-linux:masterfrom
ZephyrLi-pro:master
Jun 15, 2026
Merged

lscpu: show RISC-V MMU mode#4417
karelzak merged 3 commits into
util-linux:masterfrom
ZephyrLi-pro:master

Conversation

@ZephyrLi-pro

Copy link
Copy Markdown
Contributor

This PR adds support for parsing the RISC-V mmu field from /proc/cpuinfo and displaying it in the lscpu summary output.

On RISC-V systems, the kernel may expose the current address translation mode through the mmu field, such as sv39, sv48, sv57 or none. Showing this field makes the RISC-V-specific lscpu output more complete and useful for system inspection.

This PR also frees the existing cputype ISA string when releasing struct lscpu_cputype.

Tested on a RISC-V system with mmu: sv48.

Before:

ISA: rv64imafdch ...

After:

ISA: rv64imafdch ...
MMU: sv48

Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>
Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>

@cgoesche cgoesche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The dumps for rv64-milkvpioneer and rv64-visionfive2 seem to include the memory address translation mode in their respective /proc/cpuinfo files.

In this case, you will have to update the expected output files for the regression tests, namely tests/expected/lscpu/lscpu-rv64-{milkvpioneer,visionfive2}, to include the new MMU field.

It's enough to simply run ./tests/run.sh lscpu and copy over the differing files from tests/output/lscpu/ to the tests/expected/lscpu/ directory.

@cgoesche

Copy link
Copy Markdown
Collaborator

It would also be nice to add the MMU column option to the bash-completion/lscpu.

Signed-off-by: Zephyr Li <fritchleybohrer@gmail.com>
@ZephyrLi-pro

Copy link
Copy Markdown
Contributor Author

It would also be nice to add the MMU column option to the bash-completion/lscpu.

Thanks for the review. I updated the expected lscpu outputs for the existing RISC-V dumps and added MMU as an --extended column, including the bash completion entry.

Tested with:
./lscpu --extended=CPU,MMU
./lscpu --list-columns | grep MMU
./tests/run.sh lscpu

@karelzak karelzak merged commit d4622a9 into util-linux:master Jun 15, 2026
35 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