Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp105808yba; Mon, 20 May 2019 05:49:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwF52xJYipl/iCWE6G7yuESd/xzNbhnqyT6HHSVb+GUQl6mjrxZDIRB+/muayusoClmooSr X-Received: by 2002:a65:48ca:: with SMTP id o10mr75452131pgs.136.1558356542807; Mon, 20 May 2019 05:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356542; cv=none; d=google.com; s=arc-20160816; b=BrmAqNjZ9Yb8tZUgi9o3VOtIVryXflquZemj/dYnf0BdRPznj7k8cGV6NppjbVoCet bG5ZjRnSvE+4JzmXieG/J7gP4MkuGRrbpqLeLVNtk+CRKpiszACxzhZxo/7xpCJ/MQoa 6V0CQlxgQjhpC1vNMKy8QHcoMbFI6q0ULS5y2zUIYO/SYi97ABJl9WxfyovhAyWpPSMD brirb29A3wOQS4SoRzOCcwEtjlY5QxoCSCktB689Qn/ytNrzeEUHequEdB0uDBDcVPxR IlQj4v6XUZFip1Vyxj/Gj0De7fuodxPHn4kk3qKqvLgrbF1Wb+nFsqUMaP1eSZ9QsPeH IxuQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qqwj2dkUx+ur/a/tog/DfPiMH4JjlCcX+Gpm0wKqRvM=; b=RihyJZT9oFgeEilI/wPsVHrggtZ2u5WBYLCLvugDlSQPK29VAE0CdLP8rW3vY3rBPz vxNGpHRqJ/59uUQqLlkazkUGnGMR1LhGIhRTUfHFA7XOWTEP0qOnlol0GeXj7OkOmee/ cDU6QTXO4nZWtqIxK+ICERv4m2EDk1fc0Ft1l3K1gkomr00I5AuUhPI9N0sPzitMjcux wmKAF58yq15QXs73OjE4JnP6bkeX8Y79kDZLO2fxKIl1OMVzLeQVZQVNBSRZnYWR+WS2 Z1PbbzIOllKfFdU0uzUVZqW+jYONGomd8TsZNCY3znVW5KVMvSwuPwOoGNwEE9rcxslZ poiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kRF777DN; 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 d6si19113143pln.144.2019.05.20.05.48.48; Mon, 20 May 2019 05:49:02 -0700 (PDT) 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=@kernel.org header.s=default header.b=kRF777DN; 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 S2388924AbfETMYu (ORCPT + 99 others); Mon, 20 May 2019 08:24:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:39722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388502AbfETMYs (ORCPT ); Mon, 20 May 2019 08:24:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C53C7216C4; Mon, 20 May 2019 12:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355087; bh=UH6JkK6X0kuRS9HGzftnJ0yrDm0rxbG8gjI3mS3bbjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRF777DNElJg7KO5OaB+sleO4Fzh31Tx172DoN15rw+Ef8ohceM5WYMZgOMjqMY73 qZBQeb1PfJn9SYsPYJdBRRE0ryBa1DWpMRodG+r3uPelOr5qkHEQ2sM1U/PDXCxljp EOJDqoB+g+8yhpufRIVQ1YlUYZl243nKNlWrvEwg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Drang , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 4.19 051/105] crypto: ccree - add function to handle cryptocell tee fips error Date: Mon, 20 May 2019 14:13:57 +0200 Message-Id: <20190520115250.578164349@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115247.060821231@linuxfoundation.org> References: <20190520115247.060821231@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Ofir Drang commit 897ab2316910a66bb048f1c9cefa25e6a592dcd7 upstream. Adds function that checks if cryptocell tee fips error occurred and in such case triggers system error through kernel panic. Change fips function to use this new routine. Signed-off-by: Ofir Drang Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_fips.c | 23 +++++++++++++++-------- drivers/crypto/ccree/cc_fips.h | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) --- a/drivers/crypto/ccree/cc_fips.c +++ b/drivers/crypto/ccree/cc_fips.c @@ -72,20 +72,28 @@ static inline void tee_fips_error(struct dev_err(dev, "TEE reported error!\n"); } +/* + * This function check if cryptocell tee fips error occurred + * and in such case triggers system error + */ +void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata) +{ + struct device *dev = drvdata_to_dev(p_drvdata); + + if (!cc_get_tee_fips_status(p_drvdata)) + tee_fips_error(dev); +} + /* Deferred service handler, run as interrupt-fired tasklet */ static void fips_dsr(unsigned long devarg) { struct cc_drvdata *drvdata = (struct cc_drvdata *)devarg; - struct device *dev = drvdata_to_dev(drvdata); - u32 irq, state, val; + u32 irq, val; irq = (drvdata->irq & (CC_GPR0_IRQ_MASK)); if (irq) { - state = cc_ioread(drvdata, CC_REG(GPR_HOST)); - - if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK)) - tee_fips_error(dev); + cc_tee_handle_fips_error(drvdata); } /* after verifing that there is nothing to do, @@ -113,8 +121,7 @@ int cc_fips_init(struct cc_drvdata *p_dr dev_dbg(dev, "Initializing fips tasklet\n"); tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata); - if (!cc_get_tee_fips_status(p_drvdata)) - tee_fips_error(dev); + cc_tee_handle_fips_error(p_drvdata); return 0; } --- a/drivers/crypto/ccree/cc_fips.h +++ b/drivers/crypto/ccree/cc_fips.h @@ -18,6 +18,7 @@ int cc_fips_init(struct cc_drvdata *p_dr void cc_fips_fini(struct cc_drvdata *drvdata); void fips_handler(struct cc_drvdata *drvdata); void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok); +void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata); #else /* CONFIG_CRYPTO_FIPS */ @@ -30,6 +31,7 @@ static inline void cc_fips_fini(struct c static inline void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok) {} static inline void fips_handler(struct cc_drvdata *drvdata) {} +static inline void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata) {} #endif /* CONFIG_CRYPTO_FIPS */