From patchwork Fri Jan 26 12:19:11 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: 125950 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp294120ljd; Fri, 26 Jan 2018 04:19:43 -0800 (PST) X-Google-Smtp-Source: AH8x226p5Z4VQUi6WadCdO/O0P00pKCY7ngMlHV/c0g3IrXjHfKobxawIdSOHoBEdit7+SJ8dOsH X-Received: by 10.80.204.73 with SMTP id n9mr34606579edi.69.1516969183072; Fri, 26 Jan 2018 04:19:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516969183; cv=none; d=google.com; s=arc-20160816; b=CGu9PHUMAheim+RUiPuuKZBRG6EYI5ez1TDyjm58cgjcJl86sIvQI/aFSfg51eU17q 2I8xKl2Hbpd7mVAJdbUFj+U+QYiKCSYV+wxXOCLJFOK01NoZ9+W+mBlBqwoiPyy1TMtu uohkXm9cqlamGWOYSclSUZwb8LSXKK8ZxDh8WaR2oT7DrSb/qZtK0c3pCbsZK0RTZShn lOvWmM2SDi/Fo/dXYjccXMAWK9CGS1FrUAOCMYJOs1rlh791pAdZqiQ0snTO9rwKJjpC G/JjWAX6jc9GDePXKf+vUFgcx3g4p0oeaXpHOW5pACYbuYHqd4H5jj9jo1pYAYIQ72WJ 0fbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=dpe/qd9uRt8PVcHhp2Nde0bG0ulki52Hh2IEpnWYW20=; b=kKcSSRd0xfXeDKp51Lqhwxu+0noxn2Jn/Frl2VJgrsd7/3yv/+RQgGy8bJfaojuFX1 InQMK/VHX2rpX/A230bTMTO/lncCIvj63X6ClVGkOnHUbYwv+HKmuUvcriIEX3znXigg EoNgj/LOcMFHr45YuSagCYHVZabLw/q35dduHy2h3uvZ7ZT8r08NpC8YmRfNXrkcq88X ebvsyo1mmimh7zecThNfCc929D3MOIF1q64BHBOZuSTh0eQo+nHCN7kZVc0uB1UNcsBb CVooa6/81DtG0OrsypkuPXsXYWdazni6yAfxU0N0dMgdAefmyvoB/nHSYe57Gu+IwPKt IofA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YSNI3yN+; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id q16si101649edq.170.2018.01.26.04.19.42; Fri, 26 Jan 2018 04:19:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=YSNI3yN+; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id A8AFDC224AE; Fri, 26 Jan 2018 12:19:23 +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 BF01EC224C7; Fri, 26 Jan 2018 12:19:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D62CFC224B8; Fri, 26 Jan 2018 12:19:16 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id 059FAC224D5 for ; Fri, 26 Jan 2018 12:19:16 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id r71so907714wmd.1 for ; Fri, 26 Jan 2018 04:19:16 -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=YSNI3yN+deHJHrShYpFsxJ7TA7UvHPVJmjGBzwWkW9zdoE1Df3HdAg5oMvAYkhH/yO aiC6SJUxNBYtpba1hPbXIKriqwBS9IpoPsdTsyR3/XVzMJME3JFeBTYpHoVYqpZi6SNq 7xv75iarmzzObFNZE7E+nILsgyJwKiHGkds4c= 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=nq91Pty2JUecG7JAJ+h/TwAhHwlkfn+CdRtStKyPIyitAP5HgOpFT6KUj3yHsfPAds C5SsFlIrfMoOvs6Fa0Z4sO7Jw52KBvm2U4SbRrYTLosW3cNlFActbDyAoZpiOE5c+3/V amI3S4OgJn6hFlPu0KFqTP0tk9x6DiWrPJk0qJskcYTteFZC/pW4JobGx8CHOQ1gKnQo EAcwW/PU4fc8DVuqfM00dZYvS4S+fhhUwkW/bi4rBQvrgQKTSKcfl7zY9xTHHSuVmfby q1bU/pGnCOS/h/CLDmmnDGzZIOBJvblB21CcVBVu96SDlOvuzqALRQd4leyYA5EBoxHp o3zQ== X-Gm-Message-State: AKwxytcVJHCOOIpGTqKQtX2AYf4cilQblmhFyQ2O9x3H2fg7NorSU2mH URtShExifBLt4SUzvOdQnhVlrw9KZd0= X-Received: by 10.80.144.53 with SMTP id b50mr33564876eda.265.1516969155455; Fri, 26 Jan 2018 04:19:15 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id o26sm2217427edi.18.2018.01.26.04.19.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 04:19:14 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com Date: Fri, 26 Jan 2018 12:19:11 +0000 Message-Id: <1516969153-19053-1-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: fabio.estevam@nxp.com Subject: [U-Boot] [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(+)