-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add initial support for ARM CPUs #200
Conversation
f123ec4
to
fa06d34
Compare
macOS does not allow to access EL1 registers:
|
908ead8
to
fa06d34
Compare
macos-latest is based on AArch64 now: https://github.com/actions/runner-images
fa06d34
to
cc064be
Compare
4bc87bb
to
40831eb
Compare
f2824d4
to
b9882cc
Compare
194bd9b
to
7778d96
Compare
I did a good progress targeting ARMv8/9-A in AArch64 mode, I added more than 2k LOC. I replaced
That is all I can do from userspace. I can write a kernel module to access registers not available from userspace, I found a good example here. @anrieff I would like to know if my approach in |
1d72972
to
ca0f640
Compare
ARMv9.0-A is a fork of ARMv8.5-A, so it cannot includes ARMv8.6-A+ mandatory features
I added some codenames and tests are now working for ARM CPUs. I think the code is ready to be merged in master. @anrieff, any final thoughts before merging? These changes are backward compatibles. |
Wonderful work! You can merge now, but before making a release, it would be good to mark the deprecated Since GCC shows the offending line, we can make it even better, by including the "how to fix this" hint in a comment on the same line, i.e. you can have something like
I also see two CPU cpu_feature_t's commented out (CPU_FEATURE_AA32HPD and CPU_FEATURE_AA32I8MM), what's the rub there? |
Ah, yes, these features are supported in AArch32 state only, but I focused on AArch64, that is why I was not able to detect FEAT_AA32. |
edce711
to
7fca7c3
Compare
Done in 7fca7c3. |
I know #96 is opening since 7 years, but better late that never. ARM CPUs are more and more popular (Raspberry Pi, Apple M, and so on...) and some users demand ARM CPUs support, so I started to invest some time in such feature.
My goal is to add ARM support along side x86: libcpuid on ARM can decode x86 dumps, and vice-versa. The drawback is it requires a little more memory in
struct cpu_raw_data_t
, but I think it is acceptable.Only ARM64 is supported because we cannot access MIDR from userspace in 32-bit mode. Linux and FreeBSD allow to access some EL1 registers in AArch64 mode, support for other OS is TBC. In other words, I do not see any way to support ARM CPUs up to ARMv7.
This PR adds logically more vendors in
enum cpu_vendor_t
and more features inenum cpu_feature_t
. There isCPU_FEATURE_AES
on both x86 and ARM thus the error with consistency checks (I may update the check later).In
struct cpu_id_t
, some fields do not have equivalent, that is why I added implementer/architecture_version/variant/part_num/revision. Some fields like family/model/ext_family/ext_model/stepping are x86 only. I do not know if the approach is correct, otherwise it will require a major change (like a union containing x86-specific and ARM-specific fields, depending onarchitecture
value).I tried to reuse some fields like
vendor_str
andbrand_str
, but these values are not stored in registers unlike x86.Please note that we cannot decode cache information from userspace. I do not know if hardcoding all values for all ARM CPUs in the DB is a great idea, because the size is not fixed. Example for Cortex-A55 :
Anyway, here is the
cpuid_tool
output for the Cortex-A57 CPU running on Debian 12 under a VM (QEMU TGC):@anrieff do you have time to provide a feedback? I plan to add more features (ARMv8.1 to ARMv8.9, and ARMv9.0 to ARMv9.4), I focused mostly on ARMv8.0 for now but it is just for the start. Work is required to support CPU topology (for big.LITTLE CPUs).
I use Arm Architecture Reference Manual for A-profile architecture as reference.