Skip to content

Commit a469abd

Browse files
committed
ARM: elf: add new hwcap for identifying atomic ldrd/strd instructions
CPUs implementing LPAE have atomic ldrd/strd instructions, meaning that userspace software can avoid having to use the exclusive variants of these instructions if they wish. This patch advertises the atomicity of these instructions via the hwcaps, so userspace can detect this CPU feature. Reported-by: Vladimir Danushevsky <vladimir.danushevsky@oracle.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent e38a517 commit a469abd

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎arch/arm/include/uapi/asm/hwcap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
#define HWCAP_IDIVT (1 << 18)
2626
#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */
2727
#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
28-
28+
#define HWCAP_LPAE (1 << 20)
2929

3030
#endif /* _UAPI__ASMARM_HWCAP_H */

‎arch/arm/kernel/setup.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void __init early_print(const char *str, ...)
355355

356356
static void __init cpuid_init_hwcaps(void)
357357
{
358-
unsigned int divide_instrs;
358+
unsigned int divide_instrs, vmsa;
359359

360360
if (cpu_architecture() < CPU_ARCH_ARMv7)
361361
return;
@@ -368,6 +368,11 @@ static void __init cpuid_init_hwcaps(void)
368368
case 1:
369369
elf_hwcap |= HWCAP_IDIVT;
370370
}
371+
372+
/* LPAE implies atomic ldrd/strd instructions */
373+
vmsa = (read_cpuid_ext(CPUID_EXT_MMFR0) & 0xf) >> 0;
374+
if (vmsa >= 5)
375+
elf_hwcap |= HWCAP_LPAE;
371376
}
372377

373378
static void __init feat_v6_fixup(void)
@@ -872,6 +877,7 @@ static const char *hwcap_str[] = {
872877
"vfpv4",
873878
"idiva",
874879
"idivt",
880+
"lpae",
875881
NULL
876882
};
877883

0 commit comments

Comments
 (0)