Skip to content

Protect: use userspace to get built-in information - #20964

Merged
acassis merged 2 commits into
apache:masterfrom
JianyuWang0623:mars538-protected-builtins
Oct 25, 2026
Merged

acassis merged 2 commits into
apache:masterfrom
JianyuWang0623:mars538-protected-builtins

Conversation

@JianyuWang0623

@JianyuWang0623 JianyuWang0623 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

In a protected build the kernel cannot see the user-space builtin list, so posix_spawnp() of a builtin fails with ENOENT unless user space first calls boardctl(BOARDIOC_BUILTINS). With nxinit as init, every service fails to start and there is no shell.
This series publishes the builtin table through struct userspace_s instead, and removes BOARDIOC_BUILTINS and builtin_setlist().

Impact

  • Protected builds: builtins can be spawned without any user-space registration. Flat/kernel builds unchanged.
  • ABI: BOARDIOC_BUILTINS removed and later BOARDIOC_* renumbered; struct userspace_s gains two fields.
  • All 46 in-tree kernel/*_userspace.c updated.

Testing

rv-virt:pnsh (protected + nxinit + ostest) on qemu-system-riscv32, apps at upstream master.

Before (master d17f5c91e4f), no shell:

ABCDError Starting service 'console': 2
Error Starting service 'console': 2
Error Starting service 'console': 2
Error Starting service 'console': 2
...

After (this PR):

ABCDnsh> ostest
stdio_test: Standard I/O Check: printf
ostest_main: Started user_main at PID=5
user_main: vfork() test
vfork_test: Child 6 ran and exited before the parent resumed
...
Final memory usage:
VARIABLE  BEFORE   AFTER
======== ======== ========
arena       ff1b0    ff1b0
ordblks         5        8
mxordblk    f5ff8    f0ff8
uordblks     5d10     7d30
fordblks    f94a0    f7480
user_main: Exiting
ostest_main: Exiting with status 0
nsh>

esp32s3-devkit:knsh (protected + nxinit + ostest) on an ESP32-S3-WROOM-1 board:

I (147) boot: Loaded app from partition at offset 0x10000
I (147) boot: Disabling RNG early entropy source...
nsh> ostest
...
user_main: Exiting
ostest_main: Exiting with status 0

Also built esp32s3-devkit:knsh (each commit), imxrt1050-evk:knsh, esp32s3-devkit:nsh; checkpatch.sh -c -u -m -g passes.

anjiahao1 and others added 2 commits October 24, 2026 21:09
…ormation

Get the builtin list from USERSPACE instead of BOARDIOC_BUILTINS.

Signed-off-by: anjiahao <[email protected]>
Signed-off-by: wangjianyu3 <[email protected]>
use forward declare to prevent circular dependency

Signed-off-by: yangao1 <[email protected]>
Signed-off-by: wangjianyu3 <[email protected]>
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report · Explore what changed →

esp32-devkitc

  • ROM: .flash.text -16 B (-0.0%, 127,476 B / 4,194,272 B, total: 3% used)
  • irom0_0_seg: .flash.text -16 B (-0.0%, 91,496 B / 3,342,304 B, total: 3% used)

qemu-armv8a

  • Code: .text.boardctl -20 B (-0.0%, 352,524 B)

qemu-intel64

  • Code: .text -10 B (-0.0%, 8,686,506 B)

rx65n-rsk2mb

  • ROM: .text -16 B (-0.0%, 89,324 B / 2,097,152 B, total: 4% used)

s698pm-dkit

  • Code: .text -16 B (-0.0%, 380,416 B)

No memory changes detected for:


Catch memory regressions in CI with MemBrowse. Free for open source.

@acassis
acassis merged commit 40848c9 into apache:master Oct 25, 2026
100 of 116 checks passed
casaroli pushed a commit to apache/nuttx-apps that referenced this pull request Oct 25, 2026
This reverts commit d9454d8.

apache/nuttx#20964 removed BOARDIOC_BUILTINS and struct boardioc_builtin_s,
so nxinit no longer builds in a protected build:

  init.c:214:29: error: storage size of 'builtin' isn't known
  init.c:218:12: error: 'BOARDIOC_BUILTINS' undeclared (first use in this function)

Assisted-by: Kiro:claude-opus-5.5
Signed-off-by: wangjianyu3 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants