Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: Add helper for extracting ASIDBits

Add a helper to extract ASIDBits on the current cpu

Cc: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Suzuki K Poulose and committed by
Catalin Marinas
038dc9c6 fd9c2790

+23 -13
+23 -13
arch/arm64/mm/context.c
··· 40 40 #define ASID_FIRST_VERSION (1UL << asid_bits) 41 41 #define NUM_USER_ASIDS ASID_FIRST_VERSION 42 42 43 + /* Get the ASIDBits supported by the current CPU */ 44 + static u32 get_cpu_asid_bits(void) 45 + { 46 + u32 asid; 47 + int fld = cpuid_feature_extract_field(read_cpuid(SYS_ID_AA64MMFR0_EL1), 48 + ID_AA64MMFR0_ASID_SHIFT); 49 + 50 + switch (fld) { 51 + default: 52 + pr_warn("CPU%d: Unknown ASID size (%d); assuming 8-bit\n", 53 + smp_processor_id(), fld); 54 + /* Fallthrough */ 55 + case 0: 56 + asid = 8; 57 + break; 58 + case 2: 59 + asid = 16; 60 + } 61 + 62 + return asid; 63 + } 64 + 43 65 static void flush_context(unsigned int cpu) 44 66 { 45 67 int i; ··· 209 187 210 188 static int asids_init(void) 211 189 { 212 - int fld = cpuid_feature_extract_field(read_cpuid(SYS_ID_AA64MMFR0_EL1), 4); 213 - 214 - switch (fld) { 215 - default: 216 - pr_warn("Unknown ASID size (%d); assuming 8-bit\n", fld); 217 - /* Fallthrough */ 218 - case 0: 219 - asid_bits = 8; 220 - break; 221 - case 2: 222 - asid_bits = 16; 223 - } 224 - 190 + asid_bits = get_cpu_asid_bits(); 225 191 /* If we end up with more CPUs than ASIDs, expect things to crash */ 226 192 WARN_ON(NUM_USER_ASIDS < num_possible_cpus()); 227 193 atomic64_set(&asid_generation, ASID_FIRST_VERSION);