mirror of
https://github.com/anrieff/libcpuid
synced 2024-11-20 23:01:51 +00:00
Return ERR_NO_CPUID when cpuid kernel module cannot be used on AArch32 state
This commit is contained in:
parent
b121830b44
commit
a0f07b8b26
1 changed files with 7 additions and 2 deletions
|
@ -1391,6 +1391,7 @@ int cpuid_get_raw_data_core(struct cpu_raw_data_t* data, logical_cpu_t logical_c
|
||||||
unsigned i;
|
unsigned i;
|
||||||
struct cpuid_driver_t *handle;
|
struct cpuid_driver_t *handle;
|
||||||
|
|
||||||
|
/* Try to use cpuid kernel driver on AArch32/AArch64 states */
|
||||||
if ((handle = cpu_cpuid_driver_open_core(logical_cpu)) != NULL) {
|
if ((handle = cpu_cpuid_driver_open_core(logical_cpu)) != NULL) {
|
||||||
debugf(2, "Using kernel driver to read register on logical CPU %u\n", logical_cpu);
|
debugf(2, "Using kernel driver to read register on logical CPU %u\n", logical_cpu);
|
||||||
cpu_read_arm_register_64b(handle, REQ_MIDR, &data->arm_midr);
|
cpu_read_arm_register_64b(handle, REQ_MIDR, &data->arm_midr);
|
||||||
|
@ -1424,8 +1425,9 @@ int cpuid_get_raw_data_core(struct cpu_raw_data_t* data, logical_cpu_t logical_c
|
||||||
# endif /* PLATFORM_AARCH64 */
|
# endif /* PLATFORM_AARCH64 */
|
||||||
cpu_cpuid_driver_close(handle);
|
cpu_cpuid_driver_close(handle);
|
||||||
}
|
}
|
||||||
# if defined(PLATFORM_AARCH64)
|
|
||||||
else {
|
else {
|
||||||
|
# if defined(PLATFORM_AARCH64)
|
||||||
|
/* Fallback to MRS instruction on AArch64 state */
|
||||||
if (!cpuid_present())
|
if (!cpuid_present())
|
||||||
return cpuid_set_error(ERR_NO_CPUID);
|
return cpuid_set_error(ERR_NO_CPUID);
|
||||||
debugf(2, "Using MRS instruction to read register on logical CPU %u\n", logical_cpu);
|
debugf(2, "Using MRS instruction to read register on logical CPU %u\n", logical_cpu);
|
||||||
|
@ -1449,8 +1451,11 @@ int cpuid_get_raw_data_core(struct cpu_raw_data_t* data, logical_cpu_t logical_c
|
||||||
cpu_exec_mrs(AARCH64_REG_ID_AA64PFR2_EL1, data->arm_id_aa64pfr[2]);
|
cpu_exec_mrs(AARCH64_REG_ID_AA64PFR2_EL1, data->arm_id_aa64pfr[2]);
|
||||||
cpu_exec_mrs(AARCH64_REG_ID_AA64SMFR0_EL1, data->arm_id_aa64smfr[0]);
|
cpu_exec_mrs(AARCH64_REG_ID_AA64SMFR0_EL1, data->arm_id_aa64smfr[0]);
|
||||||
cpu_exec_mrs(AARCH64_REG_ID_AA64ZFR0_EL1, data->arm_id_aa64zfr[0]);
|
cpu_exec_mrs(AARCH64_REG_ID_AA64ZFR0_EL1, data->arm_id_aa64zfr[0]);
|
||||||
}
|
# else
|
||||||
|
/* Return ERR_NO_CPUID on AArch32 state */
|
||||||
|
return cpuid_set_error(ERR_NO_CPUID);
|
||||||
# endif /* PLATFORM_AARCH64 */
|
# endif /* PLATFORM_AARCH64 */
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
# warning This CPU architecture is not supported by libcpuid
|
# warning This CPU architecture is not supported by libcpuid
|
||||||
UNUSED(data);
|
UNUSED(data);
|
||||||
|
|
Loading…
Reference in a new issue