diff options
author | Horia Geanta <horia.geanta@freescale.com> | 2013-12-05 21:09:27 (GMT) |
---|---|---|
committer | Jose Rivera <German.Rivera@freescale.com> | 2014-03-28 13:39:13 (GMT) |
commit | 779126cf974e9703db04bfe03cb45d07a21b8f85 (patch) | |
tree | 82d366f5384b47185c87bcaf9fde2e3e7d142d76 | |
parent | 6e7e54c8a5649c66ab14c5b0e4baac89b9e715b6 (diff) | |
download | linux-fsl-qoriq-779126cf974e9703db04bfe03cb45d07a21b8f85.tar.xz |
crypto: caam - do not register algorithms for unsupported SEC Eras
Commit 33de5f5c7455aea05b48d46f3024f78ecc83dc4b
(crypto: caam - add support for TLS 1.0 record)
added support for TLS 1.0 offloading, mentioning that the feature is
available for platforms having SEC Era 4 or above.
However, this doesn't stop one to actually run this feature on platforms
not supported (for e.g. P3041DS), leading to errors like:
platform ffe303000.jr: 40002807: DECO: desc idx 40: Invalid LOAD Command
Add a .min_era member for each algorithm registered by the driver,
specifying the lowest (compatible) SEC Era on which the descriptors
can run.
Change-Id: Idf929591361d244a4d7cd8352d0fb8ad7feff830
Signed-off-by: Horia Geanta <horia.geanta@freescale.com>
Reviewed-on: http://git.am.freescale.net:8181/7118
Reviewed-by: Mircea Pop <mircea.pop@freescale.com>
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Thomas Trefny <Tom.Trefny@freescale.com>
(cherry picked from commit 351d2c869e446187bc78f47dccb0213f0a5e9f17)
Conflicts:
drivers/crypto/caam/caamalg.c
drivers/crypto/caam/ctrl.c
drivers/crypto/caam/intern.h
Change-Id: I615578f0d0693eb46742e65004435821f6eb7de7
Reviewed-on: http://git.am.freescale.net:8181/10374
Reviewed-by: Cristian Stoica <cristian.stoica@freescale.com>
Reviewed-by: Mircea Pop <mircea.pop@freescale.com>
Reviewed-by: Alexandru Porosanu <alexandru.porosanu@freescale.com>
Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com>
Reviewed-by: Jose Rivera <German.Rivera@freescale.com>
-rw-r--r-- | drivers/crypto/caam/caamalg.c | 34 | ||||
-rw-r--r-- | drivers/crypto/caam/ctrl.c | 3 | ||||
-rw-r--r-- | drivers/crypto/caam/intern.h | 2 |
3 files changed, 36 insertions, 3 deletions
diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index 95e1d1a..276f123 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -2297,6 +2297,7 @@ struct caam_alg_template { u32 class1_alg_type; u32 class2_alg_type; u32 alg_op; + int min_era; }; static struct caam_alg_template driver_algs[] = { @@ -2319,6 +2320,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha1),cbc(aes))", @@ -2338,6 +2340,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha224),cbc(aes))", @@ -2358,6 +2361,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha256),cbc(aes))", @@ -2378,6 +2382,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha384),cbc(aes))", @@ -2398,6 +2403,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { @@ -2419,6 +2425,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(md5),cbc(des3_ede))", @@ -2438,6 +2445,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha1),cbc(des3_ede))", @@ -2457,6 +2465,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha224),cbc(des3_ede))", @@ -2477,6 +2486,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha256),cbc(des3_ede))", @@ -2497,6 +2507,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha384),cbc(des3_ede))", @@ -2517,6 +2528,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha512),cbc(des3_ede))", @@ -2537,6 +2549,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(md5),cbc(des))", @@ -2556,6 +2569,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_MD5 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha1),cbc(des))", @@ -2575,6 +2589,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha224),cbc(des))", @@ -2595,6 +2610,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA224 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha256),cbc(des))", @@ -2615,6 +2631,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA256 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha384),cbc(des))", @@ -2635,6 +2652,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA384 | OP_ALG_AAI_HMAC, + .min_era = 2, }, { .name = "authenc(hmac(sha512),cbc(des))", @@ -2655,6 +2673,7 @@ static struct caam_alg_template driver_algs[] = { .class2_alg_type = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA512 | OP_ALG_AAI_HMAC, + .min_era = 2, }, /* TLS record descriptors */ { @@ -2675,6 +2694,7 @@ static struct caam_alg_template driver_algs[] = { .class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC, .class2_alg_type = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC_PRECOMP, .alg_op = OP_ALG_ALGSEL_SHA1 | OP_ALG_AAI_HMAC, + .min_era = 4, }, /* ablkcipher descriptor */ { @@ -2692,6 +2712,7 @@ static struct caam_alg_template driver_algs[] = { .ivsize = AES_BLOCK_SIZE, }, .class1_alg_type = OP_ALG_ALGSEL_AES | OP_ALG_AAI_CBC, + .min_era = 2, }, { .name = "cbc(des3_ede)", @@ -2708,6 +2729,7 @@ static struct caam_alg_template driver_algs[] = { .ivsize = DES3_EDE_BLOCK_SIZE, }, .class1_alg_type = OP_ALG_ALGSEL_3DES | OP_ALG_AAI_CBC, + .min_era = 2, }, { .name = "cbc(des)", @@ -2724,6 +2746,7 @@ static struct caam_alg_template driver_algs[] = { .ivsize = DES_BLOCK_SIZE, }, .class1_alg_type = OP_ALG_ALGSEL_DES | OP_ALG_AAI_CBC, + .min_era = 2, } }; @@ -2860,7 +2883,7 @@ static int __init caam_algapi_init(void) struct device_node *dev_node; struct platform_device *pdev; struct device *ctrldev; - void *priv; + struct caam_drv_private *priv; int i = 0, err = 0; dev_node = of_find_compatible_node(NULL, NULL, "fsl,sec-v4.0"); @@ -2890,9 +2913,16 @@ static int __init caam_algapi_init(void) /* register crypto algorithms the device supports */ for (i = 0; i < ARRAY_SIZE(driver_algs); i++) { - /* TODO: check if h/w supports alg */ struct caam_crypto_alg *t_alg; + /* check if h/w supports alg */ + if (priv->era > 0 && priv->era < driver_algs[i].min_era) { + pr_warn("%s needs Era %d or higher but SEC is Era %d, skipping it\n", + driver_algs[i].driver_name, + driver_algs[i].min_era, priv->era); + continue; + } + t_alg = caam_alg_alloc(&driver_algs[i]); if (IS_ERR(t_alg)) { err = PTR_ERR(t_alg); diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 712a4c3..1099914 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -572,10 +572,11 @@ static int caam_probe(struct platform_device *pdev) /* NOTE: RTIC detection ought to go here, around Si time */ caam_id = rd_reg64(&topregs->ctrl.perfmon.caam_id); + ctrlpriv->era = caam_get_era(); /* Report "alive" for developer to see */ dev_info(dev, "device ID = 0x%016llx (Era %d)\n", caam_id, - caam_get_era()); + ctrlpriv->era); dev_info(dev, "job rings = %d, qi = %d\n", ctrlpriv->total_jobrs, ctrlpriv->qi_present); diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index cbdef5e..ed0351d 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -93,6 +93,8 @@ struct caam_drv_private { /* list of registered pkc algorithms */ struct list_head pkc_list; + int era; /* SEC Era */ + #define RNG4_MAX_HANDLES 2 /* RNG4 block */ u32 rng4_sh_init; /* This bitmap shows which of the State |