From patchwork Fri Jan 26 16:27:13 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: 125998 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp451114ljd; Fri, 26 Jan 2018 08:27:26 -0800 (PST) X-Google-Smtp-Source: AH8x226AG2Zm4VZ10WiLIFVyFXljv9A0CS4KhLBx5M22hwfpeW9KouPlpYH87MIRBv8WBNPxFeIf X-Received: by 10.80.135.8 with SMTP id i8mr34148507edb.233.1516984046130; Fri, 26 Jan 2018 08:27:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516984046; cv=none; d=google.com; s=arc-20160816; b=Gg8iaJuqvX8/8AMYVHfaUpG50w3nJI9OVAWfXEc1yqNTdJbWUck4ujfEGFL6NZVWjF olUnMkDgcvisuga9KKSMEHmHQlX/ohG52E3ZeFSc/wKkV6EBX3Bulc0c6k846ItiZMzE HWHzsIfciKjnL1eRr/nX1Mph36W3KqDc5bC/2mFAmAjmjzm9U/K/3o8F2p26ToOqjtVn OLkqXjpqPi+u7L4QgBrvzJCwZjqC5/GQNMX+vlDx1V+0oIyFZbxL39TgO+UCLTBSWbCb paeJd7SvYgt9k6SBjcFWX0lmO5fguQZjoyMxUiIkT4x3zkWsgUv2VfOJZ+FF5QhZoV7u NPIw== 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=jX6OaB0x8M1kPUy/p5djnTKm8mQ1Ex5y4wXI7AQUJ1I=; b=Ws9l/gw04Mud/cAmfzzRxfBi2zmcVk/sYchfi9/889XsPLpFjOYB37fQ7m55aqYI07 rSxY8gEwdBFwu2WN2BmrbHxgh4P+xWfHSWHl6xFziNwabVehMr0GhnpReW6MzodJjvkg 2iR5Mh/DszwtGqFWUygL+oCV0Sbm4yKRvTp84uE1/oFMCoKqJz9NDppQxRjJsWySkOtD koU3ucxLTZkaWsGyf2p61WBw1/1GxGLG5pbJZZU4EbcLvb/mk/ANzQ064RXpw0ShaYo/ 5SWv1TqljQN426lmM9I5gTCUcL3wwC/DqQfMvc1KOp+5z1sXOZ8kmiCN0CQLjJkEFOgb +xyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bJmbLbkC; 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 c44si2061732ede.367.2018.01.26.08.27.25; Fri, 26 Jan 2018 08:27:26 -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=bJmbLbkC; 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 9CFF2C22397; Fri, 26 Jan 2018 16:27:21 +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 EF925C21F4E; Fri, 26 Jan 2018 16:27:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 34C51C21D9F; Fri, 26 Jan 2018 16:27:18 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id CA846C21C4F for ; Fri, 26 Jan 2018 16:27:17 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id g1so2374456wmg.2 for ; Fri, 26 Jan 2018 08:27:17 -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=/WAWzv5KKPECnj4QTVepkuyu2648WObaxgsdMdTVi+0=; b=bJmbLbkCrfRdboijkO1NYUNQi+UzPcznNRJCHP7PI19TOve4ivmd55DtbchQo5PXtJ 5ifNxxIgyjGBGQjUep/N9ywzTJfknQvIJPYLrgFRwomD8wtMGKsc/YthtiN7oI2dL18M qHT/fhQxSHUy9poOfTkWnqqjBoqlyNZscQuX0= 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=/WAWzv5KKPECnj4QTVepkuyu2648WObaxgsdMdTVi+0=; b=TMP+jUnzcdvSbQ2CW7bb8CKMeXgJ1L29dOxTfzggLbi3clmBR6OHwUJt5bvOGwwAEs +y/Fp1tgLLeGqFEevk/S25u19gzz9tEtYYNbRs2GnZEZA33Jr5LJUmfIsCWY9vwgv4th K7CsPRn7qJfmyeDAlAdwAZWmbyATGfsz0yWqTfmoPhGQ59HrLHoIW2MN1gAej4OuWalL bWPaN/pEKyde3kBYk05AA+KUFKQDkhl4kHhHGSya3P96dTWWnjOBxra2cu6o4MHvIKD2 7VzN5SwPxe1W/fTGIlgr0QZUnksTPOmCAVt0Y+i6+Bv37YXWfUnbQd5Jh2+sK9QXTyPb wzdQ== X-Gm-Message-State: AKwxytdUwfILfhk7PtVzD2GMHXs+JcwJk1kvZQy5xfDxfbNN+SRtkHnV wAuwM307rMWQvIuDqqOtfWXjcWgFjOM= X-Received: by 10.80.204.133 with SMTP id q5mr4651770edi.112.1516984037201; Fri, 26 Jan 2018 08:27:17 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id s5sm2758137eda.60.2018.01.26.08.27.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 Jan 2018 08:27:16 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com Date: Fri, 26 Jan 2018 16:27:13 +0000 Message-Id: <1516984035-20929-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 v4 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" V4: - Fix dim-witted omission of #include to remove warning 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 | 5 +++++ drivers/crypto/fsl/jr.c | 9 +++++++++ drivers/crypto/fsl/jr.h | 2 ++ 3 files changed, 16 insertions(+)