Received: by 10.223.176.46 with SMTP id f43csp828682wra; Wed, 24 Jan 2018 06:35:46 -0800 (PST) X-Google-Smtp-Source: AH8x226oAolXSuVMFhhXIn8SUZxNZoP2xsfIq6ZAXVhLeRZOg0Y6uxN3XyRBP9cI87XW/eQIVieW X-Received: by 2002:a17:902:b212:: with SMTP id t18-v6mr7937681plr.293.1516804546414; Wed, 24 Jan 2018 06:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516804546; cv=none; d=google.com; s=arc-20160816; b=e9H1g0L+FU60fa/DK2Yb4UkuPm8fj23kGljfCndwiQxdcztT6tWkbR8p7EAVuEh28U vJphmTC2v4AhbYlwHliwKnEd6R4RfddvK4W22/igIIPNS6klELXQDHaqP6/9qx7HCR+Q Jr014u5VaHkPpVkgHZzjbV69GtncO4Kka1E2pb2QWCDB91fEVAVdJXhspr+MdsCLXg6T tNbynPabBYhrVDtY2Lf6N0uZn5J4lOM3cIn9+/qayW75xU+PYD6ugHu6dhF5DHKaaJ9G Cd16Jt/dfHVPdWwyyZTdHvvX2gux0B66BV8oyzl8+ubd8Vg8HqOWq+msEfn7GVP2M+de EcEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=tKfkETPWI4oruvfXV15+O8aSfIxsbLOxb4HjudiV84w=; b=RosX3tnTP0TDMn7tQXGXBnjKMowtLlp3Jic5vJJqfORuu3CaUDzyykMXjAn5OIe5wD utB1SVR7SrYuzUSj77ltfWD2uOV7UBI9fAPhwgdf5uNkfu7evcxdY9RS4so1z9XvTZHI lfsbjRXUr2575Fd8ATrwVnouO0YntMpG0r3EIzIcvrUT5ijFJI26GWwuMxC7fJIoa1cj BFLy8wZ0ZDt/Cv9IrDsUn1Yqax1xMhodqas72uFF9UtrWRBVsweZV3bbUFYrCek+YMx9 v1ftnK/fBJ/ubB0TjCJSXS942sP8htRFca7FurwmnQZsWDNEWePUFdWDveyVWpFSbT0b X1KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=PCr06j8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n80si2952816pfi.380.2018.01.24.06.35.32; Wed, 24 Jan 2018 06:35:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=PCr06j8E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933939AbeAXOfF (ORCPT + 99 others); Wed, 24 Jan 2018 09:35:05 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:41746 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933723AbeAXOfD (ORCPT ); Wed, 24 Jan 2018 09:35:03 -0500 Received: by mail-wm0-f67.google.com with SMTP id f71so8869323wmf.0 for ; Wed, 24 Jan 2018 06:35:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tKfkETPWI4oruvfXV15+O8aSfIxsbLOxb4HjudiV84w=; b=PCr06j8ERa5ie1V/hS6S/gyvcACeSD0JjQomrf+hrElmuwVn39kr5vIiJCOa1FxMPH JeSxi5Vb8jLEUMCkXvrVmQvxYHYV6d3sC+Q5imhIjOYfexXc7WVM4g2UyKzGNBClN3zV TsN5nwufF0hlsA7Q3xQdGlheAjEui03DfmidHY8N6n8Rdlaky3TQkehGRX80UJIWcODt k+lPpbpLjae843H3EDwIBKxOSNFxt3/KOnIzCD7qP5u9FRIvzLBLYSMymox0NEAqinz2 xJWgnrZsxE9hEJHcyGyNdMmYi9ZyW4O0TKV4BpJiSArYTppuJtHCYo1hi/jhdZtgCWdZ 0mLg== 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:mime-version :content-transfer-encoding; bh=tKfkETPWI4oruvfXV15+O8aSfIxsbLOxb4HjudiV84w=; b=QZJlhmM5d59glL+cIl1B9/ZX5hHoXZv+9TgxQMUkGB4rXcgQUUdCZLoq47xfVvatxP B2AHLIQp8DxrEUFeyO4TJc+3N/Pm5PoKu+z67eN64gxxS9mqP3I1ZzRxt7QIAprEc81a dzby0SeQZG/uEQdhDiW1dt+/v9kOu2vEDhTCiaeQ1YNX8yumd+vO8LVClXTSRPvjjWl1 xENGcVc1RlNUsue+xd9yEsPemJwurKAXjXZZ3wWsd8X5vIlERiAB/hbWT/EVvMjc54+m er89GAzlpa8zZCEwezq/48+lmv33BOPoZjj0SbGa8+aqC4mSL6rN/Ybfr9mq2UCLiuKs IjFQ== X-Gm-Message-State: AKwxytd0jvhefz4sRenvGkfBR+0UIaPPuMkSaUo1lzNl8qzrkn4S04rx G3tmyspIrAMmHHebgRVU8b2eVw== X-Received: by 10.80.202.193 with SMTP id f1mr25386906edi.30.1516804502275; Wed, 24 Jan 2018 06:35:02 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id k5sm342933ede.51.2018.01.24.06.35.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jan 2018 06:35:01 -0800 (PST) From: Bryan O'Donoghue To: horia.geanta@nxp.com, aymen.sghaier@nxp.com, linux-crypto@vger.kernel.org Cc: fabio.estevam@nxp.com, peng.fan@nxp.com, herbert@gondor.apana.org.au, davem@davemloft.net, lukas.auer@aisec.fraunhofer.de, rui.silva@linaro.org, ryan.harkin@linaro.org, linux-kernel@vger.kernel.org, Bryan O'Donoghue Subject: [PATCH 0/6] Enable CAAM on i.MX7s fix TrustZone issues Date: Wed, 24 Jan 2018 14:34:53 +0000 Message-Id: <1516804499-12663-1-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch-set enables CAAM on the i.MX7s and fixes a number of issues identified with the CAAM driver and hardware when TrustZone mode is enabled. The first block of patches are simple bug-fixes, followed by a second block of patches which are simple enabling patches for the i.MX7Solo - note we aren't enabling for the i.MX7Dual since we don't have hardware to test that out but it should be a 1:1 mapping for others to enable when appropriate. The final block in this series implements a fix for using the CAAM when OPTEE/TrustZone is enabled. The various details are logged in these threads. Link: https://github.com/OP-TEE/optee_os/issues/1408 Link: https://tinyurl.com/yam5gv9a Link: https://patchwork.ozlabs.org/cover/865042 In simple terms, when TrustZone is active the first page of the CAAM becomes inaccessible to Linux as it has a special 'TZ bit' associated with it that software cannot toggle or even view AFAIK. The patches here then 1. Detect when TrustZone is active 2. Detect if u-boot (or OPTEE) has already initialized the RNG and loads the CAAM driver in a different way - skipping over the RNG initialization that Linux now no-longer has permissions to carry out. Should #1 be true but #2 not be true, driver loading stops (and Rui's patch for the NULL pointer dereference fixes a cash on this path). If #2 is true but #1 is not then it's a NOP as Linux has full permission to rewrite the deco registers in the first page of CAAM registers. Finally then if #1 and #2 are true, the fixes here allow the CAAM to come up and for the RNG to be useable again. Bryan O'Donoghue (3): crypto: caam: Fix endless loop when RNG is already initialized crypto: caam: add logic to detect when running under TrustZone crypto: caam: detect RNG init when TrustZone is active Rui Miguel Silva (3): crypto: caam: Fix null dereference at error path ARM: dts: imx7s: add CAAM device node imx7d: add CAAM clocks arch/arm/boot/dts/imx7s.dtsi | 26 +++++++++++++++++++ drivers/clk/imx/clk-imx7d.c | 3 +++ drivers/crypto/caam/ctrl.c | 45 ++++++++++++++++++++++++++++++--- drivers/crypto/caam/intern.h | 1 + include/dt-bindings/clock/imx7d-clock.h | 5 +++- 5 files changed, 76 insertions(+), 4 deletions(-) -- 2.7.4