Received: by 10.223.176.46 with SMTP id f43csp2438504wra; Thu, 25 Jan 2018 09:51:16 -0800 (PST) X-Google-Smtp-Source: AH8x2274LtiErH1jZdDlbJ2VNGyhdX73ysNlSypTWnsmdxdIp2ExOmsJS7aIsW9KS/IS61Eu5D2Y X-Received: by 10.98.70.194 with SMTP id o63mr16902217pfi.58.1516902676770; Thu, 25 Jan 2018 09:51:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516902676; cv=none; d=google.com; s=arc-20160816; b=N+rsTIyrPG3HIZap6e0BD5TZsFa2+MFcQ4ljwH4YCMckE84jkuuz4BDNPUEgUbu0yl lx3dHMh9QTimiuTWEf3a3RFcy3r7M4QAWKRfQe5wkVykFmXyCvwCFLv57YDERTF1fpV/ k0fad8OM+6N/4QBOilyhOeZDIAPKBXRnhajE1SoOzB/Meb/zo6msYH8Dam5uf9duIrzW rGwkefL4DRs1y8dy4loBoPgEynnZVicMDvDLzoE0DjO1oV6R68QPYU10KkuEQJd+5e6s +/2Ruh9ff662HHyCSrOT0cFcK2nVbOzwm80eq2xykwdPxByIMclTqR6CAEehDogC7N8y SFoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=idIaZzQc5KbSi9RAvQ3fUzKJtj/FI2ntjBeZfxh5FPg=; b=iZnag9iVbiFYIdhahbx0QyVXgx9lt1OXzQUjU4o5YfoxGVQ9eiAvL658Qte1ADAm5P qyAePc7/tMo+VxHhIMSP9c1X38Hk9DLZD7Er108u2dg6Kd/G/dFZPxPNEqQvMpPDA/nh vx49wZwU77gZ+tVK37OgXQZruyyhIR9kWRAsinypi72NZhk4cwsS2jS90zu7JBfBTuU7 kxTdA+as4sQD3vyETPJZf/aHUjEawqi3veh/khJYiLkrREZiDgPx7rZFvC6a/Q+ce8Mp e0MKcZ1TB3TSW+1w6Q62SVXKJPTzklHVLpZR1OQpVg0twE4o9KgCzO/jP15pgewDa+Ko Fkaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=p2bRh9g3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 62-v6si2297552pld.136.2018.01.25.09.51.01; Thu, 25 Jan 2018 09:51:16 -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=@nxp.com header.s=selector1 header.b=p2bRh9g3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751218AbeAYRuh (ORCPT + 99 others); Thu, 25 Jan 2018 12:50:37 -0500 Received: from mail-he1eur01on0087.outbound.protection.outlook.com ([104.47.0.87]:29728 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751105AbeAYRug (ORCPT ); Thu, 25 Jan 2018 12:50:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=idIaZzQc5KbSi9RAvQ3fUzKJtj/FI2ntjBeZfxh5FPg=; b=p2bRh9g3uQC5kcU/7Obbu0nwLDh3WUyM/BOEVUNA0aQuCQ6snSLRD/IHl/q39ZhVT84CQJPe2/7uBB5wCvT9nVtOPCQYHRWIBLu8nA+4hqEPFcIDPB0SUdpXiSCaIQU3mAdq3OLS/1CGgxZz20KMa4eZDzXg2QCj6dFGWQbkZw8= Received: from VI1PR0402MB3342.eurprd04.prod.outlook.com (52.134.8.142) by VI1PR0401MB2639.eurprd04.prod.outlook.com (10.168.66.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 25 Jan 2018 17:50:32 +0000 Received: from VI1PR0402MB3342.eurprd04.prod.outlook.com ([fe80::3507:8836:aae3:375e]) by VI1PR0402MB3342.eurprd04.prod.outlook.com ([fe80::3507:8836:aae3:375e%13]) with mapi id 15.20.0428.024; Thu, 25 Jan 2018 17:50:31 +0000 From: =?iso-8859-2?Q?Horia_Geant=E3?= To: Bryan O'Donoghue , Aymen Sghaier , "linux-crypto@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Fabio Estevam , Peng Fan , "herbert@gondor.apana.org.au" , "davem@davemloft.net" , "lukas.auer@aisec.fraunhofer.de" , "rui.silva@linaro.org" , "ryan.harkin@linaro.org" Subject: Re: [RESEND PATCH 0/6] Enable CAAM on i.MX7s fix TrustZone issues Thread-Topic: [RESEND PATCH 0/6] Enable CAAM on i.MX7s fix TrustZone issues Thread-Index: AQHTlSK1t6AdBm+Ipk2quX4Kj1dXCQ== Date: Thu, 25 Jan 2018 17:50:31 +0000 Message-ID: References: <1516805435-15034-1-git-send-email-pure.logic@nexus-software.ie> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=horia.geanta@nxp.com; x-originating-ip: [86.34.165.90] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0401MB2639;7:wEdu5Q3HQK2bQuHsoSJi1OviC03A5bmtc61dkDxlJX9AOX+CGMTNNjeG56of2Y7+BkWtgHZGG8/oLfA1vLC25ceEEsOHfCHEphm8fd/o3edTrmXGIPXjFn2VGOqtpPKvCEObW0RmmtjGW50L+A6PyAMLjp2GANy9nVGgtUFy4b8qjy+gNjtFawIVlkX+aYqwTaJTTPnrvzRyFcwmoVCYrXAfn6Ye9LroGAPaIweQO4Fdl1/txrOZQvwroHCBPA6H x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(979002)(39380400002)(396003)(366004)(39860400002)(346002)(376002)(189003)(199004)(66066001)(25786009)(305945005)(110136005)(966005)(74316002)(54906003)(33656002)(316002)(478600001)(14454004)(4326008)(3660700001)(3280700002)(7736002)(6246003)(2900100001)(8676002)(81156014)(81166006)(8936002)(6436002)(26005)(3846002)(76176011)(6116002)(59450400001)(9686003)(105586002)(6306002)(229853002)(6506007)(53546011)(5660300001)(99286004)(2501003)(106356001)(97736004)(86362001)(7696005)(68736007)(5250100002)(2201001)(53936002)(2906002)(55016002)(102836004)(186003)(217873001)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0401MB2639;H:VI1PR0402MB3342.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: fbccd799-a677-456e-b9ad-08d5641c210a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020);SRVR:VI1PR0401MB2639; x-ms-traffictypediagnostic: VI1PR0401MB2639: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(171593684265217)(166708455590820); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(5005006)(8121501046)(2017080701011)(3002001)(10201501046)(93006095)(93001095)(3231023)(2400081)(944501161)(6055026)(6041288)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:VI1PR0401MB2639;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0401MB2639; x-forefront-prvs: 0563F2E8B7 received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: eklfKVcxTTRs2E+oEri2yHAq/1QqsEh3scqJJhRYVrbqGckZQ/jLyrcO08BPEcTCDPOvsjXV13X/6TKb4j+QrA== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbccd799-a677-456e-b9ad-08d5641c210a X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jan 2018 17:50:31.8068 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2639 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/24/2018 4:50 PM, Bryan O'Donoghue wrote:=0A= > This patch-set enables CAAM on the i.MX7s and fixes a number of issues=0A= > identified with the CAAM driver and hardware when TrustZone mode is=0A= > enabled.=0A= > =0A= > The first block of patches are simple bug-fixes, followed by a second blo= ck=0A= > of patches which are simple enabling patches for the i.MX7Solo - note we= =0A= > aren't enabling for the i.MX7Dual since we don't have hardware to test th= at=0A= > out but it should be a 1:1 mapping for others to enable when appropriate.= =0A= > =0A= > The final block in this series implements a fix for using the CAAM when= =0A= > OPTEE/TrustZone is enabled. The various details are logged in these=0A= > threads.=0A= > =0A= > Link: https://github.com/OP-TEE/optee_os/issues/1408=0A= > Link: https://tinyurl.com/yam5gv9a=0A= > Link: https://patchwork.ozlabs.org/cover/865042=0A= > =0A= > In simple terms, when TrustZone is active the first page of the CAAM=0A= > becomes inaccessible to Linux as it has a special 'TZ bit' associated wit= h=0A= > it that software cannot toggle or even view AFAIK.=0A= If the first ("global") caam register page is not accessible, RNG init is n= ot=0A= the only problem. For e.g. device endianness detection won't work. A comple= te=0A= list could be generated by auditing all places where this page is r/w.=0A= =0A= IMHO the correct direction for solving such cases (i.e. Linux kernel is pro= vided=0A= only with access to a few job rings) is to split the driver in two independ= ent=0A= ones - controller driver and job ring driver - and have corresponding DT no= des=0A= for them. Controller DT node and one or more of the job ring DT nodes would= be=0A= deleted by the boot loader / trusted firmware if needed.=0A= Of course, the job ring DT node might need additional properties for the dr= iver=0A= to work.=0A= =0A= Thanks,=0A= Horia=0A= =0A= > =0A= > The patches here then=0A= > =0A= > 1. Detect when TrustZone is active=0A= > 2. Detect if u-boot (or OPTEE) has already initialized the RNG=0A= > =0A= > and loads the CAAM driver in a different way - skipping over the RNG=0A= > initialization that Linux now no-longer has permissions to carry out.=0A= > =0A= > Should #1 be true but #2 not be true, driver loading stops (and Rui's pat= ch=0A= > for the NULL pointer dereference fixes a cash on this path). If #2 is tru= e=0A= > but #1 is not then it's a NOP as Linux has full permission to rewrite the= =0A= > deco registers in the first page of CAAM registers.=0A= > =0A= > Finally then if #1 and #2 are true, the fixes here allow the CAAM to come= =0A= > up and for the RNG to be useable again.=0A= > =0A= > Bryan O'Donoghue (3):=0A= > crypto: caam: Fix endless loop when RNG is already initialized=0A= > crypto: caam: add logic to detect when running under TrustZone=0A= > crypto: caam: detect RNG init when TrustZone is active=0A= > =0A= > Rui Miguel Silva (3):=0A= > crypto: caam: Fix null dereference at error path=0A= > ARM: dts: imx7s: add CAAM device node=0A= > imx7d: add CAAM clocks=0A= > =0A= > arch/arm/boot/dts/imx7s.dtsi | 26 +++++++++++++++++++=0A= > drivers/clk/imx/clk-imx7d.c | 3 +++=0A= > drivers/crypto/caam/ctrl.c | 45 +++++++++++++++++++++++++++= +++---=0A= > drivers/crypto/caam/intern.h | 1 +=0A= > include/dt-bindings/clock/imx7d-clock.h | 5 +++-=0A= > 5 files changed, 76 insertions(+), 4 deletions(-)=0A= > =0A=