Commit cb62374
authored
fix(syscall): 修复cputime, sys_rt_sigtimedwait and sys_rt_sigreturn (#1406)
1. **修复:** 进程 CPU 时间统UserUContext 计精度,将统计基准调整为扣除 IRQ 和 Steal 时间后的净时间(accounted_cputime),避免将硬件中断处理时间错误计入进程的 utime/stime
2. **修复:** `sys_rt_sigtimedwait`:
- 修复了信号等待逻辑,确保即使 等待信号集 为空也能正确进入 do_kernel_rt_sigtimedwait,符合 Linux 行为。
- 修复潜在的无限睡眠问题:当线程被非目标信号或非超时事件唤醒时,将正确返回 EINTR,避免进程一直挂起。
- 修复了bitflags错误移除的bug,应该使用remove()。
3. **修复:** `sys_rt_sigreturn:`:
- 当从信号处理函数返回用户态时,内核错误地使用 sysretq 来处理 sys_rt_sigreturn 的返回,%rcx 和 %r11 这两个寄存器被意外破坏。
- 修复:如果待恢复的 %rcx / %r11 与 sysretq 的行为冲突,则强制跳转到 .L_syscall_must_use_iret 分支,使用 iretq 指令精确恢复完整的上下文。
TODO: 目标线程的 TGID 没有正确设置为 leader 的 PID,导致还有两个sys_rt_sigtimedwait的测例无法通过。
```sh
Value of: tgkill(getpid(), tid, kSigno)
Expected: not -1 (success)
Actual: -1 (of type int), with errno PosixError(errno=3 No such process)
```
---------
Signed-off-by: aLinChe <[email protected]>1 parent a69dad1 commit cb62374
File tree
6 files changed
+33
-19
lines changed- kernel/src
- arch/x86_64/asm
- ipc/syscall
- sched
- user/apps/tests/syscall/gvisor
- blocklists
6 files changed
+33
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
410 | 415 | | |
411 | 416 | | |
412 | 417 | | |
| |||
415 | 420 | | |
416 | 421 | | |
417 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
67 | 65 | | |
68 | 66 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | 67 | | |
75 | 68 | | |
76 | 69 | | |
| |||
134 | 127 | | |
135 | 128 | | |
136 | 129 | | |
137 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
138 | 137 | | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| 91 | + | |
| 92 | + | |
91 | 93 | | |
92 | | - | |
| 94 | + | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
95 | 97 | | |
96 | | - | |
| 98 | + | |
97 | 99 | | |
98 | | - | |
99 | | - | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
| |||
This file was deleted.
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
0 commit comments