-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat: add support for restartable system calls on RISC-V64 #10520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -258,14 +258,48 @@ struct signal_ucontext | |||||
struct rt_hw_stack_frame frame; | ||||||
}; | ||||||
|
||||||
void *arch_signal_ucontext_restore(rt_base_t user_sp) | ||||||
void arch_syscall_restart(void *sp, void *ksp); | ||||||
|
||||||
void arch_signal_check_erestart(void *eframe, void *ksp) | ||||||
{ | ||||||
struct rt_hw_stack_frame *exp_frame = eframe; | ||||||
long rc = exp_frame->a0; | ||||||
long sys_id = exp_frame->a7; | ||||||
|
||||||
(void)sys_id; | ||||||
|
||||||
if (rc == -ERESTART) | ||||||
{ | ||||||
LOG_D("%s(rc=%ld,sys_id=%ld,pid=%d)", __func__, rc, sys_id, lwp_self()->pid); | ||||||
LOG_D("%s: restart rc = %ld", lwp_get_syscall_name(sys_id), rc); | ||||||
|
||||||
/* t0 stores the copy of user's first syscall argument */ | ||||||
exp_frame->a0 = exp_frame->t0; | ||||||
/* adjust for epc auto-increment in syscall_handler */ | ||||||
exp_frame->epc -= 4; | ||||||
/* copy exception frame from user stack to kernel stack */ | ||||||
lwp_memcpy(ksp - sizeof(*exp_frame), exp_frame, sizeof(*exp_frame)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Extra space between function arguments. Remove the extra space after the comma for consistent formatting. 函数参数间有多余空格。移除逗号后的多余空格以保持格式一致。
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
|
||||||
arch_syscall_restart(exp_frame, ksp); | ||||||
} | ||||||
|
||||||
return; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant return statement at the end of a void function. This return statement can be removed for cleaner code. 在void函数末尾的冗余return语句。可以移除此return语句使代码更简洁。
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
} | ||||||
|
||||||
static void arch_signal_post_action(struct signal_ucontext *new_sp, rt_base_t kernel_sp) | ||||||
{ | ||||||
arch_signal_check_erestart(&new_sp->frame, (void *)kernel_sp); | ||||||
} | ||||||
|
||||||
void *arch_signal_ucontext_restore(rt_base_t user_sp, rt_base_t kernel_sp) | ||||||
{ | ||||||
struct signal_ucontext *new_sp; | ||||||
new_sp = (void *)user_sp; | ||||||
|
||||||
if (lwp_user_accessable(new_sp, sizeof(*new_sp))) | ||||||
{ | ||||||
lwp_thread_signal_mask(rt_thread_self(), LWP_SIG_MASK_CMD_SET_MASK, &new_sp->save_sigmask, RT_NULL); | ||||||
arch_signal_post_action(new_sp, kernel_sp); | ||||||
} | ||||||
else | ||||||
{ | ||||||
|
@@ -320,8 +354,12 @@ void *arch_signal_ucontext_save(int signo, siginfo_t *psiginfo, | |||||
|
||||||
void arch_syscall_set_errno(void *eframe, int expected, int code) | ||||||
{ | ||||||
/* NO support */ | ||||||
return ; | ||||||
struct rt_hw_stack_frame *exp_frame = eframe; | ||||||
|
||||||
if (exp_frame->a0 == -expected) | ||||||
{ | ||||||
exp_frame->a0 = -code; | ||||||
} | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -354,4 +392,4 @@ int arch_backtrace_uthread(rt_thread_t thread) | |||||
return -1; | ||||||
} | ||||||
return -1; | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sys_id variable is assigned but only used to suppress unused variable warnings. Consider removing the variable assignment if it's truly unused, or use it in the LOG_D statements that follow.
sys_id变量被赋值但仅用于抑制未使用变量警告。如果确实未使用,考虑移除变量赋值,或在后续的LOG_D语句中使用它。
Copilot uses AI. Check for mistakes.