From patchwork Thu May 19 13:18:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 624062 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r9WsD33Kzz9sdg for ; Thu, 19 May 2016 23:20:32 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b3Nqt-0004nJ-Mj; Thu, 19 May 2016 13:18:59 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b3Nqq-0004QF-OL for linux-arm-kernel@lists.infradead.org; Thu, 19 May 2016 13:18:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C5992F; Thu, 19 May 2016 06:18:55 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (e104818-lin.cambridge.arm.com [10.1.203.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2C5B83F213; Thu, 19 May 2016 06:18:35 -0700 (PDT) Date: Thu, 19 May 2016 14:18:32 +0100 From: Catalin Marinas To: "Xiaqing (A)" Subject: Re: [PATCH] arm64: cpuinfo: add AArch64 & elf platform for app compatibility Message-ID: <20160519131832.GO22378@e104818-lin.cambridge.arm.com> References: <1463625873-60016-1-git-send-email-saberlily.xia@hisilicon.com> <20160519104925.GL22378@e104818-lin.cambridge.arm.com> <573D9E40.4000705@hisilicon.com> <20160519125039.GN22378@e104818-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160519125039.GN22378@e104818-lin.cambridge.arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160519_061856_818151_C7CBEA73 X-CRM114-Status: GOOD ( 18.94 ) X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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<--------------------- ------------------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 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 #include +#include #include #include #include @@ -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))