aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOfir Drang <ofir.drang@arm.com>2019-04-18 09:39:09 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2019-04-25 03:38:16 -0400
commit897ab2316910a66bb048f1c9cefa25e6a592dcd7 (patch)
tree7a4c23403082d5cc49fd90e372d687a434f7804c
parent3499efbeed39d114873267683b9e776bcb34b058 (diff)
crypto: ccree - add function to handle cryptocell tee fips error
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 <ofir.drang@arm.com> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com> Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/ccree/cc_fips.c23
-rw-r--r--drivers/crypto/ccree/cc_fips.h2
2 files changed, 17 insertions, 8 deletions
diff --git a/drivers/crypto/ccree/cc_fips.c b/drivers/crypto/ccree/cc_fips.c
index 4a67248f5625..5ad3ffb7acaa 100644
--- a/drivers/crypto/ccree/cc_fips.c
+++ b/drivers/crypto/ccree/cc_fips.c
@@ -70,20 +70,28 @@ static inline void tee_fips_error(struct device *dev)
70 dev_err(dev, "TEE reported error!\n"); 70 dev_err(dev, "TEE reported error!\n");
71} 71}
72 72
73/*
74 * This function check if cryptocell tee fips error occurred
75 * and in such case triggers system error
76 */
77void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata)
78{
79 struct device *dev = drvdata_to_dev(p_drvdata);
80
81 if (!cc_get_tee_fips_status(p_drvdata))
82 tee_fips_error(dev);
83}
84
73/* Deferred service handler, run as interrupt-fired tasklet */ 85/* Deferred service handler, run as interrupt-fired tasklet */
74static void fips_dsr(unsigned long devarg) 86static void fips_dsr(unsigned long devarg)
75{ 87{
76 struct cc_drvdata *drvdata = (struct cc_drvdata *)devarg; 88 struct cc_drvdata *drvdata = (struct cc_drvdata *)devarg;
77 struct device *dev = drvdata_to_dev(drvdata); 89 u32 irq, val;
78 u32 irq, state, val;
79 90
80 irq = (drvdata->irq & (CC_GPR0_IRQ_MASK)); 91 irq = (drvdata->irq & (CC_GPR0_IRQ_MASK));
81 92
82 if (irq) { 93 if (irq) {
83 state = cc_ioread(drvdata, CC_REG(GPR_HOST)); 94 cc_tee_handle_fips_error(drvdata);
84
85 if (state != (CC_FIPS_SYNC_TEE_STATUS | CC_FIPS_SYNC_MODULE_OK))
86 tee_fips_error(dev);
87 } 95 }
88 96
89 /* after verifing that there is nothing to do, 97 /* after verifing that there is nothing to do,
@@ -111,8 +119,7 @@ int cc_fips_init(struct cc_drvdata *p_drvdata)
111 dev_dbg(dev, "Initializing fips tasklet\n"); 119 dev_dbg(dev, "Initializing fips tasklet\n");
112 tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata); 120 tasklet_init(&fips_h->tasklet, fips_dsr, (unsigned long)p_drvdata);
113 121
114 if (!cc_get_tee_fips_status(p_drvdata)) 122 cc_tee_handle_fips_error(p_drvdata);
115 tee_fips_error(dev);
116 123
117 return 0; 124 return 0;
118} 125}
diff --git a/drivers/crypto/ccree/cc_fips.h b/drivers/crypto/ccree/cc_fips.h
index 2c287faf10ff..fc33eeb4d566 100644
--- 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_drvdata);
18void cc_fips_fini(struct cc_drvdata *drvdata); 18void cc_fips_fini(struct cc_drvdata *drvdata);
19void fips_handler(struct cc_drvdata *drvdata); 19void fips_handler(struct cc_drvdata *drvdata);
20void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok); 20void cc_set_ree_fips_status(struct cc_drvdata *drvdata, bool ok);
21void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata);
21 22
22#else /* CONFIG_CRYPTO_FIPS */ 23#else /* CONFIG_CRYPTO_FIPS */
23 24
@@ -30,6 +31,7 @@ static inline void cc_fips_fini(struct cc_drvdata *drvdata) {}
30static inline void cc_set_ree_fips_status(struct cc_drvdata *drvdata, 31static inline void cc_set_ree_fips_status(struct cc_drvdata *drvdata,
31 bool ok) {} 32 bool ok) {}
32static inline void fips_handler(struct cc_drvdata *drvdata) {} 33static inline void fips_handler(struct cc_drvdata *drvdata) {}
34static inline void cc_tee_handle_fips_error(struct cc_drvdata *p_drvdata) {}
33 35
34#endif /* CONFIG_CRYPTO_FIPS */ 36#endif /* CONFIG_CRYPTO_FIPS */
35 37