hujun260 opened a new pull request, #17984:
URL: https://github.com/apache/nuttx/pull/17984

   ## 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**:
     - Change ARCH_KERNEL_STACK configuration dependency from `BUILD_KERNEL` to 
`BUILD_KERNEL || BUILD_PROTECTED`
     - Enables kernel stack allocation in both kernel-only and protected build 
modes
   
   - **sched/pthread/pthread_create.c**:
     - Remove redundant `CONFIG_BUILD_KERNEL` check from kernel stack 
allocation conditional
     - Change condition from `CONFIG_ARCH_ADDRENV && CONFIG_BUILD_KERNEL && 
CONFIG_ARCH_KERNEL_STACK` to `CONFIG_ARCH_ADDRENV && CONFIG_ARCH_KERNEL_STACK`
     - Allows kernel stack allocation whenever CONFIG_ARCH_KERNEL_STACK is 
enabled, regardless of build mode
   
   ## Benefits & Technical Details
   
   - **Protected build support**: Separate kernel and user stacks now work in 
protected mode
   - **Stack isolation**: Improves security by isolating kernel stack from 
userspace
   - **Configuration flexibility**: ARCH_KERNEL_STACK no longer tied 
exclusively to BUILD_KERNEL
   - **Code simplification**: Removes unnecessary BUILD_KERNEL coupling in 
pthread code
   - **Consistent behavior**: Same kernel/user stack separation available in 
both modes
   
   ## Testing
   
   - Verified CONFIG_ARCH_KERNEL_STACK is available when CONFIG_BUILD_PROTECTED 
is enabled
   - Confirmed kernel stacks are properly allocated for pthreads in protected 
mode
   - Tested pthread creation with separate kernel and user stacks in protected 
builds
   - Validated kernel stack isolation prevents userspace code from accessing 
kernel stack
   - Confirmed no regressions in existing BUILD_KERNEL configurations
   
   ## Impact
   
   - **Compatibility**: Fully backward compatible, extends existing feature
   - **Configuration**: Enables new configuration combinations for protected 
builds
   - **Scope**: Affects protected mode process creation and kernel stack 
management
   - **Architecture**: Applies to all architectures supporting 
ARCH_KERNEL_STACK and address environments


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to