From patchwork Mon May 20 12:14:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164627 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp238884ili; Mon, 20 May 2019 05:42:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzACKbC5+BvMHO7Ni03EMuIljhxygJwW9SEtMMnhtJ+vTZ1lLjkzhN9SiIsF4ux6SkC+GNV X-Received: by 2002:a62:e217:: with SMTP id a23mr35333567pfi.128.1558356129374; Mon, 20 May 2019 05:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356129; cv=none; d=google.com; s=arc-20160816; b=dncygAuwxADWmy8/nwRUtdgYwyQmFHJWBPKp1oZ7O1tP3PQ8twwwMKHMRc/FjEfio8 fcIZl2dvggFsrPxAulXzyf3yqLIj/LdqIZfPxB37Xt166ylnME8n9BIqGmrkBagveWMU W075rGuCCdja+W4NgC2riRgaYbTSLWrgueLRiaSWwWwISVVLCXXN5Sx2UaLNm5TMW7ym 2KOnycvDJfLLPkM5hXqb+xM2jVxvnuHaf7c9Aax8Z7dYaINd8a2rO3+9JrBoGz2VHDpy uUOvJ+hf7/e/+MJNqH4eQN1aGkH6p6BGRssuhvgMIb1KVmn5Z3pwF8AbppZ0ESKIaAnq Fhcg== 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=HRXfyWtwSjgis4dTsWFnC5+OhH15LWHNb5Qgkec+X/jfDck5DwNLxZwr8xQNVDbTLB UGAcBVQ+eOOPGexZ5QNOBr7Md6BhFPsDxePA5HmB7iGnYpY67fH7ni1FdHGcjwD7IJWh WqoXLYCwgseei4V/ZWPHls0Ywov5HWQKg6Tp3Psf9WhvYGAx7I8cPXKUnVGr0xMDUyjd 1zJ7Erueq2czNwI/0cUzzOMHy6GH2Ti6qh4WlurtiUs1snSlhWfVE7ZC9P5Gi04LSywm bL1k4mXnLL/LgPekfAgN3OxULqjjtizUZrCV/cqMNpJDNhkpT1FJsxMG1lwtp0APrce4 RfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=orcuSauu; 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 e11si12396932pgv.569.2019.05.20.05.42.05; Mon, 20 May 2019 05:42:09 -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=orcuSauu; 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 S2391385AbfETMjb (ORCPT + 30 others); Mon, 20 May 2019 08:39:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:51140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390464AbfETMd5 (ORCPT ); Mon, 20 May 2019 08:33:57 -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 6EC1A21479; Mon, 20 May 2019 12:33:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355636; bh=UH6JkK6X0kuRS9HGzftnJ0yrDm0rxbG8gjI3mS3bbjs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=orcuSauuii3WoxygER1rmdg9cUHpBE7G28LruDxZ0GE6kWmQL5gh7vJNS0ZOLCvW5 Bp86g67OWqfbdS8rG4uSQC8o/VDfIXa3BsyeW+jeQqQpuyC2SdlM+NKDOC37Im+kIv YToGMKv2HWPZtoW5qc5UAyCTtLxy/xuwC0tW/6/c= 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 5.1 067/128] crypto: ccree - add function to handle cryptocell tee fips error Date: Mon, 20 May 2019 14:14:14 +0200 Message-Id: <20190520115254.337524887@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115249.449077487@linuxfoundation.org> References: <20190520115249.449077487@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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 */