aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/setup.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-03-19 14:04:05 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2015-03-28 11:46:15 -0400
commita092aedb8115c16cb49bc64dd09cb20471ff942b (patch)
tree7a1a867410c8cfdff4ec9fbb4f9ed8920bd8f2ef /arch/arm/kernel/setup.c
parentb8c9592b4a6c93211c8163888a97880d608503b5 (diff)
ARM: 8319/1: advertise availability of v8 Crypto instructions
When running the 32-bit ARM kernel on ARMv8 capable bare metal (e.g., 32-bit Android userland and kernel on a Cortex-A53), or as a KVM guest on a 64-bit host, we should advertise the availability of the Crypto instructions, so that userland libraries such as OpenSSL may use them. (Support for the v8 Crypto instructions in the 32-bit build was added to OpenSSL more than six months ago) This adds the ID feature bit detection, and sets elf_hwcap2 accordingly. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel/setup.c')
-rw-r--r--arch/arm/kernel/setup.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 637c449e6060..910bb1796946 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -376,6 +376,7 @@ void __init early_print(const char *str, ...)
376static void __init cpuid_init_hwcaps(void) 376static void __init cpuid_init_hwcaps(void)
377{ 377{
378 int block; 378 int block;
379 u32 isar5;
379 380
380 if (cpu_architecture() < CPU_ARCH_ARMv7) 381 if (cpu_architecture() < CPU_ARCH_ARMv7)
381 return; 382 return;
@@ -390,6 +391,27 @@ static void __init cpuid_init_hwcaps(void)
390 block = cpuid_feature_extract(CPUID_EXT_MMFR0, 0); 391 block = cpuid_feature_extract(CPUID_EXT_MMFR0, 0);
391 if (block >= 5) 392 if (block >= 5)
392 elf_hwcap |= HWCAP_LPAE; 393 elf_hwcap |= HWCAP_LPAE;
394
395 /* check for supported v8 Crypto instructions */
396 isar5 = read_cpuid_ext(CPUID_EXT_ISAR5);
397
398 block = cpuid_feature_extract_field(isar5, 4);
399 if (block >= 2)
400 elf_hwcap2 |= HWCAP2_PMULL;
401 if (block >= 1)
402 elf_hwcap2 |= HWCAP2_AES;
403
404 block = cpuid_feature_extract_field(isar5, 8);
405 if (block >= 1)
406 elf_hwcap2 |= HWCAP2_SHA1;
407
408 block = cpuid_feature_extract_field(isar5, 12);
409 if (block >= 1)
410 elf_hwcap2 |= HWCAP2_SHA2;
411
412 block = cpuid_feature_extract_field(isar5, 16);
413 if (block >= 1)
414 elf_hwcap2 |= HWCAP2_CRC32;
393} 415}
394 416
395static void __init elf_hwcap_fixup(void) 417static void __init elf_hwcap_fixup(void)