From patchwork Fri Jan 26 12:24:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 866278 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="G7GwzC6W"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zSdQM39y8z9s81 for ; Fri, 26 Jan 2018 23:24:59 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id E9790C223F7; Fri, 26 Jan 2018 12:24:52 +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=RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID 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 2AFEAC223C5; Fri, 26 Jan 2018 12:24:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 910D2C22052; Fri, 26 Jan 2018 12:24:48 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 3A9B3C21DA1 for ; Fri, 26 Jan 2018 12:24:48 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id r71so936287wmd.1 for ; Fri, 26 Jan 2018 04:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=bUiR90BZAOmsR4jM5sTTTIz8BfrbW3c1Ldr/sa4Ma6c=; b=G7GwzC6WvqpfDYrr98RMRIHtJ9UAN7Q6MWzy3gC+JrVo1T+n+WwI+NLBRGAwRQsa5Q ZfZY83ouZx82+r/cQ5JjFt7QyGaXMkJSx4UjPQXerxEEKiDLeLjL3fUZtckz+Ir7Got6 Z1C8wfpBBIXHfisjKGYFzLf0zdbpgt4KY15sY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=bUiR90BZAOmsR4jM5sTTTIz8BfrbW3c1Ldr/sa4Ma6c=; b=UPF/FnGrTVYwq4qieIiNoPM3L9vJnzZNnkn06OzSEBkga21H+vliC4RQDPf2cyC9NF 6+B+SlgQzxme4TNIvbxuMe0DF13qOJaf0dikPi9Pc2jCdikJhX3FhpY3qNae6Nc/0hU6 11TjL2ZNRTe4Urjc8cc5GkLt8aPLAqrw/4HisWa1rWCdZCKLRI2qu3yk3qDSIvd6jajW 7iK+OI5RECPbbCr/ekpLoqxeBdQxJOQAY3X3aaH4bstJxpHpdINvNtiZHt8EPgfftIT3 1iJAzDEfBSk8Umc2rZM8+hM+ATVcqTgsKUvhT0IOORpsJmcq39lo/hSRjlYSPJwM54RO jbUg== X-Gm-Message-State: AKwxyteP1wMBYQGD/Y5PXAzv7cv43zOUSkAptzm+/osSVL+8OKxjetXC wscRAgG72hnQZpo8IyXN3jMdJ47khac= X-Google-Smtp-Source: AH8x225Z9T+e5NEiiqfP0PYU3kw5dj1bmNKeCX2HXu/Rr3MrvrzVGv8FYP0+YPwGuZZ2/lrTTkZPfA== X-Received: by 10.80.174.177 with SMTP id e46mr33985236edd.49.1516969487692; Fri, 26 Jan 2018 04:24:47 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id 15sm2546827eds.54.2018.01.26.04.24.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 04:24:47 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com Date: Fri, 26 Jan 2018 12:24:42 +0000 Message-Id: <1516969484-19409-1-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: fabio.estevam@nxp.com Subject: [U-Boot] [RESEND PATCH v3 0/2] Fix CAAM for TrustZone enable for warp7 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" V3: - Changed location of sec_init() from warp.c::board_init() to soc.c::arch_misc_init() which will allow any i.MX7 which defines CONFIG_FSL_CAAM to forget about running sec_init(). V2: - Add an explicit assignment of JRMID when setting job-ring ownership Required on my reference part where the JRMID field is not set on the third job-ring V1: This series is the u-boot fix to a problem we encountered when enabling OPTEE/TrustZone on the WaRP7. The symptom is once TrustZone is activated the first page of CAAM registers becomes read-only, read-zero from the perspective of Linux and other non TrustZone contexts. Offlining the problem with Peng Fan[1] we eventually came to realise the problem could be worked around by 1. Making Linux skip RNG initialisation - a set of patches should be hitting LKML to do just that. 2. Initialising the RNG either from u-boot or OPTEE. In this case u-boot is the right place to-do that because there's upstream code in u-boot that just works. Patch #2 does that for the WaRP7. 3. Ensuring the job-ring registers are assigned to the non TrustZone mode. On the i.MX7 after the BootROM runs the job-ring registers are assigned to TrustZone. Patch #1 does that for all CAAM hardware. On point #3 this ordinarily isn't a problem because unless TrustZone is activated the restrictions on the job-ring registers don't kick in, its only after enabling TrustZone that Linux will loose access to the job-ring registers. Finally should OPTEE or another TEE want to do things with the job-ring registers it will have sufficient privilege to assign whichever job-ring registers it wants to OPTEE/TEE but will naturally then have to arbitrate with Linux to inform the Kernel CAAM driver which job-ring registers it can and cannot access. That arbitration process is for a future putative OPTEE/TEE CAAM driver to solve and is out of scope of this patchset. [1] Thanks for all of your help BTW - Peng, there's no way this would be working without you giving direction on how. Bryan O'Donoghue (2): drivers/crypto/fsl: assign job-rings to non-TrustZone imx: mx7: run sec_init for CAAM RNG arch/arm/mach-imx/mx7/soc.c | 4 ++++ drivers/crypto/fsl/jr.c | 9 +++++++++ drivers/crypto/fsl/jr.h | 2 ++ 3 files changed, 15 insertions(+)