From patchwork Mon Mar 16 08:44:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mason X-Patchwork-Id: 6016031 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 09D449F314 for ; Mon, 16 Mar 2015 08:47:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 435BF2049C for ; Mon, 16 Mar 2015 08:47:42 +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 60D30200F4 for ; Mon, 16 Mar 2015 08:47:41 +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 1YXQeK-0008NQ-Ll; Mon, 16 Mar 2015 08:45:24 +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 1YXQeG-0007Cd-6a for linux-arm-kernel@lists.infradead.org; Mon, 16 Mar 2015 08:45:21 +0000 Received: from [192.168.1.37] (unknown [77.207.132.113]) (Authenticated sender: shill) by smtp4-g21.free.fr (Postfix) with ESMTPSA id DFB774C802E; Mon, 16 Mar 2015 09:43:52 +0100 (CET) Message-ID: <550697FE.1020804@free.fr> Date: Mon, 16 Mar 2015 09:44:46 +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> <5505C40C.1050001@free.fr> In-Reply-To: <5505C40C.1050001@free.fr> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150316_014520_400301_C39728D7 X-CRM114-Status: GOOD ( 15.70 ) 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 15/03/2015 18:40, Mason wrote: > 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? Same player shoot again. -- >8 -- Date: Sun, 15 Mar 2015 17:59:53 +0100 Subject: [PATCH] Use read_cpuid_ext() macro instead of inline asm In commit 067e710b9a98 ("ARM: 7801/1: prevent gcc 4.5 from reordering extended CP15 reads above is_smp() test") 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. Signed-off-by: Mason Reviewed-by: Paul Walmsley --- 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;