From patchwork Wed Jul 10 12:59:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 2825722 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1AD9DC0AB2 for ; Wed, 10 Jul 2013 13:02:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 355E0201C4 for ; Wed, 10 Jul 2013 13:02:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 244AD201B5 for ; Wed, 10 Jul 2013 13:02:37 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uwu0n-0002nw-MO; Wed, 10 Jul 2013 13:00:51 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uwu0X-0003w3-AV; Wed, 10 Jul 2013 13:00:33 +0000 Received: from mail-ea0-x22f.google.com ([2a00:1450:4013:c01::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uwu0N-0003t5-HS for linux-arm-kernel@lists.infradead.org; Wed, 10 Jul 2013 13:00:24 +0000 Received: by mail-ea0-f175.google.com with SMTP id z7so4925517eaf.34 for ; Wed, 10 Jul 2013 06:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=G5voXbvUS9ZOx+Qdha7ZgmJjwKB+iePM/Z16WHDvT/k=; b=XW1UFhNVIO/wsQSa3obK2JtrhwV91LymIz/RROiUQbaH0jdeoF33MtbHZg0m2f1o0d RRts1vOAoKEX0gRFlYjmoJJeLRPfVhTheZ1OYptYzG4WQ3LPrH1KcLlueR9QcmrVqzG/ tN6rsbkJlXf6S5oG7jpisKHv/6y1Uo1TTHkiP2oy+mSpDDbgacUWh1n0mUeO+FSzNYFF bEtFR8nDfFPCNKzupZyKZXdKkRaQdRjmzVBm0eTxtc/kN1Ix8IL8CAEAgZiSByPQpt23 DticHYxkPYup0XNWiIt6+OBZTzezcDIg4etsxcpnYC6zW/wl+eEbKAhDToZUll0L8m9h RaXw== X-Received: by 10.14.104.135 with SMTP id i7mr35710598eeg.3.1373461201526; Wed, 10 Jul 2013 06:00:01 -0700 (PDT) Received: from localhost.localdomain (ip-88-212-34-237.antik.sk. [88.212.34.237]) by mx.google.com with ESMTPSA id o5sm59830172eef.5.2013.07.10.05.59.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 06:00:00 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: linux-kernel@vger.kernel.org, Tony Lindgren , Aaro Koskinen Subject: [PATCH v2 2/2] RX-51: ARM errata 430973 workaround Date: Wed, 10 Jul 2013 14:59:05 +0200 Message-Id: <1373461145-9812-3-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1373461145-9812-1-git-send-email-pali.rohar@gmail.com> References: <1362044548-5398-1-git-send-email-pali.rohar@gmail.com> <1373461145-9812-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130710_090023_815870_477E4193 X-CRM114-Status: GOOD ( 20.84 ) X-Spam-Score: -2.0 (--) Cc: Nishanth Menon , linux@arm.linux.org.uk, Peter De Schrijver , Ivaylo Dimitrov , Santosh Shilimkar , Pavel Machek , =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Closed and signed Nokia X-Loader bootloader stored in RX-51 nand does not set IBE bit in ACTLR and starting kernel in non-secure mode. So direct write to ACTLR by our kernel does not working and the code for ARM errata 430973 in commit 7ce236fcd6fd45b0441a2d49acb2ceb2de2e8a47 that sets IBE bit is a noop. In order to have workaround for ARM errata 430973 from non-secure world on RX-51 we needs Secure Monitor Call to set IBE BIT in ACTLR. This patch adds RX-51 specific SMC support and sets IBE bit in ACTLR during board init code for ARM errata 430973 workaround. ARM errata 430973 workaround is needed for thumb-2 ISA compiled userspace binaries. Without this workaround thumb-2 binaries crashing. So with this patch it is possible to recompile and run applications/binaries with thumb-2 ISA on RX-51. Signed-off-by: Ivaylo Dimitrov Signed-off-by: Pali Rohár --- arch/arm/mach-omap2/board-rx51.c | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c index 03663c2..f234dee 100644 --- a/arch/arm/mach-omap2/board-rx51.c +++ b/arch/arm/mach-omap2/board-rx51.c @@ -2,6 +2,8 @@ * Board support file for Nokia N900 (aka RX-51). * * Copyright (C) 2007, 2008 Nokia + * Copyright (C) 2012 Ivaylo Dimitrov + * Copyright (C) 2013 Pali Rohár * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -21,6 +23,7 @@ #include #include +#include #include #include #include @@ -31,7 +34,14 @@ #include "mux.h" #include "gpmc.h" #include "pm.h" +#include "soc.h" #include "sdram-nokia.h" +#include "omap-secure.h" + +/* Secure PPA (Primary Protected Application) APIs */ +#define RX51_PPA_HWRNG 29 +#define RX51_PPA_L2_INVAL 40 +#define RX51_PPA_WRITE_ACR 42 #define RX51_GPIO_SLEEP_IND 162 @@ -90,6 +100,66 @@ static struct omap_musb_board_data musb_board_data = { .power = 0, }; +/** + * rx51_secure_dispatcher: Routine to dispatch secure PPA API calls + * @idx: The PPA API index + * @process: Process ID + * @flag: The flag indicating criticality of operation + * @nargs: Number of valid arguments out of four. + * @arg1, arg2, arg3 args4: Parameters passed to secure API + * + * Return the non-zero error value on failure. + */ +static u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs, + u32 arg1, u32 arg2, u32 arg3, u32 arg4) +{ + u32 ret; + u32 param[5]; + + param[0] = nargs+1; /* RX-51 needs number of arguments + 1 */ + param[1] = arg1; + param[2] = arg2; + param[3] = arg3; + param[4] = arg4; + + /* + * Secure API needs physical address + * pointer for the parameters + */ + local_irq_disable(); + local_fiq_disable(); + flush_cache_all(); + outer_clean_range(__pa(param), __pa(param + 5)); + ret = omap_smc3(idx, process, flag, __pa(param)); + flush_cache_all(); + local_fiq_enable(); + local_irq_enable(); + + return ret; +} + +/** + * rx51_secure_update_aux_cr: Routine to modify the contents of Auxiliary Control Register + * @set_bits: bits to set in ACR + * @clr_bits: bits to clear in ACR + * + * Return the non-zero error value on failure. +*/ +static u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits) +{ + u32 acr; + + /* Read ACR */ + asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr)); + acr &= ~clear_bits; + acr |= set_bits; + + return rx51_secure_dispatcher(RX51_PPA_WRITE_ACR, + 0, + FLAG_START_CRITICAL, + 1, acr, 0, 0, 0); +} + static void __init rx51_init(void) { struct omap_sdrc_params *sdrc_params; @@ -105,6 +175,14 @@ static void __init rx51_init(void) rx51_peripherals_init(); rx51_camera_init(); + if (omap_type() == OMAP2_DEVICE_TYPE_SEC) { +#ifdef CONFIG_ARM_ERRATA_430973 + pr_info("RX-51: Enabling ARM errata 430973 workaround\n"); + /* set IBE to 1 */ + rx51_secure_update_aux_cr(BIT(6), 0); +#endif + } + /* Ensure SDRC pins are mux'd for self-refresh */ omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);