Received: by 10.223.176.5 with SMTP id f5csp2265429wra; Mon, 5 Feb 2018 00:47:49 -0800 (PST) X-Google-Smtp-Source: AH8x224fdh2N4hi9qMtQcAHujNv3IFIWvd1ZLSHfcwYGnzsZHe9RRqedYJ2XLLoUcN5bCD6B4+2s X-Received: by 10.99.158.65 with SMTP id r1mr9957021pgo.373.1517820469273; Mon, 05 Feb 2018 00:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517820469; cv=none; d=google.com; s=arc-20160816; b=YdmQx67PgE4Ae7I4KRsJD/SRr5zq65K6GTBGwkW1I5lps/o2f0IslO3sdYj+WALVzJ K0VFykOlEknuN0xEc0j5OuGLZKO9DPxbP8jlUF2eY8FteTICW9REuLUIexACBGQZFv1c z6B5qnEv3LT5qzNI+TncDVmuL/8R5kt+Qo+PthXO3KU9jLuU6ec0e5nYyPAyFmG0+7CD c3sohw9Sv1PHDX0+lJyu1EHSk4mDluRnOJK6Aj4dU185fSrY5YtWVlqOeUzm2BgaMh73 zy/Y0bCx5Sdv/JYuItad5aYG+Xr4palv/38QrJ9VQURPp2WwNyy4zTInjDbSllk9Fp0c ol3w== 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=v2WDu82XlOY8us3QZ65/66wfTlNnUeeB0fpGwt9FtVI=; b=GaSk+rbadMklWvxCJxkeu+HH7VKKVSg+Hr8qZYiZPqvryxRnk3A03jVZTQlQQjBWu0 pnv2FxHMdJIjpd+H/F89obb2eEqTZRyOlE4WGjqEFaPxQ+u96YmH7qbiZNIcbkUQVanO tB4xtR7TBJ0rS9dq6ciB+ojNXIBrlfjd2pn5yQ4BIKVFSy8YIuzrnanaHEif7pKHz18P z9xuHf9y1JB7n77YBUPHw3QZjsyk1NGQdFMpHlDRO2wewBUOVxJVVrDgUfGZZF5GrdvB 56jRl+qJUX3+Rq0p5LAvZl4QPBQvWMwyobM1AVtqI98E7BOJ+CV+rnDl/0paKKPqQCrd b65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=E2xXlZwY; 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 bc10-v6si4571462plb.190.2018.02.05.00.47.34; Mon, 05 Feb 2018 00:47:49 -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=E2xXlZwY; 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 S1752583AbeBEIqM (ORCPT + 99 others); Mon, 5 Feb 2018 03:46:12 -0500 Received: from mail-ve1eur01on0051.outbound.protection.outlook.com ([104.47.1.51]:61547 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752195AbeBEIqE (ORCPT ); Mon, 5 Feb 2018 03:46:04 -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=v2WDu82XlOY8us3QZ65/66wfTlNnUeeB0fpGwt9FtVI=; b=E2xXlZwYbFHJE/aB12szuiFi7gROykxEwuuDf6zfrmZXUd4OZt8X+C3KY5Ks7dJ5o7+knwG/tXfHor5jZ85EyHl74iug4AVjmknyCh0eMHIjztzXThsk7nGn1lqzKE+8eH1FHKyzqeqkPqqcz9dZKUnHxYtcPzd26grhH3Q1VHY= Received: from VI1PR0402MB3342.eurprd04.prod.outlook.com (52.134.8.142) by VI1PR0402MB3534.eurprd04.prod.outlook.com (52.134.4.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Mon, 5 Feb 2018 08:46:01 +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.0444.022; Mon, 5 Feb 2018 08:45:59 +0000 From: =?iso-8859-2?Q?Horia_Geant=E3?= To: "Auer, Lukas" , "linux-kernel@vger.kernel.org" , Aymen Sghaier , "pure.logic@nexus-software.ie" , "linux-crypto@vger.kernel.org" CC: Peng Fan , "davem@davemloft.net" , "ryan.harkin@linaro.org" , Fabio Estevam , "rui.silva@linaro.org" , "herbert@gondor.apana.org.au" Subject: Re: [PATCH v3 2/5] crypto: caam: Fix endless loop when RNG is already initialized Thread-Topic: [PATCH v3 2/5] crypto: caam: Fix endless loop when RNG is already initialized Thread-Index: AQHTmjdOwMiIynBKwEGhPiBJHBZpZw== Date: Mon, 5 Feb 2018 08:45:59 +0000 Message-ID: References: <1517364040-27607-1-git-send-email-pure.logic@nexus-software.ie> <1517364040-27607-3-git-send-email-pure.logic@nexus-software.ie> <78ad6a62-190c-e4fe-dd23-e1d058f9bbb2@nexus-software.ie> <1517576063.2002.19.camel@aisec.fraunhofer.de> 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;VI1PR0402MB3534;7:OB5AzkmhJxX+gR69h/15pbBPiJoTmEPld4rSCAHpyyMykRwoL3D0rjVpObLoezrpGuQkX8wXZ7VmEWgt+fbrJJxakiQ39TQz3+9P82nofsTVRrqrwRDyqOJmeXUzZhOAeAz8lxFRwQYy8CWnwaTicBQquN/FaAkV/SQAHbaAFDa87GF2ve6AwYIyPovfQzTX3qYHCVGrBtc6wBRZMRdhb+42KNhMJ7DmnzWRm8QY/v4N9ovWzXw95T0kqJba9vFH x-ms-exchange-antispam-srfa-diagnostics: SSOS;SSOR; x-forefront-antispam-report: SFV:SKI;SCL:-1;SFV:NSPM;SFS:(10009020)(346002)(376002)(396003)(39380400002)(39860400002)(366004)(377424004)(189003)(199004)(966005)(5660300001)(14454004)(6506007)(53546011)(66066001)(26005)(102836004)(55016002)(9686003)(6306002)(99286004)(106356001)(110136005)(2906002)(54906003)(186003)(478600001)(7696005)(6246003)(76176011)(3280700002)(53936002)(6436002)(3660700001)(2201001)(25786009)(81166006)(81156014)(8676002)(8936002)(575784001)(59450400001)(5250100002)(2501003)(86362001)(316002)(4326008)(97736004)(6116002)(229853002)(3846002)(105586002)(305945005)(74316002)(2900100001)(33656002)(7736002)(68736007)(93886005);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB3534;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: 62e465dc-b8aa-4694-8d59-08d56c74e14f x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020);SRVR:VI1PR0402MB3534; x-ms-traffictypediagnostic: VI1PR0402MB3534: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(3231101)(2400082)(944501161)(3002001)(93006095)(93001095)(6055026)(6041288)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:VI1PR0402MB3534;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0402MB3534; x-forefront-prvs: 0574D4712B received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: rL8S72nzA7b9/jljGoZb46Tc2DtM05mG7i7EdzotV9tnJyFY0lxLcNAOAZkifoU04hlQmONkbw27nFHmrW6Jyg== 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: 62e465dc-b8aa-4694-8d59-08d56c74e14f X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Feb 2018 08:45:59.3480 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3534 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/2/2018 2:54 PM, Auer, Lukas wrote:=0A= > On Fri, 2018-02-02 at 11:20 +0000, Bryan O'Donoghue wrote:=0A= >> On 01/02/18 12:16, Horia Geant=E3 wrote:=0A= >>> If the loop cannot exit based on value of "ret" !=3D -EAGAIN, then it= =0A= >>> means=0A= >>> caam_probe() will eventually fail due to ret =3D=3D -EAGAIN:=0A= >>> if (ret) {=0A= >>> dev_err(dev, "failed to instantiate RNG");=0A= >>> goto caam_remove;=0A= >>> }=0A= >>=0A= >> For me it's an endless loop applying the first two=0A= >>=0A= >> https://patchwork.ozlabs.org/patch/866460/=0A= >> https://patchwork.ozlabs.org/patch/866462/=0A= >>=0A= >> but not this one=0A= >>=0A= >> https://patchwork.ozlabs.org/patch/865890/=0A= >>=0A= [snip]=0A= > =0A= > I think the problem lies in the instantiate_rng() function. If the=0A= > driver is unable to acquire DEC0 it'll return -ENODEV. This should=0A= > terminate the while loop in the probe function. However, the return=0A= > value is never checked and is instead overwritten with -EAGAIN, causing= =0A= > the endless loop.=0A= > =0A= > This problem only occurs if u-boot instantiates only one of the state=0A= > handles (ent_delay doesn't get incremented) and the kernel runs in non-= =0A= > secure mode (DEC0 can't get acquired). Instantiating all state handles=0A= > in u-boot therefore fixes this problem. In addition, the return value=0A= > in instantiate_rng() should be handled correctly by including=0A= > =0A= > if (ret)=0A= > break;=0A= > =0A= > right after "ret =3D run_descriptor_deco0(ctrldev, desc, &status);".=0A= > =0A= Indeed, the error path is incorrect and should be fixed as you mentioned.= =0A= I will send a patch replacing this one.=0A= Note that this fixes only the error path, meaning caam_probe() won't go int= o an=0A= endless loop and instead will return -ENODEV, due to being unable to acquir= e=0A= control of DECO0.=0A= =0A= There are still a few hurdles to cross for CAAM to work in a TZ environment= .=0A= =0A= For e.g. could you please check / confirm whether DECO0MIDR (DECO0 MID regi= sters=0A= @0xA0, @0xA4) are set such that Linux kernel is allowed to r/w DECO0-relate= d=0A= registers?=0A= =0A= Thanks,=0A= Horia=0A=