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: 866459 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="bJmbLbkC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zSkp730f2z9s0g for ; Sat, 27 Jan 2018 03:27:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8F08FC22391; 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-Google-Smtp-Source: AH8x225ot79FIX6X2/6W0KKGWVgcJ0aeB5+RpLxSXPpsIE7rRUfwf1X663x3byxcJ9qIvsmzJbA71A== 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(+)