···8080{8181 struct crypto_tfm *xfm = crypto_ablkcipher_tfm(tfm);8282 struct ccp_ctx *ctx = crypto_tfm_ctx(xfm);8383+ unsigned int ccpversion = ccp_version();8384 int ret;84858586 ret = xts_check_key(xfm, key, key_len);8687 if (ret)8788 return ret;88898989- /* Only support 128-bit AES key with a 128-bit Tweak key,9090- * otherwise use the fallback9090+ /* Version 3 devices support 128-bit keys; version 5 devices can9191+ * accommodate 128- and 256-bit keys.9192 */9293 switch (key_len) {9394 case AES_KEYSIZE_128 * 2:9495 memcpy(ctx->u.aes.key, key, key_len);9696+ break;9797+ case AES_KEYSIZE_256 * 2:9898+ if (ccpversion > CCP_VERSION(3, 0))9999+ memcpy(ctx->u.aes.key, key, key_len);95100 break;96101 }97102 ctx->u.aes.key_len = key_len / 2;···110105{111106 struct ccp_ctx *ctx = crypto_tfm_ctx(req->base.tfm);112107 struct ccp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);108108+ unsigned int ccpversion = ccp_version();109109+ unsigned int fallback = 0;113110 unsigned int unit;114111 u32 unit_size;115112 int ret;···138131 break;139132 }140133 }141141- if ((unit_size == CCP_XTS_AES_UNIT_SIZE__LAST) ||142142- (ctx->u.aes.key_len != AES_KEYSIZE_128)) {134134+ /* The CCP has restrictions on block sizes. Also, a version 3 device135135+ * only supports AES-128 operations; version 5 CCPs support both136136+ * AES-128 and -256 operations.137137+ */138138+ if (unit_size == CCP_XTS_AES_UNIT_SIZE__LAST)139139+ fallback = 1;140140+ if ((ccpversion < CCP_VERSION(5, 0)) &&141141+ (ctx->u.aes.key_len != AES_KEYSIZE_128))142142+ fallback = 1;143143+ if ((ctx->u.aes.key_len != AES_KEYSIZE_128) &&144144+ (ctx->u.aes.key_len != AES_KEYSIZE_256))145145+ fallback = 1;146146+ if (fallback) {143147 SKCIPHER_REQUEST_ON_STACK(subreq, ctx->u.aes.tfm_skcipher);144148145149 /* Use the fallback to process the request for any