aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/kernel
diff options
context:
space:
mode:
authorSteve Capper <steve.capper@linaro.org>2013-12-16 16:04:36 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2013-12-19 12:44:08 -0500
commit4bff28ccda2b7a3fbdf8e80aef7a599284681dc6 (patch)
tree3291ace36bb2b611521874f81581d8cb1fa7fb90 /arch/arm64/kernel
parent148eb0a1db8e37a5966afe98223cefe0c1837c26 (diff)
arm64: Add hwcaps for crypto and CRC32 extensions.
Advertise the optional cryptographic and CRC32 instructions to user space where present. Several hwcap bits [3-7] are allocated. Signed-off-by: Steve Capper <steve.capper@linaro.org> [bit 2 is taken now so use bits 3-7 instead] Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64/kernel')
-rw-r--r--arch/arm64/kernel/setup.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 82d65bb536b2..bb33fff09ba2 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -126,6 +126,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
126static void __init setup_processor(void) 126static void __init setup_processor(void)
127{ 127{
128 struct cpu_info *cpu_info; 128 struct cpu_info *cpu_info;
129 u64 features, block;
129 130
130 cpu_info = lookup_processor_type(read_cpuid_id()); 131 cpu_info = lookup_processor_type(read_cpuid_id());
131 if (!cpu_info) { 132 if (!cpu_info) {
@@ -141,6 +142,37 @@ static void __init setup_processor(void)
141 142
142 sprintf(init_utsname()->machine, ELF_PLATFORM); 143 sprintf(init_utsname()->machine, ELF_PLATFORM);
143 elf_hwcap = 0; 144 elf_hwcap = 0;
145
146 /*
147 * ID_AA64ISAR0_EL1 contains 4-bit wide signed feature blocks.
148 * The blocks we test below represent incremental functionality
149 * for non-negative values. Negative values are reserved.
150 */
151 features = read_cpuid(ID_AA64ISAR0_EL1);
152 block = (features >> 4) & 0xf;
153 if (!(block & 0x8)) {
154 switch (block) {
155 default:
156 case 2:
157 elf_hwcap |= HWCAP_PMULL;
158 case 1:
159 elf_hwcap |= HWCAP_AES;
160 case 0:
161 break;
162 }
163 }
164
165 block = (features >> 8) & 0xf;
166 if (block && !(block & 0x8))
167 elf_hwcap |= HWCAP_SHA1;
168
169 block = (features >> 12) & 0xf;
170 if (block && !(block & 0x8))
171 elf_hwcap |= HWCAP_SHA2;
172
173 block = (features >> 16) & 0xf;
174 if (block && !(block & 0x8))
175 elf_hwcap |= HWCAP_CRC32;
144} 176}
145 177
146static void __init setup_machine_fdt(phys_addr_t dt_phys) 178static void __init setup_machine_fdt(phys_addr_t dt_phys)
@@ -280,6 +312,11 @@ static const char *hwcap_str[] = {
280 "fp", 312 "fp",
281 "asimd", 313 "asimd",
282 "evtstrm", 314 "evtstrm",
315 "aes",
316 "pmull",
317 "sha1",
318 "sha2",
319 "crc32",
283 NULL 320 NULL
284}; 321};
285 322