1 #![allow(dead_code)] 2 use crate::include::bindings::bindings::pt_regs; 3 4 /// @brief 判断给定的栈帧是否来自用户态 5 /// 判断方法为:根据代码段选择子是否具有ring3的访问权限(低2bit均为1) user_mode(regs: *const pt_regs) -> bool6pub fn user_mode(regs: *const pt_regs) -> bool { 7 if (unsafe { (*regs).cs } & 0x3) != 0 { 8 return true; 9 } else { 10 return false; 11 } 12 } 13