Skip to content

Conversation

@ThePassionate
Copy link
Contributor

Summary

This PR includes four improvements to the NuttX crypto subsystem:

  1. Add olen field for virtio mode support - Add olen field to crypt_op structure and crp_olen to cryptop structure to support output length tracking in virtio crypto mode.

  2. Export ivlen to support different cipher algorithms - Add ivlen field to crypt_op and crp_ivlen to cryptop structure to support cipher algorithms with different IV lengths.

  3. Optimize cryptodev without dynamic memory - Replace dynamic memory allocation with stack-based variables in cryptodev_op(). This eliminates kmm_malloc/kmm_free overhead and simplifies error handling by removing the need for goto bail cleanup paths.

  4. Determine the order of crypto drivers - After adding the cross-core crypto driver, there are now three encryption modes:

    • Hardware driver in local core
    • Crypto driver in remote core
    • Software encryption in local core

    This prioritizes local hardware driver first, then remote driver (typically hardware), and finally local software encryption as a fallback.

Impact

These changes improve crypto subsystem flexibility, performance, and support for virtio-based crypto operations.

Testing

Build and runtime tested on NuttX with software crypto drivers.

@github-actions github-actions bot added Area: Crypto Size: M The size of the change in this PR is medium labels Jan 20, 2026
@wangchdo
Copy link
Contributor

This CI error seems to be occurring in every PR:

Configuration/Tool: qemu-armv8a/rpproxy
2026-01-20 04:31:48
------------------------------------------------------------------------------------
  Cleaning...
/github/workspace/sources/apps/Application.mk:238: target 'signest.c.github.workspace.sources.apps.testing.ostest.o' given more than once in the same rule
/github/workspace/sources/apps/Application.mk:238: target 'signest.c.github.workspace.sources.apps.testing.ostest.o' given more than once in the same rule
  Configuring...
  Building NuttX...
cu_main.c: In function 'sigint':
Error: cu_main.c:128:33: error: 'siginfo' undeclared (first use in this function)
  128 |   FAR struct cu_globals_s *cu = siginfo->si_user;
      |                                 ^~~~~~~
cu_main.c:128:33: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/github/workspace/sources/apps/Application.mk:330: cu_main.c.github.workspace.sources.apps.system.cu.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:54: /github/workspace/sources/apps/system/cu_all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [tools/LibTargets.mk:248: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory

@xiaoxiang781216
Copy link
Contributor

@ThePassionate please fix the break as soon as possible.

@xiaoxiang781216
Copy link
Contributor

This CI error seems to be occurring in every PR:

Configuration/Tool: qemu-armv8a/rpproxy
2026-01-20 04:31:48
------------------------------------------------------------------------------------
  Cleaning...
/github/workspace/sources/apps/Application.mk:238: target 'signest.c.github.workspace.sources.apps.testing.ostest.o' given more than once in the same rule
/github/workspace/sources/apps/Application.mk:238: target 'signest.c.github.workspace.sources.apps.testing.ostest.o' given more than once in the same rule
  Configuring...
  Building NuttX...
cu_main.c: In function 'sigint':
Error: cu_main.c:128:33: error: 'siginfo' undeclared (first use in this function)
  128 |   FAR struct cu_globals_s *cu = siginfo->si_user;
      |                                 ^~~~~~~
cu_main.c:128:33: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/github/workspace/sources/apps/Application.mk:330: cu_main.c.github.workspace.sources.apps.system.cu.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:54: /github/workspace/sources/apps/system/cu_all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [tools/LibTargets.mk:248: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 385: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory

it's strange why apache/nuttx-apps#3314 pass ci.

Add olen field to crypt_op structure and crp_olen to cryptop structure
to support output length tracking in virtio crypto mode.

Signed-off-by: makejian <makejian@xiaomi.com>
Add ivlen field to crypt_op and crp_ivlen to cryptop structure to support
cipher algorithms with different IV lengths.

Signed-off-by: makejian <makejian@xiaomi.com>
Replace dynamic memory allocation with stack-based variables in cryptodev_op().
This eliminates kmm_malloc/kmm_free overhead and simplifies error handling
by removing the need for goto bail cleanup paths.

Signed-off-by: makejian <makejian@xiaomi.com>
After adding the cross-core crypto driver, there are now three encryption modes:
1. Hardware driver in local core
2. Crypto driver in remote core
3. Software encryption in local core

This prioritizes local hardware driver first, then remote driver (typically hardware),
and finally local software encryption as a fallback.

Signed-off-by: makejian <makejian@xiaomi.com>
@ThePassionate ThePassionate force-pushed the crypto-optimize-drivers branch from 4825783 to 41e7c2f Compare January 20, 2026 12:35
@xiaoxiang781216 xiaoxiang781216 merged commit 5b52a32 into apache:master Jan 20, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Crypto Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants