From patchwork Sun Mar 15 17:40:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 6013631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 76BA69F399 for ; Sun, 15 Mar 2015 17:44:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97067202DD for ; Sun, 15 Mar 2015 17:44:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52D652025B for ; Sun, 15 Mar 2015 17:44:19 +0000 (UTC) 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 1YXCXA-0006Uf-Fg; Sun, 15 Mar 2015 17:41:04 +0000 Received: from smtp4-g21.free.fr ([2a01:e0c:1:1599::13]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YXCX7-0006Qh-Bk for linux-arm-kernel@lists.infradead.org; Sun, 15 Mar 2015 17:41:02 +0000 Received: from [192.168.1.37] (unknown [77.207.132.113]) (Authenticated sender: shill) by smtp4-g21.free.fr (Postfix) with ESMTPSA id F2B4B4C8095; Sun, 15 Mar 2015 18:39:34 +0100 (CET) Message-ID: <5505C40C.1050001@free.fr> Date: Sun, 15 Mar 2015 18:40:28 +0100 From: Mason User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33 MIME-Version: 1.0 To: Russell King - ARM Linux Subject: Re: read_cpuid_id() in arch/arm/kernel/setup.c References: <55030A68.6070002@free.fr> <20150313161953.GS8656@n2100.arm.linux.org.uk> <550312BB.8020902@free.fr> <20150313164546.GV8656@n2100.arm.linux.org.uk> In-Reply-To: <20150313164546.GV8656@n2100.arm.linux.org.uk> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150315_104101_612022_B03F0521 X-CRM114-Status: GOOD ( 14.93 ) X-Spam-Score: -0.7 (/) Cc: Paul Walmsley , Will Deacon , Jonathan Austin , Linux ARM X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 13/03/2015 17:45, Russell King - ARM Linux wrote: > Yes, this one I like - and it probably fixes a potential latent bug > where the compiler was free to re-order that mrc outside of the if() > statement. > > Please wrap it up as a normal submission, thanks. Proposed patch at the end of this message. I'm now puzzling over why it's required to have "memory" in read_cpuid_ext's clobber list, and not in read_cpuid's? Regards. -- >8 -- Date: Sun, 15 Mar 2015 17:59:53 +0100 Subject: [PATCH] Use read_cpuid_ext() macro instead of inline asm In commit 067e710b9a982a92cc8294d7fa0f1e924c65bba1, Paul Walmsley fixed read_cpuid_ext() and added the following comment. The memory clobber prevents gcc 4.5 from reordering the mrc before any is_smp() tests, which can cause undefined instruction aborts on ARM1136 r0 due to the missing extended CP15 registers. --- arch/arm/kernel/setup.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index e55408e..1d60beb 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -246,12 +246,9 @@ static int __get_cpu_architecture(void) if (cpu_arch) cpu_arch += CPU_ARCH_ARMv3; } else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) { - unsigned int mmfr0; - /* Revised CPUID format. Read the Memory Model Feature * Register 0 and check for VMSAv7 or PMSAv7 */ - asm("mrc p15, 0, %0, c0, c1, 4" - : "=r" (mmfr0)); + unsigned int mmfr0 = read_cpuid_ext(CPUID_EXT_MMFR0); if ((mmfr0 & 0x0000000f) >= 0x00000003 || (mmfr0 & 0x000000f0) >= 0x00000030) cpu_arch = CPU_ARCH_ARMv7;