signal.rs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. use core::sync::atomic::{compiler_fence, Ordering};
  2. use core::{ffi::c_void, intrinsics::unlikely, mem::size_of};
  3. use defer::defer;
  4. use log::error;
  5. use system_error::SystemError;
  6. pub use crate::ipc::generic_signal::AtomicGenericSignal as AtomicSignal;
  7. pub use crate::ipc::generic_signal::GenericSigChildCode as SigChildCode;
  8. pub use crate::ipc::generic_signal::GenericSigSet as SigSet;
  9. pub use crate::ipc::generic_signal::GenericSignal as Signal;
  10. use crate::{
  11. arch::{
  12. fpu::FpState,
  13. interrupt::TrapFrame,
  14. process::table::{USER_CS, USER_DS},
  15. syscall::nr::SYS_RESTART_SYSCALL,
  16. CurrentIrqArch, MMArch,
  17. },
  18. exception::InterruptArch,
  19. ipc::{
  20. signal::{restore_saved_sigmask, set_current_blocked},
  21. signal_types::{
  22. PosixSigInfo, SaHandlerType, SigInfo, Sigaction, SigactionType, SignalArch, SignalFlags,
  23. },
  24. },
  25. mm::MemoryManagementArch,
  26. process::ProcessManager,
  27. syscall::user_access::UserBufferWriter,
  28. };
  29. /// 信号处理的栈的栈指针的最小对齐数量
  30. pub const STACK_ALIGN: u64 = 16;
  31. /// 信号最大值
  32. pub const MAX_SIG_NUM: usize = 64;
  33. bitflags! {
  34. #[repr(C,align(8))]
  35. #[derive(Default)]
  36. pub struct SigFlags:u32{
  37. const SA_NOCLDSTOP = 1;
  38. const SA_NOCLDWAIT = 2;
  39. const SA_SIGINFO = 4;
  40. const SA_ONSTACK = 0x08000000;
  41. const SA_RESTART = 0x10000000;
  42. const SA_NODEFER = 0x40000000;
  43. const SA_RESETHAND = 0x80000000;
  44. const SA_RESTORER =0x04000000;
  45. const SA_ALL = Self::SA_NOCLDSTOP.bits()|Self::SA_NOCLDWAIT.bits()|Self::SA_NODEFER.bits()|Self::SA_ONSTACK.bits()|Self::SA_RESETHAND.bits()|Self::SA_RESTART.bits()|Self::SA_SIGINFO.bits()|Self::SA_RESTORER.bits();
  46. }
  47. }
  48. #[repr(C, align(16))]
  49. #[derive(Debug, Clone, Copy)]
  50. pub struct SigFrame {
  51. // pub pedding: u64,
  52. /// 指向restorer的地址的指针。(该变量必须放在sigframe的第一位,因为这样才能在handler返回的时候,跳转到对应的代码,执行sigreturn)
  53. pub ret_code_ptr: *mut core::ffi::c_void,
  54. pub handler: *mut c_void,
  55. pub info: PosixSigInfo,
  56. pub context: SigContext,
  57. }
  58. #[repr(C, align(16))]
  59. #[derive(Debug, Clone, Copy)]
  60. pub struct SigContext {
  61. /// sigcontext的标志位
  62. pub sc_flags: u64,
  63. pub sc_stack: X86SigStack, // 信号处理程序备用栈信息
  64. pub frame: TrapFrame, // 暂存的系统调用/中断返回时,原本要弹出的内核栈帧
  65. // pub trap_num: u64, // 用来保存线程结构体中的trap_num字段
  66. pub oldmask: SigSet, // 暂存的执行信号处理函数之前的,被设置block的信号
  67. pub cr2: u64, // 用来保存线程结构体中的cr2字段
  68. // pub err_code: u64, // 用来保存线程结构体中的err_code字段
  69. pub reserved_for_x87_state: Option<FpState>,
  70. pub reserved: [u64; 8],
  71. }
  72. impl SigContext {
  73. /// 设置sigcontext
  74. ///
  75. /// ## 参数
  76. ///
  77. /// - `mask` 要被暂存的信号mask标志位
  78. /// - `regs` 进入信号处理流程前,Restore all要弹出的内核栈栈帧
  79. ///
  80. /// ## 返回值
  81. ///
  82. /// - `Ok(0)`
  83. /// - `Err(Systemerror)` (暂时不会返回错误)
  84. pub fn setup_sigcontext(
  85. &mut self,
  86. mask: &SigSet,
  87. frame: &TrapFrame,
  88. ) -> Result<i32, SystemError> {
  89. //TODO 引入线程后补上
  90. // let current_thread = ProcessManager::current_pcb().thread;
  91. let pcb = ProcessManager::current_pcb();
  92. let mut archinfo_guard = pcb.arch_info_irqsave();
  93. self.oldmask = *mask;
  94. self.frame = *frame;
  95. // context.trap_num = unsafe { (*current_thread).trap_num };
  96. // context.err_code = unsafe { (*current_thread).err_code };
  97. // context.cr2 = unsafe { (*current_thread).cr2 };
  98. self.reserved_for_x87_state = *archinfo_guard.fp_state();
  99. // 保存完毕后,清空fp_state,以免下次save的时候,出现SIMD exception
  100. archinfo_guard.clear_fp_state();
  101. return Ok(0);
  102. }
  103. /// 指定的sigcontext恢复到当前进程的内核栈帧中,并将当前线程结构体的几个参数进行恢复
  104. ///
  105. /// ## 参数
  106. /// - `frame` 目标栈帧(也就是把context恢复到这个栈帧中)
  107. ///
  108. /// ##返回值
  109. /// - `true` -> 成功恢复
  110. /// - `false` -> 执行失败
  111. pub fn restore_sigcontext(&mut self, frame: &mut TrapFrame) -> bool {
  112. let guard = ProcessManager::current_pcb();
  113. let mut arch_info = guard.arch_info_irqsave();
  114. (*frame) = self.frame;
  115. // (*current_thread).trap_num = (*context).trap_num;
  116. *arch_info.cr2_mut() = self.cr2 as usize;
  117. // (*current_thread).err_code = (*context).err_code;
  118. // 如果当前进程有fpstate,则将其恢复到pcb的fp_state中
  119. *arch_info.fp_state_mut() = self.reserved_for_x87_state;
  120. arch_info.restore_fp_state();
  121. return true;
  122. }
  123. }
  124. /// @brief 信号处理备用栈的信息
  125. #[allow(dead_code)]
  126. #[derive(Debug, Clone, Copy)]
  127. pub struct X86SigStack {
  128. pub sp: *mut c_void,
  129. pub flags: u32,
  130. pub size: u32,
  131. pub fpstate: FpState,
  132. }
  133. unsafe fn do_signal(frame: &mut TrapFrame, got_signal: &mut bool) {
  134. let pcb = ProcessManager::current_pcb();
  135. let siginfo = pcb.try_siginfo_irqsave(5);
  136. if unlikely(siginfo.is_none()) {
  137. return;
  138. }
  139. let siginfo_read_guard = siginfo.unwrap();
  140. // 检查sigpending是否为0
  141. if siginfo_read_guard.sig_pending().signal().bits() == 0 || !frame.is_from_user() {
  142. // 若没有正在等待处理的信号,或者将要返回到的是内核态,则返回
  143. return;
  144. }
  145. let mut sig_number: Signal;
  146. let mut info: Option<SigInfo>;
  147. let mut sigaction: Option<Sigaction>;
  148. let sig_block: SigSet = *siginfo_read_guard.sig_blocked();
  149. drop(siginfo_read_guard);
  150. // x86_64 上不再需要 sig_struct 自旋锁
  151. let siginfo_mut = pcb.try_siginfo_mut(5);
  152. if unlikely(siginfo_mut.is_none()) {
  153. return;
  154. }
  155. let mut siginfo_mut_guard = siginfo_mut.unwrap();
  156. loop {
  157. (sig_number, info) = siginfo_mut_guard.dequeue_signal(&sig_block, &pcb);
  158. // 如果信号非法,则直接返回
  159. if sig_number == Signal::INVALID {
  160. return;
  161. }
  162. let sa = pcb.sighand().handler(sig_number).unwrap();
  163. match sa.action() {
  164. SigactionType::SaHandler(action_type) => match action_type {
  165. SaHandlerType::Error => {
  166. error!("Trying to handle a Sigerror on Process:{:?}", pcb.raw_pid());
  167. return;
  168. }
  169. SaHandlerType::Default => {
  170. sigaction = Some(sa);
  171. }
  172. SaHandlerType::Ignore => continue,
  173. SaHandlerType::Customized(_) => {
  174. sigaction = Some(sa);
  175. }
  176. },
  177. SigactionType::SaSigaction(_) => todo!(),
  178. }
  179. /*
  180. * Global init gets no signals it doesn't want.
  181. * Container-init gets no signals it doesn't want from same
  182. * container.
  183. *
  184. * Note that if global/container-init sees a sig_kernel_only()
  185. * signal here, the signal must have been generated internally
  186. * or must have come from an ancestor namespace. In either
  187. * case, the signal cannot be dropped.
  188. */
  189. // todo: https://code.dragonos.org.cn/xref/linux-6.6.21/include/linux/signal.h?fi=sig_kernel_only#444
  190. if ProcessManager::current_pcb()
  191. .sighand()
  192. .flags_contains(SignalFlags::UNKILLABLE)
  193. && !sig_number.kernel_only()
  194. {
  195. continue;
  196. }
  197. if sigaction.is_some() {
  198. break;
  199. }
  200. }
  201. let oldset = *siginfo_mut_guard.sig_blocked();
  202. //避免死锁
  203. drop(siginfo_mut_guard);
  204. // no sig_struct guard to drop
  205. drop(pcb);
  206. // 做完上面的检查后,开中断
  207. CurrentIrqArch::interrupt_enable();
  208. if sigaction.is_none() {
  209. return;
  210. }
  211. *got_signal = true;
  212. let mut sigaction = sigaction.unwrap();
  213. // 注意!由于handle_signal里面可能会退出进程,
  214. // 因此这里需要检查清楚:上面所有的锁、arc指针都被释放了。否则会产生资源泄露的问题!
  215. let res: Result<i32, SystemError> =
  216. handle_signal(sig_number, &mut sigaction, &info.unwrap(), &oldset, frame);
  217. compiler_fence(Ordering::SeqCst);
  218. if res.is_err() {
  219. error!(
  220. "Error occurred when handling signal: {}, pid={:?}, errcode={:?}",
  221. sig_number as i32,
  222. ProcessManager::current_pcb().raw_pid(),
  223. res.as_ref().unwrap_err()
  224. );
  225. }
  226. }
  227. fn try_restart_syscall(frame: &mut TrapFrame) {
  228. defer!({
  229. // 如果没有信号需要传递,我们只需恢复保存的信号掩码
  230. restore_saved_sigmask();
  231. });
  232. if unsafe { frame.syscall_nr() }.is_none() {
  233. return;
  234. }
  235. let syscall_err = unsafe { frame.syscall_error() };
  236. if syscall_err.is_none() {
  237. return;
  238. }
  239. let syscall_err = syscall_err.unwrap();
  240. let mut restart = false;
  241. match syscall_err {
  242. SystemError::ERESTARTSYS | SystemError::ERESTARTNOHAND | SystemError::ERESTARTNOINTR => {
  243. frame.rax = frame.errcode;
  244. frame.rip -= 2;
  245. restart = true;
  246. }
  247. SystemError::ERESTART_RESTARTBLOCK => {
  248. frame.rax = SYS_RESTART_SYSCALL as u64;
  249. frame.rip -= 2;
  250. restart = true;
  251. }
  252. _ => {}
  253. }
  254. log::debug!("try restart syscall: {:?}", restart);
  255. }
  256. pub struct X86_64SignalArch;
  257. impl SignalArch for X86_64SignalArch {
  258. /// 处理信号,并尝试重启系统调用
  259. ///
  260. /// 参考: https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/signal.c#865
  261. unsafe fn do_signal_or_restart(frame: &mut TrapFrame) {
  262. let mut got_signal = false;
  263. do_signal(frame, &mut got_signal);
  264. if got_signal {
  265. return;
  266. }
  267. try_restart_syscall(frame);
  268. }
  269. fn sys_rt_sigreturn(trap_frame: &mut TrapFrame) -> u64 {
  270. let frame = (trap_frame.rsp as usize - size_of::<u64>()) as *mut SigFrame;
  271. // 如果当前的rsp不来自用户态,则认为产生了错误(或被SROP攻击)
  272. if UserBufferWriter::new(frame, size_of::<SigFrame>(), true).is_err() {
  273. error!("rsp doesn't from user level");
  274. let _r = crate::ipc::kill::kill_process(
  275. ProcessManager::current_pcb().raw_pid(),
  276. Signal::SIGSEGV,
  277. )
  278. .map_err(|e| e.to_posix_errno());
  279. return trap_frame.rax;
  280. }
  281. let mut sigmask: SigSet = unsafe { (*frame).context.oldmask };
  282. set_current_blocked(&mut sigmask);
  283. // 从用户栈恢复sigcontext
  284. if !unsafe { &mut (*frame).context }.restore_sigcontext(trap_frame) {
  285. error!("unable to restore sigcontext");
  286. let _r = crate::ipc::kill::kill_process(
  287. ProcessManager::current_pcb().raw_pid(),
  288. Signal::SIGSEGV,
  289. )
  290. .map_err(|e| e.to_posix_errno());
  291. // 如果这里返回 err 值的话会丢失上一个系统调用的返回值
  292. }
  293. // 由于系统调用的返回值会被系统调用模块被存放在rax寄存器,因此,为了还原原来的那个系统调用的返回值,我们需要在这里返回恢复后的rax的值
  294. return trap_frame.rax;
  295. }
  296. }
  297. /// @brief 真正发送signal,执行自定义的处理函数
  298. ///
  299. /// @param sig 信号number
  300. /// @param sigaction 信号响应动作
  301. /// @param info 信号信息
  302. /// @param oldset
  303. /// @param regs 之前的系统调用将要返回的时候,要弹出的栈帧的拷贝
  304. ///
  305. /// @return Result<0,SystemError> 若Error, 则返回错误码,否则返回Ok(0)
  306. ///
  307. /// 参考 https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/signal.c#787
  308. #[inline(never)]
  309. fn handle_signal(
  310. sig: Signal,
  311. sigaction: &mut Sigaction,
  312. info: &SigInfo,
  313. oldset: &SigSet,
  314. frame: &mut TrapFrame,
  315. ) -> Result<i32, SystemError> {
  316. if unsafe { frame.syscall_nr() }.is_some() {
  317. if let Some(syscall_err) = unsafe { frame.syscall_error() } {
  318. match syscall_err {
  319. SystemError::ERESTARTNOHAND => {
  320. frame.rax = SystemError::EINTR.to_posix_errno() as i64 as u64;
  321. }
  322. SystemError::ERESTARTSYS => {
  323. if !sigaction.flags().contains(SigFlags::SA_RESTART) {
  324. frame.rax = SystemError::EINTR.to_posix_errno() as i64 as u64;
  325. } else {
  326. frame.rax = frame.errcode;
  327. frame.rip -= 2;
  328. }
  329. }
  330. SystemError::ERESTART_RESTARTBLOCK => {
  331. // 为了让带 SA_RESTART 的时序(例如 clock_nanosleep 相对睡眠)也能自动重启,
  332. // 当 SA_RESTART 设置时,按 ERESTARTSYS 的语义处理;否则返回 EINTR。
  333. if !sigaction.flags().contains(SigFlags::SA_RESTART) {
  334. frame.rax = SystemError::EINTR.to_posix_errno() as i64 as u64;
  335. } else {
  336. frame.rax = frame.errcode;
  337. frame.rip -= 2;
  338. }
  339. }
  340. SystemError::ERESTARTNOINTR => {
  341. frame.rax = frame.errcode;
  342. frame.rip -= 2;
  343. }
  344. _ => {}
  345. }
  346. }
  347. }
  348. // 设置栈帧
  349. return setup_frame(sig, sigaction, info, oldset, frame);
  350. }
  351. /// @brief 在用户栈上开辟一块空间,并且把内核栈的栈帧以及需要在用户态执行的代码给保存进去。
  352. ///
  353. /// @param regs 进入信号处理流程前,Restore all要弹出的内核栈栈帧
  354. fn setup_frame(
  355. sig: Signal,
  356. sigaction: &mut Sigaction,
  357. info: &SigInfo,
  358. oldset: &SigSet,
  359. trap_frame: &mut TrapFrame,
  360. ) -> Result<i32, SystemError> {
  361. let ret_code_ptr: *mut c_void;
  362. let temp_handler: *mut c_void;
  363. match sigaction.action() {
  364. SigactionType::SaHandler(handler_type) => match handler_type {
  365. SaHandlerType::Default => {
  366. sig.handle_default();
  367. return Ok(0);
  368. }
  369. SaHandlerType::Customized(handler) => {
  370. // 如果handler位于内核空间
  371. if handler >= MMArch::USER_END_VADDR {
  372. // 如果当前是SIGSEGV,则采用默认函数处理
  373. if sig == Signal::SIGSEGV {
  374. sig.handle_default();
  375. return Ok(0);
  376. } else {
  377. error!("attempting to execute a signal handler from kernel");
  378. sig.handle_default();
  379. return Err(SystemError::EINVAL);
  380. }
  381. } else {
  382. // 为了与Linux的兼容性,64位程序必须由用户自行指定restorer
  383. if sigaction.flags().contains(SigFlags::SA_RESTORER) {
  384. ret_code_ptr = sigaction.restorer().unwrap().data() as *mut c_void;
  385. } else {
  386. error!(
  387. "pid-{:?} forgot to set SA_FLAG_RESTORER for signal {:?}",
  388. ProcessManager::current_pcb().raw_pid(),
  389. sig as i32
  390. );
  391. let r = crate::ipc::kill::kill_process(
  392. ProcessManager::current_pcb().raw_pid(),
  393. Signal::SIGSEGV,
  394. );
  395. if r.is_err() {
  396. error!("In setup_sigcontext: generate SIGSEGV signal failed");
  397. }
  398. return Err(SystemError::EINVAL);
  399. }
  400. if sigaction.restorer().is_none() {
  401. error!(
  402. "restorer in process:{:?} is not defined",
  403. ProcessManager::current_pcb().raw_pid()
  404. );
  405. return Err(SystemError::EINVAL);
  406. }
  407. temp_handler = handler.data() as *mut c_void;
  408. }
  409. }
  410. SaHandlerType::Ignore => {
  411. return Ok(0);
  412. }
  413. _ => {
  414. return Err(SystemError::EINVAL);
  415. }
  416. },
  417. SigactionType::SaSigaction(_) => {
  418. //TODO 这里应该是可以恢复栈的,等后续来做
  419. error!("trying to recover from sigaction type instead of handler");
  420. return Err(SystemError::EINVAL);
  421. }
  422. }
  423. let frame: *mut SigFrame = get_stack(sigaction, trap_frame, size_of::<SigFrame>());
  424. // debug!("frame=0x{:016x}", frame as usize);
  425. // 要求这个frame的地址位于用户空间,因此进行校验
  426. let r: Result<UserBufferWriter<'_>, SystemError> =
  427. UserBufferWriter::new(frame, size_of::<SigFrame>(), true);
  428. if r.is_err() {
  429. // 如果地址区域位于内核空间,则直接报错
  430. // todo: 生成一个sigsegv
  431. let r = crate::ipc::kill::kill_process(
  432. ProcessManager::current_pcb().raw_pid(),
  433. Signal::SIGSEGV,
  434. );
  435. if r.is_err() {
  436. error!("In setup frame: generate SIGSEGV signal failed");
  437. }
  438. error!("In setup frame: access check failed");
  439. return Err(SystemError::EFAULT);
  440. }
  441. // 将siginfo拷贝到用户栈
  442. info.copy_posix_siginfo_to_user(unsafe { &mut ((*frame).info) as *mut PosixSigInfo })
  443. .map_err(|e| -> SystemError {
  444. let r = crate::ipc::kill::kill_process(
  445. ProcessManager::current_pcb().raw_pid(),
  446. Signal::SIGSEGV,
  447. );
  448. if r.is_err() {
  449. error!("In copy_posix_siginfo_to_user: generate SIGSEGV signal failed");
  450. }
  451. return e;
  452. })?;
  453. // todo: 拷贝处理程序备用栈的地址、大小、ss_flags
  454. unsafe {
  455. (*frame)
  456. .context
  457. .setup_sigcontext(oldset, trap_frame)
  458. .map_err(|e: SystemError| -> SystemError {
  459. let r = crate::ipc::kill::kill_process(
  460. ProcessManager::current_pcb().raw_pid(),
  461. Signal::SIGSEGV,
  462. );
  463. if r.is_err() {
  464. error!("In setup_sigcontext: generate SIGSEGV signal failed");
  465. }
  466. return e;
  467. })?
  468. };
  469. unsafe {
  470. // 在开头检验过sigaction.restorer是否为空了,实际上libc会保证 restorer始终不为空
  471. (*frame).ret_code_ptr = ret_code_ptr;
  472. }
  473. unsafe { (*frame).handler = temp_handler };
  474. // 传入信号处理函数的第一个参数
  475. trap_frame.rdi = sig as u64;
  476. trap_frame.rsi = unsafe { &(*frame).info as *const PosixSigInfo as u64 };
  477. trap_frame.rsp = frame as u64;
  478. trap_frame.rip = unsafe { (*frame).handler as u64 };
  479. // 设置cs和ds寄存器
  480. trap_frame.cs = (USER_CS.bits() | 0x3) as u64;
  481. trap_frame.ds = (USER_DS.bits() | 0x3) as u64;
  482. // 禁用中断
  483. // trap_frame.rflags &= !(0x200);
  484. return Ok(0);
  485. }
  486. #[inline(always)]
  487. fn get_stack(sigaction: &mut Sigaction, frame: &TrapFrame, size: usize) -> *mut SigFrame {
  488. // TODO:在 linux 中会根据 Sigaction 中的一个flag 的值来确定是否使用pcb中的 signal 处理程序备用堆栈,现在的
  489. // pcb中也没有这个备用堆栈
  490. // 目前对于备用栈的实现不完善, 需要补全, 来自https://code.dragonos.org.cn/xref/linux-6.1.9/arch/x86/kernel/signal.c#241
  491. let mut _entering_altstack = false;
  492. let binding = ProcessManager::current_pcb();
  493. let stack = binding.sig_altstack();
  494. let mut _rsp: usize = 0;
  495. // 检查是否使用备用栈
  496. if sigaction.flags().contains(SigFlags::SA_ONSTACK) {
  497. // 这里还需要检查当前是否在信号栈上, 未实现
  498. _rsp = stack.sp + stack.size as usize - size; // 栈指向顶部, 与 else 中一样, 需要减 size
  499. _entering_altstack = true;
  500. } else {
  501. // 这里 else 的判断条件也没实现全, 同样未实现, 应该使用 else if
  502. // 默认使用 用户栈的栈顶指针-128字节的红区-sigframe的大小 并且16字节对齐
  503. _rsp = (frame.rsp as usize) - 128 - size;
  504. }
  505. // 按照要求进行对齐,别问为什么减8,不减8就是错的,可以看
  506. // https://sourcegraph.com/github.com/torvalds/linux@dd72f9c7e512da377074d47d990564959b772643/-/blob/arch/x86/kernel/signal.c?L124
  507. // 我猜测是跟x86汇编的某些弹栈行为有关系,它可能会出于某种原因递增 rsp
  508. _rsp &= (!(STACK_ALIGN - 1)) as usize - 8;
  509. // rsp &= (!(STACK_ALIGN - 1)) as usize;
  510. return _rsp as *mut SigFrame;
  511. }