Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpuinfo: Check for extensions using riscv_hwprobe #18

Merged
merged 4 commits into from
Nov 9, 2024

Conversation

OFFTKP
Copy link
Contributor

@OFFTKP OFFTKP commented Nov 8, 2024

Update Cpuinfo to use the linux syscall riscv_hwprobe to check for extensions instead of the auxiliary vector value.

Each case is written out explicitly because in the future more extensions might be added and the syscall may include more bitfields when the current one (RISCV_HWPROBE_KEY_IMA_EXT_0) runs out of bits.

https://github.com/torvalds/linux/blob/master/arch/riscv/include/uapi/asm/hwprobe.h

Copy link
Owner

@lioncash lioncash left a comment

Choose a reason for hiding this comment

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

Mostly minor stylistic comments, but nice changes overall. I really like getting nix specific headers out of the cpuinfo header, so projects don't implicitly have those dumped in for feature testing

src/cpuinfo.cpp Outdated Show resolved Hide resolved
src/cpuinfo.cpp Show resolved Hide resolved
src/cpuinfo.cpp Outdated Show resolved Hide resolved
src/cpuinfo.cpp Outdated Show resolved Hide resolved
@OFFTKP
Copy link
Contributor Author

OFFTKP commented Nov 9, 2024

All done!

src/cpuinfo.cpp Outdated Show resolved Hide resolved
@OFFTKP
Copy link
Contributor Author

OFFTKP commented Nov 9, 2024

I should mention that this syscall exists from Linux 6.4 onwards, maybe it should fallback to the old implementation if the syscall fails

Edit: Made it fallback to the old implementation if the syscall returns error due to not existing

@lioncash lioncash merged commit 7b2395b into lioncash:main Nov 9, 2024
4 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.

2 participants