From patchwork Mon Apr 30 08:34:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Vadot X-Patchwork-Id: 906573 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=freebsd.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40ZJGb0N74z9s0W for ; Mon, 30 Apr 2018 18:53:10 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A5747C21F3C; Mon, 30 Apr 2018 08:46:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9EA68C21F5E; Mon, 30 Apr 2018 08:36:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A60C0C21F5E; Mon, 30 Apr 2018 08:34:53 +0000 (UTC) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by lists.denx.de (Postfix) with ESMTPS id 1C261C21F01 for ; Mon, 30 Apr 2018 08:34:49 +0000 (UTC) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id 737e5d43 for ; Mon, 30 Apr 2018 10:34:48 +0200 (CEST) Received: from wopr.blih.net (62-210-199-19.rev.poneytelecom.eu [62.210.199.19]) by mail.blih.net (OpenSMTPD) with ESMTPSA id 75c8f076 TLS version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO for ; Mon, 30 Apr 2018 10:34:43 +0200 (CEST) Received: from elbarto (uid 1001) (envelope-from manu@bidouilliste.com) id 7c9b8 by wopr.blih.net (DragonFly Mail Agent v0.11); Mon, 30 Apr 2018 10:34:43 +0200 From: Emmanuel Vadot To: sjg@chromium.org, bmeng.cn@gmail.com, andriy.shevchenko@linux.intel.com, rick@andestech.com, philipp.tomsich@theobroma-systems.com, albert.u.boot@aribaud.net, xypron.glpk@gmx.de Date: Mon, 30 Apr 2018 10:34:41 +0200 Message-Id: <20180430083441.72712-1-manu@freebsd.org> X-Mailer: git-send-email 2.16.3 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 5/5] cmd: bootelf: Flush cache before starting X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some application might load some code at location that contain stale cache entries. Before running a elf or raw binary, flush the caches if they are enabled. Signed-off-by: Emmanuel Vadot --- cmd/elf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/elf.c b/cmd/elf.c index 5b59fc6329..f372306de5 100644 --- a/cmd/elf.c +++ b/cmd/elf.c @@ -109,6 +109,17 @@ static unsigned long do_bootelf_exec(ulong (*entry)(int, char * const[]), { unsigned long ret; +#if defined(CONFIG_SYS_HAVE_DCACHE_MAINTENANCE) && \ + !defined(CONFIG_SYS_DCACHE_OFF) + if (dcache_status()) + flush_dcache_all(); +#endif +#if defined(CONFIG_SYS_HAVE_ICACHE_MAINTENANCE) && \ + !defined(CONFIG_SYS_ICACHE_OFF) + if (icache_status()) + invalidate_icache_all(); +#endif + /* * pass address parameter as argv[0] (aka command name), * and all remaining args