From patchwork Tue Apr 7 13:57:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 6171681 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B24DBF4A6 for ; Tue, 7 Apr 2015 13:57:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 91E9920263 for ; Tue, 7 Apr 2015 13:57:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1A514202B4 for ; Tue, 7 Apr 2015 13:57:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755042AbbDGN5e (ORCPT ); Tue, 7 Apr 2015 09:57:34 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:41174 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755031AbbDGN5b (ORCPT ); Tue, 7 Apr 2015 09:57:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=4o8StIVxF0mXO/sRKeegjPb4s5lOQL8HWJqjTS2D5u4=; b=n7TJ2vKonuw5WN++cJOaMUjc3Jm7fhVZipfiZ364wwLHgfmWP92a0sBioN69/Krt+N2dFP5D+K6s+/3qDd7f03B776C6TPobZxD/ScwCOw8MXBvSV9kpHEvP6gxXOXihwUkhDudvPEeLM/m8Wk0ifNYHCKGSPnSaN8+YxLRSB9o=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:49952) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1YfU0F-0002mq-Qg; Tue, 07 Apr 2015 14:57:20 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1YfU0A-0004sp-Cd; Tue, 07 Apr 2015 14:57:14 +0100 Date: Tue, 7 Apr 2015 14:57:13 +0100 From: Russell King - ARM Linux To: Tony Lindgren Cc: Ivaylo Dimitrov , Pavel Machek , "linux-omap@vger.kernel.org" , Sebastian Reichel , "linux-arm-kernel@lists.infradead.org" , Matthijs van Duin Subject: Re: ARM errata 430973 on multi platform kernels Message-ID: <20150407135713.GL4027@n2100.arm.linux.org.uk> References: <20150403225212.GY10805@atomide.com> <5520E2EE.4080302@gmail.com> <5521A438.1070008@gmail.com> <20150406151939.GG18048@atomide.com> <20150406154037.GI18048@atomide.com> <5522BEEF.2000405@gmail.com> <20150406174245.GJ18048@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150406174245.GJ18048@atomide.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 Mon, Apr 06, 2015 at 10:42:45AM -0700, Tony Lindgren wrote: > * Ivaylo Dimitrov [150406 10:15]: > > On 6.04.2015 18:40, Tony Lindgren wrote: > > > > > >Oops sorry, wrong numbers for errata above.. s/458693/430973/, here's > > >a better version: > > > > > >1. For cortex-a8 revisions affected by 430973, we can do a custom > > > cpu_v7_switch_mm function that always does flush BTAC/BTB. > > > > > > > Why custom function, if IBE bit is zero, BTB invalidate instruction is a > > NOP. Do you think that "mcr p15, 0, r2, c7, c5, 6" executed as a NOP will > > put so much overhead, that it deserves a custom function? > > Hmm but it still seems to do something also on cortex-a8 r3p2 that > is supposedly not affected by 430973.. Based on my tests so far, at least > armhf running cpuburn-a8 in the background and doing apt-get update > segfaults constantly without flush BTAC/BTB. This seems to be the case > no matter how the aux ctrl reg bits are set.. This should be reproducable > on any pandboard xm BTW. > > > >2. For HS cortex-a8 processors other than n900 affected by 430973, > > > we need to implement functions similar to rx51_secure_update_aux_cr, > > > the bootrom on n900 is different from TI HS omaps so the SMC call > > > numbering may be different. > > > > > >3. For later cortex-a8 processors not affected by 430973, we need > > > to clear IBE bit to avoid erratum 687067. > > > > > > > Maybe it should be implemented something like: > > > > 1. if Cortex-A8, always execute invalidate BTB instruction in > > cpu_v7_switch_mm > > This part still seems to need more investigating for why it's still > needed also r3p2 as I describe above. Otherwise we may be hiding some > other bug. > > > 2. For Cortex-A8 revisions affected by 430973, set IBE bit to 1, set it > > to 0 for all others. That should happen as soon as possible, > > otherwise kernel may crash on affected revisions if thumb- > > compiled. > > Yes this makes sense. Well, one thing we can do is to tweak the proc-v7*.S such that we detect Cortex-A8 separately, and only execute the BTB flush for CA8 processors if the errata is enabled. Something like this (untested): diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S index bc86be205c04..fa385140715f 100644 --- a/arch/arm/mm/proc-v7-2level.S +++ b/arch/arm/mm/proc-v7-2level.S @@ -37,15 +37,18 @@ * It is assumed that: * - we are not using split page tables */ -ENTRY(cpu_v7_switch_mm) +ENTRY(cpu_ca8_switch_mm) #ifdef CONFIG_MMU mov r2, #0 - mmid r1, r1 @ get mm->context.id - ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP) - ALT_UP(orr r0, r0, #TTB_FLAGS_UP) #ifdef CONFIG_ARM_ERRATA_430973 mcr p15, 0, r2, c7, c5, 6 @ flush BTAC/BTB #endif +#endif +ENTRY(cpu_v7_switch_mm) +#ifdef CONFIG_MMU + mmid r1, r1 @ get mm->context.id + ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP) + ALT_UP(orr r0, r0, #TTB_FLAGS_UP) #ifdef CONFIG_PID_IN_CONTEXTIDR mrc p15, 0, r2, c13, c0, 1 @ read current context ID lsr r2, r2, #8 @ extract the PID @@ -61,6 +64,7 @@ ENTRY(cpu_v7_switch_mm) #endif bx lr ENDPROC(cpu_v7_switch_mm) +ENDPROC(cpu_ca8_switch_mm) /* * cpu_v7_set_pte_ext(ptep, pte) diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S index b1d19ea5e1af..6bec3cfbea39 100644 --- a/arch/arm/mm/proc-v7.S +++ b/arch/arm/mm/proc-v7.S @@ -153,6 +153,21 @@ ENDPROC(cpu_v7_do_resume) #endif /* + * Cortex-A8 + */ + globl_equ cpu_ca8_proc_init, cpu_v7_proc_init + globl_equ cpu_ca8_proc_fin, cpu_v7_proc_fin + globl_equ cpu_ca8_reset, cpu_v7_reset + globl_equ cpu_ca8_do_idle, cpu_v7_do_idle + globl_equ cpu_ca8_dcache_clean_area, cpu_v7_dcache_clean_area + globl_equ cpu_ca8_set_pte_ext, cpu_v7_set_pte_ext + globl_equ cpu_ca8_suspend_size, cpu_v7_suspend_size +#ifdef CONFIG_ARM_CPU_SUSPEND + globl_equ cpu_ca8_do_suspend, cpu_v7_do_suspend + globl_equ cpu_ca8_do_resume, cpu_v7_do_resume +#endif + +/* * Cortex-A9 processor functions */ globl_equ cpu_ca9mp_proc_init, cpu_v7_proc_init @@ -471,7 +486,10 @@ __v7_setup_stack: @ define struct processor (see and proc-macros.S) define_processor_functions v7, dabort=v7_early_abort, pabort=v7_pabort, suspend=1 +#ifndef CONFIG_ARM_LPAE + define_processor_functions ca8, dabort=v7_early_abort, pabort=v7_pabort, suspend=1 define_processor_functions ca9mp, dabort=v7_early_abort, pabort=v7_pabort, suspend=1 +#endif #ifdef CONFIG_CPU_PJ4B define_processor_functions pj4b, dabort=v7_early_abort, pabort=v7_pabort, suspend=1 #endif @@ -527,6 +545,16 @@ __v7_ca9mp_proc_info: __v7_proc __v7_ca9mp_proc_info, __v7_ca9mp_setup, proc_fns = ca9mp_processor_functions .size __v7_ca9mp_proc_info, . - __v7_ca9mp_proc_info + /* + * ARM Ltd. Cortex A8 processor. + */ + .type __v7_ca8_proc_info, #object +__v7_ca8_proc_info: + .long 0x410fc080 + .long 0xff0ffff0 + __v7_proc __v7_ca8mp_proc_info, proc_fns = ca8_processor_functions + .size __v7_ca8_proc_info, . - __v7_ca8_proc_info + #endif /* CONFIG_ARM_LPAE */ /*