Repository navigation
system/nxinit: register g_builtins with the kernel under PROTECTED build - #3821
Closed
JianyuWang0623 wants to merge 1 commit into
Closed
JianyuWang0623 wants to merge 1 commit into
JianyuWang0623 wants to merge 1 commit into
Conversation
In PROTECTED builds g_builtins is linked only into the user blob, so the kernel-side builtin table stays empty and init.rc services fail to spawn with ENOENT. Register it via boardctl(BOARDIOC_BUILTINS) before starting any service. Assisted-by: OpenCode:claude-sonnet-5 Signed-off-by: wangjianyu3 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Under
CONFIG_BUILD_PROTECTED,nxinit'sinit_main()runs in user space while the binfmt builtin loader and BINFS run in kernel space. The builtin application table (g_builtins/g_builtin_count) is linked only into the user blob (nuttx_user) and is never present in the kernel image. As a result, any kernel-space lookup against that table — such as theposix_spawnp()call that starts theconsole shservice frominit.rc— fails withENOENT, because the kernel-sideg_builtins[]was never populated.NuttX already ships the fix for this gap:
include/nuttx/lib/builtin.hdocuments thatboardctl(BOARDIOC_BUILTINS)must be called by the application layer to register the table with the kernel. This change wires that call up ininit_main(), before any service is started. The block is guarded by#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_BUILTIN)and compiled out entirely for FLAT and KERNEL builds, which are unaffected (in FLAT, there is no separate address space; in KERNEL, user-space addresses cannot meaningfully be passed across the boundary in this way).nshis not affected by this problem:exec_builtin()has atask_spawn()fallback path that does not require a populated kernel-side table.Impact
Only affects
CONFIG_BUILD_PROTECTED && CONFIG_BUILTINbuilds. FLAT and KERNEL builds are not changed. The apache/nuttxrv-virt:pnshconfiguration (already switched to nxinit on master) currently fails to start its console service withError Starting service 'console': 2; this PR fixes that. A pending nuttx PR that switchesqemu-armv7rto nxinit also depends on this change.Testing
Host: Linux x86_64,
arm-none-eabi-gcc 10.3.1Target:
qemu-armv7r:pnsh(PROTECTED build)QEMU: 10.2.1,
-M virt -cpu cortex-r5fBefore this change: boot log prints
Error Starting service 'console': 2and the console service never starts.After this change, three consecutive runs:
init_main(PID 3, PPID 0) andsh(PID 4, PPID 3) confirm the expected parent-child relationship.qemu-armv7r:nsh(flat build): compiles cleanly with this change; the#ifguard excludes the new code entirely.rv-virt:pnsh: not built or run on this branch; it is known to exhibit the same failure on apache/nuttx master without this fix.