mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: "Xiaqing (A)" <saberlily.xia@hisilicon.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	linaro-kernel@lists.linaro.org, puck.chen@hisilicon.com,
	suzhuangluan@hisilicon.com, will.deacon@arm.com,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: cpuinfo: add AArch64 & elf platform for app compatibility
Date: Thu, 19 May 2016 14:18:32 +0100	[thread overview]
Message-ID: <20160519131832.GO22378@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <20160519125039.GN22378@e104818-lin.cambridge.arm.com>

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

-- 
Catalin

  reply	other threads:[~2016-05-19 13:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-19  2:44 x00195127
2016-05-19 10:14 ` Martinez Kristofer
2016-05-19 10:49 ` Catalin Marinas
2016-05-19 11:06   ` Xiaqing (A)
2016-05-19 12:50     ` Catalin Marinas
2016-05-19 13:18       ` Catalin Marinas [this message]
2016-05-20  3:22         ` Xiaqing (A)
2016-05-20  9:55           ` Catalin Marinas
2016-05-19 11:04 ` Robin Murphy
2016-05-19 11:42   ` Xiaqing (A)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160519131832.GO22378@e104818-lin.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=puck.chen@hisilicon.com \
    --cc=saberlily.xia@hisilicon.com \
    --cc=suzhuangluan@hisilicon.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®