Skip to contentSkip to conversation

arm64: setup: report non-optional CPU features

PATCH New Alex Van Brunt 2 participants 3 messages Jan 28, 2014 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: setup: report non-optional CPU features

There are a large number of popular applications compiled for ARMv7-A that read /proc/cpuinfo to find out what features the CPU has. But, when they are run on an arm64 kernel, they fail to run. This is because features that were optional on ARMv7 or earlier but are not optional on ARMv8-A like Thumb are not listed as a CPU feature using the arm64 kernel. To make those applications run, the kernel still needs to print the features in the list.

This patch changes "cat /proc/cpuinfo" from printing:

Features : fp asimd

To printing:

Features : fp asimd wp half thumb fastmult vfp edsp neon vfpv3d16 tlsi vfpv4 idiva idivt

Subject: [PATCH] arm64: setup: report non-optional CPU features

Many ARM applications read the CPU features list provided by the kernel in /proc/cpuinfo to determine which features to use. If a feature is not listed, the application with either run slower or will not run at all.

CPU features that are no longer optional in ARMv8-A, but were optional in previous architectures still need to be printed. To achieve this, always report these features.

Change-Id I0a8092ee07926ae5410d7863a270a76fa224297d
---
 arch/arm64/kernel/setup.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm64/kernel/setup.c +2 -0
index bd9bbd0..7f8e9bd 100644
@@ -302,6 +302,8 @@ static int c_show(struct seq_file *m, void *v)
 	for (i = 0; hwcap_str[i]; i++)
 		if (elf_hwcap & (1 << i))
 			seq_printf(m, "%s ", hwcap_str[i]);
+	/* Print non-optional features in ARMv8 */
+	seq_printf(m, "half thumb fastmult vfp neon vfpv3 vfpv4 idiva");
 
 	seq_printf(m, "\nCPU implementer\t: 0x%02x\n", read_cpuid_id() >> 24);
 	seq_printf(m, "CPU architecture: AArch64\n");
Signature · 1 line
1.8.1.5
maintainer
#1 lore raw

PATCH 1/1 arm64: setup: report non-optional CPU features

Quoted 2 lines · Alex Van Brunt

There are a large number of popular applications compiled for ARMv7-A that read /proc/cpuinfo to find out what features the CPU has.

ELF_HWCAP should work fine. Which popular applications are these?

Quoted 6 lines

But, when they are run
on an arm64 kernel, they fail to run. This is because features that were optional on ARMv7 or earlier but are not optional on ARMv8-A like Thumb are not listed as a CPU feature using the arm64 kernel. To make those applications run, the kernel still needs to print the features in the list.

Quoted 7 lines

This patch changes "cat /proc/cpuinfo" from printing:

Features : fp asimd

To printing:

Features : fp asimd wp half thumb fastmult vfp edsp neon vfpv3d16 tlsi vfpv4 idiva idivt

That's not correct, the features reported are for the AArch64 mode, it doesn't make sense to overlap the AArch32 features here. There is COMPAT_ELF_HWCAP and the bits should be passed correctly to AArch32 binaries.

A solution would be to add a check for personality(current->personality) == PER_LINUX32 and report cpuinfo in an AArch32 compatible way and based on COMPAT_ELF_HWCAP.

Signature · 1 line
Catalin
#2 lore raw

PATCH 1/1 arm64: setup: report non-optional CPU features

There are a large number of Android applications that read "/proc/cpuinfo" to determine what CPU features are available. These applications are delivered as binaries and cannot be easily recompiled. Another example of code is the Android NDK framework. It will separately read "/proc/cpuinfo" and parse the "Features" list to get the list of CPU features.

Are there other architectures that report different information in "/proc/cpuinfo" depending on the personality? x86 doesn't. The problem I have with making this conditional on the personality is that CPU's "Features" list should be listing the features of the CPU not the features of the kernel mode. For example, the CPU does have the "thumb" feature even if the personality doesn't use it.

-----Original Message-----
From: Catalin Marinas [mailto:catalin.marinas at arm.com]
Sent: Tuesday, January 28, 2014 9:23 AM
To: Alexander Van Brunt
Cc: Will Deacon; Linux ARM Kernel
Subject: Re: [PATCH] arm64: setup: report non-optional CPU features

Quoted 2 lines · Alex Van Brunt

There are a large number of popular applications compiled for ARMv7-A that read /proc/cpuinfo to find out what features the CPU has.

ELF_HWCAP should work fine. Which popular applications are these?

Quoted 6 lines

But, when they are run
on an arm64 kernel, they fail to run. This is because features that were optional on ARMv7 or earlier but are not optional on ARMv8-A like Thumb are not listed as a CPU feature using the arm64 kernel. To make those applications run, the kernel still needs to print the features in the list.

Quoted 7 lines

This patch changes "cat /proc/cpuinfo" from printing:

Features : fp asimd

To printing:

Features : fp asimd wp half thumb fastmult vfp edsp neon vfpv3d16 tlsi vfpv4 idiva idivt

That's not correct, the features reported are for the AArch64 mode, it doesn't make sense to overlap the AArch32 features here. There is COMPAT_ELF_HWCAP and the bits should be passed correctly to AArch32 binaries.

A solution would be to add a check for personality(current->personality) == PER_LINUX32 and report cpuinfo in an AArch32 compatible way and based on COMPAT_ELF_HWCAP.

--
Catalin