Skip to content

Commit eda2171

Browse files
committed
Merge branch 'for-next/cpufeature' into for-next/core
Additional CPU sanity checks for MTE and preparatory changes for systems where not all of the CPUs support 32-bit EL0. * for-next/cpufeature: arm64: Restrict undef hook for cpufeature registers arm64: Kill 32-bit applications scheduled on 64-bit-only CPUs KVM: arm64: Kill 32-bit vCPUs on systems with mismatched EL0 support arm64: Allow mismatched 32-bit EL0 support arm64: cpuinfo: Split AArch32 registers out into a separate struct arm64: Check if GMID_EL1.BS is the same on all CPUs arm64: Change the cpuinfo_arm64 member type for some sysregs to u64
2 parents 5ceb045 + cf292e9 commit eda2171

8 files changed

Lines changed: 288 additions & 98 deletions

File tree

arch/arm64/include/asm/cpu.h

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,7 @@
1212
/*
1313
* Records attributes of an individual CPU.
1414
*/
15-
struct cpuinfo_arm64 {
16-
struct cpu cpu;
17-
struct kobject kobj;
18-
u32 reg_ctr;
19-
u32 reg_cntfrq;
20-
u32 reg_dczid;
21-
u32 reg_midr;
22-
u32 reg_revidr;
23-
24-
u64 reg_id_aa64dfr0;
25-
u64 reg_id_aa64dfr1;
26-
u64 reg_id_aa64isar0;
27-
u64 reg_id_aa64isar1;
28-
u64 reg_id_aa64mmfr0;
29-
u64 reg_id_aa64mmfr1;
30-
u64 reg_id_aa64mmfr2;
31-
u64 reg_id_aa64pfr0;
32-
u64 reg_id_aa64pfr1;
33-
u64 reg_id_aa64zfr0;
34-
15+
struct cpuinfo_32bit {
3516
u32 reg_id_dfr0;
3617
u32 reg_id_dfr1;
3718
u32 reg_id_isar0;
@@ -54,6 +35,30 @@ struct cpuinfo_arm64 {
5435
u32 reg_mvfr0;
5536
u32 reg_mvfr1;
5637
u32 reg_mvfr2;
38+
};
39+
40+
struct cpuinfo_arm64 {
41+
struct cpu cpu;
42+
struct kobject kobj;
43+
u64 reg_ctr;
44+
u64 reg_cntfrq;
45+
u64 reg_dczid;
46+
u64 reg_midr;
47+
u64 reg_revidr;
48+
u64 reg_gmid;
49+
50+
u64 reg_id_aa64dfr0;
51+
u64 reg_id_aa64dfr1;
52+
u64 reg_id_aa64isar0;
53+
u64 reg_id_aa64isar1;
54+
u64 reg_id_aa64mmfr0;
55+
u64 reg_id_aa64mmfr1;
56+
u64 reg_id_aa64mmfr2;
57+
u64 reg_id_aa64pfr0;
58+
u64 reg_id_aa64pfr1;
59+
u64 reg_id_aa64zfr0;
60+
61+
struct cpuinfo_32bit aarch32;
5762

5863
/* pseudo-ZCR for recording maximum ZCR_EL1 LEN value: */
5964
u64 reg_zcr;

arch/arm64/include/asm/cpufeature.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,13 @@ static inline bool id_aa64pfr0_sve(u64 pfr0)
619619
return val > 0;
620620
}
621621

622+
static inline bool id_aa64pfr1_mte(u64 pfr1)
623+
{
624+
u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_MTE_SHIFT);
625+
626+
return val >= ID_AA64PFR1_MTE;
627+
}
628+
622629
void __init setup_cpu_features(void);
623630
void check_local_cpu_capabilities(void);
624631

@@ -630,9 +637,15 @@ static inline bool cpu_supports_mixed_endian_el0(void)
630637
return id_aa64mmfr0_mixed_endian_el0(read_cpuid(ID_AA64MMFR0_EL1));
631638
}
632639

640+
const struct cpumask *system_32bit_el0_cpumask(void);
641+
DECLARE_STATIC_KEY_FALSE(arm64_mismatched_32bit_el0);
642+
633643
static inline bool system_supports_32bit_el0(void)
634644
{
635-
return cpus_have_const_cap(ARM64_HAS_32BIT_EL0);
645+
u64 pfr0 = read_sanitised_ftr_reg(SYS_ID_AA64PFR0_EL1);
646+
647+
return static_branch_unlikely(&arm64_mismatched_32bit_el0) ||
648+
id_aa64pfr0_32bit_el0(pfr0);
636649
}
637650

638651
static inline bool system_supports_4kb_granule(void)

0 commit comments

Comments
 (0)