On 9/21/2020 10:32 AM, Andrei Botila (OSS) wrote: > +static bool xts_skcipher_ivsize(struct skcipher_request *req) > +{ > + struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req); > + unsigned int ivsize = crypto_skcipher_ivsize(skcipher); > + u64 size = 0; > + > + size = get_unaligned((u64 *)(req->iv + (ivsize / 2))); > + > + return !!size; Just get rid of the "size" local variable and return !!get_unaligned(...). Also the function should be inline. > @@ -3344,13 +3379,30 @@ static int caam_cra_init(struct crypto_skcipher *tfm) > struct caam_skcipher_alg *caam_alg = > container_of(alg, typeof(*caam_alg), skcipher); > struct caam_ctx *ctx = crypto_skcipher_ctx(tfm); > - > - crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx)); > + u32 alg_aai = caam_alg->caam.class1_alg_type & OP_ALG_AAI_MASK; > > ctx->enginectx.op.do_one_request = skcipher_do_one_req; > > - return caam_init_common(crypto_skcipher_ctx(tfm), &caam_alg->caam, > - false); > + if (alg_aai == OP_ALG_AAI_XTS) { > + const char *tfm_name = crypto_tfm_alg_name(&tfm->base); > + struct crypto_skcipher *fallback; > + > + fallback = crypto_alloc_skcipher(tfm_name, 0, > + CRYPTO_ALG_NEED_FALLBACK); > + if (IS_ERR(fallback)) { > + dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n", > + tfm_name, PTR_ERR(fallback)); > + return PTR_ERR(fallback); > + } > + > + ctx->fallback = fallback; > + crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx) + > + crypto_skcipher_reqsize(fallback)); > + } else { > + crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx)); > + } > + > + return caam_init_common(ctx, &caam_alg->caam, false); In case caam_init_common() fails, fallback should be freed for XTS path. Horia