arm64: /proc/cpuinfo updates for compat tasks
Subsystems (2)
Catalin Marinas
maintainercover arm64: /proc/cpuinfo updates for compat tasks
The first patch is relatively simple, adding the "model name" line which is present in the arm32 /proc/cpuinfo.
The second patch is up for discussion. When arm64 support was merged, we concluded that "uname -m" should report "aarch64" even for compat tasks. The only way to change the output to "armv8l" was to set the PER_LINUX32 personality (and I think this is in line with x86).
We followed a similar personality approach for /proc/cpuinfo where the compat one is only exposed if the task sets/inherits PER_LINUX32. The downside is that apparently some 32-bit applications started making use of the 64-bit /proc/cpuinfo format. To prevent further spread, I'm proposing the second patch in this series to force compat /proc/cpuinfo for 32-bit tasks. This is a departure from the "uname -m" behaviour but maybe they don't need to be coupled anyway.
Thoughts?
Catalin Marinas (2):
arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks
arm64: Always provide compat /proc/cpuinfo for 32-bit tasks
arch/arm64/include/asm/elf.h | 4 ++-- arch/arm64/kernel/cpuinfo.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
Catalin Marinas
maintainerPATCH 1/2 arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks
This patch brings the PER_LINUX32 /proc/cpuinfo format more in line with the 32-bit ARM one by providing an additional line:
model name : ARMv8 Processor rev X (v8l)
--- arch/arm64/include/asm/elf.h | 4 ++-- arch/arm64/kernel/cpuinfo.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-)
arch/arm64/include/asm/elf.h +2 -2
@@ -160,14 +160,14 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,#define STACK_RND_MASK (0x3ffff >> (PAGE_SHIFT - 12))#endif -#ifdef CONFIG_COMPAT -#ifdef __AARCH64EB__#define COMPAT_ELF_PLATFORM ("v8b")#else #define COMPAT_ELF_PLATFORM ("v8l")#endif +#ifdef CONFIG_COMPAT +#define COMPAT_ELF_ET_DYN_BASE (2 * TASK_SIZE_32 / 3)/* AArch32 registers. */
arch/arm64/kernel/cpuinfo.c +7 -1
@@ -22,6 +22,8 @@#include <linux/bitops.h> #include <linux/bug.h> +#include <linux/compat.h> +#include <linux/elf.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/personality.h>
@@ -104,6 +106,7 @@ static const char *const compat_hwcap2_str[] = {static int c_show (struct seq_file *m,void *v) {int i, j; +bool compat =personality (current->personality) ==PER_LINUX32 ;for_each_online_cpu (i) {struct cpuinfo_arm64 *cpuinfo = &per_cpu (cpu_data, i);
@@ -115,6 +118,9 @@ static int c_show(struct seq_file *m, void *v)* "processor". Give glibc what it expects. */ seq_printf (m,"processor\t: %d\n" , i); +if (compat) +seq_printf (m,"model name\t: ARMv8 Processor rev %d (%s)\n" , +MIDR_REVISION (midr),COMPAT_ELF_PLATFORM ); seq_printf(m, "BogoMIPS\t: %lu.%02lu\n", loops_per_jiffy / (500000UL/HZ),
@@ -127,7 +133,7 @@ static int c_show(struct seq_file *m, void *v)* software which does already (at least for 32-bit). */ seq_puts (m,"Features\t:" ); -if (personality (current->personality) ==PER_LINUX32 ) { +if (compat) {#ifdef CONFIG_COMPAT for (j =0 ; compat_hwcap_str[j]; j++)if (compat_elf_hwcap & (1 << j))
PATCH 1/2 arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks
Quoted 5 lines · Catalin Marinas
This patch brings the
PER_LINUX32/proc/cpuinfoformat more in line with the 32-bit ARM one by providing an additional line:model name : ARMv8 Processor rev X (v8l)
Quoted 7 lines
Cc <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Catalin Marinas <[email protected]>--- arch/arm64/include/asm/elf.h | 4 ++-- arch/arm64/kernel/cpuinfo.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-)
Looks good to me:
Will
Catalin Marinas
maintainerPATCH 1/2 arm64: Provide "model name" in /proc/cpuinfo for PER_LINUX32 tasks
Quoted 14 lines · Will Deacon
Quoted 5 lines · Catalin Marinas
This patch brings the
PER_LINUX32/proc/cpuinfoformat more in line with the 32-bit ARM one by providing an additional line:model name : ARMv8 Processor rev X (v8l)
Quoted 7 lines
Cc <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Catalin Marinas <[email protected]>--- arch/arm64/include/asm/elf.h | 4 ++-- arch/arm64/kernel/cpuinfo.c | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-)
Quoted 3 lines
Looks good to me:
Acked-by Will Deacon <[email protected]>
I guess you can take it as a fix for 4.7.
Signature · 1 line
Catalin
Catalin Marinas
maintainerPATCH 2/2 arm64: Always provide compat /proc/cpuinfo for 32-bit tasks
In reply to Catalin MarinasCurrently, the compat /proc/cpuinfo is provided only if a task has the PER_LINUX32 personality, either by setting it explicitly or by inheriting it from the parent task. This is in line with the "uname -m" behaviour.
However, there are 32-bit user applications making use of the /proc/cpuinfo and unaware of a need to set the personality. This patch changes the arm64 /proc/cpuinfo logic to provide the compat information if the task is 32-bit _or_ the PER_LINUX32 personality is set.
--- arch/arm64/kernel/cpuinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/kernel/cpuinfo.c +2 -1
@@ -106,7 +106,8 @@ static const char *const compat_hwcap2_str[] = {static int c_show (struct seq_file *m,void *v) {int i, j; -bool compat =personality (current->personality) ==PER_LINUX32 ; +bool compat =is_compat_task () || +personality (current->personality) ==PER_LINUX32 ;for_each_online_cpu (i) {struct cpuinfo_arm64 *cpuinfo = &per_cpu (cpu_data, i);
PATCH 2/2 arm64: Always provide compat /proc/cpuinfo for 32-bit tasks
Quoted 23 lines · Catalin Marinas
Currently, the compat
/proc/cpuinfois provided only if a task has thePER_LINUX32personality, either by setting it explicitly or by inheriting it from the parent task. This is in line with the "uname -m" behaviour.However, there are 32-bit user applications making use of the
/proc/cpuinfoand unaware of a need to set the personality. This patch changes the arm64/proc/cpuinfologic to provide the compat information if the task is 32-bit _or_ thePER_LINUX32personality is set.Cc <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Catalin Marinas <[email protected]>--- arch/arm64/kernel/cpuinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/kernel/cpuinfo.c +0
-0
arch/arm64/kernel/cpuinfo.c static const char *const compat_hwcap2_str[] = { · line 110
Quoted 6 lines
arch/arm64/kernel/cpuinfo.c +2
-1@@ -106,7 +106,8 @@ static const char *const compat_hwcap2_str[] = {static int c_show (struct seq_file *m,void *v) {int i, j; -bool compat =personality (current->personality) ==PER_LINUX32 ; +bool compat =is_compat_task () || +personality (current->personality) ==PER_LINUX32 ;
Hmm, I'm uneasy about this. It feels like an inconsistency with other things like uname, where we require the personality to be changed explicitly in order to get the AArch32 interface.
I'd rather go back to changing personality automatically based on the elf machine, or continue to require that applications be run with the correct personality (e.g. via linux32). This half way house is just confusing.
Arnd might have more thoughts...
Will
Re: [PATCH 2/2] arm64: Always provide compat /proc/cpuinfo for 32-bit tasks
In reply to Catalin MarinasHi all,
Quoted 10 lines · Catalin Marinas
Currently, the compat
/proc/cpuinfois provided only if a task has thePER_LINUX32personality, either by setting it explicitly or by inheriting it from the parent task. This is in line with the "uname -m" behaviour.However, there are 32-bit user applications making use of the
/proc/cpuinfoand unaware of a need to set the personality. This patch changes the arm64/proc/cpuinfologic to provide the compat information if the task is 32-bit _or_ thePER_LINUX32personality is set.
Quoted 4 lines
Cc <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Will Deacon <[email protected]>Signed-off-by Catalin Marinas <[email protected]>
What's the status on this patch? The previous patch (which was accepted already) is indeed confusing, because ARM32 processes on an ARM64 system are not necessarily setting PER_LINUX32.
I'm also curious, why was 'model name' removed from ARM64 in the first place? Plenty of other architectures support a similar property, and it's useful for some tools that already parse this, such as coreutils uname -p on Gentoo (and presumably others -- my Ubuntu machine must be similarly patched, as it supports uname -p on x86_64).
If we were to just stick 'model name' back in unconditionally, we could avoid the objections Will raised entirely :)
Regards,
Brian
Quoted 18 lines
--- arch/arm64/kernel/cpuinfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/arm64/kernel/cpuinfo.c +2
-1@@ -106,7 +106,8 @@ static const char *const compat_hwcap2_str[] = {static int c_show (struct seq_file *m,void *v) {int i, j; -bool compat =personality (current->personality) ==PER_LINUX32 ; +bool compat =is_compat_task () || +personality (current->personality) ==PER_LINUX32 ;for_each_online_cpu (i) {struct cpuinfo_arm64 *cpuinfo = &per_cpu (cpu_data, i);