1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-11-10 22:59:13 +00:00

Extract both AArch32 and AArch64 registers on AArch64

This commit is contained in:
The Tumultuous Unicorn Of Darkness 2024-07-09 18:17:54 +02:00
parent a4c97cd1e7
commit 7b6047c2ac
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A
2 changed files with 22 additions and 12 deletions

View file

@ -1356,6 +1356,22 @@ int cpuid_get_raw_data_core(struct cpu_raw_data_t* data, logical_cpu_t logical_c
cpu_read_arm_register_32b(handle, REQ_ID_MMFR0 + i, &data->arm_id_mmfr[i]);
for (i = 0; i < MAX_ARM_ID_PFR_REGS; i++)
cpu_read_arm_register_32b(handle, REQ_ID_PFR0 + i, &data->arm_id_pfr[i]);
# if defined(PLATFORM_AARCH64)
for (i = 0; i < MAX_ARM_ID_AA64AFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64AFR0 + i, &data->arm_id_aa64afr[i]);
for (i = 0; i < MAX_ARM_ID_AA64DFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64DFR0 + i, &data->arm_id_aa64dfr[i]);
for (i = 0; i < MAX_ARM_ID_AA64ISAR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64ISAR0 + i, &data->arm_id_aa64isar[i]);
for (i = 0; i < MAX_ARM_ID_AA64MMFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64MMFR0 + i, &data->arm_id_aa64mmfr[i]);
for (i = 0; i < MAX_ARM_ID_AA64PFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64PFR0 + i, &data->arm_id_aa64pfr[i]);
for (i = 0; i < MAX_ARM_ID_AA64SMFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64SMFR0 + i, &data->arm_id_aa64smfr[i]);
for (i = 0; i < MAX_ARM_ID_AA64ZFR_REGS; i++)
cpu_read_arm_register_64b(handle, REQ_ID_AA64ZFR0 + i, &data->arm_id_aa64zfr[i]);
# endif /* PLATFORM_AARCH64 */
cpu_cpuid_driver_close(handle);
}
# if defined(PLATFORM_AARCH64)

View file

@ -399,16 +399,10 @@ static const struct arm_id_part* get_cpu_implementer_parts(const struct arm_hw_i
return &hw_impl->parts[i];
}
static inline bool is_aarch32_mode(struct cpu_raw_data_t* raw)
{
return (raw->arm_id_afr[0] != 0) || (raw->arm_id_dfr[0] != 0) || (raw->arm_id_isar[0] != 0) || (raw->arm_id_mmfr[0] != 0) || (raw->arm_id_pfr[0] != 0);
}
/* Unused
static inline bool is_aarch64_mode(struct cpu_raw_data_t* raw)
{
return (raw->arm_id_aa64afr[0] != 0) || (raw->arm_id_aa64dfr[0] != 0) || (raw->arm_id_aa64isar[0] != 0) || (raw->arm_id_aa64mmfr[0] != 0) || (raw->arm_id_aa64pfr[0] != 0);
} */
}
static bool decode_arm_architecture_version_by_midr(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
{
@ -594,7 +588,7 @@ static void set_feature_status(struct cpu_id_t* data, struct arm_arch_extension_
}
}
static void match_arm_features(bool is_aarch32, cpu_feature_t feature, const struct arm_feature_map_t* feature_map, struct cpu_id_t* data, struct arm_arch_extension_t* ext_status)
static void match_arm_features(bool is_aarch64, cpu_feature_t feature, const struct arm_feature_map_t* feature_map, struct cpu_id_t* data, struct arm_arch_extension_t* ext_status)
{
bool field_is_present, feature_is_present = false;
unsigned i;
@ -604,9 +598,9 @@ static void match_arm_features(bool is_aarch32, cpu_feature_t feature, const str
for (i = 0; i < MAX_IDENTIFY_FIELDS; i++) {
field = &feature_map->fields[i];
if (is_aarch32 && field->aarch32_reg != NULL)
if (!is_aarch64 && field->aarch32_reg != NULL)
reg_value = *field->aarch32_reg;
else if (!is_aarch32 && field->aarch64_reg != NULL)
else if (is_aarch64 && field->aarch64_reg != NULL)
reg_value = *field->aarch64_reg;
else
break; // quit on sentinel values
@ -681,7 +675,7 @@ static void load_arm_feature_mte4(struct cpu_raw_data_t* raw, struct cpu_id_t* d
static void load_arm_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data, struct arm_arch_extension_t* ext_status)
{
cpu_feature_t feature;
const bool is_aarch32 = is_aarch32_mode(raw);
const bool is_aarch64 = is_aarch64_mode(raw);
/* Thumb */
set_feature_status(data, ext_status,
@ -2524,7 +2518,7 @@ static void load_arm_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data,
for (feature = 0; feature < NUM_CPU_FEATURES; feature++)
if (features_map[feature].ver_optional)
match_arm_features(is_aarch32, feature, &features_map[feature], data, ext_status);
match_arm_features(is_aarch64, feature, &features_map[feature], data, ext_status);
/* Some fields do not follow the standard ID scheme */
load_arm_feature_pauth(data, ext_status);