From patchwork Sat Dec 6 21:00:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: afzal mohammed X-Patchwork-Id: 5450491 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F19E59F30B for ; Sat, 6 Dec 2014 21:05:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2B1320142 for ; Sat, 6 Dec 2014 21:05:26 +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 684CE20120 for ; Sat, 6 Dec 2014 21:05:25 +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 1XxMTT-0000Yi-Fx; Sat, 06 Dec 2014 21:01:07 +0000 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XxMTP-0000Wx-Tg for linux-arm-kernel@lists.infradead.org; Sat, 06 Dec 2014 21:01:04 +0000 Received: by mail-pa0-f48.google.com with SMTP id rd3so2797778pab.21 for ; Sat, 06 Dec 2014 13:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=Ds9NiAMhUq/70F6JOO8RlTMyLvU0wCJSGftdnCNWf3Q=; b=C0ZGshSR8WGM/DEMod0f9p8X9J/fEHAT4DdT17iEG4AI/HX8Gb5QhRrTTkjtxxYJKq vUcbLa+JUsW9AgJPwn36L9f3Vza5lNGc8f9zniGOkhkqELVPegGlb5UXbvow1cDWwJIv wdg/YgW1IzucvRUy2IH4VF5ZtCrImF8XEEk+3QgoksmZC34zw6Lc1/OEodrzJUwXS5wI WDBAL77O8+IvTBdcGtHNF6fNv9z10UHZS+X+Qa3Hh60i6vSrLDkzKxL4lqthXaovBQPJ 4hUP5+vDoDH8gMZIfw1eaT/Ng4yJaPIIdvmXjhU2+nE+14cSsFbW6beDfc8RsmWPCXFi JaWg== X-Received: by 10.66.218.42 with SMTP id pd10mr38940223pac.151.1417899642154; Sat, 06 Dec 2014 13:00:42 -0800 (PST) Received: from localhost ([223.227.114.91]) by mx.google.com with ESMTPSA id fn7sm32656915pad.38.2014.12.06.13.00.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 06 Dec 2014 13:00:41 -0800 (PST) Date: Sun, 7 Dec 2014 02:30:31 +0530 From: Afzal Mohammed To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Subject: Re: Do I need to invalidate caches before enabling (on ARMv7)? Message-ID: <20141206210031.GA1758@afzal-ThinkPad-R50e> References: <20141204100357.GO2129@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141204100357.GO2129@pengutronix.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141206_130104_018483_D6D1E5B4 X-CRM114-Status: GOOD ( 15.20 ) X-Spam-Score: -0.8 (/) Cc: kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org 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=-2.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Hi Uwe, On Thu, Dec 04, 2014 at 11:03:57AM +0100, Uwe Kleine-König wrote: > The breakage I'm currently seeing in barebox might well be explained by > stale I-cache entries and barebox (as of now) doesn't invalidate the > i-cache before enabling it. Looking into how Linux enables the I-cache > in the decompressor for v7[1] revealed that the caches are not cleaned > there either. (So my plan to copy from Linux failed :-) > > Now I wonder if that is only an unlikely (or even theoretical) issue > that wasn't noticed up to now or if I'm missing something. > So stale entries in the cache might even hurt before the cache is > enabled?! This would mean that you want to invalidate/flush the cache at > disable-time. Still I think doing it before enabling it in Linux would > be a good idea. And if it's only because bootloaders and (maybe worse) > boot roms cannot be trusted in this area. Are you sure that stale I-cache is causing the issue ?, but D-cache should not have stale data - it is a pre-requisite for booting the Kernel [1,2] (though not in Booting documentation) We were troubled by this issue when Kernel was loaded directly w/o bootloader, since D-cache was not invalidated, upon enabling, due to stale data Kernel was crashing randomly Did want to patch it for long time, but then with cash invalidation and all it never happened ;) Regards Afzal [1] http://www.arm.linux.org.uk/developer/booting.php [2] http://comments.gmane.org/gmane.linux.ports.arm.kernel/77718 ---------------------------------8<-------------------------------------- diff --git a/Documentation/arm/Booting b/Documentation/arm/Booting index 371814a36719..c4c423164d5e 100644 --- a/Documentation/arm/Booting +++ b/Documentation/arm/Booting @@ -193,6 +193,7 @@ In any case, the following conditions must be met: The MMU must be off. Instruction cache may be on or off. Data cache must be off. + Data cache should be invalidated. If the kernel is entered in HYP mode, the above requirements apply to the HYP mode configuration in addition to the ordinary PL1 (privileged