arch: enable ARCH_KERNEL_STACK support in protected builds#17984
Merged
GUIDINGLI merged 2 commits intoapache:masterfrom Jan 18, 2026
Merged
arch: enable ARCH_KERNEL_STACK support in protected builds#17984GUIDINGLI merged 2 commits intoapache:masterfrom
GUIDINGLI merged 2 commits intoapache:masterfrom
Conversation
Expand ARCH_KERNEL_STACK configuration to support both BUILD_KERNEL and BUILD_PROTECTED modes. Change Kconfig dependency from "depends on BUILD_KERNEL" to "depends on BUILD_KERNEL || BUILD_PROTECTED". Update pthread_create.c to remove redundant BUILD_KERNEL check when allocating kernel stacks with CONFIG_ARCH_KERNEL_STACK enabled. Enables protected builds to use separate kernel and user stacks for processes. Signed-off-by: hujun5 <hujun5@xiaomi.com>
Move kernel stack allocation from exec_module() (binary format execution) to nxtask_init() (task initialization) with proper type checking. Add conditional check to allocate kernel stack only for non-kernel tasks (ttype != TCB_FLAG_TTYPE_KERNEL). Enables kernel stack allocation for both exec'd tasks and regular task_create() calls in protected builds, allowing userspace to create tasks with proper kernel stack isolation. Signed-off-by: hujun5 <hujun5@xiaomi.com>
xiaoxiang781216
approved these changes
Jan 17, 2026
acassis
approved these changes
Jan 18, 2026
GUIDINGLI
approved these changes
Jan 18, 2026
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
Enable ARCH_KERNEL_STACK support in protected kernel builds (BUILD_PROTECTED) in addition to kernel-only builds (BUILD_KERNEL). The separate kernel stack feature is useful for both modes where address environments separate kernel and userspace memory. Update configuration and code to allow kernel stack allocation in protected builds, enabling proper kernel and user stack separation for protected mode processes.
Changes
arch/Kconfig:
BUILD_KERNELtoBUILD_KERNEL || BUILD_PROTECTEDsched/pthread/pthread_create.c:
CONFIG_BUILD_KERNELcheck from kernel stack allocation conditionalCONFIG_ARCH_ADDRENV && CONFIG_BUILD_KERNEL && CONFIG_ARCH_KERNEL_STACKtoCONFIG_ARCH_ADDRENV && CONFIG_ARCH_KERNEL_STACKBenefits & Technical Details
Testing
Impact