-
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,50 @@ 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(*eframe), eframe, sizeof(*eframe)); | ||||
|
||||
arch_syscall_restart(eframe, 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. [nitpick] The explicit
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); | ||||
|
||||
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. [nitpick] The explicit
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
} | ||||
|
||||
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,7 +356,13 @@ void *arch_signal_ucontext_save(int signo, siginfo_t *psiginfo, | |||
|
||||
void arch_syscall_set_errno(void *eframe, int expected, int code) | ||||
{ | ||||
/* NO support */ | ||||
struct rt_hw_stack_frame *exp_frame = eframe; | ||||
|
||||
if (exp_frame->a0 == -expected) | ||||
{ | ||||
exp_frame->a0 = -code; | ||||
} | ||||
|
||||
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. [nitpick] The explicit
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||
} | ||||
|
||||
|
@@ -354,4 +396,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.
Using
sizeof(*eframe)
whereeframe
is avoid*
parameter will not give the correct size. The size should besizeof(struct rt_hw_stack_frame)
since that's the actual type being copied.Copilot uses AI. Check for mistakes.