Enable the Mediatek EIP-93 crypto engine
Subsystems (3)
v3 cover Enable the Mediatek EIP-93 crypto engine
This series enable the Mediatek EIP-93 crypto engine as found in the MT7621
This engine is capable of AES/DES/3DES ciphers in ECB/CBC and CTR modes, hash and hmac(hash) using MD5, SHA1, SHA224 and SHA256. The engine can do full authenc(hmac(x), cipher(y)) using mentioned ciphers and hashes. The engine also has an ANSI X9.31 PRNG.
This driver is fully test and passes all the extra tests when selecting:CONFIG_CRYPTO_MANAGER_EXTRA_TESTS
For now only simple cipher and authenc are added. In the future I will add patches for hash/hmac and the PRNG.
Richard van Schagen
Changes since V2:
- Adding 2 missing "static" which got lost in my editing (sorry)
Changes since V1:
- Fix errors found by kernel test robot.
--- .../bindings/crypto/mediatek,mtk-eip93.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml
drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/mtk-eip93/Kconfig | 49 ++ drivers/crypto/mtk-eip93/Makefile | 7 + drivers/crypto/mtk-eip93/eip93-aead.c | 767 +++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-aead.h | 43 ++ drivers/crypto/mtk-eip93/eip93-aes.h | 15 + drivers/crypto/mtk-eip93/eip93-cipher.c | 399 ++++++++++++ drivers/crypto/mtk-eip93/eip93-cipher.h | 62 ++ drivers/crypto/mtk-eip93/eip93-common.c | 784 ++++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-common.h | 34 + drivers/crypto/mtk-eip93/eip93-des.h | 15 + drivers/crypto/mtk-eip93/eip93-main.c | 458 ++++++++++++++ drivers/crypto/mtk-eip93/eip93-main.h | 146 +++++ drivers/crypto/mtk-eip93/eip93-regs.h | 382 ++++++++++++ 15 files changed, 3164 insertions(+) create mode 100644 drivers/crypto/mtk-eip93/Kconfig create mode 100644 drivers/crypto/mtk-eip93/Makefile create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.c create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.h create mode 100644 drivers/crypto/mtk-eip93/eip93-aes.h create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.c create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.h create mode 100644 drivers/crypto/mtk-eip93/eip93-common.c create mode 100644 drivers/crypto/mtk-eip93/eip93-common.h create mode 100644 drivers/crypto/mtk-eip93/eip93-des.h create mode 100644 drivers/crypto/mtk-eip93/eip93-main.c create mode 100644 drivers/crypto/mtk-eip93/eip93-main.h create mode 100644 drivers/crypto/mtk-eip93/eip93-regs.h
PATCH v3 1/2 dt-bindings: crypto: Add Mediatek EIP-93 crypto engine
Add bindings for the Mediatek EIP-93 crypto engine.
---
Changes since V2:
- Adding 2 missing "static" which got lost in my editing (sorry)
Changes since V1
- Add missing #include to examples
.../bindings/crypto/mediatek,mtk-eip93.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +43 -0
@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/mediatek,mtk-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek EIP93 crypto engine + +maintainers: + - Richard van Schagen <[email protected]> + +properties: + compatible: + enum: + - mediatek, mtk-eip93 + + reg: + maxItems: 1 + + interrupts-parent: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupt-parent + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/mips-gic.h> + + crypto: crypto@1e004000 { + compatible = "mediatek,mtk-eip93"; + reg = <0x1e004000 0x1000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SHARED 19 IRQ_TYPE_LEVEL_HIGH>; + };
Signature · 1 line
2.30.2
Re: [PATCH v3 1/2] dt-bindings: crypto: Add Mediatek EIP-93 crypto engine
Quoted 2 lines · Richard van Schagen
Add bindings for the Mediatek EIP-93 crypto engine.
Please resend to DT list so automated checks run and it is in my review queue.
Quoted 23 lines
Signed-off-by Richard van Schagen <[email protected]>---
Changes since V2:
- Adding 2 missing "static" which got lost in my editing (sorry)Changes since V1
- Add missing #include to examples.../bindings/crypto/mediatek,mtk-eip93.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yamlDocumentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +5
-0@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/crypto/mediatek,mtk-eip93.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml line 15
Quoted 10 lines
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +10
-0+ +title: Mediatek EIP93 crypto engine + +maintainers: + - Richard van Schagen <[email protected]> + +properties: + compatible: + enum: + - mediatek, mtk-eip93
Looks like a typo. 'make dt_binding_check' would have pointed this out.
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml line 21
Quoted 6 lines
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +6
-0+ + reg: + maxItems: 1 + + interrupts-parent: + maxItems: 1
Drop this. First, it's 'interrupt-parent'. Second, it is valid for interrupt-parent to be in any parent node as well. So you don't need to define it here.
Quoted 25 lines
Documentation/devicetree/bindings/crypto/mediatek,mtk-eip93.yaml new file +22
-1+ + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupt-parent + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/mips-gic.h> + + crypto: crypto@1e004000 { + compatible = "mediatek,mtk-eip93"; + reg = <0x1e004000 0x1000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SHARED 19 IRQ_TYPE_LEVEL_HIGH>; + }; --2.30.2
PATCH v3 2/2 crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
In reply to Richard van SchagenThis patch adds support for the Mediatek EIP-93 crypto engine.
This will add AES/DES/3DES ciphers in ECB/CBC and CTR modes as well as authenc(HMAC(x), cipher(y)) using HMAC MD5, SHA1, SHA224 and SHA256.
---
Changes since V2:
- Adding 2 missing "static" which got lost in my editing (sorry)
Changes since V1:
- Removed unused variables
- Add corrected header files
- Select dependencies in Kconfig
drivers/crypto/Kconfig | 2 + drivers/crypto/Makefile | 1 + drivers/crypto/mtk-eip93/Kconfig | 49 ++ drivers/crypto/mtk-eip93/Makefile | 7 + drivers/crypto/mtk-eip93/eip93-aead.c | 767 +++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-aead.h | 43 ++ drivers/crypto/mtk-eip93/eip93-aes.h | 15 + drivers/crypto/mtk-eip93/eip93-cipher.c | 399 ++++++++++++ drivers/crypto/mtk-eip93/eip93-cipher.h | 62 ++ drivers/crypto/mtk-eip93/eip93-common.c | 784 ++++++++++++++++++++++++ drivers/crypto/mtk-eip93/eip93-common.h | 34 + drivers/crypto/mtk-eip93/eip93-des.h | 15 + drivers/crypto/mtk-eip93/eip93-main.c | 458 ++++++++++++++ drivers/crypto/mtk-eip93/eip93-main.h | 146 +++++ drivers/crypto/mtk-eip93/eip93-regs.h | 382 ++++++++++++ 15 files changed, 3164 insertions(+) create mode 100644 drivers/crypto/mtk-eip93/Kconfig create mode 100644 drivers/crypto/mtk-eip93/Makefile create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.c create mode 100644 drivers/crypto/mtk-eip93/eip93-aead.h create mode 100644 drivers/crypto/mtk-eip93/eip93-aes.h create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.c create mode 100644 drivers/crypto/mtk-eip93/eip93-cipher.h create mode 100644 drivers/crypto/mtk-eip93/eip93-common.c create mode 100644 drivers/crypto/mtk-eip93/eip93-common.h create mode 100644 drivers/crypto/mtk-eip93/eip93-des.h create mode 100644 drivers/crypto/mtk-eip93/eip93-main.c create mode 100644 drivers/crypto/mtk-eip93/eip93-main.h create mode 100644 drivers/crypto/mtk-eip93/eip93-regs.h
drivers/crypto/Kconfig +2 -0
@@ -912,4 +912,6 @@ config CRYPTO_DEV_SA2UL source "drivers/crypto/keembay/Kconfig" +source "drivers/crypto/mtk-eip93/Kconfig" + endif # CRYPTO_HW
drivers/crypto/Makefile +1 -0
@@ -51,3 +51,4 @@ obj-$(CONFIG_CRYPTO_DEV_ZYNQMP_AES) += xilinx/ obj-y += hisilicon/ obj-$(CONFIG_CRYPTO_DEV_AMLOGIC_GXL) += amlogic/ obj-y += keembay/ +obj-$(CONFIG_CRYPTO_DEV_EIP93) += mtk-eip93/
drivers/crypto/mtk-eip93/Kconfig new file +49 -0
49 lines not on this page · raw message
drivers/crypto/mtk-eip93/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +obj-$(CONFIG_CRYPTO_DEV_EIP93) += crypto-hw-eip93.o + +crypto-hw-eip93-y += eip93-main.o eip93-common.o + +crypto-hw-eip93-$(CONFIG_CRYPTO_DEV_EIP93_SKCIPHER) += eip93-cipher.o +crypto-hw-eip93-$(CONFIG_CRYPTO_DEV_EIP93_AEAD) += eip93-aead.o +
drivers/crypto/mtk-eip93/eip93-aead.c new file +767 -0
767 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-aead.h new file +43 -0
43 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-aes.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ +#ifndef _EIP93_AES_H_ +#define _EIP93_AES_H_ + +extern struct mtk_alg_template mtk_alg_ecb_aes; +extern struct mtk_alg_template mtk_alg_cbc_aes; +extern struct mtk_alg_template mtk_alg_ctr_aes; +extern struct mtk_alg_template mtk_alg_rfc3686_aes; + +#endif /* _EIP93_AES_H_ */
drivers/crypto/mtk-eip93/eip93-cipher.c new file +399 -0
399 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-cipher.h new file +62 -0
62 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-common.c new file +784 -0
784 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-common.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ + +#ifndef _EIP93_COMMON_H_ +#define _EIP93_COMMON_H_ + +inline int mtk_put_descriptor (struct mtk_device *mtk, +struct eip93_descriptor_s *desc); + +inline void *mtk_get_descriptor (struct mtk_device *mtk); + +inline int mtk_get_free_saState (struct mtk_device *mtk); + +void mtk_set_saRecord (struct saRecord_s *saRecord,const unsigned int keylen, +const u32 flags); + +#if IS_ENABLED (CONFIG_CRYPTO_DEV_EIP93_SKCIPHER ) +int mtk_skcipher_send_req (struct crypto_async_request *async); + +void mtk_skcipher_handle_result (struct mtk_device *mtk, +struct crypto_async_request *async, +int err); +#endif + +#if IS_ENABLED (CONFIG_CRYPTO_DEV_EIP93_HMAC ) +int mtk_authenc_setkey (struct crypto_shash *cshash,struct saRecord_s *sa, +const u8 *authkey,unsigned int authkeylen); +#endif + +#endif /* _EIP93_COMMON_H_ */
drivers/crypto/mtk-eip93/eip93-des.h new file +15 -0
@@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 +* +* Copyright (C) 2019 - 2021 +* +* Richard van Schagen <[email protected]> +*/ +#ifndef _EIP93_DES_H_ +#define _EIP93_DES_H_ + +extern struct mtk_alg_template mtk_alg_ecb_des; +extern struct mtk_alg_template mtk_alg_cbc_des; +extern struct mtk_alg_template mtk_alg_ecb_des3_ede; +extern struct mtk_alg_template mtk_alg_cbc_des3_ede; + +#endif /* _EIP93_DES_H_ */
drivers/crypto/mtk-eip93/eip93-main.c new file +458 -0
458 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-main.h new file +146 -0
146 lines not on this page · raw message
drivers/crypto/mtk-eip93/eip93-regs.h new file +382 -0
211 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.2
Part of the diff is not shown here. View the raw message.
kernel test robot
build botRe: [PATCH v3 2/2] crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
Thank you for the patch! Perhaps something to improve:
Hi Richard,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master robh/for-next v5.15-rc7 next-20211027] [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/Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: arm-randconfig-r001-20211027 (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/b4ea2578718d77c7cbac42427a511182d91ac5f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 git checkout b4ea2578718d77c7cbac42427a511182d91ac5f1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/crypto/mtk-eip93/eip93-common.c:282:6: warning: no previous prototype for 'mtk_set_saRecord' [-Wmissing-prototypes]
282 | void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen,
| ^~~~~~~~~~~~~~~~
vim +/mtk_set_saRecord +282 drivers/crypto/mtk-eip93/eip93-common.c
196
197 int check_valid_request(struct mtk_cipher_reqctx *rctx)
198 {
199 struct scatterlist *src = rctx->sg_src;
200 struct scatterlist *dst = rctx->sg_dst;
201 uint32_t src_nents, dst_nents;
202 u32 textsize = rctx->textsize;
203 u32 authsize = rctx->authsize;
204 u32 blksize = rctx->blksize;
205 u32 totlen_src = rctx->assoclen + rctx->textsize;
206 u32 totlen_dst = rctx->assoclen + rctx->textsize;
207 u32 copy_len;
208 bool src_align, dst_align;
209 int err = -EINVAL;
210
211 if (!IS_CTR(rctx->flags)) {
212 if (!IS_ALIGNED(textsize, blksize))
213 return err;
214 }
215
216 if (authsize) {
217 if (IS_ENCRYPT(rctx->flags))
218 totlen_dst += authsize;
219 else
220 totlen_src += authsize;
221 }
222
223 src_nents = sg_nents_for_len(src, totlen_src);
224 dst_nents = sg_nents_for_len(dst, totlen_dst);
225
226 if (src == dst) {
227 src_nents = max(src_nents, dst_nents);
228 dst_nents = src_nents;
229 if (unlikely((totlen_src || totlen_dst) && (src_nents <= 0)))
230 return err;
231
232 } else {
233 if (unlikely(totlen_src && (src_nents <= 0)))
234 return err;
235
236 if (unlikely(totlen_dst && (dst_nents <= 0)))
237 return err;
238 }
239
240 if (authsize) {
241 if (dst_nents == 1 && src_nents == 1) {
242 src_align = mtk_is_sg_aligned(src, totlen_src, blksize);
243 if (src == dst)
244 dst_align = src_align;
245 else
246 dst_align = mtk_is_sg_aligned(dst,
247 totlen_dst, blksize);
248 } else {
249 src_align = false;
250 dst_align = false;
251 }
252 } else {
253 src_align = mtk_is_sg_aligned(src, totlen_src, blksize);
254 if (src == dst)
255 dst_align = src_align;
256 else
257 dst_align = mtk_is_sg_aligned(dst, totlen_dst, blksize);
258 }
259
260 copy_len = max(totlen_src, totlen_dst);
261 if (!src_align) {
262 err = mtk_make_sg_copy(src, &rctx->sg_src, copy_len, true);
263 if (err)
264 return err;
265 }
266
267 if (!dst_align) {
268 err = mtk_make_sg_copy(dst, &rctx->sg_dst, copy_len, false);
269 if (err)
270 return err;
271 }
272
273 rctx->src_nents = sg_nents_for_len(rctx->sg_src, totlen_src);
274 rctx->dst_nents = sg_nents_for_len(rctx->sg_dst, totlen_dst);
275
276 return 0;
277 }
278 /*
279 * Set saRecord function:
280 * Even saRecord is set to "0", keep " = 0" for readability.
281 */
> 282 void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen,
283 const u32 flags)
284 {
285 saRecord->saCmd0.bits.ivSource = 2;
286 if (IS_ECB(flags))
287 saRecord->saCmd0.bits.saveIv = 0;
288 else
289 saRecord->saCmd0.bits.saveIv = 1;
290
291 saRecord->saCmd0.bits.opGroup = 0;
292 saRecord->saCmd0.bits.opCode = 0;
293
294 switch ((flags & MTK_ALG_MASK)) {
295 case MTK_ALG_AES:
296 saRecord->saCmd0.bits.cipher = 3;
297 saRecord->saCmd1.bits.aesKeyLen = keylen >> 3;
298 break;
299 case MTK_ALG_3DES:
300 saRecord->saCmd0.bits.cipher = 1;
301 break;
302 case MTK_ALG_DES:
303 saRecord->saCmd0.bits.cipher = 0;
304 break;
305 default:
306 saRecord->saCmd0.bits.cipher = 15;
307 }
308
309 switch ((flags & MTK_HASH_MASK)) {
310 case MTK_HASH_SHA256:
311 saRecord->saCmd0.bits.hash = 3;
312 break;
313 case MTK_HASH_SHA224:
314 saRecord->saCmd0.bits.hash = 2;
315 break;
316 case MTK_HASH_SHA1:
317 saRecord->saCmd0.bits.hash = 1;
318 break;
319 case MTK_HASH_MD5:
320 saRecord->saCmd0.bits.hash = 0;
321 break;
322 default:
323 saRecord->saCmd0.bits.hash = 15;
324 }
325
326 saRecord->saCmd0.bits.hdrProc = 0;
327 saRecord->saCmd0.bits.padType = 3;
328 saRecord->saCmd0.bits.extPad = 0;
329 saRecord->saCmd0.bits.scPad = 0;
330
331 switch ((flags & MTK_MODE_MASK)) {
332 case MTK_MODE_CBC:
333 saRecord->saCmd1.bits.cipherMode = 1;
334 break;
335 case MTK_MODE_CTR:
336 saRecord->saCmd1.bits.cipherMode = 2;
337 break;
338 case MTK_MODE_ECB:
339 saRecord->saCmd1.bits.cipherMode = 0;
340 break;
341 }
342
343 saRecord->saCmd1.bits.byteOffset = 0;
344 saRecord->saCmd1.bits.hashCryptOffset = 0;
345 saRecord->saCmd0.bits.digestLength = 0;
346 saRecord->saCmd1.bits.copyPayload = 0;
347
348 if (IS_HMAC(flags)) {
349 saRecord->saCmd1.bits.hmac = 1;
350 saRecord->saCmd1.bits.copyDigest = 1;
351 saRecord->saCmd1.bits.copyHeader = 1;
352 } else {
353 saRecord->saCmd1.bits.hmac = 0;
354 saRecord->saCmd1.bits.copyDigest = 0;
355 saRecord->saCmd1.bits.copyHeader = 0;
356 }
357
358 /* Default for now, might be used for ESP offload */
359 saRecord->saCmd1.bits.seqNumCheck = 0;
360 saRecord->saSpi = 0x0;
361 saRecord->saSeqNumMask[0] = 0xFFFFFFFF;
362 saRecord->saSeqNumMask[1] = 0x0;
363 }
364
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH v3 2/2] crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
In reply to Richard van SchagenThank you for the patch! Perhaps something to improve:
Hi Richard,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master robh/for-next v5.15-rc7 next-20211027] [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/Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: riscv-randconfig-r031-20211027 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/b4ea2578718d77c7cbac42427a511182d91ac5f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 git checkout b4ea2578718d77c7cbac42427a511182d91ac5f1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from drivers/crypto/mtk-eip93/eip93-common.c:15:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from drivers/crypto/mtk-eip93/eip93-common.c:15:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from drivers/crypto/mtk-eip93/eip93-common.c:15:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
drivers/crypto/mtk-eip93/eip93-common.c:282:6: warning: no previous prototype for function 'mtk_set_saRecord' [-Wmissing-prototypes]
void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen,
^
drivers/crypto/mtk-eip93/eip93-common.c:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen,
^
static
drivers/crypto/mtk-eip93/eip93-common.c:527:18: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const u8 *' (aka 'const unsigned char *') [-Wpointer-to-int-cast]
if (!IS_ALIGNED((u32)reqiv, rctx->ivsize) || IS_RFC3686(flags)) {
^~~~~~~~~~
include/linux/align.h:13:30: note: expanded from macro 'IS_ALIGNED'
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
^
drivers/crypto/mtk-eip93/eip93-common.c:527:18: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const u8 *' (aka 'const unsigned char *') [-Wpointer-to-int-cast]
if (!IS_ALIGNED((u32)reqiv, rctx->ivsize) || IS_RFC3686(flags)) {
^~~~~~~~~~
include/linux/align.h:13:44: note: expanded from macro 'IS_ALIGNED'
#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
^
drivers/crypto/mtk-eip93/eip93-common.c:593:19: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'struct crypto_async_request *' [-Wpointer-to-int-cast]
cdesc.arc4Addr = (u32)async;
^~~~~~~~~~
drivers/crypto/mtk-eip93/eip93-common.c:693:5: warning: no previous prototype for function 'mtk_skcipher_send_req' [-Wmissing-prototypes]
int mtk_skcipher_send_req(struct crypto_async_request *async)
^
drivers/crypto/mtk-eip93/eip93-common.c:693:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int mtk_skcipher_send_req(struct crypto_async_request *async)
^
static
drivers/crypto/mtk-eip93/eip93-common.c:709:6: warning: no previous prototype for function 'mtk_skcipher_handle_result' [-Wmissing-prototypes]
void mtk_skcipher_handle_result(struct mtk_device *mtk,
^
drivers/crypto/mtk-eip93/eip93-common.c:709:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void mtk_skcipher_handle_result(struct mtk_device *mtk,
^
static
>> drivers/crypto/mtk-eip93/eip93-common.c:725:5: warning: no previous prototype for function 'mtk_authenc_setkey' [-Wmissing-prototypes]
int mtk_authenc_setkey(struct crypto_shash *cshash, struct saRecord_s *sa,
^ drivers/crypto/mtk-eip93/eip93-common.c:725:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int mtk_authenc_setkey(struct crypto_shash *cshash, struct saRecord_s *sa,
^
static
14 warnings generated.
--
In file included from drivers/crypto/mtk-eip93/eip93-aead.c:24:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
^
In file included from drivers/crypto/mtk-eip93/eip93-aead.c:24:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
^
In file included from drivers/crypto/mtk-eip93/eip93-aead.c:24:
In file included from include/linux/dma-mapping.h:10:
In file included from include/linux/scatterlist.h:9:
In file included from arch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
~~~~~~~~~~ ^
>> drivers/crypto/mtk-eip93/eip93-aead.c:30:6: warning: no previous prototype for function 'mtk_aead_handle_result' [-Wmissing-prototypes]
void mtk_aead_handle_result(struct mtk_device *mtk,
^
drivers/crypto/mtk-eip93/eip93-aead.c:30:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void mtk_aead_handle_result(struct mtk_device *mtk,
^
static
>> drivers/crypto/mtk-eip93/eip93-aead.c:49:5: warning: no previous prototype for function 'mtk_aead_send_req' [-Wmissing-prototypes]
int mtk_aead_send_req(struct crypto_async_request *async)
^
drivers/crypto/mtk-eip93/eip93-aead.c:49:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int mtk_aead_send_req(struct crypto_async_request *async)
^
static
>> drivers/crypto/mtk-eip93/eip93-aead.c:152:7: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (keys.enckeylen < CTR_RFC3686_NONCE_SIZE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/crypto/mtk-eip93/eip93-aead.c:209:9: note: uninitialized use occurs here
return err;
^~~
drivers/crypto/mtk-eip93/eip93-aead.c:152:3: note: remove the 'if' if its condition is always false
if (keys.enckeylen < CTR_RFC3686_NONCE_SIZE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/crypto/mtk-eip93/eip93-aead.c:145:9: note: initialize the variable 'err' to silence this warning
int err;
^
= 010 warnings generated.
vim +/mtk_authenc_setkey +725 drivers/crypto/mtk-eip93/eip93-common.c
708
> 709 void mtk_skcipher_handle_result(struct mtk_device *mtk,
710 struct crypto_async_request *async,
711 int err)
712 {
713 struct skcipher_request *req = skcipher_request_cast(async);
714 struct mtk_cipher_reqctx *rctx = skcipher_request_ctx(req);
715
716 mtk_unmap_dma(mtk, rctx, req->src, req->dst);
717 mtk_handle_result(mtk, rctx, req->iv);
718
719 skcipher_request_complete(req, err);
720 }
721 #endif
722
723 #if IS_ENABLED(CONFIG_CRYPTO_DEV_EIP93_HMAC)
724 /* basically this is set hmac - key */
> 725 int mtk_authenc_setkey(struct crypto_shash *cshash, struct saRecord_s *sa,---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v3 2/2] crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
Hi All,
Before I send another version of this patch I have one question:
I am seeing /warnings from arch/riscv/include/asm/io.h
In my Kconfig I have: depends on SOC_MT7621 || COMPILE_TEST
I need to keep the include/linux/dma-mapping.h so should I remove the COMPILE_TEST or can I safely ignore those warnings?
Thanks,
Richard van Schagen
Quoted 211 lines · kernel test robot
Hi Richard,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master robh/for-next v5.15-rc7 next-20211027] [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/Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: riscv-randconfig-r031-20211027 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/b4ea2578718d77c7cbac42427a511182d91ac5f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 git checkoutb4ea2578718d77c7cbac42427a511182d91ac5f1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=riscvIf you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>All warnings (new ones prefixed by >>):
In file included from
drivers/crypto/mtk-eip93/eip93-common.c:15:
In file included frominclude/linux/dma-mapping.h:10:
In file included frominclude/linux/scatterlist.h:9:
In file included fromarch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from drivers/crypto/mtk-eip93/eip93-common.c:15: In file included from include/linux/dma-mapping.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from drivers/crypto/mtk-eip93/eip93-common.c:15: In file included from include/linux/dma-mapping.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; ~~~~~~~~~~ ^ drivers/crypto/mtk-eip93/eip93-common.c:282:6: warning: no previous prototype for function 'mtk_set_saRecord' [-Wmissing-prototypes] void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen, ^ drivers/crypto/mtk-eip93/eip93-common.c:282:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void mtk_set_saRecord(struct saRecord_s *saRecord, const unsigned int keylen, ^ static drivers/crypto/mtk-eip93/eip93-common.c:527:18: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const u8 *' (aka 'const unsigned char *') [-Wpointer-to-int-cast] if (!IS_ALIGNED((u32)reqiv, rctx->ivsize) || IS_RFC3686(flags)) { ^~~~~~~~~~ include/linux/align.h:13:30: note: expanded from macro 'IS_ALIGNED' #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) ^ drivers/crypto/mtk-eip93/eip93-common.c:527:18: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'const u8 *' (aka 'const unsigned char *') [-Wpointer-to-int-cast] if (!IS_ALIGNED((u32)reqiv, rctx->ivsize) || IS_RFC3686(flags)) { ^~~~~~~~~~ include/linux/align.h:13:44: note: expanded from macro 'IS_ALIGNED' #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) ^ drivers/crypto/mtk-eip93/eip93-common.c:593:19: warning: cast to smaller integer type 'u32' (aka 'unsigned int') from 'struct crypto_async_request *' [-Wpointer-to-int-cast] cdesc.arc4Addr = (u32)async; ^~~~~~~~~~ drivers/crypto/mtk-eip93/eip93-common.c:693:5: warning: no previous prototype for function 'mtk_skcipher_send_req' [-Wmissing-prototypes] int mtk_skcipher_send_req(struct crypto_async_request *async) ^ drivers/crypto/mtk-eip93/eip93-common.c:693:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int mtk_skcipher_send_req(struct crypto_async_request *async) ^ static drivers/crypto/mtk-eip93/eip93-common.c:709:6: warning: no previous prototype for function 'mtk_skcipher_handle_result' [-Wmissing-prototypes] void mtk_skcipher_handle_result(struct mtk_device *mtk, ^
drivers/crypto/mtk-eip93/eip93-common.c:709:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void mtk_skcipher_handle_result(structmtk_device*mtk,
^
staticQuoted 1 line
Quoted 1 line
drivers/crypto/mtk-eip93/eip93-common.c:725:5: warning: no previous prototype for function 'mtk_authenc_setkey' [-Wmissing-prototypes]int mtk_authenc_setkey(struct
crypto_shash*cshash, structsaRecord_s*sa,^
drivers/crypto/mtk-eip93/eip93-common.c:725:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int mtk_authenc_setkey(structcrypto_shash*cshash, structsaRecord_s*sa,
^
static
14 warnings generated.
--
In file included fromdrivers/crypto/mtk-eip93/eip93-aead.c:24:
In file included frominclude/linux/dma-mapping.h:10:
In file included frominclude/linux/scatterlist.h:9:
In file included fromarch/riscv/include/asm/io.h:136:
include/asm-generic/io.h:464:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]val = __raw_readb(PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:477:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu' #define __le16_to_cpu(x) ((__force __u16)(__le16)(x)) ^ In file included from drivers/crypto/mtk-eip93/eip93-aead.c:24: In file included from include/linux/dma-mapping.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:490:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr)); ~~~~~~~~~~ ^ include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu' #define __le32_to_cpu(x) ((__force __u32)(__le32)(x)) ^ In file included from drivers/crypto/mtk-eip93/eip93-aead.c:24: In file included from include/linux/dma-mapping.h:10: In file included from include/linux/scatterlist.h:9: In file included from arch/riscv/include/asm/io.h:136: include/asm-generic/io.h:501:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writeb(value, PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:511:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:521:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr); ~~~~~~~~~~ ^ include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port; ~~~~~~~~~~ ^Quoted 1 line
Quoted 1 line
drivers/crypto/mtk-eip93/eip93-aead.c:30:6: warning: no previous prototype for function 'mtk_aead_handle_result' [-Wmissing-prototypes]void mtk_aead_handle_result(struct
mtk_device*mtk,^
drivers/crypto/mtk-eip93/eip93-aead.c:30:1: note: declare 'static' if the function is not intended to be used outside of this translation unit void mtk_aead_handle_result(structmtk_device*mtk,
^
staticQuoted 1 line
Quoted 1 line
drivers/crypto/mtk-eip93/eip93-aead.c:49:5: warning: no previous prototype for function 'mtk_aead_send_req' [-Wmissing-prototypes]int
mtk_aead_send_req(struct crypto_async_request *async)^
drivers/crypto/mtk-eip93/eip93-aead.c:49:1: note: declare 'static' if the function is not intended to be used outside of this translation unit intmtk_aead_send_req(struct crypto_async_request *async)
^
staticQuoted 1 line
Quoted 1 line
drivers/crypto/mtk-eip93/eip93-aead.c:152:7: warning: variable 'err' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]if (keys.enckeylen <
CTR_RFC3686_NONCE_SIZE)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/crypto/mtk-eip93/eip93-aead.c:209:9: note: uninitialized use occurs herereturn err; ^~~ drivers/crypto/mtk-eip93/eip93-aead.c:152:3: note: remove the 'if' if its condition is always false if (keys.enckeylen < CTR_RFC3686_NONCE_SIZE) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/crypto/mtk-eip93/eip93-aead.c:145:9: note: initialize the variable 'err' to silence this warning int err; ^ = 010 warnings generated.
vim +/mtk_authenc_setkey +725
drivers/crypto/mtk-eip93/eip93-common.c708
Quoted 1 line
709 void mtk_skcipher_handle_result(struct
mtk_device*mtk,710 struct
crypto_async_request*async,
711 int err)
712 {
713 structskcipher_request*req =skcipher_request_cast(async);
714 structmtk_cipher_reqctx*rctx =skcipher_request_ctx(req);
715
716mtk_unmap_dma(mtk, rctx, req->src, req->dst);
717mtk_handle_result(mtk, rctx, req->iv);
718
719skcipher_request_complete(req, err);
720 }
721 #endif
722
723 #ifIS_ENABLED(CONFIG_CRYPTO_DEV_EIP93_HMAC)
724 /* basically this is set hmac - key */Quoted 1 line
725 int mtk_authenc_setkey(struct
crypto_shash*cshash, structsaRecord_s*sa,---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
<.config.gz>
kernel test robot
build botRe: [PATCH v3 2/2] crypto: mtk-eip93 - Add Mediatek EIP-93 crypto engine
In reply to Richard van SchagenThank you for the patch! Perhaps something to improve:
Hi Richard,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on herbert-cryptodev-2.6/master]
[also build test WARNING on herbert-crypto-2.6/master robh/for-next v5.15-rc7 next-20211027] [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/Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: arm64-randconfig-s031-20211027 (attached as .config) compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/b4ea2578718d77c7cbac42427a511182d91ac5f1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Richard-van-Schagen/Enable-the-Mediatek-EIP-93-crypto-engine/20211027-171429 git checkout b4ea2578718d77c7cbac42427a511182d91ac5f1
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/crypto/mtk-eip93/eip93-common.c:551:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted __be32 [usertype] @@ drivers/crypto/mtk-eip93/eip93-common.c:551:37: sparse: expected unsigned int drivers/crypto/mtk-eip93/eip93-common.c:551:37: sparse: got restricted __be32 [usertype] >> drivers/crypto/mtk-eip93/eip93-common.c:555:23: sparse: sparse: cast to restricted __be32 drivers/crypto/mtk-eip93/eip93-common.c:658:43: sparse: sparse: cast to restricted __be32 >> drivers/crypto/mtk-eip93/eip93-common.c:527:14: sparse: sparse: non size-preserving pointer to integer cast
drivers/crypto/mtk-eip93/eip93-common.c:593:31: sparse: sparse: non size-preserving pointer to integer cast
vim +551 drivers/crypto/mtk-eip93/eip93-common.c
500
501 int mtk_send_req(struct crypto_async_request *async,
502 const u8 *reqiv, struct mtk_cipher_reqctx *rctx)
503 {
504 struct mtk_crypto_ctx *ctx = crypto_tfm_ctx(async->tfm);
505 struct mtk_device *mtk = ctx->mtk;
506 struct scatterlist *src = rctx->sg_src;
507 struct scatterlist *dst = rctx->sg_dst;
508 struct saState_s *saState;
509 struct mtk_state_pool *saState_pool;
510 struct eip93_descriptor_s cdesc;
511 u32 flags = rctx->flags;
512 int idx;
513 int offsetin = 0, err = -ENOMEM;
514 u32 datalen = rctx->assoclen + rctx->textsize;
515 u32 split = datalen;
516 u32 start, end, ctr, blocks;
517 u32 iv[AES_BLOCK_SIZE / sizeof(u32)];
518
519 rctx->saState_ctr = NULL;
520 rctx->saState = NULL;
521
522 if (IS_ECB(flags))
523 goto skip_iv;
524
525 memcpy(iv, reqiv, rctx->ivsize);
526
> 527 if (!IS_ALIGNED((u32)reqiv, rctx->ivsize) || IS_RFC3686(flags)) {
528 rctx->flags &= ~MTK_DESC_DMA_IV;
529 flags = rctx->flags;
530 }
531
532 if (IS_DMA_IV(flags)) {
533 rctx->saState = (void *)reqiv;
534 } else {
535 idx = mtk_get_free_saState(mtk);
536 if (idx < 0)
537 goto send_err;
538 saState_pool = &mtk->ring->saState_pool[idx];
539 rctx->saState_idx = idx;
540 rctx->saState = saState_pool->base;
541 rctx->saState_base = saState_pool->base_dma;
542 memcpy(rctx->saState->stateIv, iv, rctx->ivsize);
543 }
544
545 saState = rctx->saState;
546
547 if (IS_RFC3686(flags)) {
548 saState->stateIv[0] = ctx->saNonce;
549 saState->stateIv[1] = iv[0];
550 saState->stateIv[2] = iv[1];
> 551 saState->stateIv[3] = cpu_to_be32(1);
552 } else if (!IS_HMAC(flags) && IS_CTR(flags)) {
553 /* Compute data length. */
554 blocks = DIV_ROUND_UP(rctx->textsize, AES_BLOCK_SIZE);
> 555 ctr = be32_to_cpu(iv[3]); 556 /* Check 32bit counter overflow. */
557 start = ctr;
558 end = start + blocks - 1;
559 if (end < start) {
560 split = AES_BLOCK_SIZE * -start;
561 /*
562 * Increment the counter manually to cope with
563 * the hardware counter overflow.
564 */
565 iv[3] = 0xffffffff;
566 crypto_inc((u8 *)iv, AES_BLOCK_SIZE);
567 idx = mtk_get_free_saState(mtk);
568 if (idx < 0)
569 goto free_state;
570 saState_pool = &mtk->ring->saState_pool[idx];
571 rctx->saState_ctr_idx = idx;
572 rctx->saState_ctr = saState_pool->base;
573 rctx->saState_base_ctr = saState_pool->base_dma;
574
575 memcpy(rctx->saState_ctr->stateIv, reqiv, rctx->ivsize);
576 memcpy(saState->stateIv, iv, rctx->ivsize);
577 }
578 }
579
580 if (IS_DMA_IV(flags)) {
581 rctx->saState_base = dma_map_single(mtk->dev, (void *)reqiv,
582 rctx->ivsize, DMA_TO_DEVICE);
583 if (dma_mapping_error(mtk->dev, rctx->saState_base))
584 goto free_state;
585 }
586 skip_iv:
587 cdesc.peCrtlStat.bits.hostReady = 1;
588 cdesc.peCrtlStat.bits.prngMode = 0;
589 cdesc.peCrtlStat.bits.hashFinal = 0;
590 cdesc.peCrtlStat.bits.padCrtlStat = 0;
591 cdesc.peCrtlStat.bits.peReady = 0;
592 cdesc.saAddr = rctx->saRecord_base;
593 cdesc.arc4Addr = (u32)async;
594 if (ctx->type == MTK_ALG_TYPE_AEAD)
595 cdesc.userId = MTK_DESC_AEAD;
596 else
597 cdesc.userId = MTK_DESC_SKCIPHER;
598 rctx->cdesc = &cdesc;
599
600 /* map DMA_BIDIRECTIONAL to invalidate cache on destination
601 * implies __dma_cache_wback_inv
602 */
603 dma_map_sg(mtk->dev, dst, rctx->dst_nents, DMA_BIDIRECTIONAL);
604 if (src != dst)
605 dma_map_sg(mtk->dev, src, rctx->src_nents, DMA_TO_DEVICE);
606
607 err = mtk_scatter_combine(mtk, rctx, datalen, split, offsetin);
608
609 return err;
610
611 free_state:
612 if (rctx->saState) {
613 saState_pool = &mtk->ring->saState_pool[rctx->saState_idx];
614 saState_pool->in_use = false;
615 }
616
617 if (rctx->saState_ctr) {
618 saState_pool = &mtk->ring->saState_pool[rctx->saState_ctr_idx];
619 saState_pool->in_use = false;
620 }
621 send_err:
622 return err;
623 }
624
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org