Repository navigation
[components][lwp] fix signal ordering and ELF segment protection - #11895
BernardXiong wants to merge 3 commits into
Conversation
- keep FIFO order for signals carrying the same signal number - map ELF segments with permissions derived from p_flags - keep the scheduler usable while handling signals on RISC-V
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
🏷️ Tag: components_lwpReviewers: @xu18838022837 Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-01 00:52 CST)
📝 Review Instructions
|
- expand the protection flag checks to braced statements - no functional change
|
| static size_t elf_prot_from_pflags(uint32_t p_flags) | ||
| { | ||
| size_t prot = PROT_NONE; | ||
| if (p_flags & PF_R) | ||
| { | ||
| prot |= PROT_READ; | ||
| } | ||
| if (p_flags & PF_W) | ||
| { | ||
| prot |= PROT_WRITE; | ||
| } | ||
| if (p_flags & PF_X) | ||
| { | ||
| prot |= PROT_EXEC; | ||
| } | ||
| return prot; | ||
| } | ||
|
|
There was a problem hiding this comment.
这个在后续的:
rt-thread/components/lwp/lwp_user_mm.h
Lines 213 to 232 in ff82e23
不开启 LWP_USING_MPROTECT 会默认设置为 MMU_MAP_U_RWCB,此处是否需要添加 LWP_USING_MPROTECT 控制比较好一些
There was a problem hiding this comment.
并且原本 elf_file_mmap 的注释放到了elf_prot_from_pflags 前面了
There was a problem hiding this comment.
这里的 prot 只有在开启 LWP_USING_MPROTECT 时才真正生效:lwp_user_mm_attr_to_kernel() 在未开启 MPROTECT 时(lwp_user_mm.h 的 #else 分支)会忽略入参并统一返回 MMU_MAP_U_RWCB,所以映射行为和修改前完全一致,这里不需要再额外加 #ifdef 控制。
已在 commit 7fae086 的调用点补充注释说明这一点,避免后续读者误以为未开启 MPROTECT 时会被映射成只读/可执行。
There was a problem hiding this comment.
已修正(commit 7fae086):把 elf_prot_from_pflags() 移到 elf_file_mmap() 的 kernel-doc 注释之前,并给这个 helper 单独补了简短注释,elf_file_mmap() 的文档重新紧挨着函数。
Move the new elf_prot_from_pflags() helper above the kernel-doc block of elf_file_mmap() so the documentation stays attached to the function it describes. Also document that deriving the protection from p_flags is a no-op while LWP_USING_MPROTECT is disabled, because lwp_user_mm_attr_to_kernel() maps every attribute as MMU_MAP_U_RWCB. Co-Authored-By: Claude Code <noreply@anthropic.com>
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
Signals with the same number were inserted in reverse order, ELF segments were always mapped read-write regardless of p_flags, and RISC-V signal handling ran with interrupts disabled while taking sleeping locks.
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up