Content-Type: multipart/mixed; boundary="===============5532404067182037900==" MIME-Version: 1.0 From: kernel test robot To: kbuild-all@lists.01.org Subject: Re: [PATCH 1/8] crypto: sun8i-ce: do not allocate memory when handling requests Date: Thu, 27 Jan 2022 12:17:24 +0800 Message-ID: <202201271243.hLjdr8IB-lkp@intel.com> In-Reply-To: <20220126210441.3661782-2-clabbe@baylibre.com> List-Id: --===============5532404067182037900== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Corentin, I love your patch! Perhaps something to improve: [auto build test WARNING on sunxi/sunxi/for-next] [also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6= /master v5.17-rc1 next-20220125] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-allw= inner-various-improvments/20220127-050556 base: https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git sun= xi/for-next config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/2022012= 7/202201271243.hLjdr8IB-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 2a1b7a= a016c0f4b5598806205bdfbab1ea2d92c4) reproduce (this is a W=3D1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/= make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install arm64 cross compiling tool for clang build # apt-get install binutils-aarch64-linux-gnu # https://github.com/0day-ci/linux/commit/d0b880af8c99abcd0f36463b8= 2c92d71024408de git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Corentin-Labbe/crypto-allwinner-va= rious-improvments/20220127-050556 git checkout d0b880af8c99abcd0f36463b82c92d71024408de # save the config file to linux build tree mkdir build_dir COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W=3D= 1 O=3Dbuild_dir ARCH=3Darm64 SHELL=3D/bin/bash drivers/crypto/allwinner/sun= 8i-ce/ If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All warnings (new ones prefixed by >>): >> drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c:258:1: warning: unus= ed label 'theend_key' [-Wunused-label] theend_key: ^~~~~~~~~~~ 1 warning generated. vim +/theend_key +258 drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c 06f751b613296cc Corentin Labbe 2019-10-23 108 = 06f751b613296cc Corentin Labbe 2019-10-23 109 flow =3D rctx->flow; 06f751b613296cc Corentin Labbe 2019-10-23 110 = 06f751b613296cc Corentin Labbe 2019-10-23 111 chan =3D &ce->chanlist[flo= w]; 06f751b613296cc Corentin Labbe 2019-10-23 112 = 06f751b613296cc Corentin Labbe 2019-10-23 113 cet =3D chan->tl; 06f751b613296cc Corentin Labbe 2019-10-23 114 memset(cet, 0, sizeof(stru= ct ce_task)); 06f751b613296cc Corentin Labbe 2019-10-23 115 = 93c7f4d357de68f Corentin Labbe 2019-11-17 116 cet->t_id =3D cpu_to_le32(= flow); 93c7f4d357de68f Corentin Labbe 2019-11-17 117 common =3D ce->variant->al= g_cipher[algt->ce_algo_id]; 93c7f4d357de68f Corentin Labbe 2019-11-17 118 common |=3D rctx->op_dir |= CE_COMM_INT; 93c7f4d357de68f Corentin Labbe 2019-11-17 119 cet->t_common_ctl =3D cpu_= to_le32(common); 06f751b613296cc Corentin Labbe 2019-10-23 120 /* CTS and recent CE (H6) = need length in bytes, in word otherwise */ 6b4f76c2cd9e6c3 Corentin Labbe 2020-09-18 121 if (ce->variant->cipher_t_= dlen_in_bytes) 93c7f4d357de68f Corentin Labbe 2019-11-17 122 cet->t_dlen =3D cpu_to_le= 32(areq->cryptlen); 93c7f4d357de68f Corentin Labbe 2019-11-17 123 else 93c7f4d357de68f Corentin Labbe 2019-11-17 124 cet->t_dlen =3D cpu_to_le= 32(areq->cryptlen / 4); 06f751b613296cc Corentin Labbe 2019-10-23 125 = 93c7f4d357de68f Corentin Labbe 2019-11-17 126 sym =3D ce->variant->op_mo= de[algt->ce_blockmode]; 06f751b613296cc Corentin Labbe 2019-10-23 127 len =3D op->keylen; 06f751b613296cc Corentin Labbe 2019-10-23 128 switch (len) { 06f751b613296cc Corentin Labbe 2019-10-23 129 case 128 / 8: 93c7f4d357de68f Corentin Labbe 2019-11-17 130 sym |=3D CE_AES_128BITS; 06f751b613296cc Corentin Labbe 2019-10-23 131 break; 06f751b613296cc Corentin Labbe 2019-10-23 132 case 192 / 8: 93c7f4d357de68f Corentin Labbe 2019-11-17 133 sym |=3D CE_AES_192BITS; 06f751b613296cc Corentin Labbe 2019-10-23 134 break; 06f751b613296cc Corentin Labbe 2019-10-23 135 case 256 / 8: 93c7f4d357de68f Corentin Labbe 2019-11-17 136 sym |=3D CE_AES_256BITS; 06f751b613296cc Corentin Labbe 2019-10-23 137 break; 06f751b613296cc Corentin Labbe 2019-10-23 138 } 06f751b613296cc Corentin Labbe 2019-10-23 139 = 93c7f4d357de68f Corentin Labbe 2019-11-17 140 cet->t_sym_ctl =3D cpu_to_= le32(sym); 06f751b613296cc Corentin Labbe 2019-10-23 141 cet->t_asym_ctl =3D 0; 06f751b613296cc Corentin Labbe 2019-10-23 142 = 0605fa0f78266cc Corentin Labbe 2020-09-18 143 rctx->addr_key =3D dma_map= _single(ce->dev, op->key, op->keylen, DMA_TO_DEVICE); 0605fa0f78266cc Corentin Labbe 2020-09-18 144 if (dma_mapping_error(ce->= dev, rctx->addr_key)) { 06f751b613296cc Corentin Labbe 2019-10-23 145 dev_err(ce->dev, "Cannot = DMA MAP KEY\n"); 06f751b613296cc Corentin Labbe 2019-10-23 146 err =3D -EFAULT; 06f751b613296cc Corentin Labbe 2019-10-23 147 goto theend; 06f751b613296cc Corentin Labbe 2019-10-23 148 } 0605fa0f78266cc Corentin Labbe 2020-09-18 149 cet->t_key =3D cpu_to_le32= (rctx->addr_key); 06f751b613296cc Corentin Labbe 2019-10-23 150 = 06f751b613296cc Corentin Labbe 2019-10-23 151 ivsize =3D crypto_skcipher= _ivsize(tfm); 06f751b613296cc Corentin Labbe 2019-10-23 152 if (areq->iv && crypto_skc= ipher_ivsize(tfm) > 0) { a216f8d540cf132 Corentin Labbe 2020-09-18 153 rctx->ivlen =3D ivsize; 06f751b613296cc Corentin Labbe 2019-10-23 154 if (rctx->op_dir & CE_DEC= RYPTION) { 06f751b613296cc Corentin Labbe 2019-10-23 155 offset =3D areq->cryptle= n - ivsize; d0b880af8c99abc Corentin Labbe 2022-01-26 156 scatterwalk_map_and_copy= (chan->backup_iv, areq->src, a216f8d540cf132 Corentin Labbe 2020-09-18 157 offset, ivsize, 0); 06f751b613296cc Corentin Labbe 2019-10-23 158 } d0b880af8c99abc Corentin Labbe 2022-01-26 159 memcpy(chan->bounce_iv, a= req->iv, ivsize); d0b880af8c99abc Corentin Labbe 2022-01-26 160 rctx->addr_iv =3D dma_map= _single(ce->dev, chan->bounce_iv, rctx->ivlen, 93c7f4d357de68f Corentin Labbe 2019-11-17 161 DMA_TO_DEVICE); 0605fa0f78266cc Corentin Labbe 2020-09-18 162 if (dma_mapping_error(ce-= >dev, rctx->addr_iv)) { 06f751b613296cc Corentin Labbe 2019-10-23 163 dev_err(ce->dev, "Cannot= DMA MAP IV\n"); 06f751b613296cc Corentin Labbe 2019-10-23 164 err =3D -ENOMEM; 06f751b613296cc Corentin Labbe 2019-10-23 165 goto theend_iv; 06f751b613296cc Corentin Labbe 2019-10-23 166 } 0605fa0f78266cc Corentin Labbe 2020-09-18 167 cet->t_iv =3D cpu_to_le32= (rctx->addr_iv); 06f751b613296cc Corentin Labbe 2019-10-23 168 } 06f751b613296cc Corentin Labbe 2019-10-23 169 = 06f751b613296cc Corentin Labbe 2019-10-23 170 if (areq->src =3D=3D areq-= >dst) { 06f751b613296cc Corentin Labbe 2019-10-23 171 nr_sgs =3D dma_map_sg(ce-= >dev, areq->src, sg_nents(areq->src), 06f751b613296cc Corentin Labbe 2019-10-23 172 DMA_BIDIRECTIONAL); 06f751b613296cc Corentin Labbe 2019-10-23 173 if (nr_sgs <=3D 0 || nr_s= gs > MAX_SG) { 06f751b613296cc Corentin Labbe 2019-10-23 174 dev_err(ce->dev, "Invali= d sg number %d\n", nr_sgs); 06f751b613296cc Corentin Labbe 2019-10-23 175 err =3D -EINVAL; 06f751b613296cc Corentin Labbe 2019-10-23 176 goto theend_iv; 06f751b613296cc Corentin Labbe 2019-10-23 177 } 06f751b613296cc Corentin Labbe 2019-10-23 178 nr_sgd =3D nr_sgs; 06f751b613296cc Corentin Labbe 2019-10-23 179 } else { 06f751b613296cc Corentin Labbe 2019-10-23 180 nr_sgs =3D dma_map_sg(ce-= >dev, areq->src, sg_nents(areq->src), 06f751b613296cc Corentin Labbe 2019-10-23 181 DMA_TO_DEVICE); 06f751b613296cc Corentin Labbe 2019-10-23 182 if (nr_sgs <=3D 0 || nr_s= gs > MAX_SG) { 06f751b613296cc Corentin Labbe 2019-10-23 183 dev_err(ce->dev, "Invali= d sg number %d\n", nr_sgs); 06f751b613296cc Corentin Labbe 2019-10-23 184 err =3D -EINVAL; 06f751b613296cc Corentin Labbe 2019-10-23 185 goto theend_iv; 06f751b613296cc Corentin Labbe 2019-10-23 186 } 06f751b613296cc Corentin Labbe 2019-10-23 187 nr_sgd =3D dma_map_sg(ce-= >dev, areq->dst, sg_nents(areq->dst), 06f751b613296cc Corentin Labbe 2019-10-23 188 DMA_FROM_DEVICE); 06f751b613296cc Corentin Labbe 2019-10-23 189 if (nr_sgd <=3D 0 || nr_s= gd > MAX_SG) { 06f751b613296cc Corentin Labbe 2019-10-23 190 dev_err(ce->dev, "Invali= d sg number %d\n", nr_sgd); 06f751b613296cc Corentin Labbe 2019-10-23 191 err =3D -EINVAL; 06f751b613296cc Corentin Labbe 2019-10-23 192 goto theend_sgs; 06f751b613296cc Corentin Labbe 2019-10-23 193 } 06f751b613296cc Corentin Labbe 2019-10-23 194 } 06f751b613296cc Corentin Labbe 2019-10-23 195 = 06f751b613296cc Corentin Labbe 2019-10-23 196 len =3D areq->cryptlen; 06f751b613296cc Corentin Labbe 2019-10-23 197 for_each_sg(areq->src, sg,= nr_sgs, i) { 93c7f4d357de68f Corentin Labbe 2019-11-17 198 cet->t_src[i].addr =3D cp= u_to_le32(sg_dma_address(sg)); 06f751b613296cc Corentin Labbe 2019-10-23 199 todo =3D min(len, sg_dma_= len(sg)); 93c7f4d357de68f Corentin Labbe 2019-11-17 200 cet->t_src[i].len =3D cpu= _to_le32(todo / 4); 06f751b613296cc Corentin Labbe 2019-10-23 201 dev_dbg(ce->dev, "%s tota= l=3D%u SG(%d %u off=3D%d) todo=3D%u\n", __func__, 06f751b613296cc Corentin Labbe 2019-10-23 202 areq->cryptlen, i, cet->= t_src[i].len, sg->offset, todo); 06f751b613296cc Corentin Labbe 2019-10-23 203 len -=3D todo; 06f751b613296cc Corentin Labbe 2019-10-23 204 } 06f751b613296cc Corentin Labbe 2019-10-23 205 if (len > 0) { 06f751b613296cc Corentin Labbe 2019-10-23 206 dev_err(ce->dev, "remaini= ng len %d\n", len); 06f751b613296cc Corentin Labbe 2019-10-23 207 err =3D -EINVAL; 06f751b613296cc Corentin Labbe 2019-10-23 208 goto theend_sgs; 06f751b613296cc Corentin Labbe 2019-10-23 209 } 06f751b613296cc Corentin Labbe 2019-10-23 210 = 06f751b613296cc Corentin Labbe 2019-10-23 211 len =3D areq->cryptlen; 06f751b613296cc Corentin Labbe 2019-10-23 212 for_each_sg(areq->dst, sg,= nr_sgd, i) { 93c7f4d357de68f Corentin Labbe 2019-11-17 213 cet->t_dst[i].addr =3D cp= u_to_le32(sg_dma_address(sg)); 06f751b613296cc Corentin Labbe 2019-10-23 214 todo =3D min(len, sg_dma_= len(sg)); 93c7f4d357de68f Corentin Labbe 2019-11-17 215 cet->t_dst[i].len =3D cpu= _to_le32(todo / 4); 06f751b613296cc Corentin Labbe 2019-10-23 216 dev_dbg(ce->dev, "%s tota= l=3D%u SG(%d %u off=3D%d) todo=3D%u\n", __func__, 06f751b613296cc Corentin Labbe 2019-10-23 217 areq->cryptlen, i, cet->= t_dst[i].len, sg->offset, todo); 06f751b613296cc Corentin Labbe 2019-10-23 218 len -=3D todo; 06f751b613296cc Corentin Labbe 2019-10-23 219 } 06f751b613296cc Corentin Labbe 2019-10-23 220 if (len > 0) { 06f751b613296cc Corentin Labbe 2019-10-23 221 dev_err(ce->dev, "remaini= ng len %d\n", len); 06f751b613296cc Corentin Labbe 2019-10-23 222 err =3D -EINVAL; 06f751b613296cc Corentin Labbe 2019-10-23 223 goto theend_sgs; 06f751b613296cc Corentin Labbe 2019-10-23 224 } 06f751b613296cc Corentin Labbe 2019-10-23 225 = 06f751b613296cc Corentin Labbe 2019-10-23 226 chan->timeout =3D areq->cr= yptlen; 0605fa0f78266cc Corentin Labbe 2020-09-18 227 rctx->nr_sgs =3D nr_sgs; 0605fa0f78266cc Corentin Labbe 2020-09-18 228 rctx->nr_sgd =3D nr_sgd; 0605fa0f78266cc Corentin Labbe 2020-09-18 229 return 0; 06f751b613296cc Corentin Labbe 2019-10-23 230 = 06f751b613296cc Corentin Labbe 2019-10-23 231 theend_sgs: 06f751b613296cc Corentin Labbe 2019-10-23 232 if (areq->src =3D=3D areq-= >dst) { 884b93c51025026 Xiang Chen 2021-03-16 233 dma_unmap_sg(ce->dev, are= q->src, sg_nents(areq->src), 884b93c51025026 Xiang Chen 2021-03-16 234 DMA_BIDIRECTIONAL); 06f751b613296cc Corentin Labbe 2019-10-23 235 } else { 06f751b613296cc Corentin Labbe 2019-10-23 236 if (nr_sgs > 0) 884b93c51025026 Xiang Chen 2021-03-16 237 dma_unmap_sg(ce->dev, ar= eq->src, sg_nents(areq->src), 884b93c51025026 Xiang Chen 2021-03-16 238 DMA_TO_DEVICE); 884b93c51025026 Xiang Chen 2021-03-16 239 dma_unmap_sg(ce->dev, are= q->dst, sg_nents(areq->dst), 884b93c51025026 Xiang Chen 2021-03-16 240 DMA_FROM_DEVICE); 06f751b613296cc Corentin Labbe 2019-10-23 241 } 06f751b613296cc Corentin Labbe 2019-10-23 242 = 06f751b613296cc Corentin Labbe 2019-10-23 243 theend_iv: 06f751b613296cc Corentin Labbe 2019-10-23 244 if (areq->iv && ivsize > 0= ) { 0605fa0f78266cc Corentin Labbe 2020-09-18 245 if (rctx->addr_iv) 0605fa0f78266cc Corentin Labbe 2020-09-18 246 dma_unmap_single(ce->dev= , rctx->addr_iv, rctx->ivlen, DMA_TO_DEVICE); 06f751b613296cc Corentin Labbe 2019-10-23 247 offset =3D areq->cryptlen= - ivsize; 06f751b613296cc Corentin Labbe 2019-10-23 248 if (rctx->op_dir & CE_DEC= RYPTION) { d0b880af8c99abc Corentin Labbe 2022-01-26 249 memcpy(areq->iv, chan->b= ackup_iv, ivsize); d0b880af8c99abc Corentin Labbe 2022-01-26 250 memzero_explicit(chan->b= ackup_iv, ivsize); 06f751b613296cc Corentin Labbe 2019-10-23 251 } else { 06f751b613296cc Corentin Labbe 2019-10-23 252 scatterwalk_map_and_copy= (areq->iv, areq->dst, offset, 06f751b613296cc Corentin Labbe 2019-10-23 253 ivsize, 0); 06f751b613296cc Corentin Labbe 2019-10-23 254 } d0b880af8c99abc Corentin Labbe 2022-01-26 255 memzero_explicit(chan->bo= unce_iv, ivsize); 06f751b613296cc Corentin Labbe 2019-10-23 256 } 06f751b613296cc Corentin Labbe 2019-10-23 257 = 06f751b613296cc Corentin Labbe 2019-10-23 @258 theend_key: 0605fa0f78266cc Corentin Labbe 2020-09-18 259 dma_unmap_single(ce->dev, = rctx->addr_key, op->keylen, DMA_TO_DEVICE); 06f751b613296cc Corentin Labbe 2019-10-23 260 = 06f751b613296cc Corentin Labbe 2019-10-23 261 theend: 06f751b613296cc Corentin Labbe 2019-10-23 262 return err; 06f751b613296cc Corentin Labbe 2019-10-23 263 } 06f751b613296cc Corentin Labbe 2019-10-23 264 = --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org --===============5532404067182037900==--