Skip to content

refactor(futex): 迁移futex系统调用到syscall table机制#1320

Merged
fslongjin merged 1 commit intoDragonOS-Community:masterfrom
fslongjin:refactor-move-futex-syscall-to-table
Oct 10, 2025
Merged

refactor(futex): 迁移futex系统调用到syscall table机制#1320
fslongjin merged 1 commit intoDragonOS-Community:masterfrom
fslongjin:refactor-move-futex-syscall-to-table

Conversation

@fslongjin
Copy link
Member

  • 将futex系统调用从通用系统调用模块中分离
  • 为futex和robust futex创建独立的系统调用处理器

- 将futex系统调用从通用系统调用模块中分离
- 为futex和robust futex创建独立的系统调用处理器

Signed-off-by: longjin <longjin@DragonOS.org>
Copilot AI review requested due to automatic review settings October 10, 2025 14:49
@fslongjin fslongjin merged commit bc7c38b into DragonOS-Community:master Oct 10, 2025
12 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the futex system call implementation by migrating it from the general syscall module to a dedicated syscall table mechanism. The change separates futex functionality into specialized handlers while maintaining the same API and functionality.

  • Migrates futex, set_robust_list, and get_robust_list system calls to dedicated handlers
  • Creates independent syscall handlers implementing the Syscall trait for better modularity
  • Removes futex-related code from the general syscall dispatcher

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
kernel/src/syscall/mod.rs Removes futex-related imports and syscall cases from the general dispatcher
kernel/src/libs/futex/syscall/sys_robust_futex.rs Implements dedicated handlers for set_robust_list and get_robust_list syscalls
kernel/src/libs/futex/syscall/sys_futex.rs Implements dedicated handler for the futex syscall with complete functionality
kernel/src/libs/futex/syscall/mod.rs Module declaration for the new syscall handlers
kernel/src/libs/futex/syscall.rs Removes old futex implementation from the general syscall module
kernel/src/driver/base/kobject.rs Updates lifetime annotations for lock guard methods
kernel/src/arch/x86_64/driver/rtc.rs Updates lifetime annotations for lock guard methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

let reader = UserBufferReader::new(
utime as *const PosixTimeSpec,
core::mem::size_of::<PosixTimeSpec>(),
frame.is_from_user(),
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frame.is_from_user() call suggests context-dependent behavior, but this parameter should be validated. Consider adding a comment explaining when this would be false and ensuring the behavior is correct for kernel-space calls.

Copilot uses AI. Check for mistakes.
let len = Self::len(args);

// 判断用户空间地址的合法性
verify_area(head, core::mem::size_of::<u32>())?;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verification uses size_of::<u32>() but the comment mentions *const PosixRobustListHead. The size validation should match the actual structure being accessed, not a u32.

Suggested change
verify_area(head, core::mem::size_of::<u32>())?;
verify_area(head, core::mem::size_of::<crate::libs::futex::futex::RobustListHead>())?;

Copilot uses AI. Check for mistakes.
Comment on lines +100 to +101
verify_area(head, core::mem::size_of::<u32>())?;
verify_area(len_ptr, core::mem::size_of::<u32>())?;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the set_robust_list handler, the verification uses size_of::<u32>() but should use the correct sizes for PosixRobustListHead pointer and usize respectively.

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +136
verify_area(uaddr, core::mem::size_of::<u32>())?;
verify_area(uaddr2, core::mem::size_of::<u32>())?;
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verification of uaddr2 occurs unconditionally, but some futex operations don't use uaddr2. Consider moving this verification to only the operations that actually use the second address to avoid unnecessary validation.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants