From patchwork Mon May 20 12:13:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164610 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp220474ili; Mon, 20 May 2019 05:24:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuheiSXNOzJzzbPfSmPXbd1wnOCYyP+mXUkJaAycJbsJUyfQZ2+FQ/zYcxaQZR7bBx1G0q X-Received: by 2002:aa7:8d81:: with SMTP id i1mr52248262pfr.244.1558355090636; Mon, 20 May 2019 05:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355090; cv=none; d=google.com; s=arc-20160816; b=JwX9agx84N0+8DIQM+n/E1X6Hc3copvey169XicCCsyYFRFCcCX5VtZd5WYniMCLb5 xVDstX9jKpS70vw7V+uS4J+nid2mrf7INdKU6tkyOQw1CP5V/JX0FmVJsntNOT5gsi3n dGn1e3HN0FRndaPYeQf/coEZggUANhRuDF7QtR5BLYzjA/nrZDFr/Y69K18YGb/uDImD LKJBwfJVEfvH+++SgLyRK19mXzfqw1rKQPoFIQwKtwLSfIO8GU8kUxWvhqbJrKf8wzrR jZrkggE7huhVRdXCk5E64rc4B7NPZrbCNvTQ8dsYqyzo66JUagE0cTazwkGwSUCXpxR0 qyjg== 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=yacvhFP+zhgzJqFu4xT7vQ3gOVCWJ3lw/u5CqXEfxdWeGle6ICuYGBZx4kn5lI0JbI jz1K3RTgr9u4WA2xgZYzngR51AMU6YcrNI7mUJ9jbEz/KM3ntmSfDKcHD07crgZBh24P arDaXfNLyfR3QSZFawZ6InHE5uI8RNEYdvGjzNZL4VnHkvpwB8m2XR1psEkPd1SeV2zd VPcncmJbpYTC5RbE/vBU9G1t5qCxSL6Rws2FH51qHO4ULK+90s+S4+f80Leiio+v9JZ9 T3hWGUAToCTED4H4bLob6yriKOfff65ELfkMxkpIDqYVcf8M9M54wj79+aSFM0T8Rgpj rXEQ== 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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 z124si18972073pfz.212.2019.05.20.05.24.50; Mon, 20 May 2019 05:24:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388188AbfETMYt (ORCPT + 14 others); Mon, 20 May 2019 08:24:49 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 */