we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
Signed-off-by: Qing Xia saberlily.xia@hisilicon.com --- arch/arm64/kernel/cpuinfo.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470..c3527ad 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -114,6 +114,9 @@ static int c_show(struct seq_file *m, void *v) * online processors, looking for lines beginning with * "processor". Give glibc what it expects. */ + seq_printf(m, "Processor\t: AArch64 Processor rev %d (%s)\n", + read_cpuid_id() & 15, ELF_PLATFORM); + seq_printf(m, "processor\t: %d\n", i);
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
On Thu, May 19, 2016 at 10:44 AM, x00195127 saberlily.xia@hisilicon.com wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
Signed-off-by: Qing Xia saberlily.xia@hisilicon.com
arch/arm64/kernel/cpuinfo.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470..c3527ad 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -114,6 +114,9 @@ static int c_show(struct seq_file *m, void *v) * online processors, looking for lines beginning with * "processor". Give glibc what it expects. */
seq_printf(m, "Processor\t: AArch64 Processor rev %d (%s)\n",
read_cpuid_id() & 15, ELF_PLATFORM);
Nit: read_cpuid_id() & 0xf, ELF_PLATFORM); What're those apps will need this string to startup?
M.K.
seq_printf(m, "processor\t: %d\n", i); seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
-- 1.8.3.2
linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
On Thu, May 19, 2016 at 10:44:33AM +0800, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
I have the same question as Martinez: what are those apps? If they are 64-bit apps, they can always assume AArch64 processor.
在 2016/5/19 18:49, Catalin Marinas 写道:
On Thu, May 19, 2016 at 10:44:33AM +0800, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
I have the same question as Martinez: what are those apps? If they are 64-bit apps, they can always assume AArch64 processor.
Those are 32-bit apps, and those apps are very popular in our country.
On Thu, May 19, 2016 at 07:06:40PM +0800, Xiaqing (A) wrote:
在 2016/5/19 18:49, Catalin Marinas 写道:
On Thu, May 19, 2016 at 10:44:33AM +0800, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
I have the same question as Martinez: what are those apps? If they are 64-bit apps, they can always assume AArch64 processor.
Those are 32-bit apps, and those apps are very popular in our country.
32-bit apps checking for "AArch64" is a really silly idea. What do they do with this information?
I'm rather inclined to merge this patch:
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..623d7d291dd6 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -127,7 +127,8 @@ 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 (is_compat_task() || + personality(current->personality) == PER_LINUX32) { #ifdef CONFIG_COMPAT for (j = 0; compat_hwcap_str[j]; j++) if (compat_elf_hwcap & (1 << j))
As discussed here:
http://article.gmane.org/gmane.linux.kernel/2209217
On Thu, May 19, 2016 at 01:50:40PM +0100, Catalin Marinas wrote:
On Thu, May 19, 2016 at 07:06:40PM +0800, Xiaqing (A) wrote:
在 2016/5/19 18:49, Catalin Marinas 写道:
On Thu, May 19, 2016 at 10:44:33AM +0800, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
I have the same question as Martinez: what are those apps? If they are 64-bit apps, they can always assume AArch64 processor.
Those are 32-bit apps, and those apps are very popular in our country.
32-bit apps checking for "AArch64" is a really silly idea. What do they do with this information?
I'm rather inclined to merge this patch:
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..623d7d291dd6 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -127,7 +127,8 @@ 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 (is_compat_task() ||
personality(current->personality) == PER_LINUX32) {
#ifdef CONFIG_COMPAT for (j = 0; compat_hwcap_str[j]; j++) if (compat_elf_hwcap & (1 << j))
To make it even more in line with the AArch32 kernel, let's add the "model name":
------------------8<--------------------- diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..6bda9d30a769 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -22,6 +22,7 @@
#include <linux/bitops.h> #include <linux/bug.h> +#include <linux/elf.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/personality.h> @@ -104,6 +105,8 @@ static const char *const compat_hwcap2_str[] = { static int c_show(struct seq_file *m, void *v) { int i, j; + bool compat = is_compat_task() || + 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)) ------------------8<---------------------
With the above, a compat task or a native one with PER_LINUX32 personality would get:
processor : 0 model name : ARMv8 Processor rev 0 (v8l) BogoMIPS : 100.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt lpae evtstrm aes pmull sha1 sha2 crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 0
在 2016/5/19 21:18, Catalin Marinas 写道:
On Thu, May 19, 2016 at 01:50:40PM +0100, Catalin Marinas wrote:
On Thu, May 19, 2016 at 07:06:40PM +0800, Xiaqing (A) wrote:
在 2016/5/19 18:49, Catalin Marinas 写道:
On Thu, May 19, 2016 at 10:44:33AM +0800, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
I have the same question as Martinez: what are those apps? If they are 64-bit apps, they can always assume AArch64 processor.
Those are 32-bit apps, and those apps are very popular in our country.
32-bit apps checking for "AArch64" is a really silly idea. What do they do with this information?
I'm rather inclined to merge this patch:
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..623d7d291dd6 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -127,7 +127,8 @@ 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 (is_compat_task() ||
#ifdef CONFIG_COMPAT for (j = 0; compat_hwcap_str[j]; j++) if (compat_elf_hwcap & (1 << j))personality(current->personality) == PER_LINUX32) {
To make it even more in line with the AArch32 kernel, let's add the "model name":
------------------8<--------------------- diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..6bda9d30a769 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -22,6 +22,7 @@
#include <linux/bitops.h> #include <linux/bug.h> +#include <linux/elf.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/personality.h> @@ -104,6 +105,8 @@ static const char *const compat_hwcap2_str[] = { static int c_show(struct seq_file *m, void *v) { int i, j;
bool compat = is_compat_task() ||
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) {
#ifdef CONFIG_COMPAT for (j = 0; compat_hwcap_str[j]; j++) if (compat_elf_hwcap & (1 << j))if (compat) {
------------------8<---------------------
With the above, a compat task or a native one with PER_LINUX32 personality would get:
processor : 0 model name : ARMv8 Processor rev 0 (v8l) BogoMIPS : 100.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt lpae evtstrm aes pmull sha1 sha2 crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 0
I have tested with your patch, the app still can not start up at all.
I'm sorry I didn't explan this exactly before, those apps are 32-bit android apps(com.tencent.pao etc.). They want to get the information as "*D m3e : GetCPUType:AArch64 Processor rev 0 (aarch64)*" and I'm sure the process is forked by zygote not zygote64 in android M.
Finally, I find that apps need the information "Processor :", so when I change your patch as below, the apps can start up. ---------------------------------------------------------------------- diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470..f14ea4a 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -104,6 +104,8 @@ static const char *const compat_hwcap2_str[] = { static int c_show(struct seq_file *m, void *v) { int i, j; + bool compat = is_compat_task() || + personality(current->personality) == PER_LINUX32;
for_each_online_cpu(i) { struct cpuinfo_arm64 *cpuinfo = &per_cpu(cpu_data, i); @@ -116,6 +118,10 @@ static int c_show(struct seq_file *m, void *v) */ seq_printf(m, "processor\t: %d\n", i);
+ if (compat) + seq_printf(m, "Processor\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), loops_per_jiffy / (5000UL/HZ) % 100); @@ -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))
On Fri, May 20, 2016 at 11:22:40AM +0800, Xiaqing (A) wrote:
在 2016/5/19 21:18, Catalin Marinas 写道:
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470486f3..6bda9d30a769 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -22,6 +22,7 @@
#include <linux/bitops.h> #include <linux/bug.h> +#include <linux/elf.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/personality.h> @@ -104,6 +105,8 @@ static const char *const compat_hwcap2_str[] = { static int c_show(struct seq_file *m, void *v) { int i, j;
bool compat = is_compat_task() ||
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)) ------------------8<---------------------
With the above, a compat task or a native one with PER_LINUX32 personality would get:
processor : 0 model name : ARMv8 Processor rev 0 (v8l) BogoMIPS : 100.00 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt lpae evtstrm aes pmull sha1 sha2 crc32 CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 0
I have tested with your patch, the app still can not start up at all.
I'm sorry I didn't explan this exactly before, those apps are 32-bit android apps(com.tencent.pao etc.). They want to get the information as "*D m3e : GetCPUType:AArch64 Processor rev 0 (aarch64)*" and I'm sure the process is forked by zygote not zygote64 in android M.
So, these 32-bit applications would never run on an arm32 kernel (because with my patch, compat /proc/cpuinfo is the same as the native arm32 kernel)? How did they get into this situation?
I recall from some past discussions with Google on this aspect that there are indeed applications parsing /proc/cpuinfo but the 32-bit zygote would set PER_LINUX32 so that child processes would inherit it and always get the compat /proc/cpuinfo. I don't follow the Android developments, so I can't tell whether this personality setting is in place.
While we did change the /proc/cpuinfo 64-bit format slightly in 3.19, I find it insane that there are 32-bit applications relying on always running under a 64-bit kernel.
On 19/05/16 03:44, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
Signed-off-by: Qing Xia saberlily.xia@hisilicon.com
arch/arm64/kernel/cpuinfo.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470..c3527ad 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -114,6 +114,9 @@ static int c_show(struct seq_file *m, void *v) * online processors, looking for lines beginning with * "processor". Give glibc what it expects. */
seq_printf(m, "Processor\t: AArch64 Processor rev %d (%s)\n",
read_cpuid_id() & 15, ELF_PLATFORM);
The pre-3.19 behaviour printed this once - now you're printing it for every CPU in the system, but all with the same revision of whichever core this happens to be running on, which is unjustifiably incorrect.
Furthermore, this string provides virtually no useful information anyway - the majority of code running on AArch64 already knows that by virtue of the fact that *it's running at all*, and for scripts/interpreted code/etc. there are already appropriate mechanisms for discovering the platform (e.g. uname).
Robin.
seq_printf(m, "processor\t: %d\n", i);
seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
在 2016/5/19 19:04, Robin Murphy 写道:
On 19/05/16 03:44, x00195127 wrote:
we find that some apps will read cpuinfo when start up, they need the string as follows: "Processor : AArch64 Processor rev 0 (aarch64)"
Then thay could load the corresponding libs. But now arm64 platform's cpuinfo don't has this now, so we need add this.
Signed-off-by: Qing Xia saberlily.xia@hisilicon.com
arch/arm64/kernel/cpuinfo.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 3808470..c3527ad 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -114,6 +114,9 @@ static int c_show(struct seq_file *m, void *v) * online processors, looking for lines beginning with * "processor". Give glibc what it expects. */
seq_printf(m, "Processor\t: AArch64 Processor rev %d (%s)\n",
read_cpuid_id() & 15, ELF_PLATFORM);
The pre-3.19 behaviour printed this once - now you're printing it for every CPU in the system, but all with the same revision of whichever core this happens to be running on, which is unjustifiably incorrect.
Furthermore, this string provides virtually no useful information anyway
- the majority of code running on AArch64 already knows that by virtue
of the fact that *it's running at all*, and for scripts/interpreted code/etc. there are already appropriate mechanisms for discovering the platform (e.g. uname).
Robin.
Those are 32-bit andriod apps, and according to my tests they really need this information, although this information is already useless in my opinion. A lot of android apps update very slowly.
seq_printf(m, "processor\t: %d\n", i); seq_printf(m, "BogoMIPS\t: %lu.%02lu\n",
.
linaro-kernel@lists.linaro.org